Fix publish for projects created before the production template#26
Merged
Conversation
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
temporarily deployed
to
fix/publish-legacy-projects - build PR #26
June 12, 2026 18:14 — with
Render
Destroyed
hyperio-mc
approved these changes
Jun 12, 2026
hyperio-mc
left a comment
Collaborator
There was a problem hiding this comment.
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: copiesserver.jsandzepto-bridge.jsfrom the current template when absent, and patchespackage.jsonto addbuild/startscripts +hyper-zepto/vitedeps 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 inpublish.mjsuses 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,buildscript, andstartscript (9/9 checks green)
Clean fix. Good call doing this client-side where template files are available rather than server-side.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jsonand noserver.js/zepto-bridge.js— but the injected Dockerfile runsnpm run buildandnode server.js.Fix:
preparePublishFiles()backfills the missing infrastructure into the publish payload client-side (where the template files are available): copiesserver.js/zepto-bridge.jsfrom the current template when absent, and addsbuild/startscripts plushyper-zepto/vitedeps to package.json if missing. Anything the project already defines is left untouched; current-template projects pass through unchanged (identity, asserted byte-for-byte).🤖 Generated with Claude Code