@metaobjectsdev/cli 1.0.0-rc.4 → 1.0.0-rc.6
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 +41 -9
- package/dist/src/commands/docs.js.map +1 -1
- package/dist/src/commands/gen.d.ts +8 -0
- package/dist/src/commands/gen.d.ts.map +1 -1
- package/dist/src/commands/gen.js +17 -4
- package/dist/src/commands/gen.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +181 -35
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/migrate.d.ts +6 -0
- package/dist/src/commands/migrate.d.ts.map +1 -1
- package/dist/src/commands/migrate.js +11 -5
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/prompt-snapshot.d.ts.map +1 -1
- package/dist/src/commands/prompt-snapshot.js +2 -1
- package/dist/src/commands/prompt-snapshot.js.map +1 -1
- package/dist/src/commands/types.d.ts.map +1 -1
- package/dist/src/commands/types.js +12 -3
- package/dist/src/commands/types.js.map +1 -1
- package/dist/src/commands/upgrade.d.ts.map +1 -1
- package/dist/src/commands/upgrade.js +38 -4
- 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 +108 -30
- package/dist/src/commands/verify.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +55 -8
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/advisory.d.ts +6 -0
- package/dist/src/lib/advisory.d.ts.map +1 -1
- package/dist/src/lib/advisory.js +13 -0
- package/dist/src/lib/advisory.js.map +1 -1
- package/dist/src/lib/anti-patterns.d.ts.map +1 -1
- package/dist/src/lib/anti-patterns.js +2 -4
- package/dist/src/lib/anti-patterns.js.map +1 -1
- package/dist/src/lib/args.d.ts +251 -12
- package/dist/src/lib/args.d.ts.map +1 -1
- package/dist/src/lib/args.js +119 -92
- package/dist/src/lib/args.js.map +1 -1
- package/dist/src/lib/base-url-advisory.d.ts +37 -0
- package/dist/src/lib/base-url-advisory.d.ts.map +1 -0
- package/dist/src/lib/base-url-advisory.js +162 -0
- package/dist/src/lib/base-url-advisory.js.map +1 -0
- package/dist/src/lib/codegen-drift.d.ts +8 -0
- package/dist/src/lib/codegen-drift.d.ts.map +1 -1
- package/dist/src/lib/codegen-drift.js +43 -10
- package/dist/src/lib/codegen-drift.js.map +1 -1
- package/dist/src/lib/detect-stack.d.ts +17 -0
- package/dist/src/lib/detect-stack.d.ts.map +1 -1
- package/dist/src/lib/detect-stack.js +64 -2
- package/dist/src/lib/detect-stack.js.map +1 -1
- package/dist/src/lib/docs-drift.d.ts +12 -1
- package/dist/src/lib/docs-drift.d.ts.map +1 -1
- package/dist/src/lib/docs-drift.js +85 -16
- package/dist/src/lib/docs-drift.js.map +1 -1
- package/dist/src/lib/git-ignore.d.ts +59 -0
- package/dist/src/lib/git-ignore.d.ts.map +1 -0
- package/dist/src/lib/git-ignore.js +120 -0
- package/dist/src/lib/git-ignore.js.map +1 -0
- package/dist/src/lib/ignored-scaffold-check.d.ts +12 -0
- package/dist/src/lib/ignored-scaffold-check.d.ts.map +1 -0
- package/dist/src/lib/ignored-scaffold-check.js +75 -0
- package/dist/src/lib/ignored-scaffold-check.js.map +1 -0
- package/dist/src/lib/load-error.d.ts +46 -0
- package/dist/src/lib/load-error.d.ts.map +1 -0
- package/dist/src/lib/load-error.js +51 -0
- package/dist/src/lib/load-error.js.map +1 -0
- package/dist/src/lib/load-metaobjects-config.d.ts.map +1 -1
- package/dist/src/lib/load-metaobjects-config.js +65 -1
- package/dist/src/lib/load-metaobjects-config.js.map +1 -1
- package/dist/src/lib/manifest-ignored-check.d.ts.map +1 -1
- package/dist/src/lib/manifest-ignored-check.js +23 -36
- package/dist/src/lib/manifest-ignored-check.js.map +1 -1
- package/dist/src/lib/output.d.ts +22 -1
- package/dist/src/lib/output.d.ts.map +1 -1
- package/dist/src/lib/output.js +39 -12
- package/dist/src/lib/output.js.map +1 -1
- package/dist/src/lib/rel-posix.d.ts +5 -0
- package/dist/src/lib/rel-posix.d.ts.map +1 -0
- package/dist/src/lib/rel-posix.js +23 -0
- package/dist/src/lib/rel-posix.js.map +1 -0
- package/dist/src/lib/replay-remedy.d.ts +2 -0
- package/dist/src/lib/replay-remedy.d.ts.map +1 -0
- package/dist/src/lib/replay-remedy.js +69 -0
- package/dist/src/lib/replay-remedy.js.map +1 -0
- package/dist/src/lib/requirement-lint.d.ts.map +1 -1
- package/dist/src/lib/requirement-lint.js +25 -5
- package/dist/src/lib/requirement-lint.js.map +1 -1
- package/package.json +10 -10
- package/src/commands/docs.ts +51 -12
- package/src/commands/gen.ts +19 -4
- package/src/commands/init.ts +188 -39
- package/src/commands/migrate.ts +13 -5
- package/src/commands/prompt-snapshot.ts +2 -1
- package/src/commands/types.ts +12 -3
- package/src/commands/upgrade.ts +44 -4
- package/src/commands/verify.ts +120 -32
- package/src/index.ts +55 -8
- package/src/lib/advisory.ts +15 -0
- package/src/lib/anti-patterns.ts +2 -5
- package/src/lib/args.ts +154 -109
- package/src/lib/base-url-advisory.ts +173 -0
- package/src/lib/codegen-drift.ts +52 -9
- package/src/lib/detect-stack.ts +73 -2
- package/src/lib/docs-drift.ts +107 -17
- package/src/lib/git-ignore.ts +159 -0
- package/src/lib/ignored-scaffold-check.ts +78 -0
- package/src/lib/load-error.ts +89 -0
- package/src/lib/load-metaobjects-config.ts +58 -1
- package/src/lib/manifest-ignored-check.ts +25 -33
- package/src/lib/output.ts +64 -11
- package/src/lib/rel-posix.ts +25 -0
- package/src/lib/replay-remedy.ts +78 -0
- package/src/lib/requirement-lint.ts +26 -5
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
import { mkdtempSync, rmSync, existsSync, readFileSync, readdirSync, statSync, cpSync, } from "node:fs";
|
|
31
31
|
import { tmpdir } from "node:os";
|
|
32
32
|
import { join, relative, resolve, isAbsolute } from "node:path";
|
|
33
|
-
import { runGen, contentHash, readGeneratedHash, listGeneratedPaths, } from "@metaobjectsdev/codegen-ts";
|
|
33
|
+
import { runGen, contentHash, readGeneratedHash, listGeneratedPaths, NAMES_FILE_SUFFIX, } from "@metaobjectsdev/codegen-ts";
|
|
34
34
|
/** Collect the committed outDirs declared by the config (default + per-target),
|
|
35
35
|
* resolved against `projectRoot` — a relative outDir (the common, portable,
|
|
36
36
|
* `meta init`-scaffolded shape) must resolve against the project the CLI's
|
|
@@ -91,6 +91,7 @@ export async function computeCodegenDrift(config, metadata, projectRoot, scope)
|
|
|
91
91
|
clean: false,
|
|
92
92
|
driftedFiles: [],
|
|
93
93
|
lines: [],
|
|
94
|
+
handEditedNames: [],
|
|
94
95
|
error: "verify --codegen: no outDir configured — cannot locate the committed " +
|
|
95
96
|
"generated output to diff against. Set 'outDir' (and/or per-target " +
|
|
96
97
|
"outDir) in metaobjects.config.ts.",
|
|
@@ -153,6 +154,7 @@ export async function computeCodegenDrift(config, metadata, projectRoot, scope)
|
|
|
153
154
|
// Diff each committed outDir against its temp mirror.
|
|
154
155
|
const driftedFiles = new Set();
|
|
155
156
|
const lines = [];
|
|
157
|
+
const handEditedNames = new Set();
|
|
156
158
|
// Whether we have any record of what we wrote here. With records, the orphan
|
|
157
159
|
// branch below can scope itself to our own output; with none, it cannot tell
|
|
158
160
|
// our stale output from a stranger's file, so the old verdict stands.
|
|
@@ -190,20 +192,51 @@ export async function computeCodegenDrift(config, metadata, projectRoot, scope)
|
|
|
190
192
|
else {
|
|
191
193
|
const a = readFileSync(join(committed, rel), "utf8");
|
|
192
194
|
const b = readFileSync(join(fresh, rel), "utf8");
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
195
|
+
if (a !== b) {
|
|
196
|
+
// A `<Entity>Names` artifact is the ONE generated file where a hand edit is
|
|
197
|
+
// itself the defect, so the exemption below does not reach it. RULED: if you
|
|
198
|
+
// want a constant of your own, put it in a file of your own.
|
|
199
|
+
//
|
|
200
|
+
// The exemption exists because `meta gen` MERGES a hand edit and reports
|
|
201
|
+
// "merged", so convicting it printed a remedy that could not work — gen
|
|
202
|
+
// merges again and the next verify fails identically. A names artifact is not
|
|
203
|
+
// that shape. It is a module of physical database names, every value a string:
|
|
204
|
+
// no compiler can see a wrong one, no test reads it, and the whole point of
|
|
205
|
+
// the artifact is that a name is spelled ONCE per run and referenced. So an
|
|
206
|
+
// edited one silently renames a column for every consumer of it, while the
|
|
207
|
+
// gate reports "generated output is in sync with the metadata" — the exact
|
|
208
|
+
// failure the artifact was added to prevent, committed inside the artifact.
|
|
209
|
+
//
|
|
210
|
+
// Keyed on the suffix the emitter and the reference template both spell from
|
|
211
|
+
// one constant. An adopter who owns the generator and RENAMES the artifact
|
|
212
|
+
// opts out of this — stated rather than hidden; the gate cannot recognise a
|
|
213
|
+
// file shape it was never told about.
|
|
214
|
+
if (rel.endsWith(NAMES_FILE_SUFFIX)) {
|
|
215
|
+
driftedFiles.add(relKey);
|
|
216
|
+
handEditedNames.add(relKey);
|
|
217
|
+
lines.push(`~ ${relKey} (hand-edited; a names artifact must match a fresh regen exactly — ` +
|
|
218
|
+
`put constants of your own in a file of your own)`);
|
|
219
|
+
}
|
|
220
|
+
else if (readGeneratedHash(projectGenStateDir, relKey) !== contentHash(b)) {
|
|
221
|
+
// Not `a !== b` alone: that convicts the hand edit `meta gen` preserved.
|
|
222
|
+
// The question this gate can honestly answer is "is the GENERATED
|
|
223
|
+
// contribution current?", and the recorded hash answers exactly it.
|
|
224
|
+
// FAILS CLOSED, matching `isPristineGenerated`: with no recorded hash
|
|
225
|
+
// nothing is proven, so the old byte verdict stands.
|
|
226
|
+
driftedFiles.add(relKey);
|
|
227
|
+
lines.push(`~ ${relKey} (committed content differs from a fresh regen)`);
|
|
228
|
+
}
|
|
201
229
|
}
|
|
202
230
|
}
|
|
203
231
|
}
|
|
204
232
|
}
|
|
205
233
|
const sorted = [...driftedFiles].sort();
|
|
206
|
-
return {
|
|
234
|
+
return {
|
|
235
|
+
clean: sorted.length === 0,
|
|
236
|
+
driftedFiles: sorted,
|
|
237
|
+
lines,
|
|
238
|
+
handEditedNames: [...handEditedNames].sort(),
|
|
239
|
+
};
|
|
207
240
|
}
|
|
208
241
|
finally {
|
|
209
242
|
rmSync(tempRoot, { recursive: true, force: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-drift.js","sourceRoot":"","sources":["../../../src/lib/codegen-drift.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,mFAAmF;AACnF,uCAAuC;AACvC,EAAE;AACF,6EAA6E;AAC7E,kFAAkF;AAClF,gFAAgF;AAChF,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,iFAAiF;AACjF,kFAAkF;AAClF,qCAAqC;AACrC,EAAE;AACF,mFAAmF;AACnF,oFAAoF;AACpF,iFAAiF;AACjF,yEAAyE;AACzE,+EAA+E;AAC/E,yEAAyE;AACzE,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,6EAA6E;AAC7E,8EAA8E;AAC9E,mEAAmE;AAEnE,OAAO,EACL,WAAW,EACX,MAAM,EACN,UAAU,EACV,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,MAAM,GACP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EACL,MAAM,EACN,WAAW,EACX,iBAAiB,EACjB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"codegen-drift.js","sourceRoot":"","sources":["../../../src/lib/codegen-drift.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,E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AAC;QACH,CAAC;QAED,MAAM,MAAM,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC,IAAI,EAAE,CAAC;QACxC,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;YAC1B,YAAY,EAAE,MAAM;YACpB,KAAK;YACL,eAAe,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,IAAI,EAAE;SAC7C,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import { type Stack } from "@metaobjectsdev/sdk/agent-context";
|
|
2
|
+
/**
|
|
3
|
+
* Refuse an unknown `--server` / `--client` value instead of dropping it.
|
|
4
|
+
*
|
|
5
|
+
* `--server node` — the CLI's own help example — used to exit 0 with no warning and record
|
|
6
|
+
* `"servers": []`. Worse than the missing four reference fragments: a non-empty override
|
|
7
|
+
* array suppresses BOTH the prior manifest's stack and detection, so the emitted context then
|
|
8
|
+
* declared "Stack: no server, no client" and told the agent that this project has no
|
|
9
|
+
* `metaobjects.config.ts` — about a project with a Fastify server, a React client, and the
|
|
10
|
+
* very config file the same CLI had just read. One silently-dropped flag value made three
|
|
11
|
+
* statements false in the artifact whose whole job is to orient an agent correctly.
|
|
12
|
+
*
|
|
13
|
+
* Either accept the value or say so; never neither.
|
|
14
|
+
*/
|
|
15
|
+
export declare function assertKnownStackValues(overrides: {
|
|
16
|
+
servers: string[];
|
|
17
|
+
clients: string[];
|
|
18
|
+
}): void;
|
|
2
19
|
/** Resolve the stack: explicit --server/--client overrides take precedence; otherwise detect.
|
|
3
20
|
* Concern tokens (e.g. requirements) are always OBSERVED from project state, independent of
|
|
4
21
|
* any --server/--client override — a concern is not a stack axis. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect-stack.d.ts","sourceRoot":"","sources":["../../../src/lib/detect-stack.ts"],"names":[],"mappings":"AAIA,OAAO,EAEkC,KAAK,KAAK,EAElD,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"detect-stack.d.ts","sourceRoot":"","sources":["../../../src/lib/detect-stack.ts"],"names":[],"mappings":"AAIA,OAAO,EAEkC,KAAK,KAAK,EAElD,MAAM,mCAAmC,CAAC;AA0E3C;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,IAAI,CAoBhG;AAED;;qEAEqE;AACrE,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAcnH"}
|
|
@@ -41,14 +41,76 @@ async function probe(cwd) {
|
|
|
41
41
|
hasRequirementNodes: () => requirementNodes,
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Spellings accepted for a stack value that is not the canonical one.
|
|
46
|
+
*
|
|
47
|
+
* `node` is here because the CLI's OWN `--help` gives it as an example of `--server`, and it
|
|
48
|
+
* is the more natural word for a Fastify backend run by the Node CLI. It used to be filtered
|
|
49
|
+
* out silently — see `assertKnownStackValues` for what that silence cost.
|
|
50
|
+
*/
|
|
51
|
+
const SERVER_ALIASES = {
|
|
52
|
+
node: "typescript",
|
|
53
|
+
nodejs: "typescript",
|
|
54
|
+
ts: "typescript",
|
|
55
|
+
"c#": "csharp",
|
|
56
|
+
dotnet: "csharp",
|
|
57
|
+
py: "python",
|
|
58
|
+
};
|
|
59
|
+
const CLIENT_ALIASES = {
|
|
60
|
+
reactjs: "react",
|
|
61
|
+
"react-query": "tanstack",
|
|
62
|
+
};
|
|
63
|
+
/** Canonicalize one value, or `undefined` when it names nothing we know. */
|
|
64
|
+
function canonical(raw, valid, aliases) {
|
|
65
|
+
const v = raw.trim().toLowerCase();
|
|
66
|
+
if (valid.includes(v))
|
|
67
|
+
return v;
|
|
68
|
+
return aliases[v];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Refuse an unknown `--server` / `--client` value instead of dropping it.
|
|
72
|
+
*
|
|
73
|
+
* `--server node` — the CLI's own help example — used to exit 0 with no warning and record
|
|
74
|
+
* `"servers": []`. Worse than the missing four reference fragments: a non-empty override
|
|
75
|
+
* array suppresses BOTH the prior manifest's stack and detection, so the emitted context then
|
|
76
|
+
* declared "Stack: no server, no client" and told the agent that this project has no
|
|
77
|
+
* `metaobjects.config.ts` — about a project with a Fastify server, a React client, and the
|
|
78
|
+
* very config file the same CLI had just read. One silently-dropped flag value made three
|
|
79
|
+
* statements false in the artifact whose whole job is to orient an agent correctly.
|
|
80
|
+
*
|
|
81
|
+
* Either accept the value or say so; never neither.
|
|
82
|
+
*/
|
|
83
|
+
export function assertKnownStackValues(overrides) {
|
|
84
|
+
const bad = [];
|
|
85
|
+
for (const s of overrides.servers) {
|
|
86
|
+
if (canonical(s, SERVER_LANGS, SERVER_ALIASES) === undefined) {
|
|
87
|
+
bad.push(`--server ${s} (known: ${SERVER_LANGS.join(", ")})`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
for (const c of overrides.clients) {
|
|
91
|
+
if (canonical(c, CLIENT_FRAMEWORKS, CLIENT_ALIASES) === undefined) {
|
|
92
|
+
bad.push(`--client ${c} (known: ${CLIENT_FRAMEWORKS.join(", ")})`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (bad.length > 0) {
|
|
96
|
+
throw new Error(`unknown stack value(s): ${bad.join("; ")}. A value that names nothing is refused rather ` +
|
|
97
|
+
"than dropped: an empty stack suppresses both the prior manifest and detection, and the " +
|
|
98
|
+
"generated agent context then states the project has no server, no client and no " +
|
|
99
|
+
"metaobjects.config.ts.");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
44
102
|
/** Resolve the stack: explicit --server/--client overrides take precedence; otherwise detect.
|
|
45
103
|
* Concern tokens (e.g. requirements) are always OBSERVED from project state, independent of
|
|
46
104
|
* any --server/--client override — a concern is not a stack axis. */
|
|
47
105
|
export async function resolveStack(cwd, overrides) {
|
|
48
106
|
const validServers = SERVER_LANGS;
|
|
49
107
|
const validClients = CLIENT_FRAMEWORKS;
|
|
50
|
-
const oServers = overrides.servers
|
|
51
|
-
|
|
108
|
+
const oServers = overrides.servers
|
|
109
|
+
.map((s) => canonical(s, validServers, SERVER_ALIASES))
|
|
110
|
+
.filter((s) => s !== undefined);
|
|
111
|
+
const oClients = overrides.clients
|
|
112
|
+
.map((c) => canonical(c, validClients, CLIENT_ALIASES))
|
|
113
|
+
.filter((c) => c !== undefined);
|
|
52
114
|
const p = await probe(cwd);
|
|
53
115
|
const concerns = detectConcerns(p);
|
|
54
116
|
if (oServers.length > 0 || oClients.length > 0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect-stack.js","sourceRoot":"","sources":["../../../src/lib/detect-stack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EACL,WAAW,EAAE,cAAc,EAAE,SAAS,EAEtC,YAAY,EAAE,iBAAiB,GAChC,MAAM,mCAAmC,CAAC;AAE3C,SAAS,QAAQ,CAAC,GAAW;IAC3B,mFAAmF;IACnF,yCAAyC;IACzC,OAAO,uBAAuB,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;A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,CAAC,CAAC,EAAwB,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;IACxD,MAAM,CAAC,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,MAAM,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC/F,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IAChC,OAAO,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -7,8 +7,19 @@ export interface DocsDriftResult {
|
|
|
7
7
|
/** Human-readable, one line per file. */
|
|
8
8
|
lines: string[];
|
|
9
9
|
/** The denominator both the passing and the failing report divide by: the pages a fresh
|
|
10
|
-
* run produced, plus any committed page under `agent/` it no longer emits
|
|
10
|
+
* run produced, plus any committed page under `agent/` it no longer emits, MINUS the
|
|
11
|
+
* git-ignored ones. A pure function of (fresh set, repository ignore rules) — never of
|
|
12
|
+
* which files happen to be on this machine's disk. */
|
|
11
13
|
checked: number;
|
|
14
|
+
/** How many pages a fresh run emits that the project git-ignores, so did not check.
|
|
15
|
+
* Reported on BOTH the passing and the failing line: a gate that quietly checked two
|
|
16
|
+
* of 589 pages and said "no drift" would be indistinguishable from one that checked
|
|
17
|
+
* everything. */
|
|
18
|
+
ignored: number;
|
|
19
|
+
/** Why the ignore rules could not be consulted, when they could not be. Undefined means
|
|
20
|
+
* they were. The gate then falls back to checking EVERY page a fresh run emits — the
|
|
21
|
+
* pre-existing behaviour — and says so rather than degrading silently. */
|
|
22
|
+
ignoreReason?: string | undefined;
|
|
12
23
|
/** Set when the gate could not run at all. */
|
|
13
24
|
error?: string;
|
|
14
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs-drift.d.ts","sourceRoot":"","sources":["../../../src/lib/docs-drift.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"docs-drift.d.ts","sourceRoot":"","sources":["../../../src/lib/docs-drift.ts"],"names":[],"mappings":"AAwDA,MAAM,WAAW,eAAe;IAC9B,uFAAuF;IACvF,KAAK,EAAE,OAAO,CAAC;IACf;yDACqD;IACrD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,yCAAyC;IACzC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;;2DAGuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB;;;sBAGkB;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB;;+EAE2E;IAC3E,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA4DD,MAAM,WAAW,oBAAoB;IACnC,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAC;IACpB,oFAAoF;IACpF,OAAO,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC,CA2J3F"}
|
|
@@ -19,9 +19,11 @@
|
|
|
19
19
|
// `.gen-state/.hashes.json` to tell a preserved hand edit from stale output; here
|
|
20
20
|
// there is no such offer to honour.
|
|
21
21
|
//
|
|
22
|
-
// 2. IT REPORTS A FILE AS EXTRA ONLY WHERE IT OWNS THE DIRECTORY. `docs.outDir`
|
|
23
|
-
//
|
|
24
|
-
// documentation — this repository's own `docs/` holds a hundred such files.
|
|
22
|
+
// 2. IT REPORTS A FILE AS EXTRA ONLY WHERE IT OWNS THE DIRECTORY. `docs.outDir` is a
|
|
23
|
+
// directory an adopter chooses, and it may well be one full of hand-written
|
|
24
|
+
// documentation — this repository's own `docs/` holds a hundred such files. (The
|
|
25
|
+
// default moved to `./docs/generated` for exactly that reason: defaulting into the
|
|
26
|
+
// most-owned directory name in the ecosystem contradicted this paragraph.) Its
|
|
25
27
|
// `api/` subtree is not ours either: on a multi-port project those pages are written
|
|
26
28
|
// by the OTHER port's docs command (`mvn metaobjects:docs`, `metaobjects docs`,
|
|
27
29
|
// `dotnet meta docs`), which this gate never runs, so a fresh run here legitimately
|
|
@@ -46,8 +48,10 @@
|
|
|
46
48
|
// entity that was DELETED stays committed and this gate stays green.
|
|
47
49
|
import { mkdtempSync, rmSync, existsSync, readFileSync, readdirSync, lstatSync } from "node:fs";
|
|
48
50
|
import { tmpdir } from "node:os";
|
|
49
|
-
import { join, relative, resolve, isAbsolute
|
|
51
|
+
import { join, relative, resolve, isAbsolute } from "node:path";
|
|
50
52
|
import { docsCommand } from "../commands/docs.js";
|
|
53
|
+
import { gitIgnored } from "./git-ignore.js";
|
|
54
|
+
import { toPosix } from "./rel-posix.js";
|
|
51
55
|
/**
|
|
52
56
|
* Recursively list files under `dir`, relative to it.
|
|
53
57
|
*
|
|
@@ -95,7 +99,7 @@ const GENERATED_MARKER = "@generated";
|
|
|
95
99
|
* hand-written note inside `agent/` out of it.
|
|
96
100
|
*/
|
|
97
101
|
function isOurs(docsDir, rel) {
|
|
98
|
-
const normalized = rel
|
|
102
|
+
const normalized = toPosix(rel);
|
|
99
103
|
if (!OWNED_PREFIXES.some((p) => normalized.startsWith(p)))
|
|
100
104
|
return false;
|
|
101
105
|
try {
|
|
@@ -138,6 +142,7 @@ export async function computeDocsDrift(args) {
|
|
|
138
142
|
driftedFiles: [],
|
|
139
143
|
lines: [],
|
|
140
144
|
checked: 0,
|
|
145
|
+
ignored: 0,
|
|
141
146
|
error: `verify --docs: 'meta docs' exited ${exit}, so the committed pages could not be ` +
|
|
142
147
|
`compared against a fresh run. Fix that first — the error is above.`,
|
|
143
148
|
};
|
|
@@ -149,17 +154,84 @@ export async function computeDocsDrift(args) {
|
|
|
149
154
|
driftedFiles: [],
|
|
150
155
|
lines: [],
|
|
151
156
|
checked: 0,
|
|
157
|
+
ignored: 0,
|
|
152
158
|
error: "verify --docs: a fresh 'meta docs' produced no pages, so there is nothing to " +
|
|
153
159
|
"compare. Check that this project declares metadata the docs surfaces cover.",
|
|
154
160
|
};
|
|
155
161
|
}
|
|
162
|
+
// Committed-but-not-regenerated, inside the directories this command owns.
|
|
163
|
+
const freshSet = new Set(fresh);
|
|
164
|
+
const ownedOrphans = listFiles(docsDir)
|
|
165
|
+
.filter((rel) => !freshSet.has(rel) && isOurs(docsDir, rel))
|
|
166
|
+
.sort();
|
|
167
|
+
// A page the project deliberately does not commit is not drift.
|
|
168
|
+
//
|
|
169
|
+
// `docs.outDir` is a directory, not a namespace MetaObjects owns — the same
|
|
170
|
+
// jurisdiction ruling 0.24.3 made for `verify --codegen`. But `--codegen` could key
|
|
171
|
+
// on `.gen-state/.hashes.json`, a record of what the generator WROTE, and `meta
|
|
172
|
+
// docs` keeps no such manifest. What it can ask instead is what the PROJECT says:
|
|
173
|
+
// a page under `docs.outDir` that git reports ignored is one the project has
|
|
174
|
+
// declared it does not commit.
|
|
175
|
+
//
|
|
176
|
+
// This is not a guess about intent, it is the project's own statement of it. And it
|
|
177
|
+
// cannot be used to hide a file the project actually tracks: git never reports a
|
|
178
|
+
// TRACKED path as ignored, whatever pattern matches it, so a committed page is
|
|
179
|
+
// always compared.
|
|
180
|
+
//
|
|
181
|
+
// The exemption is computed over the FRESH set by NAME, present on disk or not.
|
|
182
|
+
// That is what makes the verdict machine-independent: a developer box that has run
|
|
183
|
+
// `meta docs` locally has all 589 pages on disk and a CI runner has two, and both
|
|
184
|
+
// must report the same denominator. Deciding per-file-existence would have made
|
|
185
|
+
// `checked` a property of the machine.
|
|
186
|
+
//
|
|
187
|
+
// Without it: an estate generating three surfaces and committing 2 files of 589 —
|
|
188
|
+
// gitignoring the rest with a comment explaining they are a derived view of
|
|
189
|
+
// metadata that is already the source of truth — was told it had 588 drifted pages,
|
|
190
|
+
// of which exactly ONE was real.
|
|
191
|
+
const ignoreCandidates = [...fresh, ...ownedOrphans];
|
|
192
|
+
// honourGlobalExcludes: false — this verdict must be a property of the repository.
|
|
193
|
+
// A gate that passes for the author and fails in CI because of a personal ignore
|
|
194
|
+
// file is worse than no gate.
|
|
195
|
+
const ignoreLookup = gitIgnored(docsDir, ignoreCandidates, {
|
|
196
|
+
honourGlobalExcludes: false,
|
|
197
|
+
});
|
|
198
|
+
const ignored = "ignored" in ignoreLookup ? ignoreLookup.ignored : new Set();
|
|
199
|
+
const ignoreReason = "unavailable" in ignoreLookup ? ignoreLookup.unavailable : undefined;
|
|
200
|
+
const isIgnored = (rel) => ignored.has(toPosix(rel));
|
|
201
|
+
const toCheck = fresh.filter((rel) => !isIgnored(rel));
|
|
202
|
+
const orphans = ownedOrphans.filter((rel) => !isIgnored(rel));
|
|
203
|
+
// BOTH halves. `ignoreCandidates` above tests fresh pages AND owned orphans, so an
|
|
204
|
+
// ignored orphan is dropped from the check exactly like an ignored fresh page — but
|
|
205
|
+
// counting only the fresh half reported a number SMALLER than the work actually
|
|
206
|
+
// skipped. That is the `verify --templates` denominator mistake in miniature (a line
|
|
207
|
+
// describing work the command did not do), which is the very thing the orphan loop
|
|
208
|
+
// below is written to avoid; the two must be consistent about the same set.
|
|
209
|
+
const ignoredCount = fresh.length - toCheck.length + (ownedOrphans.length - orphans.length);
|
|
210
|
+
// A gate asked to check pages that could check NONE must not answer "no drift".
|
|
211
|
+
if (toCheck.length === 0 && orphans.length === 0) {
|
|
212
|
+
return {
|
|
213
|
+
clean: false,
|
|
214
|
+
driftedFiles: [],
|
|
215
|
+
lines: [],
|
|
216
|
+
checked: 0,
|
|
217
|
+
ignored: ignoredCount,
|
|
218
|
+
ignoreReason,
|
|
219
|
+
error: `verify --docs: a fresh 'meta docs' produced ${fresh.length} page(s) and every ` +
|
|
220
|
+
`one of them is git-ignored, so there is nothing to compare. Commit the pages ` +
|
|
221
|
+
`you want checked, or run without --docs.`,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
156
224
|
const driftedFiles = [];
|
|
157
225
|
const lines = [];
|
|
158
|
-
for (const rel of
|
|
226
|
+
for (const rel of toCheck) {
|
|
159
227
|
const committedPath = join(docsDir, rel);
|
|
160
228
|
if (!existsSync(committedPath)) {
|
|
161
229
|
driftedFiles.push(rel);
|
|
162
|
-
|
|
230
|
+
// When the rules could not be consulted the last clause would be a claim we
|
|
231
|
+
// have not checked, so it is dropped rather than asserted.
|
|
232
|
+
lines.push(ignoreReason === undefined
|
|
233
|
+
? `+ ${rel} (a fresh 'meta docs' emits it; not committed, not git-ignored)`
|
|
234
|
+
: `+ ${rel} (a fresh 'meta docs' emits it; not committed)`);
|
|
163
235
|
continue;
|
|
164
236
|
}
|
|
165
237
|
const a = readFileSync(committedPath, "utf8");
|
|
@@ -169,14 +241,9 @@ export async function computeDocsDrift(args) {
|
|
|
169
241
|
lines.push(`~ ${rel} (committed content differs from a fresh 'meta docs')`);
|
|
170
242
|
}
|
|
171
243
|
}
|
|
172
|
-
//
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
// and a green run reported different denominators for the same project.
|
|
176
|
-
const freshSet = new Set(fresh);
|
|
177
|
-
const orphans = listFiles(docsDir)
|
|
178
|
-
.filter((rel) => !freshSet.has(rel) && isOurs(docsDir, rel))
|
|
179
|
-
.sort();
|
|
244
|
+
// Counted into `checked` as well as `driftedFiles` so the failing line and the
|
|
245
|
+
// passing line keep dividing by the same set — the `verify --templates` mistake,
|
|
246
|
+
// where a red run and a green run reported different denominators for one project.
|
|
180
247
|
for (const rel of orphans) {
|
|
181
248
|
driftedFiles.push(rel);
|
|
182
249
|
lines.push(`- ${rel} (committed; a fresh 'meta docs' no longer emits it)`);
|
|
@@ -185,7 +252,9 @@ export async function computeDocsDrift(args) {
|
|
|
185
252
|
clean: driftedFiles.length === 0,
|
|
186
253
|
driftedFiles: driftedFiles.sort(),
|
|
187
254
|
lines,
|
|
188
|
-
checked:
|
|
255
|
+
checked: toCheck.length + orphans.length,
|
|
256
|
+
ignored: ignoredCount,
|
|
257
|
+
ignoreReason,
|
|
189
258
|
};
|
|
190
259
|
}
|
|
191
260
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs-drift.js","sourceRoot":"","sources":["../../../src/lib/docs-drift.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,EAAE;AACF,mFAAmF;AACnF,wFAAwF;AACxF,2FAA2F;AAC3F,uFAAuF;AACvF,mEAAmE;AACnE,EAAE;AACF,0FAA0F;AAC1F,4FAA4F;AAC5F,wEAAwE;AACxE,EAAE;AACF,2FAA2F;AAC3F,YAAY;AACZ,EAAE;AACF,4FAA4F;AAC5F,wFAAwF;AACxF,+EAA+E;AAC/E,uFAAuF;AACvF,yCAAyC;AACzC,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"docs-drift.js","sourceRoot":"","sources":["../../../src/lib/docs-drift.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,EAAE;AACF,mFAAmF;AACnF,wFAAwF;AACxF,2FAA2F;AAC3F,uFAAuF;AACvF,mEAAmE;AACnE,EAAE;AACF,0FAA0F;AAC1F,4FAA4F;AAC5F,wEAAwE;AACxE,EAAE;AACF,2FAA2F;AAC3F,YAAY;AACZ,EAAE;AACF,4FAA4F;AAC5F,wFAAwF;AACxF,+EAA+E;AAC/E,uFAAuF;AACvF,yCAAyC;AACzC,EAAE;AACF,uFAAuF;AACvF,iFAAiF;AACjF,sFAAsF;AACtF,wFAAwF;AACxF,oFAAoF;AACpF,0FAA0F;AAC1F,qFAAqF;AACrF,yFAAyF;AACzF,wFAAwF;AACxF,0FAA0F;AAC1F,kFAAkF;AAClF,gEAAgE;AAChE,EAAE;AACF,0FAA0F;AAC1F,yFAAyF;AACzF,wFAAwF;AACxF,2FAA2F;AAC3F,0FAA0F;AAC1F,4FAA4F;AAC5F,EAAE;A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;QACjF,mFAAmF;QACnF,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvB,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,sDAAsD,CAAC,CAAC;QAC7E,CAAC;QACD,OAAO;YACL,KAAK,EAAE,YAAY,CAAC,MAAM,KAAK,CAAC;YAChC,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE;YACjC,KAAK;YACL,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM;YACxC,OAAO,EAAE,YAAY;YACrB,YAAY;SACb,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** Ignored paths, or the reason the question could not be asked. */
|
|
2
|
+
export type GitIgnoreResult = {
|
|
3
|
+
readonly ignored: ReadonlySet<string>;
|
|
4
|
+
} | {
|
|
5
|
+
readonly unavailable: string;
|
|
6
|
+
};
|
|
7
|
+
export interface GitIgnoreOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Whether a per-user ignore file (`core.excludesFile`) may contribute to the
|
|
10
|
+
* verdict.
|
|
11
|
+
*
|
|
12
|
+
* `false` for anything whose answer must be a property of the REPOSITORY — a gate
|
|
13
|
+
* that passes on the author's machine and fails in CI because of a personal ignore
|
|
14
|
+
* file is worse than no gate. Implemented by pointing `core.excludesFile` at a path
|
|
15
|
+
* that does not exist, which is the only way to neutralise it.
|
|
16
|
+
*
|
|
17
|
+
* `true` where the question is genuinely about this machine — "will this file reach
|
|
18
|
+
* anyone else?" is answered by every rule that applies here, personal ones included.
|
|
19
|
+
*
|
|
20
|
+
* Note `.git/info/exclude` is per-clone and CANNOT be neutralised; it is reported
|
|
21
|
+
* like any other rule, and the caller's count line is what exposes it.
|
|
22
|
+
*/
|
|
23
|
+
readonly honourGlobalExcludes: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Ask git which of `rels` are ignored, relative to `dir`.
|
|
27
|
+
*
|
|
28
|
+
* Returns `unavailable` — never throws, never guesses — when git is not on PATH or
|
|
29
|
+
* `dir` is not inside a repository. A caller must decide what that means for it;
|
|
30
|
+
* silently treating "cannot say" as "nothing is ignored" is a fallback that lies, and
|
|
31
|
+
* the callers here say so out loud instead.
|
|
32
|
+
*/
|
|
33
|
+
export declare function gitIgnored(dir: string, rels: readonly string[], opts: GitIgnoreOptions): GitIgnoreResult;
|
|
34
|
+
/**
|
|
35
|
+
* Single-path convenience: true / false / undefined when git cannot say.
|
|
36
|
+
*
|
|
37
|
+
* `honourGlobalExcludes` is the caller's decision — see the option's doc.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isGitIgnored(dir: string, rel: string, opts: GitIgnoreOptions): boolean | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* WHICH rule ignores `rel` — the `.gitignore` file, its line, and the pattern.
|
|
42
|
+
*
|
|
43
|
+
* Advisories that tell an adopter to fix an ignore rule have to name the rule that is
|
|
44
|
+
* actually in force, not a conventional location. The exclusion can live in ANY
|
|
45
|
+
* `.gitignore` up the tree, in `.git/info/exclude`, or in a per-user excludes file, and an
|
|
46
|
+
* advisory that assumes one of them sends the reader to edit a file that does not hold the
|
|
47
|
+
* rule — after which the same advisory prints again, unchanged. `git check-ignore -v`
|
|
48
|
+
* answers it exactly, so nothing has to be assumed.
|
|
49
|
+
*
|
|
50
|
+
* `undefined` when git cannot say or nothing matches. The verdict itself still comes from
|
|
51
|
+
* `isGitIgnored`; this is only for the message, so a failure here degrades the wording
|
|
52
|
+
* rather than the check.
|
|
53
|
+
*/
|
|
54
|
+
export declare function gitIgnoreSource(dir: string, rel: string, opts: GitIgnoreOptions): {
|
|
55
|
+
file: string;
|
|
56
|
+
line: string;
|
|
57
|
+
pattern: string;
|
|
58
|
+
} | undefined;
|
|
59
|
+
//# sourceMappingURL=git-ignore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-ignore.d.ts","sourceRoot":"","sources":["../../../src/lib/git-ignore.ts"],"names":[],"mappings":"AAoBA,oEAAoE;AACpE,MAAM,MAAM,eAAe,GACvB;IAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAE,GACzC;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAErC,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;CACxC;AAKD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,IAAI,EAAE,gBAAgB,GACrB,eAAe,CAwCjB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,gBAAgB,GACrB,OAAO,GAAG,SAAS,CAIrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,gBAAgB,GACrB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAwB7D"}
|