@md-code/follow-architecture 0.3.0 → 0.3.3
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/CHANGELOG.md +38 -0
- package/README.md +1341 -472
- package/dist/args.d.ts +4 -0
- package/dist/args.js +18 -1
- package/dist/bin/follow-architecture.js +3 -3
- package/dist/closure-project.d.ts +4 -0
- package/dist/closure-project.js +122 -0
- package/dist/code-entities/classify.d.ts +11 -0
- package/dist/code-entities/classify.js +45 -0
- package/dist/code-entities/connector.d.ts +8 -0
- package/dist/code-entities/connector.js +119 -0
- package/dist/code-entities/entities.d.ts +9 -0
- package/dist/{code-roles/roles.js → code-entities/entities.js} +81 -54
- package/dist/code-entities/project.d.ts +21 -0
- package/dist/code-entities/project.js +249 -0
- package/dist/code-entities/walk.d.ts +31 -0
- package/dist/code-entities/walk.js +95 -0
- package/dist/config-options.d.ts +23 -0
- package/dist/config-options.js +18 -1
- package/dist/config-project.js +10 -2
- package/dist/config-report.d.ts +1 -1
- package/dist/config-report.js +20 -3
- package/dist/config-rule.d.ts +25 -0
- package/dist/config-rule.js +89 -6
- package/dist/config-state.d.ts +14 -3
- package/dist/config-state.js +180 -17
- package/dist/config.d.ts +25 -0
- package/dist/css/index.d.ts +11 -7
- package/dist/css/index.js +124 -23
- package/dist/css/syntax/css/gate.js +5 -5
- package/dist/css/syntax/css/index.d.ts +1 -1
- package/dist/css/syntax/css/index.js +1 -1
- package/dist/css/syntax/css/reference.d.ts +1 -1
- package/dist/css/syntax/css/reference.js +15 -3
- package/dist/css/syntax/language.d.ts +1 -1
- package/dist/css/syntax/language.js +4 -2
- package/dist/css/syntax/scss/index.d.ts +2 -2
- package/dist/css/syntax/scss/index.js +1 -1
- package/dist/css/syntax/scss/reference.d.ts +1 -1
- package/dist/css/syntax/scss/reference.js +7 -1
- package/dist/css/syntax/styled/document.d.ts +3 -3
- package/dist/css/syntax/styled/document.js +17 -7
- package/dist/css/syntax/styled/markup.d.ts +1 -1
- package/dist/css/syntax/styled/markup.js +22 -14
- package/dist/css/syntax/styled/tags.d.ts +2 -0
- package/dist/css/syntax/styled/tags.js +22 -0
- package/dist/css/syntax/styled/template.js +10 -4
- package/dist/css/syntax/tailwind/tailwind.js +4 -4
- package/dist/css/value/check.d.ts +1 -1
- package/dist/css/value/check.js +1 -1
- package/dist/css/value/expression/arithmetic.d.ts +2 -2
- package/dist/css/value/expression/arithmetic.js +7 -3
- package/dist/css/value/expression/block.d.ts +2 -2
- package/dist/css/value/expression/block.js +4 -3
- package/dist/css/value/expression/conditional.d.ts +2 -2
- package/dist/css/value/expression/conditional.js +1 -1
- package/dist/css/value/expression/index.d.ts +2 -2
- package/dist/css/value/expression/index.js +10 -6
- package/dist/css/value/expression/map.d.ts +2 -2
- package/dist/css/value/expression/map.js +2 -2
- package/dist/css/value/object/index.d.ts +2 -2
- package/dist/css/value/object/index.js +14 -4
- package/dist/css/value/object/members.d.ts +2 -2
- package/dist/css/value/object/node.js +9 -4
- package/dist/css/value/object/path.d.ts +3 -3
- package/dist/css/value/object/path.js +10 -4
- package/dist/css/value/pieces.d.ts +3 -3
- package/dist/css/value/pieces.js +14 -4
- package/dist/css/value/resolve.js +15 -5
- package/dist/css/value/scope.d.ts +3 -2
- package/dist/css/value/scope.js +25 -7
- package/dist/css/value/substitute.js +43 -11
- package/dist/entities/architecture.d.ts +28 -25
- package/dist/entities/ast/assignments-raw.d.ts +1 -1
- package/dist/entities/ast/assignments-raw.js +61 -8
- package/dist/entities/ast/assignments-tagged.d.ts +1 -1
- package/dist/entities/ast/assignments-tagged.js +22 -7
- package/dist/entities/ast/assignments.d.ts +1 -1
- package/dist/entities/ast/assignments.js +6 -4
- package/dist/entities/ast/branches.d.ts +1 -1
- package/dist/entities/ast/calls.d.ts +1 -1
- package/dist/entities/ast/calls.js +19 -3
- package/dist/entities/ast/classes.d.ts +1 -1
- package/dist/entities/ast/classes.js +5 -1
- package/dist/entities/ast/comments.d.ts +3 -2
- package/dist/entities/ast/comments.js +47 -17
- package/dist/entities/ast/declaration.d.ts +1 -1
- package/dist/entities/ast/depth.d.ts +2 -2
- package/dist/entities/ast/depth.js +15 -8
- package/dist/entities/ast/enums.d.ts +1 -1
- package/dist/entities/ast/export-chain.d.ts +15 -0
- package/dist/entities/ast/export-chain.js +171 -0
- package/dist/entities/ast/file-exports.d.ts +1 -1
- package/dist/entities/ast/file-exports.js +26 -3
- package/dist/entities/ast/file-facts.d.ts +6 -3
- package/dist/entities/ast/file-facts.js +33 -4
- package/dist/entities/ast/file-imports.d.ts +1 -1
- package/dist/entities/ast/file-imports.js +26 -3
- package/dist/entities/ast/file.d.ts +2 -2
- package/dist/entities/ast/file.js +2 -1
- package/dist/entities/ast/functions.d.ts +1 -1
- package/dist/entities/ast/functions.js +13 -4
- package/dist/entities/ast/heritage.d.ts +1 -1
- package/dist/entities/ast/heritage.js +9 -1
- package/dist/entities/ast/index.d.ts +6 -3
- package/dist/entities/ast/index.js +82 -26
- package/dist/entities/ast/kind.d.ts +1 -1
- package/dist/entities/ast/kind.js +7 -1
- package/dist/entities/ast/modifiers.d.ts +1 -1
- package/dist/entities/ast/modifiers.js +4 -4
- package/dist/entities/ast/project.js +33 -2
- package/dist/entities/ast/properties.d.ts +1 -1
- package/dist/entities/ast/properties.js +10 -5
- package/dist/entities/ast/resolve.d.ts +1 -1
- package/dist/entities/ast/resolve.js +4 -4
- package/dist/entities/ast/tree.d.ts +4 -2
- package/dist/entities/ast/tree.js +184 -17
- package/dist/entities/ast/types.d.ts +1 -1
- package/dist/entities/ast/types.js +2 -1
- package/dist/entities/ast/usage.d.ts +1 -1
- package/dist/entities/ast/usage.js +1 -1
- package/dist/entities/ast/variables.d.ts +1 -1
- package/dist/entities/context.d.ts +4 -4
- package/dist/entities/facts.d.ts +36 -13
- package/dist/entities/findings.d.ts +3 -3
- package/dist/entities/kinds.d.ts +1 -1
- package/dist/entities/kinds.js +131 -30
- package/dist/entities/location/homes.d.ts +10 -10
- package/dist/entities/location/homes.js +74 -48
- package/dist/entities/location/place.d.ts +1 -1
- package/dist/entities/location/place.js +10 -3
- package/dist/entities/location/where.d.ts +8 -6
- package/dist/entities/location/where.js +79 -30
- package/dist/entities/location.d.ts +3 -3
- package/dist/entities/location.js +17 -17
- package/dist/entities/operators.js +1 -1
- package/dist/entities/overview/data.d.ts +6 -6
- package/dist/entities/overview/decision.d.ts +11 -11
- package/dist/entities/overview/finding.d.ts +10 -10
- package/dist/entities/overview/graph.d.ts +28 -11
- package/dist/entities/overview/input.d.ts +2 -2
- package/dist/entities/overview/summaries.d.ts +17 -15
- package/dist/entities/queries.d.ts +1 -1
- package/dist/entities/queries.js +72 -12
- package/dist/entities/repair.d.ts +1 -1
- package/dist/entities/repair.js +8 -2
- package/dist/entities/schema.d.ts +17 -3
- package/dist/entities/schema.js +74 -16
- package/dist/entities/story.d.ts +5 -5
- package/dist/entities/structure-facts.d.ts +1 -1
- package/dist/entities/token.d.ts +4 -4
- package/dist/entities/tree/build.d.ts +4 -3
- package/dist/entities/tree/build.js +95 -44
- package/dist/entities/tree/entries.d.ts +3 -3
- package/dist/entities/tree/entries.js +41 -16
- package/dist/entities/tree/index.d.ts +2 -2
- package/dist/entities/tree/index.js +1 -1
- package/dist/entities/tree/match.d.ts +2 -2
- package/dist/entities/tree/match.js +9 -5
- package/dist/fa-index.d.ts +16 -0
- package/dist/fa-index.js +165 -0
- package/dist/fa-open.d.ts +51 -0
- package/dist/fa-open.js +232 -0
- package/dist/fa-store.d.ts +22 -0
- package/dist/fa-store.js +222 -0
- package/dist/fa-values.d.ts +37 -0
- package/dist/fa-values.js +104 -0
- package/dist/facts-record.d.ts +45 -0
- package/dist/facts-record.js +287 -0
- package/dist/frameworks/angular/index.d.ts +2 -2
- package/dist/frameworks/angular/index.js +2 -1
- package/dist/frameworks/facet.d.ts +3 -1
- package/dist/frameworks/facet.js +13 -0
- package/dist/frameworks/index.d.ts +1 -1
- package/dist/frameworks/index.js +8 -4
- package/dist/frameworks/react/index.d.ts +2 -2
- package/dist/frameworks/react/index.js +33 -10
- package/dist/frameworks/test/index.d.ts +6 -0
- package/dist/frameworks/test/index.js +157 -0
- package/dist/frameworks/vue/index.d.ts +2 -2
- package/dist/frameworks/vue/index.js +2 -1
- package/dist/ignore.d.ts +3 -0
- package/dist/ignore.js +48 -0
- package/dist/index-file.d.ts +43 -0
- package/dist/index-file.js +218 -0
- package/dist/index-run.d.ts +39 -0
- package/dist/index-run.js +217 -0
- package/dist/index-zone.d.ts +25 -0
- package/dist/index-zone.js +209 -0
- package/dist/main.d.ts +5 -2
- package/dist/main.js +207 -34
- package/dist/nodes/child-entities.d.ts +3 -0
- package/dist/nodes/child-entities.js +12 -0
- package/dist/nodes/children.d.ts +4 -4
- package/dist/nodes/children.js +54 -11
- package/dist/nodes/finally/emit.d.ts +3 -3
- package/dist/nodes/finally/emit.js +26 -10
- package/dist/nodes/finally/entities.d.ts +13 -0
- package/dist/nodes/finally/entities.js +42 -0
- package/dist/nodes/finally/index.d.ts +6 -6
- package/dist/nodes/finally/index.js +8 -8
- package/dist/nodes/finally/queries.d.ts +2 -2
- package/dist/nodes/finally/queries.js +7 -4
- package/dist/nodes/finally/relations-access.d.ts +2 -2
- package/dist/nodes/finally/relations-access.js +22 -18
- package/dist/nodes/finally/relations-edge.d.ts +5 -5
- package/dist/nodes/finally/relations-edge.js +67 -44
- package/dist/nodes/finally/relations-group.d.ts +7 -7
- package/dist/nodes/finally/relations-group.js +28 -25
- package/dist/nodes/finally/relations.d.ts +2 -2
- package/dist/nodes/finally/relations.js +16 -12
- package/dist/nodes/finally/required.d.ts +3 -3
- package/dist/nodes/finally/required.js +9 -7
- package/dist/nodes/finally/violation.d.ts +2 -2
- package/dist/nodes/similar.d.ts +3 -3
- package/dist/nodes/similar.js +61 -49
- package/dist/piece-forms.d.ts +9 -0
- package/dist/piece-forms.js +68 -0
- package/dist/{pipeline-roles.d.ts → pipeline-entities.d.ts} +2 -2
- package/dist/{pipeline-roles.js → pipeline-entities.js} +32 -28
- package/dist/pipeline-facts.d.ts +4 -3
- package/dist/pipeline-facts.js +47 -55
- package/dist/{pipeline-unroled.d.ts → pipeline-unclassified.d.ts} +2 -2
- package/dist/{pipeline-unroled.js → pipeline-unclassified.js} +58 -63
- package/dist/pipeline.js +19 -64
- package/dist/release-file.d.ts +3 -0
- package/dist/release-file.js +13 -0
- package/dist/report/asks.d.ts +3 -3
- package/dist/report/asks.js +16 -6
- package/dist/report/configErrors.d.ts +55 -27
- package/dist/report/configErrors.js +81 -35
- package/dist/report/errorTypes/codes/structure.d.ts +1 -1
- package/dist/report/errorTypes/codes/structure.js +9 -9
- package/dist/report/errorTypes/decision-maker.d.ts +5 -5
- package/dist/report/errorTypes/decision-maker.js +4 -4
- package/dist/report/errorTypes/destinations.d.ts +5 -5
- package/dist/report/errorTypes/destinations.js +52 -34
- package/dist/report/errorTypes/finding-type.d.ts +3 -3
- package/dist/report/errorTypes/index.d.ts +1 -1
- package/dist/report/errorTypes/types/fileContents.d.ts +4 -4
- package/dist/report/errorTypes/types/fileContents.js +11 -5
- package/dist/report/errorTypes/types/unknownEntity.d.ts +9 -0
- package/dist/report/errorTypes/types/{unknownRole.js → unknownEntity.js} +12 -7
- package/dist/report/errorTypes/types/wrongAction.d.ts +5 -5
- package/dist/report/errorTypes/types/wrongAction.js +18 -13
- package/dist/report/errorTypes/types/wrongPlacement.d.ts +4 -4
- package/dist/report/errorTypes/types/wrongPlacement.js +19 -9
- package/dist/report/errorTypes/vocabulary/ids.d.ts +2 -2
- package/dist/report/errorTypes/vocabulary/ids.js +3 -3
- package/dist/report/errorTypes/vocabulary/phrases.d.ts +2 -2
- package/dist/report/errorTypes/vocabulary/phrases.js +39 -26
- package/dist/report/errorTypes/vocabulary/places.d.ts +3 -3
- package/dist/report/errorTypes/vocabulary/places.js +13 -13
- package/dist/report/finding-from.d.ts +3 -3
- package/dist/report/finding-from.js +14 -9
- package/dist/report/notices.d.ts +6 -1
- package/dist/report/notices.js +46 -20
- package/dist/report/observed.d.ts +19 -0
- package/dist/report/observed.js +87 -0
- package/dist/report/render-report.d.ts +1 -1
- package/dist/report/render-report.js +33 -30
- package/dist/report/user-report/build/bundle.js +9 -0
- package/dist/report/user-report/build/bundle.prebuilt.js +799 -297
- package/dist/report/user-report/data/collect.d.ts +2 -2
- package/dist/report/user-report/data/collect.js +15 -12
- package/dist/report/user-report/data/entities.d.ts +7 -0
- package/dist/report/user-report/data/{roles.js → entities.js} +27 -22
- package/dist/report/user-report/data/{role-examples.d.ts → entity-examples.d.ts} +3 -3
- package/dist/report/user-report/data/entity-examples.js +126 -0
- package/dist/report/user-report/data/{role-filters.d.ts → entity-filters.d.ts} +2 -2
- package/dist/report/user-report/data/{role-filters.js → entity-filters.js} +7 -7
- package/dist/report/user-report/data/entity-marks.d.ts +5 -0
- package/dist/report/user-report/data/{role-marks.js → entity-marks.js} +11 -11
- package/dist/report/user-report/data/file-tree.d.ts +3 -3
- package/dist/report/user-report/data/file-tree.js +13 -5
- package/dist/report/user-report/data/finding-boundary.d.ts +4 -4
- package/dist/report/user-report/data/finding-boundary.js +2 -2
- package/dist/report/user-report/data/finding-plan.d.ts +5 -5
- package/dist/report/user-report/data/finding-plan.js +10 -10
- package/dist/report/user-report/data/finding-title.d.ts +2 -2
- package/dist/report/user-report/data/finding-title.js +8 -8
- package/dist/report/user-report/data/findings.d.ts +4 -4
- package/dist/report/user-report/data/findings.js +30 -20
- package/dist/report/user-report/data/graph-edges.d.ts +4 -4
- package/dist/report/user-report/data/graph-edges.js +19 -19
- package/dist/report/user-report/data/graph-entities.d.ts +6 -0
- package/dist/report/user-report/data/graph-entities.js +158 -0
- package/dist/report/user-report/data/graph-helpers.d.ts +5 -5
- package/dist/report/user-report/data/graph-helpers.js +15 -15
- package/dist/report/user-report/data/graph.d.ts +5 -4
- package/dist/report/user-report/data/graph.js +28 -21
- package/dist/report/user-report/data/nodes.d.ts +2 -2
- package/dist/report/user-report/data/nodes.js +16 -16
- package/dist/report/user-report/data/rules.d.ts +7 -0
- package/dist/report/user-report/data/{invariants.js → rules.js} +13 -13
- package/dist/report/user-report/data/scan.d.ts +1 -1
- package/dist/report/user-report/data/scan.js +2 -2
- package/dist/report/user-report/html/shell.d.ts +1 -1
- package/dist/report/user-report/html/shell.js +1 -1
- package/dist/report/user-report/index.d.ts +1 -1
- package/dist/report/user-report/shared/describe.d.ts +1 -1
- package/dist/report/user-report/shared/describe.js +6 -6
- package/dist/rules/index.d.ts +7 -0
- package/dist/{invariants → rules}/index.js +85 -57
- package/dist/{invariants → rules}/list-vars.d.ts +2 -2
- package/dist/{invariants → rules}/list-vars.js +9 -3
- package/dist/{invariants → rules}/name.js +2 -2
- package/dist/rules/normalize.d.ts +5 -0
- package/dist/{invariants → rules}/normalize.js +35 -32
- package/dist/{invariants → rules}/vars.d.ts +9 -7
- package/dist/{invariants → rules}/vars.js +5 -5
- package/dist/scan-run.d.ts +20 -0
- package/dist/scan-run.js +130 -0
- package/dist/scripts/audit-report.js +2 -2
- package/dist/usage-index.d.ts +4 -0
- package/dist/usage-index.js +272 -0
- package/dist/usage-mode.d.ts +7 -0
- package/dist/usage-mode.js +16 -0
- package/dist/usage-pass.d.ts +19 -0
- package/dist/usage-pass.js +136 -0
- package/dist/usage-prepare.d.ts +2 -0
- package/dist/usage-prepare.js +22 -0
- package/dist/usage-sweep.d.ts +10 -0
- package/dist/usage-sweep.js +254 -0
- package/dist/utils/aliases.d.ts +22 -0
- package/dist/utils/aliases.js +163 -0
- package/dist/utils/classify.d.ts +2 -2
- package/dist/utils/classify.js +4 -4
- package/dist/utils/distinct.js +4 -2
- package/dist/utils/files.js +24 -30
- package/dist/utils/fixpoint.js +2 -2
- package/dist/utils/host.d.ts +1 -1
- package/dist/utils/host.js +4 -1
- package/dist/utils/imports.js +66 -12
- package/dist/utils/keyed.js +2 -2
- package/dist/utils/map-record.js +2 -2
- package/dist/utils/packages.d.ts +15 -0
- package/dist/utils/packages.js +197 -0
- package/dist/utils/path-label.js +3 -1
- package/dist/utils/pattern.d.ts +5 -4
- package/dist/utils/pattern.js +38 -8
- package/dist/utils/permission.d.ts +3 -3
- package/dist/utils/permission.js +4 -2
- package/dist/utils/plural.js +2 -2
- package/dist/utils/qualified.js +4 -4
- package/dist/utils/rank.js +2 -2
- package/dist/utils/record.js +1 -1
- package/dist/utils/search.js +7 -2
- package/dist/utils/speak.js +1 -1
- package/dist/utils/split.js +14 -1
- package/dist/utils/template.d.ts +1 -1
- package/dist/utils/template.js +1 -1
- package/dist/utils/tokenize.js +6 -1
- package/dist/utils/typed-field.js +2 -2
- package/dist/utils/verdicts.js +1 -1
- package/entities/operators.ts +1 -1
- package/package.json +101 -90
- package/report/errorTypes/vocabulary/ids.ts +7 -2
- package/report/errorTypes/vocabulary/phrases.ts +47 -27
- package/report/errorTypes/vocabulary/places.ts +21 -16
- package/report/user-report/shared/describe.ts +7 -7
- package/dist/code-roles/classify.d.ts +0 -11
- package/dist/code-roles/classify.js +0 -43
- package/dist/code-roles/connector.d.ts +0 -5
- package/dist/code-roles/connector.js +0 -114
- package/dist/code-roles/project.d.ts +0 -12
- package/dist/code-roles/project.js +0 -122
- package/dist/code-roles/roles.d.ts +0 -8
- package/dist/invariants/index.d.ts +0 -6
- package/dist/invariants/normalize.d.ts +0 -4
- package/dist/nodes/child-roles.d.ts +0 -3
- package/dist/nodes/child-roles.js +0 -12
- package/dist/nodes/finally/roles.d.ts +0 -13
- package/dist/nodes/finally/roles.js +0 -41
- package/dist/report/errorTypes/types/unknownRole.d.ts +0 -9
- package/dist/report/user-report/data/graph-roles.d.ts +0 -5
- package/dist/report/user-report/data/graph-roles.js +0 -71
- package/dist/report/user-report/data/invariants.d.ts +0 -7
- package/dist/report/user-report/data/role-examples.js +0 -94
- package/dist/report/user-report/data/role-marks.d.ts +0 -5
- package/dist/report/user-report/data/roles.d.ts +0 -7
- /package/dist/{invariants → rules}/name.d.ts +0 -0
package/dist/utils/files.js
CHANGED
|
@@ -26,42 +26,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.collectFiles = void 0;
|
|
27
27
|
// The ONE directory walk: which files of a repo the tool looks at. Scan scope is
|
|
28
28
|
// the tool's (extensions, skipped folders, skipped globs), never the
|
|
29
|
-
// architecture's — so there is one walker and two callers.
|
|
30
|
-
|
|
29
|
+
// architecture's — so there is one walker and two callers. The recursion itself
|
|
30
|
+
// is the shared one (`@md-code/utils/node/files`): this file only states FA's
|
|
31
|
+
// scan scope on top of it.
|
|
31
32
|
const path = __importStar(require("node:path"));
|
|
32
33
|
const minimatch_1 = require("minimatch");
|
|
34
|
+
const files_1 = require("@md-code/utils/node/files");
|
|
33
35
|
const imports_1 = require("./imports");
|
|
34
|
-
const notices_1 = require("
|
|
36
|
+
const notices_1 = require("@md-code/follow-architecture/report/notices");
|
|
35
37
|
// Absolute paths of every scanned file under `repoRoot`.
|
|
36
38
|
const collectFiles = (repoRoot, { exts, ignoreDirs, ignoreGlobs = [] }) => {
|
|
37
39
|
const extSet = new Set(exts);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
walk(abs);
|
|
58
|
-
}
|
|
59
|
-
else if (extSet.has(path.extname(entry.name)) && !(ignoreGlobs ?? []).some((g) => (0, minimatch_1.minimatch)((0, imports_1.toRel)(repoRoot, abs), g))) {
|
|
60
|
-
out.push(abs);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
walk(repoRoot);
|
|
40
|
+
// `dot: true` because the walk below visits dot folders and dot files
|
|
41
|
+
// (`.prettierrc.js`, `apps/.tmp-ssr/…`): an ignore glob that cannot name them is
|
|
42
|
+
// not a scope, and `apps/**` would silently keep the dotted half of the tree.
|
|
43
|
+
const ignored = (rel) => ignoreGlobs.some((g) => (0, minimatch_1.minimatch)(rel, g, { dot: true }));
|
|
44
|
+
// The shared walk tests extensions by suffix, FA by the extension itself:
|
|
45
|
+
// the suffix pre-filter may keep a `x.mts` for `.ts`, the filter below drops
|
|
46
|
+
// it again, so the file list is exactly the one FA always had.
|
|
47
|
+
const files = (0, files_1.walk)(repoRoot, exts, ignoreDirs, {
|
|
48
|
+
// A dot directory is scan scope like any other here: FA has always
|
|
49
|
+
// visited `.github`, `.changeset` and friends unless listed as ignored.
|
|
50
|
+
dot: true,
|
|
51
|
+
// An unreadable folder is not a scan error: the file list just does not
|
|
52
|
+
// include it (folder facts degrade, the rule still runs). The reason is
|
|
53
|
+
// reported, so a short list never looks like a complete one.
|
|
54
|
+
onUnreadable: (dir, error) => {
|
|
55
|
+
(0, notices_1.notice)(`the folder ${dir} could not be read`, error instanceof Error ? error.message : String(error));
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
const out = files.filter((abs) => extSet.has(path.extname(abs)) && !ignored((0, imports_1.toRel)(repoRoot, abs)));
|
|
65
59
|
// SORTED, always: `readdirSync` returns whatever order the filesystem
|
|
66
60
|
// happens to keep (hashed on btrfs, insertion on ext4), so without this the
|
|
67
61
|
// same tree produced a different report from one machine — or one run — to
|
package/dist/utils/fixpoint.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.untilStable = void 0;
|
|
4
4
|
// A FIXPOINT is one mechanism: a step changes state and reports whether it did,
|
|
5
5
|
// and the walk repeats until a step changes nothing (or a stated pass limit is
|
|
6
|
-
// reached).
|
|
7
|
-
//
|
|
6
|
+
// reached). Entity assignment and call-target resolution feed each other — a
|
|
7
|
+
// entity may be inferred from the entities of the callees, while a callee's entity is
|
|
8
8
|
// what classification resolves — so the passes repeat until nothing moves.
|
|
9
9
|
// The walk is the same for any mutually-feeding enrichment; what a step DOES
|
|
10
10
|
// is the caller's own.
|
package/dist/utils/host.d.ts
CHANGED
package/dist/utils/host.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hostOf = void 0;
|
|
4
|
-
const spansLine = (candidate, line) => Array.isArray(candidate.lines) &&
|
|
4
|
+
const spansLine = (candidate, line) => Array.isArray(candidate.lines) &&
|
|
5
|
+
candidate.lines.length > 0 &&
|
|
6
|
+
candidate.lines[0] <= line &&
|
|
7
|
+
line <= candidate.lines[candidate.lines.length - 1];
|
|
5
8
|
const isLater = (a, b, list) => list.indexOf(b) - list.indexOf(a);
|
|
6
9
|
const hostOf = (candidates, line) => {
|
|
7
10
|
if (line === null)
|
package/dist/utils/imports.js
CHANGED
|
@@ -36,8 +36,10 @@ exports.pathsOf = exports.toRel = exports.resolveImport = void 0;
|
|
|
36
36
|
// escapes the architecture's own file set.
|
|
37
37
|
const path = __importStar(require("node:path"));
|
|
38
38
|
const ts_morph_1 = require("ts-morph");
|
|
39
|
-
const notices_1 = require("
|
|
39
|
+
const notices_1 = require("@md-code/follow-architecture/report/notices");
|
|
40
40
|
const resolve_1 = require("./resolve");
|
|
41
|
+
const aliases_1 = require("./aliases");
|
|
42
|
+
const packages_1 = require("./packages");
|
|
41
43
|
const norm = (p) => String(p).replace(/\\/g, "/");
|
|
42
44
|
const toRel = (repoRoot, filePath) => norm(path.relative(repoRoot, filePath));
|
|
43
45
|
exports.toRel = toRel;
|
|
@@ -48,14 +50,13 @@ exports.toRel = toRel;
|
|
|
48
50
|
// An alias that names a FILE (`"@md/styles": packages/styles/index.ts`) is the
|
|
49
51
|
// common case, and its subpaths go through that file's DIRECTORY: `index.ts/*`
|
|
50
52
|
// names a folder that cannot exist, so `@md/styles/themes/viking` never resolved
|
|
51
|
-
// and the checker failed on it later.
|
|
52
|
-
|
|
53
|
+
// and the checker failed on it later. Where a target sits is the alias module's
|
|
54
|
+
// answer (`folderOf`), not a second reading of it here.
|
|
53
55
|
const pathsOf = (aliases) => {
|
|
54
56
|
const paths = {};
|
|
55
57
|
for (const [alias, target] of Object.entries(aliases ?? {})) {
|
|
56
58
|
paths[alias] = [target];
|
|
57
|
-
|
|
58
|
-
paths[`${alias}/*`] = [`${base}/*`];
|
|
59
|
+
paths[`${alias}/*`] = [`${(0, packages_1.folderOf)(target)}/*`];
|
|
59
60
|
}
|
|
60
61
|
return paths;
|
|
61
62
|
};
|
|
@@ -107,15 +108,68 @@ const resolutionHost = (project, repoRoot, repoFiles) => {
|
|
|
107
108
|
useCaseSensitiveFileNames: () => true,
|
|
108
109
|
};
|
|
109
110
|
};
|
|
111
|
+
const setups = new WeakMap();
|
|
112
|
+
// The setup is keyed by the ARRAY the caller passes: the same reference means the
|
|
113
|
+
// same scanned set (the caller must not mutate an array it handed in). A default
|
|
114
|
+
// `[]` would be a fresh reference per call and would miss the cache every time,
|
|
115
|
+
// so the empty case has one constant.
|
|
116
|
+
const NO_FILES = [];
|
|
117
|
+
const setupOf = (project, repoRoot, aliases, repoFiles = NO_FILES) => {
|
|
118
|
+
const cached = setups.get(project);
|
|
119
|
+
if (cached && cached.repoFiles === repoFiles && cached.repoRoot === repoRoot && cached.aliases === aliases)
|
|
120
|
+
return cached;
|
|
121
|
+
const setup = {
|
|
122
|
+
repoRoot,
|
|
123
|
+
repoFiles,
|
|
124
|
+
aliases,
|
|
125
|
+
scanned: new Set(repoFiles),
|
|
126
|
+
options: {
|
|
127
|
+
baseUrl: repoRoot,
|
|
128
|
+
paths: pathsOf(aliases),
|
|
129
|
+
moduleResolution: ts_morph_1.ts.ModuleResolutionKind.Node10,
|
|
130
|
+
allowJs: true,
|
|
131
|
+
},
|
|
132
|
+
host: resolutionHost(project, repoRoot, repoFiles),
|
|
133
|
+
};
|
|
134
|
+
setups.set(project, setup);
|
|
135
|
+
return setup;
|
|
136
|
+
};
|
|
110
137
|
// Resolve an import source (relative path or alias) to a repo-relative file.
|
|
111
138
|
// A resolution that lands outside the scanned set (a `.d.ts`, a file in an
|
|
112
139
|
// ignored folder) is not a relation the architecture can talk about → null.
|
|
113
|
-
//
|
|
114
|
-
// compiler
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
140
|
+
//
|
|
141
|
+
// The compiler answers for folders, entry files and plain module paths. A package
|
|
142
|
+
// that publishes SUBPATHS has neither a root file nor a folder per subpath —
|
|
143
|
+
// `"./chip"` is `dist/types/atoms/Chip/index.d.ts`, built from
|
|
144
|
+
// `atoms/Chip/index.tsx` — so those subpaths are asked of the package's own
|
|
145
|
+
// `exports`, through the ONE alias reader (`utils/aliases`), never a second one.
|
|
146
|
+
const aliasedSource = (specifier, setup) => {
|
|
147
|
+
const alias = (0, aliases_1.splitAlias)(setup.aliases, specifier);
|
|
148
|
+
if (!alias || !setup.repoFiles.length)
|
|
118
149
|
return null;
|
|
119
|
-
|
|
120
|
-
|
|
150
|
+
const place = (0, aliases_1.locateAlias)(setup.aliases, alias.name, alias.rest, {
|
|
151
|
+
repoRoot: setup.repoRoot,
|
|
152
|
+
repoFiles: setup.repoFiles,
|
|
153
|
+
});
|
|
154
|
+
for (const file of place?.files ?? [])
|
|
155
|
+
if (setup.scanned.has(file))
|
|
156
|
+
return file;
|
|
157
|
+
return null;
|
|
158
|
+
};
|
|
159
|
+
const resolveImport = (sf, source, { repoRoot, aliases, repoFiles }) => {
|
|
160
|
+
const setup = setupOf(sf.getProject(), repoRoot, aliases, repoFiles);
|
|
161
|
+
return (0, resolve_1.resolveReference)(source || null, (specifier) => {
|
|
162
|
+
const hit = ts_morph_1.ts.resolveModuleName(specifier, sf.getFilePath(), setup.options, setup.host).resolvedModule;
|
|
163
|
+
const rel = hit ? toRel(repoRoot, hit.resolvedFileName) : null;
|
|
164
|
+
// The compiler's answer IS the relation — unless it lands outside the
|
|
165
|
+
// scanned set (a built mirror of a published subpath) or nowhere at all.
|
|
166
|
+
if (rel != null && (!repoFiles || setup.scanned.has(rel)))
|
|
167
|
+
return rel;
|
|
168
|
+
// Without a scanned set there is nothing to check an answer against: the
|
|
169
|
+
// compiler's own answer stands, as it always did.
|
|
170
|
+
if (!repoFiles)
|
|
171
|
+
return rel;
|
|
172
|
+
return aliasedSource(specifier, setup);
|
|
173
|
+
}, (rel) => rel);
|
|
174
|
+
};
|
|
121
175
|
exports.resolveImport = resolveImport;
|
package/dist/utils/keyed.js
CHANGED
|
@@ -4,10 +4,10 @@ exports.keyedDefs = void 0;
|
|
|
4
4
|
// A KEYED SECTION is one mechanism: the YAML may write a section as a LIST of
|
|
5
5
|
// `{ slug, … }` entries or as a MAP keyed by slug, and both spellings describe
|
|
6
6
|
// the same defs. The nodes section reads it one way (`entities/tree/build`),
|
|
7
|
-
// the
|
|
7
|
+
// the entities section the same way (`code-entities/entities`) — so the walk lives
|
|
8
8
|
// here once: a list is itself; a map's entries take their key as the slug when
|
|
9
9
|
// the entry does not name one. What a def IS and what is validated afterwards
|
|
10
|
-
// is the caller's own; nothing here knows nodes or
|
|
10
|
+
// is the caller's own; nothing here knows nodes or entities.
|
|
11
11
|
const field_1 = require("./field");
|
|
12
12
|
// The defs a list-or-map section declares, in declared order. The caller's def
|
|
13
13
|
// type `T` flows through untouched; a map value that is not a record is kept
|
package/dist/utils/map-record.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.mapRecord = void 0;
|
|
4
4
|
// A MAPPED RECORD is one mechanism: a record's entries are each read into a
|
|
5
5
|
// value, and the answers are collected under the same keys. The aliases
|
|
6
|
-
// section maps each name to a normalized path (`aliases`);
|
|
7
|
-
// map each kind to its normalized action (`code-
|
|
6
|
+
// section maps each name to a normalized path (`aliases`); an entity's actions
|
|
7
|
+
// map each kind to its normalized action (`code-entities/entities`). The walk is the
|
|
8
8
|
// same — read each entry, keep the key — so it lives here once. What an entry
|
|
9
9
|
// IS and how it is read is the caller's own.
|
|
10
10
|
const mapRecord = (record, read) => Object.fromEntries(Object.entries(record).map(([k, v]) => [k, read(k, v)]));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type FieldValue } from "@md-code/follow-architecture/utils/field";
|
|
2
|
+
declare const ENTRY_FILE: RegExp;
|
|
3
|
+
declare const norm: (p: string | null | undefined) => string;
|
|
4
|
+
declare const isFile: (p: string) => boolean;
|
|
5
|
+
declare const folderOf: (target: string) => string;
|
|
6
|
+
type Manifest = {
|
|
7
|
+
exports?: FieldValue;
|
|
8
|
+
typesVersions?: FieldValue;
|
|
9
|
+
};
|
|
10
|
+
declare const manifestOf: (repoRoot: string | null | undefined, folder: string) => Manifest | null;
|
|
11
|
+
declare const exportsPath: (manifest: Manifest | null, rest: string) => string | null;
|
|
12
|
+
declare const typesVersionPath: (manifest: Manifest | null, rest: string) => string | null;
|
|
13
|
+
declare const sourceOf: (folder: string, artifact: string, repoFiles: readonly string[]) => string | null;
|
|
14
|
+
declare const publicSources: (folder: string, manifest: Manifest | null, repoFiles: readonly string[]) => string[];
|
|
15
|
+
export { ENTRY_FILE, norm, isFile, folderOf, manifestOf, exportsPath, typesVersionPath, sourceOf, publicSources, type Manifest, };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.publicSources = exports.sourceOf = exports.typesVersionPath = exports.exportsPath = exports.manifestOf = exports.folderOf = exports.isFile = exports.norm = exports.ENTRY_FILE = void 0;
|
|
27
|
+
// What a package folder says about its own entry points. An alias target is a
|
|
28
|
+
// folder or an entry file; a SUBPATH of that package is described by the package's
|
|
29
|
+
// manifest (`exports`, `typesVersions`), which names BUILD artifacts — while the
|
|
30
|
+
// architecture talks about the sources those artifacts were built from. So the
|
|
31
|
+
// artifact's path tail is matched against the scanned files of that package.
|
|
32
|
+
//
|
|
33
|
+
// This is the ONE reader of a package manifest: the import resolver and the
|
|
34
|
+
// config's alias patterns both ask it, so neither grows its own copy.
|
|
35
|
+
const fs = __importStar(require("node:fs"));
|
|
36
|
+
const path = __importStar(require("node:path"));
|
|
37
|
+
const field_1 = require("@md-code/follow-architecture/utils/field");
|
|
38
|
+
// A target that ends in a source extension names a FILE; anything else a folder.
|
|
39
|
+
const ENTRY_FILE = /\.[cm]?[jt]sx?$/;
|
|
40
|
+
exports.ENTRY_FILE = ENTRY_FILE;
|
|
41
|
+
const norm = (p) => String(p ?? "")
|
|
42
|
+
.replace(/\\/g, "/")
|
|
43
|
+
.replace(/^\.\//, "")
|
|
44
|
+
.replace(/\/+$/, "");
|
|
45
|
+
exports.norm = norm;
|
|
46
|
+
const isFile = (p) => ENTRY_FILE.test(norm(p));
|
|
47
|
+
exports.isFile = isFile;
|
|
48
|
+
// The folder an alias target names: the target itself, or the entry file's own.
|
|
49
|
+
const folderOf = (target) => (isFile(target) ? norm(target).replace(/\/[^/]*$/, "") : norm(target));
|
|
50
|
+
exports.folderOf = folderOf;
|
|
51
|
+
// Read once per folder per process: a run asks the same package hundreds of times
|
|
52
|
+
// (one question per import) and the file cannot change under a run.
|
|
53
|
+
const manifests = new Map();
|
|
54
|
+
const manifestOf = (repoRoot, folder) => {
|
|
55
|
+
if (repoRoot == null)
|
|
56
|
+
return null;
|
|
57
|
+
const key = `${repoRoot}\u0000${folder}`;
|
|
58
|
+
const cached = manifests.get(key);
|
|
59
|
+
if (cached !== undefined)
|
|
60
|
+
return cached;
|
|
61
|
+
let manifest = null;
|
|
62
|
+
try {
|
|
63
|
+
manifest = JSON.parse(fs.readFileSync(path.join(repoRoot, folder, "package.json"), "utf8"));
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// A package without a manifest publishes no subpaths; the folder reading
|
|
67
|
+
// still answers, so this is not worth a notice.
|
|
68
|
+
manifest = null;
|
|
69
|
+
}
|
|
70
|
+
manifests.set(key, manifest);
|
|
71
|
+
return manifest;
|
|
72
|
+
};
|
|
73
|
+
exports.manifestOf = manifestOf;
|
|
74
|
+
// The path a condition object names. `types` first: the source mirror is what the
|
|
75
|
+
// architecture talks about, the built file is an artifact of it.
|
|
76
|
+
const CONDITIONS = ["types", "import", "default", "node", "require"];
|
|
77
|
+
const pathIn = (value) => {
|
|
78
|
+
if (typeof value === "string")
|
|
79
|
+
return value;
|
|
80
|
+
if ((0, field_1.isList)(value)) {
|
|
81
|
+
for (const item of value) {
|
|
82
|
+
const found = pathIn(item);
|
|
83
|
+
if (found)
|
|
84
|
+
return found;
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
if (!(0, field_1.isObj)(value))
|
|
89
|
+
return null;
|
|
90
|
+
for (const condition of CONDITIONS) {
|
|
91
|
+
const found = pathIn(value[condition]);
|
|
92
|
+
if (found)
|
|
93
|
+
return found;
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
};
|
|
97
|
+
// `exports["./subpath"]` — the public entry a subpath names, if the package has
|
|
98
|
+
// one. An import may spell the built file's extension (`@pkg/chip.js`); the
|
|
99
|
+
// manifest never does, so the extension-less spelling is asked too.
|
|
100
|
+
const exportsPath = (manifest, rest) => {
|
|
101
|
+
const entries = manifest?.exports;
|
|
102
|
+
if (!(0, field_1.isObj)(entries))
|
|
103
|
+
return null;
|
|
104
|
+
const bare = norm(rest).replace(ENTRY_FILE, "");
|
|
105
|
+
for (const name of bare === rest ? [rest] : [rest, bare]) {
|
|
106
|
+
for (const key of [`./${name}`, `./${name}.js`, `./${name}/index`, `./${name}.ts`]) {
|
|
107
|
+
const found = key in entries ? pathIn(entries[key]) : null;
|
|
108
|
+
if (found)
|
|
109
|
+
return found;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
};
|
|
114
|
+
exports.exportsPath = exportsPath;
|
|
115
|
+
// One `typesVersions` pattern: an exact name, or a `*` that captures the middle.
|
|
116
|
+
const fromPattern = (pattern, target, rest) => {
|
|
117
|
+
const name = norm(pattern);
|
|
118
|
+
const star = name.indexOf("*");
|
|
119
|
+
if (star === -1)
|
|
120
|
+
return name === rest ? pathIn(target) : null;
|
|
121
|
+
const head = name.slice(0, star);
|
|
122
|
+
const tail = name.slice(star + 1);
|
|
123
|
+
if (!rest.startsWith(head) || !rest.endsWith(tail))
|
|
124
|
+
return null;
|
|
125
|
+
const found = pathIn(target);
|
|
126
|
+
const captured = rest.slice(head.length, rest.length - tail.length);
|
|
127
|
+
return found ? norm(found).replace("*", captured) : null;
|
|
128
|
+
};
|
|
129
|
+
// `typesVersions[version][pattern]` — the second place a package may describe a
|
|
130
|
+
// subpath, read with the SAME tail rule once a pattern names a path.
|
|
131
|
+
const typesVersionPath = (manifest, rest) => {
|
|
132
|
+
const versions = manifest?.typesVersions;
|
|
133
|
+
if (!(0, field_1.isObj)(versions))
|
|
134
|
+
return null;
|
|
135
|
+
for (const table of Object.values(versions)) {
|
|
136
|
+
if (!(0, field_1.isObj)(table))
|
|
137
|
+
continue;
|
|
138
|
+
for (const [pattern, target] of Object.entries(table)) {
|
|
139
|
+
const found = fromPattern(pattern, target, rest);
|
|
140
|
+
if (found)
|
|
141
|
+
return found;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
};
|
|
146
|
+
exports.typesVersionPath = typesVersionPath;
|
|
147
|
+
// ── artifact → source ───────────────────────────────────────────────────────
|
|
148
|
+
const SOURCE_EXTS = [".tsx", ".ts", ".d.ts"];
|
|
149
|
+
const scannedSets = new WeakMap();
|
|
150
|
+
const scannedOf = (repoFiles) => {
|
|
151
|
+
let scanned = scannedSets.get(repoFiles);
|
|
152
|
+
if (!scanned) {
|
|
153
|
+
scanned = new Set(repoFiles.map(norm));
|
|
154
|
+
scannedSets.set(repoFiles, scanned);
|
|
155
|
+
}
|
|
156
|
+
return scanned;
|
|
157
|
+
};
|
|
158
|
+
// The scanned file an artifact was built from: the artifact's own segments, tried
|
|
159
|
+
// from the LONGEST suffix down, against the files of that package. The build
|
|
160
|
+
// folder (`dist/types/…`) is in no source path, so the first suffix a source file
|
|
161
|
+
// ends with is the answer.
|
|
162
|
+
const sourceOf = (folder, artifact, repoFiles) => {
|
|
163
|
+
const segments = norm(artifact)
|
|
164
|
+
.replace(/\.d\.ts$/, "")
|
|
165
|
+
.replace(ENTRY_FILE, "")
|
|
166
|
+
.split("/")
|
|
167
|
+
.filter(Boolean);
|
|
168
|
+
const scanned = scannedOf(repoFiles);
|
|
169
|
+
for (let i = 0; i < segments.length; i += 1) {
|
|
170
|
+
const tail = segments.slice(i).join("/");
|
|
171
|
+
for (const ext of SOURCE_EXTS) {
|
|
172
|
+
const file = `${folder}/${tail}${ext}`;
|
|
173
|
+
if (scanned.has(file))
|
|
174
|
+
return file;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return null;
|
|
178
|
+
};
|
|
179
|
+
exports.sourceOf = sourceOf;
|
|
180
|
+
// Every public subpath a package publishes, as sources — what `@pkg/*` means for
|
|
181
|
+
// a package that has no folders to walk.
|
|
182
|
+
const publicSources = (folder, manifest, repoFiles) => {
|
|
183
|
+
const entries = manifest?.exports;
|
|
184
|
+
if (!(0, field_1.isObj)(entries))
|
|
185
|
+
return [];
|
|
186
|
+
const out = [];
|
|
187
|
+
for (const [key, value] of Object.entries(entries)) {
|
|
188
|
+
if (!key.startsWith("./"))
|
|
189
|
+
continue;
|
|
190
|
+
const artifact = pathIn(value);
|
|
191
|
+
const source = artifact ? sourceOf(folder, artifact, repoFiles) : null;
|
|
192
|
+
if (source)
|
|
193
|
+
out.push(source);
|
|
194
|
+
}
|
|
195
|
+
return out;
|
|
196
|
+
};
|
|
197
|
+
exports.publicSources = publicSources;
|
package/dist/utils/path-label.js
CHANGED
|
@@ -26,7 +26,9 @@ const pathTemplate = (paths) => {
|
|
|
26
26
|
exports.pathTemplate = pathTemplate;
|
|
27
27
|
// Shortest label that still says WHERE it is: the last N path segments.
|
|
28
28
|
const tailPath = (template, keep = 2) => {
|
|
29
|
-
const segs = String(template ?? "")
|
|
29
|
+
const segs = String(template ?? "")
|
|
30
|
+
.split("/")
|
|
31
|
+
.filter(Boolean);
|
|
30
32
|
return segs.length <= keep ? segs.join("/") : segs.slice(-keep).join("/");
|
|
31
33
|
};
|
|
32
34
|
exports.tailPath = tailPath;
|
package/dist/utils/pattern.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
declare const DEFAULT_IGNORE_DIRS: string[];
|
|
1
|
+
declare const DEFAULT_IGNORE_DIRS: readonly string[];
|
|
2
|
+
declare const DEFAULT_IGNORE_PATHS: readonly string[];
|
|
2
3
|
declare const DEFAULT_SIMILARITY = 0.6;
|
|
3
4
|
declare const DEFAULT_EXTS: string[];
|
|
4
5
|
declare const expandBraces: (s: string) => string[];
|
|
@@ -8,11 +9,11 @@ declare const placeholderRe: (n: string) => string;
|
|
|
8
9
|
declare const PLACEHOLDER: RegExp;
|
|
9
10
|
declare const patternBody: (pattern: string) => {
|
|
10
11
|
body: string;
|
|
11
|
-
names: string[];
|
|
12
|
+
names: readonly string[];
|
|
12
13
|
};
|
|
13
14
|
declare const compilePattern: (pattern: string) => {
|
|
14
15
|
re: RegExp;
|
|
15
|
-
names: string[];
|
|
16
|
+
names: readonly string[];
|
|
16
17
|
};
|
|
17
18
|
declare const checkRegex: (p: string, where: string) => void;
|
|
18
|
-
export { DEFAULT_EXTS, DEFAULT_SIMILARITY, DEFAULT_IGNORE_DIRS, globToRegex, conventionOf, placeholderRe, compilePattern, patternBody, PLACEHOLDER, expandBraces, checkRegex };
|
|
19
|
+
export { DEFAULT_EXTS, DEFAULT_SIMILARITY, DEFAULT_IGNORE_DIRS, DEFAULT_IGNORE_PATHS, globToRegex, conventionOf, placeholderRe, compilePattern, patternBody, PLACEHOLDER, expandBraces, checkRegex, };
|
package/dist/utils/pattern.js
CHANGED
|
@@ -23,13 +23,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.checkRegex = exports.expandBraces = exports.PLACEHOLDER = exports.patternBody = exports.compilePattern = exports.placeholderRe = exports.conventionOf = exports.globToRegex = exports.DEFAULT_IGNORE_DIRS = exports.DEFAULT_SIMILARITY = exports.DEFAULT_EXTS = void 0;
|
|
27
|
-
const configError = __importStar(require("
|
|
26
|
+
exports.checkRegex = exports.expandBraces = exports.PLACEHOLDER = exports.patternBody = exports.compilePattern = exports.placeholderRe = exports.conventionOf = exports.globToRegex = exports.DEFAULT_IGNORE_PATHS = exports.DEFAULT_IGNORE_DIRS = exports.DEFAULT_SIMILARITY = exports.DEFAULT_EXTS = void 0;
|
|
27
|
+
const configError = __importStar(require("@md-code/follow-architecture/report/configErrors"));
|
|
28
|
+
const ignore_1 = require("@md-code/follow-architecture/ignore");
|
|
28
29
|
// Glob → regex and the naming-convention placeholder machinery shared by
|
|
29
|
-
// every entity that matches file paths (nodes,
|
|
30
|
-
// Directories that never contain source code.
|
|
31
|
-
|
|
30
|
+
// every entity that matches file paths (nodes, rules, fileSpecs).
|
|
31
|
+
// Directories that never contain source code. The list lives in `ignore.ts`
|
|
32
|
+
// because the ESLint rule skips exactly the same folders; a repo may add more
|
|
33
|
+
// via `ignoreDirs`.
|
|
34
|
+
const DEFAULT_IGNORE_DIRS = ignore_1.IGNORE_DIRS;
|
|
32
35
|
exports.DEFAULT_IGNORE_DIRS = DEFAULT_IGNORE_DIRS;
|
|
36
|
+
// Repo-relative paths outside the contract — the repository's own scope, not the
|
|
37
|
+
// tool's: empty here, and a caller adds its own via `--ignore` / `ignores`.
|
|
38
|
+
const DEFAULT_IGNORE_PATHS = ignore_1.IGNORE_PATHS;
|
|
39
|
+
exports.DEFAULT_IGNORE_PATHS = DEFAULT_IGNORE_PATHS;
|
|
33
40
|
// Source extensions the TOOL scans by default. Scan scope is a tool concern, not
|
|
34
41
|
// architecture (the yaml must not carry it) — and it is an option, not a fact of
|
|
35
42
|
// the tool's code: `--ext <ext>` / the rule's `exts` add to this list.
|
|
@@ -164,19 +171,42 @@ exports.PLACEHOLDER = PLACEHOLDER;
|
|
|
164
171
|
// patterns, node paths and node children. A placeholder is swapped for a sentinel
|
|
165
172
|
// before the glob is compiled so its own characters survive, then put back as a
|
|
166
173
|
// capture group of the convention it asks for.
|
|
174
|
+
// The same templates are compiled again and again: every file is matched against
|
|
175
|
+
// every node path, every finding against the rule's patterns. Compilation is pure
|
|
176
|
+
// (a template always yields the same body and names), so it is memoised; the
|
|
177
|
+
// produced expressions have no `g` flag, so one instance is safe to reuse.
|
|
178
|
+
// The memo is MODULE-wide and grows to the number of distinct templates the run
|
|
179
|
+
// meets (bounded by the working tree — a CLI run dies with it); the captured
|
|
180
|
+
// names are handed out READ-ONLY, so one caller cannot edit another's.
|
|
181
|
+
const bodies = new Map();
|
|
167
182
|
const patternBody = (pattern) => {
|
|
183
|
+
const key = String(pattern);
|
|
184
|
+
const cached = bodies.get(key);
|
|
185
|
+
if (cached)
|
|
186
|
+
return cached;
|
|
168
187
|
const names = [];
|
|
169
|
-
const glob = String(pattern)
|
|
188
|
+
const glob = String(pattern)
|
|
189
|
+
.replace(/\\/g, "/")
|
|
190
|
+
.replace(PLACEHOLDER, (_, n) => {
|
|
170
191
|
names.push(n);
|
|
171
192
|
return `\u0000${n}\u0000`;
|
|
172
193
|
});
|
|
173
194
|
const body = globToRegex(glob).replace(/\u0000([A-Za-z][A-Za-z0-9_-]*)\u0000/g, (_, n) => `(${placeholderRe(n)})`);
|
|
174
|
-
|
|
195
|
+
const compiled = { body, names };
|
|
196
|
+
bodies.set(key, compiled);
|
|
197
|
+
return compiled;
|
|
175
198
|
};
|
|
176
199
|
exports.patternBody = patternBody;
|
|
200
|
+
const patterns = new Map();
|
|
177
201
|
const compilePattern = (pattern) => {
|
|
202
|
+
const key = String(pattern);
|
|
203
|
+
const cached = patterns.get(key);
|
|
204
|
+
if (cached)
|
|
205
|
+
return cached;
|
|
178
206
|
const { body, names } = patternBody(pattern);
|
|
179
|
-
|
|
207
|
+
const compiled = { re: new RegExp(`^${body}$`), names };
|
|
208
|
+
patterns.set(key, compiled);
|
|
209
|
+
return compiled;
|
|
180
210
|
};
|
|
181
211
|
exports.compilePattern = compilePattern;
|
|
182
212
|
const checkRegex = (p, where) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Arch, ActionDef } from "
|
|
2
|
-
import type { FileFacts } from "
|
|
3
|
-
import type { Caps } from "
|
|
1
|
+
import type { Arch, ActionDef } from "@md-code/follow-architecture/entities/architecture";
|
|
2
|
+
import type { FileFacts } from "@md-code/follow-architecture/entities/facts";
|
|
3
|
+
import type { Caps } from "@md-code/follow-architecture/entities/location/where";
|
|
4
4
|
type Permission = {
|
|
5
5
|
allowed: boolean;
|
|
6
6
|
denied: boolean;
|
package/dist/utils/permission.js
CHANGED
|
@@ -7,10 +7,12 @@ exports.permissionOf = void 0;
|
|
|
7
7
|
// against a declared allowance asks the same two questions. The walk — allow
|
|
8
8
|
// when some `where` entry admits, then refuse when some `except` entry admits —
|
|
9
9
|
// lives here once. What the entries MEAN is the shared `where` grammar's own.
|
|
10
|
-
const location_1 = require("
|
|
10
|
+
const location_1 = require("@md-code/follow-architecture/entities/location");
|
|
11
11
|
const permissionOf = (action, ask) => {
|
|
12
12
|
const allowed = !(0, location_1.checkWhere)(action.where, ask.rel, ask.arch, ask.scope, ask.caps);
|
|
13
|
-
const denied = (action.except ?? []).length
|
|
13
|
+
const denied = (action.except ?? []).length
|
|
14
|
+
? !(0, location_1.checkWhere)(action.except, ask.rel, ask.arch, ask.scope, ask.caps)
|
|
15
|
+
: false;
|
|
14
16
|
return { allowed, denied };
|
|
15
17
|
};
|
|
16
18
|
exports.permissionOf = permissionOf;
|
package/dist/utils/plural.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.plural = void 0;
|
|
4
4
|
// A PLURAL is one mechanism: a count read as "1 thing" / "N things". The browser
|
|
5
|
-
// counts
|
|
5
|
+
// counts entities / rules / matches (`utils/format`); any consumer that names a
|
|
6
6
|
// count asks the same question. The irregular plural is the caller's own; the
|
|
7
7
|
// regular one adds `s`.
|
|
8
|
-
const plural = (n, one, many) => `${n} ${n === 1 ? one : many ?? `${one}s`}`;
|
|
8
|
+
const plural = (n, one, many) => `${n} ${n === 1 ? one : (many ?? `${one}s`)}`;
|
|
9
9
|
exports.plural = plural;
|
package/dist/utils/qualified.js
CHANGED
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.answerWhenAllPass = void 0;
|
|
4
4
|
// A QUALIFIED ANSWER is one mechanism: a subject must pass every guard before
|
|
5
5
|
// it earns an answer; the first guard that refuses ends the question with
|
|
6
|
-
// nothing. A misfit
|
|
7
|
-
// that sits outside them (`pipeline-
|
|
8
|
-
// scope is one of the declared kinds (`code-
|
|
6
|
+
// nothing. A misfit entity is a named candidate of a declared entity with homes
|
|
7
|
+
// that sits outside them (`pipeline-entities`); a scope accessor is a record whose
|
|
8
|
+
// scope is one of the declared kinds (`code-entities/entities`). The walk is the same
|
|
9
9
|
// — ask each guard in order, answer only when all pass — so it lives here once.
|
|
10
10
|
// What the guards ARE and what the answer is is the caller's own; nothing here
|
|
11
|
-
// knows
|
|
11
|
+
// knows entities or accessors.
|
|
12
12
|
// The answer when every guard passes; null the moment one refuses. Guards are
|
|
13
13
|
// asked in order, so a cheap refusal short-circuits the rest.
|
|
14
14
|
const answerWhenAllPass = (subject, guards, answer) => {
|
package/dist/utils/rank.js
CHANGED
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.rankedOffers = void 0;
|
|
4
4
|
// A RANKED SHORTLIST is one mechanism: candidates are scored against a subject,
|
|
5
5
|
// the ones below the bar are dropped, and the rest are offered best first. A
|
|
6
|
-
//
|
|
6
|
+
// entity's destinations are its homes scored by branch and prefix
|
|
7
7
|
// (`entities/location/homes`); a folder's lookalikes are the declared entities
|
|
8
|
-
// scored by the share of their
|
|
8
|
+
// scored by the share of their entities it holds (`nodes/similar`). The walk is
|
|
9
9
|
// the same — score, keep, rank — so it lives here once. What a candidate IS,
|
|
10
10
|
// how it is scored and what the bar means are the caller's own.
|
|
11
11
|
// Score every candidate, keep the ones the scorer offers (non-null), and sort
|
package/dist/utils/record.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.recordWithout = void 0;
|
|
|
4
4
|
// A RECORD WITHOUT KEYS is one mechanism: a record carries some keys that are
|
|
5
5
|
// NOT data (a report template beside a filter, an `arch` beside the facts),
|
|
6
6
|
// and a reader that wants only the data takes the record minus those keys.
|
|
7
|
-
// The
|
|
7
|
+
// The rule runtime strips `report` before matching (`rules/vars`);
|
|
8
8
|
// the query engine strips `arch` before resolving a `$ref`
|
|
9
9
|
// (`entities/queries`). The walk is the same — copy every key except the named
|
|
10
10
|
// ones — so it lives here once. Which keys are not data is the caller's own.
|