Commands

Interact with Mimosa via the command line with a large set of commands and options

Each command has a section dedicated to it below, but here is a quick list of the available non-module commands. Most commands have flags that influence the behavior of the command. Read more about those below.

Mimosa's module features have their own set of commands prefixed with mod:. Read about them on the Module's page.

new

The best way to get started with Mimosa is to use it to create a new application/project structure.

$ mimosa new nameOfApplicationHere

The new command will kick off a series of prompts to choose meta-languages, a templating library, a server, and a server templater. Mimosa will then create a directory using the name provided. Inside that directory Mimosa will populate an application skeleton. The assets directory will contain some example code and a group of vendor scripts, like require.js, as well as CSS and micro-template assets for the chosen selections.

If a server was chosen, Mimosa will include the bare essentials for an Express application, including a simple router and a file Mimosa will use to start Express. That code will be delivered in the chosen meta-language.

Lastly, Mimosa will provide some starter views for an index page in the chosen view templating language.

If no server is chosen, Mimosa can handle serving assets. Mimosa provides some configuration options for an embedded Express server so not having a server is a little less painful than it would be otherwise.

The project directory will also contain Mimosa's configuration file. Almost everything inside of it is commented out, but all the options and explanations for each option are present. The only config not commented out will be changes to the server config if something other than the defaults was chosen.

Also included for good measure, is a starter makefile. Even if make isn't available, the commands listed in the makefile should provide some guidance.

Pick the defaults (-d/--defaults)

Should Mimosa's defaults (CoffeeScript, Handlebars, Stylus, Express, Jade) suffice, the prompts can be bypassed by providing a --defaults flag.

$ mimosa new nameOfApplicationHere --defaults
$ mimosa new nameOfApplicationHere -d

Davids-MacBook-Pro:mim dbashford$ mimosa new foo

Determining system capabilities...

Mimosa will guide you through project creation. You will be prompted to pick the JavaScript meta-language, CSS meta-language, and micro-templating library you would like to use. For more about those choices, see http://mimosajs.com/compilers.html. You will also be prompted to pick the server and server-side view technologies you would like to use. If you pick no server, Mimosa will serve your assets for you.

For all of the technologies, if your favorite is not an option, you can add a GitHub issue and we'll look into adding it.

If you are unsure which options to pick, the ones with asterisks are Mimosa favorites. Feel free to hit the web to research your selections, Mimosa will be here when you get back.

To start, please choose your JavaScript meta-language:

1) (*) CoffeeScript - http://coffeescript.org/
2) Iced CoffeeScript - http://maxtaco.github.com/coffee-script/
3) LiveScript - http://gkz.github.com/LiveScript/
4) None (Raw JavaScript)
5) TypeScript - http://www.typescriptlang.org
: 1

You chose (*) CoffeeScript - http://coffeescript.org/.

Choose your CSS meta-language:

1) LESS - http://lesscss.org/
2) None (Raw CSS)
3) SASS - http://sass-lang.com/
4) (*) Stylus - http://learnboost.github.com/stylus/
: 4

You chose Stylus - http://learnboost.github.com/stylus/.

Choose your micro-templating language:

1) (*) Dust - https://github.com/linkedin/dustjs/
2) Embedded JavaScript Templates (EJS) - https://github.com/visionmedia/ejs
3) Emblem - http://emblemjs.com
4) (*) Handlebars - http://handlebarsjs.com/
5) Hogan - http://twitter.github.com/hogan.js/
6) HTML - Just Plain HTML Snippets, no compiling
7) Jade - http://jade-lang.com/
8) LoDash - http://lodash.com/docs#template
9) None (No Templating)
10) Underscore - http://underscorejs.org/#template
: 5

You chose Hogan - http://twitter.github.com/hogan.js/.

Choose your server technology:

1) None - You don't need a server, or you'd like Mimosa to serve your application for you.
2) (*) Express - http://expressjs.com/
: 1

You chose (*) Express - http://expressjs.com/.

And finally choose your server view templating library:

1) (*) Jade - http://jade-lang.com/
2) Hogan - http://twitter.github.com/hogan.js/
3) Plain HTML
4) Embedded JavaScript Templates (EJS) - https://github.com/visionmedia/ejs
5) Handlebars - http://handlebarsjs.com/

You chose (*) Jade - http://jade-lang.com/.

Creating and setting up your project...

23:20:05 - Copying skeleton project into /Users/dbashford/mim/foo
23:20:05 - Installing node modules
23:20:09 - New project creation complete! Execute 'mimosa watch --server' from inside your project to monitor the file system. Then start coding!
Davids-MacBook-Pro:mim dbashford$

