CLI Reference
The @vtex/fsp-cli is the glue that ties all modules together, both in local development and when building the modules.
Commands
Init
The init command sets up the store monorepo for development.
Arguments
N/A
Flags
| Flag | Semantics |
|---|---|
--from-discovery | Initializes the store monorepo from an existing Discovery repo |
init writes only @vtex/fsp-cli into the root manifest — each module declares the CLI that builds it — and adds the setting that keeps those CLIs’ dependencies apart for the package manager it detects. See the monorepo reference for both. The package manager the project already uses is carried over rather than replaced.
Create
This command creates a new module customization. If no argument is passed to the command, a wizard will guide the user through all the options.
Arguments
| Argument | Semantic | Required |
|---|---|---|
account | the account that will be customized | false |
module | the module that will be customized | false |
path | the path where the module customization code will live | false |
After scaffolding, create adds the module’s CLI to the manifest it just wrote, puts the module in the workspace globs, and updates the isolation setting if that manager needs one — so the new module builds without further setup. See fsp doctor.
Flags
N/A
Dev
This command starts the development environment for a given account The account must be a key on the stores object inside the faststore.json file.
All modules listed inside the stores.{account} key will be started on their assigned ports and a proxy server will be started on port 3000 by default to provide a seamless experience when customizing multiple modules.
Arguments
| Argument | Semantic | Required |
|---|---|---|
account | the account for which the development servers will be started | true |
Flags
| Argument | Semantic | Required |
|---|---|---|
--proxy-port | a custom port for the proxy server to be started on | false |
Build
The build command is used to build the production-ready version of each module of an account. If no modules are specified as an argument, all modules will be built. The account and modules specified must match what’s available on faststore.json.
Arguments
| Argument | Semantic | Required |
|---|---|---|
account | the account for which the modules will be built | true |
moduleList | a comma separated list of modules to build. | false |
Flags
N/A
Doctor
Checks that the monorepo keeps each module’s dependencies to itself, and repairs it with --fix. dev and build run the same checks but only report; this is the command that changes anything. See fsp doctor for what it looks at.
Arguments
| Argument | Semantic | Required |
|---|---|---|
account | the account to check. Defaults to every account configured. | false |
Flags
| Flag | Semantics |
|---|---|
--fix | Apply the repairs instead of only reporting them |
Serve
Run the output of the build command locally.
Arguments
| Argument | Semantic | Required |
|---|---|---|
account | the account for which we are running the build outputs | true |
Flags
N/A
Lifecycle hooks
A module CLI can ask fsp to run one of its own commands around dev, build or serve. It declares that in its package.json, mapping a lifecycle point to a command it ships:
{ "fsp": { "hooks": { "preBuild": "analyze", "postBuild": "report" } }}The available points are preDev, postDev, preBuild, postBuild, preServe and postServe. A hook receives the same arguments as the command it wraps, and runs in its own process like any other module command — so it resolves its own dependencies, and a non-zero exit fails the fsp command that triggered it.
Modules that declare no hooks are simply skipped; nothing is loaded to find that out.
Note that postDev runs once the dev servers have been started rather than once they are accepting connections. fsp starts them and brings up its proxy without waiting, so the proxy is there while they are still booting.