Using Grunt in the framework

Common commands

grunt dev
Cleans out the build, compiles with source maps, and sets file watchers.

grunt diff
Use as an alternative to the above. Doesn't set watchers, but only compiles the files that have changed.

grunt server
Starts a local server and opens a browser. Use to view your framework course.

grunt server-scorm
Same as above, but provides a dummy SCORM interface to allow you to test the tracking of your course.

grunt build
Cleans and compiles. Reserve for use before production/going-live.

ctrl + c
This is not a Grunt command, but a generic console command. You'll want to use it to cancel the server you started or to interrupt any other task you ran.

Find the full list of commands in the Adapt framework repository or by running grunt help in the root of your framework installation. Some of the commands listed are not intended to be run individually from the command line. They are used by other command line tasks or by the Adapt authoring tool (AT). Because the framework is the engine of the AT, Grunt is also used by the authoring tool. Grunt tasks are triggered by the AT's user interface, for example, when you click "Preview" or "Publish course". Attempting to use these framework commands on the AT will be unsuccessful and could lead to frustrating problems.

What is Grunt?

Grunt is a task runner. It's software that automates repetitive tasks.

The pieces of an Adapt course—JSON, Less, media assets, JavaScript plugins—are assembled and optimized by Grunt. Adapt uses it for such things as compiling code, running a local server, and exporting and importing text data for translations.

Two parts are required to run Grunt: the CLI and the task runner. Grunt-CLI runs the local installation of the Grunt task runner. Separating these roles permits different versions of the task runner to coexist on the same computer. You can read more here: https://gruntjs.com/getting-started.

When you get ready to create your very first Adapt module using the framework, you'll need to install the Grunt-CLI. If you install it globally (with the -g flag), you won't have to install it with every course you create:
npm install -g grunt-cli
Still you must install the Grunt task runner with every framework installation:
npm install grunt

No matter how you get the framework downloaded to your computer, it will include a folder and a couple of files with "grunt" in their names. These are resources used by the Grunt task runner and do not indicate that Grunt has been installed. If Grunt has been installed, your command line (i.e., cmd, prompt, console, terminal) will recognize the grunt command. Open your command line and navigate into the root folder of your framework project (the folder that contains Gruntfile.js.). Run this command: grunt
If Grunt is installed, the command will be treated as grunt help as will list the Grunt commands used by the Adapt framework.

Alternative to Grunt

Kineo's adapt-rub-cli uses and extends the Grunt files bundled with the framework. Features include multiple courses using a single code base, combining flags, and a command for zipping the course as a SCO.  The framework folder structure requires a couple of changes. But they are easy to make—and to revert if you decide to abandon rub-cli.

Grunt's future in Adapt

Expect that in a future release, the Adapt framework will abandon Grunt in favor of webpack.