@driftsys/markspec 0.12.1 → 0.13.0
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/ast/build.d.ts.map +1 -1
- package/esm/ast/build.js +19 -5
- package/esm/ast/equivalence.js +14 -2
- package/esm/ast/nodes.d.ts +15 -3
- package/esm/ast/nodes.d.ts.map +1 -1
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +18 -3
- package/esm/compiler/mod.d.ts +34 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +112 -48
- package/esm/compiler/schema.d.ts +3 -2
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +6 -3
- package/esm/criteria/scenarios.d.ts +55 -0
- package/esm/criteria/scenarios.d.ts.map +1 -0
- package/esm/criteria/scenarios.js +133 -0
- package/esm/discovery/mod.d.ts +20 -1
- package/esm/discovery/mod.d.ts.map +1 -1
- package/esm/discovery/mod.js +105 -17
- package/esm/formatter/entry_body.d.ts +8 -5
- package/esm/formatter/entry_body.d.ts.map +1 -1
- package/esm/formatter/entry_body.js +12 -8
- package/esm/formatter/feature_file.d.ts +40 -0
- package/esm/formatter/feature_file.d.ts.map +1 -0
- package/esm/formatter/feature_file.js +88 -0
- package/esm/formatter/mod.d.ts +21 -2
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +64 -22
- package/esm/gates/mod.d.ts +2 -2
- package/esm/gates/mod.d.ts.map +1 -1
- package/esm/gates/mod.js +17 -2
- package/esm/gherkin/load.d.ts +35 -0
- package/esm/gherkin/load.d.ts.map +1 -0
- package/esm/gherkin/load.js +39 -0
- package/esm/gherkin/parse.d.ts +11 -0
- package/esm/gherkin/parse.d.ts.map +1 -0
- package/esm/gherkin/parse.js +311 -0
- package/esm/gherkin/position.d.ts +23 -0
- package/esm/gherkin/position.d.ts.map +1 -0
- package/esm/gherkin/position.js +21 -0
- package/esm/gherkin/procedure.d.ts +76 -0
- package/esm/gherkin/procedure.d.ts.map +1 -0
- package/esm/gherkin/procedure.js +164 -0
- package/esm/gherkin/project.d.ts +35 -0
- package/esm/gherkin/project.d.ts.map +1 -0
- package/esm/gherkin/project.js +64 -0
- package/esm/gherkin/role.d.ts +23 -0
- package/esm/gherkin/role.d.ts.map +1 -0
- package/esm/gherkin/role.js +28 -0
- package/esm/gherkin/types.d.ts +118 -0
- package/esm/gherkin/types.d.ts.map +1 -0
- package/esm/gherkin/types.js +12 -0
- package/esm/lock/acquire_compile.d.ts +12 -4
- package/esm/lock/acquire_compile.d.ts.map +1 -1
- package/esm/lock/acquire_compile.js +15 -5
- package/esm/lock/canonical_edges.d.ts +6 -2
- package/esm/lock/canonical_edges.d.ts.map +1 -1
- package/esm/lock/canonical_edges.js +10 -3
- package/esm/lock/model.d.ts +5 -0
- package/esm/lock/model.d.ts.map +1 -1
- package/esm/lock/parser.d.ts.map +1 -1
- package/esm/lock/parser.js +2 -0
- package/esm/lock/resolve.d.ts +6 -2
- package/esm/lock/resolve.d.ts.map +1 -1
- package/esm/lock/resolve.js +36 -4
- package/esm/lock/serializer.d.ts.map +1 -1
- package/esm/lock/serializer.js +7 -1
- package/esm/mod.d.ts +23 -6
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +18 -5
- package/esm/model/mod.d.ts +42 -1
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +1 -1
- package/esm/model/relations.d.ts +9 -0
- package/esm/model/relations.d.ts.map +1 -1
- package/esm/model/relations.js +16 -1
- package/esm/parser/attributes.d.ts +82 -3
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +199 -32
- package/esm/parser/body_tokens.d.ts +1 -1
- package/esm/parser/body_tokens.d.ts.map +1 -1
- package/esm/parser/body_tokens.js +49 -35
- package/esm/parser/feature_file.d.ts +116 -0
- package/esm/parser/feature_file.d.ts.map +1 -0
- package/esm/parser/feature_file.js +540 -0
- package/esm/parser/markdown.d.ts +7 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +129 -40
- package/esm/parser/mod.d.ts +18 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +51 -0
- package/esm/parser/translate.d.ts.map +1 -1
- package/esm/parser/translate.js +5 -0
- package/esm/refs/mod.d.ts +2 -1
- package/esm/refs/mod.d.ts.map +1 -1
- package/esm/refs/mod.js +12 -4
- package/esm/refs/split.d.ts +58 -0
- package/esm/refs/split.d.ts.map +1 -0
- package/esm/refs/split.js +137 -0
- package/esm/reporter/mod.d.ts +7 -0
- package/esm/reporter/mod.d.ts.map +1 -1
- package/esm/reporter/mod.js +113 -3
- package/esm/validator/attributes.d.ts.map +1 -1
- package/esm/validator/attributes.js +4 -1
- package/esm/validator/block_role.d.ts +40 -0
- package/esm/validator/block_role.d.ts.map +1 -0
- package/esm/validator/block_role.js +109 -0
- package/esm/validator/feature_ac.d.ts.map +1 -1
- package/esm/validator/feature_ac.js +6 -1
- package/esm/validator/feature_parse.d.ts +35 -0
- package/esm/validator/feature_parse.d.ts.map +1 -0
- package/esm/validator/feature_parse.js +69 -0
- package/esm/validator/locators.d.ts +36 -0
- package/esm/validator/locators.d.ts.map +1 -0
- package/esm/validator/locators.js +184 -0
- package/esm/validator/mod.d.ts +10 -1
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +38 -14
- package/esm/validator/normalize.d.ts.map +1 -1
- package/esm/validator/normalize.js +8 -3
- package/esm/validator/per_type_attrs.d.ts +3 -3
- package/esm/validator/per_type_attrs.js +3 -3
- package/esm/validator/pipeline.d.ts +4 -12
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +24 -5
- package/esm/validator/procedure.d.ts +22 -0
- package/esm/validator/procedure.d.ts.map +1 -0
- package/esm/validator/procedure.js +58 -0
- package/esm/validator/trace_types.d.ts.map +1 -1
- package/esm/validator/trace_types.js +4 -3
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +4 -1
- package/esm/validator/type_resolution.d.ts +5 -3
- package/esm/validator/type_resolution.d.ts.map +1 -1
- package/esm/validator/type_resolution.js +14 -2
- package/esm/validator/types.d.ts +11 -0
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +26 -4
- package/esm/validator/uxil_family.d.ts +1 -1
- package/package.json +3 -1
- package/script/ast/build.d.ts.map +1 -1
- package/script/ast/build.js +19 -5
- package/script/ast/equivalence.js +14 -2
- package/script/ast/nodes.d.ts +15 -3
- package/script/ast/nodes.d.ts.map +1 -1
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +18 -3
- package/script/compiler/mod.d.ts +34 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +110 -46
- package/script/compiler/schema.d.ts +3 -2
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +6 -3
- package/script/criteria/scenarios.d.ts +55 -0
- package/script/criteria/scenarios.d.ts.map +1 -0
- package/script/criteria/scenarios.js +139 -0
- package/script/discovery/mod.d.ts +20 -1
- package/script/discovery/mod.d.ts.map +1 -1
- package/script/discovery/mod.js +106 -17
- package/script/formatter/entry_body.d.ts +8 -5
- package/script/formatter/entry_body.d.ts.map +1 -1
- package/script/formatter/entry_body.js +12 -8
- package/script/formatter/feature_file.d.ts +40 -0
- package/script/formatter/feature_file.d.ts.map +1 -0
- package/script/formatter/feature_file.js +92 -0
- package/script/formatter/mod.d.ts +21 -2
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +63 -21
- package/script/gates/mod.d.ts +2 -2
- package/script/gates/mod.d.ts.map +1 -1
- package/script/gates/mod.js +17 -2
- package/script/gherkin/load.d.ts +35 -0
- package/script/gherkin/load.d.ts.map +1 -0
- package/script/gherkin/load.js +76 -0
- package/script/gherkin/parse.d.ts +11 -0
- package/script/gherkin/parse.d.ts.map +1 -0
- package/script/gherkin/parse.js +314 -0
- package/script/gherkin/position.d.ts +23 -0
- package/script/gherkin/position.d.ts.map +1 -0
- package/script/gherkin/position.js +24 -0
- package/script/gherkin/procedure.d.ts +76 -0
- package/script/gherkin/procedure.d.ts.map +1 -0
- package/script/gherkin/procedure.js +169 -0
- package/script/gherkin/project.d.ts +35 -0
- package/script/gherkin/project.d.ts.map +1 -0
- package/script/gherkin/project.js +67 -0
- package/script/gherkin/role.d.ts +23 -0
- package/script/gherkin/role.d.ts.map +1 -0
- package/script/gherkin/role.js +31 -0
- package/script/gherkin/types.d.ts +118 -0
- package/script/gherkin/types.d.ts.map +1 -0
- package/script/gherkin/types.js +13 -0
- package/script/lock/acquire_compile.d.ts +12 -4
- package/script/lock/acquire_compile.d.ts.map +1 -1
- package/script/lock/acquire_compile.js +15 -5
- package/script/lock/canonical_edges.d.ts +6 -2
- package/script/lock/canonical_edges.d.ts.map +1 -1
- package/script/lock/canonical_edges.js +10 -3
- package/script/lock/model.d.ts +5 -0
- package/script/lock/model.d.ts.map +1 -1
- package/script/lock/parser.d.ts.map +1 -1
- package/script/lock/parser.js +2 -0
- package/script/lock/resolve.d.ts +6 -2
- package/script/lock/resolve.d.ts.map +1 -1
- package/script/lock/resolve.js +36 -4
- package/script/lock/serializer.d.ts.map +1 -1
- package/script/lock/serializer.js +7 -1
- package/script/mod.d.ts +23 -6
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +45 -6
- package/script/model/mod.d.ts +42 -1
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +2 -1
- package/script/model/relations.d.ts +9 -0
- package/script/model/relations.d.ts.map +1 -1
- package/script/model/relations.js +17 -1
- package/script/parser/attributes.d.ts +82 -3
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +205 -33
- package/script/parser/body_tokens.d.ts +1 -1
- package/script/parser/body_tokens.d.ts.map +1 -1
- package/script/parser/body_tokens.js +49 -35
- package/script/parser/feature_file.d.ts +116 -0
- package/script/parser/feature_file.d.ts.map +1 -0
- package/script/parser/feature_file.js +548 -0
- package/script/parser/markdown.d.ts +7 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +128 -39
- package/script/parser/mod.d.ts +18 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +52 -1
- package/script/parser/translate.d.ts.map +1 -1
- package/script/parser/translate.js +5 -0
- package/script/refs/mod.d.ts +2 -1
- package/script/refs/mod.d.ts.map +1 -1
- package/script/refs/mod.js +12 -4
- package/script/refs/split.d.ts +58 -0
- package/script/refs/split.d.ts.map +1 -0
- package/script/refs/split.js +145 -0
- package/script/reporter/mod.d.ts +7 -0
- package/script/reporter/mod.d.ts.map +1 -1
- package/script/reporter/mod.js +113 -3
- package/script/validator/attributes.d.ts.map +1 -1
- package/script/validator/attributes.js +4 -1
- package/script/validator/block_role.d.ts +40 -0
- package/script/validator/block_role.d.ts.map +1 -0
- package/script/validator/block_role.js +112 -0
- package/script/validator/feature_ac.d.ts.map +1 -1
- package/script/validator/feature_ac.js +6 -1
- package/script/validator/feature_parse.d.ts +35 -0
- package/script/validator/feature_parse.d.ts.map +1 -0
- package/script/validator/feature_parse.js +73 -0
- package/script/validator/locators.d.ts +36 -0
- package/script/validator/locators.d.ts.map +1 -0
- package/script/validator/locators.js +188 -0
- package/script/validator/mod.d.ts +10 -1
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +38 -14
- package/script/validator/normalize.d.ts.map +1 -1
- package/script/validator/normalize.js +8 -3
- package/script/validator/per_type_attrs.d.ts +3 -3
- package/script/validator/per_type_attrs.js +3 -3
- package/script/validator/pipeline.d.ts +4 -12
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +23 -5
- package/script/validator/procedure.d.ts +22 -0
- package/script/validator/procedure.d.ts.map +1 -0
- package/script/validator/procedure.js +61 -0
- package/script/validator/trace_types.d.ts.map +1 -1
- package/script/validator/trace_types.js +4 -3
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +4 -1
- package/script/validator/type_resolution.d.ts +5 -3
- package/script/validator/type_resolution.d.ts.map +1 -1
- package/script/validator/type_resolution.js +14 -2
- package/script/validator/types.d.ts +11 -0
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +27 -4
- package/script/validator/uxil_family.d.ts +1 -1
package/script/compiler/mod.js
CHANGED
|
@@ -9,9 +9,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.generateInverses = exports.serializeCompileResult = void 0;
|
|
10
10
|
exports.compile = compile;
|
|
11
11
|
const mod_js_1 = require("../model/mod.js");
|
|
12
|
+
const scenarios_js_1 = require("../criteria/scenarios.js");
|
|
13
|
+
const split_js_1 = require("../refs/split.js");
|
|
12
14
|
const mod_js_2 = require("../parser/mod.js");
|
|
13
15
|
const mod_js_3 = require("../validator/mod.js");
|
|
14
|
-
const uxil_family_js_1 = require("../validator/uxil_family.js");
|
|
15
16
|
const mod_js_4 = require("../typl/mod.js");
|
|
16
17
|
const discipline_registry_js_1 = require("../profile/discipline_registry.js");
|
|
17
18
|
const constants_js_1 = require("./constants.js");
|
|
@@ -45,7 +46,9 @@ function resolveGit(raw, withContributors) {
|
|
|
45
46
|
* Project `Entry.source` onto `EntryProperties.source`. Always returns a
|
|
46
47
|
* non-empty object — every entry has a known source category. Markdown
|
|
47
48
|
* entries get `{ type: "markdown" }`; doc-comment entries get the full
|
|
48
|
-
* code-source fan-out (adapter, language, function, rule)
|
|
49
|
+
* code-source fan-out (adapter, language, function, rule); `.feature`
|
|
50
|
+
* header entries get `{ type: "feature-file", adapter: "gherkin", rule }`
|
|
51
|
+
* where `rule` is the Gherkin node kind.
|
|
49
52
|
*/
|
|
50
53
|
function resolveSource(source) {
|
|
51
54
|
if (source.kind === "markdown") {
|
|
@@ -60,7 +63,11 @@ function resolveSource(source) {
|
|
|
60
63
|
rule: source.rule,
|
|
61
64
|
};
|
|
62
65
|
}
|
|
63
|
-
|
|
66
|
+
if (source.kind === "feature-file") {
|
|
67
|
+
// The Gherkin node the header stands above is the extractor rule.
|
|
68
|
+
return { type: "feature-file", adapter: "gherkin", rule: source.node };
|
|
69
|
+
}
|
|
70
|
+
// Exhaustiveness check — adding a fourth EntrySource variant becomes a
|
|
64
71
|
// compile-time error here, forcing a deliberate decision about its
|
|
65
72
|
// properties.source projection rather than silently inheriting the
|
|
66
73
|
// tree-sitter branch's defaults.
|
|
@@ -109,6 +116,14 @@ class Semaphore {
|
|
|
109
116
|
* Compile MarkSpec files from the given paths into a resolved
|
|
110
117
|
* traceability graph.
|
|
111
118
|
*
|
|
119
|
+
* The returned diagnostics combine parse diagnostics, the validator
|
|
120
|
+
* pipeline's diagnostics, inverse-generation diagnostics and MSL-T013. The
|
|
121
|
+
* pipeline call is the same `runPipeline` call that bare `markspec check`
|
|
122
|
+
* and the LSP make, with project-wide scope by default
|
|
123
|
+
* (`options.projectWide`), so MSL-L006 and the other traceability rules are
|
|
124
|
+
* included. The diagnostics do not include fmt drift, lockfile drift or prose
|
|
125
|
+
* lint.
|
|
126
|
+
*
|
|
112
127
|
* @param paths - File paths to compile
|
|
113
128
|
* @param options - Compile options
|
|
114
129
|
* @returns Compiled entries, links, and diagnostics
|
|
@@ -181,26 +196,26 @@ async function compile(paths, options) {
|
|
|
181
196
|
if (res.document)
|
|
182
197
|
documents.set(res.filePath, res.document);
|
|
183
198
|
}
|
|
184
|
-
// Phase 2: Validate all entries
|
|
185
|
-
//
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
//
|
|
199
|
+
// Phase 2: Validate all entries with the same validator pipeline that
|
|
200
|
+
// bare `markspec check` and the LSP run (`runPipeline`): core hygiene,
|
|
201
|
+
// classification, typed attributes, traceability (MSL-L006, MSL-T014),
|
|
202
|
+
// Gherkin checks and the uxil family. By default the requested path set is
|
|
203
|
+
// the whole project, so project-wide scope applies (`options.projectWide`).
|
|
204
|
+
// Only the pipeline's diagnostics are used. The graph below is built from
|
|
205
|
+
// compile's own classification, so the compiled graph does not depend on
|
|
206
|
+
// the pipeline. CLI-only gates (fmt drift, lock drift, prose lint) are
|
|
207
|
+
// not part of compile.
|
|
208
|
+
const pipelineDiagnostics = (0, mod_js_3.runPipeline)(allEntries, options.profile ?? null, options.captionConventions ?? {}, {
|
|
209
|
+
projectWide: options.projectWide ?? true,
|
|
210
|
+
declaredUpstreamIds: options.declaredUpstreamIds ?? [],
|
|
211
|
+
}).diagnostics;
|
|
212
|
+
// Phase 2.5: Classify entries when a profile is loaded. The
|
|
213
|
+
// classification diagnostics are already part of the pipeline result.
|
|
191
214
|
let classifiedEntries = allEntries;
|
|
192
215
|
if (options.profile) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
parseDiagnostics.push(...stage2.diagnostics);
|
|
216
|
+
classifiedEntries = (0, mod_js_3.classifyEntriesStage)(allEntries, options.profile)
|
|
217
|
+
.entries;
|
|
196
218
|
}
|
|
197
|
-
// Phase 2.6: uxil diagnostics family (S9 #727) — profile-gated (inert
|
|
198
|
-
// without a `declares: ux-surface` designation), mirroring runPipeline's
|
|
199
|
-
// Stage 5 so compile-backed surfaces (CLI compile/export/show, the MCP
|
|
200
|
-
// server) agree with `check` and the LSP on designated corpora. No
|
|
201
|
-
// file-local filter here: the requested path set IS the corpus being
|
|
202
|
-
// compiled — the same full-set semantics MSL-L006 assumes in compile.
|
|
203
|
-
const uxilDiagnostics = (0, uxil_family_js_1.validateUxilFamily)(classifiedEntries, options.profile ?? null);
|
|
204
219
|
// Phase 3: Build traceability graph.
|
|
205
220
|
// Keep first occurrence of each display ID (validator catches duplicates).
|
|
206
221
|
const entries = new Map();
|
|
@@ -238,22 +253,25 @@ async function compile(paths, options) {
|
|
|
238
253
|
entries.set(entry.displayId, entry);
|
|
239
254
|
}
|
|
240
255
|
}
|
|
256
|
+
// Phase 4.5: Attach criteria (scenario names of fenced feature blocks)
|
|
257
|
+
// to Requirement and Contract entries, then resolve link locators
|
|
258
|
+
// against them (epic #915).
|
|
259
|
+
attachCriteria(entries, options.profile);
|
|
241
260
|
const authoredLinks = extractLinks([...entries.values()]);
|
|
242
|
-
const links = [...authoredLinks, ...generatedLinks];
|
|
261
|
+
const links = resolveLocators([...authoredLinks, ...generatedLinks], entries, options.profile);
|
|
243
262
|
// MSL-T013: check link targets for draft/retired state.
|
|
244
263
|
const linkTargetDiags = (0, link_target_js_1.checkLinkTargets)(entries, links);
|
|
245
264
|
const forward = buildAdjacency(links, (l) => l.from);
|
|
246
265
|
const reverse = buildAdjacency(links, (l) => l.to);
|
|
247
|
-
// Build the corpus typl registry directly —
|
|
266
|
+
// Build the corpus typl registry directly — the pipeline (called above)
|
|
248
267
|
// already ran the full validateTypl pass (citation resolution, TYPL-009,
|
|
249
|
-
// etc.) for
|
|
250
|
-
//
|
|
251
|
-
//
|
|
268
|
+
// etc.) for its diagnostics; re-running it here just to get `.registry`
|
|
269
|
+
// would redo that work a second time per compile/show/context/report/
|
|
270
|
+
// export/MCP call.
|
|
252
271
|
const typeRegistry = (0, mod_js_4.buildTypeRegistry)([...entries.values()]);
|
|
253
272
|
let diagnostics = [
|
|
254
273
|
...parseDiagnostics,
|
|
255
|
-
...
|
|
256
|
-
...uxilDiagnostics,
|
|
274
|
+
...pipelineDiagnostics,
|
|
257
275
|
...linkTargetDiags,
|
|
258
276
|
];
|
|
259
277
|
// Phase 5: Corpus-aware diagnostic post-pass (ADR-030). A project entry
|
|
@@ -289,35 +307,81 @@ function extractLinks(entries) {
|
|
|
289
307
|
}
|
|
290
308
|
/**
|
|
291
309
|
* Attributes whose value is `slug + optional free-text locator` per
|
|
292
|
-
* ADR-002 §2.6 (citation type + legacy Derived-from tolerance).
|
|
293
|
-
* target is the leading non-whitespace token
|
|
310
|
+
* ADR-002 §2.6 (citation type + legacy Derived-from tolerance). Without a
|
|
311
|
+
* bracket locator, the link target is the leading non-whitespace token.
|
|
294
312
|
*/
|
|
295
|
-
const
|
|
313
|
+
const LEADING_TOKEN_ATTRS = new Set([
|
|
296
314
|
"Derived-from",
|
|
297
315
|
"References",
|
|
298
316
|
]);
|
|
299
|
-
/**
|
|
317
|
+
/** The link target of one comma-separated part without a locator, as
|
|
318
|
+
* before scenario locators: the leading token for
|
|
319
|
+
* {@linkcode LEADING_TOKEN_ATTRS}, else the whole trimmed part. */
|
|
320
|
+
function plainTarget(key, part) {
|
|
321
|
+
const trimmed = part.trim();
|
|
322
|
+
return LEADING_TOKEN_ATTRS.has(key) ? trimmed.split(/\s/)[0] : trimmed;
|
|
323
|
+
}
|
|
324
|
+
/** Map an attribute key+value to zero or more links. The value is split
|
|
325
|
+
* with {@linkcode splitTraceValues}. A part with a bracket locator
|
|
326
|
+
* (`A [x]`) yields a link to `A` that keeps the normalized locator. Any
|
|
327
|
+
* other part is read as before scenario locators existed
|
|
328
|
+
* ({@linkcode plainTarget}). */
|
|
300
329
|
function extractLinksFromAttribute(from, key, value, location) {
|
|
301
330
|
const kind = constants_js_1.ATTR_TO_LINK_KIND[key];
|
|
302
331
|
if (!kind)
|
|
303
332
|
return [];
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
333
|
+
return (0, split_js_1.splitTraceValues)(value).map((part) => {
|
|
334
|
+
const { target, locator } = (0, split_js_1.parseTraceValue)(part);
|
|
335
|
+
if (locator !== undefined) {
|
|
336
|
+
return { from, to: (0, mod_js_1.makeDisplayId)(target), kind, location, locator };
|
|
337
|
+
}
|
|
338
|
+
return { from, to: (0, mod_js_1.makeDisplayId)(plainTarget(key, part)), kind, location };
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
/** Attach `criteria` to every criteria-bearing, non-upstream entry that
|
|
342
|
+
* has at least one scenario. Entries without scenarios are left unchanged, so compiled
|
|
343
|
+
* output for projects without feature blocks does not change. */
|
|
344
|
+
function attachCriteria(entries, profile) {
|
|
345
|
+
for (const [id, entry] of entries) {
|
|
346
|
+
// Upstream (federated) entries are read-only references: no criteria.
|
|
347
|
+
if ((0, mod_js_1.isUpstreamEntry)(entry))
|
|
348
|
+
continue;
|
|
349
|
+
if (!(0, scenarios_js_1.isCriteriaBearing)(entry, profile))
|
|
350
|
+
continue;
|
|
351
|
+
const criteria = (0, scenarios_js_1.buildCriteria)(entry);
|
|
352
|
+
if (criteria.length > 0)
|
|
353
|
+
entries.set(id, { ...entry, criteria });
|
|
313
354
|
}
|
|
314
|
-
// Comma-separated targets for id-list attributes.
|
|
315
|
-
return value
|
|
316
|
-
.split(",")
|
|
317
|
-
.map((s) => s.trim())
|
|
318
|
-
.filter((s) => s.length > 0)
|
|
319
|
-
.map((to) => ({ from, to: (0, mod_js_1.makeDisplayId)(to), kind, location }));
|
|
320
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* Set `locatorResolved` on every link whose locator is on a `"criterion"`
|
|
358
|
+
* relation and whose target resolves to a criteria-bearing entry. For a
|
|
359
|
+
* generated inverse the target of the authored relation is `link.from`.
|
|
360
|
+
*/
|
|
361
|
+
function resolveLocators(links, entries, profile) {
|
|
362
|
+
// A target may be written as a display ID or as a ULID.
|
|
363
|
+
const byUlid = new Map();
|
|
364
|
+
for (const e of entries.values())
|
|
365
|
+
if (e.id)
|
|
366
|
+
byUlid.set(e.id, e);
|
|
367
|
+
return links.map((link) => {
|
|
368
|
+
if (link.locator === undefined)
|
|
369
|
+
return link;
|
|
370
|
+
if ((0, mod_js_1.relationLocatorMode)(LINK_KIND_TO_ATTR[link.kind]) !== "criterion") {
|
|
371
|
+
return link;
|
|
372
|
+
}
|
|
373
|
+
const targetId = link.origin === "generated" ? link.from : link.to;
|
|
374
|
+
const target = entries.get(targetId) ?? byUlid.get(targetId);
|
|
375
|
+
if (!target || !(0, scenarios_js_1.isCriteriaBearing)(target, profile))
|
|
376
|
+
return link;
|
|
377
|
+
const resolved = (target.criteria ?? []).some((c) => c.addressable && c.name === link.locator);
|
|
378
|
+
return { ...link, locatorResolved: resolved };
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
/** Reverse of {@linkcode ATTR_TO_LINK_KIND}: each link kind has one
|
|
382
|
+
* attribute. */
|
|
383
|
+
const LINK_KIND_TO_ATTR = Object
|
|
384
|
+
.fromEntries(Object.entries(constants_js_1.ATTR_TO_LINK_KIND).map(([attr, kind]) => [kind, attr]));
|
|
321
385
|
/** Build an adjacency map from links using a key selector. */
|
|
322
386
|
function buildAdjacency(links, keyFn) {
|
|
323
387
|
const map = new Map();
|
|
@@ -70,8 +70,9 @@ export declare function serializeCompileResult(result: CompileResult): Serialize
|
|
|
70
70
|
/**
|
|
71
71
|
* Convert an {@linkcode Entry} to a JSON-safe {@linkcode SerializedEntry} by
|
|
72
72
|
* replacing `typedAttributes` (a `ReadonlyMap`) with a plain
|
|
73
|
-
* `Record<string, readonly string[]>`,
|
|
74
|
-
* (privacy rule — never publish connector state)
|
|
73
|
+
* `Record<string, readonly string[]>`, stripping `properties.sync`
|
|
74
|
+
* (privacy rule — never publish connector state), and dropping
|
|
75
|
+
* `attributeLines` (a parser aid for diagnostic locations).
|
|
75
76
|
*/
|
|
76
77
|
export declare function serializeEntry(entry: Entry): SerializedEntry;
|
|
77
78
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -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,WAAW,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEvE;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,EAAE,iBAAiB,CAAC,GAAG;IAC7D,QAAQ,C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BAAuB,CAazB;AAgBD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,CA8B5D"}
|
|
@@ -46,8 +46,9 @@ function serializeTypeRegistry(registry) {
|
|
|
46
46
|
/**
|
|
47
47
|
* Convert an {@linkcode Entry} to a JSON-safe {@linkcode SerializedEntry} by
|
|
48
48
|
* replacing `typedAttributes` (a `ReadonlyMap`) with a plain
|
|
49
|
-
* `Record<string, readonly string[]>`,
|
|
50
|
-
* (privacy rule — never publish connector state)
|
|
49
|
+
* `Record<string, readonly string[]>`, stripping `properties.sync`
|
|
50
|
+
* (privacy rule — never publish connector state), and dropping
|
|
51
|
+
* `attributeLines` (a parser aid for diagnostic locations).
|
|
51
52
|
*/
|
|
52
53
|
function serializeEntry(entry) {
|
|
53
54
|
// Replace the ReadonlyMap with a plain Record when populated; omit when empty
|
|
@@ -66,7 +67,9 @@ function serializeEntry(entry) {
|
|
|
66
67
|
// from a delivered corpus, matching the serialized-field-presence
|
|
67
68
|
// contract. Object rest destructuring drops the named key regardless
|
|
68
69
|
// of its value, unlike `...entry` alone.
|
|
69
|
-
|
|
70
|
+
// `attributeLines` is a parser aid for diagnostic locations, not part
|
|
71
|
+
// of the compiled schema.
|
|
72
|
+
const { origin, attributeLines: _attributeLines, ...rest } = entry;
|
|
70
73
|
return {
|
|
71
74
|
...rest,
|
|
72
75
|
typedAttributes,
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module criteria/scenarios
|
|
3
|
+
*
|
|
4
|
+
* Scenario index. Builds the `Entry.criteria` subset
|
|
5
|
+
* `{ form: "scenario", name, addressable, location }` from the fenced
|
|
6
|
+
* `gherkin` / `feature` blocks of an entry body.
|
|
7
|
+
*
|
|
8
|
+
* Source of the scenario names, per block:
|
|
9
|
+
*
|
|
10
|
+
* - the Gherkin AST (`FeatureNode.feature`) when it is present, in any spoken
|
|
11
|
+
* language;
|
|
12
|
+
* - otherwise the line scanner ({@linkcode scanScenarioNames}, English
|
|
13
|
+
* keywords only), when the block did not parse (`parseError`) or when the
|
|
14
|
+
* parser was not loaded at parse time.
|
|
15
|
+
*
|
|
16
|
+
* `parseFile` loads the parser before it parses a text with a gherkin fence,
|
|
17
|
+
* so every entry that reaches the compiler, the validator and the reporter
|
|
18
|
+
* carries the AST or a `parseError`, unless the parser import failed. The
|
|
19
|
+
* scanner for the not-loaded case covers that failure and code that builds
|
|
20
|
+
* entries with the synchronous `parse()` before any load.
|
|
21
|
+
*/
|
|
22
|
+
import type { Criterion, EffectiveProfile, Entry } from "../model/mod.js";
|
|
23
|
+
/**
|
|
24
|
+
* Collect the scenario names of one Gherkin source text, in order.
|
|
25
|
+
* `line` is the 0-based line of the keyword within `source`. Lines between
|
|
26
|
+
* doc-string delimiters (`"""` or three backticks) are skipped. `Background`
|
|
27
|
+
* and `Rule` are not scenarios. Names are trimmed but not otherwise
|
|
28
|
+
* normalized.
|
|
29
|
+
*/
|
|
30
|
+
export declare function scanScenarioNames(source: string): {
|
|
31
|
+
name: string;
|
|
32
|
+
line: number;
|
|
33
|
+
}[];
|
|
34
|
+
/**
|
|
35
|
+
* Build the criteria of an entry from its feature blocks, in source order.
|
|
36
|
+
* Only top-level fenced blocks of the body are indexed: a fence nested in a
|
|
37
|
+
* list item or another container yields no criteria.
|
|
38
|
+
* A block with an AST contributes the AST's scenarios; see the module comment
|
|
39
|
+
* for the fallback. Names are normalized with {@linkcode normalizeLocator}. The blocks of one
|
|
40
|
+
* entry form one scope: a normalized name that occurs more than once, and an
|
|
41
|
+
* empty name, are not addressable. `location.line` is the file-relative line
|
|
42
|
+
* of the keyword; `location.column` is always 1.
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildCriteria(entry: Entry): readonly Criterion[];
|
|
45
|
+
/** `true` when `entry`'s type resolves to core Requirement or Contract —
|
|
46
|
+
* the entries that carry criteria (epic #915, decision 3). Uses the
|
|
47
|
+
* profile extends chain when a profile is loaded, else the core hierarchy.
|
|
48
|
+
* An entry without a resolved type carries no criteria. */
|
|
49
|
+
export declare function isCriteriaBearing(entry: Entry, profile: EffectiveProfile | null | undefined): boolean;
|
|
50
|
+
/** `true` when `entry`'s type is, or extends, the core `Test` type — the
|
|
51
|
+
* entries whose `Verifies` links count for criterion coverage (epic #915,
|
|
52
|
+
* decision 2). Uses the profile extends chain when a profile is loaded,
|
|
53
|
+
* else the core hierarchy. */
|
|
54
|
+
export declare function isTestEntry(entry: Entry, profile: EffectiveProfile | null | undefined): boolean;
|
|
55
|
+
//# sourceMappingURL=scenarios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenarios.d.ts","sourceRoot":"","sources":["../../src/criteria/scenarios.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAU1E;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,GACb;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,CAsBlC;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,SAAS,EAAE,CA8BhE;AAKD;;;2DAG2D;AAC3D,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAAG,SAAS,GAC3C,OAAO,CAQT;AAMD;;;8BAG8B;AAC9B,wBAAgB,WAAW,CACzB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAAG,SAAS,GAC3C,OAAO,CAMT"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module criteria/scenarios
|
|
4
|
+
*
|
|
5
|
+
* Scenario index. Builds the `Entry.criteria` subset
|
|
6
|
+
* `{ form: "scenario", name, addressable, location }` from the fenced
|
|
7
|
+
* `gherkin` / `feature` blocks of an entry body.
|
|
8
|
+
*
|
|
9
|
+
* Source of the scenario names, per block:
|
|
10
|
+
*
|
|
11
|
+
* - the Gherkin AST (`FeatureNode.feature`) when it is present, in any spoken
|
|
12
|
+
* language;
|
|
13
|
+
* - otherwise the line scanner ({@linkcode scanScenarioNames}, English
|
|
14
|
+
* keywords only), when the block did not parse (`parseError`) or when the
|
|
15
|
+
* parser was not loaded at parse time.
|
|
16
|
+
*
|
|
17
|
+
* `parseFile` loads the parser before it parses a text with a gherkin fence,
|
|
18
|
+
* so every entry that reaches the compiler, the validator and the reporter
|
|
19
|
+
* carries the AST or a `parseError`, unless the parser import failed. The
|
|
20
|
+
* scanner for the not-loaded case covers that failure and code that builds
|
|
21
|
+
* entries with the synchronous `parse()` before any load.
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.scanScenarioNames = scanScenarioNames;
|
|
25
|
+
exports.buildCriteria = buildCriteria;
|
|
26
|
+
exports.isCriteriaBearing = isCriteriaBearing;
|
|
27
|
+
exports.isTestEntry = isTestEntry;
|
|
28
|
+
const mod_js_1 = require("../model/mod.js");
|
|
29
|
+
const discipline_mode_js_1 = require("../profile/discipline_mode.js");
|
|
30
|
+
const split_js_1 = require("../refs/split.js");
|
|
31
|
+
const position_js_1 = require("../gherkin/position.js");
|
|
32
|
+
/** Matches a scenario-like keyword line. Group 2 is the raw name. */
|
|
33
|
+
const SCENARIO_RE = /^\s*(Scenario Outline|Scenario Template|Scenario|Example):\s*(.*)$/;
|
|
34
|
+
/**
|
|
35
|
+
* Collect the scenario names of one Gherkin source text, in order.
|
|
36
|
+
* `line` is the 0-based line of the keyword within `source`. Lines between
|
|
37
|
+
* doc-string delimiters (`"""` or three backticks) are skipped. `Background`
|
|
38
|
+
* and `Rule` are not scenarios. Names are trimmed but not otherwise
|
|
39
|
+
* normalized.
|
|
40
|
+
*/
|
|
41
|
+
function scanScenarioNames(source) {
|
|
42
|
+
const found = [];
|
|
43
|
+
// The delimiter that opened the current doc string, if any. Only the same
|
|
44
|
+
// delimiter closes it.
|
|
45
|
+
let openDelimiter;
|
|
46
|
+
source.split(/\r?\n/).forEach((text, line) => {
|
|
47
|
+
const trimmed = text.trim();
|
|
48
|
+
const delimiter = trimmed.startsWith('"""')
|
|
49
|
+
? '"""'
|
|
50
|
+
: trimmed.startsWith("```")
|
|
51
|
+
? "```"
|
|
52
|
+
: undefined;
|
|
53
|
+
if (delimiter !== undefined) {
|
|
54
|
+
if (openDelimiter === undefined)
|
|
55
|
+
openDelimiter = delimiter;
|
|
56
|
+
else if (openDelimiter === delimiter)
|
|
57
|
+
openDelimiter = undefined;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (openDelimiter !== undefined)
|
|
61
|
+
return;
|
|
62
|
+
const match = SCENARIO_RE.exec(text);
|
|
63
|
+
if (match)
|
|
64
|
+
found.push({ name: match[2].trim(), line });
|
|
65
|
+
});
|
|
66
|
+
return found;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Build the criteria of an entry from its feature blocks, in source order.
|
|
70
|
+
* Only top-level fenced blocks of the body are indexed: a fence nested in a
|
|
71
|
+
* list item or another container yields no criteria.
|
|
72
|
+
* A block with an AST contributes the AST's scenarios; see the module comment
|
|
73
|
+
* for the fallback. Names are normalized with {@linkcode normalizeLocator}. The blocks of one
|
|
74
|
+
* entry form one scope: a normalized name that occurs more than once, and an
|
|
75
|
+
* empty name, are not addressable. `location.line` is the file-relative line
|
|
76
|
+
* of the keyword; `location.column` is always 1.
|
|
77
|
+
*/
|
|
78
|
+
function buildCriteria(entry) {
|
|
79
|
+
const bodyStart = entry.bodyStartLine ?? (entry.location.line + 1);
|
|
80
|
+
const raw = [];
|
|
81
|
+
for (const block of entry.bodyAst ?? []) {
|
|
82
|
+
if (!isFeature(block))
|
|
83
|
+
continue;
|
|
84
|
+
if (block.feature !== undefined) {
|
|
85
|
+
for (const scenario of block.feature.scenarios) {
|
|
86
|
+
raw.push({
|
|
87
|
+
name: (0, split_js_1.normalizeLocator)(scenario.name),
|
|
88
|
+
line: (0, position_js_1.featureFileLine)(entry, block, scenario.range.start.line),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
// Block did not parse, or the parser was not loaded: scan it. Body-
|
|
94
|
+
// relative range line 1 is `bodyStart`; the block's first source line
|
|
95
|
+
// follows the opening fence line.
|
|
96
|
+
const firstSourceLine = bodyStart + block.range.start.line;
|
|
97
|
+
for (const { name, line } of scanScenarioNames(block.source)) {
|
|
98
|
+
raw.push({ name: (0, split_js_1.normalizeLocator)(name), line: firstSourceLine + line });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const counts = new Map();
|
|
102
|
+
for (const { name } of raw)
|
|
103
|
+
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
104
|
+
return raw.map(({ name, line }) => ({
|
|
105
|
+
form: "scenario",
|
|
106
|
+
name,
|
|
107
|
+
addressable: name !== "" && counts.get(name) === 1,
|
|
108
|
+
location: { file: entry.location.file, line, column: 1 },
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
/** Core types whose descendants carry criteria. */
|
|
112
|
+
const CRITERIA_BEARING_TYPES = ["Requirement", "Contract"];
|
|
113
|
+
/** `true` when `entry`'s type resolves to core Requirement or Contract —
|
|
114
|
+
* the entries that carry criteria (epic #915, decision 3). Uses the
|
|
115
|
+
* profile extends chain when a profile is loaded, else the core hierarchy.
|
|
116
|
+
* An entry without a resolved type carries no criteria. */
|
|
117
|
+
function isCriteriaBearing(entry, profile) {
|
|
118
|
+
const type = entry.type;
|
|
119
|
+
if (type === undefined)
|
|
120
|
+
return false;
|
|
121
|
+
return CRITERIA_BEARING_TYPES.some((core) => profile
|
|
122
|
+
? (0, discipline_mode_js_1.extendsTransitively)(type, core, profile)
|
|
123
|
+
: (0, mod_js_1.descendantsOf)(core).has(type));
|
|
124
|
+
}
|
|
125
|
+
function isFeature(block) {
|
|
126
|
+
return block.kind === "feature";
|
|
127
|
+
}
|
|
128
|
+
/** `true` when `entry`'s type is, or extends, the core `Test` type — the
|
|
129
|
+
* entries whose `Verifies` links count for criterion coverage (epic #915,
|
|
130
|
+
* decision 2). Uses the profile extends chain when a profile is loaded,
|
|
131
|
+
* else the core hierarchy. */
|
|
132
|
+
function isTestEntry(entry, profile) {
|
|
133
|
+
const type = entry.type;
|
|
134
|
+
if (type === undefined)
|
|
135
|
+
return false;
|
|
136
|
+
return profile
|
|
137
|
+
? (0, discipline_mode_js_1.extendsTransitively)(type, "Test", profile)
|
|
138
|
+
: (0, mod_js_1.descendantsOf)("Test").has(type);
|
|
139
|
+
}
|
|
@@ -26,7 +26,13 @@ export { type GitignoreRule, isIgnored, parseGitignore } from "./gitignore.js";
|
|
|
26
26
|
export declare const SOURCE_EXTENSIONS: ReadonlySet<string>;
|
|
27
27
|
/** Markdown only — the `fmt` scope (the formatter never rewrites source). */
|
|
28
28
|
export declare const MARKDOWN_EXTENSIONS: ReadonlySet<string>;
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Gherkin `.feature` files, whose `# [ID]` header comments define entries
|
|
31
|
+
* (ADR-038). Not part of {@linkcode SOURCE_EXTENSIONS}: that set drives the
|
|
32
|
+
* tree-sitter grammars and the LSP, and `.feature` files use neither.
|
|
33
|
+
*/
|
|
34
|
+
export declare const FEATURE_EXTENSIONS: ReadonlySet<string>;
|
|
35
|
+
/** Everything MarkSpec-relevant: markdown, source and `.feature` files. */
|
|
30
36
|
export declare const RELEVANT_EXTENSIONS: ReadonlySet<string>;
|
|
31
37
|
/** One directory entry from {@linkcode DiscoveryIO.readDir}.
|
|
32
38
|
* Structurally compatible with `Deno.DirEntry`. */
|
|
@@ -67,4 +73,17 @@ export interface DiscoverOptions {
|
|
|
67
73
|
* output across filesystems. Unreadable directories are skipped.
|
|
68
74
|
*/
|
|
69
75
|
export declare function discoverFiles(root: string, io: DiscoveryIO, options?: DiscoverOptions): AsyncGenerator<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Report whether {@linkcode discoverFiles} with the same `root`, `io` and
|
|
78
|
+
* `options` would yield `path`. It applies the same rules as the walk: the
|
|
79
|
+
* extension filter, hidden directories, the built-in build-output skips, the
|
|
80
|
+
* `.gitignore` chain and `exclude`. It checks the directories from `root`
|
|
81
|
+
* down to the file, so a file under an ignored directory is not included.
|
|
82
|
+
* The file must exist as a regular file: a path that does not exist, a
|
|
83
|
+
* symbolic link, and a path outside `root` are not included. It lists every
|
|
84
|
+
* ancestor directory of the file, so it is meant for per-file checks, not
|
|
85
|
+
* bulk use. It compares paths as given: case and symbolic links in the
|
|
86
|
+
* directories above the file are not resolved.
|
|
87
|
+
*/
|
|
88
|
+
export declare function isDiscoverable(path: string, root: string, io: DiscoveryIO, options?: DiscoverOptions): Promise<boolean>;
|
|
70
89
|
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/discovery/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/discovery/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAYH,OAAO,EAAE,KAAK,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE/E;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAmBhD,CAAC;AAEH,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAAoB,CAAC;AAEzE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAyB,CAAC;AAE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