watch

Mimosa will watch the configured watch.sourceDir, which is by default the assets directory. When files are added, updated, or deleted, Mimosa's workflows will start and execute the registered Mimosa module code, including the compiling and copying of code.

$ mimosa watch

Serve Assets (-s/--server)

If need to serve assets, start Mimosa with the server flag.

$ mimosa watch --server
    $ mimosa watch -s

By default, Mimosa will run a piece of code located at server.path. If Mimosa was used to create the project, and a server was chosen, a server.coffee (.iced/.js/.ls) file will be at the project's root. Mimosa will run the startServer function in this file and pass it the full mimosa-config and a callback function that must be executed.

Mimosa's embedded (non-extendable) Express server can be used by changing the server.defaultServer.enabled configuration to true. If no server was chosen during project creation, this setting will be set.

Davids-MacBook-Pro:foo dbashford$ mimosa watch --server --optimize
09:34:57 - Watching /Users/dbashford/mim/foo/assets
09:34:57 - Compiled/copied [[ /Users/dbashford/mim/foo/public/javascripts/main.js ]]
09:34:57 - Compiled/copied [[ /Users/dbashford/mim/foo/public/stylesheets/style.css ]]
09:34:57 - Compiled/copied [[ /Users/dbashford/mim/foo/public/javascripts/app/example-view.js ]]
09:34:57 - Compiled/copied [[ /Users/dbashford/mim/foo/public/javascripts/vendor/jquery.js ]]
09:34:57 - Compiled/copied [[ /Users/dbashford/mim/foo/public/javascripts/templates.js ]]
09:34:57 - Compiled/copied [[ /Users/dbashford/mim/foo/public/javascripts/vendor/require.js ]]
09:34:57 - Beginning requirejs optimization for module [[ main ]]
09:34:59 - The compiled file [[ /Users/dbashford/mim/foo/public/javascripts/main-built.js ]] is ready for use.
09:34:59 - Requirejs optimization complete.
09:34:59 - Mimosa is starting your server: /Users/dbashford/mim/foo/server.coffee
info - socket.io started

Clean Compiled Assets First (-c/--clean)

Use the --clean flag to clean out the compiled directory before watching starts. This forces a recompile and recopy of all assets.

$ mimosa watch --clean
$ mimosa watch -c

Delete Compiled Directory First (-d/--delete)

More drastic than the clean flag, the --delete flag will remove the compiled directory entirely. This is the same as the --force option for the clean command below. More details about the difference between cleaning and deleting below.

$ mimosa watch --delete
$ mimosa watch -d

Serve Optimized Assets (-o/--optimize)

Start mimosa watch with the --optimize flag turned on and Mimosa will optimize the codebase on start-up and with every file change. See the optimization tab to read more about Mimosa's default optimization options.

$ mimosa watch --optimize
$ mimosa watch -o

Minify Assets (-m/--minify)

Start mimosa watch with the --minify flag turned on and Mimosa will, by default, use Uglify2 to compress JavaScript files after they are compiled and before they are written.

$ mimosa watch --minify
$ mimosa watch -m

Minify and Optimize Assets (-mo/--minify --optimize)

$ mimosa watch --minify --optimize
$ mimosa watch -mo

When combined, the --minify and --optimize options provide more control over the application's minification strategy. Check out the Minify + Optimize section of the Optimization tab to learn more.

Use a Profile (-P/--profile)

Follow the --profile flag with the name of a profile, and Mimosa will use that profile to override the mimosa-config contained in the profile. See the profiles section of the Utilities page for more information on profiles.

$ mimosa watch --profile nameOfProfile
$ mimosa watch -P nameOfProfile

clean

mimosa clean will wipe out any file from the compiledDir that is currently in the sourceDir. Any assets in the compiledDir that are not in the sourceDir are left alone in case they were placed there purposefully. Mimosa makes a pass to clean out the files, and once done, it makes a pass to clean out any directories that are now empty.

$ mimosa clean

Force Asset Deletion (-f/--force)

Because the clean command will not remove anything in compiledDir that isn't in sourceDir, Mimosa may leave behind code. If mimosa watch is running and a file is deleted or renamed, Mimosa cleans out the compiled version of that file, but if Mimosa is not running and a file is deleted or removed, Mimosa has no way of knowing the files left behind are safe for cleaning.

When included, the --force flag will remove the entire compiled directory and all of its contents, no questions asked.

Use a Profile (-P/--profile)

