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:
$ npx featurevisor buildOutput#
The build output can be found in the datafiles directory.
If your featurevisor.config.js file looks like this:
module.exports = { tags: ['all'], environments: ['staging', 'production'],}And you have a target:
description: All featuresThen the contents of your datafiles directory will look like this:
$ tree datafiles.├── production│ └── featurevisor-all.json└── staging └── featurevisor-all.json2 directories, 2 filesNext 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:
$ npx featurevisor build --revision 1.2.3Revision 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:
$ npx featurevisor build --revision-from-hashIf 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:
$ npx featurevisor build --no-state-filesPrinting#
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:
$ npx featurevisor build \ --feature=foo \ --environment=production \ --json \ --prettyOr if you with to print datafile containing all features for a specific environment:
$ npx featurevisor build --environment=production --json --prettyTo print a specific target-shaped datafile:
$ npx featurevisor build --environment=production --target=web --json --prettyThis 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:
$ npx featurevisor build --datafiles-dir=./custom-directoryTargets#
The same build command generates one datafile for each target defined in targets/.
To build only selected targets, pass --target once or more:
$ npx featurevisor build --target=web --target=mobileRepeated 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.

