@metaobjectsdev/cli 0.24.0 → 0.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/commands/docs.d.ts.map +1 -1
- package/dist/src/commands/docs.js +13 -13
- package/dist/src/commands/docs.js.map +1 -1
- package/dist/src/commands/gen.d.ts.map +1 -1
- package/dist/src/commands/gen.js +9 -4
- package/dist/src/commands/gen.js.map +1 -1
- package/dist/src/commands/upgrade.d.ts.map +1 -1
- package/dist/src/commands/upgrade.js +48 -24
- package/dist/src/commands/upgrade.js.map +1 -1
- package/dist/src/commands/verify.d.ts.map +1 -1
- package/dist/src/commands/verify.js +26 -2
- package/dist/src/commands/verify.js.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +13 -8
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/load-metaobjects-config.d.ts +31 -0
- package/dist/src/lib/load-metaobjects-config.d.ts.map +1 -1
- package/dist/src/lib/load-metaobjects-config.js +43 -0
- package/dist/src/lib/load-metaobjects-config.js.map +1 -1
- package/package.json +10 -10
- package/src/commands/docs.ts +22 -18
- package/src/commands/gen.ts +10 -4
- package/src/commands/upgrade.ts +50 -27
- package/src/commands/verify.ts +26 -2
- package/src/index.ts +13 -8
- package/src/lib/load-metaobjects-config.ts +45 -0
package/dist/src/index.js
CHANGED
|
@@ -18,7 +18,7 @@ COMMANDS:
|
|
|
18
18
|
gen [<entity>...] Codegen TS targets from your declared metadata
|
|
19
19
|
types [query] Search the metadata vocabulary (types, subtypes, @attrs) by name or description
|
|
20
20
|
export Flatten loaded metadata to one canonical JSON artifact
|
|
21
|
-
docs <
|
|
21
|
+
docs [<project-root>] --out <dir> Generate neutral metadata documentation (entity + template pages; --site for HTML site)
|
|
22
22
|
verify Drift gate — subverbs: --templates / --db / --codegen (bare = --templates)
|
|
23
23
|
upgrade Rewrite retired metadata vocabulary (previews; --apply writes)
|
|
24
24
|
prompt-snapshot Snapshot rendered template.* output; --check gates drift
|
|
@@ -39,9 +39,11 @@ EXPORT FLAGS:
|
|
|
39
39
|
--out <file> Write output to a file (default: stdout)
|
|
40
40
|
|
|
41
41
|
DOCS FLAGS:
|
|
42
|
-
<
|
|
42
|
+
[<project-root>] PROJECT ROOT to resolve metadata from — the directory that CONTAINS
|
|
43
|
+
your metadata, NOT the metadata directory. Passing it SCOPES the run
|
|
44
|
+
(default: cwd)
|
|
43
45
|
--out <dir>, -o Output directory for the pages (default: ./docs)
|
|
44
|
-
--templates <dir> Project root to resolve adopter templates/ overrides (default: <
|
|
46
|
+
--templates <dir> Project root to resolve adopter templates/ overrides (default: <project-root>)
|
|
45
47
|
--prompts <dir> Extra dir holding prompt .mustache sources for --site (e.g. data/templates/)
|
|
46
48
|
|
|
47
49
|
VERIFY FLAGS (ADR-0021 D2 — explicit subverbs; combine any; exit 1 on ANY drift):
|
|
@@ -159,12 +161,15 @@ FLAGS:
|
|
|
159
161
|
docs: `meta docs — generate neutral metadata documentation (entity + template pages)
|
|
160
162
|
|
|
161
163
|
USAGE:
|
|
162
|
-
meta docs [<
|
|
164
|
+
meta docs [<project-root>] [flags]
|
|
163
165
|
|
|
164
166
|
FLAGS:
|
|
165
|
-
<
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
[<project-root>] PROJECT ROOT to resolve metadata from — the directory that CONTAINS
|
|
168
|
+
your metadata, NOT the metadata directory itself. (The Python and C#
|
|
169
|
+
'docs' positionals mean the metadata dir; this one does not.) Passing
|
|
170
|
+
it SCOPES the run to that directory's own sources; no ancestor
|
|
171
|
+
.metaobjects/config.json is consulted. Omitted (default), the project
|
|
172
|
+
is discovered by walking up.
|
|
168
173
|
--out <dir>, -o Output directory for the pages (default: ./docs)
|
|
169
174
|
--model Emit the markdown model surface (entity + template pages)
|
|
170
175
|
--api Emit the markdown api surface (generated SDK reference)
|
|
@@ -173,7 +178,7 @@ FLAGS:
|
|
|
173
178
|
--metamodel Document the built-in metamodel vocabulary (no metadata needed)
|
|
174
179
|
--site Generate the browsable HTML documentation site (<out>/site/)
|
|
175
180
|
--scaffold-site Copy the site's templates + assets into codegen/docs-site/ to own (theme) them
|
|
176
|
-
--templates <dir> Project root to resolve adopter templates/ overrides (default: <
|
|
181
|
+
--templates <dir> Project root to resolve adopter templates/ overrides (default: <project-root>)
|
|
177
182
|
--prompts <dir> Extra dir holding prompt .mustache sources (for --site) when they
|
|
178
183
|
live outside the metadata sources or templates/ (e.g. data/templates/)
|
|
179
184
|
--help, -h Print this help
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1D,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAE7B,MAAM,SAAS,GAAG,4BAA4B,OAAO
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,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AE,GAAG,CAAC,CAAC;QAChC,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;YAC/D,OAAO,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC;QACD,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;YACjE,OAAO,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACnC,CAAC;QACD,KAAK,iBAAiB,CAAC,CAAC,CAAC;YACvB,MAAM,EAAE,qBAAqB,EAAE,GAAG,MAAM,MAAM,CAAC,+BAA+B,CAAC,CAAC;YAChF,OAAO,qBAAqB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC1C,CAAC;QACD,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;YACjE,OAAO,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;QACnD,CAAC;QACD;YACE,GAAG,CAAC,KAAK,CAAC,oBAAoB,GAAG,+CAA+C,CAAC,CAAC;YAClF,OAAO,CAAC,CAAC;IACb,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MetaDataTypeProvider, MetaobjectsGenConfig } from "@metaobjectsdev/codegen-ts";
|
|
2
|
+
import { type Collection } from "@metaobjectsdev/sdk";
|
|
2
3
|
/**
|
|
3
4
|
* The `loadMemory` options a project's gen config contributes.
|
|
4
5
|
*
|
|
@@ -46,5 +47,35 @@ export declare function loadMemoryOptionsFrom(cfg: Pick<MetaobjectsGenConfig, "p
|
|
|
46
47
|
* never adopt a parent checkout's codegen config.
|
|
47
48
|
*/
|
|
48
49
|
export declare function resolveGenConfigDir(startDir: string, fallback: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* The collection a TypeScript package GENERATES FROM (#340).
|
|
52
|
+
*
|
|
53
|
+
* #326/#327 established that the two config files answer different questions, and gave
|
|
54
|
+
* `metaobjects.config.ts` its own walk. This is the remaining half of the same split:
|
|
55
|
+
* a sub-project whose TS config sits below the collection root was still LOADING the
|
|
56
|
+
* ancestor's whole source set, so its `src/generated` absorbed metadata belonging to
|
|
57
|
+
* unrelated parts of the repository — one adopter's web app went from 376 files to 831,
|
|
58
|
+
* the surplus being another module's server-side prompt payload DTOs. It fails OPEN
|
|
59
|
+
* (`tsc` passes, tests pass), so the only symptom is a directory that quietly doubled.
|
|
60
|
+
*
|
|
61
|
+
* The rule: an ancestor `.metaobjects/config.json` is the DEFAULT for a package that
|
|
62
|
+
* declares no sources of its own, never an ADDITION to one that does. So when the TS
|
|
63
|
+
* config sits somewhere the collection did not, that directory is re-resolved as a
|
|
64
|
+
* collection in its own right, and it wins if it actually resolves any metadata.
|
|
65
|
+
*
|
|
66
|
+
* It can only ever NARROW, and only in a shape that could not have worked before:
|
|
67
|
+
* - the two directories coincide (every `meta init` project, and every run from a
|
|
68
|
+
* project root) — returns the original, untouched, without a second resolve;
|
|
69
|
+
* - the sub-project declares no sources — the pinned resolve throws
|
|
70
|
+
* `ERR_SOURCE_UNRESOLVED` or comes back empty, and the ancestor stands, so a
|
|
71
|
+
* package that genuinely lives off an ancestor tree keeps working;
|
|
72
|
+
* - the sub-project has its own metadata — it generates from exactly that, which is
|
|
73
|
+
* what it did before source resolution learned to walk upward.
|
|
74
|
+
*
|
|
75
|
+
* Deliberately NOT applied to `.metaobjects/` STATE. Migrations, snapshots and the
|
|
76
|
+
* operational block stay keyed on the discovered collection's directory (#326 settled
|
|
77
|
+
* that); this narrows what is LOADED, and nothing about where state lives.
|
|
78
|
+
*/
|
|
79
|
+
export declare function resolveGenCollection(collection: Collection, genConfigDir: string): Promise<Collection>;
|
|
49
80
|
export declare function loadMetaobjectsConfig(projectRoot: string): Promise<MetaobjectsGenConfig>;
|
|
50
81
|
//# sourceMappingURL=load-metaobjects-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-metaobjects-config.d.ts","sourceRoot":"","sources":["../../../src/lib/load-metaobjects-config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"load-metaobjects-config.d.ts","sourceRoot":"","sources":["../../../src/lib/load-metaobjects-config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAgJzE;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,IAAI,CAAC,oBAAoB,EAAE,WAAW,GAAG,WAAW,CAAC,GAAG,SAAS,GACrE;IAAE,SAAS,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAKhF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAU9E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,UAAU,CAAC,CAUrB;AAED,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA0I9F"}
|
|
@@ -5,6 +5,7 @@ import { dirname, join, resolve } from "node:path";
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { randomBytes } from "node:crypto";
|
|
7
7
|
import { createJiti } from "jiti";
|
|
8
|
+
import { resolveCollection } from "@metaobjectsdev/sdk";
|
|
8
9
|
const CONFIG_FILE = "metaobjects.config.ts";
|
|
9
10
|
// Prefix for the transient, pre-processed config the loader writes next to the
|
|
10
11
|
// user's config (see the rewrite step below). Normally deleted in a finally
|
|
@@ -199,6 +200,48 @@ export function resolveGenConfigDir(startDir, fallback) {
|
|
|
199
200
|
}
|
|
200
201
|
return fallback;
|
|
201
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* The collection a TypeScript package GENERATES FROM (#340).
|
|
205
|
+
*
|
|
206
|
+
* #326/#327 established that the two config files answer different questions, and gave
|
|
207
|
+
* `metaobjects.config.ts` its own walk. This is the remaining half of the same split:
|
|
208
|
+
* a sub-project whose TS config sits below the collection root was still LOADING the
|
|
209
|
+
* ancestor's whole source set, so its `src/generated` absorbed metadata belonging to
|
|
210
|
+
* unrelated parts of the repository — one adopter's web app went from 376 files to 831,
|
|
211
|
+
* the surplus being another module's server-side prompt payload DTOs. It fails OPEN
|
|
212
|
+
* (`tsc` passes, tests pass), so the only symptom is a directory that quietly doubled.
|
|
213
|
+
*
|
|
214
|
+
* The rule: an ancestor `.metaobjects/config.json` is the DEFAULT for a package that
|
|
215
|
+
* declares no sources of its own, never an ADDITION to one that does. So when the TS
|
|
216
|
+
* config sits somewhere the collection did not, that directory is re-resolved as a
|
|
217
|
+
* collection in its own right, and it wins if it actually resolves any metadata.
|
|
218
|
+
*
|
|
219
|
+
* It can only ever NARROW, and only in a shape that could not have worked before:
|
|
220
|
+
* - the two directories coincide (every `meta init` project, and every run from a
|
|
221
|
+
* project root) — returns the original, untouched, without a second resolve;
|
|
222
|
+
* - the sub-project declares no sources — the pinned resolve throws
|
|
223
|
+
* `ERR_SOURCE_UNRESOLVED` or comes back empty, and the ancestor stands, so a
|
|
224
|
+
* package that genuinely lives off an ancestor tree keeps working;
|
|
225
|
+
* - the sub-project has its own metadata — it generates from exactly that, which is
|
|
226
|
+
* what it did before source resolution learned to walk upward.
|
|
227
|
+
*
|
|
228
|
+
* Deliberately NOT applied to `.metaobjects/` STATE. Migrations, snapshots and the
|
|
229
|
+
* operational block stay keyed on the discovered collection's directory (#326 settled
|
|
230
|
+
* that); this narrows what is LOADED, and nothing about where state lives.
|
|
231
|
+
*/
|
|
232
|
+
export async function resolveGenCollection(collection, genConfigDir) {
|
|
233
|
+
if (resolve(genConfigDir) === resolve(collection.configDir))
|
|
234
|
+
return collection;
|
|
235
|
+
try {
|
|
236
|
+
const pinned = await resolveCollection(genConfigDir, { explicitDir: genConfigDir });
|
|
237
|
+
return pinned.files.length > 0 ? pinned : collection;
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
// The sub-project declares nothing resolvable of its own — inherit, exactly as a
|
|
241
|
+
// package with no config always has.
|
|
242
|
+
return collection;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
202
245
|
export async function loadMetaobjectsConfig(projectRoot) {
|
|
203
246
|
const fullPath = resolve(projectRoot, CONFIG_FILE);
|
|
204
247
|
if (!existsSync(fullPath)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-metaobjects-config.js","sourceRoot":"","sources":["../../../src/lib/load-metaobjects-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"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AQ,CAAC,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC,CAAC,yBAAyB,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metaobjectsdev/cli",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.1",
|
|
4
4
|
"description": "CLI for MetaObjects: scaffold, codegen, migrate, and drift-detection commands.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/src/index.js",
|
|
@@ -49,15 +49,15 @@
|
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@libsql/kysely-libsql": "^0.4.0",
|
|
52
|
-
"@metaobjectsdev/codegen-ts": "0.24.
|
|
53
|
-
"@metaobjectsdev/codegen-ts-react": "0.24.
|
|
54
|
-
"@metaobjectsdev/codegen-ts-tanstack": "0.24.
|
|
55
|
-
"@metaobjectsdev/docs-site": "0.24.
|
|
56
|
-
"@metaobjectsdev/metadata": "0.24.
|
|
57
|
-
"@metaobjectsdev/migrate-ts": "0.24.
|
|
58
|
-
"@metaobjectsdev/render": "0.24.
|
|
59
|
-
"@metaobjectsdev/runtime-ts": "0.24.
|
|
60
|
-
"@metaobjectsdev/sdk": "0.24.
|
|
52
|
+
"@metaobjectsdev/codegen-ts": "0.24.1",
|
|
53
|
+
"@metaobjectsdev/codegen-ts-react": "0.24.1",
|
|
54
|
+
"@metaobjectsdev/codegen-ts-tanstack": "0.24.1",
|
|
55
|
+
"@metaobjectsdev/docs-site": "0.24.1",
|
|
56
|
+
"@metaobjectsdev/metadata": "0.24.1",
|
|
57
|
+
"@metaobjectsdev/migrate-ts": "0.24.1",
|
|
58
|
+
"@metaobjectsdev/render": "0.24.1",
|
|
59
|
+
"@metaobjectsdev/runtime-ts": "0.24.1",
|
|
60
|
+
"@metaobjectsdev/sdk": "0.24.1",
|
|
61
61
|
"@toon-format/toon": "^2.3.0",
|
|
62
62
|
"jiti": "^2.4.0"
|
|
63
63
|
},
|
package/src/commands/docs.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// `meta docs <
|
|
1
|
+
// `meta docs [<project-root>] --out <dir>` — STANDALONE neutral metadata docs.
|
|
2
2
|
//
|
|
3
3
|
// Emits one neutral page per entity (`<Entity>.md`) and one per
|
|
4
4
|
// `template.output` (`<Template>.md`) from metadata ALONE — no gen config, no
|
|
@@ -39,8 +39,12 @@ import { generateSite, SITE_TEMPLATE_NAMES, SITE_ASSET_NAMES, readSiteFile } fro
|
|
|
39
39
|
type DocsLayout = "flat" | "package";
|
|
40
40
|
|
|
41
41
|
interface DocsFlags {
|
|
42
|
-
/**
|
|
43
|
-
metadata
|
|
42
|
+
/** The PROJECT ROOT to resolve metadata from — the directory that CONTAINS
|
|
43
|
+
* the metadata, never the metadata directory itself (#344). Named for what
|
|
44
|
+
* it is: while it was called `metadata` the help text spelled the positional
|
|
45
|
+
* `<metadata>`, which is what the Python and C# `docs` positionals actually
|
|
46
|
+
* mean, and pointing this one at `metaobjects/` fails. */
|
|
47
|
+
projectRoot: string;
|
|
44
48
|
/** Output directory for the rendered pages. */
|
|
45
49
|
out: string;
|
|
46
50
|
/** Page-placement layout. `flat` (default) writes `<Name>.md` at the out
|
|
@@ -48,7 +52,7 @@ interface DocsFlags {
|
|
|
48
52
|
* for multi-package models with repeated short names). */
|
|
49
53
|
layout: DocsLayout;
|
|
50
54
|
/** Optional override for the project root used to resolve adopter
|
|
51
|
-
* `templates/` overrides. Defaults to the
|
|
55
|
+
* `templates/` overrides. Defaults to the project root. */
|
|
52
56
|
templates?: string;
|
|
53
57
|
/** Optional directory holding the prompt `.mustache` sources, for a project
|
|
54
58
|
* whose templates live outside the conventional `metaobjects/` or `templates/`
|
|
@@ -66,12 +70,12 @@ interface DocsFlags {
|
|
|
66
70
|
outProvided: boolean;
|
|
67
71
|
/** Whether `--layout` was explicitly passed (same override semantics). */
|
|
68
72
|
layoutProvided: boolean;
|
|
69
|
-
/** Whether the `<
|
|
73
|
+
/** Whether the `<project-root>` positional was explicitly passed. An explicit path
|
|
70
74
|
* DEFINES the source set (`resolveCollection`'s `explicitDir` pin); the default
|
|
71
75
|
* cwd discovers one by walking up. Without this distinction the two are
|
|
72
76
|
* indistinguishable at the call site, which is how an explicitly-scoped run came
|
|
73
77
|
* to have an ancestor config's sources unioned into it (#327). */
|
|
74
|
-
|
|
78
|
+
projectRootProvided: boolean;
|
|
75
79
|
/** FR-033 S3 — document the METAMODEL ITSELF (the built-in type/subtype/attr
|
|
76
80
|
* vocabulary) instead of a user's entities. Needs NO metadata + NO config. */
|
|
77
81
|
metamodel: boolean;
|
|
@@ -93,7 +97,7 @@ function parseLayout(v: string | undefined, flag: string): DocsLayout {
|
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
function parseDocsArgs(argv: string[], cwd: string): DocsFlags {
|
|
96
|
-
let
|
|
100
|
+
let projectRoot: string | undefined;
|
|
97
101
|
let out: string | undefined;
|
|
98
102
|
let templates: string | undefined;
|
|
99
103
|
let prompts: string | undefined;
|
|
@@ -155,8 +159,8 @@ function parseDocsArgs(argv: string[], cwd: string): DocsFlags {
|
|
|
155
159
|
prompts = a.slice("--prompts=".length);
|
|
156
160
|
} else if (a.startsWith("-")) {
|
|
157
161
|
throw new Error(`unknown flag: ${a}`);
|
|
158
|
-
} else if (
|
|
159
|
-
|
|
162
|
+
} else if (projectRoot === undefined) {
|
|
163
|
+
projectRoot = a;
|
|
160
164
|
} else {
|
|
161
165
|
throw new Error(`unexpected argument: ${a}`);
|
|
162
166
|
}
|
|
@@ -172,11 +176,11 @@ function parseDocsArgs(argv: string[], cwd: string): DocsFlags {
|
|
|
172
176
|
if (wantApi) surfaces.push("api");
|
|
173
177
|
if (wantRequirements) surfaces.push("requirements");
|
|
174
178
|
return {
|
|
175
|
-
// `<
|
|
176
|
-
// (mirrors how migrate/gen treat the working directory as the root).
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
// Default out dir, resolved against the
|
|
179
|
+
// `<project-root>` is the project root that CONTAINS the metadata; default
|
|
180
|
+
// cwd (mirrors how migrate/gen treat the working directory as the root).
|
|
181
|
+
projectRoot: projectRoot ?? cwd,
|
|
182
|
+
projectRootProvided: projectRoot !== undefined,
|
|
183
|
+
// Default out dir, resolved against the project root below. In --metamodel
|
|
180
184
|
// mode the renderer writes under <out>/metamodel/, default ./docs/metamodel.
|
|
181
185
|
out: out ?? (wantMetamodel ? "./docs/metamodel" : "./docs"),
|
|
182
186
|
// Default flat preserves today's single-package output (+ existing goldens).
|
|
@@ -210,7 +214,7 @@ export async function docsCommand(args: string[], cwd: string): Promise<number>
|
|
|
210
214
|
return metamodelDocsCommand(cwd, flags.out);
|
|
211
215
|
}
|
|
212
216
|
|
|
213
|
-
const metaRoot = resolvePath(cwd, flags.
|
|
217
|
+
const metaRoot = resolvePath(cwd, flags.projectRoot);
|
|
214
218
|
// Absolute prompt-source dir for the site (--prompts), for a project whose
|
|
215
219
|
// templates live outside metaobjects/ or templates/ (e.g. data/templates/).
|
|
216
220
|
const promptsDir = flags.prompts !== undefined ? resolvePath(cwd, flags.prompts) : undefined;
|
|
@@ -238,11 +242,11 @@ export async function docsCommand(args: string[], cwd: string): Promise<number>
|
|
|
238
242
|
// everything project-relative — `metaobjects.config.ts` and its providers,
|
|
239
243
|
// the `docs.outDir` it names, the adopter `templates/` overrides, the owned
|
|
240
244
|
// `codegen/docs-site/` theme — has to come from that same directory. Reading
|
|
241
|
-
// the config from the ambient `<
|
|
245
|
+
// the config from the ambient `<project-root>` argument while the metadata came
|
|
242
246
|
// from an ancestor renders the ancestor's model with the subdirectory's
|
|
243
247
|
// (absent) providers. For a run at the project root the two are the same path.
|
|
244
248
|
//
|
|
245
|
-
// An EXPLICIT `<
|
|
249
|
+
// An EXPLICIT `<project-root>` positional pins the collection rather than seeding a
|
|
246
250
|
// walk (#327). The argument has always meant "document this": before sources were
|
|
247
251
|
// resolvable it read `<path>/metaobjects/` and nothing else, and passing it to
|
|
248
252
|
// discovery turned it into a starting point, so the nearest ancestor
|
|
@@ -255,7 +259,7 @@ export async function docsCommand(args: string[], cwd: string): Promise<number>
|
|
|
255
259
|
try {
|
|
256
260
|
collection = await resolveCollection(
|
|
257
261
|
metaRoot,
|
|
258
|
-
flags.
|
|
262
|
+
flags.projectRootProvided ? { explicitDir: metaRoot } : undefined,
|
|
259
263
|
);
|
|
260
264
|
} catch (err) {
|
|
261
265
|
log.error(`docs: ${(err as Error).message}`);
|
package/src/commands/gen.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { relative } from "node:path";
|
|
2
2
|
import { parseGenArgs } from "../lib/args.js";
|
|
3
3
|
import { resolveGenConfig } from "../lib/config.js";
|
|
4
|
-
import { loadMemoryOptionsFrom, loadMetaobjectsConfig, resolveGenConfigDir } from "../lib/load-metaobjects-config.js";
|
|
4
|
+
import { loadMemoryOptionsFrom, loadMetaobjectsConfig, resolveGenCollection, resolveGenConfigDir } from "../lib/load-metaobjects-config.js";
|
|
5
5
|
import { formatGenResult, formatGenResultToon, type GenFileEntry, type GenFileStatus } from "../lib/output.js";
|
|
6
6
|
import { formatGenResultJson } from "../lib/output-json.js";
|
|
7
7
|
import type { OutputFormat } from "../lib/format.js";
|
|
@@ -74,6 +74,12 @@ export async function genCommand(args: string[], cwd: string, fmt: OutputFormat
|
|
|
74
74
|
// project root's config exactly as before.
|
|
75
75
|
const projectRoot = resolveGenConfigDir(cwd, collection.configDir);
|
|
76
76
|
|
|
77
|
+
// ...and a package that declares its own sources GENERATES from them (#340). An
|
|
78
|
+
// ancestor collection is the default for a package that declares none, never an
|
|
79
|
+
// addition to one that does — otherwise a sub-project's output silently absorbs
|
|
80
|
+
// metadata from unrelated trees. Identical object when the two configs sit together.
|
|
81
|
+
const genCollection = await resolveGenCollection(collection, projectRoot);
|
|
82
|
+
|
|
77
83
|
// Advisory: nudge to refresh the .claude/skills docs if they predate this CLI.
|
|
78
84
|
// Rooted at `projectRoot`, not ambient cwd — the scaffolded agent context sits
|
|
79
85
|
// with the project that declares the metadata, so a run from a subdirectory
|
|
@@ -97,8 +103,8 @@ export async function genCommand(args: string[], cwd: string, fmt: OutputFormat
|
|
|
97
103
|
|
|
98
104
|
let metadata;
|
|
99
105
|
try {
|
|
100
|
-
metadata = await loadMemory(
|
|
101
|
-
files:
|
|
106
|
+
metadata = await loadMemory(genCollection.configDir, {
|
|
107
|
+
files: genCollection.files,
|
|
102
108
|
...loadMemoryOptionsFrom(forgeConfig),
|
|
103
109
|
});
|
|
104
110
|
} catch (err) {
|
|
@@ -120,7 +126,7 @@ export async function genCommand(args: string[], cwd: string, fmt: OutputFormat
|
|
|
120
126
|
// GENERATED entities, never over what the collection loads. Always
|
|
121
127
|
// passed: an unconfigured project's predicate admits everything, so this
|
|
122
128
|
// is a no-op for the common case, not a behavior change.
|
|
123
|
-
scope:
|
|
129
|
+
scope: genCollection.inScope,
|
|
124
130
|
...(cliConfig.entities.length > 0 ? { entityFilter: cliConfig.entities } : {}),
|
|
125
131
|
});
|
|
126
132
|
} catch (err) {
|
package/src/commands/upgrade.ts
CHANGED
|
@@ -22,8 +22,8 @@ import { resolveCollection } from "@metaobjectsdev/sdk";
|
|
|
22
22
|
import { rewriteDocument } from "@metaobjectsdev/metadata";
|
|
23
23
|
import { log } from "../lib/log.js";
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
const
|
|
25
|
+
/** YAML authoring (ADR-0006). Rewritten by the `yaml`-backed arm, loaded on demand below. */
|
|
26
|
+
const YAML_EXTENSIONS = new Set([".yaml", ".yml"]);
|
|
27
27
|
|
|
28
28
|
interface UpgradeFlags {
|
|
29
29
|
apply: boolean;
|
|
@@ -56,8 +56,10 @@ export async function upgradeCommand(args: string[], cwd: string): Promise<numbe
|
|
|
56
56
|
if ((err as Error).message === "__help__") {
|
|
57
57
|
log.info(
|
|
58
58
|
"meta upgrade [<project>] [--to <version>] [--apply]\n\n" +
|
|
59
|
-
" Rewrites retired metadata vocabulary
|
|
60
|
-
"
|
|
59
|
+
" Rewrites retired metadata vocabulary in JSON and YAML metadata alike.\n" +
|
|
60
|
+
" Previews by default; --apply writes.\n" +
|
|
61
|
+
" Retirements needing a human decision are REFUSED and listed with their guide.\n\n" +
|
|
62
|
+
" Exit: 0 clean · 1 refusals remain · 2 bad usage · 3 some files could not be read.",
|
|
61
63
|
);
|
|
62
64
|
return 0;
|
|
63
65
|
}
|
|
@@ -78,23 +80,38 @@ export async function upgradeCommand(args: string[], cwd: string): Promise<numbe
|
|
|
78
80
|
let totalChanges = 0;
|
|
79
81
|
let totalRefusals = 0;
|
|
80
82
|
let filesChanged = 0;
|
|
81
|
-
|
|
83
|
+
let checked = 0;
|
|
84
|
+
// Files we could not READ AT ALL. Distinct from "checked and clean" in every report and in
|
|
85
|
+
// the exit code — conflating them is the whole of #339.
|
|
86
|
+
const notChecked: string[] = [];
|
|
87
|
+
|
|
88
|
+
// The YAML arm carries the `yaml` package, so it lives behind its own subpath and is
|
|
89
|
+
// loaded only when the estate actually contains YAML. Importing it eagerly would pull a
|
|
90
|
+
// Node-only dependency into every `meta` invocation.
|
|
91
|
+
const hasYaml = files.some((f) => YAML_EXTENSIONS.has(extname(f).toLowerCase()));
|
|
92
|
+
const rewriteYaml = hasYaml
|
|
93
|
+
? (await import("@metaobjectsdev/metadata/vocabulary-rewrite-yaml")).rewriteYamlDocument
|
|
94
|
+
: undefined;
|
|
95
|
+
|
|
96
|
+
const opts = flags.maxVersion !== undefined ? { maxVersion: flags.maxVersion } : {};
|
|
82
97
|
|
|
83
98
|
for (const file of files) {
|
|
84
99
|
const rel = relative(projectRoot, file);
|
|
100
|
+
const before = await readFile(file, "utf8");
|
|
85
101
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
102
|
+
let r;
|
|
103
|
+
if (YAML_EXTENSIONS.has(extname(file).toLowerCase())) {
|
|
104
|
+
const y = rewriteYaml?.(before, opts);
|
|
105
|
+
// A document that does not parse was not examined, and must never be counted as clean.
|
|
106
|
+
if (y === undefined || y.unparseable) {
|
|
107
|
+
notChecked.push(rel);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
r = y;
|
|
111
|
+
} else {
|
|
112
|
+
r = rewriteDocument(before, opts);
|
|
92
113
|
}
|
|
93
|
-
|
|
94
|
-
const before = await readFile(file, "utf8");
|
|
95
|
-
const r = rewriteDocument(before, {
|
|
96
|
-
...(flags.maxVersion !== undefined ? { maxVersion: flags.maxVersion } : {}),
|
|
97
|
-
});
|
|
114
|
+
checked++;
|
|
98
115
|
if (r.changes.length === 0 && r.refusals.length === 0) continue;
|
|
99
116
|
|
|
100
117
|
log.info(`\n${rel}`);
|
|
@@ -115,19 +132,20 @@ export async function upgradeCommand(args: string[], cwd: string): Promise<numbe
|
|
|
115
132
|
}
|
|
116
133
|
|
|
117
134
|
log.info("");
|
|
118
|
-
if (
|
|
135
|
+
if (notChecked.length > 0) {
|
|
119
136
|
log.warn(
|
|
120
|
-
`${
|
|
121
|
-
`
|
|
137
|
+
`${notChecked.length} file(s) could not be parsed and were NOT checked — fix these ` +
|
|
138
|
+
`first, then re-run:\n ${notChecked.join("\n ")}`,
|
|
122
139
|
);
|
|
123
140
|
}
|
|
124
141
|
|
|
142
|
+
// Every conclusion states how many files it is a conclusion ABOUT. "No retired vocabulary
|
|
143
|
+
// found" read on its own says the estate is clean, and it is the last line, so it is the
|
|
144
|
+
// one that sticks — on the estate that reported this, it was the opposite of the truth.
|
|
145
|
+
const scope = `${checked} file(s) checked${notChecked.length > 0 ? `, ${notChecked.length} NOT checked` : ""}`;
|
|
146
|
+
|
|
125
147
|
if (totalChanges === 0 && totalRefusals === 0) {
|
|
126
|
-
log.info(
|
|
127
|
-
skipped.length > 0
|
|
128
|
-
? "meta upgrade — no retired vocabulary found in the JSON metadata."
|
|
129
|
-
: "meta upgrade — no retired vocabulary found.",
|
|
130
|
-
);
|
|
148
|
+
log.info(`meta upgrade — no retired vocabulary found (${scope}).`);
|
|
131
149
|
} else if (totalChanges === 0) {
|
|
132
150
|
// Refusals only. Reporting "rewrote 0 declarations", or advertising `--apply`, both
|
|
133
151
|
// promise an action guaranteed to change nothing and bury the fact that the remaining
|
|
@@ -143,8 +161,7 @@ export async function upgradeCommand(args: string[], cwd: string): Promise<numbe
|
|
|
143
161
|
}
|
|
144
162
|
|
|
145
163
|
// Non-zero while ANY refusal stands, applied or not. A partial upgrade that exited 0 would
|
|
146
|
-
// let CI record the migration as done while metadata still fails to load.
|
|
147
|
-
// not read at all counts the same way, for the same reason.
|
|
164
|
+
// let CI record the migration as done while metadata still fails to load.
|
|
148
165
|
if (totalRefusals > 0) {
|
|
149
166
|
log.error(
|
|
150
167
|
`${totalRefusals} declaration(s) need a human decision and were left untouched — ` +
|
|
@@ -152,5 +169,11 @@ export async function upgradeCommand(args: string[], cwd: string): Promise<numbe
|
|
|
152
169
|
);
|
|
153
170
|
return 1;
|
|
154
171
|
}
|
|
155
|
-
|
|
172
|
+
|
|
173
|
+
// "I could not look" gets its OWN code. It used to share exit 1 with "work remains", so a
|
|
174
|
+
// script could not tell an estate needing decisions from one the tool never opened — and
|
|
175
|
+
// an adopter whose whole estate was skipped got a failure exit next to a message saying
|
|
176
|
+
// nothing was found.
|
|
177
|
+
if (notChecked.length > 0) return 3;
|
|
178
|
+
return 0;
|
|
156
179
|
}
|
package/src/commands/verify.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { warnIfManifestIgnored } from "../lib/manifest-ignored-check.js";
|
|
|
15
15
|
import { scanSourceForAntiPatterns } from "../lib/anti-patterns.js";
|
|
16
16
|
import { FileProvider } from "../lib/file-provider.js";
|
|
17
17
|
import { derivePayloadFieldTree } from "../lib/payload-field-tree.js";
|
|
18
|
-
import { loadMemoryOptionsFrom, loadMetaobjectsConfig, resolveGenConfigDir } from "../lib/load-metaobjects-config.js";
|
|
18
|
+
import { loadMemoryOptionsFrom, loadMetaobjectsConfig, resolveGenCollection, resolveGenConfigDir } from "../lib/load-metaobjects-config.js";
|
|
19
19
|
import { computeCodegenDrift } from "../lib/codegen-drift.js";
|
|
20
20
|
import { checkRequirements, summariseRequirements } from "../lib/requirement-check.js";
|
|
21
21
|
import { resolveD1Config, resolveMigrateConfig } from "../lib/config.js";
|
|
@@ -954,9 +954,33 @@ export async function verifyCommand(
|
|
|
954
954
|
// question 3) — a `gen` that committed under a narrowed scope and a
|
|
955
955
|
// `verify --codegen` that regenerates unscoped would disagree about which
|
|
956
956
|
// files should exist, reporting every out-of-scope entity as drift.
|
|
957
|
+
//
|
|
958
|
+
// The same argument governs the SOURCE SET (#340), and it is the reason this
|
|
959
|
+
// resolves its own collection instead of reusing the outer one: `gen` in a
|
|
960
|
+
// sub-project generates from that package's own sources, so a `--codegen` gate
|
|
961
|
+
// that regenerated from the ancestor's wider set would report every file the
|
|
962
|
+
// ancestor contributes as drift — turning the #340 fix into a broken gate. It is
|
|
963
|
+
// re-resolved rather than hoisted because `verify`'s subverbs COMPOSE: `--db` and
|
|
964
|
+
// `--templates` are answering a question about the whole declared collection, and
|
|
965
|
+
// narrowing the outer `root` would silently change what they check.
|
|
966
|
+
const genCollection = await resolveGenCollection(collection, genConfigDir);
|
|
967
|
+
let codegenRoot = root;
|
|
968
|
+
if (genCollection !== collection) {
|
|
969
|
+
try {
|
|
970
|
+
codegenRoot = await loadMemory(genCollection.configDir, {
|
|
971
|
+
files: genCollection.files,
|
|
972
|
+
...configLoadOptions,
|
|
973
|
+
strict: !flags.lax,
|
|
974
|
+
});
|
|
975
|
+
} catch (err) {
|
|
976
|
+
log.error(`verify --codegen: failed to load this package's metadata: ${(err as Error).message}`);
|
|
977
|
+
return 2;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
957
981
|
let result;
|
|
958
982
|
try {
|
|
959
|
-
result = await computeCodegenDrift(forgeConfig,
|
|
983
|
+
result = await computeCodegenDrift(forgeConfig, codegenRoot, genConfigDir, genCollection.inScope);
|
|
960
984
|
} catch (err) {
|
|
961
985
|
log.error(`verify --codegen: regeneration failed: ${(err as Error).message}`);
|
|
962
986
|
return 1;
|