Command Line Tools

Rekit provides a set of command line tools to manage components, actions and routing rules for Rekit projects. They are implemented as JavaScript modules in the package rekit-core. Then Rekit just wraps them as command line tools. Actually rekit-core is also used by Rekit Portal.

Create an app

You can use below command to create an app:

rekit create <app-name> [--sass]

This will create an app named app-name under the current directory. The flag --sass allows to use sass instead of less as the css transpiler.

Create a plugin

You can use below command to create a plugin:

rekit create-plugin <plugin-name>

It will create a local plugin if the current directory is in a Rekit project, otherwise create a public plugin.

For more information, please read the document at: http://rekit.js.org/docs/plugin.html.

Install a plugin

If you will use a plugin via npm, use the below command:

rekit install <plugin-name>

This will execute install.js script of the plugin to do the initialization and added the plugin name to rekit.plugins section of package.json.

Rekit tools

Rekit tools are pure scripts shipped with created applications. They are put in the tools folder of your app and are supposed to be edited to meet additional requirements of your project.

tools/server.js

This script is used to start dev servers, by default it starts all 3 servers include webpack dev server, Rekit portal and the build result server. You can only start some of servers by arguments.

Usage:

node tools/server.js [-m, --mode] [--readonly]
  • mode: if not provided, all 3 dev servers are started. Otherwise only the specified dev server is started. It could be:
    • dev: webpack dev server
    • portal: Rekit portal
    • build: start a static express server for build folder.
  • readonly: start the Rekit portal on readonly mode. It's useful to start a portal server only for explore the project structure. For example, the Rekit portal live demo is running on readonly mode.

It's also available as the npm script: npm start.

tools/run_test.js

This script is helpful to run one or multiple unit tests. It accepts argument what tests files should be run.

Usage:

node tools/run_test.js <file-pattern>

The file pattern is the same as what mocha accepts. If no file-pattern specified, it runs all tests and generates test coverage report. Otherwise run tests matches the pattern.

For example:

node tools/run_test.js features/home/redux/counterPlusOne.test.js  // run test of a redux action
node tools/run_test.js features/home // run all tests of home feature
node tools/run_test.js // run all tests and generate test coverage report

It's also available as the npm script: npm test.

tools/build.js

This script is used to build the project.

Usage:

node tools/build.js

It's also available as the npm script: npm run build. It will build the project to the build folder.

Manage features, components and actions.

This is the key part of daily Rekit development. You will use below commands to mange Rekit elements.

Note: though all commands are put under the rekit command, i.e. rekit add component home/comp1. Actually Rekit will find the local rekit-core package in your app to finish the operation. So execute rekit commands under different Rekit apps may have different behaviors if those apps depends on different versions of rekit-core.

All such commands have silimar patterns:

  • rekit add <type>: add an element of the type.
  • rekit mv <type>: move/rename an element of the type.
  • rekit rm <type>: delete an element of the type.

All commands supports [-h] argument to see the usage help. i.e. rekit add -h.

Below is the list of all Rekit commands to manage project elements:

Commands Description
rekit add feature <feature-name> Add a new feature.
rekit mv feature <old-name> <new-name> Rename a feature.
rekit rm feature <feature-name> Delete a feature.
rekit add component <component-name> [-u] [-c] Add a new component.
- `-u`: specify the url pattern of the component. - `-c`: it's a container component connected to Redux store.
rekit mv component <old-name> <new-name> Rename a component.
rekit rm component <component-name> Delete a component.
rekit add action <action-name> [-a] Add a new action.
- `-u`: add an async action.
rekit mv action <old-name> <new-name> Rename an action.
rekit rm action <action-name> Delete an action.

results matching ""

    No results matching ""