@md-code/follow-architecture 0.3.0 → 0.3.2
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 +21 -0
- package/README.md +1310 -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 +132 -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} +98 -61
- package/dist/code-entities/project.d.ts +21 -0
- package/dist/code-entities/project.js +259 -0
- package/dist/code-entities/walk.d.ts +31 -0
- package/dist/code-entities/walk.js +105 -0
- package/dist/config-options.d.ts +23 -0
- package/dist/config-options.js +18 -1
- package/dist/config-project.js +27 -9
- package/dist/config-report.d.ts +1 -1
- package/dist/config-report.js +37 -10
- package/dist/config-rule.d.ts +25 -0
- package/dist/config-rule.js +106 -13
- package/dist/config-state.d.ts +14 -3
- package/dist/config-state.js +197 -24
- package/dist/config.d.ts +25 -0
- package/dist/css/index.d.ts +11 -7
- package/dist/css/index.js +141 -30
- 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 +18 -8
- 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 +21 -9
- package/dist/css/syntax/scss/index.d.ts +2 -2
- package/dist/css/syntax/scss/index.js +18 -8
- 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 +34 -14
- 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 +32 -15
- 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 +21 -11
- 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 +148 -37
- 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 +10 -8
- package/dist/entities/location/where.js +89 -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 +89 -19
- 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 +112 -51
- package/dist/entities/tree/entries.d.ts +4 -4
- 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 +26 -12
- 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 +242 -0
- package/dist/fa-store.d.ts +22 -0
- package/dist/fa-store.js +232 -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 +297 -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 +25 -11
- 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 +62 -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 +219 -0
- package/dist/main.d.ts +5 -2
- package/dist/main.js +223 -41
- 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 +64 -11
- package/dist/nodes/finally/emit.d.ts +4 -4
- 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 +78 -56
- 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 +64 -62
- 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.d.ts +1 -1
- 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 +21 -11
- 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/index.js +17 -7
- 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 +26 -7
- 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 +32 -19
- 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 +136 -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 +33 -23
- 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 +19 -9
- 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/index.js +17 -7
- 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/rules/normalize.js +108 -0
- 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 +19 -9
- package/dist/usage-index.d.ts +4 -0
- package/dist/usage-index.js +282 -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 +264 -0
- package/dist/utils/aliases.d.ts +22 -0
- package/dist/utils/aliases.js +173 -0
- package/dist/utils/classify.d.ts +2 -2
- package/dist/utils/classify.js +4 -4
- package/dist/utils/configs.js +17 -7
- package/dist/utils/distinct.js +4 -2
- package/dist/utils/files.js +41 -37
- 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 +83 -19
- 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 +207 -0
- package/dist/utils/path-label.js +3 -1
- package/dist/utils/pattern.d.ts +5 -4
- package/dist/utils/pattern.js +55 -15
- 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/invariants/normalize.js +0 -95
- 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
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { FieldValue } from "
|
|
1
|
+
import type { FieldValue } from "@md-code/follow-architecture/utils/field";
|
|
2
2
|
type Violation = {
|
|
3
3
|
line: number;
|
|
4
4
|
text: string;
|
|
5
5
|
fix?: string | null;
|
|
6
6
|
ask?: string | null;
|
|
7
7
|
kind?: string;
|
|
8
|
-
|
|
8
|
+
entity?: string | null;
|
|
9
9
|
names?: string[];
|
|
10
10
|
where?: string | null;
|
|
11
11
|
owning?: string | null;
|
package/dist/nodes/similar.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Arch, ArchNode } from "
|
|
2
|
-
import type { ScanContext } from "
|
|
1
|
+
import type { Arch, ArchNode } from "@md-code/follow-architecture/entities/architecture";
|
|
2
|
+
import type { ScanContext } from "@md-code/follow-architecture/entities/context";
|
|
3
3
|
declare const criteriaOf: (arch: Arch, node: ArchNode) => string[];
|
|
4
4
|
type SimilarCache = {
|
|
5
5
|
files: Map<string, string[]>;
|
|
@@ -14,7 +14,7 @@ type Lookalike = {
|
|
|
14
14
|
score: number;
|
|
15
15
|
hit: number;
|
|
16
16
|
total: number;
|
|
17
|
-
|
|
17
|
+
entities: string[];
|
|
18
18
|
};
|
|
19
19
|
declare const similarNodes: (arch: Arch, folder: string, ctx: SimilarScan | null | undefined, threshold?: number) => Lookalike[];
|
|
20
20
|
export { similarNodes, criteriaOf };
|
package/dist/nodes/similar.js
CHANGED
|
@@ -15,24 +15,34 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.criteriaOf = exports.similarNodes = void 0;
|
|
27
|
-
// HOW MUCH a folder LOOKS LIKE a declared entity — measured in
|
|
37
|
+
// HOW MUCH a folder LOOKS LIKE a declared entity — measured in ENTITYS, not in
|
|
28
38
|
// file names.
|
|
29
39
|
//
|
|
30
40
|
// A folder is a feature when the code inside it IS the code a feature holds: a
|
|
31
41
|
// store model, actions, a controller. Whether the file is called `store.ts` or
|
|
32
|
-
// `whatever.ts` says nothing — the
|
|
33
|
-
// entity contributes the
|
|
34
|
-
//
|
|
35
|
-
// the score is the share of the entity's
|
|
42
|
+
// `whatever.ts` says nothing — the ENTITY of the code does. So each declared
|
|
43
|
+
// entity contributes the entities its children declare, the folder contributes the
|
|
44
|
+
// entities its files actually have (classified exactly like everything else), and
|
|
45
|
+
// the score is the share of the entity's entities that are already there.
|
|
36
46
|
//
|
|
37
47
|
// Only entities at or above the threshold are offered, and ALL of them are: a
|
|
38
48
|
// folder can be 80% a feature and 66% a type home, and both are true answers.
|
|
@@ -40,22 +50,23 @@ exports.criteriaOf = exports.similarNodes = void 0;
|
|
|
40
50
|
// default 60%).
|
|
41
51
|
const fs = __importStar(require("node:fs"));
|
|
42
52
|
const path = __importStar(require("node:path"));
|
|
43
|
-
const notices_1 = require("
|
|
44
|
-
const pattern_1 = require("
|
|
45
|
-
const
|
|
46
|
-
const classify_1 = require("
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
53
|
+
const notices_1 = require("@md-code/follow-architecture/report/notices");
|
|
54
|
+
const pattern_1 = require("@md-code/follow-architecture/utils/pattern");
|
|
55
|
+
const index_1 = require("@md-code/follow-architecture/entities/ast/index");
|
|
56
|
+
const classify_1 = require("@md-code/follow-architecture/code-entities/classify");
|
|
57
|
+
const project_1 = require("@md-code/follow-architecture/code-entities/project");
|
|
58
|
+
const location_1 = require("@md-code/follow-architecture/entities/location");
|
|
59
|
+
const try_read_1 = require("@md-code/follow-architecture/utils/try-read");
|
|
60
|
+
const reason_1 = require("@md-code/follow-architecture/utils/reason");
|
|
61
|
+
const distinct_1 = require("@md-code/follow-architecture/utils/distinct");
|
|
62
|
+
const rank_1 = require("@md-code/follow-architecture/utils/rank");
|
|
63
|
+
const child_entities_1 = require("./child-entities");
|
|
64
|
+
// The entities an entity is MADE OF — one criterion per entity, not per file.
|
|
54
65
|
// The distinct-collect walk is the shared `distinctFlat` core; the child's
|
|
55
|
-
//
|
|
66
|
+
// entities are the shared `entitiesOfChild` reading.
|
|
56
67
|
const criteriaOf = (arch, node) => {
|
|
57
68
|
const children = node.children ?? [];
|
|
58
|
-
return (0, distinct_1.distinctFlat)(children, (c) => (0,
|
|
69
|
+
return (0, distinct_1.distinctFlat)(children, (c) => (0, child_entities_1.entitiesOfChild)(arch, c));
|
|
59
70
|
};
|
|
60
71
|
exports.criteriaOf = criteriaOf;
|
|
61
72
|
// The files that belong to this folder: the entity's children live at the top of
|
|
@@ -64,28 +75,39 @@ const filesIn = (folder, repoFiles) => {
|
|
|
64
75
|
const depth = (0, location_1.segmentsOf)(folder).length;
|
|
65
76
|
return (repoFiles ?? []).filter((file) => file.startsWith(`${folder}/`) && (0, location_1.segmentsOf)(file).length - depth <= 2);
|
|
66
77
|
};
|
|
67
|
-
// The
|
|
68
|
-
// else. A file outside the project contributes no
|
|
69
|
-
// because "no
|
|
70
|
-
const
|
|
78
|
+
// The entities one file's code has, parsed and classified exactly like everything
|
|
79
|
+
// else. A file outside the project contributes no entities — and says why,
|
|
80
|
+
// because "no entities" and "could not look" are different answers.
|
|
81
|
+
const entitiesOfFile = (rel, ctx) => (0, try_read_1.readOrFallback)(rel, (file) => {
|
|
71
82
|
const abs = path.join(ctx.repoRoot, file);
|
|
72
|
-
const sf = (0,
|
|
73
|
-
const importMap = (0,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
//
|
|
83
|
+
const sf = (0, index_1.loadSourceFile)(ctx.project, abs, fs.readFileSync(abs, "utf8"));
|
|
84
|
+
const importMap = (0, index_1.importNameModules)(sf, ctx.repoRoot, ctx.aliases ?? {}, ctx.repoFiles);
|
|
85
|
+
// Which entity a piece IS is a classification question; the checker's
|
|
86
|
+
// project-wide `references` answer is not read here, so it is not asked
|
|
87
|
+
// for — this pass runs over a whole folder and would otherwise pay the
|
|
88
|
+
// heaviest fact for every file in it.
|
|
89
|
+
const candidates = (0, index_1.collectCandidates)(sf, importMap, file, ctx.repoRoot, { usage: false });
|
|
90
|
+
return (0, classify_1.classifyEntities)(candidates, ctx.arch?.entities ?? {}, ctx.arch).present;
|
|
91
|
+
}, [], (e) => (0, notices_1.notice)(`the entities in ${rel} could not be read`, (0, reason_1.reasonOf)(e)));
|
|
92
|
+
// The entities the folder's code actually has. Parsed and classified once per file
|
|
78
93
|
// per run — the folder is judged by the same facts its own findings come from.
|
|
79
|
-
const
|
|
80
|
-
const
|
|
94
|
+
const entitiesInFolder = (ctx, folder) => {
|
|
95
|
+
const entities = new Set();
|
|
81
96
|
const cache = (ctx.cache ??= { files: new Map() });
|
|
97
|
+
// The project-wide index already classified every file of this folder — reading
|
|
98
|
+
// its answer costs a map lookup instead of a second parse of the whole folder.
|
|
99
|
+
// A run whose index is not built yet (the first file's checks) parses, exactly
|
|
100
|
+
// as before.
|
|
101
|
+
const classified = (0, project_1.projectEntitiesByFile)();
|
|
82
102
|
for (const rel of filesIn(folder, ctx.repoFiles)) {
|
|
83
|
-
if (!cache.files.has(rel))
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
103
|
+
if (!cache.files.has(rel)) {
|
|
104
|
+
const known = classified?.get(rel);
|
|
105
|
+
cache.files.set(rel, known ? [...known] : entitiesOfFile(rel, ctx));
|
|
106
|
+
}
|
|
107
|
+
for (const entity of cache.files.get(rel) ?? [])
|
|
108
|
+
entities.add(entity);
|
|
87
109
|
}
|
|
88
|
-
return
|
|
110
|
+
return entities;
|
|
89
111
|
};
|
|
90
112
|
// Whether this folder IS this entity — the node's path as a template, matched
|
|
91
113
|
// against the concrete folder (`apps/backend/{kebab-case}` ← `apps/backend/document`).
|
|
@@ -95,21 +117,21 @@ const isOwnPath = (node, folder) => (node.variants ?? [])
|
|
|
95
117
|
.some((template) => (0, pattern_1.compilePattern)(template).re.test(folder));
|
|
96
118
|
// Lookalikes answer ONE question: "this folder is declared nowhere — what does it
|
|
97
119
|
// look like?" A folder the architecture already places gets a precise answer from
|
|
98
|
-
// the
|
|
99
|
-
//
|
|
100
|
-
// its problem is that a piece inside it fits no declared
|
|
120
|
+
// the entity homes (`placeFor`), and offering it a sibling entity made of the same
|
|
121
|
+
// entities only says "move an action out of `actions/`", which is not its problem:
|
|
122
|
+
// its problem is that a piece inside it fits no declared entity.
|
|
101
123
|
const isDeclaredPath = (arch, folder) => (arch.nodes.all ?? []).some((n) => isOwnPath(n, folder));
|
|
102
124
|
// TWO SIDES OF ONE COMPARISON. The entity must cover most of its OWN shape
|
|
103
|
-
// (`commands` declares two
|
|
125
|
+
// (`commands` declares two entities and every folder holding both is 2/2 —
|
|
104
126
|
// "looks like a command folder" was true of a whole feature), AND the entity
|
|
105
127
|
// must account for most of what the folder actually holds, or it explains
|
|
106
128
|
// only a corner of it and is not a shape this folder has.
|
|
107
129
|
const resembles = (criteria, present, threshold) => {
|
|
108
|
-
// A shape needs at least two
|
|
109
|
-
//
|
|
130
|
+
// A shape needs at least two entities to be a shape: an entity declaring one
|
|
131
|
+
// entity would match half the folders in any repo.
|
|
110
132
|
if (criteria.length < 2)
|
|
111
133
|
return null;
|
|
112
|
-
const hit = criteria.filter((
|
|
134
|
+
const hit = criteria.filter((entity) => present.has(entity));
|
|
113
135
|
const score = hit.length / criteria.length;
|
|
114
136
|
if (score < threshold || hit.length / present.size < threshold)
|
|
115
137
|
return null;
|
|
@@ -120,34 +142,34 @@ const resembles = (criteria, present, threshold) => {
|
|
|
120
142
|
// is an instance of `apps/backend/{kebab-case}`, and the variant's own path is
|
|
121
143
|
// a template — comparing it as text never matched, so the offer read "move
|
|
122
144
|
// this feature's controller into this feature".
|
|
123
|
-
// The offer a measured hit earns: the entity's own path, its score, its
|
|
145
|
+
// The offer a measured hit earns: the entity's own path, its score, its entities.
|
|
124
146
|
const offerOf = (node, hit, total) => ({
|
|
125
147
|
slug: node.slug,
|
|
126
148
|
path: node.variants?.[0]?.path ?? node.path ?? null,
|
|
127
149
|
score: hit.length / total,
|
|
128
150
|
hit: hit.length,
|
|
129
151
|
total,
|
|
130
|
-
|
|
152
|
+
entities: hit,
|
|
131
153
|
});
|
|
132
154
|
const lookalikeOf = (node, folder, match) => {
|
|
133
155
|
const criteria = criteriaOf(match.arch, node);
|
|
134
156
|
const hit = isOwnPath(node, folder) ? null : resembles(criteria, match.present, match.threshold);
|
|
135
157
|
return hit ? offerOf(node, hit, criteria.length) : null;
|
|
136
158
|
};
|
|
137
|
-
// The folder's own
|
|
159
|
+
// The folder's own entity set, when there is anything to compare: a folder the
|
|
138
160
|
// architecture already declares (or that holds no classifiable code) has no
|
|
139
161
|
// lookalike question to answer.
|
|
140
|
-
const
|
|
162
|
+
const folderEntities = (arch, folder, ctx) => {
|
|
141
163
|
if (!ctx?.project || isDeclaredPath(arch, folder))
|
|
142
164
|
return null;
|
|
143
|
-
const present =
|
|
165
|
+
const present = entitiesInFolder({ ...ctx, arch }, folder);
|
|
144
166
|
return present.size ? present : null;
|
|
145
167
|
};
|
|
146
168
|
// The declared entities this folder resembles, best first. `score` is the share
|
|
147
|
-
// of the entity's
|
|
169
|
+
// of the entity's entities the folder already holds. The score-keep-rank walk is
|
|
148
170
|
// the shared `rankedOffers` core.
|
|
149
171
|
const similarNodes = (arch, folder, ctx, threshold = arch.similarity ?? pattern_1.DEFAULT_SIMILARITY) => {
|
|
150
|
-
const present =
|
|
172
|
+
const present = folderEntities(arch, folder, ctx);
|
|
151
173
|
if (!present)
|
|
152
174
|
return [];
|
|
153
175
|
const match = { arch, present, threshold };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Candidate } from "./entities/facts";
|
|
2
|
+
declare const governedByValues: (c: Candidate) => boolean;
|
|
3
|
+
type Described = {
|
|
4
|
+
lines: ReadonlySet<number>;
|
|
5
|
+
names: ReadonlySet<string>;
|
|
6
|
+
};
|
|
7
|
+
declare const unclassifiedPiece: (c: Candidate, described: Described, touching: ReadonlySet<string>) => boolean;
|
|
8
|
+
export { governedByValues, unclassifiedPiece };
|
|
9
|
+
export type { Described };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unclassifiedPiece = exports.governedByValues = void 0;
|
|
4
|
+
// A PIECE is a candidate that can carry an entity. Every candidate the AST layer
|
|
5
|
+
// collects is one, except two structural cases: a variable declared INSIDE a
|
|
6
|
+
// function (the function answers for it) and an anonymous function handed
|
|
7
|
+
// straight to a call — that is the call's ARGUMENT (`.map(x => …)`), not code
|
|
8
|
+
// with a life of its own. A `const` is a piece only at MODULE scope.
|
|
9
|
+
// The kinds whose body is a scope of its own: a binding inside one is a LOCAL,
|
|
10
|
+
// and the function, loop or class that owns it answers for it. A `for (const x
|
|
11
|
+
// of …)` at the top of a module declares a loop variable, not a piece of the
|
|
12
|
+
// module.
|
|
13
|
+
const LOCAL_SCOPES = new Set([
|
|
14
|
+
"FunctionDeclaration",
|
|
15
|
+
"MethodDeclaration",
|
|
16
|
+
"ArrowFunction",
|
|
17
|
+
"FunctionExpression",
|
|
18
|
+
"Constructor",
|
|
19
|
+
"GetAccessor",
|
|
20
|
+
"SetAccessor",
|
|
21
|
+
"Block",
|
|
22
|
+
"CaseClause",
|
|
23
|
+
"ModuleBlock",
|
|
24
|
+
"ForStatement",
|
|
25
|
+
"ForOfStatement",
|
|
26
|
+
"ForInStatement",
|
|
27
|
+
"WhileStatement",
|
|
28
|
+
"DoStatement",
|
|
29
|
+
"ClassDeclaration",
|
|
30
|
+
"ClassExpression",
|
|
31
|
+
]);
|
|
32
|
+
const atModuleScope = (c) => !(c.kind?.ancestors ?? []).some((a) => LOCAL_SCOPES.has(a.is ?? ""));
|
|
33
|
+
const isPiece = (c) => {
|
|
34
|
+
if ((c.kind?.own?.is ?? null) === "VariableDeclaration")
|
|
35
|
+
return atModuleScope(c);
|
|
36
|
+
return c.name != null || c.kind?.parent?.is !== "CallExpression";
|
|
37
|
+
};
|
|
38
|
+
// A piece whose VALUE is judged by the css-fact rules, not by an entity: a
|
|
39
|
+
// styled/createGlobalStyle/css fragment (a tagged template), or a DATA literal
|
|
40
|
+
// (a token group, a breakpoint table, a rhythm origin). These are values, not
|
|
41
|
+
// behaviour — the settled model leaves them unclassified on purpose and checks their
|
|
42
|
+
// contents instead (`proper-values`, `proper-naming`, `proper-documentation`).
|
|
43
|
+
const VALUE_INITIALIZERS = new Set([
|
|
44
|
+
"TaggedTemplateExpression",
|
|
45
|
+
"ObjectLiteralExpression",
|
|
46
|
+
"SatisfiesExpression",
|
|
47
|
+
"AsExpression",
|
|
48
|
+
"ArrayLiteralExpression",
|
|
49
|
+
"NoSubstitutionTemplateLiteral",
|
|
50
|
+
]);
|
|
51
|
+
const governedByValues = (c) => VALUE_INITIALIZERS.has(c.kind?.initializer?.is ?? "");
|
|
52
|
+
exports.governedByValues = governedByValues;
|
|
53
|
+
const isClassified = (c, described) => Boolean(c.entity) || described.lines.has(c.lines?.[0] ?? 1) || (c.name != null && described.names.has(c.name));
|
|
54
|
+
const governedByValuesOrCss = (c) => Boolean(c.framework?.css?.templates?.length) || governedByValues(c);
|
|
55
|
+
// A module-scope binding the language lets change is a HIDDEN STORE: `let`/`var`
|
|
56
|
+
// at the top of a module outlives every call and is writable from every
|
|
57
|
+
// importer. The `no-hidden-store` law owns that — "make it a `const`, or move the
|
|
58
|
+
// changing value into the function that owns it" — so asking which entity it is
|
|
59
|
+
// asks the wrong question. Inside a function or a block the binding is a local,
|
|
60
|
+
// and its owner answers for it.
|
|
61
|
+
const hiddenStore = (c) => c.mutable === true && atModuleScope(c);
|
|
62
|
+
const unclassifiedPiece = (c, described, touching) => !isClassified(c, described) &&
|
|
63
|
+
isPiece(c) &&
|
|
64
|
+
Boolean(c.name) &&
|
|
65
|
+
touching.has(c.name ?? "") &&
|
|
66
|
+
!governedByValuesOrCss(c) &&
|
|
67
|
+
!hiddenStore(c);
|
|
68
|
+
exports.unclassifiedPiece = unclassifiedPiece;
|
|
@@ -2,5 +2,5 @@ import type { Arch } from "./entities/architecture";
|
|
|
2
2
|
import type { FileContext } from "./entities/context";
|
|
3
3
|
import type { Candidate } from "./entities/facts";
|
|
4
4
|
import type { Finding } from "./entities/findings";
|
|
5
|
-
declare const
|
|
6
|
-
export {
|
|
5
|
+
declare const checkEntityHomes: (withEntities: readonly Candidate[], ctx: FileContext, arch: Arch, out: Finding[]) => void;
|
|
6
|
+
export { checkEntityHomes };
|
|
@@ -1,56 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
// The
|
|
5
|
-
//
|
|
6
|
-
// reported with the place it belongs. ONE finding per
|
|
3
|
+
exports.checkEntityHomes = void 0;
|
|
4
|
+
// The ENTITY-HOME phase: every candidate must fit its ENTITY's declared home. A
|
|
5
|
+
// entity says where its code may be declared; code of that entity anywhere else is
|
|
6
|
+
// reported with the place it belongs. ONE finding per entity per file — four
|
|
7
7
|
// helpers in one file are one decision, not four copies of the same sentence.
|
|
8
8
|
const location_1 = require("./entities/location");
|
|
9
9
|
const finally_1 = require("./nodes/finally");
|
|
10
10
|
const asks_1 = require("./report/asks");
|
|
11
11
|
const cli_report_1 = require("./report/cli-report");
|
|
12
12
|
const qualified_1 = require("./utils/qualified");
|
|
13
|
-
// Is this candidate a misfit?
|
|
13
|
+
// Is this candidate a misfit? An entity's report is about a NAME: an anonymous
|
|
14
14
|
// function is the argument or the body of something else, and naming it would
|
|
15
|
-
// produce a sentence with a hole in it.
|
|
15
|
+
// produce a sentence with a hole in it. An entity nobody declares, or one with no
|
|
16
16
|
// home, restricts nothing. The guards are the shared qualified-answer walk;
|
|
17
|
-
// the home question is `
|
|
18
|
-
const
|
|
19
|
-
|
|
17
|
+
// the home question is `fitsEntity`'s own.
|
|
18
|
+
const misfitEntityOf = (c, arch, rel) => (0, qualified_1.answerWhenAllPass)(c, [
|
|
19
|
+
(x) => Boolean(x.entity && arch.entities?.[x.entity] && x.name),
|
|
20
|
+
(x) => (0, location_1.homesOf)(arch, x.entity ?? "").length > 0,
|
|
21
|
+
(x) => !(0, finally_1.fitsEntity)(x.entity ?? "", arch, rel),
|
|
22
|
+
], (x) => x.entity ?? null);
|
|
23
|
+
// The misfits by entity: every named candidate of a declared entity with homes,
|
|
20
24
|
// sitting outside every one of them.
|
|
21
|
-
const misfitsOf = (
|
|
25
|
+
const misfitsOf = (withEntities, arch, rel) => {
|
|
22
26
|
const misfits = new Map();
|
|
23
|
-
for (const c of
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
27
|
+
for (const c of withEntities) {
|
|
28
|
+
const entity = misfitEntityOf(c, arch, rel);
|
|
29
|
+
if (!entity || !c.name)
|
|
26
30
|
continue;
|
|
27
|
-
misfits.set(
|
|
31
|
+
misfits.set(entity, [...(misfits.get(entity) ?? []), { name: c.name, line: c.lines?.[0] ?? 1 }]);
|
|
28
32
|
}
|
|
29
33
|
return misfits;
|
|
30
34
|
};
|
|
31
|
-
// The reason a misfit is a misfit: the
|
|
35
|
+
// The reason a misfit is a misfit: the entity's own wording when the config has
|
|
32
36
|
// one (a clause, not a sentence — the subject and the place are the frame's
|
|
33
37
|
// job), else the plain statement of what the code is and what to fill in.
|
|
34
|
-
const whyOf = (
|
|
35
|
-
const own = arch.
|
|
38
|
+
const whyOf = (entity, names, place, arch) => {
|
|
39
|
+
const own = arch.entities[entity].report;
|
|
36
40
|
const ownMessage = typeof own === "object" && own !== null ? own.message : null;
|
|
37
41
|
if (ownMessage)
|
|
38
42
|
return ownMessage;
|
|
39
|
-
//
|
|
43
|
+
// An entity with NO place for this file must not reach `place.path`: widening the
|
|
40
44
|
// rules to `packages` put such a file in front of this line and it crashed.
|
|
41
45
|
const fill = !place || place.concrete ? "" : `; fill ${(0, location_1.placeholdersOf)(place.path)} for the instance this code belongs to`;
|
|
42
|
-
return `${names.length > 1 ? "They are" : "It is"} \`${
|
|
46
|
+
return `${names.length > 1 ? "They are" : "It is"} \`${entity}\` code${fill}.`;
|
|
43
47
|
};
|
|
44
|
-
// One
|
|
48
|
+
// One entity's misfit finding: the demand and its sentence come from the ONE
|
|
45
49
|
// vocabulary in report/asks — "this code belongs elsewhere" is a `move`, said
|
|
46
50
|
// the same way here and in the folder check. The BOX the sentence names is
|
|
47
51
|
// resolved here, once, so the picture and the sentence cannot disagree.
|
|
48
|
-
const misfitFinding = (
|
|
52
|
+
const misfitFinding = (entity, found, ctx, arch) => {
|
|
49
53
|
const names = found.map((x) => x.name);
|
|
50
54
|
const list = names.map((n) => `\`${n}\``).join(", ");
|
|
51
55
|
// WHERE this code belongs — asked of the ONE implementation in homes, so
|
|
52
56
|
// this message and the folder-level one can never name different places.
|
|
53
|
-
const place = (0, location_1.placeFor)(arch,
|
|
57
|
+
const place = (0, location_1.placeFor)(arch, entity, ctx.rel);
|
|
54
58
|
const where = place ? `\`${place.path}\`` : null;
|
|
55
59
|
const report = asks_1.asks.move({
|
|
56
60
|
what: list,
|
|
@@ -60,16 +64,16 @@ const misfitFinding = (role, found, ctx, arch) => {
|
|
|
60
64
|
// The path WITHOUT backticks: the text decorates, the data does not.
|
|
61
65
|
path: place?.path ?? null,
|
|
62
66
|
// `findingFrom` substitutes `{what}` / `{destination}` from the vars below.
|
|
63
|
-
why: whyOf(
|
|
67
|
+
why: whyOf(entity, names, place, arch),
|
|
64
68
|
});
|
|
65
|
-
return (0, cli_report_1.findingFrom)({ report, line: found[0].line }, "
|
|
69
|
+
return (0, cli_report_1.findingFrom)({ report, line: found[0].line }, "entities", entity, `entity:${entity}:report`, {
|
|
66
70
|
path: ctx.rel,
|
|
67
71
|
what: names.join(", "),
|
|
68
72
|
destination: place?.path ?? null,
|
|
69
73
|
});
|
|
70
74
|
};
|
|
71
|
-
const
|
|
72
|
-
for (const [
|
|
73
|
-
out.push(misfitFinding(
|
|
75
|
+
const checkEntityHomes = (withEntities, ctx, arch, out) => {
|
|
76
|
+
for (const [entity, found] of misfitsOf(withEntities, arch, ctx.rel))
|
|
77
|
+
out.push(misfitFinding(entity, found, ctx, arch));
|
|
74
78
|
};
|
|
75
|
-
exports.
|
|
79
|
+
exports.checkEntityHomes = checkEntityHomes;
|
package/dist/pipeline-facts.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Project } from "ts-morph";
|
|
2
|
+
declare const needsUsage: (arch: Arch) => boolean;
|
|
2
3
|
import type { Arch } from "./entities/architecture";
|
|
3
4
|
import type { FileContext } from "./entities/context";
|
|
4
5
|
import type { Candidate, FileFacts } from "./entities/facts";
|
|
5
|
-
|
|
6
|
-
declare const collectFacts: (abs: string, arch: Arch, project: Project, repoFiles: string[], dedupe: SeenStore) => {
|
|
6
|
+
declare const collectFacts: (...args: [abs: string, arch: Arch, project: Project, repoFiles: string[], usage?: boolean, record?: boolean, inText?: string]) => {
|
|
7
7
|
ctx: FileContext;
|
|
8
8
|
candidates: Candidate[];
|
|
9
9
|
fileFacts: FileFacts;
|
|
10
|
+
text: string;
|
|
10
11
|
};
|
|
11
|
-
export { collectFacts };
|
|
12
|
+
export { needsUsage, collectFacts };
|
package/dist/pipeline-facts.js
CHANGED
|
@@ -15,27 +15,56 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.collectFacts = void 0;
|
|
36
|
+
exports.collectFacts = exports.needsUsage = void 0;
|
|
27
37
|
// The FACTS phase of the per-file pipeline: load the source file, collect the
|
|
28
38
|
// candidates once, attach the facet readings (framework, CSS, call depth), and
|
|
29
39
|
// build the file's fact set. Classification and the file facts both consume the
|
|
30
40
|
// same candidates, so nothing is collected twice.
|
|
31
41
|
const path = __importStar(require("node:path"));
|
|
32
|
-
const fs = __importStar(require("node:fs"));
|
|
33
42
|
const imports_1 = require("./utils/imports");
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
const walk_1 = require("./code-entities/walk");
|
|
44
|
+
// Does the config ever READ the checker facts (`references`, `implementations`)?
|
|
45
|
+
// Answering either is a project-wide type-checker call per exported name — the
|
|
46
|
+
// heaviest fact a scan produces — so the extraction only asks for them when some
|
|
47
|
+
// filter can actually use them. A conservative scan of the serialized policy:
|
|
48
|
+
// when the key appears anywhere, it computes (never silently drops a fact a rule
|
|
49
|
+
// depends on).
|
|
50
|
+
const configMentions = (arch, fact) => {
|
|
51
|
+
try {
|
|
52
|
+
return JSON.stringify({ rules: arch.rules, entities: arch.entities }).includes(`"${fact}"`);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const usageNeeded = new WeakMap();
|
|
59
|
+
const needsUsage = (arch) => {
|
|
60
|
+
const cached = usageNeeded.get(arch);
|
|
61
|
+
if (cached !== undefined)
|
|
62
|
+
return cached;
|
|
63
|
+
const need = configMentions(arch, "references") || configMentions(arch, "implementations");
|
|
64
|
+
usageNeeded.set(arch, need);
|
|
65
|
+
return need;
|
|
66
|
+
};
|
|
67
|
+
exports.needsUsage = needsUsage;
|
|
39
68
|
// The file's place and the run's shared state, before any fact is collected.
|
|
40
69
|
const buildFileContext = (abs, arch, load) => {
|
|
41
70
|
const repoRoot = arch.repoRoot ?? ".";
|
|
@@ -51,62 +80,35 @@ const buildFileContext = (abs, arch, load) => {
|
|
|
51
80
|
// The built architecture — scope entries (`{ node: slug }`) resolve
|
|
52
81
|
// against the tree, and filters may reference it too.
|
|
53
82
|
arch,
|
|
54
|
-
|
|
55
|
-
|
|
83
|
+
entities: [],
|
|
84
|
+
entityCtx: null,
|
|
56
85
|
facts: null,
|
|
57
86
|
repoFiles: load.repoFiles,
|
|
58
|
-
// Shared across the run: lets node-level checks report once per folder
|
|
59
|
-
// instead of once per file inside it.
|
|
60
|
-
dedupe: load.dedupe,
|
|
61
87
|
};
|
|
62
88
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const withFacets = (candidates, run) => {
|
|
76
|
-
const { ctx, sf, text, project, arch, repoFiles, importMap } = run;
|
|
77
|
-
(0, depth_1.attachCallDepth)(candidates, {
|
|
78
|
-
rel: ctx.rel,
|
|
79
|
-
project,
|
|
80
|
-
repoRoot: arch.repoRoot ?? ctx.repoRoot ?? ".",
|
|
81
|
-
aliases: ctx.aliases,
|
|
89
|
+
// The file's facts are needed BEFORE classification — an entity may be recognised
|
|
90
|
+
// by what the file depends on (`file.imports`), not only by the candidate's own
|
|
91
|
+
// shape. That whole walk (load → candidates → facets → file facts → classify) is
|
|
92
|
+
// ONE function (`code-entities/walk`), shared with the editor's index and the
|
|
93
|
+
// report's cards; this phase only adds what the pipeline itself needs: the file's
|
|
94
|
+
// context, and the decision whether the checker facts are worth computing.
|
|
95
|
+
const collectFacts = (...args) => {
|
|
96
|
+
const [abs, arch, project, repoFiles, usage = true, record = false, inText] = args;
|
|
97
|
+
const walked = (0, walk_1.walkFile)({
|
|
98
|
+
rel: (0, imports_1.toRel)(arch.repoRoot ?? ".", abs),
|
|
99
|
+
arch,
|
|
100
|
+
repoRoot: arch.repoRoot ?? ".",
|
|
82
101
|
repoFiles,
|
|
83
|
-
|
|
102
|
+
aliases: arch.aliases,
|
|
103
|
+
project,
|
|
104
|
+
text: inText,
|
|
105
|
+
usage,
|
|
106
|
+
record,
|
|
84
107
|
});
|
|
85
|
-
(0, frameworks_1.enrich)(candidates, { rel: ctx.rel, sf, text, repoRoot: arch.repoRoot ?? ctx.repoRoot, importMap });
|
|
86
|
-
(0, css_1.attachToCandidates)(candidates, { sf });
|
|
87
|
-
for (const candidate of candidates)
|
|
88
|
-
classifyMembers(candidate.kind?.initializer?.members);
|
|
89
|
-
return candidates;
|
|
90
|
-
};
|
|
91
|
-
// Load → candidates → facets → file facts. The file's facts are needed BEFORE
|
|
92
|
-
// classification — a role may be recognised by what the file depends on
|
|
93
|
-
// (`file.imports`), not only by the candidate's own shape. The only fields that
|
|
94
|
-
// need the classification are `candidates` and `roles`, so they are filled in
|
|
95
|
-
// afterwards; every candidate holds the same facts object, so `infer` sees
|
|
96
|
-
// everything the file facts offer, not a hand-picked subset.
|
|
97
|
-
const collectFacts = (...args) => {
|
|
98
|
-
const [abs, arch, project, repoFiles, dedupe] = args;
|
|
99
|
-
const text = fs.readFileSync(abs, "utf8");
|
|
100
|
-
const sf = (0, ast_1.loadSourceFile)(project, abs, text);
|
|
101
|
-
const ctx = buildFileContext(abs, arch, { sf, repoFiles, dedupe });
|
|
102
|
-
const importMap = (0, ast_1.importNameModules)(sf, ctx.repoRoot ?? ".", ctx.aliases, repoFiles);
|
|
103
108
|
// `repoRoot` lets the type-resolved facts (`assignments[].type`,
|
|
104
109
|
// `parameters[].typeFile`) be repo-relative, which is what
|
|
105
110
|
// `location: { node: … }` matches against.
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
for (const c of candidates)
|
|
109
|
-
c.file = fileFacts;
|
|
110
|
-
return { ctx, candidates, fileFacts };
|
|
111
|
+
const ctx = buildFileContext(abs, arch, { sf: walked.sf, repoFiles });
|
|
112
|
+
return { ctx, candidates: walked.candidates, fileFacts: walked.fileFacts, text: walked.text };
|
|
111
113
|
};
|
|
112
114
|
exports.collectFacts = collectFacts;
|
|
@@ -3,7 +3,7 @@ import type { Arch } from "./entities/architecture";
|
|
|
3
3
|
import type { FileContext } from "./entities/context";
|
|
4
4
|
import type { Candidate } from "./entities/facts";
|
|
5
5
|
import type { Finding } from "./entities/findings";
|
|
6
|
-
declare const
|
|
6
|
+
declare const checkUnclassified: (withEntities: readonly Candidate[], run: {
|
|
7
7
|
present: readonly string[];
|
|
8
8
|
ctx: FileContext;
|
|
9
9
|
arch: Arch;
|
|
@@ -11,4 +11,4 @@ declare const checkUnroled: (withRoles: readonly Candidate[], run: {
|
|
|
11
11
|
repoFiles: string[];
|
|
12
12
|
out: Finding[];
|
|
13
13
|
}) => void;
|
|
14
|
-
export {
|
|
14
|
+
export { checkUnclassified };
|