Skip to content

Commit c9e0d77

Browse files
feat(cli): os init scaffolds a starter app and list view, so a new project opens in the Console with its own object (#32291)
Fixes #32212 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:`os init` 默认的 `app` 模板现在多写一个入门应用 `src/apps/main.app.ts`(导航里只有一项,打开模板自带的对象)和该对象的列表视图 `src/views/NAMESPACE_item.view.ts`;`plugin` 模板只多写列表视图,不带应用;`empty` 模板不变。 - 为什么改:以前 `os init` 出来的项目启动后,对象能通过 REST/MCP 访问,但没有任何应用列出它,新用户按启动横幅打开 Console 只看到平台自带的应用,看不到自己的项目。这与 #32209 对 `npm create objectstack` 的修复是同一个问题的另一个脚手架。 - 风险与回滚:只影响新生成的项目,已有项目不受影响。一个可见后果:`app` 类型的包最多只能有一个应用(ADR-0019 D3),所以新项目里再跑 `os g app` 会被拒绝,作者应往入门应用里加导航项(与 #32209 的 blank 模板相同);目录里已有 `src/apps/index.ts` 或 `src/views/index.ts` 时保留原文件、只追加一行导出,不覆盖。回滚即还原 `packages/cli/src/commands/init.ts`。 - 先看:`packages/cli/src/commands/init.ts`(`wiredBarrelExporting` 与 `writeTemplateSrcFiles` 里新增的追加分支,最有风险的一段);`packages/cli/test/generate-scaffold-wiring.test.ts` 第 5 节(新的行为钉子);`packages/cli/test/init-template-comments-self-contained.test.ts`(`../` 规则改为按深度判断)。 - 两分钟验证:在任意空目录运行 `objectstack init demo --no-install && cd demo && objectstack validate`,预期输出 `UI: 1 Apps 1 Views` 且校验通过、无警告。 - 需要你做的:无,席位落地。 ## What changes `os init` scaffolds its objects and, until now, no app, so a project booted with its object served over REST and MCP and nothing of its own in the Console, which lists an object only where an app's navigation names it. - **`app` template** (the default): writes `src/apps/main.app.ts`, an app named `NAMESPACE_main_app` labelled with the project's title, whose one navigation entry opens the starter object, and `src/views/NAMESPACE_item.view.ts`, that object's list view (a grid of every field it declares, sorted by its title field). Each is exported from its directory's `index.ts`, which the config already wires. The files are what `os g app main --object NAMESPACE_item` and `os g view NAMESPACE_item` write, and the barrels are the empty barrel plus the line those generators append: the apps barrel is byte-identical to the one `create-objectstack`'s blank starter ships since #32209. - **`plugin` template**: writes the list view and **no app**. Judgment, with the reason: a view travels with its object, so a host that names the object in its own navigation opens this list; navigation is the host's to compose, and an app shipped in a metadata package would land in the app switcher of every stack that loads it. The template also has no `dev` or `start` script, so there is no Console of its own for an app to fill. - **`empty` template**: unchanged. It declares no object, so there is nothing for an app entry or a view to name (`os g app` itself refuses without an object). - **The route the card asked to be named**: the object is referenced through an import of its module (`ITEM.name`), never as a typed-out name, as #32209 does with `Note.name`. Renaming the object in its own file moves the app entry and the view with it. The other route, teaching `create-objectstack`'s rename to move `objectName`/`object` literals, lives outside this card's surface and is not needed for `os init`, which renders the names per project. - **One consequence, stated rather than hidden**: a package whose manifest type is `app` holds at most one app (ADR-0019 D3, enforced by `defineStack`). With the starter app in place, `os g app NAME --object OBJECT` in a fresh `os init` project is refused (exit 1, "must define at most one app … Fold them into one app with multiple tabs", and the command takes its write back out). Before this change the first `os g app` succeeded. The starter app's own comment therefore tells the author to add a navigation entry to it (a `group` entry nests them) rather than a second app, and the nightly reach e2e now pins that refusal before it removes the starter app and runs every generator as before. This is the same shape #32209 shipped for the blank starter. - **Scaffolding into a non-empty directory** (`os init` with no name): an existing `src/apps/index.ts` or `src/views/index.ts` is kept, and the template's export line is appended once if the file lacks it, the way `os generate` appends to a barrel it finds. Empty barrels keep the existing rule (never written over an existing file). The producer is `packages/cli/src/commands/init.ts`, as the card named. `generate.ts` and `packages/create-objectstack/**` are untouched. ## Tests - `packages/cli/test/generate-scaffold-wiring.test.ts`, new top-level describe `[#32212] a scaffolded project lists its objects in an app, each with a list view`: scaffolds each template through the real emitter and loads its config the way `os validate` does; asserts every object has exactly one list view binding it with the object's own fields as columns, the `app` template's app navigates to every scaffolded object, the `plugin` template ships no app, `empty` ships nothing, and renaming the object's `name:` in its own file moves the app entry and the view with it (with no `'NAMESPACE_item'` literal in any app or view file). - Same file: the empty-barrel probes moved from the views barrel (now non-empty) to the flows barrel; a new case pins the append-once behaviour on an existing views barrel, including a file with no trailing newline and a second run that writes nothing. - `packages/cli/test/create-objectstack-wiring-parity.test.ts`: the compared `os init` barrel is the rendered barrel minus the generator export lines, i.e. the empty barrel. One export-line pattern serves both this and the #32209 assertions. - `packages/cli/test/init-template-comments-self-contained.test.ts`: the `../` entry now judges depth, as its own comment prescribed for this exact condition and as `create-objectstack`'s copy does since #32209. `../objects/NAMESPACE_item.object` from `src/apps/` stays inside the project; a climb above the project root still reddens. - `packages/cli/test/generate-scaffolds-reach-stack.e2e.test.ts` (nightly): first `os g app` beside the starter app must be refused by the one-app rule with nothing written; then the starter app is removed (file and barrel line) and every generator runs as before. `os validate` counts 1 App and 2 Views (the starter's list view plus the generated one). - `packages/cli/test/starter-field-consumers.e2e.test.ts` needs no change: since #32209 its control unwires any view a starter ships, which now includes this one. ## Acceptance notes - `os validate` on a `-t plugin` scaffold prints the advisory "No apps or plugins defined — this stack may not do much". It printed the same before this change (the plugin template never had an app), and it follows from the plugin judgment above; noted, not changed. - The starter list view's label is `All NAMESPACE_TITLE Items` and the app entry's `NAMESPACE_TITLE Items`, where `os g view` would print the object's singular label (`All My App Item`): the object declares no plural label, so the scaffold spells the plural itself. - Found beside this card, reported to the seat for filing (not fixed here, outside the surface): the blank starter's `src/apps/main.app.ts` comment, its README and `content/docs/getting-started/your-first-project.mdx` tell the author to "generate an app of its own" with `objectstack generate app NAME --object OBJECT`; in that project the command is refused by the same one-app rule (measured on a copy of the template at this head: exit 1, "An 'app' package must define at most one app, but found 2"). - The docs page `content/docs/deployment/cli.mdx` describes `-t plugin` as writing "`objectstack.config.ts` … plus `src/objects/*.object.ts`"; it does not list views. Still true as far as it goes; not edited here (outside this card's surface). ## Verification All readings below are on this branch at `fe206cab5` unless a line names another head (each named head differs from `fe206cab5` only by the starter app's comment text and the changeset). <details><summary>Targeted tests at fe206ca: 13 files, 264 tests, green</summary> - `pnpm --filter @objectstack/cli exec vitest run --project unit --maxWorkers=2` over the 12 unit-tier files that pin `os init` (init, init-scaffold-authoring-rules, init-template-comments-self-contained, init-scaffold-file-name-registry-parity, create-objectstack-wiring-parity, generate-scaffold-wiring, scaffold-emission-typechecks, scaffold-test-script-passes, scaffold-object-declaration-shape, scaffold-manifest-schema, starter-field-consumers, init-manifest-id): `Test Files 12 passed (12)`, `Tests 256 passed (256)`. - `--project integration test/generate-stack-reach.test.ts test/scaffold-test-script-passes.test.ts`: `Test Files 1 passed (1)`, `Tests 8 passed (8)`. - Nightly, `OS_TEST_TIERS=nightly … test/generate-scaffolds-reach-stack.e2e.test.ts`: `Test Files 1 passed (1)`, `Tests 14 passed (14)`, including the new one-app refusal case. </details> <details><summary>Package suite and typecheck</summary> - `pnpm --filter @objectstack/cli typecheck` (tsc plus `check:test-typecheck`) at `fe206cab5`: exit 0, "test layer compiles … 3 file(s) / 28 error(s) / 6 pinned signature(s) held". - `pnpm --filter @objectstack/cli exec vitest run --project unit --maxWorkers=2` at `7122465ff`: `Test Files 2 failed | 410 passed (412)`, `Tests 5857 passed | 29 skipped`. The two files (`published-subpath-console.pin`, `published-subpath-hook-body.pin`) refused before running because `packages/cli` itself was not built ("packages/cli is not built … Run: pnpm --filter @objectstack/cli build"); after that build both ran: `Test Files 2 passed (2)`, `Tests 29 passed (29)`. The `integration` layer is declared to CI apart from the files named above. - Nightly `starter-field-consumers.e2e` and `init-created-files-summary.e2e` at `7122465ff`: both passed (2 of the 3 files in that run; the third, the reach e2e, was then adapted to the one-app rule and is green above). </details> <details><summary>Ablation (one-shot, not kept)</summary> With the app entry's `objectName: ITEM.name` replaced by a typed-out `'NAMESPACE_item'` (via `scripts/ablation-replace.mjs`, anchor 1 to 0, blob `d3dd3002` to `23d6bffd`), `generate-scaffold-wiring.test.ts` went red on exactly one test: "`app`: renaming the object in its own file moves the app entry and the view with it" (`Tests 1 failed | 46 passed`). Restored: `git hash-object` equals the HEAD blob `d3dd3002`, `git diff HEAD` empty. </details> <details><summary>Boot: a real os init project in the Console's API</summary> `os init demo --no-install` then `os validate`: "Validation passed", `UI: 1 Apps 1 Views`, no warnings; `os lint`: "All checks passed". `os compile` then `os serve --dev` on a random port, signed in as the dev admin: - `GET /api/v1/meta/app` answered 200 with `demo_main_app` (navigation: `demo_item`) beside `setup` and `account`. - `GET /api/v1/meta/view` answered 200 with `demo_item.default`, `object: demo_item`, label "All Demo Items", columns name/description/status, `_diagnostics.valid: true`. - `GET /api/v1/data/demo_item` answered 200, `total: 0`. The server was stopped by its recorded pid and the port was free afterwards. `os init pkg -t plugin`: `os validate` passed with `UI: 1 Views`. </details> <details><summary>Local gates</summary> `node scripts/pm/dispatch-gates.mjs --commands` (derived at `a5af54126`, same 68 families re-derived at the final diff): 63 exit 0; 5 NOT MEASURED, each exit 3 PREREQUISITE NOT MET because they read the build of packages outside the CLI's closure (`check:dual-build-cjs-loads`, `check:i18n`, `check:i18n-coverage`, `check:i18n-walk-parity`, `check:type-check-debt`); CI runs them. `dispatch-gates --ran`: "68 derived famil(ies) accounted for — 63 run, 5 NOT-MEASURED". Re-run at `fe206cab5` after the last changeset edit: `check-adr-0087-registration`, `check-changeset-no-major`, `check-empty-changeset`, `check:issue-citations`, `check:doc-authoring`, `check:nul-bytes`, `check:scaffold-emission-policy`, `check-closing-keyword-parity`, all exit 0. `eslint --no-inline-config` over the changed source and test files: exit 0, no findings. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01QSeKYm8sWjp2Pk76warN7w)_ --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 49bc3be commit c9e0d77

6 files changed

Lines changed: 428 additions & 23 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/cli': patch
3+
---
4+
5+
feat(cli): `os init` scaffolds a starter app and list view, so a new project opens in the Console with its own object
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`os init` (the default `app` template) now writes `src/apps/main.app.ts`, an app whose one navigation entry opens the starter object, and `src/views/NAMESPACE_item.view.ts`, that object's list view, each wired through its directory's `index.ts`. Before, the project booted with its object served over REST and MCP and nothing of its own in the Console, which lists an object only where an app names it. The files are what `os generate app main --object NAMESPACE_item` and `os generate view NAMESPACE_item` write, except that both reference the object through an import of its module (`.name`) instead of typing its name out, so renaming the object moves them with it.
11+
12+
A package whose manifest type is `app` holds at most one app, so in a project scaffolded this way `os generate app` is refused while the starter app is there: add a navigation entry for each new object to `src/apps/main.app.ts` instead (its comment says so), or replace the starter app with your own.
13+
14+
`os init -t plugin` writes the list view and no app: navigation belongs to the stack that loads the package, and the template has no `dev` script with a Console of its own. `os init -t empty` declares no object and writes neither.
15+
16+
Scaffolding into a directory that already holds `src/apps/index.ts` or `src/views/index.ts` keeps that file and appends the template's export line to it, as `os generate` does.

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

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,102 @@ export {};
790790
*/
791791
const EMPTY_WIRED_BARRELS = new WeakSet<(name: string, namespace: string) => string>();
792792

793+
/**
794+
* The export lines a wired barrel carries after its empty header, keyed by the
795+
* barrel's renderer. {@link writeTemplateSrcFiles} APPENDS these, one per line
796+
* the file lacks, to a barrel that already exists instead of overwriting it —
797+
* what `objectstack generate` does to a barrel it finds — so an author's own
798+
* `src/views/index.ts` keeps every export it had and still wires the
799+
* template's view.
800+
*/
801+
const WIRED_BARREL_EXPORTS = new WeakMap<
802+
(name: string, namespace: string) => string,
803+
(name: string, namespace: string) => string[]
804+
>();
805+
806+
/**
807+
* The barrel of the wired directory for `type`, written as the empty one
808+
* {@link renderEmptyWiredBarrel} renders followed by `exports` — the bytes
809+
* `os init` would write and then `os g <type>` would append to, so a template
810+
* that ships a scaffold of its own wires it exactly the way the generator
811+
* would have.
812+
*/
813+
function wiredBarrelExporting(
814+
type: string,
815+
exports: (name: string, namespace: string) => string[],
816+
): (name: string, namespace: string) => string {
817+
const barrel = SCAFFOLD_WIRED_BARRELS.find((b) => b.type === type);
818+
if (!barrel) throw new Error(`os init: no generator writes '${type}', so there is no barrel to wire it in`);
819+
const render = (name: string, namespace: string) =>
820+
renderEmptyWiredBarrel(barrel.stackKey, barrel.type)
821+
+ exports(name, namespace).map((line) => `${line}\n`).join('');
822+
WIRED_BARREL_EXPORTS.set(render, exports);
823+
return render;
824+
}
825+
826+
// ─── The starter app and list view (#32212) ──────────────────────────
827+
//
828+
// A project with objects and no app boots with its objects served over REST
829+
// and MCP and nothing of its own in the Console, which lists an object only
830+
// where an app's navigation names it — so the dev banner's Console link opened
831+
// on the platform's apps alone. The `app` template therefore ships what
832+
// `os g app main --object <its object>` and `os g view <its object>` write,
833+
// and the `plugin` template the list view alone (see its entry for why).
834+
//
835+
// Both reference the object through an import of its own module (`.name`),
836+
// never as a typed-out string: a rename of the object moves the references
837+
// with it. That is the shape `create-objectstack`'s blank starter uses for the
838+
// same files, so the two scaffolders do not teach two ways to bind an object.
839+
840+
/** The object a template's starter files bind: its module and binding name. */
841+
function starterObjectImport(namespace: string): string {
842+
return `import ${toCamelCase(namespace)}Item from '../objects/${namespace}_item.object';`;
843+
}
844+
845+
/** The plural label the starter app and list view show the starter object under. */
846+
function starterObjectPlural(namespace: string): string {
847+
return `${toTitleCase(namespace)} Items`;
848+
}
849+
850+
/**
851+
* The list view `os g view <namespace>_item` writes for the starter object,
852+
* with `fields` as its columns (every field the object declares, as the
853+
* generator lists them) and `note` as the comment saying where it is opened.
854+
*/
855+
function renderStarterListView(namespace: string, fields: readonly string[], note: readonly string[]): string {
856+
const binding = `${toCamelCase(namespace)}Item`;
857+
return `import * as UI from '@objectstack/spec/ui';
858+
${starterObjectImport(namespace)}
859+
860+
/**
861+
* ${toTitleCase(`${namespace}_item`)} Views
862+
*/
863+
${note.map((line) => `// ${line}`.trimEnd()).join('\n')}
864+
const ${binding}Views: UI.View = {
865+
// A views container is registered under the object it binds to: \`object\`
866+
// is its identity, so it declares no \`name\` or \`label\` of its own. The
867+
// label people see is the list view's, below.
868+
object: ${binding}.name,
869+
list: {
870+
label: 'All ${starterObjectPlural(namespace)}',
871+
type: 'grid',
872+
columns: [
873+
${fields.map((field) => ` { field: '${field}' },`).join('\n')}
874+
],
875+
sort: [{ field: '${fields[0]}', order: 'asc' }],
876+
pagination: { pageSize: 25 },
877+
},
878+
};
879+
880+
export default ${binding}Views;
881+
`;
882+
}
883+
884+
/** The views barrel line `os g view <namespace>_item` appends. */
885+
function starterViewExport(namespace: string): string {
886+
return `export { default as ${toCamelCase(namespace)}Item } from './${namespace}_item.view';`;
887+
}
888+
793889
/**
794890
* `srcFiles` plus an empty barrel for every wired directory the template does
795891
* not already write an `index.ts` into.
@@ -937,6 +1033,59 @@ const ${toCamelCase(namespace)}Item = ObjectSchema.create({
9371033
9381034
export default ${toCamelCase(namespace)}Item;
9391035
`,
1036+
// The starter app: what the Console lists beside the platform's own
1037+
// apps, with the starter object as its one navigation entry. The bytes
1038+
// `os g app main --object <namespace>_item` writes, the object bound by
1039+
// import instead of by its typed-out name.
1040+
'src/apps/index.ts': wiredBarrelExporting('app', () => [
1041+
"export { default as main } from './main.app';",
1042+
]),
1043+
'src/apps/main.app.ts': (name, namespace) => `import * as UI from '@objectstack/spec/ui';
1044+
${starterObjectImport(namespace)}
1045+
1046+
/**
1047+
* Main App
1048+
*/
1049+
// This project's app: what the Console lists beside the platform's own apps,
1050+
// and what puts an object in the Console's navigation. An object no app lists
1051+
// is still served over REST and MCP, but the Console has no route to it. A
1052+
// package whose manifest type is 'app' holds at most one app, so this is the
1053+
// one: to put another object in the Console, add a navigation entry for it
1054+
// below (a 'group' entry with children nests them) rather than a second app,
1055+
// and give it a list view — \`objectstack generate view OBJECT\` writes one.
1056+
//
1057+
// The object is referenced through its import, never as a typed-out name, so
1058+
// renaming it moves this entry with it. When you delete the starter object,
1059+
// delete its entry below too.
1060+
const mainApp: UI.App = {
1061+
name: '${namespace}_main_app',
1062+
label: '${toTitleCase(name)}',
1063+
navigation: [
1064+
{
1065+
id: \`\${${toCamelCase(namespace)}Item.name}_nav\`,
1066+
type: 'object',
1067+
label: '${starterObjectPlural(namespace)}',
1068+
objectName: ${toCamelCase(namespace)}Item.name,
1069+
},
1070+
],
1071+
};
1072+
1073+
export default mainApp;
1074+
`,
1075+
// The starter object's list view: what the app's entry above opens.
1076+
'src/views/index.ts': wiredBarrelExporting('view', (_name, namespace) => [starterViewExport(namespace)]),
1077+
'src/views/__name___item.view.ts': (_name, namespace) => renderStarterListView(
1078+
namespace,
1079+
['name', 'description', 'status'],
1080+
[
1081+
`The list the Console opens from the \`${starterObjectPlural(namespace)}\` entry of`,
1082+
'src/apps/main.app.ts. Every column names a field the object declares: a',
1083+
'column naming a field it lacks renders blank. The object is referenced',
1084+
'through its import, so renaming it moves this view with it. When you',
1085+
'delete the starter object, delete this file and its export line in',
1086+
'src/views/index.ts too.',
1087+
],
1088+
),
9401089
}),
9411090
},
9421091

