Skip to content

Add factory:setup + upfront prerequisite checks for pnpm factory:go#5591

Open
lukemelia wants to merge 2 commits into
mainfrom
cs-12186-a-fresh-cardstackboxel-checkout-cannot-run-pnpm-factorygo
Open

Add factory:setup + upfront prerequisite checks for pnpm factory:go#5591
lukemelia wants to merge 2 commits into
mainfrom
cs-12186-a-fresh-cardstackboxel-checkout-cannot-run-pnpm-factorygo

Conversation

@lukemelia

Copy link
Copy Markdown
Contributor

Problem

On a fresh pnpm install-only checkout, pnpm factory:go could not run end-to-end. It failed with a chain of four distinct blockers, each surfacing as a separate opaque crash from deep inside a run, and each requiring monorepo-internals knowledge to fix:

  1. No working Node pin — root package.json requires node >=24, but the only pin was .nvmrc (Volta doesn't read it); software-factory's volta.extends: "../../package.json" dead-ended because the root had no volta block.
  2. Unbuilt boxel-cli/dist/api.js — the entrypoint imports @cardstack/boxel-cli/api, which resolves to a gitignored dist/api.js that nothing in the factory:go path builds → ERR_MODULE_NOT_FOUND at module load.
  3. Host build lacking dev-mode test entriesboxel test's harness needs host/dist/tests/index.html, only emitted by a dev-mode host build.
  4. Missing Playwright browser binaryboxel test launches headless Chromium; the binary was never downloaded.

None were documented, and no error pointed at the next blocker in the chain.

Fix

Attacks the root cause (factory:go did zero upfront validation) rather than committing build artifacts:

  • src/preflight.ts (new) — detects all four prerequisites. Imports nothing from boxel-cli, so it can run before the dist/api.js import that used to crash first.
  • src/cli/factory-entrypoint.ts — runs preflight up front and defers the boxel-cli import until it passes. Missing prerequisites produce one consolidated message pointing at pnpm factory:setup; every missing item is listed with its individual fix command. --help still works.
  • scripts/factory-setup.ts + factory:setup script (new) — idempotent bootstrap that builds the missing artifacts and installs the Playwright browser, skipping anything already present. --force rebuilds everything.
  • Root package.json — added a real volta pin (node: 24.17.0, matching .nvmrc/devEngines) so the existing volta.extends chain resolves.
  • README — documented the one-time setup and the Node requirement.

Verification

  • Preflight self-check reports the correct satisfied/missing set and formats the consolidated message.
  • --help → usage, exit 0.
  • Simulated missing dist/api.js → clean consolidated message + exit 1 (no ERR_MODULE_NOT_FOUND).
  • factory:setup no-op run skips all three steps, exit 0.
  • eslint + prettier clean; ember-tsc --noEmit clean.

Out of scope

This handles missing artifacts on a fresh checkout. A stale dist/api.js (present but built from older source) still passes the existence check yet can crash on a missing named export; factory:setup --force fixes it, but automatic staleness detection is a possible follow-up.

🤖 Generated with Claude Code

A fresh checkout could not run pnpm factory:go without four undocumented
manual fixes, each surfacing as a separate opaque crash from deep inside a
run: no working Node pin, an unbuilt boxel-cli dist/api.js, a host build
lacking dev-mode test entries, and a missing Playwright browser binary.

- Add src/preflight.ts: detects all four prerequisites (Node >= 24,
  boxel-cli/dist/api.js, host/dist/tests/index.html, Playwright
  chromium-headless-shell) without importing boxel-cli, so the check runs
  before the dist/api.js import that would otherwise crash first.
- factory-entrypoint.ts now runs preflight up front and defers the
  boxel-cli import until it passes, reporting every missing prerequisite at
  once and pointing at pnpm factory:setup. --help still works.
- Add scripts/factory-setup.ts (pnpm factory:setup): idempotent bootstrap
  that builds the missing artifacts and installs the Playwright browser,
  skipping anything already present (--force rebuilds all).
- Add a real volta pin to the root package.json so the existing
  volta.extends chain in software-factory resolves a Node version.
- Document the one-time setup and Node requirement in the README.

CS-12186

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Host Test Results

    1 files  ±    0      1 suites  ±0   2h 26m 1s ⏱️ + 2h 15m 25s
3 355 tests +3 203  3 340 ✅ +3 189  15 💤 +14  0 ❌ ±0 
3 373 runs  +3 221  3 358 ✅ +3 207  15 💤 +14  0 ❌ ±0 

Results for commit f582171. ± Comparison against earlier commit b57fec9.

Realm Server Test Results

    1 files  ±0      1 suites  ±0   12m 58s ⏱️ + 1m 21s
1 934 tests +1  1 934 ✅ +1  0 💤 ±0  0 ❌ ±0 
2 013 runs  +1  2 013 ✅ +1  0 💤 ±0  0 ❌ ±0 

Results for commit f582171. ± Comparison against earlier commit b57fec9.

preflight locates the Playwright browser cache via homedir(). Two
factory-entrypoint integration tests override HOME to isolate the
boxel-cli profile, which hid the browsers CI installed under the real
home — preflight reported the Chromium headless-shell binary missing and
aborted factory:go before either test reached the behavior it asserts.

Export preflight's browser-cache resolver and pass its result to the
spawned factory:go via PLAYWRIGHT_BROWSERS_PATH (which preflight honors
ahead of homedir()), so the check finds the browsers regardless of the
child's HOME.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant