Tutorial: The Flitter CLI

The Flitter CLI

By default, Flitter ships with the flitter-cli package, which enables use of the ./flitter command. This command is designed to aid development on Flitter. This command should only be run from the root of the application, as it depends on relative paths.

Run a Deployment

./flitter deploy <deployment name>

Flitter units can define special functions called deployments. These deployments are designed to be one-time, non-reversible functions that set up the unit's necessary files and configuration, etc. For example, the flitter-auth package provides the auth deployment which creates the controllers, models, views, and middleware to enable Flitter's auth provider.

Create a New File From a Template

./flitter new <template name> <file name>

Flitter units can also define templates for files that are used regularly in Flitter. For example, libflitter provides several templates like the controller, model, config, and router templates, which create the respective <file name> in the base directory corresponding to the type of file you are generating.

Launch the Flitter Shell

./flitter shell

Sometimes, when you're developing a feature for your app, it's useful to be able to test things out and interact with Flitter directly, without having to interact with Flitter through a web-browser. As such, this command will start an interactive prompt that has access to the entire Flitter context. It behaves just like an interactive Node prompt, but it is started from within Flitter, so you can access all the same resources that your app can directly.

Note: The ability to use await commands in the shell is super useful for testing things in Flitter, since most things in Flitter happen async. If you are using a new enough version of Node, you can start the Flitter shell with await support like so:

node --experimental-repl-await flitter shell

Upgrade Flitter In-Place (experimental)

./flitter flap

Flitter Flap is an experimental migration tool designed to help keep Flitter applications up-to-date even after they're deployed. Once Flitter's core packages are updated via Yarn, you can use Flap to run any migrations those packages provide. These will make changes to the core Flitter file structure/syntax to keep your app up to date with the latest Flitter core. This feature is relatively new and is a work in progress. It is not recommended for most apps at this time.

Next: Production