Featurevisor

Workflow

Building datafiles

Datafiles are JSON files generated from targets and optional environments. They are used to evaluate features in your application via Featurevisor SDKs.

Usage

Use Featurevisor CLI to build your datafiles:

Command
$ npx featurevisor build

Output

The build output can be found in the datafiles directory.

If your featurevisor.config.js file looks like this:

featurevisor.config.js
module.exports = {
tags: ['all'],
environments: ['staging', 'production'],
}

And you have a target:

targets/all.yml
description: All features

Then the contents of your datafiles directory will look like this:

$ tree datafiles
.
├── production
│   └── featurevisor-all.json
└── staging
└── featurevisor-all.json
2 directories, 2 files

Next to datafiles, the build process will also generate some additional JSON files that we can learn more about in State files.

Revision

By default, Featurevisor will increment the revision number as found in .featurevisor/REVISION file (learn more in state files).

Custom revision

You can optionally customize the revision value when building datafiles by passing a --revision flag:

Command
$ npx featurevisor build --revision 1.2.3

Revision from hash

If instead of an incremented revision, you want to use the hash of the individual datafile content, you can pass --revision-from-hash:

Command
$ npx featurevisor build --revision-from-hash

If in a particular datafile the content has not changed, the revision will remain the same as the previous build.

This is useful for caching purposes.

No state files

If you wish to build datafiles without making any changes to state files, you can pass the --no-state-files flag:

Command
$ npx featurevisor build --no-state-files

Printing

You can print the contents of a datafile for a single feature or all the features in an environment without writing anything to disk by passing these flags:

Command
$ npx featurevisor build \
--feature=foo \
--environment=production \
--json \
--pretty

Or if you with to print datafile containing all features for a specific environment:

Command
$ npx featurevisor build --environment=production --json --pretty

To print a specific target-shaped datafile:

Command
$ npx featurevisor build --environment=production --target=web --json --pretty

This is useful primarily for debugging and testing purposes.

If you are an SDK developer in other languages besides JavaScript, you may want to use this handy command to get the generated datafile content in JSON format that you can use in your own test runner.

Datafiles directory

By default, datafiles will be generated in the datafiles directory, or your custom directory if you have specified it under datafilesDirectoryPath in your featurevisor.config.js file.

You can optionally override it from CLI:

Command
$ npx featurevisor build --datafiles-dir=./custom-directory

Targets

The same build command generates one datafile for each target defined in targets/.

To build only selected targets, pass --target once or more:

Command
$ npx featurevisor build --target=web --target=mobile

Repeated targets are deduplicated. When printing with --json or --print, only one target can be selected because the command writes one datafile to standard output.

Learn more in Targets page.

Previous
Linting