Follow the --profile flag with the name of a profile, and Mimosa will use that profile to override the mimosa-config contained in the profile. See the profiles section of the Utilities page for more information on profiles.

$ mimosa clean --profile nameOfProfile
$ mimosa clean -P nameOfProfile

Davids-MacBook-Pro:foo dbashford$ mimosa clean
13:46:45 - Deleted file [[ /Users/dbashford/mim/foo/public/javascripts/main.js ]]
13:46:45 - Deleted file [[ /Users/dbashford/mim/foo/public/stylesheets/style.css ]]
13:46:45 - Deleted file [[ /Users/dbashford/mim/foo/public/javascripts/app/example-view.js ]]
13:46:45 - Deleted file [[ /Users/dbashford/mim/foo/public/javascripts/vendor/jquery.js ]]
13:46:45 - Deleted file [[ /Users/dbashford/mim/foo/public/javascripts/vendor/require.js ]]
13:46:45 - Deleted file [[ /Users/dbashford/mim/foo/public/javascripts/vendor/dust.js ]]
13:46:45 - Deleted file [[ /Users/dbashford/mim/foo/public/javascripts/templates.js ]]
13:46:45 - Deleted file [[ /Users/dbashford/mim/foo/public/javascripts/main-built.js ]]
13:46:45 - Deleted empty directory [[ /Users/dbashford/mim/foo/public/javascripts/vendor ]]
13:46:45 - Deleted empty directory [[ /Users/dbashford/mim/foo/public/javascripts/app ]]
13:46:45 - Deleted empty directory [[ /Users/dbashford/mim/foo/public/stylesheets ]]
13:46:45 - Deleted empty directory [[ /Users/dbashford/mim/foo/public/javascripts ]]
13:46:45 - [[ /Users/dbashford/mimosaplay/foo/public ]] has been cleaned.
Davids-MacBook-Pro:foo dbashford$

build

Use mimosa build to make one pass through the project to compile assets without starting up a watch. This command will compile any assets that need compiling, deliver the results to the public directory, and then exit. mimosa build is also used when creating deployable versions of a project. This command also executes a clean before it does anything, so it builds a clean version of the application.

$ mimosa build

Optimized Build (-o/--optimize)

If you want to build and generate optimized output, provide an --optimize flag. See the Optimization page for more information.

$ mimosa build --optimize
$ mimosa build -o

Minify Assets (-m/--minify)

To build with minified code, run the build command with the --minify flag turned on. Mimosa will use Uglify2 to compress JavaScript files as they are compiled and before they are written.

Minify and Optimize Assets (-mo/--minify --optimize)

Davids-MacBook-Pro:foo dbashford$ mimosa build --optimize
10:13:33 - Beginning build
10:13:33 - Compiled/copied [[ /Users/dbashford/mim/foo/public/index.html ]]
10:13:33 - Compiled/copied [[ /Users/dbashford/mim/foo/public/javascripts/main.js ]]
10:13:33 - Compiled/copied [[ /Users/dbashford/mim/foo/public/stylesheets/style.css ]]
10:13:33 - Compiled/copied [[ /Users/dbashford/mim/foo/public/javascripts/app/example-view.js ]]
10:13:33 - Compiled/copied [[ /Users/dbashford/mim/foo/public/javascripts/vendor/require.js ]]
10:13:33 - Compiled/copied [[ /Users/dbashford/mim/foo/public/javascripts/vendor/jquery.js ]]
10:13:33 - Compiled/copied [[ /Users/dbashford/mim/foo/public/javascripts/templates.js ]]
10:13:33 - Beginning requirejs optimization for module [[ main ]]
10:13:35 - The compiled file [[ /Users/dbashford/mim/foo/public/javascripts/main-built.js ]] is ready for use.
10:13:35 - Requirejs optimization complete.
10:13:35 - Finished build
Davids-MacBook-Pro:foo dbashford$

$ mimosa build --minify --optimize
$ mimosa build -mo

Need a bit more control over a project's minification strategy? See the page on optimization to see the benefit of using --minify and --optimize together.

Package Application (-p/--package)

Provide a --package flag and Mimosa will invoke any installed packaging modules. Mimosa doesn't come with any packaging modules by default, but modules like mimosa-web-package are available and can be added to an application by simply adding the module name to the mimosa-config modules array.

Use a Profile (-P/--profile)

Follow the --profile flag with the name of a profile, and Mimosa will use that profile to override the mimosa-config contained in the profile. See the profiles section of the Utilities page for more information on profiles.

$ mimosa build --profile nameOfProfile
$ mimosa build -P nameOfProfile

virgin

Because, after all, a virgin mimosa is just orange juice.

