Deploying
Codeflow projects are typically tested from within the designer using the embedded Codeflow engine. However, to deploy projects to production or to run from a command line, the engine can be called directly from a command line.
The engine can be installed directly as an NPM package. The engine should run on any system that runs Node.js version 4.0 and greater.
To begin, install engine as a global NPM package.
npm install -g codeflow
Running engine
After installing the engine, Codeflow commands can be executed from a command line terminal as below:
codeflow [command] <options> <command params>
Commands
Option |
Description |
---|---|
run [params] | Command to execute a single flow or the whole project. |
install [params] | Command to install dependency packages. Should be run from the root of a Codeflow project. Omit the parameter to install all the dependent packages from command line. |
uninstall [params] | Uninstall the specified package from the project. Should be run from the root of a Codeflow project. |
Running flows
The run command is used to run a flow or entire project:
codeflow run <options> [path]
Where path can be a path to an individual flow, or the root folder of a Codeflow project. When the folder is passed, the project is started as whole, where all the trigger files inside the project are started by the engine automatically during startup.
Run options
Short option |
Long option |
Description |
---|---|---|
-i | --input |
Pass a json as the input data. Example: codeflow run -i '{"age":50}' compute.flw |
-w | --working-dir |
Set the current working directory. Paths passed are resolved relative to the working directory. Example: codeflow run -w /user/project flow.flw |
-o | --output | Print the output returned. Example: codeflow run hello.flw -o will print whatever returned by hello.flw to the console |
-c | --optimize | Run optimized. If set, this will make Codeflow compile the flows into JavaScript for optimum performance. Example: codeflow run hello.flw -c |
-e | --env |
Set the environment. Value should be one of dev , qa or prod . This option is used to load the context specific configuration file. |
-d | --debug | Set the engine in debug mode. Can pass either ipc or tcp . Defaults to tcp . This is used by Codeflow designer. |
-p | --debug-port |
Change the default debugger port. |
Installing packages
In Codeflow, the installed package dependencies (packages installed under {project-root}/.packages folder) are not be typically added to the version control. Just tracking the package.json that includes the list of dependent packages is enough. The install command can then be used to install the dependent packages from the command line during deployment.
codeflow install <namespace/name@version>,<namespace/name@version>...
Example:
To install all the dependent packages specified in the package.json, simply run install without any parameters at the project's root directory:
cd <project directory>
codeflow install
To install a specific package that may or may not be listed in the package.json, run:
codeflow install codeflow/handlebars
Specific versions of a package can also be installed by appending @<version>
as below:
codeflow install codeflow/handlebars@0.1.1
Uninstalling packages
The uninstall command can be used to remove an unused package from the current project.
codeflow uninstall <namespace/name>,<namespace/name>...
Examples
Use case |
Example command(s) |
---|---|
Run a flow | codeflow run hello.flw |
Run a flow with an input JSON |
codeflow run update.flw -i '{"id": 1, "name": "Jack Sparrow"}' |
Run a flow with an input JSON and print the output |
codeflow run calculate.flw -i '{"age": 30}' -o |
Start as project from the current directory |
codeflow run . |
Start as project from a specific path |
codeflow run . -w /path-to-project |
Installing all the dependent packages |
codeflow install |
Install or update to the latest version of a package |
codeflow install codeflow/handlebars |
Install or update to a specific version of a package |
codeflow install codeflow/handlebars@0.1.10 |
Uninstall a package | codeflow uninstall codeflow/archiver |