@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
|
@@ -0,0 +1,209 @@
|
|
|
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.MAX_FOLDER = exports.MAX_ZONE = exports.extendZone = exports.closureOf = exports.importersOf = exports.zoneOf = void 0;
|
|
27
|
+
// WHICH FILES A WARM RUN HAS TO READ AGAIN. The summary in the light section
|
|
28
|
+
// answers for the bytes of its own file, but not all of a file's facts are decided
|
|
29
|
+
// there: a type, a usage
|
|
30
|
+
// count or an import is answered by ANOTHER file, and a file that moved changes
|
|
31
|
+
// the answers of its neighbours. So freshness cannot be "the file's own hash
|
|
32
|
+
// matches" — the zone adds everything the change can reach: the imports (what
|
|
33
|
+
// this file reads), the importers (what reads this file) and, transitively, their
|
|
34
|
+
// neighbours, plus the folders those files sit in (a folder-level finding is a
|
|
35
|
+
// statement about the folder's members).
|
|
36
|
+
//
|
|
37
|
+
// A zone that has grown past `MAX_ZONE` files is no longer a neighbourhood: the
|
|
38
|
+
// change touched something everything depends on, and reading the whole scan
|
|
39
|
+
// again is both simpler and no slower.
|
|
40
|
+
//
|
|
41
|
+
// A file that DISAPPEARED is the one change the index cannot report: the index
|
|
42
|
+
// answers only for paths a run names, and the walk no longer names it. It is
|
|
43
|
+
// still visible through the survivors that imported it — those are stale anyway —
|
|
44
|
+
// and its own record is still in the index, which is what names the files IT
|
|
45
|
+
// pointed at: their answers ("who uses me") were decided by a file that no longer
|
|
46
|
+
// exists.
|
|
47
|
+
const fs = __importStar(require("node:fs"));
|
|
48
|
+
const path = __importStar(require("node:path"));
|
|
49
|
+
const fa_index_1 = require("./fa-index");
|
|
50
|
+
// Files read again in one run.
|
|
51
|
+
const MAX_ZONE = 200;
|
|
52
|
+
exports.MAX_ZONE = MAX_ZONE;
|
|
53
|
+
// A directory's own members are part of the zone, but a folder with more files
|
|
54
|
+
// than this is treated as "everything".
|
|
55
|
+
const MAX_FOLDER = 400;
|
|
56
|
+
exports.MAX_FOLDER = MAX_FOLDER;
|
|
57
|
+
// Importers of every file, from the summaries' dependency lists.
|
|
58
|
+
const importersOf = (light, relOf) => {
|
|
59
|
+
const out = new Map();
|
|
60
|
+
for (const [abs, entry] of light) {
|
|
61
|
+
const rel = relOf.get(abs);
|
|
62
|
+
if (rel === undefined)
|
|
63
|
+
continue;
|
|
64
|
+
for (const dep of entry.summary.deps) {
|
|
65
|
+
const list = out.get(dep) ?? [];
|
|
66
|
+
list.push(rel);
|
|
67
|
+
out.set(dep, list);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
};
|
|
72
|
+
exports.importersOf = importersOf;
|
|
73
|
+
const expand = (out, queue, rels) => {
|
|
74
|
+
for (const rel of rels) {
|
|
75
|
+
if (out.has(rel))
|
|
76
|
+
continue;
|
|
77
|
+
out.add(rel);
|
|
78
|
+
queue.push(rel);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
// The transitive closure of `seeds` over the given edge sets, stopping once the
|
|
82
|
+
// answer is already too large to be worth narrowing.
|
|
83
|
+
const closureOf = (seeds, edges, limit) => {
|
|
84
|
+
const out = new Set(seeds);
|
|
85
|
+
const queue = [...seeds];
|
|
86
|
+
for (let at = 0; at < queue.length && out.size <= limit; at += 1) {
|
|
87
|
+
for (const next of edges)
|
|
88
|
+
expand(out, queue, next(queue[at]));
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
};
|
|
92
|
+
exports.closureOf = closureOf;
|
|
93
|
+
// A folder's own members, or null when the folder is too large to treat as a zone.
|
|
94
|
+
const folderMates = (repoFiles, rels) => {
|
|
95
|
+
const dirs = new Set(rels.map((rel) => path.posix.dirname(rel)));
|
|
96
|
+
const out = [];
|
|
97
|
+
for (const rel of repoFiles)
|
|
98
|
+
if (dirs.has(path.posix.dirname(rel)))
|
|
99
|
+
out.push(rel);
|
|
100
|
+
return out.length > MAX_FOLDER ? null : out;
|
|
101
|
+
};
|
|
102
|
+
// A dependency that is not part of the scan is not a lost dependency: an import of
|
|
103
|
+
// `react` resolves into `node_modules`, and a file the scope excluded (another
|
|
104
|
+
// extension, an ignored folder) is still on disk. Only a path that the scan would
|
|
105
|
+
// have covered AND that is no longer there means the file went away.
|
|
106
|
+
const EXISTS = new Map();
|
|
107
|
+
const isGone = (root, rel, known) => {
|
|
108
|
+
if (known.has(rel))
|
|
109
|
+
return false;
|
|
110
|
+
const cached = EXISTS.get(rel);
|
|
111
|
+
if (cached !== undefined)
|
|
112
|
+
return cached;
|
|
113
|
+
const exists = fs.existsSync(path.resolve(root, rel));
|
|
114
|
+
EXISTS.set(rel, exists);
|
|
115
|
+
return !exists;
|
|
116
|
+
};
|
|
117
|
+
// The files that changed since the last run: no summary, a summary this tool
|
|
118
|
+
// cannot use, or one that names a dependency that is gone.
|
|
119
|
+
const staleOf = (args) => {
|
|
120
|
+
const { light, absFiles, repoFiles, root } = args;
|
|
121
|
+
const known = new Set(repoFiles);
|
|
122
|
+
const out = [];
|
|
123
|
+
for (let at = 0; at < absFiles.length; at += 1) {
|
|
124
|
+
const entry = light.get(absFiles[at]);
|
|
125
|
+
const fresh = entry !== undefined && !entry.summary.deps.some((dep) => isGone(root, dep, known));
|
|
126
|
+
if (!fresh)
|
|
127
|
+
out.push(repoFiles[at]);
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
130
|
+
};
|
|
131
|
+
// The files a gone file pointed at. `null` means the targets cannot be known (the
|
|
132
|
+
// index never held the gone file), and the caller then reads everything.
|
|
133
|
+
const lostTargets = (args) => {
|
|
134
|
+
const { index, light, repoFiles, root } = args;
|
|
135
|
+
const known = new Set(repoFiles);
|
|
136
|
+
const gone = new Set();
|
|
137
|
+
for (const entry of light.values()) {
|
|
138
|
+
for (const dep of entry.summary.deps)
|
|
139
|
+
if (isGone(root, dep, known))
|
|
140
|
+
gone.add(dep);
|
|
141
|
+
}
|
|
142
|
+
if (gone.size === 0)
|
|
143
|
+
return [];
|
|
144
|
+
const targets = [];
|
|
145
|
+
for (const rel of gone) {
|
|
146
|
+
const entry = (0, fa_index_1.lightAt)(index, path.resolve(root, rel));
|
|
147
|
+
if (entry === null)
|
|
148
|
+
return null;
|
|
149
|
+
targets.push(...entry.summary.deps);
|
|
150
|
+
}
|
|
151
|
+
return targets;
|
|
152
|
+
};
|
|
153
|
+
// A file the index has never seen brings facts nobody has read yet — and its
|
|
154
|
+
// imports are facts about OTHER files: an export it starts to use gains a
|
|
155
|
+
// reference, and a reference travels through barrels. So the added file's own
|
|
156
|
+
// dependencies join the zone, and so do theirs while new ones keep appearing.
|
|
157
|
+
// The reverse direction (a file that goes away) needs none of this: `zoneOf`
|
|
158
|
+
// already read the tombstone's deps.
|
|
159
|
+
const depsOfAdded = (added, depsOf, absOf, zone) => {
|
|
160
|
+
const extra = new Set();
|
|
161
|
+
for (const rel of added) {
|
|
162
|
+
for (const dep of depsOf(absOf.get(rel) ?? ""))
|
|
163
|
+
if (!zone.has(dep) && absOf.has(dep))
|
|
164
|
+
extra.add(dep);
|
|
165
|
+
}
|
|
166
|
+
return extra;
|
|
167
|
+
};
|
|
168
|
+
const extendZone = (args, extract) => {
|
|
169
|
+
const { zone, known, depsOf, absOf, repoFiles } = args;
|
|
170
|
+
let added = [...zone].filter((rel) => !known.has(absOf.get(rel) ?? ""));
|
|
171
|
+
let extracted = 0;
|
|
172
|
+
for (;;) {
|
|
173
|
+
const extra = depsOfAdded(added, depsOf, absOf, zone);
|
|
174
|
+
if (extra.size === 0)
|
|
175
|
+
return extracted;
|
|
176
|
+
if (zone.size + extra.size > MAX_ZONE) {
|
|
177
|
+
// The addition pulls in more than a neighbourhood: read everything.
|
|
178
|
+
for (const rel of repoFiles)
|
|
179
|
+
zone.add(rel);
|
|
180
|
+
return extracted + extract(zone);
|
|
181
|
+
}
|
|
182
|
+
for (const rel of extra)
|
|
183
|
+
zone.add(rel);
|
|
184
|
+
extracted += extract(extra);
|
|
185
|
+
added = [...extra];
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
exports.extendZone = extendZone;
|
|
189
|
+
// What must be read again, and how many files changed.
|
|
190
|
+
const zoneOf = (args) => {
|
|
191
|
+
const { index, light, absFiles, repoFiles, root } = args;
|
|
192
|
+
const stale = staleOf({ light, absFiles, repoFiles, root });
|
|
193
|
+
const absOf = new Map();
|
|
194
|
+
const relOf = new Map();
|
|
195
|
+
for (let at = 0; at < repoFiles.length; at += 1) {
|
|
196
|
+
absOf.set(repoFiles[at], absFiles[at]);
|
|
197
|
+
relOf.set(absFiles[at], repoFiles[at]);
|
|
198
|
+
}
|
|
199
|
+
const importers = importersOf(light, relOf);
|
|
200
|
+
const depsOfRel = (rel) => light.get(absOf.get(rel) ?? "")?.summary.deps ?? [];
|
|
201
|
+
const importersOfRel = (rel) => importers.get(rel) ?? [];
|
|
202
|
+
const lost = lostTargets({ index, light, repoFiles, root });
|
|
203
|
+
const seeds = lost === null ? [...repoFiles] : [...stale, ...lost];
|
|
204
|
+
const widened = closureOf(seeds, [depsOfRel, importersOfRel], MAX_ZONE);
|
|
205
|
+
const mates = folderMates(repoFiles, [...widened]);
|
|
206
|
+
const zone = mates === null ? new Set(repoFiles) : new Set([...widened, ...mates]);
|
|
207
|
+
return { zone, stale: stale.length };
|
|
208
|
+
};
|
|
209
|
+
exports.zoneOf = zoneOf;
|
package/dist/main.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { type Args } from "./args";
|
|
1
2
|
import type { Arch, RawArch } from "./entities/architecture";
|
|
2
3
|
import type { RuleOptions } from "./config-options";
|
|
3
|
-
type ArchSections = Pick<RawArch, "nodes" | "
|
|
4
|
+
type ArchSections = Pick<RawArch, "nodes" | "entities" | "rules" | "aliases" | "report">;
|
|
4
5
|
declare const buildArchitecture: (raw: ArchSections | null | undefined) => Arch;
|
|
5
6
|
declare const loadArchitecture: (config: string | RawArch | RuleOptions | null | undefined) => Arch;
|
|
7
|
+
declare const canonicalRoot: (dir: string) => string;
|
|
8
|
+
declare const repoOf: (args: Args, cwd: string) => string;
|
|
6
9
|
declare const main: (argv: string[]) => number;
|
|
7
|
-
export { main, loadArchitecture, buildArchitecture };
|
|
10
|
+
export { main, loadArchitecture, buildArchitecture, canonicalRoot, repoOf };
|
package/dist/main.js
CHANGED
|
@@ -23,18 +23,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.buildArchitecture = exports.loadArchitecture = exports.main = void 0;
|
|
26
|
+
exports.repoOf = exports.canonicalRoot = exports.buildArchitecture = exports.loadArchitecture = exports.main = void 0;
|
|
27
27
|
const fs = __importStar(require("node:fs"));
|
|
28
28
|
const path = __importStar(require("node:path"));
|
|
29
29
|
const remeda_1 = require("remeda");
|
|
30
30
|
const tree_1 = require("./entities/tree");
|
|
31
|
-
const
|
|
32
|
-
const normalize_1 = require("./
|
|
31
|
+
const entities_1 = require("./code-entities/entities");
|
|
32
|
+
const normalize_1 = require("./rules/normalize");
|
|
33
33
|
const aliases_1 = require("./aliases");
|
|
34
34
|
const pipeline_1 = require("./pipeline");
|
|
35
|
+
const index_run_1 = require("./index-run");
|
|
36
|
+
const usage_prepare_1 = require("./usage-prepare");
|
|
37
|
+
const fa_store_1 = require("./fa-store");
|
|
35
38
|
const pattern_1 = require("./utils/pattern");
|
|
36
39
|
const cli_report_1 = require("./report/cli-report");
|
|
37
|
-
const
|
|
40
|
+
const scan_run_1 = require("./scan-run");
|
|
38
41
|
const notices_1 = require("./report/notices");
|
|
39
42
|
const user_report_1 = require("./report/user-report");
|
|
40
43
|
const imports_1 = require("./utils/imports");
|
|
@@ -42,6 +45,7 @@ const files_1 = require("./utils/files");
|
|
|
42
45
|
const args_1 = require("./args");
|
|
43
46
|
const keyed_1 = require("./utils/keyed");
|
|
44
47
|
const field_1 = require("./utils/field");
|
|
48
|
+
const schema_1 = require("./entities/schema");
|
|
45
49
|
const configError = __importStar(require("./report/configErrors"));
|
|
46
50
|
const yaml = __importStar(require("js-yaml"));
|
|
47
51
|
// The report layer owns its payload; the input contract is the ONE entity
|
|
@@ -51,32 +55,86 @@ const writeOverview = user_report_1.writeOverview;
|
|
|
51
55
|
// The nodes section as a list — the shared list-or-map walk, the same one the
|
|
52
56
|
// tree builder reads.
|
|
53
57
|
const nodesOf = (raw) => (0, keyed_1.keyedDefs)(raw.nodes).filter((n) => n != null);
|
|
54
|
-
// Every
|
|
55
|
-
// a typo would otherwise give a home to
|
|
58
|
+
// Every rule id must be unique, and every entity a node names must exist —
|
|
59
|
+
// a typo would otherwise give a home to an entity nothing ever infers.
|
|
56
60
|
const checkBuilt = (arch) => {
|
|
57
|
-
const ids = arch.
|
|
61
|
+
const ids = arch.rules.map((i) => i.id);
|
|
58
62
|
if (new Set(ids).size !== ids.length)
|
|
59
|
-
throw configError.
|
|
60
|
-
const known = new Set(Object.keys(arch.
|
|
61
|
-
for (const
|
|
62
|
-
if (!known.has(
|
|
63
|
-
throw configError.
|
|
63
|
+
throw configError.duplicateRuleIds(ids);
|
|
64
|
+
const known = new Set(Object.keys(arch.entities));
|
|
65
|
+
for (const entity of Object.keys(arch.nodes.entityHomes)) {
|
|
66
|
+
if (!known.has(entity))
|
|
67
|
+
throw configError.nodeEntityUnknown(entity);
|
|
64
68
|
}
|
|
65
69
|
};
|
|
70
|
+
// The tool's own option keys travel in the same bag as the architecture
|
|
71
|
+
// sections (the ESLint rule hands both). They are not sections, and are not
|
|
72
|
+
// shown in the section dictionary.
|
|
73
|
+
const TOOL_KEYS = new Set([
|
|
74
|
+
"config",
|
|
75
|
+
"configs",
|
|
76
|
+
"include",
|
|
77
|
+
"exts",
|
|
78
|
+
"similarity",
|
|
79
|
+
"barrelDepth",
|
|
80
|
+
"ignoreDirs",
|
|
81
|
+
"ignores",
|
|
82
|
+
"exportPath",
|
|
83
|
+
"file",
|
|
84
|
+
"report",
|
|
85
|
+
]);
|
|
86
|
+
// Old vocabulary is rejected BY NAME — the reader is shown the sections and
|
|
87
|
+
// their meanings, never a guess at what an old key used to mean. `role` on a
|
|
88
|
+
// node or in a `where` entry, `codeRole` as a filter key, and `$codeRole` as a
|
|
89
|
+
// reference are all caught here, before any normalizer can silently ignore them.
|
|
90
|
+
const walkVocabulary = (value) => {
|
|
91
|
+
if (typeof value === "string") {
|
|
92
|
+
if (value.includes("$codeRole"))
|
|
93
|
+
throw configError.legacyReference({ ref: "$codeRole" });
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (Array.isArray(value)) {
|
|
97
|
+
for (const item of value)
|
|
98
|
+
walkVocabulary(item);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (!(0, field_1.isObj)(value))
|
|
102
|
+
return;
|
|
103
|
+
for (const [key, item] of Object.entries(value)) {
|
|
104
|
+
if (key === "role")
|
|
105
|
+
throw configError.legacyRoleKey();
|
|
106
|
+
if (key === "codeRole")
|
|
107
|
+
throw configError.legacyFilterKey();
|
|
108
|
+
walkVocabulary(item);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const assertCurrentVocabulary = (raw) => {
|
|
112
|
+
for (const key of Object.keys(raw)) {
|
|
113
|
+
if (schema_1.SCHEMA.top.includes(key) || TOOL_KEYS.has(key))
|
|
114
|
+
continue;
|
|
115
|
+
throw configError.unknownTopKey({ key });
|
|
116
|
+
}
|
|
117
|
+
walkVocabulary(raw);
|
|
118
|
+
};
|
|
66
119
|
const buildArchitecture = (raw) => {
|
|
67
120
|
if (!(0, field_1.isObj)(raw))
|
|
68
121
|
throw configError.notAnObject();
|
|
69
122
|
const config = raw;
|
|
123
|
+
assertCurrentVocabulary(config);
|
|
70
124
|
if (!nodesOf(config).length)
|
|
71
125
|
throw configError.withoutNodes();
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
126
|
+
// The alias map is read ONCE, before anything that can name a place: node
|
|
127
|
+
// names, rule globs, `location` filters and the import resolver all ask the
|
|
128
|
+
// same `utils/aliases` reader, so a specifier means the same everywhere.
|
|
129
|
+
const aliases = (0, aliases_1.normalizeAliases)(config.aliases ?? {});
|
|
130
|
+
const entities = config.entities ? (0, entities_1.normalizeEntities)(config.entities, aliases) : {};
|
|
131
|
+
const tree = (0, tree_1.buildTree)(config.nodes, aliases);
|
|
132
|
+
const rules = (0, remeda_1.pipe)(config.rules ?? [], (0, remeda_1.map)((i) => (0, normalize_1.normalizeRule)(i, new Set(Object.keys(entities)), aliases)));
|
|
75
133
|
const arch = {
|
|
76
134
|
nodes: tree,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
aliases
|
|
135
|
+
entities,
|
|
136
|
+
rules,
|
|
137
|
+
aliases,
|
|
80
138
|
// The config as written, for consumers that show it back (the overview).
|
|
81
139
|
raw: config,
|
|
82
140
|
};
|
|
@@ -148,18 +206,88 @@ const loadArchitecture = (config) => {
|
|
|
148
206
|
return naming(file, () => buildArchitecture(parseArchitecture(readConfigText(file), file)));
|
|
149
207
|
};
|
|
150
208
|
exports.loadArchitecture = loadArchitecture;
|
|
209
|
+
// `--barrel-depth <n>`: a positive integer, or the reader is told why not.
|
|
210
|
+
const barrelDepthArg = (raw) => {
|
|
211
|
+
const depth = Number(raw);
|
|
212
|
+
if (!Number.isInteger(depth) || depth < 1)
|
|
213
|
+
throw configError.limitNotPositiveInteger({ key: "--barrel-depth", value: raw });
|
|
214
|
+
return depth;
|
|
215
|
+
};
|
|
216
|
+
// One `--files` entry: a FILE, or a FOLDER with the scanned files it holds.
|
|
217
|
+
// A folder used to match nothing — the entry was dropped for not being a file and
|
|
218
|
+
// the report came back empty. `scanned` is the universe, so a folder can never
|
|
219
|
+
// pull in a file the scan does not read.
|
|
220
|
+
const filesOfEntry = (repoRoot, scanned, entry) => {
|
|
221
|
+
const abs = path.resolve(repoRoot, entry);
|
|
222
|
+
if (!fs.existsSync(abs))
|
|
223
|
+
return [];
|
|
224
|
+
if (fs.statSync(abs).isFile())
|
|
225
|
+
return [abs];
|
|
226
|
+
const prefix = abs.endsWith(path.sep) ? abs : `${abs}${path.sep}`;
|
|
227
|
+
return scanned.filter((file) => file.startsWith(prefix));
|
|
228
|
+
};
|
|
151
229
|
// The files a run checks: `--files` restricts the scan to the given files
|
|
152
230
|
// (agent stop-hooks lint only changed files); otherwise every scanned file.
|
|
153
231
|
const collectedFiles = (repoRoot, scanned, files) => {
|
|
154
232
|
if (files.length) {
|
|
155
|
-
return (0, remeda_1.pipe)(files, (0, remeda_1.
|
|
233
|
+
return (0, remeda_1.pipe)(files, (0, remeda_1.flatMap)((entry) => filesOfEntry(repoRoot, scanned, entry)), (0, remeda_1.map)((abs) => ({ abs, rel: (0, imports_1.toRel)(repoRoot, abs) })));
|
|
156
234
|
}
|
|
157
235
|
return (0, remeda_1.pipe)(scanned, (0, remeda_1.map)((abs) => ({ abs, rel: (0, imports_1.toRel)(repoRoot, abs) })));
|
|
158
236
|
};
|
|
159
|
-
// The run's findings: every checked file, one shared dedupe store.
|
|
237
|
+
// The run's findings: every checked file, one shared dedupe store. The files are
|
|
238
|
+
// checked against the ONE project over the scan — `references` asks across files,
|
|
239
|
+
// so a per-file project would answer "nobody uses this" for a name the rest of
|
|
240
|
+
// the repo calls.
|
|
241
|
+
// What the index did, for `FA_INDEX_VERBOSE`; a failed write is always reported,
|
|
242
|
+
// because the run then keeps its findings but forgets them.
|
|
243
|
+
const reportIndex = (stats, file) => {
|
|
244
|
+
if (process.env.FA_INDEX_VERBOSE) {
|
|
245
|
+
console.error(`fa index: ${stats.mode} stale=${stats.stale} zone=${stats.zone} extracted=${stats.extracted} written=${stats.written} chunks=${stats.chunks} compacted=${stats.compactions} pruned=${stats.pruned} bytes=${stats.bytes}`);
|
|
246
|
+
}
|
|
247
|
+
if (stats.warning !== null)
|
|
248
|
+
console.error(`follow-architecture: ${stats.warning}`);
|
|
249
|
+
// Not a failure: the records are in the file and the file keeps its size. Said
|
|
250
|
+
// once per run, in the index's words, only when there is a file to name.
|
|
251
|
+
if (stats.compactionWarning !== null && file !== undefined)
|
|
252
|
+
console.error(`follow-architecture: ${(0, fa_store_1.compactionLine)(file, stats.compactionWarning)}`);
|
|
253
|
+
};
|
|
254
|
+
// The files `--files` named that the scan never saw: those are checked the plain
|
|
255
|
+
// way, because nothing about them is in the index.
|
|
256
|
+
const outsideOf = (files, shouldCheck, inside) => (0, remeda_1.pipe)(files, (0, remeda_1.filter)((f) => shouldCheck(f.rel) && !inside.has(f.abs)));
|
|
160
257
|
const runFindings = (files, run) => {
|
|
161
258
|
const dedupe = new Map();
|
|
162
|
-
|
|
259
|
+
// The scan's own answers first: with an index the run reads what it already
|
|
260
|
+
// knows and only looks at what changed. Null means this run has no usable
|
|
261
|
+
// index, and the plain path below reads every file.
|
|
262
|
+
// `--files` narrows what is REPORTED, not what the repo answers: the index still
|
|
263
|
+
// covers every scanned file, so a dependency outside the list is still known.
|
|
264
|
+
const reported = new Set((0, remeda_1.pipe)(files, (0, remeda_1.filter)((f) => run.shouldCheck(f.rel)), (0, remeda_1.map)((f) => f.rel)));
|
|
265
|
+
const indexed = (0, index_run_1.runIndexed)({
|
|
266
|
+
arch: run.arch,
|
|
267
|
+
repoFiles: run.repoFiles,
|
|
268
|
+
absFiles: run.scanned,
|
|
269
|
+
scope: run.scope,
|
|
270
|
+
option: run.index,
|
|
271
|
+
usage: run.usage,
|
|
272
|
+
dedupe,
|
|
273
|
+
shouldCheck: (abs) => reported.has((0, imports_1.toRel)(run.arch.repoRoot ?? ".", abs)),
|
|
274
|
+
});
|
|
275
|
+
if (indexed !== null)
|
|
276
|
+
reportIndex(indexed.stats, run.index);
|
|
277
|
+
// Who answers `references`, and — for the plain path below, which reads every
|
|
278
|
+
// file — the name counts that answer it without a project.
|
|
279
|
+
(0, usage_prepare_1.prepareUsage)(run.usage, run.arch.repoRoot ?? ".", run.repoFiles);
|
|
280
|
+
const project = (0, scan_run_1.wholeRepoProject)();
|
|
281
|
+
// `--files` may name a file outside the scan scope: that one is checked the
|
|
282
|
+
// plain way, exactly as before.
|
|
283
|
+
const inside = new Set(run.scanned);
|
|
284
|
+
const outside = indexed === null ? [] : outsideOf(files, run.shouldCheck, inside);
|
|
285
|
+
const findings = indexed !== null
|
|
286
|
+
? [
|
|
287
|
+
...indexed.findings,
|
|
288
|
+
...(0, remeda_1.pipe)(outside, (0, remeda_1.flatMap)((f) => (0, pipeline_1.checkFile)(f.abs, run.arch, project, run.repoFiles, dedupe))),
|
|
289
|
+
]
|
|
290
|
+
: (0, remeda_1.pipe)(files, (0, remeda_1.filter)((f) => run.shouldCheck(f.rel)), (0, remeda_1.flatMap)((f) => (0, pipeline_1.checkFile)(f.abs, run.arch, project, run.repoFiles, dedupe)));
|
|
163
291
|
const orphans = (0, remeda_1.pipe)(files, (0, remeda_1.filter)((f) => !run.shouldCheck(f.rel)), (0, remeda_1.map)((f) => f.rel), (r) => [...r].sort());
|
|
164
292
|
return { findings, orphans };
|
|
165
293
|
};
|
|
@@ -193,37 +321,82 @@ const writeTextReport = (args, run) => {
|
|
|
193
321
|
}
|
|
194
322
|
return args.check && run.findings.length > 0 ? 1 : 0;
|
|
195
323
|
};
|
|
324
|
+
const configOf = (args, cwd) => typeof args.config === "string" ? path.resolve(cwd, args.config) : args.config;
|
|
325
|
+
// ONE DIRECTORY, ONE NAME. The index is keyed by the repo root, and the same
|
|
326
|
+
// directory answers to several names: a symlinked home reaches it as `/home/...`
|
|
327
|
+
// or as `/var/home/...`, and the CLI and the editor's server each pick their own.
|
|
328
|
+
// An index written under one spelling was foreign under the other, so the rule
|
|
329
|
+
// silently re-read the whole repo on its first pull — a `--config` path the shell
|
|
330
|
+
// spelled one way and the server another were two repos. Both entry points
|
|
331
|
+
// canonicalise the root BEFORE it becomes a file path, so the file, the header and
|
|
332
|
+
// every abs path in it agree.
|
|
333
|
+
const canonicalRoot = (dir) => {
|
|
334
|
+
try {
|
|
335
|
+
return fs.realpathSync(dir);
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
return dir;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
exports.canonicalRoot = canonicalRoot;
|
|
342
|
+
// The repo starts where the architecture file is — the SAME anchor the ESLint
|
|
343
|
+
// rule uses — so `--config ../arch.yaml` scans the repo that file describes.
|
|
344
|
+
// An explicit `--cwd` still decides where the scan begins.
|
|
345
|
+
const repoOf = (args, cwd) => {
|
|
346
|
+
if (typeof args.config !== "string" || args.cwd != null)
|
|
347
|
+
return canonicalRoot(cwd);
|
|
348
|
+
return canonicalRoot(path.dirname(path.resolve(cwd, args.config)));
|
|
349
|
+
};
|
|
350
|
+
exports.repoOf = repoOf;
|
|
196
351
|
const main = (argv) => {
|
|
197
352
|
const args = (0, args_1.parseArgs)(argv);
|
|
198
353
|
if (args.help) {
|
|
199
|
-
console.log("usage: follow-architecture [--config <path>] [--ext <.ext>]... [--ignore <glob>]... [--ignore-dir <name>]... [--files <path>]... [--out <path>] [--overview [path]] [--check]");
|
|
354
|
+
console.log("usage: follow-architecture [--config <path>] [--ext <.ext>]... [--ignore <glob>]... [--ignore-dir <name>]... [--files <path>]... [--out <path>] [--overview [path]] [--index <path|off>] [--usage <checker|index>] [--barrel-depth <n>] [--check]");
|
|
200
355
|
return 0;
|
|
201
356
|
}
|
|
202
357
|
const cwd = path.resolve(args.cwd ?? process.cwd());
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
// An explicit `--cwd` still decides where the scan begins.
|
|
206
|
-
const configPath = typeof args.config === "string" ? path.resolve(cwd, args.config) : args.config;
|
|
207
|
-
const repoRoot = typeof configPath === "string" && args.cwd == null ? path.dirname(configPath) : cwd;
|
|
358
|
+
const configPath = configOf(args, cwd);
|
|
359
|
+
const repoRoot = repoOf(args, cwd);
|
|
208
360
|
const arch = loadArchitecture(configPath);
|
|
209
361
|
arch.repoRoot = repoRoot;
|
|
362
|
+
// How far a name may travel through barrels before the walk stops. A TOOL
|
|
363
|
+
// option (`--barrel-depth`, the rule's `barrelDepth`), never a config section:
|
|
364
|
+
// where a name is judged is the law, not a per-repo budget.
|
|
365
|
+
if (args.barrelDepth !== undefined)
|
|
366
|
+
arch.barrelDepth = barrelDepthArg(args.barrelDepth);
|
|
210
367
|
const shouldCheck = (0, tree_1.matchers)(arch);
|
|
211
368
|
// Scan scope is the TOOL's: its defaults, extended by `--ext`, never by the
|
|
212
369
|
// architecture (which describes code, not how to find it).
|
|
213
370
|
const exts = [...new Set([...pattern_1.DEFAULT_EXTS, ...(args.ext ?? [])])];
|
|
214
371
|
const ignoreDirs = [...new Set([...pattern_1.DEFAULT_IGNORE_DIRS, ...(args.ignoreDir ?? [])])];
|
|
372
|
+
// Repo-relative paths a REPOSITORY declares out of scope: `--ignore` only. The
|
|
373
|
+
// tool ships none (`IGNORE_PATHS` is empty) — an `apps/`, a `scripts/` or a
|
|
374
|
+
// `.js` rule of one monorepo must not hide a consumer's code.
|
|
375
|
+
const ignoreGlobs = [...new Set([...pattern_1.DEFAULT_IGNORE_PATHS, ...(args.ignore ?? [])])];
|
|
215
376
|
// ONE walk: the scan list, the repo file list and the ts-morph project are the
|
|
216
377
|
// same set of files. `references` asks who uses a name ACROSS files.
|
|
217
|
-
const scanned = (0, files_1.collectFiles)(repoRoot, { exts, ignoreDirs, ignoreGlobs
|
|
218
|
-
|
|
378
|
+
const scanned = (0, files_1.collectFiles)(repoRoot, { exts, ignoreDirs, ignoreGlobs });
|
|
379
|
+
// The scan's file list decides which project holds what: per-file work reads the
|
|
380
|
+
// shards this run opens, whole-repo questions read the one project over `scanned`.
|
|
381
|
+
(0, scan_run_1.openRun)({ repoRoot, arch, absFiles: scanned });
|
|
219
382
|
const collected = collectedFiles(repoRoot, scanned, args.files);
|
|
220
383
|
// `repoFiles` is the FULL repo file list (for import resolution and folder
|
|
221
384
|
// facts), even when `--files` restricts which files are CHECKED.
|
|
222
385
|
const repoFiles = (0, remeda_1.pipe)(scanned, (0, remeda_1.map)((abs) => (0, imports_1.toRel)(repoRoot, abs)));
|
|
223
|
-
const
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
386
|
+
const scope = { exts, ignoreDirs, ignoreGlobs };
|
|
387
|
+
const { findings, orphans } = runFindings(collected, {
|
|
388
|
+
arch,
|
|
389
|
+
repoFiles,
|
|
390
|
+
shouldCheck,
|
|
391
|
+
scanned,
|
|
392
|
+
scope,
|
|
393
|
+
index: args.index,
|
|
394
|
+
usage: args.usage,
|
|
395
|
+
});
|
|
396
|
+
const code = args.overview
|
|
397
|
+
? writeOverviewReport({ overview: args.overview, check: args.check }, { arch, findings, orphans, repoFiles, repoRoot, configPath, project: (0, scan_run_1.wholeRepoProject)() })
|
|
398
|
+
: writeTextReport({ out: args.out, check: args.check }, { findings, orphans, repoRoot });
|
|
399
|
+
(0, scan_run_1.endRun)();
|
|
400
|
+
return code;
|
|
228
401
|
};
|
|
229
402
|
exports.main = main;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.entitiesOfChild = void 0;
|
|
4
|
+
const entitiesOfChild = (arch, child) => {
|
|
5
|
+
if (!child)
|
|
6
|
+
return [];
|
|
7
|
+
if (child.entities?.length)
|
|
8
|
+
return child.entities;
|
|
9
|
+
const target = child.nodeSlug ? arch.nodes.bySlug[child.nodeSlug] : null;
|
|
10
|
+
return target?.entities ?? [];
|
|
11
|
+
};
|
|
12
|
+
exports.entitiesOfChild = entitiesOfChild;
|
package/dist/nodes/children.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Arch, ArchChild, ArchNode, ArchVariant, RawChild, RawNode } from "
|
|
1
|
+
import type { Arch, ArchChild, ArchNode, ArchVariant, RawChild, RawNode } from "@md-code/follow-architecture/entities/architecture";
|
|
2
2
|
type FolderContents = {
|
|
3
3
|
present: Set<string>;
|
|
4
4
|
declared: ArchChild[];
|
|
@@ -16,10 +16,10 @@ declare const missingRequiredChild: (node: ArchNode, arch: Arch, rel: string, ct
|
|
|
16
16
|
declare const nodePathRe: (template: string) => RegExp;
|
|
17
17
|
type PrefixMatcher = Pick<ArchVariant, "re" | "names" | "literalLen" | "isFile">;
|
|
18
18
|
declare const nodePrefixRe: (template: string) => PrefixMatcher;
|
|
19
|
-
declare const
|
|
20
|
-
|
|
19
|
+
declare const entitiesOf: (spec: {
|
|
20
|
+
entity?: string | string[] | null;
|
|
21
21
|
} | null | undefined) => string[];
|
|
22
22
|
declare const compileChild: (name: RawChild) => ArchChild;
|
|
23
|
-
export { nodePathRe, nodePrefixRe, compileChild, folderContents, missingRequiredChild, ancestorChain,
|
|
23
|
+
export { nodePathRe, nodePrefixRe, compileChild, folderContents, missingRequiredChild, ancestorChain, entitiesOf };
|
|
24
24
|
export type { ConcreteFolder };
|
|
25
25
|
export type { RawNode, RawChild };
|