1 | # Storybook Chromatic & Storybook Chroma
|
2 |
|
3 | A CLI to connect your Storybook with Chromatic or Chroma.
|
4 |
|
5 | <img width="100%" src="https://user-images.githubusercontent.com/3070389/63930825-5abe5f00-ca54-11e9-8320-7ee949823458.gif" alt="">
|
6 |
|
7 | ## Install
|
8 |
|
9 | ```sh
|
10 | yarn add storybook-chromatic
|
11 | ```
|
12 |
|
13 | ## Usage
|
14 |
|
15 | You can use this package normally, which means installing it and adding a script called `chromatic` to your `package.json`
|
16 |
|
17 | ```
|
18 | "chromatic": "chromatic",
|
19 | ```
|
20 |
|
21 | But alternatively (and this is useful for testing) you can use npx:
|
22 |
|
23 | **Use a git branch**:
|
24 | ```sh
|
25 | npx -p chromaui/chromatic-cli#master chromatic --dev
|
26 | ```
|
27 |
|
28 | **Use a debug version on npm**:
|
29 | ```sh
|
30 | npx -p storybook-chromatic chromatic
|
31 | ```
|
32 |
|
33 | Using npx has pros and cons:
|
34 |
|
35 | - đź‘Ť You'll never be out of date, you'll use the latest version every time, never have to worry about upgrading this.
|
36 | - đź‘Ť You don't need this package as a dependency, and don't need to install it during local development
|
37 | - đź‘Ž This will add a delay when you actually do want to run this, like in your CI, delaying feedback.
|
38 |
|
39 | ### Usage in a github action
|
40 |
|
41 | There are examples here: [/.github/workflows](/.github/workflows).
|
42 |
|
43 | Do not run this based on a github pull_request event. If you do, the commit and branch will get reported wrong, use [https://github.com/chromaui/action](https://github.com/chromaui/action) instead.
|
44 |
|
45 | ### Main options
|
46 |
|
47 | ```
|
48 | --app-code="<your app code>"
|
49 | ```
|
50 |
|
51 | You can also use the environment variable: `CHROMATIC_APP_CODE`
|
52 |
|
53 | ### Storybook options
|
54 |
|
55 | ```
|
56 | --build-script-name [name], -b The npm script that builds your Storybook [build-storybook]
|
57 | --script-name [name], -s The npm script that starts your Storybook [storybook]
|
58 | --exec <command>, -e Alternatively, a full command to run to start your storybook
|
59 | --do-not-start, -S Don't attempt to start or build; use if your Storybook is already running
|
60 |
|
61 | --storybook-port <port>, -p What port is your Storybook running on (auto detected from -s, if set)
|
62 | --storybook-url <url>, -u Storybook is already running at (external) url (implies -S)'
|
63 | --storybook-build-dir, -d <dirname> Provide a directory with your built storybook; use if you've already built your storybook
|
64 | --storybook-https Use if Storybook is running on https (auto detected from -s, if set)
|
65 | --storybook-cert <path> Use if Storybook is running on https (auto detected from -s, if set)
|
66 | --storybook-key <path> Use if Storybook is running on https (auto detected from -s, if set)
|
67 | --storybook-ca <ca> Use if Storybook is running on https (auto detected from -s, if set)
|
68 | ```
|
69 |
|
70 | These options are not required, this CLI is 0-config if you have a `build-storybook` script in your `package.json`.
|
71 |
|
72 | ### Chromatic options
|
73 |
|
74 | ```
|
75 | --auto-accept-changes [branch] Accept any (non-error) changes or new stories for this build [only for <branch> if specified]'
|
76 | --exit-zero-on-changes [branch] Use a 0 exit code if changes are detected (i.e. don't stop the build) [only for <branch> if specified]
|
77 | --exit-once-uploaded [branch] Exit with 0 once the built version has been sent to chromatic [only for <branch> if specified]
|
78 | --ignore-last-build-on-branch [branch] Do not use the last build on this branch as a baseline if it is no longer in history (i.e. branch was rebased) [only for <branch> if specified]'
|
79 | --preserve-missing Treat missing stories as unchanged (as opposed to deleted) when comparing to the baseline'
|
80 | --no-interactive Do not prompt for package.json changes
|
81 | --only <component:story> Only run a single story or a glob-style subset of stories (for debugging purposes
|
82 | ```
|
83 |
|
84 | ### Debug options
|
85 |
|
86 | ```
|
87 | --skip Skip chromatic tests (mark as passing)
|
88 | --list List available stories (for debugging purposes)
|
89 | --ci This build is running on CI, non-interactively (alternatively, pass CI=true)
|
90 | --debug Output more debugging information
|
91 | ```
|
92 |
|
93 | ### Environment variables
|
94 |
|
95 | This package will load any variables from a `.env` file if present
|
96 |
|
97 | ## Issues
|
98 |
|
99 | If you encounter issues with the CLI please report them via the in-app chat (Intercom widget) or at https://github.com/chromaui/chromatic-cli/issues. Thanks!
|
100 |
|
101 | ## Contributing
|
102 |
|
103 | Because of the nature of this package: it being a connector between Storybook and a web service, you may need an app code to test this locally. Just send us a message at opensource@hichroma.com or sign up for an account!
|
104 |
|
105 | All contributions are welcome!
|
106 |
|
107 | ## Future plans:
|
108 |
|
109 | - We'd like to unify this so there's just a single package on npm.
|
110 | - Migrate to Typescript
|
111 | - Deprecate all the storybook options in favor of a sane `--config` flag
|
112 |
|
113 | ## Publishing
|
114 |
|
115 | We publish with a script:
|
116 |
|
117 | ```sh
|
118 | ./scripts/publish.js
|
119 | ```
|
120 |
|
121 | You can pass any flags to this you'd normally be able to pass to `npm publish`, such as `--dry-run` or `--tag="alpha"`.
|
122 |
|
123 | Before publishing we check if the current user has permissions and if the version isn't already on npm
|
124 |
|
125 | ## Compatibility & versioning
|
126 |
|
127 | Compatibility is guaranteed between this package and Chromatic like so:
|
128 |
|
129 | - Production Chromatic ensures it’s compatible with what’s on NPM
|
130 | - What's on the master branch is equal to what's published on NPM
|
131 | - This package ensures it’s compatible with production Chromatic
|
132 |
|
133 | To facilitate upgrading in the future, removing and adding features, this is the process:
|
134 |
|
135 | - Any new features will have to be on Chromatic production before they could be used in this package
|
136 | - We can feature flags to be able to test new functionality
|
137 | - Chromatic production can not remove any features this package depends on until after the usage has been removed from this package.
|
138 | Plus a grace period so users have upgraded
|