Mojito comes with a command-line tool that provides a number of key
capabilities for the developer, from generating code skeletons, to
running tests and test coverage, to cleaning up and documenting the
code base.

All commands except mojitocreate must be run from within the application
directory.

Archetypes are used to create skeletons for the different types of artifacts
in a Mojito application. The skeletons only contain stripped down boilerplate
code that is easier to create using the command-line tool rather than by hand.

To create a skeleton for a Mojito application:

$mojitocreateapp[<archetype-name>]<path/to/app-name>

This will create an empty application (i.e., one with no mojits) with the name
provided. The application is created in a directory named <app-name> within
the specified directory. If no archetype name is provided, the default archetype
is used.

From the application directory, use the following command to create a skeleton
for a mojit:

$mojitocreatemojit[<archetype-name>]<mojit-name>

This will create an empty mojit with the name provided. The command assumes it
is being executed within an application directory. Thus, the mojit is created
in a directory named <mojit-name> within a mojits subdirectory of the
application directory. For example, the mojit MyMojit would be created in
mojits/MyMojit.

As with application creation, if no archetype name is provided, the default
archetype is used. Depending upon the archetype, the skeleton may include any
or all of the controller, model, view, and binder.

Mojito offers the following three archetypes for applications and mojits.

simple - The minimal configuration and code needed to run an application.

default - This archetype is run if no command-line archetype option is
specified. It is a happy medium between simple and full.

demo - This archetype is only availabe for applications, but let’s you
create demo applications. The built-in demo application is the quickstart
application that serves documentation and serves as an example application.

full - Provides the most comprehensive configuration and code for
applications.

You can also customize archetypes and then use them to generate code.
For example, if you customized the template code that Mojito uses (or create your own)
to generate boilerplate code, such as an application or a mojit,
you could have Mojito use your archetype to generate code with the following command:

$mojitocreatemojit<archetype-path><generated_code-path>

For example: $mojitocreateapp./my_archetypes/mobile_web_app./my_apps/micro_blog

Unit tests are run using YUI Test invoked using the Mojito command-line tool.
Test output is written to the console and also to the file
{CWD}/artifacts/test/result.xml, where {CWD} is the current working directory.
Note when you run tests, the output may overwrite the results of past tests. To avoid this,
you can use the long option --directory or an abbreviation such as --dir to
to specify where to write test results.

To run tests for an application:

$mojitotest[app][.]

To run the unit tests for a specific mojit, use one of the following:

$mojitotestmojit<mojit-path>

$mojitotestmojit<mojit-name>

To run the unit tests for one or more modules of a mojit, use one of the following:

Code coverage is invoked in the same way as unit testing, but with the added
option --coverage or -c. To run code coverage tests, you need to have
Java installed. You can specify where to write the coverage results using the option
--directory or --dir. Coverage results are written to
the directory {CWD}/artifacts/test/coverage/ by default. You can also specify the
path to write results with the long option --directory or an abbreviation such as
--dir (see example below).

Mojito v0.8 and earlier used the Mojito CLI utility to start
applications (mojitostart). If you have an older application
you need to create an app.js first and then use nodeapp.js
to start the application.

Static code analysis is run using JSLint invoked using the Mojito command-line
tool. By default, the JSLint error report is written to
{CWD}/artifacts/jslint/jslint.html. You can also specify the directory to
write the error report to with the long option --directory or an abbreviation such
as --dir.

API documentation is generated using YUI Doc,
which is invoked using the Mojito command-line tool. Documentation output is
written to files in the locations specified below. Because it’s based on YUI Doc,
you can start a server that displays the documentation with the option --server and
specify a port with --port. You can also specify the output directory with the
the option --directory or an abbreviation such as --dir.

To generate documentation for the Mojito framework itself:

$mojitodocsmojito

Output is written to {CWD}/artifacts/docs/mojito/, where {CWD} is
the current working directory.

To generate documentation for an application, including all of its (owned)
mojits, run the following from the application directory:

$mojitodocsapp

Output is written to {app-dir}/artifacts/docs/.

To generate documentation for a specific mojit, run one of the following:

The command below generates the Graphviz file {CWD}/artifacts/gv/yui.client.dot
({CWD} represents the current working directory) that describes the YUI module
dependencies.

$mojitogv

The mojitogv command has the following options:

--client - inspects the files that have client and common as the affinity.
The default is just to inspect files that have server and common as the affinity.
For example, using the --client option, the file controller.client.js and
controller.common.js will be inspected.

You can no longer specify the base context with the --context option.
To specify a base context in Mojito v0.9 and later, you pass a context object
to the extend method in the file app.js. In the example snippet from
app.js below, the application when started will use the base context environment:staging: