CLI for CleverStack
A command line interface (CLI) for the CleverStack ecosystem.
npm install cleverstack-cli -g
cleverstack-cli depends on NPM, GruntJS and Bower and for "npm", "grunt" and "bower" to be located in your
$PATH
npm install bower -g
npm install grunt-cli -g
Quick Setup Tutorial 1. Initialize a new project 2. Installing a module 3. Removing a module 4. Running tests
Quick Tutorial for Building a New Module 1. generate 2. scaffold 3. new 4. repl
Commands 1. help 2. downgrade 3. generate (g) 4. init 5. list 6. new 7. remove 8. repl 9. scaffold (s) 10. search 11. setup 12. server (serve) 13. test (tests) 14. upgrade
Help & Resources 1. CleverStack Website 2. CleverStack Documentation 3. Official CleverStack Backend Seed 4. Official CleverStack Frontend Seed Running Tests Contributors License
Initializing a new project will download and grab CleverStack's angular-seed and node-seed seeds. After initializing the project, cleverstack-cli will automatically install any depedencies that are required through NPM and Bower.
$: clever init my-new-project
You will be asked for database credentials, this is due to the fact that we currently run
grunt dbafter the initialization. This will soon change, and your database credentials will only be asked for when you install a module that requires it.
This will create a new directory called my-new-project with two folders: backend and frontend.
$: cd my-new-project && tree -d -L 1
. βββ backend βββ frontend2 directories
When installing a module, CleverStack will automatically detect:
The command is:
$: clever install
For a list of modules, visit CleverStack's module page
$: clever install clever-background-tasks
This will install
clever-background-taskswithin the
backend/modulesfolder.
When removing a module, CleverStack will:
$: clever remove clever-background-tasks
To ensure that everything is working correctly, you can run tests with:
$: clever test unit
CleverStack will run
grunt testwithin each seed.
$: clever server
There are three commands to be aware of when building a module:
Generate will create a template of a specific component (controller, services, model, tasks, or tests) within module's name that's residing in your current working directory.
$: tree -d -L 1
.0 directories
$: clever g model my-new-model
$: tree . -d -L 1
. βββ my-new-model1 directory
$: cd my-new-model && tree . -L 1
. βββ models1 directory, 0 files
$: tree ./models
./models βββ MyNewModelModel.js2 directories, 2 files
Scaffolding is similar to generate except it'll generate every component's template for you.
Note: These files will be generated within your current working directory.
$: tree -d -L 1
.0 directories
$: clever s my-new-module
$: tree . -d -L 1
. βββ my-new-module
$: tree ./my-new-module -L 3
./my-new-module βββ config β βββ default.json βββ controllers β βββ MyNewModuleController.js βββ models β βββ MyNewModuleModel.js βββ schema β βββ seedData.json βββ services β βββ MyNewModuleService.js βββ tasks β βββ MyNewModuleTask.js βββ tests βββ integration β βββ MyNewModuleTest.js βββ unit βββ MyNewModuleTest.js11 directories, 9 files
The
newcommand is similar to
scaffoldexcept it'll create the module within the application's
modulefolder.
$: tree ./modules -d -L 1
./modules βββ my-new-module1 directory
$: tree ./modules/my-new-module -L 3
./modules/my-new-module βββ config β βββ default.json βββ controllers β βββ MyNewModuleController.js βββ models β βββ MyNewModuleModel.js βββ schema β βββ seedData.json βββ services β βββ MyNewModuleService.js βββ tasks β βββ MyNewModuleTask.js βββ tests βββ integration β βββ MyNewModuleTest.js βββ unit βββ MyNewModuleTest.js11 directories, 9 files
In order to interact with your environment's models directly, simply type in:
$: clever repl
$: clever help
Usage: clever [options]Options:
-h, --help output usage information -V, --version output the version number
Commands:
build - Builds production-ready code for the frontend seed downgrade - Downgrades a CleverStack implementation help - Displays this help message init <project> [backend|frontend] - Initialized a new project install <modules> - Installs a module within CleverStack generate <option> <name> - Generates a controller, service, model, etc. individually list - Lists all of the available CleverStack modules new <name> - Scaffolds into a specific directory called <name> remove <modules> - Removes a module within CleverStack repl - Starts the CleverStack REPL routes - Displays your project's routes scaffold <name> - Generates a controller, service, model, etc. search [query] - Searches for a cleverstack module setup - Installs NPM & Bower packages for each module and adds modules to bundleDependencies server - Starts the CleverStack server test - Runs tests within your CleverStack environment upgrade - Upgrades a CleverStack implementation
Downgrades to the next version (or specified version) of the seed/module (depending on what directory that you're currently in).
Note: This command must run under project's root directory (where frontend and backend are).
$: clever downgrade -h
Usage: clever-downgrade [options]Options:
-h, --help output usage information -V, --version output the version number
Examples:
clever downgrade clever-orm clever downgrade [email protected] [email protected] clever downgrade backend clever downgrade frontend
$: clever generate -h
Usage: clever-generate [options] [command]Commands:
service <name> Generates a service as <name> within /Users/richardgustin/Documents/Projects/CleverStack/services services <names> Generates services specified with <name ...> within /Users/richardgustin/Documents/Projects/CleverStack/services controller <name> Generates a controller as <name> within /Users/richardgustin/Documents/Projects/CleverStack/controllers controllers <names> Generates controllers specified with <name ...> within /Users/richardgustin/Documents/Projects/CleverStack/controllers model <name> Generates a model as <name> within /Users/richardgustin/Documents/Projects/CleverStack/models models <names> Generates models specified with <name ...> within /Users/richardgustin/Documents/Projects/CleverStack/models task <name> Generates a task as <name> within /Users/richardgustin/Documents/Projects/CleverStack/tasks tasks <names> Generates tasks specified with <name ...> within /Users/richardgustin/Documents/Projects/CleverStack/tasks view <name> Generates a view as <name> within /Users/richardgustin/Documents/Projects/CleverStack/views views <names> Generates views specified with <name ...> within /Users/richardgustin/Documents/Projects/CleverStack/views factory <name> Generates a factory as <name> within /Users/richardgustin/Documents/Projects/CleverStack/factories factories <names> Generates factories specified with <name ...> within /Users/richardgustin/Documents/Projects/CleverStack/factories service <name> Generates a service as <name> within /Users/richardgustin/Documents/Projects/CleverStack/services services <names> Generates services specified with <name ...> within /Users/richardgustin/Documents/Projects/CleverStack/services directive <name> Generates a directive as <name> within /Users/richardgustin/Documents/Projects/CleverStack/directives directives <names> Generates directives specified with <name ...> within /Users/richardgustin/Documents/Projects/CleverStack/directives test [options] <name> Generates a test t as <name> within /Users/richardgustin/Documents/Projects/CleverStack/tests tests [options] <names> Generates test specified with <name ...> within /Users/richardgustin/Documents/Projects/CleverStack/tests
Options:
-h, --help output usage information -V, --version output the version number
Example:
clever generate model users clever generate controller users clever g controller users clever g controllers users auth email
$: clever init -h
Usage: clever-init [options] [command]Commands:
<project> creates a new project named <project>
Options:
-h, --help output usage information -f, --force delete existing projects in your current directory /Users/richardgustin/Documents/Projects/CleverStack -v, --verbose verbose output useful for debugging -A, --allow-root allow root for bower -S, --skip-protractor skips installing protractor (Frontend only) -B, --bootstrap will run `grunt bootstrap build` as part of the setup -V, --version output the version number
Examples:
clever init my-project install the backend and frontend clever init my-project clever-auth with the clever-auth module clever init my-project backend frontend verbose way of running "clever init my-project" clever init my-project frontend only install the frontend clever init my-project backend clever-auth install the clever-auth module after installing the backend and frontend seeds Installing specific versions: clever init my-project [email protected]<version> clever init my-project [email protected]<version>
Lists all modules available for CleverStack.
$: clever list -h
Usage: clever-list [options]Options:
-h, --help output usage information -V, --version output the version number
Example: clever list
$: clever new -h
Usage: clever-new [options]Options:
-h, --help output usage information -V, --version output the version number --no-service Disables generating a service. --no-controller Disables generating a controller. --no-model Disables generating a model. --no-task Disables generating a task. --no-test Disables generating a test.
Example: clever new my_module clever new myModule
Removes a module from the project.
$: clever remove -h
Usage: clever-remove [options] [modules ...]Options:
-h, --help output usage information -V, --version output the version number
Examples: clever remove clever-background-tasks clever remove auth clever-background-tasks
Creates a REPL instance within your project's environment. Useful for executing ORM/Model commands.
Note: You must set the
NODE_ENVenvironment variable.
$: NODE_ENV=local clever repl
richards-mbp:test-jan-2015 richardgustin$ clever repl β Welcome to CleverStack using seed version 1.2.0-rc-2 β Type .commands or .help for a list of commandscleverstack::local> .commands
.commands Lists all of the REPL commands .help Alias for .commands .h Alias for .commands .modules List all of the modules within this project .models Lists all models .services Lists all services .exit Exits the CleverStack REPL .quit Alias for .exit .q Alias for .exit .history Show command history
cleverstack::local> .quit
$: clever scaffold -h
Usage: clever-scaffold [options]Options:
-h, --help output usage information -V, --version output the version number --no-service Disables generating a service. --no-controller Disables generating a controller. --no-model Disables generating a model. --no-task Disables generating a task. --no-test Disables generating a test.
Note: Scaffold will generate templates within $PWD If you wish to generate an entire model use clever new
Example: clever scaffold my_component clever scaffold myComponent
$: clever search -h
Usage: clever-search [options]Options:
-h, --help output usage information -V, --version output the version number
Examples: clever search users clever search users auth email
$: clever setup -h
Usage: clever-setup [options]Options:
-h, --help output usage information -A, --allow-root allow root for bower -S, --skip-protractor skips installing protractor (Frontend only) -B, --bootstrap will run `grunt bootstrap build` as part of the setup -v, --verbose verbose output useful for debugging -V, --version output the version number
Description:
Installs all NPM and Bower components for each module as well as building bundleDependencies. This command will also install Protractor unless explicitly skipping.
Examples:
clever setup
$: clever server -h
Usage: clever-server [options]Options:
-h, --help output usage information -V, --version output the version number -x, --host [host] Set the host for grunt server -p, --port [port] Set the port for grunt server
Example: clever server clever --host 10.0.0.0 server clever --port 7777 server
$: clever test -h
Usage: clever-test [options] [command]Commands:
e2e Runs e2e tests unit Runs unit tests coverage Generates unit test coverage reports.
Options:
-h, --help output usage information -V, --version output the version number
Examples:
clever test coverage clever test e2e clever test unit
$: clever upgrade -h
Usage: clever-upgrade [options]Options:
-h, --help output usage information -V, --version output the version number
Examples:
clever upgrade clever-orm clever upgrade [email protected] [email protected] clever upgrade backend clever upgrade frontend
Online Documentation which can provide support for install, configurations and troubleshooting.
https://github.com/CleverStack/cleverstack-cli/wiki
To run the test suite, first invoke the following command within the repo, installing the development dependencies:
$ npm install
Then run the tests:
$ make test
https://github.com/CleverStack/cleverstack-cli/graphs/contributors
See our LICENSE