@driftsys/markspec 0.12.0 → 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/config/markspec.d.ts +2 -2
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +47 -5
- 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/discovery/projects.d.ts +6 -4
- package/esm/discovery/projects.d.ts.map +1 -1
- package/esm/discovery/projects.js +27 -17
- package/esm/formatter/entry_body.d.ts +13 -12
- package/esm/formatter/entry_body.d.ts.map +1 -1
- package/esm/formatter/entry_body.js +25 -17
- 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/md_equiv.d.ts +6 -5
- package/esm/formatter/md_equiv.d.ts.map +1 -1
- package/esm/formatter/md_equiv.js +6 -5
- package/esm/formatter/mod.d.ts +25 -3
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +267 -27
- package/esm/formatter/tab_markers.d.ts +15 -0
- package/esm/formatter/tab_markers.d.ts.map +1 -0
- package/esm/formatter/tab_markers.js +133 -0
- package/esm/gates/mod.d.ts +2 -2
- package/esm/gates/mod.d.ts.map +1 -1
- package/esm/gates/mod.js +18 -3
- 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/lock/upstream_deps.js +1 -1
- package/esm/mod.d.ts +24 -6
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +19 -5
- package/esm/model/mod.d.ts +43 -2
- 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 +8 -3
- package/esm/refs/mod.d.ts.map +1 -1
- package/esm/refs/mod.js +20 -7
- 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/sync/mapping.d.ts +4 -3
- package/esm/sync/mapping.d.ts.map +1 -1
- package/esm/sync/mapping.js +52 -9
- package/esm/util/display_id.d.ts +20 -0
- package/esm/util/display_id.d.ts.map +1 -0
- package/esm/util/display_id.js +19 -0
- 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 +10 -16
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +37 -16
- 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/config/markspec.d.ts +2 -2
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +47 -5
- 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/discovery/projects.d.ts +6 -4
- package/script/discovery/projects.d.ts.map +1 -1
- package/script/discovery/projects.js +27 -17
- package/script/formatter/entry_body.d.ts +13 -12
- package/script/formatter/entry_body.d.ts.map +1 -1
- package/script/formatter/entry_body.js +25 -17
- 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/md_equiv.d.ts +6 -5
- package/script/formatter/md_equiv.d.ts.map +1 -1
- package/script/formatter/md_equiv.js +6 -5
- package/script/formatter/mod.d.ts +25 -3
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +266 -26
- package/script/formatter/tab_markers.d.ts +15 -0
- package/script/formatter/tab_markers.d.ts.map +1 -0
- package/script/formatter/tab_markers.js +141 -0
- package/script/gates/mod.d.ts +2 -2
- package/script/gates/mod.d.ts.map +1 -1
- package/script/gates/mod.js +18 -3
- 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/lock/upstream_deps.js +1 -1
- package/script/mod.d.ts +24 -6
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +48 -6
- package/script/model/mod.d.ts +43 -2
- 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 +8 -3
- package/script/refs/mod.d.ts.map +1 -1
- package/script/refs/mod.js +20 -7
- 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/sync/mapping.d.ts +4 -3
- package/script/sync/mapping.d.ts.map +1 -1
- package/script/sync/mapping.js +52 -9
- package/script/util/display_id.d.ts +20 -0
- package/script/util/display_id.d.ts.map +1 -0
- package/script/util/display_id.js +22 -0
- 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 +10 -16
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +36 -16
- 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/esm/config/mod.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { parse as parseYaml } from "@std/yaml";
|
|
8
8
|
import { dirname, join, resolve } from "@std/path";
|
|
9
|
+
import { fullFormats } from "ajv-formats/dist/formats.js";
|
|
9
10
|
import { ConfigError, DEFAULT_PROJECT_CONFIG, } from "../model/mod.js";
|
|
10
11
|
/** The config file name used as the project root marker. */
|
|
11
12
|
export const CONFIG_FILE_NAME = "project.yaml";
|
|
@@ -143,12 +144,24 @@ export function parseProjectConfig(yaml, filePath) {
|
|
|
143
144
|
// version: required string (org project schema)
|
|
144
145
|
let version = DEFAULT_PROJECT_CONFIG.version;
|
|
145
146
|
if (obj.version !== undefined && obj.version !== null && obj.version !== "") {
|
|
146
|
-
if (typeof obj.version === "
|
|
147
|
+
if (typeof obj.version === "string") {
|
|
148
|
+
version = obj.version;
|
|
149
|
+
}
|
|
150
|
+
else if (typeof obj.version === "number") {
|
|
151
|
+
// Existing tests and the guide require numeric-version coercion.
|
|
152
|
+
// This remains an exception to the org schema's string-only rule.
|
|
147
153
|
console.error(`warning: ${filePath}: version is a number (${obj.version}), ` +
|
|
148
154
|
`coerced to "${String(obj.version)}". ` +
|
|
149
155
|
`Quote it in YAML: version: "${obj.version}"`);
|
|
156
|
+
version = String(obj.version);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
errors.push({
|
|
160
|
+
field: "version",
|
|
161
|
+
message: `expected string, got ${typeof obj.version}`,
|
|
162
|
+
line: findLineNumber(yaml, "version"),
|
|
163
|
+
});
|
|
150
164
|
}
|
|
151
|
-
version = String(obj.version);
|
|
152
165
|
}
|
|
153
166
|
else {
|
|
154
167
|
errors.push({
|
|
@@ -193,6 +206,8 @@ export function parseProjectConfig(yaml, filePath) {
|
|
|
193
206
|
/** Safe upstream id: single path segment, no separators or traversal. */
|
|
194
207
|
const PROJECT_REF_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
195
208
|
const PROJECT_REF_KEYS = new Set(["url", "version", "name"]);
|
|
209
|
+
// ajv-formats provides the RFC 3986 URI validator used by schema validation.
|
|
210
|
+
const isUri = fullFormats.uri;
|
|
196
211
|
/**
|
|
197
212
|
* Parse a `dependencies:` or `references:` list of projectRef objects
|
|
198
213
|
* (`{ url (required), version?, name? }`). Pushes field errors onto
|
|
@@ -201,7 +216,7 @@ const PROJECT_REF_KEYS = new Set(["url", "version", "name"]);
|
|
|
201
216
|
* mask other unrelated errors.
|
|
202
217
|
*/
|
|
203
218
|
function parseProjectRefList(value, field, yaml, errors) {
|
|
204
|
-
if (value === undefined
|
|
219
|
+
if (value === undefined)
|
|
205
220
|
return [];
|
|
206
221
|
if (!Array.isArray(value)) {
|
|
207
222
|
errors.push({
|
|
@@ -211,6 +226,13 @@ function parseProjectRefList(value, field, yaml, errors) {
|
|
|
211
226
|
});
|
|
212
227
|
return [];
|
|
213
228
|
}
|
|
229
|
+
if (value.length === 0) {
|
|
230
|
+
errors.push({
|
|
231
|
+
field,
|
|
232
|
+
message: "must contain at least one projectRef when present",
|
|
233
|
+
line: findLineNumber(yaml, field),
|
|
234
|
+
});
|
|
235
|
+
}
|
|
214
236
|
const out = [];
|
|
215
237
|
value.forEach((item, i) => {
|
|
216
238
|
if (typeof item !== "object" || item === null || Array.isArray(item)) {
|
|
@@ -240,12 +262,24 @@ function parseProjectRefList(value, field, yaml, errors) {
|
|
|
240
262
|
});
|
|
241
263
|
return;
|
|
242
264
|
}
|
|
265
|
+
// Local paths and scp-style Git URLs are required by existing tests and
|
|
266
|
+
// documentation, although the org schema's URI format rejects them.
|
|
267
|
+
const isGitLocation = field === "dependencies" && (url.startsWith("./") || url.startsWith("../") || url.startsWith("/") ||
|
|
268
|
+
/^[A-Za-z]:\\/.test(url) ||
|
|
269
|
+
/^[^@/:\s]+@[^/:\s]+:[^\s]+$/.test(url));
|
|
270
|
+
if (!isUri(url) && !isGitLocation) {
|
|
271
|
+
errors.push({
|
|
272
|
+
field: `${field}[${i}].url`,
|
|
273
|
+
message: "must be a URI",
|
|
274
|
+
line: findLineNumber(yaml, field),
|
|
275
|
+
});
|
|
276
|
+
}
|
|
243
277
|
const ref = { url };
|
|
244
278
|
if (record.version !== undefined) {
|
|
245
|
-
if (typeof record.version !== "string"
|
|
279
|
+
if (typeof record.version !== "string") {
|
|
246
280
|
errors.push({
|
|
247
281
|
field: `${field}[${i}].version`,
|
|
248
|
-
message: "must be a
|
|
282
|
+
message: "must be a string when present",
|
|
249
283
|
line: findLineNumber(yaml, field),
|
|
250
284
|
});
|
|
251
285
|
}
|
|
@@ -266,6 +300,14 @@ function parseProjectRefList(value, field, yaml, errors) {
|
|
|
266
300
|
ref.name = record.name;
|
|
267
301
|
}
|
|
268
302
|
}
|
|
303
|
+
if (out.some((previous) => previous.url === ref.url && previous.version === ref.version &&
|
|
304
|
+
previous.name === ref.name)) {
|
|
305
|
+
errors.push({
|
|
306
|
+
field: `${field}[${i}]`,
|
|
307
|
+
message: "duplicate projectRef; list items must be unique",
|
|
308
|
+
line: findLineNumber(yaml, field),
|
|
309
|
+
});
|
|
310
|
+
}
|
|
269
311
|
out.push(ref);
|
|
270
312
|
});
|
|
271
313
|
return out;
|
|
@@ -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,133 @@
|
|
|
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 { descendantsOf } from "../model/mod.js";
|
|
23
|
+
import { extendsTransitively } from "../profile/discipline_mode.js";
|
|
24
|
+
import { normalizeLocator } from "../refs/split.js";
|
|
25
|
+
import { featureFileLine } from "../gherkin/position.js";
|
|
26
|
+
/** Matches a scenario-like keyword line. Group 2 is the raw name. */
|
|
27
|
+
const SCENARIO_RE = /^\s*(Scenario Outline|Scenario Template|Scenario|Example):\s*(.*)$/;
|
|
28
|
+
/**
|
|
29
|
+
* Collect the scenario names of one Gherkin source text, in order.
|
|
30
|
+
* `line` is the 0-based line of the keyword within `source`. Lines between
|
|
31
|
+
* doc-string delimiters (`"""` or three backticks) are skipped. `Background`
|
|
32
|
+
* and `Rule` are not scenarios. Names are trimmed but not otherwise
|
|
33
|
+
* normalized.
|
|
34
|
+
*/
|
|
35
|
+
export function scanScenarioNames(source) {
|
|
36
|
+
const found = [];
|
|
37
|
+
// The delimiter that opened the current doc string, if any. Only the same
|
|
38
|
+
// delimiter closes it.
|
|
39
|
+
let openDelimiter;
|
|
40
|
+
source.split(/\r?\n/).forEach((text, line) => {
|
|
41
|
+
const trimmed = text.trim();
|
|
42
|
+
const delimiter = trimmed.startsWith('"""')
|
|
43
|
+
? '"""'
|
|
44
|
+
: trimmed.startsWith("```")
|
|
45
|
+
? "```"
|
|
46
|
+
: undefined;
|
|
47
|
+
if (delimiter !== undefined) {
|
|
48
|
+
if (openDelimiter === undefined)
|
|
49
|
+
openDelimiter = delimiter;
|
|
50
|
+
else if (openDelimiter === delimiter)
|
|
51
|
+
openDelimiter = undefined;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (openDelimiter !== undefined)
|
|
55
|
+
return;
|
|
56
|
+
const match = SCENARIO_RE.exec(text);
|
|
57
|
+
if (match)
|
|
58
|
+
found.push({ name: match[2].trim(), line });
|
|
59
|
+
});
|
|
60
|
+
return found;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Build the criteria of an entry from its feature blocks, in source order.
|
|
64
|
+
* Only top-level fenced blocks of the body are indexed: a fence nested in a
|
|
65
|
+
* list item or another container yields no criteria.
|
|
66
|
+
* A block with an AST contributes the AST's scenarios; see the module comment
|
|
67
|
+
* for the fallback. Names are normalized with {@linkcode normalizeLocator}. The blocks of one
|
|
68
|
+
* entry form one scope: a normalized name that occurs more than once, and an
|
|
69
|
+
* empty name, are not addressable. `location.line` is the file-relative line
|
|
70
|
+
* of the keyword; `location.column` is always 1.
|
|
71
|
+
*/
|
|
72
|
+
export function buildCriteria(entry) {
|
|
73
|
+
const bodyStart = entry.bodyStartLine ?? (entry.location.line + 1);
|
|
74
|
+
const raw = [];
|
|
75
|
+
for (const block of entry.bodyAst ?? []) {
|
|
76
|
+
if (!isFeature(block))
|
|
77
|
+
continue;
|
|
78
|
+
if (block.feature !== undefined) {
|
|
79
|
+
for (const scenario of block.feature.scenarios) {
|
|
80
|
+
raw.push({
|
|
81
|
+
name: normalizeLocator(scenario.name),
|
|
82
|
+
line: featureFileLine(entry, block, scenario.range.start.line),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
// Block did not parse, or the parser was not loaded: scan it. Body-
|
|
88
|
+
// relative range line 1 is `bodyStart`; the block's first source line
|
|
89
|
+
// follows the opening fence line.
|
|
90
|
+
const firstSourceLine = bodyStart + block.range.start.line;
|
|
91
|
+
for (const { name, line } of scanScenarioNames(block.source)) {
|
|
92
|
+
raw.push({ name: normalizeLocator(name), line: firstSourceLine + line });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const counts = new Map();
|
|
96
|
+
for (const { name } of raw)
|
|
97
|
+
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
98
|
+
return raw.map(({ name, line }) => ({
|
|
99
|
+
form: "scenario",
|
|
100
|
+
name,
|
|
101
|
+
addressable: name !== "" && counts.get(name) === 1,
|
|
102
|
+
location: { file: entry.location.file, line, column: 1 },
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
/** Core types whose descendants carry criteria. */
|
|
106
|
+
const CRITERIA_BEARING_TYPES = ["Requirement", "Contract"];
|
|
107
|
+
/** `true` when `entry`'s type resolves to core Requirement or Contract —
|
|
108
|
+
* the entries that carry criteria (epic #915, decision 3). Uses the
|
|
109
|
+
* profile extends chain when a profile is loaded, else the core hierarchy.
|
|
110
|
+
* An entry without a resolved type carries no criteria. */
|
|
111
|
+
export function isCriteriaBearing(entry, profile) {
|
|
112
|
+
const type = entry.type;
|
|
113
|
+
if (type === undefined)
|
|
114
|
+
return false;
|
|
115
|
+
return CRITERIA_BEARING_TYPES.some((core) => profile
|
|
116
|
+
? extendsTransitively(type, core, profile)
|
|
117
|
+
: descendantsOf(core).has(type));
|
|
118
|
+
}
|
|
119
|
+
function isFeature(block) {
|
|
120
|
+
return block.kind === "feature";
|
|
121
|
+
}
|
|
122
|
+
/** `true` when `entry`'s type is, or extends, the core `Test` type — the
|
|
123
|
+
* entries whose `Verifies` links count for criterion coverage (epic #915,
|
|
124
|
+
* decision 2). Uses the profile extends chain when a profile is loaded,
|
|
125
|
+
* else the core hierarchy. */
|
|
126
|
+
export function isTestEntry(entry, profile) {
|
|
127
|
+
const type = entry.type;
|
|
128
|
+
if (type === undefined)
|
|
129
|
+
return false;
|
|
130
|
+
return profile
|
|
131
|
+
? extendsTransitively(type, "Test", profile)
|
|
132
|
+
: descendantsOf("Test").has(type);
|
|
133
|
+
}
|
package/esm/discovery/mod.d.ts
CHANGED
|
@@ -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;AAE7E,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAIlD,CAAC;AAEH;mDACmD;AACnD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACxD,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACrD;AAED,6CAA6C;AAC7C,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,QAAQ,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1C;;;6EAGyE;IACzE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;;;;;;OAQG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACxC;AA8BD;;;;GAIG;AACH,wBAAuB,aAAa,CAClC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,WAAW,EACf,OAAO,GAAE,eAAoB,GAC5B,cAAc,CAAC,MAAM,CAAC,CAaxB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,WAAW,EACf,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,OAAO,CAAC,CAgClB"}
|
package/esm/discovery/mod.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* I/O is injected via {@linkcode DiscoveryIO} so the module stays
|
|
18
18
|
* Node-compatible; entry points supply the Deno implementation.
|
|
19
19
|
*/
|
|
20
|
-
import { extname, join, relative, resolve, SEPARATOR } from "@std/path";
|
|
20
|
+
import { extname, isAbsolute, join, relative, resolve, SEPARATOR, } from "@std/path";
|
|
21
21
|
import { isIgnored, parseGitignore } from "./gitignore.js";
|
|
22
22
|
export { isIgnored, parseGitignore } from "./gitignore.js";
|
|
23
23
|
/**
|
|
@@ -47,10 +47,17 @@ export const SOURCE_EXTENSIONS = new Set([
|
|
|
47
47
|
]);
|
|
48
48
|
/** Markdown only — the `fmt` scope (the formatter never rewrites source). */
|
|
49
49
|
export const MARKDOWN_EXTENSIONS = new Set([".md"]);
|
|
50
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Gherkin `.feature` files, whose `# [ID]` header comments define entries
|
|
52
|
+
* (ADR-038). Not part of {@linkcode SOURCE_EXTENSIONS}: that set drives the
|
|
53
|
+
* tree-sitter grammars and the LSP, and `.feature` files use neither.
|
|
54
|
+
*/
|
|
55
|
+
export const FEATURE_EXTENSIONS = new Set([".feature"]);
|
|
56
|
+
/** Everything MarkSpec-relevant: markdown, source and `.feature` files. */
|
|
51
57
|
export const RELEVANT_EXTENSIONS = new Set([
|
|
52
58
|
...MARKDOWN_EXTENSIONS,
|
|
53
59
|
...SOURCE_EXTENSIONS,
|
|
60
|
+
...FEATURE_EXTENSIONS,
|
|
54
61
|
]);
|
|
55
62
|
/**
|
|
56
63
|
* Directory names pruned by default, in addition to the hidden-dir skip.
|
|
@@ -82,16 +89,104 @@ const BUILTIN_SKIP_RULES = parseGitignore(BUILTIN_SKIP_DIRS.map((d) => `${d}/`).
|
|
|
82
89
|
*/
|
|
83
90
|
export async function* discoverFiles(root, io, options = {}) {
|
|
84
91
|
const extensions = options.extensions ?? RELEVANT_EXTENSIONS;
|
|
92
|
+
const start = await walkStart(root, io, options);
|
|
93
|
+
// Carry excludes separately: they must stay after every `.gitignore`,
|
|
94
|
+
// including ones loaded deeper in the walk.
|
|
95
|
+
yield* walk(root, start.prefix, start.rules, start.excludeRules, io, extensions);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Report whether {@linkcode discoverFiles} with the same `root`, `io` and
|
|
99
|
+
* `options` would yield `path`. It applies the same rules as the walk: the
|
|
100
|
+
* extension filter, hidden directories, the built-in build-output skips, the
|
|
101
|
+
* `.gitignore` chain and `exclude`. It checks the directories from `root`
|
|
102
|
+
* down to the file, so a file under an ignored directory is not included.
|
|
103
|
+
* The file must exist as a regular file: a path that does not exist, a
|
|
104
|
+
* symbolic link, and a path outside `root` are not included. It lists every
|
|
105
|
+
* ancestor directory of the file, so it is meant for per-file checks, not
|
|
106
|
+
* bulk use. It compares paths as given: case and symbolic links in the
|
|
107
|
+
* directories above the file are not resolved.
|
|
108
|
+
*/
|
|
109
|
+
export async function isDiscoverable(path, root, io, options = {}) {
|
|
110
|
+
const extensions = options.extensions ?? RELEVANT_EXTENSIONS;
|
|
111
|
+
if (!isRelevantFile(path, extensions))
|
|
112
|
+
return false;
|
|
113
|
+
const rel = relative(resolve(root), resolve(path));
|
|
114
|
+
if (rel === "" || rel === ".." || rel.startsWith(`..${SEPARATOR}`) ||
|
|
115
|
+
isAbsolute(rel)) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
const segments = rel.split(SEPARATOR);
|
|
119
|
+
const start = await walkStart(root, io, options);
|
|
120
|
+
let rules = start.rules;
|
|
121
|
+
let absDir = root;
|
|
122
|
+
let relDir = start.prefix;
|
|
123
|
+
for (let i = 0; i < segments.length; i++) {
|
|
124
|
+
const gitignoreRules = await rulesForDirectory(absDir, relDir, rules, io);
|
|
125
|
+
const active = [...gitignoreRules, ...start.excludeRules];
|
|
126
|
+
const name = segments[i];
|
|
127
|
+
const entryRel = relDir === "" ? name : `${relDir}/${name}`;
|
|
128
|
+
const isLast = i === segments.length - 1;
|
|
129
|
+
// The walk yields only entries that report isFile or isDirectory, so a
|
|
130
|
+
// symbolic link, or a path that does not exist, is not discoverable.
|
|
131
|
+
const kind = await entryKind(absDir, name, io);
|
|
132
|
+
if (isLast ? kind !== "file" : kind !== "directory")
|
|
133
|
+
return false;
|
|
134
|
+
if (isLast)
|
|
135
|
+
return !isIgnored(entryRel, false, active);
|
|
136
|
+
if (isPrunedDirectory(name, entryRel, active))
|
|
137
|
+
return false;
|
|
138
|
+
rules = gitignoreRules;
|
|
139
|
+
absDir = join(absDir, name);
|
|
140
|
+
relDir = entryRel;
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
/** The kind of the entry `name` in `absDir`, as the walk sees it. */
|
|
145
|
+
async function entryKind(absDir, name, io) {
|
|
146
|
+
try {
|
|
147
|
+
for await (const e of io.readDir(absDir)) {
|
|
148
|
+
if (e.name !== name)
|
|
149
|
+
continue;
|
|
150
|
+
return e.isDirectory ? "directory" : e.isFile ? "file" : undefined;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
// An unreadable directory is skipped by the walk.
|
|
155
|
+
}
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
/** The starting rule state of a walk of `root`, shared by the walk and
|
|
159
|
+
* {@linkcode isDiscoverable}. `prefix` is the path of `root` below the
|
|
160
|
+
* folder the rules are anchored at. */
|
|
161
|
+
async function walkStart(root, io, options) {
|
|
85
162
|
const inherited = options.inheritGitignoreFrom === undefined
|
|
86
163
|
? { rules: [], prefix: "" }
|
|
87
164
|
: await inheritedGitignoreRules(options.inheritGitignoreFrom, root, io);
|
|
88
165
|
// With inherited rules, every rule is matched against paths relative to
|
|
89
166
|
// the enclosing folder, so `prefix` is the path from it down to `root`.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
167
|
+
return {
|
|
168
|
+
prefix: inherited.prefix,
|
|
169
|
+
rules: [...BUILTIN_SKIP_RULES, ...inherited.rules],
|
|
170
|
+
excludeRules: parseGitignore((options.exclude ?? []).join("\n"), inherited.prefix),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/** `true` when a file has one of the `extensions`. */
|
|
174
|
+
function isRelevantFile(path, extensions) {
|
|
175
|
+
return extensions.has(extname(path).toLowerCase());
|
|
176
|
+
}
|
|
177
|
+
/** `true` when the walk does not enter a directory: hidden, or ignored.
|
|
178
|
+
* Git semantics: paths under an ignored directory cannot be re-included, so
|
|
179
|
+
* pruning is correct. */
|
|
180
|
+
function isPrunedDirectory(name, rel, active) {
|
|
181
|
+
return name.startsWith(".") || isIgnored(rel, true, active);
|
|
182
|
+
}
|
|
183
|
+
/** The `.gitignore` rules in force inside `absDir`: the inherited `rules`
|
|
184
|
+
* followed by the directory's own `.gitignore`, so deeper rules win. */
|
|
185
|
+
async function rulesForDirectory(absDir, relDir, rules, io) {
|
|
186
|
+
const raw = await io.readFile(join(absDir, ".gitignore"));
|
|
187
|
+
return raw !== undefined && raw.length > 0
|
|
188
|
+
? [...rules, ...parseGitignore(raw, relDir)]
|
|
189
|
+
: rules;
|
|
95
190
|
}
|
|
96
191
|
/**
|
|
97
192
|
* Collect the `.gitignore` rules of the folders from `from` down to the
|
|
@@ -122,10 +217,7 @@ async function inheritedGitignoreRules(from, root, io) {
|
|
|
122
217
|
async function* walk(absDir, relDir, rules, excludeRules, io, extensions) {
|
|
123
218
|
// Deeper `.gitignore` rules win over inherited ones. Excludes stay last
|
|
124
219
|
// for this directory's decisions, but are not inherited as gitignore rules.
|
|
125
|
-
const
|
|
126
|
-
const gitignoreRules = raw !== undefined && raw.length > 0
|
|
127
|
-
? [...rules, ...parseGitignore(raw, relDir)]
|
|
128
|
-
: rules;
|
|
220
|
+
const gitignoreRules = await rulesForDirectory(absDir, relDir, rules, io);
|
|
129
221
|
const active = [...gitignoreRules, ...excludeRules];
|
|
130
222
|
const entries = [];
|
|
131
223
|
try {
|
|
@@ -139,16 +231,12 @@ async function* walk(absDir, relDir, rules, excludeRules, io, extensions) {
|
|
|
139
231
|
for (const entry of entries) {
|
|
140
232
|
const rel = relDir === "" ? entry.name : `${relDir}/${entry.name}`;
|
|
141
233
|
if (entry.isDirectory) {
|
|
142
|
-
if (entry.name
|
|
143
|
-
continue; // built-in: hidden dirs
|
|
144
|
-
// Git semantics: paths under an ignored directory cannot be
|
|
145
|
-
// re-included, so pruning here is correct (and fast).
|
|
146
|
-
if (isIgnored(rel, true, active))
|
|
234
|
+
if (isPrunedDirectory(entry.name, rel, active))
|
|
147
235
|
continue;
|
|
148
236
|
yield* walk(join(absDir, entry.name), rel, gitignoreRules, excludeRules, io, extensions);
|
|
149
237
|
}
|
|
150
238
|
else if (entry.isFile) {
|
|
151
|
-
if (!
|
|
239
|
+
if (!isRelevantFile(entry.name, extensions))
|
|
152
240
|
continue;
|
|
153
241
|
if (isIgnored(rel, false, active))
|
|
154
242
|
continue;
|
|
@@ -32,10 +32,12 @@ export declare function resolveConfigRoot(startDir: string, readFile: (path: str
|
|
|
32
32
|
* `exclude`). Each discovered `project.yaml` or `.markspec.yaml` is
|
|
33
33
|
* resolved with {@linkcode resolveConfigRoot} from its own directory, so a
|
|
34
34
|
* `.markspec.yaml` below a `project.yaml` is not a root of its own — the
|
|
35
|
-
* same answer the CLI gives for a file there.
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
35
|
+
* same answer the CLI gives for a file there. Each found root is scanned
|
|
36
|
+
* again with its own exclude list, so its negations can re-include non-hidden
|
|
37
|
+
* folders that the enclosing project's walk skipped. A found root is dropped
|
|
38
|
+
* when the start root's exclude list or the `.markspec.yaml` `exclude:` list
|
|
39
|
+
* of another found root above it covers it: each project's exclude list applies
|
|
40
|
+
* to its own subtree, with patterns relative to that project. The result is sorted.
|
|
39
41
|
*/
|
|
40
42
|
export declare function findNestedProjectRoots(root: string, io: DiscoveryIO, exclude?: readonly string[]): Promise<string[]>;
|
|
41
43
|
/** Options for {@linkcode discoverProjectRoots}. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../../src/discovery/projects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAS3D,4DAA4D;AAC5D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAM5D;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,GACtB,MAAM,GAAG,SAAS,CAOpB;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GACtD,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAG7B;AAED
|
|
1
|
+
{"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../../src/discovery/projects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAS3D,4DAA4D;AAC5D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAM5D;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,GACtB,MAAM,GAAG,SAAS,CAOpB;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GACtD,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAG7B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,WAAW,EACf,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAC1B,OAAO,CAAC,MAAM,EAAE,CAAC,CA+CnB;AAgBD,oDAAoD;AACpD,MAAM,WAAW,uBAAuB;IACtC;qCACiC;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,WAAW,EACf,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAoBnD;AAED;4CAC4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAClD;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C;;;;;;OAMG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACvD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,WAAW,EACf,OAAO,GAAE,uBAA4B,GACpC,mBAAmB,CAqErB"}
|
|
@@ -59,33 +59,43 @@ export async function resolveConfigRoot(startDir, readFile) {
|
|
|
59
59
|
* `exclude`). Each discovered `project.yaml` or `.markspec.yaml` is
|
|
60
60
|
* resolved with {@linkcode resolveConfigRoot} from its own directory, so a
|
|
61
61
|
* `.markspec.yaml` below a `project.yaml` is not a root of its own — the
|
|
62
|
-
* same answer the CLI gives for a file there.
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
62
|
+
* same answer the CLI gives for a file there. Each found root is scanned
|
|
63
|
+
* again with its own exclude list, so its negations can re-include non-hidden
|
|
64
|
+
* folders that the enclosing project's walk skipped. A found root is dropped
|
|
65
|
+
* when the start root's exclude list or the `.markspec.yaml` `exclude:` list
|
|
66
|
+
* of another found root above it covers it: each project's exclude list applies
|
|
67
|
+
* to its own subtree, with patterns relative to that project. The result is sorted.
|
|
66
68
|
*/
|
|
67
69
|
export async function findNestedProjectRoots(root, io, exclude) {
|
|
68
70
|
const out = new Set();
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
const scans = [{ root, exclude }];
|
|
72
|
+
for (const scan of scans) {
|
|
73
|
+
for await (const path of discoverFiles(scan.root, io, {
|
|
74
|
+
extensions: new Set([".yaml"]),
|
|
75
|
+
exclude: scan.exclude,
|
|
76
|
+
inheritGitignoreFrom: root,
|
|
77
|
+
})) {
|
|
78
|
+
if (!CONFIG_BASENAMES.has(basename(path)))
|
|
79
|
+
continue;
|
|
80
|
+
const dir = dirname(path);
|
|
81
|
+
if (dir === scan.root)
|
|
82
|
+
continue;
|
|
83
|
+
const found = await resolveConfigRoot(dir, io.readFile);
|
|
84
|
+
if (found !== undefined && found !== root && isWithin(root, found) &&
|
|
85
|
+
!out.has(found)) {
|
|
86
|
+
out.add(found);
|
|
87
|
+
const { config } = await loadToolConfig(found, io.readFile);
|
|
88
|
+
scans.push({ root: found, exclude: config.exclude });
|
|
89
|
+
}
|
|
81
90
|
}
|
|
82
91
|
}
|
|
83
92
|
const nested = [...out];
|
|
84
93
|
const excludeRules = new Map();
|
|
94
|
+
excludeRules.set(root, parseGitignore((exclude ?? []).join("\n"), ""));
|
|
85
95
|
const kept = [];
|
|
86
96
|
for (const candidate of nested) {
|
|
87
97
|
let covered = false;
|
|
88
|
-
for (const ancestor of nested) {
|
|
98
|
+
for (const ancestor of [root, ...nested]) {
|
|
89
99
|
if (ancestor === candidate || !isWithin(ancestor, candidate))
|
|
90
100
|
continue;
|
|
91
101
|
let rules = excludeRules.get(ancestor);
|
|
@@ -34,13 +34,11 @@ export type EntryBodyEdit = {
|
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
36
|
* 0-based content column of the list item whose marker starts at `marker`
|
|
37
|
-
* on `line`: the marker column, plus 1 for the bullet, plus the
|
|
38
|
-
* after it.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* start with a bullet and a space at `marker`, the marker column plus 2 is
|
|
43
|
-
* used as a fallback.
|
|
37
|
+
* on `line`: the marker column, plus 1 for the bullet, plus the whitespace
|
|
38
|
+
* after it. Tabs advance to the next four-column CommonMark tab stop.
|
|
39
|
+
* So `- [ID]` gives 2, `- [ID]` gives 4, and `-\t[ID]` gives 4 at
|
|
40
|
+
* column zero. Ordered lists never hold entries. When there is no bullet
|
|
41
|
+
* followed by whitespace at `marker`, use the marker column plus 2.
|
|
44
42
|
*/
|
|
45
43
|
export declare function contentColumn(line: string, marker: number): number;
|
|
46
44
|
/**
|
|
@@ -76,11 +74,14 @@ export declare function readEntryBody(text: string, file: string, displayId: str
|
|
|
76
74
|
* before or after the edit. So the edit is refused when an `MSL-P020`,
|
|
77
75
|
* `MSL-P021` or `MSL-P022` names the entry (the message starts with
|
|
78
76
|
* `<displayId>:`). This is broader than that case: `MSL-P020` also fires
|
|
79
|
-
* when a body
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
77
|
+
* when a body `Id:` or trace-relation line has other content after it,
|
|
78
|
+
* when an `Id:` run sits directly under prose (warning), and when a
|
|
79
|
+
* trailing trace-relation line is body prose (warning), so such an entry
|
|
80
|
+
* is refused too. An entry whose trailer-looking lines the parser reads as
|
|
81
|
+
* body without a diagnostic (for example `Note:` lines, or `Status:`
|
|
82
|
+
* directly under prose) is edited as the parser sees it: those lines are
|
|
83
|
+
* body. A final paragraph of only core keys after a blank line, such as a
|
|
84
|
+
* lone `Rationale:` line, is the trailer, not body.
|
|
84
85
|
*/
|
|
85
86
|
export declare function replaceEntryBody(text: string, file: string, displayId: string, body: string): Promise<EntryBodyEdit>;
|
|
86
87
|
//# sourceMappingURL=entry_body.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry_body.d.ts","sourceRoot":"","sources":["../../src/formatter/entry_body.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,wDAAwD;AACxD,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,GACjB,YAAY,GACZ,gBAAgB,GAChB,iBAAiB,GACjB,iBAAiB,CAAC;AAEtB,8CAA8C;AAC9C,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,CAAC;AA8E/D
|
|
1
|
+
{"version":3,"file":"entry_body.d.ts","sourceRoot":"","sources":["../../src/formatter/entry_body.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,wDAAwD;AACxD,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,GACjB,YAAY,GACZ,gBAAgB,GAChB,iBAAiB,GACjB,iBAAiB,CAAC;AAEtB,8CAA8C;AAC9C,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,CAAC;AA8E/D;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQlE;AAyCD;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAS7B;AASD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,aAAa,CAAC,CAoDxB"}
|