Repository navigation
Stop 'spacetime init' copying a broken generate script into TypeScript projects - #6709
Open
krisajenkins wants to merge 1 commit into
Open
krisajenkins wants to merge 1 commit into
krisajenkins wants to merge 1 commit into
Conversation
krisajenkins
force-pushed
the
kris/init-drop-gen-bindings-script
branch
from
November 25, 2026 15:59
c8fbe1d to
9723c25
Compare
This was referenced Nov 25, 2026
clockwork-tien
approved these changes
Nov 26, 2026
…t projects.
Say you scaffold a project with 'spacetime init --template react-ts' (or
any of the twelve TypeScript client templates), change your module, and
want fresh bindings. package.json has an obvious-looking 'generate'
script, so you run 'npm run generate'. It fails:
"generate": "pnpm --dir spacetimedb install && cargo run -p gen-bindings -- --out-dir src/module_bindings --module-path spacetimedb && prettier --write src/module_bindings"
gen-bindings is a tool in the SpacetimeDB repository's Cargo workspace.
The templates use it to regenerate their checked-in bindings, and the
repo's own CI calls it through this script ('pnpm generate' in
chat-react-ts, and in react-ts via bindings-typescript). Outside the repo
there is no such crate, and usually no Cargo at all. The script that
actually works for users, 'spacetime:generate', sits a line below it, but
the broken one has the name people reach for.
Nobody caught it because it works for everyone who maintains the
templates: inside the monorepo the script runs fine. 'spacetime init'
copies each template's package.json unchanged apart from the name and the
spacetimedb version, and the template smoketests only install and publish.
Renaming the script in every template would mean changing the repo's CI
and SDK scripts that call it. Instead, update_package_json, which already
rewrites each template's package.json during init, now drops any script
that invokes gen-bindings. The monorepo keeps its workflow, and scaffolded
projects get only scripts that can run.
A new test runs update_package_json over every embedded template's
package.json. It checks that each gen-bindings script is removed and
every other script is kept unchanged. It also fails if no template uses
gen-bindings any more, so the marker can't go stale silently. Removing the
call makes it fail, naming money-exchange-react-ts. Scaffolding svelte-ts
with the rebuilt CLI produces a package.json without 'generate' and with
its other scripts intact.
krisajenkins
force-pushed
the
kris/init-drop-gen-bindings-script
branch
from
November 26, 2026 16:08
9723c25 to
30d0f13
Compare
This branch has not been deployed
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.
Description of Changes
Projects scaffolded with
spacetime initfrom any of the twelve TypeScript client templates no longer get ageneratescript that cannot run.Each template's
package.jsonhas ageneratescript that callscargo run -p gen-bindings:gen-bindingsis a crate in this repo's Cargo workspace, which the templates use to regenerate their checked-in bindings (and which CI calls through this script). Outside the monorepo there is no such crate, and usually no Cargo at all, so a user who runsnpm run generateafter changing their module gets a failure. The script that works for them,spacetime:generate, sits a line below it, but the broken one has the name people reach for.It went unnoticed because it works for everyone who maintains the templates.
spacetime initcopies eachpackage.jsonunchanged apart from the name and thespacetimedbversion, and the template smoketests only install and publish.Renaming the script in every template would mean changing the repo's CI and SDK scripts that call it. Instead,
update_package_json, which already rewrites each template'spackage.jsonduring init, now drops any script that invokesgen-bindings. The monorepo keeps its workflow, and scaffolded projects get only scripts that can run.API and ABI breaking changes
None.
Rollback safety impact
n/a
Expected complexity level and risk
1
Testing
Added one test covering the following behaviors:
update_package_jsonremovesgen-bindingsscripts from every embedded template. Removing the new filter made the test fail, namingmoney-exchange-react-ts. The same test covers:gen-bindings, so the check can't go stale silently.Scaffolding
svelte-tswith the rebuilt CLI produced apackage.jsonwithoutgenerateand with its other scripts intact.