@driftsys/markspec 0.8.0 → 0.10.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/esm/compiler/mod.d.ts +7 -0
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +17 -3
- package/esm/compiler/schema.d.ts +8 -1
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +8 -1
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +25 -0
- package/esm/discovery/gitignore.d.ts +40 -0
- package/esm/discovery/gitignore.d.ts.map +1 -0
- package/esm/discovery/gitignore.js +145 -0
- package/esm/discovery/mod.d.ts +54 -0
- package/esm/discovery/mod.d.ts.map +1 -0
- package/esm/discovery/mod.js +122 -0
- package/esm/formatter/dprint.d.ts +62 -0
- package/esm/formatter/dprint.d.ts.map +1 -0
- package/esm/formatter/dprint.js +83 -0
- package/esm/formatter/md_equiv.d.ts +24 -0
- package/esm/formatter/md_equiv.d.ts.map +1 -0
- package/esm/formatter/md_equiv.js +81 -0
- package/esm/formatter/mod.d.ts +25 -0
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +106 -6
- package/esm/formatter/prose.d.ts +48 -0
- package/esm/formatter/prose.d.ts.map +1 -0
- package/esm/formatter/prose.js +85 -0
- package/esm/mod.d.ts +10 -4
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +7 -2
- package/esm/model/mod.d.ts +25 -1
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +1 -0
- package/esm/model/profile.d.ts +34 -0
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +28 -15
- package/esm/profile/chain.js +1 -0
- package/esm/profile/delivered.d.ts +27 -0
- package/esm/profile/delivered.d.ts.map +1 -0
- package/esm/profile/delivered.js +60 -0
- package/esm/profile/manifest.d.ts +1 -0
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +107 -0
- package/esm/profile/merge.d.ts.map +1 -1
- package/esm/profile/merge.js +21 -0
- package/esm/refs/mod.d.ts.map +1 -1
- package/esm/refs/mod.js +22 -0
- package/esm/reporter/mod.js +17 -4
- package/esm/self_upgrade/target.d.ts +3 -3
- package/esm/self_upgrade/target.d.ts.map +1 -1
- package/esm/self_upgrade/target.js +4 -2
- package/esm/validator/corpus.d.ts +25 -0
- package/esm/validator/corpus.d.ts.map +1 -0
- package/esm/validator/corpus.js +138 -0
- package/esm/validator/listing.d.ts.map +1 -1
- package/esm/validator/listing.js +4 -1
- package/esm/validator/mod.d.ts +2 -0
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +1 -0
- package/package.json +3 -1
- package/script/compiler/mod.d.ts +7 -0
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +16 -2
- package/script/compiler/schema.d.ts +8 -1
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +8 -1
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +25 -0
- package/script/discovery/gitignore.d.ts +40 -0
- package/script/discovery/gitignore.d.ts.map +1 -0
- package/script/discovery/gitignore.js +149 -0
- package/script/discovery/mod.d.ts +54 -0
- package/script/discovery/mod.d.ts.map +1 -0
- package/script/discovery/mod.js +128 -0
- package/script/formatter/dprint.d.ts +62 -0
- package/script/formatter/dprint.d.ts.map +1 -0
- package/script/formatter/dprint.js +120 -0
- package/script/formatter/md_equiv.d.ts +24 -0
- package/script/formatter/md_equiv.d.ts.map +1 -0
- package/script/formatter/md_equiv.js +87 -0
- package/script/formatter/mod.d.ts +25 -0
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +106 -5
- package/script/formatter/prose.d.ts +48 -0
- package/script/formatter/prose.d.ts.map +1 -0
- package/script/formatter/prose.js +88 -0
- package/script/mod.d.ts +10 -4
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +22 -3
- package/script/model/mod.d.ts +25 -1
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +1 -0
- package/script/model/profile.d.ts +34 -0
- package/script/model/profile.d.ts.map +1 -1
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +27 -14
- package/script/profile/chain.js +1 -0
- package/script/profile/delivered.d.ts +27 -0
- package/script/profile/delivered.d.ts.map +1 -0
- package/script/profile/delivered.js +65 -0
- package/script/profile/manifest.d.ts +1 -0
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +108 -1
- package/script/profile/merge.d.ts.map +1 -1
- package/script/profile/merge.js +21 -0
- package/script/refs/mod.d.ts.map +1 -1
- package/script/refs/mod.js +22 -0
- package/script/reporter/mod.js +17 -4
- package/script/self_upgrade/target.d.ts +3 -3
- package/script/self_upgrade/target.d.ts.map +1 -1
- package/script/self_upgrade/target.js +4 -2
- package/script/validator/corpus.d.ts +25 -0
- package/script/validator/corpus.d.ts.map +1 -0
- package/script/validator/corpus.js +142 -0
- package/script/validator/listing.d.ts.map +1 -1
- package/script/validator/listing.js +4 -1
- package/script/validator/mod.d.ts +2 -0
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +4 -1
package/esm/refs/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/refs/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAO7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/refs/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAO7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAGnD,CAAC;AAEH,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,QAAQ,CAajE;AAcD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,SAAS,QAAQ,EAAE,GAC1B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAgHtC"}
|
package/esm/refs/mod.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* it (WASM-migration purity guard, AGENTS.md).
|
|
13
13
|
*/
|
|
14
14
|
import { CORE_RELATIONS, DISPLAY_ID_RE, LOCK_EXTRA_INVERSE_KEYS, ULID_RE, } from "../model/mod.js";
|
|
15
|
+
import { FENCE_RE } from "../util/fence.js";
|
|
15
16
|
/**
|
|
16
17
|
* Trace-attribute keys whose values are canonicalised/healed: the core
|
|
17
18
|
* relations plus `Verified-by`. Derived from {@linkcode CORE_RELATIONS} so new
|
|
@@ -84,12 +85,25 @@ export function canonicalizeRefs(content, entries, index, ledger) {
|
|
|
84
85
|
};
|
|
85
86
|
const lines = content.split("\n");
|
|
86
87
|
let changed = false;
|
|
88
|
+
// Track fenced-code regions so illustrative trailers inside ``` / ~~~
|
|
89
|
+
// blocks (e.g. `Realizes: 01HGW...` in a ```markdown example) are never
|
|
90
|
+
// "healed" against the real ref index — the same verbatim-region rule
|
|
91
|
+
// every other fmt pass honors (§5.1; cf. `collapseBlankLines`). Without
|
|
92
|
+
// this, `markspec fmt` rewrites example IDs in spec/ADR docs on every run
|
|
93
|
+
// (#668). The parser/validator already treat fenced content as inert.
|
|
94
|
+
let inFence = false;
|
|
87
95
|
for (let i = 0; i < lines.length; i++) {
|
|
88
96
|
// Strip a trailing CR before matching so CRLF files are handled (the
|
|
89
97
|
// trailer regex ends in `$`, which `\r` would block) and re-append it on
|
|
90
98
|
// rewrite so line endings stay byte-for-byte lossless.
|
|
91
99
|
const cr = lines[i].endsWith("\r");
|
|
92
100
|
const bare = cr ? lines[i].slice(0, -1) : lines[i];
|
|
101
|
+
if (FENCE_RE.test(bare)) {
|
|
102
|
+
inFence = !inFence;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (inFence)
|
|
106
|
+
continue;
|
|
93
107
|
const m = TRACE_TRAILER_RE.exec(bare);
|
|
94
108
|
if (!m)
|
|
95
109
|
continue;
|
|
@@ -116,6 +130,14 @@ export function canonicalizeRefs(content, entries, index, ledger) {
|
|
|
116
130
|
j++;
|
|
117
131
|
const crj = lines[j].endsWith("\r");
|
|
118
132
|
const barej = crj ? lines[j].slice(0, -1) : lines[j];
|
|
133
|
+
// A fence marker is never continuation text. An indented one (e.g.
|
|
134
|
+
// ` ```md`) would otherwise match CONTINUATION_LINE_RE and be
|
|
135
|
+
// swallowed here without toggling `inFence`, desyncing fence tracking
|
|
136
|
+
// for the rest of the file. Back out and let the outer loop toggle it.
|
|
137
|
+
if (FENCE_RE.test(barej)) {
|
|
138
|
+
j--;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
119
141
|
const cm = CONTINUATION_LINE_RE.exec(barej);
|
|
120
142
|
if (!cm) {
|
|
121
143
|
j--; // not a continuation line — leave it for the outer loop
|
package/esm/reporter/mod.js
CHANGED
|
@@ -42,6 +42,17 @@ function filterEntries(result, scope, label) {
|
|
|
42
42
|
}
|
|
43
43
|
return entries;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Render an entry's provenance cell (ADR-030): `<profileId>@<profileVersion>`
|
|
47
|
+
* for an entry injected from a profile-delivered corpus, `"project"` for a
|
|
48
|
+
* project-authored entry. Shared by the traceability matrix builder so CSV,
|
|
49
|
+
* Markdown, and JSON rows all agree on the same value.
|
|
50
|
+
*/
|
|
51
|
+
function originCell(entry) {
|
|
52
|
+
return entry.origin
|
|
53
|
+
? `${entry.origin.profileId}@${entry.origin.profileVersion}`
|
|
54
|
+
: "project";
|
|
55
|
+
}
|
|
45
56
|
function buildTraceRows(result, entries) {
|
|
46
57
|
return entries.map((entry) => {
|
|
47
58
|
const fwd = result.forward.get(entry.displayId) ?? [];
|
|
@@ -50,6 +61,7 @@ function buildTraceRows(result, entries) {
|
|
|
50
61
|
id: entry.displayId,
|
|
51
62
|
title: entry.title,
|
|
52
63
|
entryType: entry.type ?? "",
|
|
64
|
+
origin: originCell(entry),
|
|
53
65
|
satisfies: fwd
|
|
54
66
|
.filter((l) => l.kind === "satisfies")
|
|
55
67
|
.map((l) => l.to)
|
|
@@ -67,20 +79,21 @@ function formatTraceability(result, entries, format) {
|
|
|
67
79
|
return JSON.stringify(rows, null, 2);
|
|
68
80
|
}
|
|
69
81
|
if (format === "csv") {
|
|
70
|
-
const header = "ID,Title,Type,Satisfies,Satisfied-by";
|
|
82
|
+
const header = "ID,Title,Type,Origin,Satisfies,Satisfied-by";
|
|
71
83
|
const lines = rows.map((r) => [
|
|
72
84
|
r.id,
|
|
73
85
|
csvEscape(r.title),
|
|
74
86
|
r.entryType,
|
|
87
|
+
csvEscape(r.origin),
|
|
75
88
|
csvEscape(r.satisfies),
|
|
76
89
|
csvEscape(r.satisfiedBy),
|
|
77
90
|
].join(","));
|
|
78
91
|
return [header, ...lines].join("\n");
|
|
79
92
|
}
|
|
80
93
|
// Markdown table
|
|
81
|
-
const header = "| ID | Title | Type | Satisfies | Satisfied-by |";
|
|
82
|
-
const sep = "| -- | ----- | ---- | --------- | ------------ |";
|
|
83
|
-
const lines = rows.map((r) => `| ${r.id} | ${r.title} | ${r.entryType} | ${r.satisfies || "\u2014"} | ${r.satisfiedBy || "\u2014"} |`);
|
|
94
|
+
const header = "| ID | Title | Type | Origin | Satisfies | Satisfied-by |";
|
|
95
|
+
const sep = "| -- | ----- | ---- | ------ | --------- | ------------ |";
|
|
96
|
+
const lines = rows.map((r) => `| ${r.id} | ${r.title} | ${r.entryType} | ${r.origin} | ${r.satisfies || "\u2014"} | ${r.satisfiedBy || "\u2014"} |`);
|
|
84
97
|
return [header, sep, ...lines].join("\n");
|
|
85
98
|
}
|
|
86
99
|
function computeCoverage(result, entries) {
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Map (os, arch) → the GitHub release target string used in tarball
|
|
5
5
|
* names. Targets match those produced by the Release workflow:
|
|
6
|
-
* x86_64-unknown-linux-gnu,
|
|
7
|
-
* aarch64-apple-darwin, x86_64-pc-windows-msvc.
|
|
6
|
+
* x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu,
|
|
7
|
+
* x86_64-apple-darwin, aarch64-apple-darwin, x86_64-pc-windows-msvc.
|
|
8
8
|
*
|
|
9
9
|
* Pure functions — no I/O, no Deno.* APIs. The CLI passes
|
|
10
10
|
* `Deno.build.os` / `Deno.build.arch` strings to platformFromBuild;
|
|
@@ -17,7 +17,7 @@ export interface Platform {
|
|
|
17
17
|
readonly os: Os;
|
|
18
18
|
readonly arch: Arch;
|
|
19
19
|
}
|
|
20
|
-
export type Target = "x86_64-unknown-linux-gnu" | "x86_64-apple-darwin" | "aarch64-apple-darwin" | "x86_64-pc-windows-msvc";
|
|
20
|
+
export type Target = "x86_64-unknown-linux-gnu" | "aarch64-unknown-linux-gnu" | "x86_64-apple-darwin" | "aarch64-apple-darwin" | "x86_64-pc-windows-msvc";
|
|
21
21
|
/** Return the release target for a platform, or undefined if not shipped. */
|
|
22
22
|
export declare function detectTarget(platform: Platform): Target | undefined;
|
|
23
23
|
/** Parse Deno.build.{os,arch} strings into a typed Platform, or undefined. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../src/self_upgrade/target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,EAAE,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAChD,MAAM,MAAM,IAAI,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExC,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IAChB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB;AAED,MAAM,MAAM,MAAM,GACd,0BAA0B,GAC1B,qBAAqB,GACrB,sBAAsB,GACtB,wBAAwB,CAAC;AAE7B,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../src/self_upgrade/target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,EAAE,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAChD,MAAM,MAAM,IAAI,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExC,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IAChB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB;AAED,MAAM,MAAM,MAAM,GACd,0BAA0B,GAC1B,2BAA2B,GAC3B,qBAAqB,GACrB,sBAAsB,GACtB,wBAAwB,CAAC;AAE7B,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAQnE;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,GACX,QAAQ,GAAG,SAAS,CAKtB"}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Map (os, arch) → the GitHub release target string used in tarball
|
|
5
5
|
* names. Targets match those produced by the Release workflow:
|
|
6
|
-
* x86_64-unknown-linux-gnu,
|
|
7
|
-
* aarch64-apple-darwin, x86_64-pc-windows-msvc.
|
|
6
|
+
* x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu,
|
|
7
|
+
* x86_64-apple-darwin, aarch64-apple-darwin, x86_64-pc-windows-msvc.
|
|
8
8
|
*
|
|
9
9
|
* Pure functions — no I/O, no Deno.* APIs. The CLI passes
|
|
10
10
|
* `Deno.build.os` / `Deno.build.arch` strings to platformFromBuild;
|
|
@@ -16,6 +16,8 @@ export function detectTarget(platform) {
|
|
|
16
16
|
const { os, arch } = platform;
|
|
17
17
|
if (os === "linux" && arch === "x86_64")
|
|
18
18
|
return "x86_64-unknown-linux-gnu";
|
|
19
|
+
if (os === "linux" && arch === "aarch64")
|
|
20
|
+
return "aarch64-unknown-linux-gnu";
|
|
19
21
|
if (os === "darwin" && arch === "x86_64")
|
|
20
22
|
return "x86_64-apple-darwin";
|
|
21
23
|
if (os === "darwin" && arch === "aarch64")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/corpus
|
|
3
|
+
*
|
|
4
|
+
* Corpus-aware diagnostic post-pass (ADR-030). Two responsibilities:
|
|
5
|
+
*
|
|
6
|
+
* 1. {@linkcode detectCorpusCollisions} — a project entry re-declaring a
|
|
7
|
+
* display ID (or Id) owned by a delivered corpus entry is MSL-R014, a
|
|
8
|
+
* distinct code from MSL-R006 because the fix is different: rename the
|
|
9
|
+
* project entry; the corpus entry is not yours to change.
|
|
10
|
+
* 2. {@linkcode attributeCorpusDiagnostics} — consumer builds must not go
|
|
11
|
+
* red from upstream bugs they cannot fix: findings located inside a
|
|
12
|
+
* corpus file are downgraded to warnings and attributed to the
|
|
13
|
+
* delivering profile; generic duplicate codes are suppressed for
|
|
14
|
+
* collided tokens (MSL-R014 replaces them).
|
|
15
|
+
*/
|
|
16
|
+
import type { Diagnostic, Entry } from "../model/mod.js";
|
|
17
|
+
/** Result of {@linkcode detectCorpusCollisions}. */
|
|
18
|
+
export interface CorpusCollisionResult {
|
|
19
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
20
|
+
/** Display-ID / Id tokens involved in a project↔corpus collision. */
|
|
21
|
+
readonly collidedTokens: ReadonlySet<string>;
|
|
22
|
+
}
|
|
23
|
+
export declare function detectCorpusCollisions(allEntries: readonly Entry[]): CorpusCollisionResult;
|
|
24
|
+
export declare function attributeCorpusDiagnostics(diagnostics: readonly Diagnostic[], allEntries: readonly Entry[], collidedTokens: ReadonlySet<string>): Diagnostic[];
|
|
25
|
+
//# sourceMappingURL=corpus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../../src/validator/corpus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAUzD,oDAAoD;AACpD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,qEAAqE;IACrE,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC9C;AAED,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,SAAS,KAAK,EAAE,GAC3B,qBAAqB,CAwFvB;AAED,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,UAAU,EAAE,SAAS,KAAK,EAAE,EAC5B,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,GAClC,UAAU,EAAE,CAiCd"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/corpus
|
|
3
|
+
*
|
|
4
|
+
* Corpus-aware diagnostic post-pass (ADR-030). Two responsibilities:
|
|
5
|
+
*
|
|
6
|
+
* 1. {@linkcode detectCorpusCollisions} — a project entry re-declaring a
|
|
7
|
+
* display ID (or Id) owned by a delivered corpus entry is MSL-R014, a
|
|
8
|
+
* distinct code from MSL-R006 because the fix is different: rename the
|
|
9
|
+
* project entry; the corpus entry is not yours to change.
|
|
10
|
+
* 2. {@linkcode attributeCorpusDiagnostics} — consumer builds must not go
|
|
11
|
+
* red from upstream bugs they cannot fix: findings located inside a
|
|
12
|
+
* corpus file are downgraded to warnings and attributed to the
|
|
13
|
+
* delivering profile; generic duplicate codes are suppressed for
|
|
14
|
+
* collided tokens (MSL-R014 replaces them).
|
|
15
|
+
*/
|
|
16
|
+
/** Generic duplicate detectors superseded by MSL-R014 for corpus collisions. */
|
|
17
|
+
const GENERIC_DUP_CODES = new Set([
|
|
18
|
+
"MSL-R005",
|
|
19
|
+
"MSL-R006",
|
|
20
|
+
"MSL-I007",
|
|
21
|
+
"MSL-I008",
|
|
22
|
+
]);
|
|
23
|
+
export function detectCorpusCollisions(allEntries) {
|
|
24
|
+
const corpusByDisplayId = new Map();
|
|
25
|
+
const corpusById = new Map();
|
|
26
|
+
for (const e of allEntries) {
|
|
27
|
+
if (!e.origin)
|
|
28
|
+
continue;
|
|
29
|
+
if (!corpusByDisplayId.has(e.displayId)) {
|
|
30
|
+
corpusByDisplayId.set(e.displayId, e);
|
|
31
|
+
}
|
|
32
|
+
if (e.id && !corpusById.has(e.id))
|
|
33
|
+
corpusById.set(e.id, e);
|
|
34
|
+
}
|
|
35
|
+
if (corpusByDisplayId.size === 0 && corpusById.size === 0) {
|
|
36
|
+
return { diagnostics: [], collidedTokens: new Set() };
|
|
37
|
+
}
|
|
38
|
+
const diagnostics = [];
|
|
39
|
+
const collided = new Set();
|
|
40
|
+
for (const e of allEntries) {
|
|
41
|
+
if (!e.origin) {
|
|
42
|
+
const displayOwner = corpusByDisplayId.get(e.displayId);
|
|
43
|
+
if (displayOwner) {
|
|
44
|
+
collided.add(e.displayId);
|
|
45
|
+
diagnostics.push({
|
|
46
|
+
code: "MSL-R014",
|
|
47
|
+
severity: "error",
|
|
48
|
+
message: `display ID '${e.displayId}' is already delivered by ` +
|
|
49
|
+
`${displayOwner.origin.profileId}@` +
|
|
50
|
+
`${displayOwner.origin.profileVersion}; rename this entry — ` +
|
|
51
|
+
`delivered corpus entries are read-only`,
|
|
52
|
+
location: e.location,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (e.id) {
|
|
56
|
+
const idOwner = corpusById.get(e.id);
|
|
57
|
+
if (idOwner) {
|
|
58
|
+
collided.add(e.id);
|
|
59
|
+
diagnostics.push({
|
|
60
|
+
code: "MSL-R014",
|
|
61
|
+
severity: "error",
|
|
62
|
+
message: `Id '${e.id}' is already delivered by ` +
|
|
63
|
+
`${idOwner.origin.profileId}@` +
|
|
64
|
+
`${idOwner.origin.profileVersion}; rename this entry — ` +
|
|
65
|
+
`delivered corpus entries are read-only`,
|
|
66
|
+
location: e.location,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
// Corpus↔corpus inter-tier collision: a later delivered entry from a
|
|
73
|
+
// DIFFERENT profile claims a display ID (or Id) the first-registered
|
|
74
|
+
// profile already owns. Same-profile duplicates are excluded — that's
|
|
75
|
+
// the delivering profile's own authoring bug, not a read-only-boundary
|
|
76
|
+
// violation, and stays on the generic duplicate codes.
|
|
77
|
+
const displayOwner = corpusByDisplayId.get(e.displayId);
|
|
78
|
+
if (displayOwner !== e && displayOwner &&
|
|
79
|
+
displayOwner.origin.profileId !== e.origin.profileId) {
|
|
80
|
+
collided.add(e.displayId);
|
|
81
|
+
diagnostics.push({
|
|
82
|
+
code: "MSL-R014",
|
|
83
|
+
severity: "error",
|
|
84
|
+
message: `display ID '${e.displayId}' is already delivered by ` +
|
|
85
|
+
`${displayOwner.origin.profileId}@` +
|
|
86
|
+
`${displayOwner.origin.profileVersion}; delivered corpus ` +
|
|
87
|
+
`entries are read-only`,
|
|
88
|
+
location: e.location,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (e.id) {
|
|
92
|
+
const idOwner = corpusById.get(e.id);
|
|
93
|
+
if (idOwner !== e && idOwner &&
|
|
94
|
+
idOwner.origin.profileId !== e.origin.profileId) {
|
|
95
|
+
collided.add(e.id);
|
|
96
|
+
diagnostics.push({
|
|
97
|
+
code: "MSL-R014",
|
|
98
|
+
severity: "error",
|
|
99
|
+
message: `Id '${e.id}' is already delivered by ` +
|
|
100
|
+
`${idOwner.origin.profileId}@` +
|
|
101
|
+
`${idOwner.origin.profileVersion}; delivered corpus entries ` +
|
|
102
|
+
`are read-only`,
|
|
103
|
+
location: e.location,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return { diagnostics, collidedTokens: collided };
|
|
109
|
+
}
|
|
110
|
+
export function attributeCorpusDiagnostics(diagnostics, allEntries, collidedTokens) {
|
|
111
|
+
const corpusFiles = new Map();
|
|
112
|
+
for (const e of allEntries) {
|
|
113
|
+
if (e.origin) {
|
|
114
|
+
corpusFiles.set(e.location.file, `${e.origin.profileId}@${e.origin.profileVersion}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const out = [];
|
|
118
|
+
for (const d of diagnostics) {
|
|
119
|
+
// Suppress the generic duplicate codes for corpus collisions; the
|
|
120
|
+
// validator embeds the offending token in single quotes, which is what
|
|
121
|
+
// this containment check keys on.
|
|
122
|
+
if (GENERIC_DUP_CODES.has(d.code) &&
|
|
123
|
+
[...collidedTokens].some((t) => d.message.includes(`'${t}'`))) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const label = d.location ? corpusFiles.get(d.location.file) : undefined;
|
|
127
|
+
if (label !== undefined) {
|
|
128
|
+
out.push({
|
|
129
|
+
...d,
|
|
130
|
+
severity: d.severity === "error" ? "warning" : d.severity,
|
|
131
|
+
message: `delivered by ${label}: ${d.message}`,
|
|
132
|
+
});
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
out.push(d);
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listing.d.ts","sourceRoot":"","sources":["../../src/validator/listing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAYpE,oDAAoD;AACpD,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,UAAU,GAAG,YAAY,CAAC;AAEnE,uEAAuE;AACvE,MAAM,WAAW,kBAAkB;IACjC,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC,0DAA0D;IAC1D,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;CAC3C;
|
|
1
|
+
{"version":3,"file":"listing.d.ts","sourceRoot":"","sources":["../../src/validator/listing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAYpE,oDAAoD;AACpD,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,UAAU,GAAG,YAAY,CAAC;AAEnE,uEAAuE;AACvE,MAAM,WAAW,kBAAkB;IACjC,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC,0DAA0D;IAC1D,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;CAC3C;AA8SD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,GACtC,SAAS,UAAU,EAAE,CAMvB"}
|
package/esm/validator/listing.js
CHANGED
|
@@ -42,7 +42,10 @@ const UNIT_FAMILY = new Set([
|
|
|
42
42
|
// ---------------------------------------------------------------------------
|
|
43
43
|
/** Listing kind implied by a file's basename, or null if not a listing file. */
|
|
44
44
|
function filenameKind(file) {
|
|
45
|
-
const
|
|
45
|
+
const name = basename(file).toLowerCase();
|
|
46
|
+
if (!name.endsWith(".md"))
|
|
47
|
+
return null;
|
|
48
|
+
const base = name.replace(/\.md$/, "");
|
|
46
49
|
if (base === "references")
|
|
47
50
|
return "references";
|
|
48
51
|
if (base === "glossary")
|
package/esm/validator/mod.d.ts
CHANGED
|
@@ -43,4 +43,6 @@ export { validateValue } from "./value_types.js";
|
|
|
43
43
|
export type { ValueValidator } from "./value_types.js";
|
|
44
44
|
export { normalizeListValues } from "./normalize.js";
|
|
45
45
|
export { effectiveTraceRules, matchesAnyTarget, validateTraceabilityForEntry, } from "./traceability.js";
|
|
46
|
+
export { attributeCorpusDiagnostics, detectCorpusCollisions, } from "./corpus.js";
|
|
47
|
+
export type { CorpusCollisionResult } from "./corpus.js";
|
|
46
48
|
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/validator/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAqCpE,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,2CAA2C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AkB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
|
package/esm/validator/mod.js
CHANGED
|
@@ -474,3 +474,4 @@ export { effectiveScope, validateAttributesForEntry } from "./attributes.js";
|
|
|
474
474
|
export { validateValue } from "./value_types.js";
|
|
475
475
|
export { normalizeListValues } from "./normalize.js";
|
|
476
476
|
export { effectiveTraceRules, matchesAnyTarget, validateTraceabilityForEntry, } from "./traceability.js";
|
|
477
|
+
export { attributeCorpusDiagnostics, detectCorpusCollisions, } from "./corpus.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driftsys/markspec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Markdown flavor and toolchain for traceable industrial documentation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown",
|
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"scripts": {},
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"@dprint/formatter": "0.5.1",
|
|
33
|
+
"@dprint/markdown": "0.20.0",
|
|
32
34
|
"@types/mdast": "^4",
|
|
33
35
|
"remark-gfm": "^4",
|
|
34
36
|
"remark-parse": "^11",
|
package/script/compiler/mod.d.ts
CHANGED
|
@@ -43,6 +43,13 @@ export interface CompileOptions {
|
|
|
43
43
|
* list is deduplicated and sorted for deterministic output.
|
|
44
44
|
*/
|
|
45
45
|
readonly withContributors?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Profile-delivered corpus entries (ADR-030), pre-loaded and
|
|
48
|
+
* origin-stamped by `loadDeliveredCorpus`. Injected AHEAD of project
|
|
49
|
+
* entries so first-entry-wins graph slots resolve to the corpus
|
|
50
|
+
* deterministically. Optional — absent means no corpus.
|
|
51
|
+
*/
|
|
52
|
+
readonly corpusEntries?: readonly Entry[];
|
|
46
53
|
}
|
|
47
54
|
/** Compiled project output with resolved traceability graph. */
|
|
48
55
|
export interface CompileResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/compiler/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,KAAK,EAEL,IAAI,EAEL,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/compiler/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,KAAK,EAEL,IAAI,EAEL,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAE,KAAK,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAOjE,uCAAuC;AACvC,MAAM,WAAW,cAAc;IAC7B,4FAA4F;IAC5F,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,qGAAqG;IACrG,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAClB,IAAI,EAAE,MAAM,KACT,OAAO,CAAC;QAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IACjD;;;;;;;;;OASG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CACjB,IAAI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GACvB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,YAAY,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC"}
|
package/script/compiler/mod.js
CHANGED
|
@@ -114,7 +114,7 @@ class Semaphore {
|
|
|
114
114
|
*/
|
|
115
115
|
async function compile(paths, options) {
|
|
116
116
|
const read = options.readFile;
|
|
117
|
-
const allEntries = [];
|
|
117
|
+
const allEntries = [...(options.corpusEntries ?? [])];
|
|
118
118
|
const parseDiagnostics = [];
|
|
119
119
|
const documents = new Map();
|
|
120
120
|
// Phase 1: Read and parse all files with bounded concurrency (16 slots).
|
|
@@ -242,11 +242,25 @@ async function compile(paths, options) {
|
|
|
242
242
|
// diagnostics are already included in validationDiagnostics, so we discard
|
|
243
243
|
// them to avoid duplicates in the output.
|
|
244
244
|
const { registry: typeRegistry } = (0, mod_js_4.validateTypl)([...entries.values()]);
|
|
245
|
-
|
|
245
|
+
let diagnostics = [
|
|
246
246
|
...parseDiagnostics,
|
|
247
247
|
...validationDiagnostics,
|
|
248
248
|
...linkTargetDiags,
|
|
249
249
|
];
|
|
250
|
+
// Phase 5: Corpus-aware diagnostic post-pass (ADR-030). A project entry
|
|
251
|
+
// that reuses a display ID or Id already delivered by a corpus is
|
|
252
|
+
// MSL-R014, not the generic MSL-R005/R006/I007/I008 duplicate codes —
|
|
253
|
+
// and findings located inside a corpus file are downgraded to
|
|
254
|
+
// attributed warnings so consumer builds don't go red over upstream
|
|
255
|
+
// bugs they cannot fix. No-op (and zero allocation beyond the spread
|
|
256
|
+
// above) when no corpus was injected.
|
|
257
|
+
if (options.corpusEntries && options.corpusEntries.length > 0) {
|
|
258
|
+
const collisions = (0, mod_js_3.detectCorpusCollisions)(allEntries);
|
|
259
|
+
diagnostics = [
|
|
260
|
+
...(0, mod_js_3.attributeCorpusDiagnostics)(diagnostics, allEntries, collisions.collidedTokens),
|
|
261
|
+
...collisions.diagnostics,
|
|
262
|
+
];
|
|
263
|
+
}
|
|
250
264
|
return {
|
|
251
265
|
entries,
|
|
252
266
|
links,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* interchange.
|
|
7
7
|
*/
|
|
8
8
|
import type { CompileResult } from "./mod.js";
|
|
9
|
-
import type { Diagnostic, Entry, Link } from "../model/mod.js";
|
|
9
|
+
import type { Diagnostic, Entry, EntryOrigin, Link } from "../model/mod.js";
|
|
10
10
|
import type { RegistryBinding, RegistryTypedef } from "../typl/mod.js";
|
|
11
11
|
/**
|
|
12
12
|
* JSON-serializable form of {@linkcode Entry}.
|
|
@@ -14,9 +14,16 @@ import type { RegistryBinding, RegistryTypedef } from "../typl/mod.js";
|
|
|
14
14
|
* Identical to `Entry` except `typedAttributes` is a plain
|
|
15
15
|
* `Record<string, readonly string[]>` instead of a `ReadonlyMap` — Maps are
|
|
16
16
|
* not JSON-serializable. All other fields are passed through unchanged.
|
|
17
|
+
*
|
|
18
|
+
* `origin` (ADR-030) is restated explicitly here — rather than relying on
|
|
19
|
+
* the `Omit<Entry, ...>` passthrough — so the field-presence contract is
|
|
20
|
+
* documented at the serialization boundary: present verbatim on entries
|
|
21
|
+
* injected from a profile-delivered corpus, absent (not `null`) on
|
|
22
|
+
* project-authored entries.
|
|
17
23
|
*/
|
|
18
24
|
export type SerializedEntry = Omit<Entry, "typedAttributes"> & {
|
|
19
25
|
readonly typedAttributes?: Record<string, readonly string[]>;
|
|
26
|
+
readonly origin?: EntryOrigin;
|
|
20
27
|
};
|
|
21
28
|
/**
|
|
22
29
|
* Serialized form of the {@linkcode TypeRegistry}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/compiler/schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iB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,CAAC;IAClD,+CAA+C;IAC/C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,sCAAsC;IACtC,QAAQ,CAAC,YAAY,EAAE,sBAAsB,CAAC;CAC/C;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,aAAa,GACpB,uBAAuB,CAazB;AAgBD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,CA4B5D"}
|
|
@@ -61,9 +61,16 @@ function serializeEntry(entry) {
|
|
|
61
61
|
const { sync: _sync, ...rest } = properties;
|
|
62
62
|
properties = Object.keys(rest).length > 0 ? rest : undefined;
|
|
63
63
|
}
|
|
64
|
+
// Pull `origin` (ADR-030) out of the spread so the key is entirely
|
|
65
|
+
// absent — not `origin: undefined` — on entries that did not come
|
|
66
|
+
// from a delivered corpus, matching the serialized-field-presence
|
|
67
|
+
// contract. Object rest destructuring drops the named key regardless
|
|
68
|
+
// of its value, unlike `...entry` alone.
|
|
69
|
+
const { origin, ...rest } = entry;
|
|
64
70
|
return {
|
|
65
|
-
...
|
|
71
|
+
...rest,
|
|
66
72
|
typedAttributes,
|
|
67
73
|
properties,
|
|
74
|
+
...(origin ? { origin } : {}),
|
|
68
75
|
};
|
|
69
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/config/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,iBAAiB,CAAC;AAEzB,4DAA4D;AAC5D,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,mDAAmD;IACnD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,gDAAgD;IAChD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AgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAiBxD;AAMD;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAUvC"}
|
package/script/config/mod.js
CHANGED
|
@@ -232,6 +232,30 @@ function parseProjectConfig(yaml, filePath) {
|
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
+
// exclude: optional string[] of gitignore-syntax patterns
|
|
236
|
+
let exclude = mod_js_1.DEFAULT_PROJECT_CONFIG.exclude;
|
|
237
|
+
if (obj.exclude !== undefined && obj.exclude !== null) {
|
|
238
|
+
if (!Array.isArray(obj.exclude)) {
|
|
239
|
+
errors.push({
|
|
240
|
+
field: "exclude",
|
|
241
|
+
message: `expected array, got ${typeof obj.exclude}`,
|
|
242
|
+
line: findLineNumber(yaml, "exclude"),
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
const bad = obj.exclude.findIndex((v) => typeof v !== "string" || v === "");
|
|
247
|
+
if (bad !== -1) {
|
|
248
|
+
errors.push({
|
|
249
|
+
field: `exclude[${bad}]`,
|
|
250
|
+
message: "each exclude pattern must be a non-empty string",
|
|
251
|
+
line: findLineNumber(yaml, "exclude"),
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
exclude = obj.exclude;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
235
259
|
if (errors.length > 0) {
|
|
236
260
|
throw new mod_js_1.ConfigError(filePath, errors);
|
|
237
261
|
}
|
|
@@ -242,6 +266,7 @@ function parseProjectConfig(yaml, filePath) {
|
|
|
242
266
|
parents,
|
|
243
267
|
parentFallback,
|
|
244
268
|
captionConventions,
|
|
269
|
+
exclude,
|
|
245
270
|
};
|
|
246
271
|
}
|
|
247
272
|
// ---------------------------------------------------------------------------
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/discovery/gitignore
|
|
3
|
+
*
|
|
4
|
+
* Pure-TypeScript `.gitignore` pattern matcher. Implements the standard
|
|
5
|
+
* semantics the discovery walker needs: `#` comments, `!` negation,
|
|
6
|
+
* trailing-`/` directory-only patterns, leading-`/` and contains-`/`
|
|
7
|
+
* anchoring, `*` / `?` / `[...]` globs, and `**` cross-directory globs.
|
|
8
|
+
* Last matching rule wins.
|
|
9
|
+
*
|
|
10
|
+
* Per git semantics, a file inside an ignored directory cannot be
|
|
11
|
+
* re-included by a negation — the walker enforces this by pruning
|
|
12
|
+
* ignored directories without descending.
|
|
13
|
+
*
|
|
14
|
+
* No I/O, no platform APIs — Node-compatible by construction.
|
|
15
|
+
*/
|
|
16
|
+
/** One compiled gitignore rule. */
|
|
17
|
+
export interface GitignoreRule {
|
|
18
|
+
/** Matches a root-relative POSIX path (no leading slash). */
|
|
19
|
+
readonly regex: RegExp;
|
|
20
|
+
/** `!pattern` — a match un-ignores the path. */
|
|
21
|
+
readonly negated: boolean;
|
|
22
|
+
/** `pattern/` — matches directories only. */
|
|
23
|
+
readonly dirOnly: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parse `.gitignore` content into compiled rules.
|
|
27
|
+
*
|
|
28
|
+
* @param content - Raw file content (LF or CRLF).
|
|
29
|
+
* @param baseDir - Root-relative POSIX dir the `.gitignore` lives in
|
|
30
|
+
* (`""` for the root one). Patterns only match paths under it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseGitignore(content: string, baseDir: string): GitignoreRule[];
|
|
33
|
+
/**
|
|
34
|
+
* Test a root-relative POSIX path against compiled rules.
|
|
35
|
+
* Last matching rule wins; no match → not ignored.
|
|
36
|
+
*
|
|
37
|
+
* @param isDir - Directory-only rules (`build/`) match only when true.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isIgnored(relPath: string, isDir: boolean, rules: readonly GitignoreRule[]): boolean;
|
|
40
|
+
//# sourceMappingURL=gitignore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitignore.d.ts","sourceRoot":"","sources":["../../src/discovery/gitignore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,mCAAmC;AACnC,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AA0DD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,aAAa,EAAE,CAyCjB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,SAAS,aAAa,EAAE,GAC9B,OAAO,CAOT"}
|