Skip to content

Commit 75108ea

Browse files
fix(create-objectstack): name the help articles in the scaffold summary and descriptions (#38584)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Jianguo** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbPPu147GzH57yhYgxsQmVGS)_ Fixes #38483 Clause-②: no Metadata-protocol: none Supersedes #38568 (same commits, continued on this branch: seat 5's dev ran out of tokens, and seat 1 took the card over in claim 7255582169 and its amendment 7255673725). #38568 is closed (7256137004). ## 维护者速读 - 用户能看到什么变化:新建项目的人在创建开始时看到的模板说明、创建完成时看到的「项目一开始包含什么」清单都写上了帮助文章;空白模板、入门示例应用、说明文档和入门教程里的简介也同步更新,入门示例的中文简介一并改好;入门教程里校验结果的对象数、字段数和视图数,以及脚手架说明里的目录树,也按带帮助文章的新模板改对了。 - 为什么做:上一轮给新项目和入门示例加入帮助文章(该卡已关闭)时,这些描述没有跟着改,审核要求用一张卡收口。 - 出错会怎样:只涉及提示文字、简介和两个内部检查的范围,出错时用户看到的清单或简介不准,不影响数据和启动,可以直接撤回。 - 要你做什么:无 ## What changes All three places were re-read on `main` at 4a43d6c first; none was already fixed. 1. **Scaffolder summary.** `npm create objectstack` now prints an `Articles` line in "Your project starts with:", between Companies and Contacts and Tasks and Notes, pointing at `src/objects/` and `src/views/` and at the sample help articles in `src/data/` (`packages/create-objectstack/src/index.ts`, the summary block only). 2. **Descriptions.** The blank template's `manifest.description` (in `objectstack.config.ts` and `objectstack.manifest.json`) and the Starter's `manifest.description` now name the help articles in English. The Starter's zh-CN package description now reads 公司、联系人与知识文章,菜单中附带平台的任务和备注。, using the article object's existing zh-CN label. The blank template stays English-only, per the seat's rulings 7249604628 and 7251614638. A scaffolded project still drops the template's description from its own files, so this text reaches only the template's own readers. 3. **platform-objects template sweeps.** `managed-api-method-affordance-sweep.test.ts` and `platform-admin-affordance-standing.test.ts` now exclude the scaffolder's template directory (`packages/create-objectstack/src/templates/`). They no longer use a path list that named only company and contact. The next template object is excluded with no edit. The control in the managed-api sweep is kept and widened. It checks four things: the directory matches at least one walked file; every match is an object file in a template's own `src/objects/`; the matches equal the template object files read off disk without the walk, with `article.object.ts` named; and the filter removes nothing outside the directory. 4. **The Template line and its mirrors** (claim amendment 7254402109). The scaffolder prints the blank template's registry description as `Template: blank — …` on every run. That description now reads `Companies, contacts and help articles, with tasks and notes from the platform in the menu — ready to extend`, the same phrase as the manifest and config (`packages/create-objectstack/src/template-registry.ts`). It is mirrored in the package README's template table and in the two getting-started pages that quote it (`your-first-project.mdx`, `build-with-claude-code.mdx`). Also updated: the Starter's English app description (`Companies, contacts and help articles, with tasks and notes`), the `examples/app-starter/package.json` description, and the two `index.ts` comments that quote the template's own description. 5. **The tutorial's counts and the README tree** (seat L1 REWORK 7255063318, commit 3df792a). `content/docs/getting-started/build-with-claude-code.mdx` said the blank template scaffolded only the companies and contacts, so the validate output read three objects and eighteen fields. The prose now names the help articles (`article.object.ts`, four fields, with its view and sample articles) and reads **four** objects and **twenty-two** fields; the validate block reads `Data: 4 Objects 22 Fields` and `UI: 1 Apps 4 Views 1 Actions`. Those numbers are measured, not summed: a fresh `--template blank` scaffold plus the page's own ticket files, through `os validate` (see Verification). The "What you get" tree in `packages/create-objectstack/README.md` now lists `article.object.ts`, a grid for articles beside the companies' and contacts' grid and board, a `data/` entry for the seed, and articles in the menu. Changeset `.changeset/38483-scaffold-names-articles.md`: patch on `create-objectstack` and `@objectstack/example-starter` (the latter is private and versioned only, the same pair the help-articles changeset used). It now also names the README tree. `@objectstack/platform-objects` gets no changeset: only its test files change. **Read first (by risk):** 1. `packages/platform-objects/src/managed-api-method-affordance-sweep.test.ts`, the `isScaffoldingTemplate` predicate and the "skips only scaffolding templates" control. A predicate that is too wide would silently stop sweeping real objects. 2. `packages/create-objectstack/src/scaffold-description.test.ts`, the new derived summary pin and the Template line pin. 3. `packages/create-objectstack/src/index.ts`, the summary block. ## Tests - New `describe` in `scaffold-description.test.ts` (the file's existing real-CLI harness, now capturing stdout). It derives the expected entries from the template: every `src/objects/*.object.ts` must be named in the printed block by its `pluralLabel`, and the block must point at `src/data/` while the template's `src/data/index.ts` exports a seed. A file with no `pluralLabel` fails loudly. Control: the derived list contains Companies, Contacts and Articles, so a moved directory cannot pass vacuously. - The same `describe` also holds the printed `Template: blank — …` line to the template: each object's plural label must appear in it (case-insensitive). So the registry description cannot drift from the tree either. - The template exclusion control in the managed-api sweep is described above. The standing test uses the same predicate. - Item 5 is prose and a docs code block with no pin; no ablation (no tested behaviour moved). <details><summary>Ablations (prior rounds, at 9f2a6cf and 80f23ea; each restored; restore proved by blob equal to HEAD and an empty git diff HEAD)</summary> - Deleted the `Articles` summary line in `index.ts` (anchor 1 to 0): `scaffold-description.test.ts` went red, 2 failed / 4 passed. Message: "the summary does not name Articles, an object the template ships", and the `src/data/` case failed too. - Added a temporary `invoice.object.ts` with `pluralLabel: 'Invoices'` to the template's `src/objects/` (the "next object" case): red, 1 failed / 5 passed. Message: "the summary does not name Invoices, an object the template ships". File removed, status clean. - Renamed the article's `pluralLabel` to `Invoices`: red on the control (1 failed / 5 passed). - At 80f23ea, reverted the registry description to `Companies and contacts, with …`: red, 1 failed / 6 passed. Message: "the Template line does not name Articles, an object the template ships". - Narrowed `isScaffoldingTemplate` in the managed-api sweep back to company and contact only: "skips only scaffolding templates, and those still exist" went red, expected 2 entries to equal 3. </details> <details><summary>Suites (re-run at head 3df792a, after merging origin/main 3014176 in 08bb2af)</summary> - After a turbo build of the `@objectstack/cli`, `create-objectstack`, `@objectstack/example-starter` and `@objectstack/platform-objects` closures (71 tasks successful), under `os-verify-lock`: - `create-objectstack` test: Test Files 26 passed (26), Tests 411 passed (411); typecheck exit 0. - `@objectstack/example-starter` test (the boot test): Test Files 2 passed (2), Tests 14 passed (14); typecheck exit 0. - `@objectstack/platform-objects` test: Test Files 130 passed (130), Tests 2218 passed (2218); typecheck exit 0. - The merge of origin/main touched none of this PR's files; the delta against main is the same 14 files. </details> ## Acceptance notes - The claim was widened (amendment 7254402109) to fold in the Template line and its mirrors. That remainder was first reported here as same-family and is now item 4 above. - The Starter's zh-CN **app** description in `starter.translation.ts` now reads `公司、联系人与知识文章,菜单中附带平台的任务和备注。`, the same wording as its zh-CN package description (second claim amendment). - With the path list gone, the cross-package input gate needs a quoted path to keep the platform-objects `packages/**/*.object.ts` glob held. The old two-path list was that witness. The control's named `article.object.ts` literal now holds it, and `check:cross-package-test-inputs` is green. - `overlap-check` names the bot-generated Version Packages PR #38192, which bumps `examples/app-starter/package.json`'s version on the line next to its description. That PR is regenerated from `main`, so the text conflict resolves on its next refresh. It also names #38568, which this PR supersedes; both merge cleanly with main. - Item 5 touches `build-with-claude-code.mdx` beyond the lines that quote the template description, as seat L1 7255063318 asked. Measuring it showed two things on that page this PR does not change: the page's own `src/apps/support.app.ts` beside the template's `main.app.ts` fails `os validate` ("An 'app' package must define at most one app", ADR-0019 D3), and the validate block's `Runtime: 3 plugins` line reads `0 plugins` in an uninstalled scaffold. The counts above were taken with the template's single app. Both are older than the help articles and are left to the seat. - Not changed, per the seat's L1 nit: the Starter's English app description has no full stop while its zh-CN twin has one. ## Verification Two-minute check: `pnpm --filter create-objectstack exec vitest run --maxWorkers=2 src/scaffold-description.test.ts` should show 7 passed, including "names each template object by its plural label" and "names each template object in the printed Template line too". <details><summary>How the tutorial's counts were measured (item 5)</summary> At 08bb2af (built): `node packages/create-objectstack/dist/index.js support-desk --template blank --skip-install --skip-skills` in a scratch directory whose `node_modules/@objectstack/spec` links to this tree's `packages/spec`, then `node packages/cli/bin/run.js validate` there. - Fresh scaffold: `✓ Validation passed`, `Data: 3 Objects 18 Fields`, `UI: 1 Apps 3 Views` (company 7 + contact 7 + article 4 fields). - Plus the page's four `title=` code blocks written verbatim (ticket object, Resolve action, ticket view, support app) and one export line each in the barrels, minus the support app's export (see the acceptance notes): `✓ Validation passed`, `Data: 4 Objects 22 Fields`, `UI: 1 Apps 4 Views 1 Actions`. </details> <details><summary>Gates</summary> - At 3df792a, `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 117 commands (the docs families included). All 117 were run, each exit captured before any pipe; `--ran` reconciliation reads "117 derived famil(ies) accounted for — 117 run, 0 NOT-MEASURED (a DERIVED zero — all 117 recorded an exit code and none of them is 3)". - 113 exited 0 on the first pass. Four exited 3 with PREREQUISITE NOT MET in the fresh worktree, and each exits 0 once its prerequisite is met: `check-plugin-teardown-shape --self-test` after fetching its pinned fixture commit ("48 cases pass"); `check:skill-examples`, `check:dual-build-cjs-loads` and `check:i18n-coverage` after a full turbo build ("352 prose examples type-check"; "126 published require entry point(s) across 74 package(s) load"; "OK (15 config(s), 577 baselined untranslated string(s), none new)"). - `overlap-check --branch=HEAD` before the push of 3df792a: "origin/main: merges cleanly"; #38568 merges cleanly; #38192 (Version Packages) conflicts on `examples/app-starter/package.json`, see the acceptance notes. - CI-run families are read from this PR's check-runs, not re-run locally. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QsR2jSh8tZmU5uBqzpvg3o <!-- signed: repo:objectstack#1 · zhuangjianguo · session_01QsR2jSh8tZmU5uBqzpvg3o --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent bcb7e7f commit 75108ea

14 files changed

Lines changed: 178 additions & 56 deletions
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'create-objectstack': patch
3+
'@objectstack/example-starter': patch
4+
---
5+
6+
fix(create-objectstack, example-starter): the scaffold summary and the descriptions name the help articles
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
`npm create objectstack` now lists the help articles in the "Your project starts with:" block it prints after creating a project: an Articles line beside Companies and Contacts, pointing at `src/objects/` and `src/views/` and at the sample articles in `src/data/`. The `Template: blank — …` line it prints first, the template table and the "What you get" tree in this package's README (the tree now lists `article.object.ts` and the `src/data/` seed), the blank template's description in `objectstack.config.ts` and in `objectstack.manifest.json`, and the Starter's package description (in English and in Simplified Chinese), its app description (in English and in Simplified Chinese) and its `package.json` description now read companies, contacts and help articles, with tasks and notes from the platform in the menu. A scaffolded project still drops the template's description from its own files.

‎content/docs/getting-started/build-with-claude-code.mdx‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ The scaffolder does more than copy files. It:
7979
────────────────────────────────────────
8080
Environment: support-desk
8181
Namespace: support_desk
82-
Template: blank — Companies and contacts, with platform tasks and notes in the menu — ready to extend
82+
Template: blank — Companies, contacts and help articles, with tasks and notes from the platform in the menu — ready to extend
8383
…
8484
→ Installing AI skills for your coding agent from @objectstack/skills@<version>...
8585
…
@@ -282,10 +282,12 @@ thing to check.
282282

283283
What it does **not** touch is what the `blank` template scaffolded in step 1:
284284
the companies and contacts (`src/objects/company.object.ts` and
285-
`contact.object.ts`, seven fields each). Nothing asked for them to go, so they
286-
stay in the project — which is why the counts below read **three** objects and
287-
**eighteen** fields, not one and four. Delete them once the ticket object has
288-
replaced them and the same run reports `1 Objects 4 Fields`.
285+
`contact.object.ts`, seven fields each) and the help articles
286+
(`article.object.ts`, four fields, with its view and sample articles). Nothing
287+
asked for them to go, so they stay in the project — which is why the counts
288+
below read **four** objects and **twenty-two** fields, not one and four. Delete
289+
them once the ticket object has replaced them and the same run reports
290+
`1 Objects 4 Fields`.
289291

