Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
| ) {} | ||
|
|
||
| write(file: string, content: string) { | ||
| if (existsSync(file) && readFileSync(file, 'utf8') === content) return false; |
There was a problem hiding this comment.
Potential file inclusion attack via reading file - medium severity
If an attacker can control the input leading into the ReadFile function, they might be able to read sensitive files and launch further attacks with that information.
Show fix
Remediation: Ignore this issue only after you've verified or sanitized the input going into this function. This issue is only relevant in the backend, not in the frontend!
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
There was a problem hiding this comment.
These paths come from the user's own project or command line, and the CLI runs with the user's permissions, so it can only read files the user can already read. Nothing to fix here.
| if (existsSync(file) && readFileSync(file, 'utf8') === content) return false; | ||
| if (!this.dryRun) { | ||
| mkdirSync(path.dirname(file), { recursive: true }); | ||
| writeFileSync(file, content); |
There was a problem hiding this comment.
Potential file inclusion attack via reading file - medium severity
If an attacker can control the input leading into the ReadFile function, they might be able to read sensitive files and launch further attacks with that information.
Show fix
Remediation: Ignore this issue only after you've verified or sanitized the input going into this function. This issue is only relevant in the backend, not in the frontend!
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
There was a problem hiding this comment.
These paths come from the user's own project or command line, and the CLI runs with the user's permissions, so it can only read files the user can already read. Nothing to fix here.
|
📦 Package Size: 8048 KB Bundled dependencies compared with PR base 154df91. Bundled dependency changesVersions from emitted source maps; external dependencies are not included. CLI / Node API
GitHub Action
|
…init init now picks the Storybook project, asks for and checks the project token, keeps it in a gitignored .env, writes chromatic.config.json and the chromatic script, installs the package, and writes a GitHub workflow or prints a snippet for other CI providers. It ends by running doctor's checks, so the user sees what's left. It replaces the old init and drops its boxen and prompts dependencies. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d7b7-69d0-75bd-a184-7440f6a67cef
init can't tell from CI files whether a monorepo already runs Chromatic for a project, so its CI step wrote duplicate workflows. It now ends with a link to the CI setup steps instead, and drops --ci, --skip-ci and the per-project secret names. TurboSnap comes from doctor's fix in the closing check, which asks how CI runs Chromatic first. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d7b7-69d0-75bd-a184-7440f6a67cef
ec08199 to
ae4f6f7
Compare
Rebuilds
chromatic initas a step-by-step setup modeled onstorybook init: it picks the project, checks the token, writes the config and script, installs once, sets up CI, and ends withdoctor's checks and fixes. It sits on thedoctorPR below it in the stack.🎬 Demo
chromatic initin a pnpm monorepo with two Storybooks, wherepackages/uihas nobuild-storybookscript: pickspackages/ui, uses the token from the environment, picks GitHub Actions, then accepts "Set buildScriptName". Recorded on an earlier commit with a fake token and a local stand-in for the token check; the flow is unchanged.📋 What changed
bin-src/setup/init.tsinit: preflight, detect the project, check the token, write the config, install once, set up CI, check the result and offer fixes, then print next stepsbin-src/setup/token.ts,project.ts.env) and picking a project and its secret namebin-src/setup/ciTemplates.tsbin-src/setup/ci.ts,detect.ts,shared.tsinitneedsbin-src/register.js,bin-src/init.tsinitto the new code. Removes the oldinitwith its test, and theboxenandpromptsdependencies only it used💡 Why
initdoes very little. On Storybook projects it only adds a script. On Storybook 9+ E2E projects it fails, because it tries to install@storybook/addon-essentialsat a version that was never published.initnow writes a working TurboSnap setup and CI job, then checks the result withdoctor.🛠️ How it works
CHROMATIC_PROJECT_TOKEN(shows its last four characters). Checks it with the same exchange every build does, and offers to save it to a gitignored.env. Never writes it topackage.jsonor the config file.chromatic.config.jsonnext to the project, withonlyChanged: trueexcept for Playwright, Cypress and a Storybook that CI uploads prebuilt. Reuses an existing.jsoncor.json5, and says what to add instead of rewriting one (that would drop its comments).chromatic(and@chromatic-com/<framework>for E2E) and the script, then runs one install..github/workflows/chromatic.yml, orchromatic-<path>.ymlnamed like the secret for a monorepo project (on push,fetch-depth: 0,workingDir,corepack enablefor Yarn 2+ and pnpm) and prints a snippet for other providers, outside the box so it pastes as valid YAML. Never overwrites a workflow. Skips when a CI job already runs Chromatic for the project.doctorchecks and offers each fix. Likedoctor, exits 1 when a check still fails.Flags:
--project,--framework,--project-token,--ci <provider>,--skip-ci,--skip-install,--dry-run,--yes. Without a terminal or in CI it never waits for input.⚖️ Trade-offs & decisions
initasks for one.init --cioverrides what it detects.CHROMATIC_PROJECT_TOKEN_PACKAGES_UI), sopackages/uiandapps/uican't collide. A single-project repo keepsCHROMATIC_PROJECT_TOKEN. Monorepo CI jobs are named the same way (chromatic-packages-ui), so two projects' snippets can share one file.🧪 Verification
initin a pnpm monorepo with two Storybooks (Vite and webpack)CI=1 node dist/bin.cjs init --yes --skip-install --project packages/ui --ci githubCHROMATIC_PROJECT_TOKEN_PACKAGES_UIchromatic.config.jsoncinit --yes"onlyChanged": true; no.jsonwritten next to it. Broken JSON: left alone, exit 0 with a pointer todoctor-cinitwithstorybook build -c storybook-configpackages/uiandapps/uiinit --project …for eachCHROMATIC_PROJECT_TOKEN_APPS_UI/_PACKAGES_UI, andchromatic.yml/chromatic-packages-ui.ymlnamedChromatic (<path>)--frameworkinit --framework viteston a Storybook repo--frameworkoverrides detectioninitsaving a pasted token with!.envin.gitignore, then without it.envinit --yestwice with a dependency that doesn't existinit --project packages/ui --framework playwright --ci gitlab --dry-run, then ran the emitted lines in one shell withpwdfor the commandspackages/ui(before: the secondcd packages/uifailed)CI=1 init --project packages/ui --ci gitlab --dry-run --yesin a pnpm monorepo;--ci bitbucketin a Playwright appyaml(before: wrapped at 80 columns with│borders)initinit --yes --skip-ciwithstorybookConfigDir: "nowhere"2140141evs.1c936df6init --yeswith a workflow whosechromaui/actionstep setsstorybookBuildDir;init --ci gitlabfor two monorepo projects"onlyChanged": truewritten, twochromatic:jobs. After: noonlyChanged,chromatic-packages-ui:andchromatic-packages-web:init --ci github --yesin a project withpackageManager: yarn@4.18.0- run: corepack enableaftersetup-node, beforeyarn install --immutableCI=1 initon an open pipe; a pnpm install that failscd, the sharedchromatic:job name, and nocorepack enableinitwithCHROMATIC_INDEX_URLpointed at a local stand-in👀 Reviewer notes
bin-src/setup/init.ts;mainat the bottom reads as the step list.📦 Published PR as canary version:
18.15.2--canary.1730.45043693619.0✨ Test out this PR locally via:
npm install chromatic@18.15.2--canary.1730.45043693619.0 # or yarn add chromatic@18.15.2--canary.1730.45043693619.0