@@ -1018,6 +1167,24 @@ const ${toCamelCase(namespace)}Item = ObjectSchema.create({
10181167
10191168
export default ${toCamelCase(namespace)}Item;
10201169
`,
1170+
// The starter object's list view, and no app (#32212). A view travels
1171+
// with its object: a host that lists the object in its own navigation
1172+
// opens this list. Navigation is the host's to compose — an app shipped
1173+
// here would land in the app switcher of every stack that loads the
1174+
// package — and this template has no `dev` or `start` script, so there
1175+
// is no Console of its own for an app to fill.
1176+
'src/views/index.ts': wiredBarrelExporting('view', (_name, namespace) => [starterViewExport(namespace)]),
1177+
'src/views/__name___item.view.ts': (_name, namespace) => renderStarterListView(
1178+
namespace,
1179+
['name'],
1180+
[
1181+
'The list a host opens for this object: a stack that loads this package',
1182+
'and names the object in its app navigation shows these columns. Every',
1183+
'column names a field the object declares: a column naming a field it',
1184+
'lacks renders blank. The object is referenced through its import, so',
1185+
'renaming it moves this view with it.',
1186+
],
1187+
),
10211188
// The starter test the `test` script above runs (#25175). Without a test
10221189
// file, `vitest run` exits 1 with "No test files found", so a fresh
10231190
// project failed its own `npm test`. It loads the package's stack —
@@ -1188,6 +1355,23 @@ export function writeTemplateSrcFiles(
11881355
// EMPTY_WIRED_BARRELS for the author's file this would overwrite.
11891356
if (EMPTY_WIRED_BARRELS.has(contentFn) && fs.existsSync(fullPath)) continue;
11901357

1358+
// A wired barrel that carries the template's own export lines is, where a
1359+
// barrel already exists, APPENDED to rather than overwritten: the author's
1360+
// exports stay, and each line of the template's the file lacks is added,
1361+
// so the template's scaffold is still wired (see WIRED_BARREL_EXPORTS).
1362+
const exportLines = WIRED_BARREL_EXPORTS.get(contentFn);
1363+
if (exportLines && fs.existsSync(fullPath)) {
1364+
const before = fs.readFileSync(fullPath, 'utf8');
1365+
const present = new Set(before.split(/\r?\n/));
1366+
const missing = exportLines(projectName, namespace).filter((line) => !present.has(line));
1367+
if (missing.length > 0) {
1368+
const separator = before === '' || before.endsWith('\n') ? '' : '\n';
1369+
fs.writeFileSync(fullPath, `${before}${separator}${missing.map((line) => `${line}\n`).join('')}`);
1370+
written.push(resolvedPath);
1371+
}
1372+
continue;
1373+
}
1374+
11911375
if (!fs.existsSync(dir)) {
11921376
fs.mkdirSync(dir, { recursive: true });
11931377
}

‎packages/cli/test/create-objectstack-wiring-parity.test.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,18 @@ describe('[#20333] the blank config wires what `os init` wires, in its lines', (
117117
});
118118

119119
describe('[#20333] the blank template ships every wired barrel', () => {
120+
// [#32212] `os init -t app` ships a starter app and list view, so its apps
121+
// and views barrels carry the export lines `os g app` / `os g view` append
122+
// after the empty barrel. The barrel compared is what `os init` writes
123+
// before those lines: the empty barrel itself, byte for byte.
124+
// One `export { default as … } from './…';` line, as `os generate` appends it.
125+
const GENERATED_EXPORT = /^export \{ default as \w+ \} from '\.\/[\w.-]+';$/;
126+
const withoutGeneratedExports = (source: string): string =>
127+
source.split('\n').filter((line) => !GENERATED_EXPORT.test(line)).join('\n');
120128
const barrels = SCAFFOLD_WIRED_BARRELS.map((b) => {
121129
const file = `${b.dir}/index.ts`;
122130
const render = TEMPLATES.app.srcFiles[file];
123-
return { ...b, file, init: render ? render('my-app', 'my_app') : undefined };
131+
return { ...b, file, init: render ? withoutGeneratedExports(render('my-app', 'my_app')) : undefined };
124132
});
125133

126134
it.each(barrels.map((b) => [b.file, b] as const))('%s exists', (_file, b) => {
@@ -141,8 +149,8 @@ describe('[#20333] the blank template ships every wired barrel', () => {
141149
// verbatim, then one `export { default as … } from './…';` line per
142150
// scaffold. Every other wired barrel stays byte-identical. So the binding
143151
// holds either way: the barrel `os init` writes is the template's prefix,
144-
// and nothing but generator export lines follows it.
145-
const GENERATED_EXPORT = /^export \{ default as \w+ \} from '\.\/[\w.-]+';$/;
152+
// and nothing but generator export lines follows it (`GENERATED_EXPORT`,
153+
// above).
146154

147155
it.each(empty.map((b) => [b.file, b] as const))(
148156
'%s is the one `os init` writes, plus only the export lines `os generate` appends',

0 commit comments

Comments
 (0)