FeaturevisorFeaturevisor

Advanced

Command Line Interface (CLI) Usage

Beyond just initializing a project and building datafiles, Featurevisor CLI can be used for a few more purposes.

Installation

Install with npm:

$ npm install -g @featurevisor/cli

Or use npx to run the CLI without installing it:

$ npx @featurevisor/cli <command>

Rest of the documentation assumes that you have installed the CLI globally.

Initializing a project

Scaffold a new project in your working directory:

$ mkdir my-project && cd my-project
$ featurevisor init

If you wish to initialize a specific example as available in the monorepo:

$ featurevisor init --example <name>

Learn more in Quick start.

Linting YAMLs

Check if the YAML files have any syntax or structural errors:

$ featurevisor lint

Lear more in Linting.

Building datafiles

Generate JSON files on a per environment and tag combination as exists in project configuration:

$ featurevisor build

Learn more in Building datafiles.

Testing

Test your features and segments:

$ featurevisor test

Learn more in Testing.

Restore state files

Building datafiles also generates state files.

To restore them to last known state in Git, run:

$ featurevisor restore

Generate static site

Build the site:

$ featurevisor site export

Serve the built site (defaults to port 3000):

$ featurevisor site serve

Serve it in a specific port:

$ featurevisor site serve -p 3000

Learn more in Status site.

Generate code

Generate TypeScript code from your YAMLs:

$ featurevisor generate-code --language typescript --out-dir ./src

See output in ./src directory.

Learn more in code generation page.

Find duplicate segments

It is possible to end up with multiple segments having same conditions in larger projects. This is not a problem per se, but we should be aware of it.

We can find these duplicates early on by running:

$ featurevisor find-duplicate-segments
Previous
Managing dependencies