Skip to content

fix(scaffold): repair new-demo registry insertion (anchor drift, CRLF, missing updatedAt) - #69

Open
linqi88 wants to merge 1 commit into
img2threejs:mainfrom
linqi88:fix/new-demo-registry-anchor
Open

linqi88 wants to merge 1 commit into
img2threejs:mainfrom
linqi88:fix/new-demo-registry-anchor

Conversation

@linqi88

@linqi88 linqi88 commented Sep 7, 2026

Copy link
Copy Markdown

Problem

npm run new-demo — step 1 of the documented "Add your own showcase" flow — fails on current main (verified at 0d75d2b):

  1. The entry-insertion anchor looks for export const demos: DemoEntry[] = [ + newline, but the registry now declares const authored: DemoEntry[] = [ (the exported const is [...authored], whose line never ends with an open bracket). The anchor can never match → "insert the entry manually".
  2. Both insertion anchors are \n-exact, so on CRLF working trees (Windows default) even the import insertion silently fails — producing a registry that references an unimported factory and fails tsc.
  3. A failed run leaves src/demos/<id>/ behind, so the retry hits "already exists — pick a different id".
  4. The scaffolded entry is missing the required updatedAt field, so npm run build fails even after the anchors are fixed.

Fix

  • Accept either const authored / export const demos as the entry anchor; tolerate \r?\n in both anchors.
  • Fail loudly when the import anchor doesn't match instead of writing a broken registry.
  • Stamp updatedAt on the scaffolded entry.

Verification

  • npm run new-demo -- pr-scaffold-check "Scaffold Check" object completes and inserts the entry into const authored; npx tsc --noEmit is clean; probe artifacts removed afterwards.
  • Repeated with a CRLF-converted registry.ts to confirm the tolerance.

…t and CRLF checkouts

- accept both `const authored` and `export const demos` array declarations as the
  entry-insertion anchor (the exported const is a spread result and never matches)
- tolerate CRLF working trees in both insertion anchors (import + entry)
- fail loudly when the import anchor does not match instead of writing a registry
  that references an unimported factory
- add the required `updatedAt` field to the scaffolded entry so `npm run build`
  passes before any manual edit, as the README promises
@linqi88
linqi88 requested a review from hoainho as a code owner September 7, 2026 02:13
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