@hailstails/hone 2.0.0-pre.2 → 2.0.0-pre.4
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/ADOPTING.md +7 -7
- package/CHANGELOG.md +76 -0
- package/MIGRATING.md +15 -6
- package/README.md +12 -13
- package/chunks/chunk-3CWFUD5B.js +38 -0
- package/chunks/chunk-5AKHEW6V.js +15 -0
- package/chunks/chunk-75XWZYNN.js +64 -0
- package/chunks/chunk-7FVSZ2VL.js +1304 -0
- package/chunks/chunk-A3RL4O5V.js +146 -0
- package/chunks/chunk-BIDD2YWP.js +398 -0
- package/chunks/{chunk-GNOMK7CR.js → chunk-BKQ3K766.js} +489 -52
- package/chunks/{chunk-NRIQD3PI.js → chunk-BRANVR7K.js} +3 -5
- package/chunks/chunk-COQMPHWZ.js +37 -0
- package/chunks/{chunk-L7BGRC6D.js → chunk-CXM5KBZX.js} +1 -1
- package/chunks/chunk-D6645WPB.js +6 -0
- package/chunks/chunk-DJMF6JIM.js +42 -0
- package/chunks/{chunk-OKLYWD2Z.js → chunk-E4D5WDRX.js} +27 -20
- package/chunks/chunk-EBX57Z3V.js +8 -0
- package/chunks/chunk-FHVNKG5Q.js +19 -0
- package/chunks/chunk-FPIP7JEC.js +191 -0
- package/chunks/{chunk-QP5TLOBY.js → chunk-HVZVKZPW.js} +12 -9
- package/chunks/chunk-LD766VWU.js +57 -0
- package/chunks/chunk-LEFM7OPS.js +41 -0
- package/chunks/chunk-LNMDMRGQ.js +51 -0
- package/chunks/{chunk-RGSHTPLA.js → chunk-MBEDAFVC.js} +3 -11
- package/chunks/chunk-OO5KV7KN.js +17 -0
- package/chunks/{chunk-ASUN4AVC.js → chunk-PVSC4SE3.js} +71 -5
- package/chunks/chunk-SKDQ3QJD.js +75 -0
- package/chunks/chunk-W5OIAUDW.js +18 -0
- package/chunks/chunk-X73RZUPO.js +63 -0
- package/chunks/chunk-XE2KKWYH.js +45 -0
- package/chunks/chunk-YGMO5Z6U.js +432 -0
- package/chunks/chunk-YONPKP3C.js +15 -0
- package/docs/adding-a-discipline-or-mechanism.md +1 -1
- package/docs/extending.md +7 -388
- package/package.json +7 -6
- package/rules/README.md +2 -2
- package/rules/typescript/checks.md +236 -18
- package/rules/typescript/symptoms/ambient-randomness/random-call.md +10 -0
- package/rules/typescript/symptoms/answer-set-in-a-hook/hook-answer.md +10 -0
- package/rules/typescript/symptoms/assertion-outside-a-test/assertion-site.md +10 -0
- package/rules/typescript/symptoms/assertion-outside-a-test.md +25 -0
- package/rules/typescript/symptoms/built-unit-called-in-place/call-of-a-call.md +10 -0
- package/rules/typescript/symptoms/built-unit-called-in-place.md +25 -0
- package/rules/typescript/symptoms/code-or-prose-read-as-text/raw-read.md +10 -0
- package/rules/typescript/symptoms/code-or-prose-read-as-text.md +31 -0
- package/rules/typescript/symptoms/computed-value-in-a-test/test-body.md +1 -1
- package/rules/typescript/symptoms/double-with-a-body/logic-in-a-passed-function.md +1 -1
- package/rules/typescript/symptoms/double-with-a-body/stub-implementation.md +2 -2
- package/rules/typescript/symptoms/export-from-a-test-file/test-file-export.md +10 -0
- package/rules/typescript/symptoms/export-from-a-test-file.md +33 -0
- package/rules/typescript/symptoms/failure-shaped-as-success/empty-catch.md +10 -0
- package/rules/typescript/symptoms/floating-version/version-selector.md +10 -0
- package/rules/typescript/symptoms/inherited-environment-in-a-subprocess/git-spawn-environment.md +1 -1
- package/rules/typescript/symptoms/many-spellings-of-one-concept/test-call-aliases.md +10 -0
- package/rules/typescript/symptoms/many-spellings-of-one-concept.md +3 -2
- package/rules/typescript/symptoms/module-or-global-patched/module-mock-call.md +4 -4
- package/rules/typescript/symptoms/no-lock-file/committed-lock-file.md +12 -0
- package/rules/typescript/symptoms/process-global-used-in-place/debugger-statement.md +10 -0
- package/rules/typescript/symptoms/process-global-used-in-place/direct-global-use.md +14 -0
- package/rules/typescript/symptoms/process-global-used-in-place.md +1 -1
- package/rules/typescript/symptoms/prose-in-code/comment-prose.md +12 -0
- package/rules/typescript/symptoms/test-switched-off/skipped-tests.md +3 -6
- package/rules/typescript/symptoms/test-switched-off.md +1 -1
- package/rules/typescript/symptoms/throw-between-our-units/throw-statement.md +10 -0
- package/rules/typescript/symptoms/throw-or-catch-in-a-test/throw-statement.md +1 -1
- package/rules/typescript/symptoms/tool-fetched-at-run-time/fetch-command.md +10 -0
- package/rules/typescript/symptoms/type-declared-in-a-test/test-type-declaration.md +10 -0
- package/rules/typescript/symptoms/type-declared-in-a-test.md +33 -0
- package/rules/typescript/symptoms/unit-without-a-running-test/companion-test-file.md +2 -2
- package/rules/typescript/symptoms/wide-input/unread-parameter.md +10 -0
- package/rules/typescript/symptoms/wide-input.md +3 -2
- package/rules/typescript/symptoms.md +183 -121
- package/src/application/conformance/conformance-testing-types.d.ts +13 -16
- package/src/domain/language-layer/authored-item-types.d.ts +50 -0
- package/src/domain/language-layer/catalogue-name.d.ts +5 -0
- package/src/domain/language-layer/check-address-text.d.ts +12 -0
- package/src/domain/rule-set/authored-rule-set-types.d.ts +31 -32
- package/src/domain/rule-set/clause-address-types.d.ts +4 -3
- package/src/domain/rule-set/rule-set-name-of.d.ts +10 -0
- package/src/domain/runner/check-binding.d.ts +18 -0
- package/src/domain/runner/check-observations.d.ts +39 -0
- package/src/domain/runner/conformance-types.d.ts +8 -2
- package/src/domain/settings/test-files.d.ts +7 -0
- package/src/eslint-plugin.js +16 -12
- package/src/hone.js +10493 -10410
- package/src/infrastructure/engines/eslint/authored-class-or-this/static-members-only/piece.json +0 -6
- package/src/infrastructure/engines/eslint/long-function/function-length/piece.json +0 -6
- package/src/infrastructure/engines/eslint/runner/pieces/eslint-piece-settings-types.d.ts +2 -0
- package/src/infrastructure/engines/eslint/runner/runner.js +953 -1189
- package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/README.md +0 -3
- package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/eslint-plugin.js +33 -21
- package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/piece.json +11 -4
- package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/skipped-tests.examples.json +28 -0
- package/src/infrastructure/engines/eslint/untyped-value/implicit-any-let/piece.json +0 -2
- package/src/infrastructure/engines/eslint/wide-input/unread-parameter/eslint-plugin.js +94 -0
- package/src/infrastructure/engines/eslint/wide-input/unread-parameter/piece.json +11 -0
- package/src/infrastructure/engines/eslint/wide-input/unread-parameter/unread-parameter.examples.json +48 -0
- package/src/infrastructure/engines/walker/ambient-randomness/random-call/ambient-randomness.js +109 -0
- package/src/infrastructure/engines/walker/ambient-randomness/random-call/piece.json +9 -0
- package/src/infrastructure/engines/walker/ambient-randomness/random-call/random-call.examples.json +48 -0
- package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/hook-answer.examples.json +42 -0
- package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/hook-answers.js +72 -0
- package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/piece.json +9 -0
- package/src/infrastructure/engines/walker/assertion-outside-a-test/assertion-site/assertion-site.examples.json +30 -0
- package/src/infrastructure/engines/walker/assertion-outside-a-test/assertion-site/assertion-site.js +123 -0
- package/src/infrastructure/engines/walker/assertion-outside-a-test/assertion-site/piece.json +9 -0
- package/src/infrastructure/engines/walker/authored-class-or-this/class-keyword/class-syntax.js +3 -3
- package/src/infrastructure/engines/walker/boolean-in-a-signature/boolean-annotation/boolean-signatures.js +7 -5
- package/src/infrastructure/engines/walker/branch-in-a-test/test-body/test-body-logic.js +213 -126
- package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/call-of-a-call.examples.json +24 -0
- package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/call-of-a-call.js +34 -0
- package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/piece.json +9 -0
- package/src/infrastructure/engines/walker/claimed-type/cast-to-any/any-cast.js +6 -4
- package/src/infrastructure/engines/walker/claimed-type/unlisted-cast-site/cast-expressions.js +6 -4
- package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/piece.json +9 -0
- package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/raw-read.examples.json +30 -0
- package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/raw-read.js +166 -0
- package/src/infrastructure/engines/walker/computed-value-in-a-test/test-body/piece.json +0 -10
- package/src/infrastructure/engines/walker/date-used-directly/clock-sources/clock-sources.js +4 -4
- package/src/infrastructure/engines/walker/default-on-a-closed-union/default-arm/switch-defaults.js +8 -6
- package/src/infrastructure/engines/walker/double-with-a-body/logic-in-a-passed-function/piece.json +0 -10
- package/src/infrastructure/engines/walker/double-with-a-body/stub-implementation/dependency-isolation.js +9 -14
- package/src/infrastructure/engines/walker/drawer-path/drawer-names/categorical-paths.js +4 -4
- package/src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/piece.json +9 -0
- package/src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/test-file-export.examples.json +30 -0
- package/src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/test-file-export.js +31 -0
- package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/empty-catch.examples.json +18 -0
- package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/empty-catch.js +32 -0
- package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/piece.json +9 -0
- package/src/infrastructure/engines/walker/floating-version/version-selector/piece.json +9 -0
- package/src/infrastructure/engines/walker/floating-version/version-selector/version-selector.examples.json +54 -0
- package/src/infrastructure/engines/walker/floating-version/version-selector/version-selector.js +75 -0
- package/src/infrastructure/engines/walker/inherited-environment-in-a-subprocess/git-spawn-environment/hermetic-git-spawns.js +8 -17
- package/src/infrastructure/engines/walker/loop-keyword/loop-statement/loops.js +8 -6
- package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/piece.json +9 -0
- package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/test-call-aliases.examples.json +36 -0
- package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/test-call-aliases.js +67 -0
- package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/module-mock-call.examples.json +34 -0
- package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/module-mocking.js +64 -16
- package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/piece.json +5 -1
- package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/committed-lock-file.examples.json +24 -0
- package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/committed-lock-file.js +41 -0
- package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/piece.json +9 -0
- package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/import-boundaries.js +18 -16
- package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/piece.json +1 -1
- package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/debugger-statement.examples.json +18 -0
- package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/debugger-statement.js +17 -0
- package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/piece.json +9 -0
- package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/direct-global-use.examples.json +63 -0
- package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/piece.json +13 -0
- package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/process-global-used-in-place.js +126 -0
- package/src/infrastructure/engines/walker/prose-in-code/comment-prose/comment-prose.examples.json +42 -0
- package/src/infrastructure/engines/walker/prose-in-code/comment-prose/piece.json +16 -0
- package/src/infrastructure/engines/walker/prose-in-code/comment-prose/prose-in-code.js +90 -0
- package/src/infrastructure/engines/walker/rebinding/test-body/piece.json +0 -10
- package/src/infrastructure/engines/walker/runner/pieces/walker-piece.d.ts +7 -5
- package/src/infrastructure/engines/walker/runner/runner.js +266 -77
- package/src/infrastructure/engines/walker/runner/toolchain/typescript-parse.d.ts +3 -0
- package/src/infrastructure/engines/walker/shorthand-name/identifier-names/identifier-names.js +12 -7
- package/src/infrastructure/engines/walker/strictness-weakened/exact-optional-property-types/piece.json +0 -10
- package/src/infrastructure/engines/walker/strictness-weakened/no-fallthrough-cases-in-switch/piece.json +0 -10
- package/src/infrastructure/engines/walker/strictness-weakened/no-implicit-override/piece.json +0 -10
- package/src/infrastructure/engines/walker/strictness-weakened/no-property-access-from-index-signature/piece.json +0 -10
- package/src/infrastructure/engines/walker/strictness-weakened/no-unchecked-indexed-access/piece.json +0 -10
- package/src/infrastructure/engines/walker/strictness-weakened/strict/compiler-overrides.js +30 -52
- package/src/infrastructure/engines/walker/strictness-weakened/use-unknown-in-catch-variables/piece.json +0 -10
- package/src/infrastructure/engines/walker/text-past-its-reader/test-body/piece.json +0 -10
- package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/piece.json +9 -0
- package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/throw-statement.examples.json +36 -0
- package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/throws-in-production.js +12 -0
- package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/throw-statement.examples.json +6 -6
- package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/throws-in-tests.js +5 -44
- package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/try-block/piece.json +0 -10
- package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/fetch-command.examples.json +42 -0
- package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/fetch-command.js +152 -0
- package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/piece.json +9 -0
- package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/piece.json +9 -0
- package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.examples.json +24 -0
- package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.js +27 -0
- package/src/infrastructure/engines/walker/type-derived-from-code/factory-return-types/factory-return-types.js +8 -6
- package/src/infrastructure/engines/walker/unit-without-a-running-test/companion-test-file/export-test-sibling.js +16 -10
- package/src/infrastructure/engines/walker/untracked-escape/directive-pointers/comments-directives.js +18 -64
- package/src/infrastructure/engines/walker/write-into-a-parameter/parameter-mutation/parameter-mutation.js +7 -5
- package/src/rule-set.d.ts +2 -1
- package/src/testing.d.ts +2 -4
- package/src/testing.js +104 -317
- package/src/{audit.d.ts → walker.d.ts} +13 -8
- package/src/walker.js +28 -0
- package/chunks/chunk-5HRMJ4O2.js +0 -608
- package/chunks/chunk-IX2VZTBO.js +0 -887
- package/chunks/chunk-K2W3D3NB.js +0 -17
- package/chunks/chunk-M6SOGWT7.js +0 -82
- package/chunks/chunk-MWLBA4B3.js +0 -849
- package/chunks/chunk-R75QELTA.js +0 -481
- package/chunks/chunk-RANAKCTW.js +0 -31
- package/chunks/chunk-TNY2PASL.js +0 -38
- package/chunks/chunk-UJONWHA4.js +0 -22
- package/docs/output-contract.md +0 -1155
- package/src/audit.js +0 -18
- package/src/domain/runner/runner-module-types.d.ts +0 -15
|
@@ -2,38 +2,11 @@ import {
|
|
|
2
2
|
isClauseId,
|
|
3
3
|
isDisciplineId,
|
|
4
4
|
isRuleSetName
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var moduleExtensionOf = (request) => new URL(request.moduleUrl).pathname.endsWith(BUILT_MODULE_EXTENSION) ? BUILT_MODULE_EXTENSION : SOURCE_MODULE_EXTENSION;
|
|
11
|
-
var MODULE_EXTENSIONS = [
|
|
12
|
-
SOURCE_MODULE_EXTENSION,
|
|
13
|
-
BUILT_MODULE_EXTENSION
|
|
14
|
-
];
|
|
15
|
-
var moduleFileForm = (request) => MODULE_EXTENSIONS.some((extension) => request.text.endsWith(extension)) ? "module-file" : "not-module-file";
|
|
16
|
-
|
|
17
|
-
// src/infrastructure/node/modules/install-layout.ts
|
|
18
|
-
var FOLDERS_BETWEEN_INSTALL_ROOT_AND_ENTRY = {
|
|
19
|
-
api: 1,
|
|
20
|
-
command: 1,
|
|
21
|
-
runner: 5
|
|
22
|
-
};
|
|
23
|
-
var installRootAboveEntry = (request) => Array.from({ length: FOLDERS_BETWEEN_INSTALL_ROOT_AND_ENTRY[request.entry] + 1 }).reduce(
|
|
24
|
-
(path) => request.directoryOf(path),
|
|
25
|
-
request.entryFile
|
|
26
|
-
);
|
|
27
|
-
var installFormOf = (request) => request.moduleExtension === BUILT_MODULE_EXTENSION ? "package" : "source";
|
|
28
|
-
var runnerModuleSegmentsOf = (request) => [
|
|
29
|
-
request.installRoot,
|
|
30
|
-
"src",
|
|
31
|
-
"infrastructure",
|
|
32
|
-
"engines",
|
|
33
|
-
request.mechanism,
|
|
34
|
-
"runner",
|
|
35
|
-
`runner${request.moduleExtension}`
|
|
36
|
-
];
|
|
5
|
+
} from "./chunk-OO5KV7KN.js";
|
|
6
|
+
import {
|
|
7
|
+
editionOrder,
|
|
8
|
+
isEdition
|
|
9
|
+
} from "./chunk-RANIXNWY.js";
|
|
37
10
|
|
|
38
11
|
// src/infrastructure/node/file-system/file-system-port.ts
|
|
39
12
|
import {
|
|
@@ -405,6 +378,122 @@ var createPathPort = (options) => portOver({
|
|
|
405
378
|
var defaultWorkingDirectory = () => process.cwd();
|
|
406
379
|
var createDefaultPathPort = (_options) => createPathPort({ flavour: "platform", workingDirectory: defaultWorkingDirectory });
|
|
407
380
|
|
|
381
|
+
// src/domain/rule-set/tool-identity.ts
|
|
382
|
+
var identified = (identity) => identity;
|
|
383
|
+
var TOOL_IDENTITY = identified({
|
|
384
|
+
name: "Hone",
|
|
385
|
+
packageName: "@hailstails/hone",
|
|
386
|
+
command: "hone",
|
|
387
|
+
ownRuleSet: "hone",
|
|
388
|
+
reservedEslintNamespace: "hone-core",
|
|
389
|
+
description: "Checks a repository against the disciplines it selects, applies its recorded exceptions and prints one verdict.",
|
|
390
|
+
repository: "https://github.com/HailsTails/hone",
|
|
391
|
+
unrelatedNpmPackage: "hone"
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
// src/domain/rule-set/clause-address.ts
|
|
395
|
+
var TOOL_RULE_SET = TOOL_IDENTITY.ownRuleSet;
|
|
396
|
+
var CLAUSE_ADDRESS_TEXT = /^(?:(?<ruleSet>[^/#]+)\/)?(?<discipline>[^/#]+)#(?<clause>[^/#]+)$/;
|
|
397
|
+
var clauseAddressPartsOf = (request) => {
|
|
398
|
+
const parts = CLAUSE_ADDRESS_TEXT.exec(request.text)?.groups;
|
|
399
|
+
const discipline = parts?.discipline;
|
|
400
|
+
const clause = parts?.clause;
|
|
401
|
+
if (discipline === void 0 || clause === void 0) {
|
|
402
|
+
return "not-a-clause-address";
|
|
403
|
+
}
|
|
404
|
+
return {
|
|
405
|
+
ruleSet: parts?.ruleSet === void 0 || parts.ruleSet === TOOL_RULE_SET ? TOOL_RULE_SET : { name: parts.ruleSet },
|
|
406
|
+
discipline,
|
|
407
|
+
clause
|
|
408
|
+
};
|
|
409
|
+
};
|
|
410
|
+
var ruleSetOf = (request) => {
|
|
411
|
+
if (request.ruleSet === TOOL_RULE_SET) {
|
|
412
|
+
return TOOL_RULE_SET;
|
|
413
|
+
}
|
|
414
|
+
return isRuleSetName(request.ruleSet.name) && request.ruleSet.name !== TOOL_RULE_SET ? { name: request.ruleSet.name } : void 0;
|
|
415
|
+
};
|
|
416
|
+
var clauseAddressOf = (request) => {
|
|
417
|
+
const parts = clauseAddressPartsOf(request);
|
|
418
|
+
if (parts === "not-a-clause-address") {
|
|
419
|
+
return parts;
|
|
420
|
+
}
|
|
421
|
+
const ruleSet = ruleSetOf({ ruleSet: parts.ruleSet });
|
|
422
|
+
return ruleSet !== void 0 && isDisciplineId(parts.discipline) && isClauseId(parts.clause) ? { ruleSet, discipline: parts.discipline, clause: parts.clause } : "not-a-clause-address";
|
|
423
|
+
};
|
|
424
|
+
var clauseAddressText = (request) => request.address.ruleSet === TOOL_RULE_SET ? `${request.address.discipline}#${request.address.clause}` : `${request.address.ruleSet.name}/${request.address.discipline}#${request.address.clause}`;
|
|
425
|
+
var sameClauseAddress = (request) => clauseAddressText({ address: request.left }) === clauseAddressText({ address: request.right }) ? "same" : "different";
|
|
426
|
+
|
|
427
|
+
// src/application/ports/host/module-extension.ts
|
|
428
|
+
var BUILT_MODULE_EXTENSION = ".js";
|
|
429
|
+
var SOURCE_MODULE_EXTENSION = ".ts";
|
|
430
|
+
var moduleExtensionOf = (request) => new URL(request.moduleUrl).pathname.endsWith(BUILT_MODULE_EXTENSION) ? BUILT_MODULE_EXTENSION : SOURCE_MODULE_EXTENSION;
|
|
431
|
+
var MODULE_EXTENSIONS = [
|
|
432
|
+
SOURCE_MODULE_EXTENSION,
|
|
433
|
+
BUILT_MODULE_EXTENSION
|
|
434
|
+
];
|
|
435
|
+
var moduleFileForm = (request) => MODULE_EXTENSIONS.some((extension) => request.text.endsWith(extension)) ? "module-file" : "not-module-file";
|
|
436
|
+
|
|
437
|
+
// src/infrastructure/node/modules/install-layout.ts
|
|
438
|
+
var FOLDERS_BETWEEN_INSTALL_ROOT_AND_ENTRY = {
|
|
439
|
+
api: 1,
|
|
440
|
+
command: 1,
|
|
441
|
+
runner: 5
|
|
442
|
+
};
|
|
443
|
+
var installRootAboveEntry = (request) => Array.from({ length: FOLDERS_BETWEEN_INSTALL_ROOT_AND_ENTRY[request.entry] + 1 }).reduce(
|
|
444
|
+
(path) => request.directoryOf(path),
|
|
445
|
+
request.entryFile
|
|
446
|
+
);
|
|
447
|
+
var installFormOf = (request) => request.moduleExtension === BUILT_MODULE_EXTENSION ? "package" : "source";
|
|
448
|
+
var runnerModuleSegmentsOf = (request) => [
|
|
449
|
+
request.installRoot,
|
|
450
|
+
"src",
|
|
451
|
+
"infrastructure",
|
|
452
|
+
"engines",
|
|
453
|
+
request.mechanism,
|
|
454
|
+
"runner",
|
|
455
|
+
`runner${request.moduleExtension}`
|
|
456
|
+
];
|
|
457
|
+
|
|
458
|
+
// src/domain/repository/repo-path.ts
|
|
459
|
+
var UNWALKABLE_SEGMENTS = ["", ".", ".."];
|
|
460
|
+
var LEADING_DRIVE_LETTER = /^[A-Za-z]:/;
|
|
461
|
+
var LINE_BREAK_OR_NUL = /[\n\r\0]/;
|
|
462
|
+
var NOT_A_REPO_PATH = "not a repo-relative path";
|
|
463
|
+
var isRepoPathText = (request) => !request.text.startsWith("/") && !LEADING_DRIVE_LETTER.test(request.text) && !request.text.includes("\\") && !LINE_BREAK_OR_NUL.test(request.text) && request.text.split("/").every((segment) => !UNWALKABLE_SEGMENTS.includes(segment)) ? "repo-path" : "not-repo-path";
|
|
464
|
+
var isRepoPath = (text) => isRepoPathText({ text }) === "repo-path";
|
|
465
|
+
|
|
466
|
+
// src/infrastructure/content-files/parsed-json.ts
|
|
467
|
+
var parsedJson = (request) => {
|
|
468
|
+
try {
|
|
469
|
+
const parsed = JSON.parse(request.text);
|
|
470
|
+
return { outcome: "ok", value: parsed };
|
|
471
|
+
} catch (thrown) {
|
|
472
|
+
return {
|
|
473
|
+
outcome: "failed",
|
|
474
|
+
error: thrown instanceof Error ? thrown.message : String(thrown)
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
// src/domain/language-layer/catalogue-name.ts
|
|
480
|
+
var CATALOGUE_NAME = "[a-z][a-z0-9]*(?:-[a-z0-9]+)*";
|
|
481
|
+
var WHOLE_CATALOGUE_NAME = new RegExp(`^${CATALOGUE_NAME}$`);
|
|
482
|
+
var isCatalogueName = (text) => WHOLE_CATALOGUE_NAME.test(text);
|
|
483
|
+
|
|
484
|
+
// src/domain/language-layer/check-address-text.ts
|
|
485
|
+
var CHECK_ADDRESS_SEPARATOR = "#";
|
|
486
|
+
var checkNamesOf = (request) => {
|
|
487
|
+
const [symptom, check, trailingSegment] = request.text.split(CHECK_ADDRESS_SEPARATOR);
|
|
488
|
+
return trailingSegment === void 0 && symptom !== void 0 && check !== void 0 && isCatalogueName(symptom) && isCatalogueName(check) ? { symptom, check } : void 0;
|
|
489
|
+
};
|
|
490
|
+
var isCheckAddressText = (text) => checkNamesOf({ text }) !== void 0;
|
|
491
|
+
var checkAddressOfNames = (names) => `${names.symptom}${CHECK_ADDRESS_SEPARATOR}${names.check}`;
|
|
492
|
+
var checkAddressTextOf = (request) => `${request.check.symptom.name}${CHECK_ADDRESS_SEPARATOR}${request.check.name}`;
|
|
493
|
+
|
|
494
|
+
// src/domain/rule-set/engine-id.ts
|
|
495
|
+
var versionOneEngineNameOf = (engine) => engine === "walker" ? "audit" : engine;
|
|
496
|
+
|
|
408
497
|
// src/infrastructure/engines/protocol/toolchain/toolchain-requirement.ts
|
|
409
498
|
import { z as z3 } from "zod";
|
|
410
499
|
var RELEASE_PATTERN = /^(\d+)\.(\d+)\.(\d+)$/;
|
|
@@ -511,6 +600,63 @@ var loadedPeer = (request) => Promise.resolve().then(() => request.location.loca
|
|
|
511
600
|
})
|
|
512
601
|
);
|
|
513
602
|
|
|
603
|
+
// src/infrastructure/content-files/rule-sets/rule-set-reader.ts
|
|
604
|
+
import { z as z7 } from "zod";
|
|
605
|
+
|
|
606
|
+
// src/domain/rule-set/piece-folder.ts
|
|
607
|
+
var INSTALL_ENGINES_SEGMENTS = ["src", "infrastructure", "engines"];
|
|
608
|
+
var enginesFolderSegmentsOf = (request) => request.ruleSetRoot === request.installRoot ? INSTALL_ENGINES_SEGMENTS : ["engines"];
|
|
609
|
+
var versionOneEnginesFolderSegmentsOf = (request) => request.ruleSetRoot === request.installRoot ? INSTALL_ENGINES_SEGMENTS : ["mechanisms"];
|
|
610
|
+
var versionOneEngineFolderOf = (request) => request.ruleSetRoot === request.installRoot ? request.mechanism : versionOneEngineNameOf(request.mechanism);
|
|
611
|
+
var pieceFolderSegmentsOf = (request) => [
|
|
612
|
+
request.ruleSetRoot,
|
|
613
|
+
...versionOneEnginesFolderSegmentsOf(request),
|
|
614
|
+
versionOneEngineFolderOf(request),
|
|
615
|
+
request.discipline
|
|
616
|
+
];
|
|
617
|
+
var namedPieceFolderSegmentsOf = (request) => [
|
|
618
|
+
request.ruleSetRoot,
|
|
619
|
+
...enginesFolderSegmentsOf(request),
|
|
620
|
+
request.mechanism,
|
|
621
|
+
request.symptom,
|
|
622
|
+
request.check
|
|
623
|
+
];
|
|
624
|
+
|
|
625
|
+
// src/domain/settings/clause-settings/reserved-edition-setting.ts
|
|
626
|
+
var RESERVED_EDITION_SETTING = "edition";
|
|
627
|
+
|
|
628
|
+
// src/domain/settings/json-values/json-kind.ts
|
|
629
|
+
var JSON_KIND_NAMES = {
|
|
630
|
+
string: "a string",
|
|
631
|
+
number: "a number",
|
|
632
|
+
boolean: "a boolean",
|
|
633
|
+
null: "null",
|
|
634
|
+
array: "an array",
|
|
635
|
+
object: "an object"
|
|
636
|
+
};
|
|
637
|
+
var jsonKindOf = (request) => {
|
|
638
|
+
if (request.value === null) return "null";
|
|
639
|
+
if (Array.isArray(request.value)) return "array";
|
|
640
|
+
const kind = typeof request.value;
|
|
641
|
+
if (kind === "string" || kind === "number" || kind === "boolean") return kind;
|
|
642
|
+
return "object";
|
|
643
|
+
};
|
|
644
|
+
var isJsonObject = (candidate) => jsonKindOf({ value: candidate }) === "object";
|
|
645
|
+
var sameItems = (request) => request.left.length === request.right.length && request.left.every(
|
|
646
|
+
(leftItem, position) => sameJsonValue({ left: leftItem, right: request.right[position] }) === "same"
|
|
647
|
+
) ? "same" : "different";
|
|
648
|
+
var sameObjects = (request) => Object.keys(request.left).length === Object.keys(request.right).length && Object.entries(request.left).every(
|
|
649
|
+
([key, leftEntry]) => Object.hasOwn(request.right, key) && sameJsonValue({ left: leftEntry, right: request.right[key] }) === "same"
|
|
650
|
+
) ? "same" : "different";
|
|
651
|
+
var sameJsonValue = (request) => {
|
|
652
|
+
const { left, right } = request;
|
|
653
|
+
if (right === void 0 || jsonKindOf({ value: left }) !== jsonKindOf({ value: right }))
|
|
654
|
+
return "different";
|
|
655
|
+
if (Array.isArray(left) && Array.isArray(right)) return sameItems({ left, right });
|
|
656
|
+
if (isJsonObject(left) && isJsonObject(right)) return sameObjects({ left, right });
|
|
657
|
+
return left === right ? "same" : "different";
|
|
658
|
+
};
|
|
659
|
+
|
|
514
660
|
// src/infrastructure/hone-config-file/identifiers.ts
|
|
515
661
|
import { z as z4 } from "zod";
|
|
516
662
|
var NOT_AN_IDENTIFIER = "not an identifier of its kind";
|
|
@@ -519,6 +665,10 @@ var ruleSetNameSchema = brandedTextSchema({
|
|
|
519
665
|
isBranded: isRuleSetName,
|
|
520
666
|
refusal: NOT_AN_IDENTIFIER
|
|
521
667
|
});
|
|
668
|
+
var ruleSetIdentitySchema = z4.union([
|
|
669
|
+
z4.literal(TOOL_RULE_SET),
|
|
670
|
+
z4.strictObject({ name: ruleSetNameSchema.refine((name) => name !== TOOL_RULE_SET) })
|
|
671
|
+
]);
|
|
522
672
|
var disciplineIdSchema = brandedTextSchema({
|
|
523
673
|
text: z4.string(),
|
|
524
674
|
isBranded: isDisciplineId,
|
|
@@ -535,14 +685,6 @@ var versionOneEngineIdSchema = z4.union([
|
|
|
535
685
|
z4.literal("audit").transform(() => "walker")
|
|
536
686
|
]);
|
|
537
687
|
|
|
538
|
-
// src/domain/repository/repo-path.ts
|
|
539
|
-
var UNWALKABLE_SEGMENTS = ["", ".", ".."];
|
|
540
|
-
var LEADING_DRIVE_LETTER = /^[A-Za-z]:/;
|
|
541
|
-
var LINE_BREAK_OR_NUL = /[\n\r\0]/;
|
|
542
|
-
var NOT_A_REPO_PATH = "not a repo-relative path";
|
|
543
|
-
var isRepoPathText = (request) => !request.text.startsWith("/") && !LEADING_DRIVE_LETTER.test(request.text) && !request.text.includes("\\") && !LINE_BREAK_OR_NUL.test(request.text) && request.text.split("/").every((segment) => !UNWALKABLE_SEGMENTS.includes(segment)) ? "repo-path" : "not-repo-path";
|
|
544
|
-
var isRepoPath = (text) => isRepoPathText({ text }) === "repo-path";
|
|
545
|
-
|
|
546
688
|
// src/infrastructure/hone-records-folder/repo-path.ts
|
|
547
689
|
import { z as z5 } from "zod";
|
|
548
690
|
var repoPathTextSchema = z5.string().superRefine((text, context) => {
|
|
@@ -553,23 +695,274 @@ var repoPathTextSchema = z5.string().superRefine((text, context) => {
|
|
|
553
695
|
var brandedRepoPathSchema = (request) => brandedTextSchema({ text: request.text, isBranded: isRepoPath, refusal: NOT_A_REPO_PATH });
|
|
554
696
|
var repoPathSchema = brandedRepoPathSchema({ text: repoPathTextSchema });
|
|
555
697
|
|
|
698
|
+
// src/infrastructure/content-files/edition.ts
|
|
699
|
+
import { z as z6 } from "zod";
|
|
700
|
+
var editionSchema = brandedTextSchema({
|
|
701
|
+
text: z6.string(),
|
|
702
|
+
isBranded: isEdition,
|
|
703
|
+
refusal: "not an edition: a whole number from 1, written as text"
|
|
704
|
+
});
|
|
705
|
+
var FIRST_EDITION = editionSchema.parse("1");
|
|
706
|
+
var clauseEditionsSchema = z6.tuple([editionSchema], editionSchema).default([FIRST_EDITION]).refine((editions) => editionOrder({ editions }) === "ascending", {
|
|
707
|
+
error: "editions must be listed in ascending order, each once"
|
|
708
|
+
}).transform(([first, ...later]) => ({
|
|
709
|
+
declared: [first, ...later],
|
|
710
|
+
default: first,
|
|
711
|
+
latest: later.at(-1) ?? first
|
|
712
|
+
}));
|
|
713
|
+
|
|
714
|
+
// src/infrastructure/content-files/rule-sets/rule-set-reader.ts
|
|
715
|
+
var SUPPORTED_VERSION = 1;
|
|
716
|
+
var readVersionOneJson = (request) => {
|
|
717
|
+
const text = request.fileText.read({ path: request.path });
|
|
718
|
+
if (text.outcome === "failed") {
|
|
719
|
+
return {
|
|
720
|
+
outcome: "failed",
|
|
721
|
+
error: { kind: "file-unreadable", path: request.path, detail: text.error.detail }
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
const parsed = parsedJson({ text: text.value });
|
|
725
|
+
if (parsed.outcome === "failed") {
|
|
726
|
+
return {
|
|
727
|
+
outcome: "failed",
|
|
728
|
+
error: { kind: "file-malformed", path: request.path, detail: parsed.error }
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
const document = parsed.value;
|
|
732
|
+
if (typeof document === "object" && document !== null && "version" in document && document.version !== SUPPORTED_VERSION) {
|
|
733
|
+
return {
|
|
734
|
+
outcome: "failed",
|
|
735
|
+
error: { kind: "unsupported-version", path: request.path, found: document.version }
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
return { outcome: "ok", value: document };
|
|
739
|
+
};
|
|
740
|
+
var entryCount = (entries) => entries.length > 0 ? "some" : "empty";
|
|
741
|
+
var textDistinctness = (texts) => new Set(texts).size === texts.length ? "distinct" : "repeated";
|
|
742
|
+
var sourceCaseSchema = z7.object({
|
|
743
|
+
name: z7.string(),
|
|
744
|
+
fileName: repoPathSchema,
|
|
745
|
+
source: z7.string(),
|
|
746
|
+
expectedLines: z7.array(z7.number()),
|
|
747
|
+
edition: editionSchema.optional()
|
|
748
|
+
});
|
|
749
|
+
var flagCaseSchema = sourceCaseSchema.refine(
|
|
750
|
+
(sourceCase) => entryCount(sourceCase.expectedLines) === "some",
|
|
751
|
+
{ error: "a flag case names no expected line" }
|
|
752
|
+
);
|
|
753
|
+
var allowCaseSchema = sourceCaseSchema.refine(
|
|
754
|
+
(sourceCase) => entryCount(sourceCase.expectedLines) === "empty",
|
|
755
|
+
{ error: "an allow case names expected lines" }
|
|
756
|
+
);
|
|
757
|
+
var anchorKindSchema = z7.discriminatedUnion("kind", [
|
|
758
|
+
z7.object({ kind: z7.literal("keyword"), keyword: z7.string() }),
|
|
759
|
+
z7.object({ kind: z7.literal("file") })
|
|
760
|
+
]);
|
|
761
|
+
var ruleSetMechanismSchema = z7.string().transform((text, context) => {
|
|
762
|
+
const parsed = versionOneEngineIdSchema.safeParse(text);
|
|
763
|
+
if (parsed.success) {
|
|
764
|
+
return parsed.data;
|
|
765
|
+
}
|
|
766
|
+
context.addIssue({
|
|
767
|
+
code: "custom",
|
|
768
|
+
message: `not a mechanism: expected one of ${engineIdSchema.options.join(", ")}`
|
|
769
|
+
});
|
|
770
|
+
return z7.NEVER;
|
|
771
|
+
});
|
|
772
|
+
var clauseCasesSchema = z7.object({
|
|
773
|
+
flag: z7.array(flagCaseSchema).refine((entries) => entryCount(entries) === "some", {
|
|
774
|
+
error: "a mechanical clause has no flag case"
|
|
775
|
+
}),
|
|
776
|
+
allow: z7.array(allowCaseSchema).refine((entries) => entryCount(entries) === "some", {
|
|
777
|
+
error: "a mechanical clause has no allow case"
|
|
778
|
+
})
|
|
779
|
+
});
|
|
780
|
+
var clauseDefinitionSchema = z7.discriminatedUnion("kind", [
|
|
781
|
+
z7.object({
|
|
782
|
+
kind: z7.literal("mechanical"),
|
|
783
|
+
id: clauseIdSchema,
|
|
784
|
+
summary: z7.string(),
|
|
785
|
+
mechanisms: z7.array(ruleSetMechanismSchema).refine((entries) => entryCount(entries) === "some", {
|
|
786
|
+
error: "a mechanical clause names no mechanism"
|
|
787
|
+
}),
|
|
788
|
+
anchor: anchorKindSchema,
|
|
789
|
+
exceptions: z7.enum(["allowed", "refused"]).default("allowed"),
|
|
790
|
+
cases: clauseCasesSchema
|
|
791
|
+
}).transform((clause) => ({
|
|
792
|
+
kind: clause.kind,
|
|
793
|
+
id: clause.id,
|
|
794
|
+
mechanisms: clause.mechanisms,
|
|
795
|
+
anchor: clause.anchor,
|
|
796
|
+
exceptions: clause.exceptions,
|
|
797
|
+
cases: clause.cases
|
|
798
|
+
})),
|
|
799
|
+
z7.object({
|
|
800
|
+
kind: z7.literal("judgement"),
|
|
801
|
+
id: clauseIdSchema,
|
|
802
|
+
summary: z7.string(),
|
|
803
|
+
enforcedBy: z7.literal("review")
|
|
804
|
+
}).transform((clause) => ({ kind: clause.kind, id: clause.id, enforcedBy: clause.enforcedBy }))
|
|
805
|
+
]);
|
|
806
|
+
var disciplineFileSchema = z7.object({
|
|
807
|
+
version: z7.literal(SUPPORTED_VERSION),
|
|
808
|
+
id: disciplineIdSchema,
|
|
809
|
+
clauses: z7.array(clauseDefinitionSchema).refine((clauses) => textDistinctness(clauses.map((clause) => clause.id)) === "distinct", {
|
|
810
|
+
error: "two clauses share an id"
|
|
811
|
+
})
|
|
812
|
+
});
|
|
813
|
+
var clauseSettingDeclarationSchema = z7.strictObject({
|
|
814
|
+
default: z7.json(),
|
|
815
|
+
choices: z7.array(z7.json()).min(1).optional()
|
|
816
|
+
}).superRefine((declaration, context) => {
|
|
817
|
+
if (declaration.choices === void 0) return;
|
|
818
|
+
const defaultKind = jsonKindOf({ value: declaration.default });
|
|
819
|
+
if (declaration.choices.some((choice) => jsonKindOf({ value: choice }) !== defaultKind)) {
|
|
820
|
+
context.addIssue({
|
|
821
|
+
code: "custom",
|
|
822
|
+
path: ["choices"],
|
|
823
|
+
message: `every choice must be ${JSON_KIND_NAMES[defaultKind]}, as the default is`
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
if (!declaration.choices.some(
|
|
827
|
+
(choice) => sameJsonValue({ left: choice, right: declaration.default }) === "same"
|
|
828
|
+
)) {
|
|
829
|
+
context.addIssue({
|
|
830
|
+
code: "custom",
|
|
831
|
+
path: ["default"],
|
|
832
|
+
message: "the default must be one of the choices"
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
var pieceFileSchema = z7.object({
|
|
837
|
+
version: z7.literal(SUPPORTED_VERSION),
|
|
838
|
+
discipline: disciplineIdSchema,
|
|
839
|
+
mechanism: ruleSetMechanismSchema,
|
|
840
|
+
clauses: z7.array(
|
|
841
|
+
z7.object({
|
|
842
|
+
clause: clauseIdSchema,
|
|
843
|
+
settings: z7.unknown(),
|
|
844
|
+
clauseSettings: z7.record(z7.string().min(1), clauseSettingDeclarationSchema).default({}).refine((declarations) => !Object.hasOwn(declarations, RESERVED_EDITION_SETTING), {
|
|
845
|
+
error: `${RESERVED_EDITION_SETTING} is reserved for the clause's editions; declare them under editions`
|
|
846
|
+
}),
|
|
847
|
+
editions: clauseEditionsSchema
|
|
848
|
+
})
|
|
849
|
+
).refine((entries) => textDistinctness(entries.map((entry) => entry.clause)) === "distinct", {
|
|
850
|
+
error: "two entries name the same clause"
|
|
851
|
+
})
|
|
852
|
+
});
|
|
853
|
+
var isContentRefusal = (issue) => issue.code === "custom";
|
|
854
|
+
var schemaRefusal = (request) => {
|
|
855
|
+
const detail = z7.prettifyError(request.error);
|
|
856
|
+
return request.error.issues.every(isContentRefusal) ? { kind: "rule-set-invalid", path: request.path, detail } : { kind: "file-malformed", path: request.path, detail };
|
|
857
|
+
};
|
|
858
|
+
var ruleSetInvalid = (request) => ({
|
|
859
|
+
outcome: "failed",
|
|
860
|
+
error: { kind: "rule-set-invalid", path: request.path, detail: request.detail }
|
|
861
|
+
});
|
|
862
|
+
var disciplineFilePath = (request) => request.path.join({
|
|
863
|
+
segments: [request.ruleSetRoot, "rules", request.discipline, "discipline.json"]
|
|
864
|
+
});
|
|
865
|
+
var pieceFilePath = (request) => request.path.join({ segments: [...pieceFolderSegmentsOf(request), "piece.json"] });
|
|
866
|
+
var clauseSummariesSchema = z7.object({
|
|
867
|
+
clauses: z7.array(z7.object({ id: clauseIdSchema, summary: z7.string() }))
|
|
868
|
+
});
|
|
869
|
+
var disciplineOfDocument = (request) => {
|
|
870
|
+
const { path } = request;
|
|
871
|
+
const parsed = disciplineFileSchema.safeParse(request.document);
|
|
872
|
+
if (!parsed.success) {
|
|
873
|
+
return { outcome: "failed", error: schemaRefusal({ path, error: parsed.error }) };
|
|
874
|
+
}
|
|
875
|
+
if (parsed.data.id !== request.discipline) {
|
|
876
|
+
return ruleSetInvalid({
|
|
877
|
+
path,
|
|
878
|
+
detail: `id ${parsed.data.id} differs from its folder name ${request.discipline}`
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
return { outcome: "ok", value: parsed.data };
|
|
882
|
+
};
|
|
883
|
+
var readSummarisedDisciplineFile = (request) => {
|
|
884
|
+
const document = readVersionOneJson(request);
|
|
885
|
+
if (document.outcome === "failed") {
|
|
886
|
+
return document;
|
|
887
|
+
}
|
|
888
|
+
const file = disciplineOfDocument({ ...request, document: document.value });
|
|
889
|
+
if (file.outcome === "failed") {
|
|
890
|
+
return file;
|
|
891
|
+
}
|
|
892
|
+
const summaries = clauseSummariesSchema.safeParse(document.value);
|
|
893
|
+
return summaries.success ? {
|
|
894
|
+
outcome: "ok",
|
|
895
|
+
value: {
|
|
896
|
+
file: file.value,
|
|
897
|
+
summaries: new Map(summaries.data.clauses.map(({ id, summary }) => [id, summary]))
|
|
898
|
+
}
|
|
899
|
+
} : { outcome: "failed", error: schemaRefusal({ path: request.path, error: summaries.error }) };
|
|
900
|
+
};
|
|
901
|
+
var readDisciplineFile = (request) => {
|
|
902
|
+
const document = readVersionOneJson(request);
|
|
903
|
+
return document.outcome === "failed" ? document : disciplineOfDocument({ ...request, document: document.value });
|
|
904
|
+
};
|
|
905
|
+
var undeclaredCaseEditionOf = (request) => request.piece.clauses.flatMap((entry) => {
|
|
906
|
+
const definition = request.discipline.clauses.find(
|
|
907
|
+
(clause) => clause.id === entry.clause && clause.kind === "mechanical"
|
|
908
|
+
);
|
|
909
|
+
const cases = definition === void 0 ? [] : [...definition.cases.flag, ...definition.cases.allow];
|
|
910
|
+
return cases.flatMap(
|
|
911
|
+
(sourceCase) => sourceCase.edition === void 0 || entry.editions.declared.includes(sourceCase.edition) ? [] : [
|
|
912
|
+
`case ${sourceCase.name} of clause ${entry.clause} runs under edition ${sourceCase.edition}, which this piece does not declare; it declares ${entry.editions.declared.join(", ")}`
|
|
913
|
+
]
|
|
914
|
+
);
|
|
915
|
+
}).at(0);
|
|
916
|
+
var readPieceFile = (request) => {
|
|
917
|
+
const path = pieceFilePath({
|
|
918
|
+
path: request.path,
|
|
919
|
+
ruleSetRoot: request.ruleSetRoot,
|
|
920
|
+
installRoot: request.installRoot,
|
|
921
|
+
mechanism: request.mechanism,
|
|
922
|
+
discipline: request.discipline.id
|
|
923
|
+
});
|
|
924
|
+
const document = readVersionOneJson({ fileText: request.fileText, path });
|
|
925
|
+
if (document.outcome === "failed") {
|
|
926
|
+
return document;
|
|
927
|
+
}
|
|
928
|
+
const parsed = pieceFileSchema.safeParse(document.value);
|
|
929
|
+
if (!parsed.success) {
|
|
930
|
+
return { outcome: "failed", error: schemaRefusal({ path, error: parsed.error }) };
|
|
931
|
+
}
|
|
932
|
+
const piece = parsed.data;
|
|
933
|
+
if (piece.discipline !== request.discipline.id) {
|
|
934
|
+
return ruleSetInvalid({
|
|
935
|
+
path,
|
|
936
|
+
detail: `discipline ${piece.discipline} differs from its folder name ${request.discipline.id}`
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
if (piece.mechanism !== request.mechanism) {
|
|
940
|
+
return ruleSetInvalid({
|
|
941
|
+
path,
|
|
942
|
+
detail: `mechanism ${piece.mechanism} differs from its folder name ${request.mechanism}`
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
const declared = request.discipline.clauses.map((clause) => clause.id);
|
|
946
|
+
const undeclared = piece.clauses.find((entry) => !declared.includes(entry.clause));
|
|
947
|
+
if (undeclared !== void 0) {
|
|
948
|
+
return ruleSetInvalid({
|
|
949
|
+
path,
|
|
950
|
+
detail: `clause ${undeclared.clause} is not declared by discipline ${request.discipline.id}`
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
const unsupported = undeclaredCaseEditionOf({ piece, discipline: request.discipline });
|
|
954
|
+
if (unsupported !== void 0) {
|
|
955
|
+
return ruleSetInvalid({ path, detail: unsupported });
|
|
956
|
+
}
|
|
957
|
+
return { outcome: "ok", value: piece };
|
|
958
|
+
};
|
|
959
|
+
|
|
556
960
|
export {
|
|
557
|
-
brandedTextSchema,
|
|
558
|
-
ruleSetNameSchema,
|
|
559
|
-
disciplineIdSchema,
|
|
560
|
-
clauseIdSchema,
|
|
561
|
-
engineIdSchema,
|
|
562
|
-
versionOneEngineIdSchema,
|
|
563
961
|
isRepoPathText,
|
|
564
962
|
isRepoPath,
|
|
565
963
|
repoPathTextSchema,
|
|
566
964
|
brandedRepoPathSchema,
|
|
567
965
|
repoPathSchema,
|
|
568
|
-
moduleExtensionOf,
|
|
569
|
-
moduleFileForm,
|
|
570
|
-
installRootAboveEntry,
|
|
571
|
-
installFormOf,
|
|
572
|
-
runnerModuleSegmentsOf,
|
|
573
966
|
failureDetailOf,
|
|
574
967
|
createDefaultFileTextPort,
|
|
575
968
|
createDefaultFileRemovalPort,
|
|
@@ -580,9 +973,53 @@ export {
|
|
|
580
973
|
createDefaultModuleLoaderPort,
|
|
581
974
|
isAbsolutePath,
|
|
582
975
|
absolutePathSchema,
|
|
976
|
+
createPathPort,
|
|
583
977
|
createDefaultPathPort,
|
|
978
|
+
TOOL_IDENTITY,
|
|
979
|
+
parsedJson,
|
|
980
|
+
TOOL_RULE_SET,
|
|
981
|
+
clauseAddressPartsOf,
|
|
982
|
+
clauseAddressOf,
|
|
983
|
+
clauseAddressText,
|
|
984
|
+
sameClauseAddress,
|
|
985
|
+
CATALOGUE_NAME,
|
|
986
|
+
isCatalogueName,
|
|
987
|
+
CHECK_ADDRESS_SEPARATOR,
|
|
988
|
+
checkNamesOf,
|
|
989
|
+
isCheckAddressText,
|
|
990
|
+
checkAddressOfNames,
|
|
991
|
+
checkAddressTextOf,
|
|
992
|
+
JSON_KIND_NAMES,
|
|
993
|
+
jsonKindOf,
|
|
994
|
+
sameJsonValue,
|
|
995
|
+
RESERVED_EDITION_SETTING,
|
|
996
|
+
moduleExtensionOf,
|
|
997
|
+
moduleFileForm,
|
|
998
|
+
installRootAboveEntry,
|
|
999
|
+
installFormOf,
|
|
1000
|
+
runnerModuleSegmentsOf,
|
|
1001
|
+
versionOneEngineNameOf,
|
|
584
1002
|
NOT_INSTALLED,
|
|
585
1003
|
gatheredPeerFailure,
|
|
586
1004
|
installedPeer,
|
|
587
|
-
loadedPeer
|
|
1005
|
+
loadedPeer,
|
|
1006
|
+
pieceFolderSegmentsOf,
|
|
1007
|
+
namedPieceFolderSegmentsOf,
|
|
1008
|
+
ruleSetNameSchema,
|
|
1009
|
+
ruleSetIdentitySchema,
|
|
1010
|
+
disciplineIdSchema,
|
|
1011
|
+
clauseIdSchema,
|
|
1012
|
+
engineIdSchema,
|
|
1013
|
+
versionOneEngineIdSchema,
|
|
1014
|
+
editionSchema,
|
|
1015
|
+
readVersionOneJson,
|
|
1016
|
+
sourceCaseSchema,
|
|
1017
|
+
anchorKindSchema,
|
|
1018
|
+
clauseCasesSchema,
|
|
1019
|
+
pieceFileSchema,
|
|
1020
|
+
disciplineFilePath,
|
|
1021
|
+
pieceFilePath,
|
|
1022
|
+
readSummarisedDisciplineFile,
|
|
1023
|
+
readDisciplineFile,
|
|
1024
|
+
readPieceFile
|
|
588
1025
|
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
TOOL_RULE_SET,
|
|
3
|
+
clauseAddressPartsOf,
|
|
2
4
|
clauseIdSchema,
|
|
3
5
|
disciplineIdSchema,
|
|
4
6
|
ruleSetNameSchema
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import {
|
|
7
|
-
TOOL_RULE_SET,
|
|
8
|
-
clauseAddressPartsOf
|
|
9
|
-
} from "./chunk-M6SOGWT7.js";
|
|
7
|
+
} from "./chunk-BKQ3K766.js";
|
|
10
8
|
|
|
11
9
|
// src/infrastructure/discipline-exceptions-folder/clause-address.ts
|
|
12
10
|
import { z } from "zod";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/infrastructure/engines/walker/runner/pieces/source-scope.ts
|
|
2
|
+
var GENERATED_FOLDER_NAMES = [
|
|
3
|
+
"node_modules",
|
|
4
|
+
"dist",
|
|
5
|
+
"build",
|
|
6
|
+
"coverage",
|
|
7
|
+
".git"
|
|
8
|
+
];
|
|
9
|
+
var GENERATED_ROOT_FOLDER_NAMES = ["vendor"];
|
|
10
|
+
var folderScope = (request) => {
|
|
11
|
+
const folders = request.file.split("/").slice(0, -1);
|
|
12
|
+
return GENERATED_ROOT_FOLDER_NAMES.includes(folders[0] ?? "") || folders.some((folder) => GENERATED_FOLDER_NAMES.includes(folder)) ? "generated" : "authored";
|
|
13
|
+
};
|
|
14
|
+
var NAME_SUFFIX = /\.([^./]+)\.[^./]+$/;
|
|
15
|
+
var fileRoleOf = (request) => {
|
|
16
|
+
const folders = request.file.split("/").slice(0, -1);
|
|
17
|
+
const suffix = NAME_SUFFIX.exec(request.file)?.[1];
|
|
18
|
+
return folders.some((folder) => request.testFiles.folders.includes(folder)) || suffix !== void 0 && request.testFiles.suffixes.includes(suffix) ? "test" : "source";
|
|
19
|
+
};
|
|
20
|
+
var testFileEligibility = (request) => typeScriptSourceKindOf(request) === "test" ? "eligible" : "skipped";
|
|
21
|
+
var TYPESCRIPT_FILE = /\.(?:ts|tsx|mts|cts)$/;
|
|
22
|
+
var DECLARATION_FILE = /\.d\.(?:ts|mts|cts)$/;
|
|
23
|
+
var TEST_EXTENSION = /\.tsx?$/;
|
|
24
|
+
var typeScriptSourceEligibility = (request) => !TYPESCRIPT_FILE.test(request.file) || DECLARATION_FILE.test(request.file) || folderScope(request) === "generated" ? "skipped" : "eligible";
|
|
25
|
+
var typeScriptSourceKindOf = (request) => {
|
|
26
|
+
if (typeScriptSourceEligibility(request) === "skipped") return "skipped";
|
|
27
|
+
if (fileRoleOf(request) === "source") return "production";
|
|
28
|
+
return TEST_EXTENSION.test(request.file) ? "test" : "skipped";
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
folderScope,
|
|
33
|
+
fileRoleOf,
|
|
34
|
+
testFileEligibility,
|
|
35
|
+
typeScriptSourceEligibility,
|
|
36
|
+
typeScriptSourceKindOf
|
|
37
|
+
};
|