storyshelf
v0.19.0
Published
StoryShelf CLI: self-hosted visual testing and review for Storybook.
Maintainers
Readme
storyshelf
The StoryShelf command-line interface (binary storyshelf): scaffold servers, initialize client config, create projects and CI tokens, upload built Storybooks as builds, purge expired builds, and retry failed builds. It talks to a running StoryShelf server over /api/v1 and has no Playwright or server dependencies, so it installs cleanly in CI.
Install
nub add storyshelfor
npm install -g storyshelfQuick start
Initialize client config (requires .storybook/main.*):
storyshelf init --url https://shelf.example.com --slug my-app
# writes .storybook/storyshelf.jsonCreate a project on the server (requires site-admin token and .storybook/main.*):
storyshelf create --url https://shelf.example.com --name my-app --token $SHELF_ADMIN_TOKEN
# prints slug + CI token and writes .storybook/storyshelf.jsonScaffold a server:
npx create-storyshelf --dir ./my-shelfAPI
Commands
storyshelf init — initialize .storybook/storyshelf.json (client config). Fails if .storybook/main.* not found. Prompts if flags missing.
storyshelf init --url <url> --slug <slug> [--build-dir <dir> --build-command <cmd> --skip <glob> -c <config>]storyshelf create — create a project and CI token on a server (requires admin token). Fails if .storybook/main.* not found and writes .storybook/storyshelf.json.
storyshelf create --url <url> --name <name> --token <admin-token>
# or env SHELF_ADMIN_TOKENcreate-storyshelf — scaffold a new StoryShelf server project.
npx create-storyshelf --dir <dir>storyshelf upload — upload a built Storybook as a build. --url/--slug optional when .storybook/storyshelf.json exists (flags > env > file). The token comes from SHELF_TOKEN (--token warns: arguments show in the process list). --sha/--branch come from the CI provider (the PR head on a pull request), then local git. Running storyshelf with no args is the same command, with no flags: it uploads if config exists, else shows help to run init.
storyshelf upload --url <url> --slug <slug> --token <token> \
--sha <sha> --branch <branch> \
[--build-dir <dir> --build-command <cmd> --force-build --skip <glob> -c <config>] [--message <msg>] \
[--author-email <email>] [--author-name <name>]The default --build-dir is storybook-static or buildDir from .storybook/storyshelf.json (see Configuration). If buildDir is missing/empty, upload runs buildCommand or npm run <buildScriptName>.
Instance commands (serve, migrate, purge, check-storage, doctor) are in storyshelf-server, a bin of @storyshelf/app; storyshelf purge, storyshelf server … and storyshelf mcp … no longer exist: scaffold with create-storyshelf and @storyshelf/mcp (storyshelf-mcp init|serve).
storyshelf retry — retry a failed build.
storyshelf retry --url <url> --slug <slug> --build-id <id> [--token <token>]storyshelf protect — print, validate and (only with --apply) write the branch rule that requires StoryShelf's gate status. Dry run by default; needs an admin token for the git host (--token, GITHUB_TOKEN or GITLAB_TOKEN), and talks to the host directly, not to the StoryShelf server. Exits 1 when the rule is missing the check and nothing was written.
storyshelf protect --provider github --repo <owner/repo> [--branch main] [--prefix storyshelf] [--gate testing|review] [--apply]
storyshelf protect --provider gitlab --repo <group/project> [--host <url>] [--apply]Example CI snippet
# .github/workflows/visual.yml
on:
push:
pull_request:
jobs:
visual:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 24 }
- run: nub install && nub run build
- run: nubx storybook build -o storybook-static
- run:
nubx storyshelf upload \
--token "${{ secrets.SHELF_TOKEN }}" \
--sha "${{ github.sha }}" \
--branch "${{ github.ref_name }}"
# --url/--slug from .storybook/storyshelf.jsonHow it fits in
The server is scaffolded via create-storyshelf, which assembles @storyshelf/core, and @storyshelf/db/sqlite (local storage is built into core) and runs Playwright captures. The CLI never imports that stack — client-only by design.
See docs/architecture.md for the capture workflow and docs/testing.md for the gated browser integration suite.
