You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 302a4c3
Browse filesBrowse the repository at this point in the historyBrowse files
fix(scenarios): the gallery export merges the card's seed rows into the blank scaffold's data list (#38672)
Fixes#38647
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:用默认空白模板搭建、保留了模板自带示例文章的应用,现在可以导出到应用画廊,导出包里同时带模板的示例文章和场景卡的示例数据;此前这类导出一律被拒。
- 为什么做:属于“场景应用导出为可试用模板包”这条线,解决评测流水线从默认模板起步的应用进不了画廊的问题。
- 出错会怎样:只影响画廊导出这一内部评测工具,出错时导出被拒并写明原因,不会写出半成品;改动可直接撤回。
- 要你做什么:无。
## What changes
Route: **merge into the existing array.** The `blank` template keeps
declaring `data: [articles]`; the template and the getting-started page
are untouched.
`withSampleData` (`packages/qa/scenarios/src/export/trial-package.ts`)
used to refuse any `defineStack({ … })` literal that declared `data`.
Now, when that `data:` is an array literal, it keeps the list and
spreads the card's rows in after its last item:
- `data: [articles]` becomes `data: [articles, ...gallerySampleData]`
- `data: []` becomes `data: [...gallerySampleData]`
- a multi-line list keeps its layout and trailing comma: `faqs,` becomes
`faqs, ...gallerySampleData,`
The import line is added as before. A literal with no `data:` still gets
`data: gallerySampleData,` as its first property.
The refusal stays for the shapes the exporter cannot read safely, each
with its reason:
- a spread in the literal (existing pin, unchanged)
- a default export that is not `defineStack` with an object literal (two
existing pins, unchanged)
- a binding already named `gallerySampleData` (existing pin, unchanged)
- a `data:` that is not an array literal, such as a shorthand `data` or
a binding. The shorthand pin is kept and its message is now more
precise.
- `data` declared twice (new pin)
What the pins now expect, and why:
- The `data: []` case of the refusal table used to expect a refusal. An
empty list is now a list the exporter can read, so that case moved to
the new merge table, which expects `[...gallerySampleData]`.
- The refusal table's first row is now `data: seeds`, a binding, which
is the non-literal shape the old row stood for.
- The export-level refusal pin now writes `data: seeds` and pins the new
full refusal text.
## Tests
- New merge table (3 cases): empty list, a list of seeds, and a
multi-line list with a trailing comma. Each case is checked byte for
byte against the expected edit.
- New pin on a fresh `blank` scaffold. The test reads
`packages/create-objectstack/src/templates/blank/objectstack.config.ts`
from the tree and runs `trialPackageSource` on it. It checks that the
result has exactly one `data`, equal to `[articles,
...gallerySampleData]`, that the imports gained the sample-data import,
that `installModes` is `['unmanaged']`, and that `src/sample-data.json`
holds the card's rows.
- New export-level pin: the crm run's project gets the template config,
`exportGallery` refuses nothing, and the exported config lists both
sources.
<details><summary>Package test + typecheck at dbd6328</summary>
```
pnpm --filter @objectstack/scenarios build && pnpm --filter @objectstack/scenarios test && pnpm --filter @objectstack/scenarios typecheck
Test Files 45 passed (45)
Tests 1430 passed (1430)
tsc --noEmit (clean)
os-verify-lock: VERDICT command-exit 0
```
</details>
<details><summary>Ablation (scripts/ablation-replace.mjs)</summary>
The mutation changed `if (existing && !list) {` to `if (existing) {`,
which brings back the old refusal of every `data:`.
- Anchor hits: 1 before, 0 after. Blob `2454d1c63a07` became
`9c86f7e97dae`.
- `exporter.test.ts`: 5 failed, 69 passed. The 3 merge cases, the
fresh-scaffold pin and the export-level scaffold pin went red.
- After the restore the blob matched HEAD `2454d1c63a07` and `git diff
HEAD` was empty.
- The suite imports `src/` directly, so no dist leg was needed.
</details>
## Acceptance notes
- **Cross-package read, declared (claim amendment 7266905293, route
A).** The pin reads the `blank` template's config from the tree. That
path is now declared in two lines: one glob on the
`@objectstack/scenarios` entry of
`scripts/cross-package-test-inputs.mjs`, and one `$TURBO_ROOT$` input on
`@objectstack/scenarios#test` in `turbo.json`.
`check:cross-package-test-inputs` exits 0 at 356648c.
- Template mode's gallery run (`templateSampleData`, `orchestrate.ts`)
sends the card's rows **as** the manifest's `data[]`, replacing what the
build declares. The exported package carries both the scaffold's
`articles` and the card's rows. So the template-mode run does not
install the scaffold's rows through the seed copy. The build's own boot
does load them, since each boot inserts `data: [articles]`. They are a
different object (the template's `blank_article`), so the two sources
cannot collide on a row. Noted only, not filed.
- The export README line "Sample data: the card's N seed rows in M
objects" still counts the card's rows only. It is still true; it just
does not mention the scaffold's rows.
## Verification
Files to read first:
1. `packages/qa/scenarios/src/export/trial-package.ts`: the
`withSampleData` hunk (the `list` / `last` insertion point).
2. `packages/qa/scenarios/test/export/exporter.test.ts`: the fresh
`blank` scaffold pin.
Two-minute check: `pnpm --filter @objectstack/scenarios exec vitest run
--maxWorkers=2 test/export/exporter.test.ts` should end with `Tests 74
passed (74)`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmQJUGAAa5rz9Yi2DvW
<!-- signed: repo:objectstack#3 · os-steve ·
session_01ADHkmQJUGAAa5rz9Yi2DvW -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(scenarios): the gallery export no longer refuses a build that kept the `blank` scaffold's `data:` list
6
+
7
+
Clause-②: yes (widening)
8
+
Metadata-protocol: none
9
+
10
+
The `blank` template of `create-objectstack` declares its own sample rows in `objectstack.config.ts` (`data: [articles]`), and the gallery export refused any config that declared `data:`, so every build that kept the scaffold's config could not become a trial package. When the default-exported `defineStack({ … })` literal already declares `data:` as a list written in place, the export now keeps that list and spreads the card's seed rows in after its last item (`data: [articles, ...gallerySampleData]`): the package arrives with the scaffold's rows the build kept and the card's seed rows, and every other byte of the config is as the AI wrote it. A config with no `data:` gains the `data: gallerySampleData` property as before.
11
+
12
+
The export still refuses, with its reason, the shapes it cannot read safely: a spread in the literal, a default export that is not `defineStack` with an object literal, a `data:` that is not an array literal (a shorthand `data`, a binding or a call), a `data:` declared more than once, and a config that already uses the import's name.
if(ts.isSpreadAssignment(p))thrownewTrialPackageRefusal('objectstack.config.ts spreads a value into `defineStack({ … })`, which may declare `data:` already, so the sample data is not added');
195
-
if(propertyName(ts,p)==='data')thrownewTrialPackageRefusal('objectstack.config.ts already declares `data:`, so the card\'s seed rows are not added as the sample data');
206
+
if(propertyName(ts,p)==='data')declared.push(p);
207
+
}
208
+
if(declared.length>1)thrownewTrialPackageRefusal('objectstack.config.ts declares `data:` more than once in `defineStack({ … })`, so the card\'s seed rows are not added as the sample data');
'objectstack.config.ts already declares `data:` as something other than a list written in place (`data: [ … ]`), so its items cannot be read and the card\'s seed rows are not added as the sample data',
['declares `data` as a shorthand property',"import { defineStack } from '@objectstack/spec';\nconst data = [];\nexport default defineStack({ manifest: {}, data });\n",/alreadydeclares`data:`/],
['declares `data:` as a binding, not a list written in place',"import { defineStack } from '@objectstack/spec';\nimport seeds from './seeds';\nexport default defineStack({ manifest: {}, data: seeds });\n",/alreadydeclares`data:`assomethingotherthanalistwritteninplace/],
657
+
['declares `data` as a shorthand property',"import { defineStack } from '@objectstack/spec';\nconst data = [];\nexport default defineStack({ manifest: {}, data });\n",/alreadydeclares`data:`assomethingotherthanalistwritteninplace/],
['spreads a value into the literal',"import { defineStack } from '@objectstack/spec';\nconst base = {};\nexport default defineStack({ ...base, manifest: {} });\n",/spreadsavalue/],
606
660
['default-exports a binding, not the call',"import { defineStack } from '@objectstack/spec';\nconst stack = defineStack({ manifest: {} });\nexport default stack;\n",/doesnotdefault-export`defineStack\(\{…\}\)`/],
607
661
['hands `defineStack` no object literal',"import { defineStack } from '@objectstack/spec';\nimport base from './base';\nexport default defineStack(base);\n",/doesnotdefault-export`defineStack\(\{…\}\)`/],
@@ -623,12 +677,14 @@ describe('exportGallery — the trial package: listing text, facet and sample da
623
677
expect(ok.omitted).toEqual(['account.owner']);
624
678
});
625
679
626
-
it('an export whose config already declares `data:` is refused with the reason, and no app directory is written',async()=>{
680
+
it('an export whose config declares `data:` as a value it cannot read is refused with the reason, and no app directory is written',async()=>{
expect(s.refused).toEqual([{id: CARD_ID,reasons: ["objectstack.config.ts already declares `data:`, so the card's seed rows are not added as the sample data"]}]);
685
+
expect(s.refused).toEqual([
686
+
{id: CARD_ID,reasons: ["objectstack.config.ts already declares `data:` as something other than a list written in place (`data: [ … ]`), so its items cannot be read and the card's seed rows are not added as the sample data"]},
0 commit comments