Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/38483-scaffold-names-articles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'create-objectstack': patch
'@objectstack/example-starter': patch
---

fix(create-objectstack, example-starter): the scaffold summary and the descriptions name the help articles

Clause-②: no
Metadata-protocol: none

`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 in this package's README, 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.
2 changes: 1 addition & 1 deletion content/docs/getting-started/build-with-claude-code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ The scaffolder does more than copy files. It:
────────────────────────────────────────
Environment: support-desk
Namespace: support_desk
Template: blank — Companies and contacts, with platform tasks and notes in the menu — ready to extend
Template: blank — Companies, contacts and help articles, with tasks and notes from the platform in the menu — ready to extend
…
→ Installing AI skills for your coding agent from @objectstack/skills@<version>...
…
Expand Down
2 changes: 1 addition & 1 deletion content/docs/getting-started/your-first-project.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bundle) with `--skip-skills` if you prefer — `AGENTS.md` is always written.

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

```bash
npm create objectstack@latest my-app -- --template blank
Expand Down
2 changes: 1 addition & 1 deletion examples/app-starter/objectstack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default defineStack({
version: '0.1.0',
type: 'app',
name: 'Starter',
description: 'Companies and contacts, with the platform\'s tasks and notes in the menu.',
description: 'Companies, contacts and help articles, with the platform\'s tasks and notes in the menu.',
// Protocol major this package is authored against (ADR-0087).
engines: { protocol: '^19' },
// A starter is taken over by the organization that installs it: an
Expand Down
2 changes: 1 addition & 1 deletion examples/app-starter/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@objectstack/example-starter",
"version": "0.1.1-next.2",
"description": "Starter app: companies and their contacts, with the platform's tasks and notes in the menu",
"description": "Starter app: companies, contacts and help articles, with the platform's tasks and notes in the menu",
"license": "Apache-2.0",
"private": true,
"main": "./objectstack.config.ts",
Expand Down
6 changes: 3 additions & 3 deletions examples/app-starter/src/translations/starter.translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ export const StarterTranslationBundle = defineTranslationBundle({
apps: {
biz_app: {
label: 'Starter',
description: 'Companies and contacts, with tasks and notes',
description: 'Companies, contacts and help articles, with tasks and notes',
},
},
},

'zh-CN': {
// The package's own name, keyed by its manifest id (objectstack#35513).
packages: {
'com.example.starter': { name: '入门示例', description: '公司与联系人,菜单中附带平台的任务和备注。' },
'com.example.starter': { name: '入门示例', description: '公司、联系人与知识文章,菜单中附带平台的任务和备注。' },
},
objects: {
biz_company: {
Expand Down Expand Up @@ -176,7 +176,7 @@ export const StarterTranslationBundle = defineTranslationBundle({
apps: {
biz_app: {
label: '起步应用',
description: '公司和联系人,以及任务和备忘',
description: '公司、联系人与知识文章,菜单中附带平台的任务和备注。',
},
},
datasets: {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-objectstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ npx create-objectstack my-app --skip-install

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

`blank` is bundled inside the npm package, so scaffolding never needs network
access.
Expand Down
18 changes: 11 additions & 7 deletions packages/create-objectstack/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
*
* The template's own `manifest.description` is DROPPED from both
* objectstack.manifest.json and objectstack.config.ts rather than carried
* over unrewritten (#9263): it describes the bundled template ("Companies
* and contacts, with tasks and notes from the platform in the menu."), not the project
* over unrewritten (#9263): it describes the bundled template ("Companies,
* contacts and help articles, with tasks and notes from the platform in the menu."), not the project
* being scaffolded, and there is nothing but the project name to derive a
* replacement from — which would only restate `name`/`displayName`. `os
* validate` already omits the description line entirely when the field is
Expand Down Expand Up @@ -194,7 +194,7 @@ function rewriteProjectIdentity(
// file refuses each, and publish refuses `category` and `visibility` — the
// list is RETIRED_TEMPLATE_MANIFEST_KEYS in rewrite-identity.ts), and DROP
// .description (#9263). The template ships a generic line describing
// ITSELF ("Companies and contacts, with tasks and notes from the platform in the menu."),
// ITSELF ("Companies, contacts and help articles, with tasks and notes from the platform in the menu."),
// not the project being scaffolded, and there is nothing but the project
// name to derive a replacement from — a name-derived sentence would be a
// bare restatement of `name`/`displayName` (e.g. "Support Desk — an
Expand Down Expand Up @@ -678,12 +678,16 @@ const program = new Command()
console.log('');

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

Expand Down
72 changes: 67 additions & 5 deletions packages/create-objectstack/src/scaffold-description.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,22 @@ const TSX = path.join(REPO_ROOT, 'node_modules', '.bin', 'tsx');
const INDEX_TS = path.join(PKG_ROOT, 'src', 'index.ts');

const TEMPLATE_DESCRIPTION_CONFIG =
'Companies and contacts, with tasks and notes from the platform in the menu.';
'Companies, contacts and help articles, with tasks and notes from the platform in the menu.';
const TEMPLATE_DESCRIPTION_MANIFEST =
'ObjectStack environment that starts with companies and contacts, with tasks and notes from the platform in the menu.';
'ObjectStack environment that starts with companies, contacts and help articles, with tasks and notes from the platform in the menu.';

let tmp: string;
let projectDir: string;
/** What the scaffolder printed, colour codes stripped. */
let printed: string;

beforeEach(() => {
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'create-objectstack-desc-'));
execFileSync(
printed = execFileSync(
TSX,
[INDEX_TS, 'support-desk', '--template', 'blank', '--skip-install', '--skip-skills'],
{ cwd: tmp, stdio: 'pipe' },
);
{ cwd: tmp, stdio: 'pipe', encoding: 'utf8' },
).replace(/\u001b\[[0-9;]*m/g, '');
projectDir = path.join(tmp, 'support-desk');
}, 30_000);

Expand Down Expand Up @@ -120,3 +122,63 @@ describe('scaffolded project description (#9263)', () => {
expect(messages).toEqual([]);
});
});

// The closing "Your project starts with:" block lists what a new project holds
// on day one. Its expected entries are derived from the template, not listed
// here: every object file under the template's `src/objects/` must be named by
// its plural label, and a template that seeds sample data must point at
// `src/data/`. So the next object added to the template fails this until the
// summary in index.ts names it.
describe('the scaffolder\'s closing summary names every object the template ships', () => {
const OBJECTS_DIR = path.join(PKG_ROOT, 'src', 'templates', 'blank', 'src', 'objects');
const DATA_INDEX = path.join(PKG_ROOT, 'src', 'templates', 'blank', 'src', 'data', 'index.ts');

/** The printed block: the lines after the heading, up to the first blank line. */
function summaryBlock(): string {
const lines = printed.split('\n');
const start = lines.findIndex((l) => l.trim() === 'Your project starts with:');
expect(start, 'the scaffolder no longer prints "Your project starts with:"').toBeGreaterThanOrEqual(0);
const end = lines.findIndex((l, i) => i > start && l.trim() === '');
return lines.slice(start + 1, end).join('\n');
}

/** Each template object file's `pluralLabel`, one per file. */
function templateObjectLabels(): string[] {
const files = fs.readdirSync(OBJECTS_DIR).filter((f) => f.endsWith('.object.ts'));
return files.map((f) => {
const label = /\bpluralLabel:\s*'([^']+)'/.exec(fs.readFileSync(path.join(OBJECTS_DIR, f), 'utf8'))?.[1];
expect(label, `${f} declares no pluralLabel, so the summary cannot be checked against it`).toBeTruthy();
return label as string;
});
}

it('names each template object by its plural label', () => {
const block = summaryBlock();
const labels = templateObjectLabels();
// Control: the derivation read real files, so a moved directory cannot pass vacuously.
expect(labels).toEqual(expect.arrayContaining(['Companies', 'Contacts', 'Articles']));
for (const label of labels) {
expect(block, `the summary does not name ${label}, an object the template ships`).toMatch(
new RegExp(`\\b${label}\\b`),
);
}
});

it('names each template object in the printed Template line too', () => {
// The line comes from the template registry's description, printed before
// the files are written; it describes the same tree, so it is held to it.
const line = printed.split('\n').find((l) => l.trim().startsWith('Template: blank'));
expect(line, 'the scaffolder no longer prints "Template: blank — …"').toBeDefined();
for (const label of templateObjectLabels()) {
expect(line, `the Template line does not name ${label}, an object the template ships`).toMatch(
new RegExp(`\\b${label}\\b`, 'i'),
);
}
});

it('points at src/data/ while the template seeds sample data', () => {
const seeds = /^export\s/m.test(fs.readFileSync(DATA_INDEX, 'utf8'));
expect(seeds, 'control: the template seeds sample data').toBe(true);
expect(summaryBlock()).toContain('src/data/');
});
});
2 changes: 1 addition & 1 deletion packages/create-objectstack/src/template-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface TemplateInfo {
*/
export const TEMPLATES: Record<string, TemplateInfo> = {
blank: {
description: 'Companies and contacts, with platform tasks and notes in the menu — ready to extend',
description: 'Companies, contacts and help articles, with tasks and notes from the platform in the menu — ready to extend',
source: { kind: 'bundled', dir: 'blank' },
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default defineStack({
version: '0.1.0',
type: 'app',
name: 'Blank Starter',
description: 'Companies and contacts, with tasks and notes from the platform in the menu.',
description: 'Companies, contacts and help articles, with tasks and notes from the platform in the menu.',
// Protocol compatibility range: the metadata-protocol major this app is
// authored against. The runtime checks it before it loads anything, so a
// runtime outside the range refuses this app at the boundary with the exact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"$schema": "https://schemas.objectstack.dev/template-manifest.json",
"namespace": "blank",
"displayName": "Blank Starter",
"description": "ObjectStack environment that starts with companies and contacts, with tasks and notes from the platform in the menu.",
"description": "ObjectStack environment that starts with companies, contacts and help articles, with tasks and notes from the platform in the menu.",
"readmePath": "README.md"
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
*/

import { readdirSync, statSync } from 'node:fs';
import { join, relative, resolve } from 'node:path';
import { join, relative, resolve, sep } from 'node:path';
import { beforeAll, describe, expect, it } from 'vitest';
import {
MANAGED_API_METHOD_UNAFFORDABLE,
Expand Down Expand Up @@ -137,15 +137,23 @@ const PACKAGES_DIR = join(REPO_ROOT, 'packages');
* be imported here: a template's `@objectstack/spec` import resolves only inside
* the generated project, which has its own install.
*
* Declared as an exact path list, not a `templates/` pattern, and pinned as
* still-existing below. Every OTHER file is imported without a try/catch, so a
* file this sweep cannot load fails the run instead of being silently dropped —
* a silent skip is how a sweep keeps passing over the objects it stopped seeing.
* Declared as the scaffolder's template directory, not a list of its files: an
* object file anywhere under it is payload copied into a new project, so the
* next object a template gains is excluded with no edit here (a path list
* naming company and contact went on sweeping the template's later
* `article.object.ts` as a booted definition). The exclusion is held from both
* sides below: it must match at least one walked file, every match must sit in
* a template's own `src/objects/`, and it must remove nothing outside the
* directory. Every OTHER file is imported without a try/catch, so a file this
* sweep cannot load fails the run instead of being silently dropped — a silent
* skip is how a sweep keeps passing over the objects it stopped seeing.
*/
const SCAFFOLDING_TEMPLATES: readonly string[] = [
'packages/create-objectstack/src/templates/blank/src/objects/company.object.ts',
'packages/create-objectstack/src/templates/blank/src/objects/contact.object.ts',
];
const SCAFFOLDING_TEMPLATES_DIR = 'packages/create-objectstack/src/templates/';

/** Whether a repo-relative path is a scaffolding template's file. */
function isScaffoldingTemplate(repoRelative: string): boolean {
return repoRelative.split(sep).join('/').startsWith(SCAFFOLDING_TEMPLATES_DIR);
}

/** Every `*.object.ts` under `packages/`, skipping build output, deps and tests. */
function walkObjectFiles(dir: string, out: string[] = []): string[] {
Expand Down Expand Up @@ -173,7 +181,7 @@ function walkObjectFiles(dir: string, out: string[] = []): string[] {
/** The files this sweep judges: every walked object file bar the templates. */
function sweptFiles(): string[] {
return walkObjectFiles(PACKAGES_DIR).filter(
(f) => !SCAFFOLDING_TEMPLATES.includes(relative(REPO_ROOT, f)),
(f) => !isScaffoldingTemplate(relative(REPO_ROOT, f)),
);
}

Expand Down Expand Up @@ -311,11 +319,37 @@ describe('#7934 — code-shipped managed objects declare only apiMethods their o
it('skips only scaffolding templates, and those still exist', () => {
// A stale exemption is documentation of nothing; an exemption that quietly
// grew is a hole. Both directions, on the SINGLE_RECORD_WRITE_ONLY pattern.
const walked = walkObjectFiles(PACKAGES_DIR).map((f) => relative(REPO_ROOT, f));
for (const template of SCAFFOLDING_TEMPLATES) {
expect(walked, `${template} is no longer a real object file — drop the exemption`).toContain(template);
const walked = walkObjectFiles(PACKAGES_DIR).map((f) => relative(REPO_ROOT, f).split(sep).join('/'));
const templates = walked.filter(isScaffoldingTemplate);
// Not empty: the directory still holds template object files.
expect(templates.length, `${SCAFFOLDING_TEMPLATES_DIR} holds no object file any more — drop the exemption`)
.toBeGreaterThan(0);
// Not over-wide: each match is an object file in a template's own src/objects/.
for (const template of templates) {
expect(template, `${template} is excluded but is not a template's object file`).toMatch(
/^packages\/create-objectstack\/src\/templates\/[^/]+\/src\/objects\/[^/]+\.object\.ts$/,
);
}
expect(walked.length - sweptFiles().length).toBe(SCAFFOLDING_TEMPLATES.length);
// Exactly the templates' object files, read off each template's src/objects/
// independently of the walk — today's blank template's article.object.ts among them.
const templatesRoot = join(REPO_ROOT, SCAFFOLDING_TEMPLATES_DIR);
const listed = readdirSync(templatesRoot).flatMap((t) => {
const objectsDir = join(templatesRoot, t, 'src', 'objects');
let entries: string[];
try {
entries = readdirSync(objectsDir);
} catch {
return [];
}
return entries
.filter((f) => f.endsWith('.object.ts'))
.map((f) => `${SCAFFOLDING_TEMPLATES_DIR}${t}/src/objects/${f}`);
});
expect([...templates].sort()).toEqual([...listed].sort());
// The template object a path list once missed, named so a regression to one is red here.
expect(templates).toContain('packages/create-objectstack/src/templates/blank/src/objects/article.object.ts');
// And the filter removes nothing outside the directory.
expect(walked.length - sweptFiles().length).toBe(templates.length);
});

// ── the verdict ───────────────────────────────────────────────────────────
Expand Down
Loading
Loading