290292
This is the same metadata that powers the REST API, the Console UI, **and the MCP
291293
tools exposed to AI** — define it once, and ObjectStack derives the rest.
@@ -347,8 +349,8 @@ Once it's clean:
347349
348350
Support Desk v0.1.0
349351
350-
Data: 3 Objects 18 Fields
351-
UI: 1 Apps 3 Views 1 Actions
352+
Data: 4 Objects 22 Fields
353+
UI: 1 Apps 4 Views 1 Actions
352354
Logic: 0 Flows
353355
Security: 0 Positions 0 Permissions
354356
Runtime: 3 plugins

‎content/docs/getting-started/your-first-project.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ bundle) with `--skip-skills` if you prefer — `AGENTS.md` is always written.
8383

8484
| Template | Source | Description |
8585
|:---|:---|:---|
86-
| `blank` *(default)* | bundled, works offline | Companies and contacts, with platform tasks and notes in the menu — ready to extend |
86+
| `blank` *(default)* | bundled, works offline | Companies, contacts and help articles, with tasks and notes from the platform in the menu — ready to extend |
8787

8888
```bash
8989
npm create objectstack@latest my-app -- --template blank

‎examples/app-starter/objectstack.config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default defineStack({
2828
version: '0.1.0',
2929
type: 'app',
3030
name: 'Starter',
31-
description: 'Companies and contacts, with the platform\'s tasks and notes in the menu.',
31+
description: 'Companies, contacts and help articles, with the platform\'s tasks and notes in the menu.',
3232
// Protocol major this package is authored against (ADR-0087).
3333
engines: { protocol: '^19' },
3434
// A starter is taken over by the organization that installs it: an

‎examples/app-starter/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@objectstack/example-starter",
33
"version": "0.1.1-next.2",
4-
"description": "Starter app: companies and their contacts, with the platform's tasks and notes in the menu",
4+
"description": "Starter app: companies, contacts and help articles, with the platform's tasks and notes in the menu",
55
"license": "Apache-2.0",
66
"private": true,
77
"main": "./objectstack.config.ts",

‎examples/app-starter/src/translations/starter.translation.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ export const StarterTranslationBundle = defineTranslationBundle({
5454
apps: {
5555
biz_app: {
5656
label: 'Starter',
57-
description: 'Companies and contacts, with tasks and notes',
57+
description: 'Companies, contacts and help articles, with tasks and notes',
5858
},
5959
},
6060
},
6161

6262
'zh-CN': {
6363
// The package's own name, keyed by its manifest id (objectstack#35513).
6464
packages: {
65-
'com.example.starter': { name: '入门示例', description: '公司与联系人,菜单中附带平台的任务和备注。' },
65+
'com.example.starter': { name: '入门示例', description: '公司、联系人与知识文章,菜单中附带平台的任务和备注。' },
6666
},
6767
objects: {
6868
biz_company: {
@@ -176,7 +176,7 @@ export const StarterTranslationBundle = defineTranslationBundle({
176176
apps: {
177177
biz_app: {
178178
label: '起步应用',
179-
description: '公司和联系人,以及任务和备忘',
179+
description: '公司、联系人与知识文章,菜单中附带平台的任务和备注。',
180180
},
181181
},
182182
datasets: {

‎packages/create-objectstack/README.md‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ npx create-objectstack my-app --skip-install
2828

2929
| Template | Source | Description |
3030
| --- | --- | --- |
31-
| `blank` *(default)* | bundled (offline) | Companies and contacts, with platform tasks and notes in the menu — ready to extend |
31+
| `blank` *(default)* | bundled (offline) | Companies, contacts and help articles, with tasks and notes from the platform in the menu — ready to extend |
3232

3333
`blank` is bundled inside the npm package, so scaffolding never needs network
3434
access.
@@ -85,13 +85,16 @@ my-app/
8585
├── README.md
8686
├── AGENTS.md # conventions for coding agents
8787
└── src/
88-
├── objects/ # companies and contacts: the platform's
89-
│ ├── index.ts # Starter app, as source
88+
├── objects/ # companies, contacts and help articles:
89+
│ ├── index.ts # the platform's Starter app, as source
9090
│ ├── company.object.ts
91-
│ └── contact.object.ts
92-
├── views/ # a grid and a board for each
93-
├── apps/main.app.ts # the menu: companies, contacts, and the
94-
│ # platform's tasks and notes
91+
│ ├── contact.object.ts
92+
│ └── article.object.ts
93+
├── views/ # a grid and a board for companies and
94+
│ # contacts, a grid for articles
95+
├── data/ # the seed: sample help articles
96+
├── apps/main.app.ts # the menu: companies, contacts, articles,
97+
│ # and the platform's tasks and notes
9598
├── actions/index.ts # an empty barrel for each directory
9699
├── flows/index.ts # `objectstack generate` writes into,
97100
├── dashboards/index.ts # already wired into objectstack.config.ts

‎packages/create-objectstack/src/index.ts‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
*
3232
* The template's own `manifest.description` is DROPPED from both
3333
* objectstack.manifest.json and objectstack.config.ts rather than carried
34-
* over unrewritten (#9263): it describes the bundled template ("Companies
35-
* and contacts, with tasks and notes from the platform in the menu."), not the project
34+
* over unrewritten (#9263): it describes the bundled template ("Companies,
35+
* contacts and help articles, with tasks and notes from the platform in the menu."), not the project
3636
* being scaffolded, and there is nothing but the project name to derive a
3737
* replacement from — which would only restate `name`/`displayName`. `os
3838
* validate` already omits the description line entirely when the field is
@@ -194,7 +194,7 @@ function rewriteProjectIdentity(
194194
// file refuses each, and publish refuses `category` and `visibility` — the
195195
// list is RETIRED_TEMPLATE_MANIFEST_KEYS in rewrite-identity.ts), and DROP
196196
// .description (#9263). The template ships a generic line describing
197-
// ITSELF ("Companies and contacts, with tasks and notes from the platform in the menu."),
197+
// ITSELF ("Companies, contacts and help articles, with tasks and notes from the platform in the menu."),
198198
// not the project being scaffolded, and there is nothing but the project
199199
// name to derive a replacement from — a name-derived sentence would be a
200200
// bare restatement of `name`/`displayName` (e.g. "Support Desk — an
@@ -678,12 +678,16 @@ const program = new Command()
678678
console.log('');
679679

680680
// What the project holds on day one, so the first `dev` run is not a
681-
// surprise: the bundled template's companies and contacts (the
682-
// platform's Starter app, as source), and the platform's tasks and notes
683-
// in its menu. `blank-template-starter-parity.test.ts` holds these lines
684-
// to the template's tree.
681+
// surprise: the bundled template's companies, contacts and help articles
682+
// (the platform's Starter app, as source) with the sample articles it
683+
// seeds, and the platform's tasks and notes in its menu.
684+
// `blank-template-starter-parity.test.ts` holds these lines to the
685+
// template's tree, and `scaffold-description.test.ts` holds the printed
686+
// block to the template's object files: an object added there fails it
687+
// until a line here names it.
685688
console.log(chalk.bold(' Your project starts with:'));
686689
console.log(chalk.dim(' Companies and Contacts src/objects/, with their lists in src/views/'));
690+
console.log(chalk.dim(' Articles src/objects/ and src/views/, with sample help articles in src/data/'));
687691
console.log(chalk.dim(" Tasks and Notes the platform's own, in the menu of src/apps/main.app.ts"));
688692
console.log('');
689693

‎packages/create-objectstack/src/scaffold-description.test.ts‎

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,22 @@ const TSX = path.join(REPO_ROOT, 'node_modules', '.bin', 'tsx');
3030
const INDEX_TS = path.join(PKG_ROOT, 'src', 'index.ts');
3131

3232
const TEMPLATE_DESCRIPTION_CONFIG =
33-
'Companies and contacts, with tasks and notes from the platform in the menu.';
33+
'Companies, contacts and help articles, with tasks and notes from the platform in the menu.';
3434
const TEMPLATE_DESCRIPTION_MANIFEST =
35-
'ObjectStack environment that starts with companies and contacts, with tasks and notes from the platform in the menu.';
35+
'ObjectStack environment that starts with companies, contacts and help articles, with tasks and notes from the platform in the menu.';
3636

3737
let tmp: string;
3838
let projectDir: string;
39+
/** What the scaffolder printed, colour codes stripped. */
40+
let printed: string;
3941

4042
beforeEach(() => {
4143
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'create-objectstack-desc-'));
42-
execFileSync(
44+
printed = execFileSync(
4345
TSX,
4446
[INDEX_TS, 'support-desk', '--template', 'blank', '--skip-install', '--skip-skills'],
45-
{ cwd: tmp, stdio: 'pipe' },
46-
);
47+
{ cwd: tmp, stdio: 'pipe', encoding: 'utf8' },
48+
).replace(/\u001b\[[0-9;]*m/g, '');
4749
projectDir = path.join(tmp, 'support-desk');
4850
}, 30_000);
4951

@@ -120,3 +122,63 @@ describe('scaffolded project description (#9263)', () => {
120122
expect(messages).toEqual([]);
121123
});
122124
});
125+
126+
// The closing "Your project starts with:" block lists what a new project holds
127+
// on day one. Its expected entries are derived from the template, not listed
128+
// here: every object file under the template's `src/objects/` must be named by
129+
// its plural label, and a template that seeds sample data must point at
130+
// `src/data/`. So the next object added to the template fails this until the
131+
// summary in index.ts names it.
132+
describe('the scaffolder\'s closing summary names every object the template ships', () => {
133+
const OBJECTS_DIR = path.join(PKG_ROOT, 'src', 'templates', 'blank', 'src', 'objects');
134+
const DATA_INDEX = path.join(PKG_ROOT, 'src', 'templates', 'blank', 'src', 'data', 'index.ts');
135+
136+
/** The printed block: the lines after the heading, up to the first blank line. */
137+
function summaryBlock(): string {
138+
const lines = printed.split('\n');
139+
const start = lines.findIndex((l) => l.trim() === 'Your project starts with:');
140+
expect(start, 'the scaffolder no longer prints "Your project starts with:"').toBeGreaterThanOrEqual(0);
141+
const end = lines.findIndex((l, i) => i > start && l.trim() === '');
142+
return lines.slice(start + 1, end).join('\n');
143+
}
144+
145+
/** Each template object file's `pluralLabel`, one per file. */
146+
function templateObjectLabels(): string[] {
147+
const files = fs.readdirSync(OBJECTS_DIR).filter((f) => f.endsWith('.object.ts'));
148+
return files.map((f) => {
149+
const label = /\bpluralLabel:\s*'([^']+)'/.exec(fs.readFileSync(path.join(OBJECTS_DIR, f), 'utf8'))?.[1];
150+
expect(label, `${f} declares no pluralLabel, so the summary cannot be checked against it`).toBeTruthy();
151+
return label as string;
152+
});
153+
}
154+
155+
it('names each template object by its plural label', () => {
156+
const block = summaryBlock();
157+
const labels = templateObjectLabels();
158+
// Control: the derivation read real files, so a moved directory cannot pass vacuously.
159+
expect(labels).toEqual(expect.arrayContaining(['Companies', 'Contacts', 'Articles']));
160+
for (const label of labels) {
161+
expect(block, `the summary does not name ${label}, an object the template ships`).toMatch(
162+
new RegExp(`\\b${label}\\b`),
163+
);
164+
}
165+
});
166+
167+
it('names each template object in the printed Template line too', () => {
168+
// The line comes from the template registry's description, printed before
169+
// the files are written; it describes the same tree, so it is held to it.
170+
const line = printed.split('\n').find((l) => l.trim().startsWith('Template: blank'));
171+
expect(line, 'the scaffolder no longer prints "Template: blank — …"').toBeDefined();
172+
for (const label of templateObjectLabels()) {
173+
expect(line, `the Template line does not name ${label}, an object the template ships`).toMatch(
174+
new RegExp(`\\b${label}\\b`, 'i'),
175+
);
176+
}
177+
});
178+
179+
it('points at src/data/ while the template seeds sample data', () => {
180+
const seeds = /^export\s/m.test(fs.readFileSync(DATA_INDEX, 'utf8'));
181+
expect(seeds, 'control: the template seeds sample data').toBe(true);
182+
expect(summaryBlock()).toContain('src/data/');
183+
});
184+
});

‎packages/create-objectstack/src/template-registry.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface TemplateInfo {
2424
*/
2525
export const TEMPLATES: Record<string, TemplateInfo> = {
2626
blank: {
27-
description: 'Companies and contacts, with platform tasks and notes in the menu — ready to extend',
27+
description: 'Companies, contacts and help articles, with tasks and notes from the platform in the menu — ready to extend',
2828
source: { kind: 'bundled', dir: 'blank' },
2929
},
3030
};

0 commit comments

Comments
 (0)