CodeVetter · Repo Unpack · Behavior traces
chromaui/chromatic-cli
Source walks followed startup, normal publishing, sharing, and patch-workspace restoration through their concrete function calls. The publishing sequence has early-stop branches for skipped commits and fully TurboSnapped builds, plus self-skips for dry-run stages. Sharing reserves its URL before uploading and reports a terminal status afterward. Post-pipeline diagnostics and metadata handling occur after build teardown, with persistence controlled separately from artifact publication.
- Startup: register.js dispatches by process.argv[2] or falls back to main; main calls run, which parses arguments, checks Node compatibility, discovers package.json, constructs InitialContext, and calls runAll.
- Context setup: runAll calls setupContext, getPartialOptions, the credential-free branch-skip preflight, and getOptions; it seeds Runtime.forceRebuild and launches runBuild alongside checkForUpdates.
- Publish preparation: renderAuth runs runAuth; runBuild then calls renderGitInfo, renderStorybookInfo, and renderInitialize, whose initialize function gathers environment/runtime metadata, calls announceBuild, and optionally sets component owners.
- Artifact preparation: buildProject selects native or web handling; the web path resolves sourceDir, setBuildCommand, and buildStorybook unless prebuilt, then prepareProject validates files and Android artifacts, traces changes, and calculates hashes.
- Upload and completion: uploadProject calls uploadBuild and waits for deduplicated sentinels, retrying without hashes on failure; a server SKIPPED result returns partial and halts downstream tasks, otherwise verifyProject publishes/verifies and snapshotProject waits for completion and maps status to an exit code.
- Sharing: share calls setupShareContext and reserveShare, invokes onUrl immediately, runs renderBuild/renderPrepare and the Listr uploadShare task, uploads supporting files before index.html, then confirms complete/error/cancelled; confirmation failures warn without replacing the upload outcome.
- Patch builds: renderPrepareWorkspace precedes authentication; runPrepareWorkspace checks cleanliness/currentness, finds and checks out the merge base, and installs dependencies. runBuild's finally calls runRestoreWorkspace despite pipeline skips, which resets, checks out the previous branch, reinstalls, and resets again.
- Post-run persistence: runAll writes diagnostics when requested or needed for metadata, uploads metadata when a published build URL permits it, cleans implicit files, and calls checkPackageJson only for non-E2E exit codes 0/1; that function can interactively add a script using originalArgv.