Workbench CLI tool commands

Use the Workbench CLI tool to make product module changes and push them to Root

This guide covers the full feature suite of the Workbench CLI tool. To set up the Workbench CLI tool, follow the Workbench setup tutorial first. To learn more about the configurability of product modules and workflows on Root, refer to the Product modules & workflows guide section.

πŸ“˜

Make the most of VS Code IntelliSense

When you clone or pull a product module from Root, the CLI tool will automatically create a .vscode directory in the root of the product module directory. The .vscode directory contains settings that enable VS Code IntelliSense features, such as validation and descriptions for JSON files.

For these features to work, the .vscode directory must be in the root directory of your VS Code workspace. This means that you should open the product module directory as a single-directory workspace in VS Code.

If you are using a different directory as the workspace, you can copy the .vscode directory to the root of your workspace to enable the IntelliSense features. Note, however, that in this case the VS Code settings will not be updated automatically if you push or pull.

Commands

rp clone [api key] [product module key]

This command creates a new directory and clones the latest draft version of your product module from Root to your local machine for local editing. This command is only used once for the initial setup of your product module on your local machine.

Use cd to navigate into the new directory in order to use the other commands.

Optional: -h or --host flag

Defaults to https://api.rootplatform.com/. This optional flag will determine the host from where the product module will be cloned. To ensure you reference the correct domain, please refer to the domains section of the API reference.

Example

Below is an example of cloning a product module and navigating into the new directory. After this step is completed, all the other rp commands can be used.

$ rp clone sandbox_NDIwZGYxg5LTgMTE4YzWkhhKZV5xdVLZENTNt dinosure -h https://api.uk.rootplatform.com/
Product module 'dinosure' successfully cloned into './dinosure' directory.
$ cd dinosure

rp pull

This command pulls all files and configurations of your product module from Root and overrides the local files. By default, this command pulls the latest draft version, not the live version.

Optional: -f or --force flag

Use the -f or --force flag to ignore the diff check and force the pull.

Warning: this overrides _all local files to match the version on Root exactly._

Optional: -l or --live flag

This optional flag will pull the live version from Root.

Optional: -ns or --no-sort flag

By default, the CLI tool will attempt to sort the keys of incoming JSON objects to match the key order of corresponding local JSON objects. You can choose to skip sorting of object keys and write them in the same order received from the Root platform by including this flag.

Example

$ rp pull
No changes to pull, local version is in sync with Root

rp push

This command pushes all the local files and configurations to Root which create a new draft version of the product module on the platform.

You can issue policies from a draft version over the API or on the dashboard in Sandbox. To deploy the draft version to live, please contact the Root team (they will review your changes and action the deploy).

Optional: -f or --force flag

Use the -f or --force flag to ignore the diff check and force the push.

Optional: -ns or --no-sort flag

By default, the CLI tool will attempt to sort the keys of incoming JSON objects to match the key order of corresponding local JSON objects. You can choose to skip sorting of object keys and write them in the same order received from the Root platform by including this flag.

Example

$ rp push
No changes to push, local version is in sync with Root

rp render

This command renders the document templates locally in the ./sandbox/output directory. It compiles a PDF file for each valid HTML document in the ./documents directory.

πŸ‘

Productivity tip

For best use during active document development, use all three the -m, -p <policy-id> and -w flags simultaneously in order to generate new documents every time changes are saved. Open the document using Preview on Mac and it will automatically refresh. This results in a real-time view of the end-result.

Optional: -m or --merge flag

Use the -m or --merge flags to execute the handlebars and merge in the merge variables located in /sandbox/merge-vars.json.

Optional: -p <policy id> or --policy-id <policy id> flag

Supply an ID for an existing sandbox policy ID with the -p or --policy-id option to fetch the corresponding merge variables. This will be ignored if the merge flag is set to false.

Optional: -w or --watch flag

Use the watch flag to enable live-reload that will re-render all the documents every time any of the template or merge-var files are saved.

Example

$ rp render -m -w
Documents successfully generated in the './sandbox' directory with merge-vars injected.
Watching for template or merge-var changes to re-render documents.

rp test

This command will run any tests specified in code > unit-tests locally. Any files ending in .js in this directory will be appended to the product module code files, after which the tests will be executed and test results returned in the console.

The test suite relies on Mocha & Chai for tests.

πŸ‘

Productivity tip

For best use during active code development, use the -w flag to rerun the test suite every time changes are saved. This allows rapid feedback and encourages righting more tests.

Optional: -w or --watch flag

Use the watch flag to enable live-reload of the test suite when changes to either the code or test files are saved.

Example

$ rp test -w rp test -w
Started test suite.


  getQuote
    βœ“ should return an integer suggested premium
    βœ“ should return a suggested premium of R115.17 (in cents)


  2 passing (8ms)

Completed test suite.
Watching for code or test file changes.

rp lint

This command will run eslint on the product module code.

Optional: -f or --fix flag

Use the -f or --fix flag to automatically apply the eslint fixes to the product module code.