fix(create-objectstack): 远程模板的对象名改写被静默跳过 —— 5/6 已发布模板对新用户不可用 (#4926) - #4927
Merged
Conversation
…te for every remote template (#4926) `npx create-objectstack@latest my-app -t <template>` produced a project that could not build for 5 of the 6 offered templates. Only the bundled `blank` worked. The nightly registry canary — the workflow whose entire purpose is to be the new-user canary — had been red on all five for at least a week (20/20 scheduled runs since 2026-07-27), unseen because it runs only on `schedule`. `rewriteProjectIdentity` read the template's original namespace from `objectstack.manifest.json` alone, and that filename means two different documents. The bundled template's is app-shaped and carries `namespace`; a remote template's is the template-REGISTRY document (`$schema: .../template-manifest.json`) and carries none — its namespace lives only in `objectstack.config.ts`. So `templateNamespace` came back undefined for every remote template, the `&& templateNamespace` guard fell through, and the object-name rewrite was skipped entirely — while the config's `namespace:` was rewritten unconditionally. That leaves `namespace: 'my_app'` beside `name: 'todo_task'`, which the ${namespace}_${shortName} rule rejects. Measured against the real templates at objectstack-ai/templates@960f24d, the old code resolved `undefined` for all five and rewrote 0 of the 74 object names that needed it: todo 7, compliance 17, content 22, contracts 12, procurement 16. Two changes, in a new module because index.ts calls program.parse() on import and nothing there is testable (the reason pkg-utils.ts already exists): - `objectstack.config.ts` is now the AUTHORITY for the template namespace, with the manifest as fallback. The config holds the very literal the scaffolder overwrites, so the two cannot disagree. - The rewrite VERIFIES ITSELF. A prefix rewrite that quietly does nothing is indistinguishable from one that was not needed, and that ambiguity is what let this ship. Any surviving stale prefix now throws, naming the files and lines, at the scaffold — not in the user's first `objectstack build`. Verified: 10 new unit tests covering both manifest shapes, the fallback, the absent case and an unparseable manifest; all five real templates now resolve their namespace and rewrite every literal with zero stale left; the bundled blank template still scaffolds to `namespace: 'regr_app'` / `name: 'regr_app_note'`; package suite 28/28, tsc --noEmit and eslint clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BbNVKv6KgPzuQ5p76nMgnf
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BbNVKv6KgPzuQ5p76nMgnf
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 8 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
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.
Closes #4926。
npx create-objectstack@latest my-app -t todo(以及 compliance / content / contracts / procurement)产出的工程连objectstack build都过不去。6 个模板里 5 个如此,只有本仓库自带的blank是好的。夜间金丝雀 —— 那个存在意义就是当新用户探针的 workflow —— 连续 20 次定时运行全红(≥2026-07-27),因为它if: github.event_name == 'schedule',PR 永远不跑,夜里没人看。根因:同名文件、两套 schema
rewriteProjectIdentity只从objectstack.manifest.json读模板原始 namespace。而这个文件名对应两种完全不同的文档:blank$schema: …/template-manifest.json(注册表文档)namespaceobjectstack.config.ts于是远程模板一律读到
undefined,&& templateNamespace守卫落空,对象名改写整段跳过;而 config 的namespace:是无条件改写的。结果namespace: 'my_app'与name: 'todo_task'并存,违反${namespace}_${shortName}。代码注释本身留了线索 ——「Used to swap the bundled template's literal
blank_prefix」:这段逻辑从设计起就只考虑自带模板。改动
抽出
src/rewrite-identity.ts(index.ts在 import 时program.parse(),里面的东西测不了 ——pkg-utils.ts当初就是为此而拆):objectstack.config.ts成为 namespace 的权威来源,manifest 降为回退。config 里的namespace:正是脚手架自己要改写的那个字面量,两者不可能不一致。objectstack build。验证
用
objectstack-ai/templates@960f24d的真实模板对新旧逻辑各跑一遍:undefinedtodoundefinedcomplianceundefinedcontentundefinedcontractsundefinedprocurement生产上共 74 处对象名从未被改写。
其余闸门:
namespace: 'regr_app'+name: 'regr_app_note';tsc --noEmit与eslint均为 0 退出码。未在本 PR 处理
金丝雀「只在夜里跑且无人看」这个结构性问题本身没修 —— 本 PR 只让它接下来会变绿。要不要给它加通知/让 PR 也跑,由维护者定。
🤖 Generated with Claude Code
https://claude.ai/code/session_01BbNVKv6KgPzuQ5p76nMgnf
Generated by Claude Code