Skip to content

Commit b882020

Browse files
os-zhuangclaude
andauthored
fix(cli): reword os init template descriptions to match what srcFiles emits (#9737) (#9774)
`app` and `plugin` claimed views/actions/extensions their srcFiles maps never write (both emit objects only). Reword to match actual emission, per triage's auto-adjudication (option 1); pin the invariant so future templates can't drift the same way undetected. Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3e373fa commit b882020

4 files changed

Lines changed: 54 additions & 3 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
"@objectstack/cli": patch
3+
---
4+
5+
fix(cli): `os init` template descriptions no longer advertise metadata kinds they never emit (#9737)
6+
7+
The `app` and `plugin` templates' `description` strings — shown by `printKV('Template', …)`
8+
right after `os init -t <template>` runs, and mirrored in `content/docs/deployment/cli.mdx` —
9+
claimed views, actions, and extensions that neither template's `srcFiles` map ever writes.
10+
Both templates emit objects only (`src/objects/index.ts` + `src/objects/{namespace}_item.ts`).
11+
12+
- `app`: `'Full application with objects, views, and actions'` → `'Full application with objects'`
13+
- `plugin`: `'Reusable plugin with objects and extensions'` → `'Reusable plugin with objects'`
14+
- `content/docs/deployment/cli.mdx`'s template table drops the same false `views` claim from the
15+
`app` row.
16+
17+
A new pin (`packages/cli/test/init.test.ts`) asserts every template's description only claims a
18+
metadata kind (`objects`/`views`/`actions`/`extensions`) its `srcFiles` map actually has an entry
19+
under, so a future template can't drift the same way.

‎content/docs/deployment/cli.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ os init my-app --no-install # Skip dependency installation
101101

102102
| Template | What it creates |
103103
|----------|-----------------|
104-
| `app` | Full application with objects, views, barrel imports |
104+
| `app` | Full application with objects, barrel imports |
105105
| `plugin` | Reusable plugin package with objects |
106106
| `empty` | Minimal project with just `objectstack.config.ts` |
107107

‎packages/cli/src/commands/init.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const TEMPLATES: Record<string, {
102102
srcFiles: Record<string, (name: string, namespace: string) => string>;
103103
}> = {
104104
app: {
105-
description: 'Full application with objects, views, and actions',
105+
description: 'Full application with objects',
106106
get dependencies() {
107107
const v = pkgVersion();
108108
// No driver is listed on purpose. `@objectstack/runtime` already depends
@@ -195,7 +195,7 @@ export default ${toCamelCase(namespace)}Item;
195195
},
196196

197197
plugin: {
198-
description: 'Reusable plugin with objects and extensions',
198+
description: 'Reusable plugin with objects',
199199
get dependencies() {
200200
return {
201201
'@objectstack/spec': pkgVersion(),

‎packages/cli/test/init.test.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,38 @@ describe('init command — published scaffold', () => {
5252
});
5353
});
5454

55+
describe('template description accuracy — matches what srcFiles emits (#9737)', () => {
56+
// A template's `description` is what `printKV('Template', …)` and
57+
// `content/docs/deployment/cli.mdx` show a user at the moment they pick
58+
// `-t <template>` — so a description claiming a metadata kind the template
59+
// never writes (the `app`/`plugin` "views"/"actions"/"extensions" claims
60+
// this pin exists for) is a load-bearing lie, not cosmetic copy. Each kind
61+
// maps to the `src/` subdirectory its files would live under; a claim with
62+
// no matching `srcFiles` entry, in either direction, is the drift #9737
63+
// found.
64+
const KIND_CLAIMS: Array<{ kind: string; claimPattern: RegExp; dirPrefix: string }> = [
65+
{ kind: 'objects', claimPattern: /\bobjects?\b/i, dirPrefix: 'src/objects/' },
66+
{ kind: 'views', claimPattern: /\bviews?\b/i, dirPrefix: 'src/views/' },
67+
{ kind: 'actions', claimPattern: /\bactions?\b/i, dirPrefix: 'src/actions/' },
68+
{ kind: 'extensions', claimPattern: /\bextensions?\b/i, dirPrefix: 'src/extensions/' },
69+
];
70+
71+
it.each(Object.keys(TEMPLATES))('template "%s" only claims metadata kinds it actually writes', (key) => {
72+
const t = TEMPLATES[key];
73+
const emittedPaths = Object.keys(t.srcFiles);
74+
for (const { kind, claimPattern, dirPrefix } of KIND_CLAIMS) {
75+
const claims = claimPattern.test(t.description);
76+
const emits = emittedPaths.some((p) => p.startsWith(dirPrefix));
77+
if (claims) {
78+
expect(
79+
emits,
80+
`template "${key}" description claims "${kind}" but srcFiles has no ${dirPrefix}* entry (description: "${t.description}")`,
81+
).toBe(true);
82+
}
83+
}
84+
});
85+
});
86+
5587
describe('native build allowlist (pnpm-workspace.yaml)', () => {
5688
// pnpm 10+ blocks dependency build scripts by default. Without an allowlist,
5789
// the scaffold installs but `serve` crashes with "Could not locate the

0 commit comments

Comments
 (0)