$ mimosa virgin

mimosa virgin includes just the watching, compiling, linting and notifications. No server, no optimizations, no writing the output. Use this if you've already got an application framework and don't need files served or optimizations, but you want to know if something doesn't compile immediately, and you want to introduce linting to your workflow.

Davids-MacBook-Pro:foo dbashford$ mimosa virgin
10:19:56 - Watching /Users/dbashford/mim/foo/assets
13:50:52 - Compiled/copied [[ /Users/dbashford/mimosaplay/foo/public/javascripts/main.js ]]
13:50:52 - Compiled/copied [[ /Users/dbashford/mimosaplay/foo/public/javascripts/app/example-view.js ]]
13:50:52 - Compiled/copied [[ /Users/dbashford/mimosaplay/foo/public/stylesheets/style.css ]]
13:50:52 - All templates compiled successfully.

Use a Profile (-P/--profile)

Follow the --profile flag with the name of a profile, and Mimosa will use that profile to override the mimosa-config contained in the profile. See the profiles section of the Utilities page for more information on profiles.

$ mimosa virgin --profile nameOfProfile
$ mimosa virgin -P nameOfProfile

update

The refresh command isn't used to update Mimosa itself. (If a new version of Mimosa is desired, execute npm install mimosa -g.) The refresh command is used to update the package.json for Mimosa managed projects.

If an application is installed using the new command, the application may fall out of date with the Mimosa skeleton as it evolves and advances. Use the refresh command to update the node packages that Mimosa installed inside an application when it was created and to get any new libraries Mimosa now includes.

Mimosa will not attempt to update any of the other assets it delivers (routes, example skeleton files, etc) because many of them may have significantly changed from when they were created.

Mimosa will first run npm uninstall for each of the skeleton libraries already in place. Then it will npm install each removed library and each new library that wasn't there originally.

$ mimosa refresh

Davids-MacBook-Pro:foo dbashford$ mimosa refresh
13:57:15 - Un-installing node package. express:3.0.0rc4
13:57:15 - Un-installing node package. jade:0.27.3
13:57:15 - Un-installing node package. watch-connect:0.3.4
13:57:15 - Un-installing node package. consolidate:0.4.0
13:57:16 - Uninstall successful
13:57:16 - Installing node package: express:3.0.0rc4
13:57:16 - Installing node package: jade:0.27.3
13:57:16 - Installing node package: watch-connect:0.3.4
13:57:16 - Installing node package: consolidate:0.4.0
13:57:20 - Install successful
13:57:20 - Finished. You are all up to date!
Davids-MacBook-Pro:foo dbashford$

config

$ mimosa config

To use an Mimosa with an existing project, use this command to copy the default mimosa-config.coffee file into the current directory. Some configuration will likely need to be updated for the project. Using this command to generate a mimosa-config is also a good way to get mimosa-config updates when they occur.

Davids-MacBook-Pro:bar dbashford$ mimosa config
10:41:34 - Copied default config file into current directory.
Davids-MacBook-Pro:bar dbashford$

-h/--help

Mimosa includes extensive help documentation for each command. Use --help or -h to bring up help.

$ mimosa --help
$ mimosa new --help
$ mimosa [command] --help

Davids-MacBook-Pro:foo dbashford$ mimosa new --help

Usage: new [options] [name]

Options:

-h, --help output usage information
-d, --defaults bypass prompts and go with Mimosa defaults (CoffeeScript, SASS, Handlebars)
-D, --debug run in debug mode

The new command will take you through a series of questions regarding what JavaScript meta-language, CSS meta-language, micro-templating library, server and server view technology you would like to use to build your project. Once you have answered the questions, Mimosa will create a directory using the name you provided, and place a project skeleton inside of it. That project skeleton will by default include a basic application using the technologies you selected.

$ mimosa new [nameOfProject]

If you wish to copy the project skeleton into your current directory instead of into a new one leave off the name.

$ mimosa new

If you are happy with the defaults (CoffeeScript, Stylus, Handlebars, Express, Jade), you can bypass the prompts by providing a 'defaults' flag.

$ mimosa new [name] --defaults
$ mimosa new [name] -d

Davids-MacBook-Pro:foo dbashford$

-D/--debug

All Mimosa commands have a debug mode that will print detailed logs to the console for everything Mimosa is doing. As you'll find out the first time you execute a Mimosa command with the --debug flag, Mimosa logs quite a bit of what it does, so this is only useful when doing deep debugging, it is not something to use regularly just to see what Mimosa is up to.

$ mimosa [command] --debug
$ mimosa [command] -D