-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: Adds commands to the documentation #25589
Changes from all commits
b23ccf1
6376e9d
8e1ec5a
20f1a91
1cc0ba0
fbf50c6
19ff85d
cb22ad2
e8dc7ca
9fcfeb2
00977ce
0aad12e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -14,9 +14,15 @@ Storybook collects completely anonymous data to help us improve user experience. | |||||
|
||||||
All of the following documentation is available in the CLI by running `storybook --help`. | ||||||
|
||||||
<Callout variant="info" icon="💡"> | ||||||
|
||||||
The commands work slightly differently if you're using npm instead of Yarn to publish Storybook. For example, `npm run storybook build -- -o ./path/to/build`. | ||||||
|
||||||
</Callout> | ||||||
|
||||||
### `dev` | ||||||
|
||||||
Compiles and serves a development build of your Storybook that reflects your source code changes in the browser in real time. Should be run from the root of your project. | ||||||
Compiles and serves a development build of your Storybook that reflects your source code changes in the browser in real-time. It should be run from the root of your project. | ||||||
|
||||||
```shell | ||||||
storybook dev [options] | ||||||
|
@@ -52,7 +58,7 @@ With the release of Storybook 8, the `-s` CLI flag was removed. We recommend usi | |||||
|
||||||
### `build` | ||||||
|
||||||
Compiles your Storybook instance so it can be [deployed](../sharing/publish-storybook.md). Should be run from the root of your project. | ||||||
Compiles your Storybook instance so it can be [deployed](../sharing/publish-storybook.md). It should be run from the root of your project. | ||||||
|
||||||
```shell | ||||||
storybook build [options] | ||||||
|
@@ -74,8 +80,150 @@ Options include: | |||||
| `--disable-telemetry` | Disables Storybook's telemetry. Learn more about it [here](../configure/telemetry.md).<br/>`storybook build --disable-telemetry` | | ||||||
| `--test` | Optimize Storybook's production build for performance and tests by removing unnecessary features with the `test` option. Learn more [here](../api/main-config-build.md).<br/>`storybook build --test` | | ||||||
|
||||||
<Callout variant="info" icon="💡"> | ||||||
<!-- Re-read this for accuracy --> | ||||||
|
||||||
### `init` | ||||||
|
||||||
Installs Storybook into your project per specified version (e.g., `@latest`, `@next`). Read more in the [installation guide](../get-started/install.md). | ||||||
|
||||||
```shell | ||||||
storybook[@version] init [options] | ||||||
``` | ||||||
|
||||||
Options include: | ||||||
|
||||||
| Option | Description | | ||||||
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||||||
| `-b`, `--builder` | Defines the [builder](../builders/index.md) to use for your Storybook instance<br/>`storybook init --builder webpack5` | | ||||||
| `-f`,`--force` | Forcefully installs Storybook into your project, prompting you to overwrite existing files<br/>`storybook init --force` | | ||||||
| `-s`, `--skip-install` | Skips the dependency installation step. Used only when you need to configure Storybook manually<br/>`storybook init --skip-install` | | ||||||
| `-t`, `--type` | Defines the [framework](../configure/frameworks.md) to use for your Storybook instance<br/>`storybook init --type solid` | | ||||||
| `-y`, `--yes` | Skips interactive prompts and automatically installs Storybook per specified version<br/>`storybook init --yes` | | ||||||
| `--package-manager` | Sets the package manager to use when installing the addon.<br/> Available package managers include `npm`, `yarn`, and `pnpm`<br/>`storybook init --package-manager pnpm` | | ||||||
| `--use-pnp` | Enables [Plug'n'Play](https://yarnpkg.com/features/pnp) support for Yarn. This option is only available when using Yarn as your package manager<br/>`storybook init --use-pnp` | | ||||||
|
||||||
### `add` | ||||||
jonniebigodes marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
Installs a Storybook addon and configures your project for it. Read more in the [addon installation guide](../addons/install-addons.md). | ||||||
|
||||||
```shell | ||||||
storybook add [addon] [options] | ||||||
``` | ||||||
|
||||||
Options include: | ||||||
|
||||||
| Option | Description | | ||||||
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||||||
| `--package-manager` | Sets the package manager to use when installing the addon.<br/> Available package managers include `npm`, `yarn`, and `pnpm`<br/>`storybook add [addon] --package-manager pnpm` | | ||||||
| `-s`, `--skip-postinstall` | Skips post-install configuration. Used only when you need to configure the addon yourself<br/>`storybook add [addon] --skip-postinstall` | | ||||||
|
||||||
### `remove` | ||||||
|
||||||
Deletes a Storybook addon from your project. Read more in the [addon installation guide](../addons/install-addons.md#removing-addons). | ||||||
|
||||||
```shell | ||||||
storybook remove [addon] [options] | ||||||
``` | ||||||
|
||||||
Options include: | ||||||
|
||||||
| Option | Description | | ||||||
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||||||
| `--package-manager` | Sets the package manager to use when removing the addon.<br/>Available package managers include `npm`, `yarn`, and `pnpm`<br/>`storybook remove [addon]--package-manager pnpm` | | ||||||
|
||||||
### `upgrade` | ||||||
|
||||||
Upgrades your Storybook instance to the latest version. Read more in the [upgrade guide](../configure/upgrading.md). | ||||||
jonniebigodes marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
```shell | ||||||
storybook upgrade [options] | ||||||
jonniebigodes marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
``` | ||||||
|
||||||
Options include: | ||||||
|
||||||
| Option | Description | | ||||||
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||||||
| `-c`, `--config-dir` | Directory where to load Storybook configurations from<br/>`storybook upgrade --config-dir .storybook` | | ||||||
| `-n`, `--dry-run` | Checks for version upgrades without installing them<br/>`storybook upgrade --dry-run` | | ||||||
| `-s`, `--skip-check` | Skips the migration check step during the upgrade process<br/> `storybook upgrade --skip-check` | | ||||||
| `-y`, `--yes` | Skips interactive prompts and automatically upgrades Storybook to the latest version<br/>`storybook upgrade --yes` | | ||||||
| `--package-manager` | Sets the package manager to use when installing the addon.<br/> Available package managers include `npm`, `yarn`, and `pnpm`<br/>`storybook upgrade --package-manager pnpm` | | ||||||
|
||||||
### `doctor` | ||||||
|
||||||
Performs a health check on your Storybook project for common issues (e.g., duplicate dependencies, incompatible addons or mismatched versions) and provides suggestions on how to fix them. Applicable when [upgrading](../configure/upgrading.md#verifying-the-upgrade) Storybook versions. | ||||||
|
||||||
```shell | ||||||
storybook doctor [options] | ||||||
``` | ||||||
|
||||||
Options include: | ||||||
|
||||||
| Option | Description | | ||||||
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||||||
| `-c`, `--config-dir` | Directory where to load Storybook configurations from<br/>`storybook doctor --config-dir .storybook` | | ||||||
| `--package-manager` | Sets the package manager to use when running the health check.<br/>Available package managers include `npm`, `yarn`, and `pnpm`<br/>`storybook doctor --package-manager pnpm` | | ||||||
|
||||||
### `info` | ||||||
|
||||||
Reports useful debugging information about your environment. Helpful in providing information when opening an issue or a discussion. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would it make sense to mention Github here? or even a link to the repo? |
||||||
|
||||||
```shell | ||||||
storybook info | ||||||
``` | ||||||
|
||||||
Example output: | ||||||
|
||||||
```shell | ||||||
Storybook Environment Info: | ||||||
|
||||||
System: | ||||||
OS: macOS 14.2 | ||||||
CPU: (8) arm64 Apple M3 | ||||||
Shell: 5.9 - /bin/zsh | ||||||
Binaries: | ||||||
Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node | ||||||
npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm <----- active | ||||||
Browsers: | ||||||
Chrome: 120.0.6099.199 | ||||||
npmPackages: | ||||||
@storybook/addon-essentials: ^7.6.6 => 7.6.6 | ||||||
@storybook/addon-interactions: ^7.6.6 => 7.6.6 | ||||||
@storybook/addon-links: ^7.6.6 => 7.6.6 | ||||||
@storybook/addon-onboarding: ^1.0.10 => 1.0.10 | ||||||
@storybook/blocks: ^7.6.6 => 7.6.6 | ||||||
@storybook/preset-create-react-app: ^7.6.6 => 7.6.6 | ||||||
@storybook/react: ^7.6.6 => 7.6.6 | ||||||
@storybook/react-webpack5: ^7.6.6 => 7.6.6 | ||||||
@storybook/test: ^7.6.6 => 7.6.6 | ||||||
storybook: ^7.6.6 => 7.6.6 | ||||||
npmGlobalPackages: | ||||||
chromatic: ^10.2.0 => 10.2.0 | ||||||
``` | ||||||
|
||||||
### `sandbox` | ||||||
|
||||||
Generates a local sandbox project for testing Storybook features based on the list of supported [frameworks](../configure/frameworks.md). Useful for reproducing bugs when opening an issue or a discussion. | ||||||
|
||||||
```shell | ||||||
storybook sandbox [framework-filter] [options] | ||||||
``` | ||||||
|
||||||
<Callout variant="info"> | ||||||
|
||||||
The `framework-filter` argument is optional and can filter the list of available frameworks. For example, `storybook sandbox react` will only show React-based sandboxes. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just a placeholder, as the CLI options need to be accounted for the CLI versioning. |
||||||
|
||||||
</Callout> | ||||||
|
||||||
Options include: | ||||||
|
||||||
| Option | Description | | ||||||
| --------------------------- | ---------------------------------------------------------------------------------------------------- | | ||||||
| `-o`, `--output [dir-name]` | Configures the location of the sandbox project<br/>`storybook sandbox --output /my-sandbox-project` | | ||||||
| `--no-init` | Generates a sandbox project without without initializing Storybook<br/>`storybook sandbox --no-init` | | ||||||
|
||||||
<Callout variant="info"> | ||||||
|
||||||
If you're using npm instead of yarn to publish Storybook, the commands work slightly different. For example, `npm run storybook build -- -o ./path/to/build`. | ||||||
If you're looking for a hosted version of the available sandboxes, see [storybook.new](https://storybook.new). | ||||||
|
||||||
</Callout> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```shell | ||
npx storybook@latest add @storybook/addon-a11y | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```shell | ||
pnpm dlx storybook@latest add @storybook/addon-a11y | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```shell | ||
yarn dlx storybook@latest add @storybook/addon-a11y | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```shell | ||
npx storybook@latest doctor | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```shell | ||
pnpm dlx storybook@latest doctor | ||
jonniebigodes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```shell | ||
yarn dlx storybook@latest doctor | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more of a feature comment/question than a documentation one.
I didn't realize the
add
command had this limitation. How do we expect users to know the difference? Is this a short-term limitation?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shilman ☝️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can’t it handle preset style addons?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are any addons where
add
fails, we should figure out what’s going on and fix the issueThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just going on what was documented here. If that limitation isn't factual, that's great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that we're all on the same page here, this isn't on us. Our presets are working; what I've encountered during my rounds collecting community addons is basically this, I've run into situations where preset addons failed to register. I cannot know for sure what's causing it, could be an outdated version or something of that nature. Hence why I left it as such so that we don't run into any situations where a user faces a similar question, reach out to us raising an issue/ discussion when the situation is out of our control.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please share a scenario where you had this failure? Thanks!