Command Line Interface (CLI)
The Bojagi CLI is a toolchain which assists in previewing local stories and deploying them to the Bojagi service.
Installation
Bojagi CLI requirements:
- React 16.8+
- Webpack 4+
- Node.js 12+
The @bojagi/cli CLI is to be installed within your repositories devDependencies
:
$ yarn add -D @bojagi/cli
$ npm install --save-dev @bojagi/cli
preview
command
The $ yarn bojagi preview
$ npx bojagi preview
Opens a local preview of how stories render inside the Bojagi webapp.
deploy
command
The The easiest way to do this is with the following command:
$ yarn bojagi deploy
$ npx bojagi deploy
This command does component analysis, builds the components with webpack and uploads them to Bojagi.
The above command works without specifying the commit. In the case your CI is not supported or the
commit couldn't be received through the git
client, use the --commit
argument:
$ yarn bojagi deploy --commit commit-sha1-id
$ npx bojagi deploy --commit commit-sha1-id
The deploy
command is an all-in-one command that does the same as the following commands
bojagi build
bojagi upload
Because of this, the deploy
command accepts all arguments, that you can pass to these commands. For more detailed descriptions see further below.
Going through the process step by step
In some cases you need to have more control over the deploy
process. For those cases, the process can be split into smaller subtasks with the following commands:
bojagi build
bojagi upload
build
command
The $ yarn bojagi build
$ npx bojagi build
The build
command scans the repository for stories and bundles the matching components. Currently, the supported module bundler is webpack.
This creates the components JavaScript files and a commons.js
file that includes all JavaScript code that is shared by all components.
upload
command
The $ yarn bojagi upload
$ npx bojagi upload
After the components build they can be uploaded. The upload
command optionally accepts the commit ID with the --commit
argument.
The commit is automatically retrieved from the environment variables. When the commit can't be detected, it needs to be passed specifically.
Note that when specifying the commit via an argument, it overrides the commit detected from your CI or Git.
scan
command
The $ yarn bojagi scan
$ npx bojagi scan
Lists the number of found stories. Convenient when testing a custom storyPath configuration.