Skip to content

Fix publish for projects created before the production template#26

Merged
twilson63 merged 1 commit into
mainfrom
fix/publish-legacy-projects
Jun 12, 2026
Merged

Fix publish for projects created before the production template#26
twilson63 merged 1 commit into
mainfrom
fix/publish-legacy-projects

Conversation

@twilson63

Copy link
Copy Markdown
Collaborator

Fixes the publish failure Tom hit in production: npm error Missing script: "build" during the Kaniko build.

Root cause: projects saved before #24 (or whose package.json the agent rewrote from the old template) have a dev-only package.json and no server.js/zepto-bridge.js — but the injected Dockerfile runs npm run build and node server.js.

Fix: preparePublishFiles() backfills the missing infrastructure into the publish payload client-side (where the template files are available): copies server.js/zepto-bridge.js from the current template when absent, and adds build/start scripts plus hyper-zepto/vite deps to package.json if missing. Anything the project already defines is left untouched; current-template projects pass through unchanged (identity, asserted byte-for-byte).

  • 5 new unit tests; headless harness now publishes a legacy-shaped project and asserts the payload is deployable (9/9 checks green)
  • Full suites green: 70 Gleam + 61 root vitest + 99 server vitest

🤖 Generated with Claude Code

Publishing a pre-Phase-1 project failed in the platform build with
'npm error Missing script: "build"': its package.json predates the
build/start scripts and the file map has no server.js or zepto-bridge.js,
which the injected Dockerfile depends on.

preparePublishFiles() now backfills the missing infrastructure at publish
time: server.js and zepto-bridge.js are copied from the current template
when absent, and package.json gains build/start scripts plus the
hyper-zepto/vite dependencies if missing. Files and scripts the project
already defines are never touched, and current-template projects pass
through unchanged. The headless harness publishes a legacy-shaped project
and asserts the payload is deployable.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@twilson63
twilson63 temporarily deployed to fix/publish-legacy-projects - build PR #26 June 12, 2026 18:14 — with Render Destroyed
@twilson63
twilson63 merged commit 493da66 into main Jun 12, 2026
@twilson63
twilson63 deleted the fix/publish-legacy-projects branch June 12, 2026 18:15

@hyperio-mc hyperio-mc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed PR #26 — Fix publish for projects created before the production template. +179/-2 across 4 files. Already merged, but here's the review.

Root cause is clear: projects saved before #24 (or whose package.json the agent rewrote) have a dev-only package.json with no server.js/zepto-bridge.js — but the injected Dockerfile runs npm run build and node server.js. That's a Missing script: "build" crash at deploy time.

Fix is correct and minimal:

  • preparePublishFiles() backfills missing infra client-side before the payload is sent: copies server.js and zepto-bridge.js from the current template when absent, and patches package.json to add build/start scripts + hyper-zepto/vite deps if missing.
  • Everything the project already defines is left untouched — custom scripts, deps, and files are preserved. Current-template projects pass through byte-for-byte unchanged (identity test asserts this).
  • Gracefully handles missing or unparseable package.json — just backfills the infra files, lets the build fail loudly instead of silently corrupting the payload.
  • The preparedFiles() wrapper in publish.mjs uses dynamic import with a try/catch fallback, so if the module isn't available the publish still works with the raw files.

Tests:

  • 5 unit tests covering legacy backfill, missing deps addition, identity (current template unchanged), custom scripts preserved, and broken JSON tolerance
  • Headless harness now publishes a legacy-shaped project and asserts the payload contains server.js, zepto-bridge.js, build script, and start script (9/9 checks green)

Clean fix. Good call doing this client-side where template files are available rather than server-side.

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.

2 participants