@md-code/follow-architecture 0.1.1 → 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 +37 -0
- package/LICENSE +202 -0
- package/README.md +1420 -139
- package/dist/aliases.d.ts +3 -0
- package/dist/aliases.js +12 -0
- package/dist/args.d.ts +18 -0
- package/dist/args.js +94 -0
- package/dist/bin/follow-architecture.d.ts +2 -0
- package/dist/bin/follow-architecture.js +23 -0
- 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-entities/entities.js +227 -0
- 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 +76 -0
- package/dist/config-options.js +52 -0
- package/dist/config-project.d.ts +4 -0
- package/dist/config-project.js +92 -0
- package/dist/config-report.d.ts +19 -0
- package/dist/config-report.js +161 -0
- package/dist/config-rule.d.ts +95 -0
- package/dist/config-rule.js +211 -0
- package/dist/config-state.d.ts +25 -0
- package/dist/config-state.js +269 -0
- package/dist/config.d.ts +107 -0
- package/dist/config.js +38 -0
- package/dist/css/index.d.ts +31 -0
- package/dist/css/index.js +251 -0
- package/dist/css/syntax/css/gate.d.ts +2 -0
- package/dist/css/syntax/css/gate.js +69 -0
- package/dist/css/syntax/css/index.d.ts +7 -0
- package/dist/css/syntax/css/index.js +51 -0
- package/dist/css/syntax/css/reference.d.ts +3 -0
- package/dist/css/syntax/css/reference.js +36 -0
- package/dist/css/syntax/language.d.ts +25 -0
- package/dist/css/syntax/language.js +81 -0
- package/dist/css/syntax/scss/index.d.ts +25 -0
- package/dist/css/syntax/scss/index.js +95 -0
- package/dist/css/syntax/scss/reference.d.ts +3 -0
- package/dist/css/syntax/scss/reference.js +17 -0
- package/dist/css/syntax/styled/document.d.ts +68 -0
- package/dist/css/syntax/styled/document.js +261 -0
- package/dist/css/syntax/styled/markup.d.ts +6 -0
- package/dist/css/syntax/styled/markup.js +84 -0
- 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.d.ts +23 -0
- package/dist/css/syntax/styled/template.js +67 -0
- package/dist/css/syntax/tailwind/tailwind-engine.d.ts +23 -0
- package/dist/css/syntax/tailwind/tailwind-engine.js +37 -0
- package/dist/css/syntax/tailwind/tailwind.d.ts +26 -0
- package/dist/css/syntax/tailwind/tailwind.js +118 -0
- package/dist/css/value/check.d.ts +86 -0
- package/dist/css/value/check.js +122 -0
- package/dist/css/value/expression/arithmetic.d.ts +7 -0
- package/dist/css/value/expression/arithmetic.js +73 -0
- package/dist/css/value/expression/block.d.ts +9 -0
- package/dist/css/value/expression/block.js +92 -0
- package/dist/css/value/expression/conditional.d.ts +8 -0
- package/dist/css/value/expression/conditional.js +53 -0
- package/dist/css/value/expression/index.d.ts +5 -0
- package/dist/css/value/expression/index.js +73 -0
- package/dist/css/value/expression/map.d.ts +7 -0
- package/dist/css/value/expression/map.js +113 -0
- package/dist/css/value/object/index.d.ts +5 -0
- package/dist/css/value/object/index.js +113 -0
- package/dist/css/value/object/members.d.ts +7 -0
- package/dist/css/value/object/members.js +103 -0
- package/dist/css/value/object/node.d.ts +8 -0
- package/dist/css/value/object/node.js +134 -0
- package/dist/css/value/object/path.d.ts +10 -0
- package/dist/css/value/object/path.js +152 -0
- package/dist/css/value/pieces.d.ts +61 -0
- package/dist/css/value/pieces.js +65 -0
- package/dist/css/value/resolve.d.ts +33 -0
- package/dist/css/value/resolve.js +104 -0
- package/dist/css/value/scope.d.ts +28 -0
- package/dist/css/value/scope.js +205 -0
- package/dist/css/value/substitute.d.ts +10 -0
- package/dist/css/value/substitute.js +145 -0
- package/dist/css/value/values.d.ts +23 -0
- package/dist/css/value/values.js +131 -0
- package/dist/entities/architecture.d.ts +165 -0
- package/dist/entities/architecture.js +2 -0
- package/dist/entities/ast/assignments-nodes.d.ts +10 -0
- package/dist/entities/ast/assignments-nodes.js +64 -0
- package/dist/entities/ast/assignments-raw.d.ts +6 -0
- package/dist/entities/ast/assignments-raw.js +139 -0
- package/dist/entities/ast/assignments-tagged.d.ts +5 -0
- package/dist/entities/ast/assignments-tagged.js +195 -0
- package/dist/entities/ast/assignments.d.ts +9 -0
- package/dist/entities/ast/assignments.js +80 -0
- package/dist/entities/ast/branches.d.ts +4 -0
- package/dist/entities/ast/branches.js +32 -0
- package/dist/entities/ast/calls.d.ts +6 -0
- package/dist/entities/ast/calls.js +150 -0
- package/dist/entities/ast/classes.d.ts +5 -0
- package/dist/entities/ast/classes.js +61 -0
- package/dist/entities/ast/climb.d.ts +12 -0
- package/dist/entities/ast/climb.js +17 -0
- package/dist/entities/ast/comments.d.ts +5 -0
- package/dist/entities/ast/comments.js +130 -0
- package/dist/entities/ast/declaration.d.ts +4 -0
- package/dist/entities/ast/declaration.js +26 -0
- package/dist/entities/ast/depth.d.ts +17 -0
- package/dist/entities/ast/depth.js +166 -0
- package/dist/entities/ast/enums.d.ts +6 -0
- package/dist/entities/ast/enums.js +17 -0
- 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 +7 -0
- package/dist/entities/ast/file-exports.js +101 -0
- package/dist/entities/ast/file-facts.d.ts +16 -0
- package/dist/entities/ast/file-facts.js +64 -0
- package/dist/entities/ast/file-imports.d.ts +5 -0
- package/dist/entities/ast/file-imports.js +100 -0
- package/dist/entities/ast/file.d.ts +5 -0
- package/dist/entities/ast/file.js +23 -0
- package/dist/entities/ast/functions.d.ts +8 -0
- package/dist/entities/ast/functions.js +111 -0
- package/dist/entities/ast/heritage.d.ts +4 -0
- package/dist/entities/ast/heritage.js +44 -0
- package/dist/entities/ast/index.d.ts +9 -0
- package/dist/entities/ast/index.js +181 -0
- package/dist/entities/ast/kind.d.ts +5 -0
- package/dist/entities/ast/kind.js +34 -0
- package/dist/entities/ast/loose.d.ts +37 -0
- package/dist/entities/ast/loose.js +2 -0
- package/dist/entities/ast/modifiers.d.ts +5 -0
- package/dist/entities/ast/modifiers.js +32 -0
- package/dist/entities/ast/project.d.ts +9 -0
- package/dist/entities/ast/project.js +106 -0
- package/dist/entities/ast/properties.d.ts +11 -0
- package/dist/entities/ast/properties.js +176 -0
- package/dist/entities/ast/resolve.d.ts +16 -0
- package/dist/entities/ast/resolve.js +317 -0
- package/dist/entities/ast/tree.d.ts +31 -0
- package/dist/entities/ast/tree.js +518 -0
- package/dist/entities/ast/types.d.ts +6 -0
- package/dist/entities/ast/types.js +46 -0
- package/dist/entities/ast/usage.d.ts +11 -0
- package/dist/entities/ast/usage.js +81 -0
- package/dist/entities/ast/variables.d.ts +8 -0
- package/dist/entities/ast/variables.js +91 -0
- package/dist/entities/context.d.ts +29 -0
- package/dist/entities/context.js +2 -0
- package/dist/entities/facts.d.ts +284 -0
- package/dist/entities/facts.js +2 -0
- package/dist/entities/findings.d.ts +19 -0
- package/dist/entities/findings.js +2 -0
- package/dist/entities/kinds.d.ts +40 -0
- package/dist/entities/kinds.js +332 -0
- package/dist/entities/location/homes.d.ts +28 -0
- package/dist/entities/location/homes.js +195 -0
- package/dist/entities/location/place.d.ts +10 -0
- package/dist/entities/location/place.js +63 -0
- package/dist/entities/location/where.d.ts +19 -0
- package/dist/entities/location/where.js +277 -0
- package/dist/entities/location.d.ts +16 -0
- package/dist/entities/location.js +140 -0
- package/dist/entities/operators.d.ts +14 -0
- package/dist/entities/operators.js +30 -0
- package/dist/entities/overview/data.d.ts +43 -0
- package/dist/entities/overview/data.js +2 -0
- package/dist/entities/overview/decision.d.ts +60 -0
- package/dist/entities/overview/decision.js +2 -0
- package/dist/entities/overview/file-tree.d.ts +10 -0
- package/dist/entities/overview/file-tree.js +2 -0
- package/dist/entities/overview/finding.d.ts +58 -0
- package/dist/entities/overview/finding.js +2 -0
- package/dist/entities/overview/graph.d.ts +82 -0
- package/dist/entities/overview/graph.js +2 -0
- package/dist/entities/overview/input.d.ts +15 -0
- package/dist/entities/overview/input.js +2 -0
- package/dist/entities/overview/summaries.d.ts +81 -0
- package/dist/entities/overview/summaries.js +2 -0
- package/dist/entities/place.d.ts +5 -0
- package/dist/entities/place.js +2 -0
- package/dist/entities/queries.d.ts +9 -0
- package/dist/entities/queries.js +375 -0
- package/dist/entities/repair.d.ts +16 -0
- package/dist/entities/repair.js +29 -0
- package/dist/entities/schema.d.ts +22 -0
- package/dist/entities/schema.js +81 -0
- package/dist/entities/story.d.ts +47 -0
- package/dist/entities/story.js +2 -0
- package/dist/entities/structure-facts.d.ts +11 -0
- package/dist/entities/structure-facts.js +2 -0
- package/dist/entities/token.d.ts +23 -0
- package/dist/entities/token.js +2 -0
- package/dist/entities/tree/build.d.ts +6 -0
- package/dist/entities/tree/build.js +313 -0
- package/dist/entities/tree/entries.d.ts +7 -0
- package/dist/entities/tree/entries.js +145 -0
- package/dist/entities/tree/index.d.ts +6 -0
- package/dist/entities/tree/index.js +21 -0
- package/dist/entities/tree/match.d.ts +17 -0
- package/dist/entities/tree/match.js +190 -0
- 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 +7 -0
- package/dist/frameworks/angular/index.js +18 -0
- package/dist/frameworks/facet.d.ts +18 -0
- package/dist/frameworks/facet.js +15 -0
- package/dist/frameworks/index.d.ts +9 -0
- package/dist/frameworks/index.js +134 -0
- package/dist/frameworks/react/index.d.ts +7 -0
- package/dist/frameworks/react/index.js +237 -0
- package/dist/frameworks/test/index.d.ts +6 -0
- package/dist/frameworks/test/index.js +157 -0
- package/dist/frameworks/vue/index.d.ts +7 -0
- package/dist/frameworks/vue/index.js +18 -0
- 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 +10 -0
- package/dist/main.js +411 -0
- package/dist/nodes/child-entities.d.ts +3 -0
- package/dist/nodes/child-entities.js +12 -0
- package/dist/nodes/children.d.ts +25 -0
- package/dist/nodes/children.js +165 -0
- package/dist/nodes/finally/emit.d.ts +6 -0
- package/dist/nodes/finally/emit.js +71 -0
- package/dist/nodes/finally/entities.d.ts +13 -0
- package/dist/nodes/finally/entities.js +42 -0
- package/dist/nodes/finally/index.d.ts +8 -0
- package/dist/nodes/finally/index.js +35 -0
- package/dist/nodes/finally/queries.d.ts +5 -0
- package/dist/nodes/finally/queries.js +25 -0
- package/dist/nodes/finally/relations-access.d.ts +5 -0
- package/dist/nodes/finally/relations-access.js +50 -0
- package/dist/nodes/finally/relations-edge.d.ts +29 -0
- package/dist/nodes/finally/relations-edge.js +148 -0
- package/dist/nodes/finally/relations-group.d.ts +31 -0
- package/dist/nodes/finally/relations-group.js +106 -0
- package/dist/nodes/finally/relations.d.ts +5 -0
- package/dist/nodes/finally/relations.js +85 -0
- package/dist/nodes/finally/required.d.ts +5 -0
- package/dist/nodes/finally/required.js +92 -0
- package/dist/nodes/finally/violation.d.ts +17 -0
- package/dist/nodes/finally/violation.js +2 -0
- package/dist/nodes/similar.d.ts +21 -0
- package/dist/nodes/similar.js +178 -0
- package/dist/piece-forms.d.ts +9 -0
- package/dist/piece-forms.js +68 -0
- package/dist/pipeline-entities.d.ts +6 -0
- package/dist/pipeline-entities.js +79 -0
- package/dist/pipeline-facts.d.ts +12 -0
- package/dist/pipeline-facts.js +114 -0
- package/dist/pipeline-unclassified.d.ts +14 -0
- package/dist/pipeline-unclassified.js +188 -0
- package/dist/pipeline.d.ts +7 -0
- package/dist/pipeline.js +28 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +3 -0
- package/dist/release-file.d.ts +3 -0
- package/dist/release-file.js +13 -0
- package/dist/report/asks.d.ts +55 -0
- package/dist/report/asks.js +60 -0
- package/dist/report/cli-report.d.ts +2 -0
- package/dist/report/cli-report.js +13 -0
- package/dist/report/config-error-guard.d.ts +8 -0
- package/dist/report/config-error-guard.js +5 -0
- package/dist/report/configErrors.d.ts +126 -0
- package/dist/report/configErrors.js +121 -0
- package/dist/report/errorTypes/codes/structure.d.ts +15 -0
- package/dist/report/errorTypes/codes/structure.js +76 -0
- package/dist/report/errorTypes/decision-maker.d.ts +23 -0
- package/dist/report/errorTypes/decision-maker.js +109 -0
- package/dist/report/errorTypes/destinations.d.ts +38 -0
- package/dist/report/errorTypes/destinations.js +165 -0
- package/dist/report/errorTypes/finding-type.d.ts +11 -0
- package/dist/report/errorTypes/finding-type.js +2 -0
- package/dist/report/errorTypes/index.d.ts +15 -0
- package/dist/report/errorTypes/index.js +55 -0
- package/dist/report/errorTypes/types/fileContents.d.ts +9 -0
- package/dist/report/errorTypes/types/fileContents.js +40 -0
- package/dist/report/errorTypes/types/unknownEntity.d.ts +9 -0
- package/dist/report/errorTypes/types/unknownEntity.js +27 -0
- package/dist/report/errorTypes/types/wrongAction.d.ts +22 -0
- package/dist/report/errorTypes/types/wrongAction.js +140 -0
- package/dist/report/errorTypes/types/wrongPlacement.d.ts +9 -0
- package/dist/report/errorTypes/types/wrongPlacement.js +67 -0
- package/dist/report/errorTypes/vocabulary/ids.d.ts +5 -0
- package/dist/report/errorTypes/vocabulary/ids.js +16 -0
- package/dist/report/errorTypes/vocabulary/phrases.d.ts +10 -0
- package/dist/report/errorTypes/vocabulary/phrases.js +187 -0
- package/dist/report/errorTypes/vocabulary/places.d.ts +8 -0
- package/dist/report/errorTypes/vocabulary/places.js +36 -0
- package/dist/report/errorTypes/vocabulary/verbs.d.ts +7 -0
- package/dist/report/errorTypes/vocabulary/verbs.js +30 -0
- package/dist/report/finding-from.d.ts +9 -0
- package/dist/report/finding-from.js +108 -0
- package/dist/report/notices.d.ts +9 -0
- package/dist/report/notices.js +57 -0
- package/dist/report/observed.d.ts +19 -0
- package/dist/report/observed.js +87 -0
- package/dist/report/render-report.d.ts +12 -0
- package/dist/report/render-report.js +145 -0
- package/dist/report/user-report/build/bundle.d.ts +3 -0
- package/dist/report/user-report/build/bundle.js +188 -0
- package/dist/report/user-report/build/bundle.prebuilt.js +1262 -0
- package/dist/report/user-report/data/collect.d.ts +4 -0
- package/dist/report/user-report/data/collect.js +93 -0
- package/dist/report/user-report/data/entities.d.ts +7 -0
- package/dist/report/user-report/data/entities.js +88 -0
- package/dist/report/user-report/data/entity-examples.d.ts +16 -0
- package/dist/report/user-report/data/entity-examples.js +136 -0
- package/dist/report/user-report/data/entity-filters.d.ts +15 -0
- package/dist/report/user-report/data/entity-filters.js +79 -0
- package/dist/report/user-report/data/entity-marks.d.ts +5 -0
- package/dist/report/user-report/data/entity-marks.js +79 -0
- package/dist/report/user-report/data/file-tree.d.ts +9 -0
- package/dist/report/user-report/data/file-tree.js +80 -0
- package/dist/report/user-report/data/finding-boundary.d.ts +9 -0
- package/dist/report/user-report/data/finding-boundary.js +21 -0
- package/dist/report/user-report/data/finding-plan.d.ts +16 -0
- package/dist/report/user-report/data/finding-plan.js +45 -0
- package/dist/report/user-report/data/finding-title.d.ts +12 -0
- package/dist/report/user-report/data/finding-title.js +36 -0
- package/dist/report/user-report/data/findings.d.ts +10 -0
- package/dist/report/user-report/data/findings.js +181 -0
- package/dist/report/user-report/data/graph-edges.d.ts +19 -0
- package/dist/report/user-report/data/graph-edges.js +109 -0
- 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 +7 -0
- package/dist/report/user-report/data/graph-helpers.js +67 -0
- package/dist/report/user-report/data/graph.d.ts +12 -0
- package/dist/report/user-report/data/graph.js +97 -0
- package/dist/report/user-report/data/nodes.d.ts +11 -0
- package/dist/report/user-report/data/nodes.js +116 -0
- package/dist/report/user-report/data/rules.d.ts +7 -0
- package/dist/report/user-report/data/rules.js +62 -0
- package/dist/report/user-report/data/scan.d.ts +8 -0
- package/dist/report/user-report/data/scan.js +69 -0
- package/dist/report/user-report/html/shell.d.ts +3 -0
- package/dist/report/user-report/html/shell.js +27 -0
- package/dist/report/user-report/index.d.ts +8 -0
- package/dist/report/user-report/index.js +58 -0
- package/dist/report/user-report/shared/describe.d.ts +7 -0
- package/dist/report/user-report/shared/describe.js +86 -0
- package/dist/rules/index.d.ts +7 -0
- package/dist/rules/index.js +327 -0
- package/dist/rules/list-vars.d.ts +5 -0
- package/dist/rules/list-vars.js +149 -0
- package/dist/rules/name.d.ts +16 -0
- package/dist/rules/name.js +18 -0
- package/dist/rules/normalize.d.ts +5 -0
- package/dist/rules/normalize.js +108 -0
- package/dist/rules/vars.d.ts +22 -0
- package/dist/rules/vars.js +117 -0
- package/dist/scan-run.d.ts +20 -0
- package/dist/scan-run.js +130 -0
- package/dist/scripts/audit-report.d.ts +2 -0
- package/dist/scripts/audit-report.js +157 -0
- 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/accumulate.d.ts +6 -0
- package/dist/utils/accumulate.js +18 -0
- package/dist/utils/aliases.d.ts +22 -0
- package/dist/utils/aliases.js +173 -0
- package/dist/utils/article.d.ts +2 -0
- package/dist/utils/article.js +12 -0
- package/dist/utils/classify.d.ts +12 -0
- package/dist/utils/classify.js +25 -0
- package/dist/utils/configs.d.ts +25 -0
- package/dist/utils/configs.js +97 -0
- package/dist/utils/count.d.ts +7 -0
- package/dist/utils/count.js +13 -0
- package/dist/utils/dispatch.d.ts +2 -0
- package/dist/utils/dispatch.js +27 -0
- package/dist/utils/distinct.d.ts +2 -0
- package/dist/utils/distinct.js +14 -0
- package/dist/utils/field.d.ts +14 -0
- package/dist/utils/field.js +60 -0
- package/dist/utils/file-name.d.ts +2 -0
- package/dist/utils/file-name.js +11 -0
- package/dist/utils/files.d.ts +7 -0
- package/dist/utils/files.js +77 -0
- package/dist/utils/fixpoint.d.ts +2 -0
- package/dist/utils/fixpoint.js +19 -0
- package/dist/utils/gate.d.ts +2 -0
- package/dist/utils/gate.js +12 -0
- package/dist/utils/group.d.ts +3 -0
- package/dist/utils/group.js +33 -0
- package/dist/utils/host.d.ts +3 -0
- package/dist/utils/host.js +16 -0
- package/dist/utils/imports.d.ts +12 -0
- package/dist/utils/imports.js +185 -0
- package/dist/utils/judged.d.ts +5 -0
- package/dist/utils/judged.js +19 -0
- package/dist/utils/keyed.d.ts +2 -0
- package/dist/utils/keyed.js +23 -0
- package/dist/utils/map-record.d.ts +2 -0
- package/dist/utils/map-record.js +11 -0
- package/dist/utils/packages.d.ts +15 -0
- package/dist/utils/packages.js +207 -0
- package/dist/utils/path-label.d.ts +6 -0
- package/dist/utils/path-label.js +37 -0
- package/dist/utils/pattern.d.ts +19 -0
- package/dist/utils/pattern.js +231 -0
- package/dist/utils/permission.d.ts +16 -0
- package/dist/utils/permission.js +18 -0
- package/dist/utils/plural.d.ts +2 -0
- package/dist/utils/plural.js +9 -0
- package/dist/utils/qualified.d.ts +2 -0
- package/dist/utils/qualified.js +21 -0
- package/dist/utils/rank.d.ts +2 -0
- package/dist/utils/rank.js +24 -0
- package/dist/utils/read-field.d.ts +12 -0
- package/dist/utils/read-field.js +50 -0
- package/dist/utils/read-when.d.ts +2 -0
- package/dist/utils/read-when.js +17 -0
- package/dist/utils/reason.d.ts +4 -0
- package/dist/utils/reason.js +9 -0
- package/dist/utils/record.d.ts +3 -0
- package/dist/utils/record.js +21 -0
- package/dist/utils/resolve.d.ts +2 -0
- package/dist/utils/resolve.js +24 -0
- package/dist/utils/search.d.ts +2 -0
- package/dist/utils/search.js +21 -0
- package/dist/utils/seen.d.ts +6 -0
- package/dist/utils/seen.js +27 -0
- package/dist/utils/span.d.ts +5 -0
- package/dist/utils/span.js +2 -0
- package/dist/utils/speak.d.ts +2 -0
- package/dist/utils/speak.js +18 -0
- package/dist/utils/split.d.ts +8 -0
- package/dist/utils/split.js +21 -0
- package/dist/utils/template.d.ts +5 -0
- package/dist/utils/template.js +5 -0
- package/dist/utils/text.d.ts +4 -0
- package/dist/utils/text.js +42 -0
- package/dist/utils/tokenize.d.ts +2 -0
- package/dist/utils/tokenize.js +18 -0
- package/dist/utils/try-read.d.ts +4 -0
- package/dist/utils/try-read.js +24 -0
- package/dist/utils/typed-field.d.ts +3 -0
- package/dist/utils/typed-field.js +16 -0
- package/dist/utils/verdicts.d.ts +4 -0
- package/dist/utils/verdicts.js +20 -0
- package/entities/operators.ts +31 -0
- package/package.json +101 -47
- package/report/errorTypes/vocabulary/ids.ts +17 -0
- package/report/errorTypes/vocabulary/phrases.ts +181 -0
- package/report/errorTypes/vocabulary/places.ts +51 -0
- package/report/errorTypes/vocabulary/verbs.ts +31 -0
- package/report/user-report/shared/describe.ts +107 -0
- package/ast.js +0 -107
- package/bin/follow-architecture.js +0 -6
- package/config.js +0 -101
- package/entities/aliases.js +0 -10
- package/entities/invariants.js +0 -134
- package/entities/nodes.js +0 -112
- package/main.js +0 -96
- package/plugin.js +0 -5
- package/report.js +0 -73
- package/utils.js +0 -104
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Arch, QueryFilter } from "@md-code/follow-architecture/entities/architecture";
|
|
2
|
+
import type { FileContext } from "@md-code/follow-architecture/entities/context";
|
|
3
|
+
import type { Violation } from "./violation";
|
|
4
|
+
import type { RelationToken as SharedToken } from "@md-code/follow-architecture/entities/token";
|
|
5
|
+
type RelationGroup = {
|
|
6
|
+
kind: string;
|
|
7
|
+
targetNode: string;
|
|
8
|
+
allowedEntities: string[];
|
|
9
|
+
sameEntities: string[];
|
|
10
|
+
via: string[];
|
|
11
|
+
route: string | null;
|
|
12
|
+
dest: string | null;
|
|
13
|
+
lines: number[];
|
|
14
|
+
what: Set<string>;
|
|
15
|
+
path: string | null;
|
|
16
|
+
pieces: Map<string, string | null>;
|
|
17
|
+
piece: string | null;
|
|
18
|
+
pieceEntity: string | null;
|
|
19
|
+
silent: boolean;
|
|
20
|
+
filtered: boolean;
|
|
21
|
+
self: boolean;
|
|
22
|
+
fact: QueryFilter | null;
|
|
23
|
+
};
|
|
24
|
+
type RelationToken = Required<Pick<SharedToken, "code" | "via">> & {
|
|
25
|
+
fact: QueryFilter | null;
|
|
26
|
+
subject: Pick<Required<NonNullable<SharedToken["subject"]>>, "pieces" | "entities" | "plural">;
|
|
27
|
+
why: Required<NonNullable<SharedToken["why"]>>;
|
|
28
|
+
};
|
|
29
|
+
declare const describeGroups: (groups: ReadonlyMap<string, RelationGroup>, ctx: FileContext, arch: Arch, violations: Violation[]) => void;
|
|
30
|
+
export { describeGroups };
|
|
31
|
+
export type { RelationGroup, RelationToken };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.describeGroups = void 0;
|
|
4
|
+
// One verdict per group of refused relations, built from facts and nothing
|
|
5
|
+
// else: the sentence (`relationMessage`), the repair, and one violation per
|
|
6
|
+
// line the group covers.
|
|
7
|
+
const index_1 = require("@md-code/follow-architecture/entities/tree/index");
|
|
8
|
+
const kinds_1 = require("@md-code/follow-architecture/entities/kinds");
|
|
9
|
+
const phrases_1 = require("@md-code/follow-architecture/report/errorTypes/vocabulary/phrases");
|
|
10
|
+
// The owner entity of a state-changing relation's target — the report names it.
|
|
11
|
+
const ownerEntityOf = (g, arch) => {
|
|
12
|
+
if (!(0, kinds_1.changesState)(g.kind))
|
|
13
|
+
return null;
|
|
14
|
+
const owner = (0, index_1.deepestMatch)(String(g.path ?? ""), arch)?.node ?? null;
|
|
15
|
+
return (owner?.entities ?? []).filter(Boolean)[0] ?? null;
|
|
16
|
+
};
|
|
17
|
+
// The fact with the owner entity attached — the report names it. A fact that is
|
|
18
|
+
// not a record carries nothing to attach to.
|
|
19
|
+
const factWithOwner = (g, ownerEntity) => {
|
|
20
|
+
if (!g.fact || typeof g.fact !== "object" || Array.isArray(g.fact))
|
|
21
|
+
return null;
|
|
22
|
+
return { ...g.fact, ownerEntity };
|
|
23
|
+
};
|
|
24
|
+
// Why the relation is refused: nothing allows it, some entities do, or nobody may.
|
|
25
|
+
const whyCodeOf = (g) => {
|
|
26
|
+
if (g.silent)
|
|
27
|
+
return "silent";
|
|
28
|
+
return g.allowedEntities.length ? "allowed" : "nobody";
|
|
29
|
+
};
|
|
30
|
+
const tokenOf = (g, arch, fileEntities) => {
|
|
31
|
+
const names = [...g.pieces.keys()];
|
|
32
|
+
const entities = [...new Set([...g.pieces.values()].filter((r) => Boolean(r)))];
|
|
33
|
+
const ownerEntity = ownerEntityOf(g, arch);
|
|
34
|
+
return {
|
|
35
|
+
code: "relation.forbidden",
|
|
36
|
+
fact: factWithOwner(g, ownerEntity),
|
|
37
|
+
subject: { pieces: names, entities: names.length ? entities : [...fileEntities], plural: names.length > 1 },
|
|
38
|
+
// The route the architecture DOES allow to the same code, if it names one.
|
|
39
|
+
via: g.via?.[0] ?? g.route ?? null,
|
|
40
|
+
why: {
|
|
41
|
+
code: whyCodeOf(g),
|
|
42
|
+
entities: g.allowedEntities,
|
|
43
|
+
// The ones the rule limits to the SAME feature instance.
|
|
44
|
+
sameEntities: g.sameEntities,
|
|
45
|
+
self: Boolean(g.self),
|
|
46
|
+
outward: Boolean(g.filtered),
|
|
47
|
+
targetNode: g.targetNode ?? null,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
// THE REPAIR for a relation the architecture refuses — always about the CODE,
|
|
52
|
+
// never about editing the rule: what to delete, or which of the code that MAY do
|
|
53
|
+
// it should own the line. A finding with no repair was a card with nothing to do
|
|
54
|
+
// (48 of them in one run).
|
|
55
|
+
const relationFix = (g, token) => {
|
|
56
|
+
const target = `\`${g.path ?? g.targetNode}\``;
|
|
57
|
+
const kind = g.kind;
|
|
58
|
+
const entities = token.why.entities;
|
|
59
|
+
// The call itself is fine; the VALUE it was given is what the `except` refused.
|
|
60
|
+
if (token.why.outward) {
|
|
61
|
+
return {
|
|
62
|
+
code: "rewrite",
|
|
63
|
+
fix: `Keep this \`${kind}\` of ${target} and change what it is given: the rule's \`except\` refuses that value.`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (!entities.length) {
|
|
67
|
+
// Nothing declares who may do it — or nobody may: either way the line is the
|
|
68
|
+
// thing that goes, and saying so is the whole advice.
|
|
69
|
+
return {
|
|
70
|
+
code: "remove",
|
|
71
|
+
fix: `Delete this \`${kind}\` of ${target}: no code in this architecture is allowed to reach \`${g.targetNode}\` that way, so the line cannot be made legal where it stands.`,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const who = entities.map((r) => `\`${r}\``).join(", ");
|
|
75
|
+
return {
|
|
76
|
+
code: "remove",
|
|
77
|
+
fix: `Delete this \`${kind}\` of ${target}, or do it from ${who} — that is the only code that may ${kind} it${token.why.sameEntities.length ? ", and only in the same feature instance" : ""}.`,
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
// One group → one verdict, carried on every line it covers.
|
|
81
|
+
const describeGroup = (g, ctx, arch, violations) => {
|
|
82
|
+
const token = tokenOf(g, arch, ctx.facts?.entities ?? []);
|
|
83
|
+
const text = (0, phrases_1.relationMessage)(token, { file: ctx.rel });
|
|
84
|
+
const lines = [...new Set(g.lines)].sort((a, b) => a - b);
|
|
85
|
+
// ONE repair per group, carried on every line it covers: a finding without
|
|
86
|
+
// a fix is a card with nothing to do.
|
|
87
|
+
const repair = relationFix(g, token);
|
|
88
|
+
for (const line of lines) {
|
|
89
|
+
violations.push({
|
|
90
|
+
kind: g.kind,
|
|
91
|
+
targetNode: g.targetNode,
|
|
92
|
+
targetPath: g.path,
|
|
93
|
+
line,
|
|
94
|
+
text,
|
|
95
|
+
fix: repair.fix,
|
|
96
|
+
ask: repair.code,
|
|
97
|
+
destination: g.dest ?? null,
|
|
98
|
+
token,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const describeGroups = (groups, ctx, arch, violations) => {
|
|
103
|
+
for (const g of groups.values())
|
|
104
|
+
describeGroup(g, ctx, arch, violations);
|
|
105
|
+
};
|
|
106
|
+
exports.describeGroups = describeGroups;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Arch } from "@md-code/follow-architecture/entities/architecture";
|
|
2
|
+
import type { FileContext } from "@md-code/follow-architecture/entities/context";
|
|
3
|
+
import type { Violation } from "./violation";
|
|
4
|
+
declare const checkRelations: (ctx: FileContext, arch: Arch, violations: Violation[]) => void;
|
|
5
|
+
export { checkRelations };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkRelations = void 0;
|
|
4
|
+
// Relations: every file→file edge, judged by the entity that owns the target.
|
|
5
|
+
// Collect (group the refusals), then describe (one token per group). The
|
|
6
|
+
// judgment of ONE edge lives in `relations-edge`; the accessor-import check
|
|
7
|
+
// in `relations-access`; the group's sentence in `relations-group`.
|
|
8
|
+
const kinds_1 = require("@md-code/follow-architecture/entities/kinds");
|
|
9
|
+
const gate_1 = require("@md-code/follow-architecture/utils/gate");
|
|
10
|
+
const judged_1 = require("@md-code/follow-architecture/utils/judged");
|
|
11
|
+
const accumulate_1 = require("@md-code/follow-architecture/utils/accumulate");
|
|
12
|
+
const relations_edge_1 = require("./relations-edge");
|
|
13
|
+
const relations_access_1 = require("./relations-access");
|
|
14
|
+
const relations_group_1 = require("./relations-group");
|
|
15
|
+
// The edges of one fact kind, each once (a call and its declare are one line).
|
|
16
|
+
const uniqueEdges = (kind, edges) => {
|
|
17
|
+
const seen = new Set();
|
|
18
|
+
const out = [];
|
|
19
|
+
for (const edge of edges) {
|
|
20
|
+
const key = `${kind}:${edge.path}:${edge.line}:${edge.what}`;
|
|
21
|
+
if (seen.has(key))
|
|
22
|
+
continue;
|
|
23
|
+
seen.add(key);
|
|
24
|
+
out.push(edge);
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
};
|
|
28
|
+
// Is this edge the closed-world rule's business? A LIBRARY is not a place the
|
|
29
|
+
// tree declares: `react`, `@apollo/client`, `fs` have no node and no entity home,
|
|
30
|
+
// so there is no folder-level rule to judge them by. What a piece may do with a
|
|
31
|
+
// library is the CANDIDATE's own business — `infer` reads `calls.module` /
|
|
32
|
+
// `imports.source` directly. Skipping here keeps the closed-world rule about
|
|
33
|
+
// REPO code; a library edge judged against an empty home list would report
|
|
34
|
+
// every `styled.div` and every `useState` as a forbidden relation. The verdicts
|
|
35
|
+
// are the shared gate: an edge is judged when none of the skips fires.
|
|
36
|
+
const judgedEdge = (edge, fileEntities) => (0, gate_1.admitsWhenNoneReject)(edge, [
|
|
37
|
+
(e) => e.external,
|
|
38
|
+
(e) => Boolean(e.piece) && !e.entity,
|
|
39
|
+
(e) => !e.piece && !fileEntities.length,
|
|
40
|
+
]);
|
|
41
|
+
// The edges of one fact kind that the closed-world rule owns (not a library's,
|
|
42
|
+
// not an unclassified piece's, not a entityless file's) — the ones it judges.
|
|
43
|
+
const ownedEdges = (kind, ctx) => {
|
|
44
|
+
const facts = ctx.facts;
|
|
45
|
+
if (!facts)
|
|
46
|
+
return [];
|
|
47
|
+
const fileEntities = facts.entities ?? [];
|
|
48
|
+
return uniqueEdges(kind, kinds_1.EDGE_FACTS[kind](facts)).filter((e) => judgedEdge(e, fileEntities));
|
|
49
|
+
};
|
|
50
|
+
// One kind's refusals → groups. The judge-and-keep walk is the shared
|
|
51
|
+
// `judgedItems` core; the keyed merge is the shared `accumulateByKey` core.
|
|
52
|
+
// Returns whether any edge of this kind was owned (passed the skips).
|
|
53
|
+
const collectKind = (kind, actionDecls, jctx) => {
|
|
54
|
+
const { ctx, arch, groups } = jctx;
|
|
55
|
+
const fileEntities = ctx.facts?.entities ?? [];
|
|
56
|
+
const edges = ownedEdges(kind, ctx);
|
|
57
|
+
const judgments = (0, judged_1.judgedItems)(edges, (e) => (0, relations_edge_1.judgeEdge)(e, { ctx, arch, kind, actionDecls, fileEntities }));
|
|
58
|
+
(0, accumulate_1.accumulateByKey)(judgments.map(({ item, verdict }) => ({ key: verdict.key, item, bucket: verdict.group })), groups, relations_edge_1.joinGroup);
|
|
59
|
+
return edges.length > 0;
|
|
60
|
+
};
|
|
61
|
+
// The refusals of every fact kind, grouped. The accessor-import check is the
|
|
62
|
+
// run's own question about the file's imports: the original asked it once per
|
|
63
|
+
// owned edge (the emitter keeps one finding per decision, so the repeated
|
|
64
|
+
// identical violations collapsed to one) — so it is asked once, and only when
|
|
65
|
+
// some edge was owned, exactly the original's condition.
|
|
66
|
+
const collectRefusals = (ctx, arch, declared, violations) => {
|
|
67
|
+
const groups = new Map();
|
|
68
|
+
let anyOwned = false;
|
|
69
|
+
for (const kind of kinds_1.FACT_KINDS) {
|
|
70
|
+
if (collectKind(kind, declared.get(kind) ?? new Map(), { ctx, arch, groups }))
|
|
71
|
+
anyOwned = true;
|
|
72
|
+
}
|
|
73
|
+
if (anyOwned)
|
|
74
|
+
(0, relations_access_1.checkAccessorImports)(ctx, arch, declared, violations);
|
|
75
|
+
return groups;
|
|
76
|
+
};
|
|
77
|
+
const checkRelations = (ctx, arch, violations) => {
|
|
78
|
+
if (!ctx.facts)
|
|
79
|
+
return;
|
|
80
|
+
// 1. COLLECT — every edge judged, the refusals grouped.
|
|
81
|
+
const groups = collectRefusals(ctx, arch, (0, kinds_1.declaredActions)(arch), violations);
|
|
82
|
+
// 2. DESCRIBE — one verdict per group, built from facts and nothing else.
|
|
83
|
+
(0, relations_group_1.describeGroups)(groups, ctx, arch, violations);
|
|
84
|
+
};
|
|
85
|
+
exports.checkRelations = checkRelations;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ArchNode } from "@md-code/follow-architecture/entities/architecture";
|
|
2
|
+
import type { FileContext } from "@md-code/follow-architecture/entities/context";
|
|
3
|
+
import type { Finding, FindingFrom } from "@md-code/follow-architecture/entities/findings";
|
|
4
|
+
declare const checkRequiredChildren: (ctx: FileContext, node: ArchNode, out: Finding[], findingFrom: FindingFrom) => void;
|
|
5
|
+
export { checkRequiredChildren };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkRequiredChildren = void 0;
|
|
4
|
+
// Required children: is this folder an instance of its node, and is anything
|
|
5
|
+
// the node requires missing.
|
|
6
|
+
const location_1 = require("@md-code/follow-architecture/entities/location");
|
|
7
|
+
const children_1 = require("@md-code/follow-architecture/nodes/children");
|
|
8
|
+
// Where the run remembers which folders it has already spoken for.
|
|
9
|
+
const foldersOf = (ctx) => ctx.dedupe?.get("required") ?? new Set();
|
|
10
|
+
const remember = (ctx, folders, key) => {
|
|
11
|
+
folders.add(key);
|
|
12
|
+
ctx.dedupe?.set("required", folders);
|
|
13
|
+
};
|
|
14
|
+
// A home outside the folder: a place the code could move to. A home inside
|
|
15
|
+
// (or the folder itself) is not an offer.
|
|
16
|
+
const outsideHome = (path, folder) => Boolean(path) && path !== folder && !path.startsWith(`${folder}/`);
|
|
17
|
+
// The homes the file's own entities would put its code in, outside this folder —
|
|
18
|
+
// the destinations a "this folder is not described" finding can offer.
|
|
19
|
+
const homesOutside = (ctx, arch, folder) => {
|
|
20
|
+
const byPath = new Map();
|
|
21
|
+
for (const c of ctx.facts?.candidates ?? []) {
|
|
22
|
+
if (!c.entity)
|
|
23
|
+
continue;
|
|
24
|
+
const path = (0, location_1.placeFor)(arch, c.entity, ctx.rel)?.path ?? null;
|
|
25
|
+
if (outsideHome(path, folder) && !byPath.has(path))
|
|
26
|
+
byPath.set(path, c.entity);
|
|
27
|
+
}
|
|
28
|
+
return byPath;
|
|
29
|
+
};
|
|
30
|
+
// A folder none of the node's declared children are in: not a folder this
|
|
31
|
+
// architecture describes. Said once per folder.
|
|
32
|
+
const foreignFolder = (...args) => {
|
|
33
|
+
const [ctx, owner, folder, declared, out, findingFrom] = args;
|
|
34
|
+
const arch = ctx.arch;
|
|
35
|
+
const key = `nodes:${owner.slug}:foreign:${folder}`;
|
|
36
|
+
const folders = foldersOf(ctx);
|
|
37
|
+
if (folders.has(key))
|
|
38
|
+
return;
|
|
39
|
+
remember(ctx, folders, key);
|
|
40
|
+
const byPath = homesOutside(ctx, arch, folder);
|
|
41
|
+
const where = byPath.size
|
|
42
|
+
? [...byPath.entries()].map(([path, entity]) => `\`${path}\` (${entity})`).join(" and ")
|
|
43
|
+
: null;
|
|
44
|
+
out.push(findingFrom({
|
|
45
|
+
key,
|
|
46
|
+
report: {
|
|
47
|
+
ask: "move",
|
|
48
|
+
message: `\`${folder}\` is not a folder this architecture describes: none of the files node \`${owner.slug}\` declares are here (${declared.map((c) => `\`${c.name}${c.folder ? "/" : ""}\``).join(", ")}).`,
|
|
49
|
+
fix: where ? `Move each part of \`${folder}\` to its own home: ${where}.` : null,
|
|
50
|
+
},
|
|
51
|
+
}, "nodes", owner.slug, `nodes:${owner.slug}:foreign`, { path: ctx.rel, folder, node: owner.slug }));
|
|
52
|
+
};
|
|
53
|
+
// One required child missing from the folder: the node's own report, or the
|
|
54
|
+
// default "create it" demand. Said once per (folder, child).
|
|
55
|
+
const missingChild = (...args) => {
|
|
56
|
+
const [ctx, owner, folder, child, out, findingFrom] = args;
|
|
57
|
+
const key = `nodes:${owner.slug}:required:${folder}:${child.name}`;
|
|
58
|
+
const folders = foldersOf(ctx);
|
|
59
|
+
if (folders.has(key))
|
|
60
|
+
return;
|
|
61
|
+
remember(ctx, folders, key);
|
|
62
|
+
out.push(findingFrom({
|
|
63
|
+
key,
|
|
64
|
+
report: child.report ?? {
|
|
65
|
+
ask: "add",
|
|
66
|
+
message: `\`{folder}\` is not a \`{node}\`: \`{child}\` is required here and is missing.`,
|
|
67
|
+
fix: `Create \`{child}\` in \`{folder}\`.`,
|
|
68
|
+
},
|
|
69
|
+
data: { node: owner.slug, folder, missing: child.name },
|
|
70
|
+
}, "nodes", owner.slug, `nodes:${owner.slug}:required`, { path: ctx.rel, folder, node: owner.slug, child: child.name, missing: child.name }));
|
|
71
|
+
};
|
|
72
|
+
// The required children the folder does not hold.
|
|
73
|
+
const missingOf = (required, present) => required.filter((child) => ![...present].some((name) => child.re.test(name)));
|
|
74
|
+
// One owner's required children, checked against what the folder holds.
|
|
75
|
+
const checkOwner = (ctx, owner, out, findingFrom) => {
|
|
76
|
+
const required = (owner.children ?? []).filter((c) => c.required);
|
|
77
|
+
const folder = required.length ? (0, location_1.fillTemplate)(owner.path, ctx.rel) : null;
|
|
78
|
+
if (!folder)
|
|
79
|
+
return;
|
|
80
|
+
const { present, declared, anyDeclared } = (0, children_1.folderContents)(owner, folder, ctx.repoFiles);
|
|
81
|
+
if (!anyDeclared) {
|
|
82
|
+
foreignFolder(ctx, owner, folder, declared, out, findingFrom);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
for (const child of missingOf(required, present))
|
|
86
|
+
missingChild(ctx, owner, folder, child, out, findingFrom);
|
|
87
|
+
};
|
|
88
|
+
const checkRequiredChildren = (ctx, node, out, findingFrom) => {
|
|
89
|
+
for (const owner of (0, children_1.ancestorChain)(node, ctx.arch))
|
|
90
|
+
checkOwner(ctx, owner, out, findingFrom);
|
|
91
|
+
};
|
|
92
|
+
exports.checkRequiredChildren = checkRequiredChildren;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FieldValue } from "@md-code/follow-architecture/utils/field";
|
|
2
|
+
type Violation = {
|
|
3
|
+
line: number;
|
|
4
|
+
text: string;
|
|
5
|
+
fix?: string | null;
|
|
6
|
+
ask?: string | null;
|
|
7
|
+
kind?: string;
|
|
8
|
+
entity?: string | null;
|
|
9
|
+
names?: string[];
|
|
10
|
+
where?: string | null;
|
|
11
|
+
owning?: string | null;
|
|
12
|
+
targetNode?: string | null;
|
|
13
|
+
targetPath?: string | null;
|
|
14
|
+
destination?: string | null;
|
|
15
|
+
token?: FieldValue;
|
|
16
|
+
};
|
|
17
|
+
export type { Violation };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Arch, ArchNode } from "@md-code/follow-architecture/entities/architecture";
|
|
2
|
+
import type { ScanContext } from "@md-code/follow-architecture/entities/context";
|
|
3
|
+
declare const criteriaOf: (arch: Arch, node: ArchNode) => string[];
|
|
4
|
+
type SimilarCache = {
|
|
5
|
+
files: Map<string, string[]>;
|
|
6
|
+
};
|
|
7
|
+
type SimilarScan = ScanContext & {
|
|
8
|
+
arch?: Arch;
|
|
9
|
+
cache?: SimilarCache;
|
|
10
|
+
};
|
|
11
|
+
type Lookalike = {
|
|
12
|
+
slug: string;
|
|
13
|
+
path: string | null;
|
|
14
|
+
score: number;
|
|
15
|
+
hit: number;
|
|
16
|
+
total: number;
|
|
17
|
+
entities: string[];
|
|
18
|
+
};
|
|
19
|
+
declare const similarNodes: (arch: Arch, folder: string, ctx: SimilarScan | null | undefined, threshold?: number) => Lookalike[];
|
|
20
|
+
export { similarNodes, criteriaOf };
|
|
21
|
+
export type { SimilarCache, Lookalike };
|
|
@@ -0,0 +1,178 @@
|
|
|
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 () {
|
|
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
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.criteriaOf = exports.similarNodes = void 0;
|
|
37
|
+
// HOW MUCH a folder LOOKS LIKE a declared entity — measured in ENTITYS, not in
|
|
38
|
+
// file names.
|
|
39
|
+
//
|
|
40
|
+
// A folder is a feature when the code inside it IS the code a feature holds: a
|
|
41
|
+
// store model, actions, a controller. Whether the file is called `store.ts` or
|
|
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.
|
|
46
|
+
//
|
|
47
|
+
// Only entities at or above the threshold are offered, and ALL of them are: a
|
|
48
|
+
// folder can be 80% a feature and 66% a type home, and both are true answers.
|
|
49
|
+
// Shapes come from the tree, the threshold from the rule option (`similarity`,
|
|
50
|
+
// default 60%).
|
|
51
|
+
const fs = __importStar(require("node:fs"));
|
|
52
|
+
const path = __importStar(require("node:path"));
|
|
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.
|
|
65
|
+
// The distinct-collect walk is the shared `distinctFlat` core; the child's
|
|
66
|
+
// entities are the shared `entitiesOfChild` reading.
|
|
67
|
+
const criteriaOf = (arch, node) => {
|
|
68
|
+
const children = node.children ?? [];
|
|
69
|
+
return (0, distinct_1.distinctFlat)(children, (c) => (0, child_entities_1.entitiesOfChild)(arch, c));
|
|
70
|
+
};
|
|
71
|
+
exports.criteriaOf = criteriaOf;
|
|
72
|
+
// The files that belong to this folder: the entity's children live at the top of
|
|
73
|
+
// it and one level down (`actions/x.ts`).
|
|
74
|
+
const filesIn = (folder, repoFiles) => {
|
|
75
|
+
const depth = (0, location_1.segmentsOf)(folder).length;
|
|
76
|
+
return (repoFiles ?? []).filter((file) => file.startsWith(`${folder}/`) && (0, location_1.segmentsOf)(file).length - depth <= 2);
|
|
77
|
+
};
|
|
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) => {
|
|
82
|
+
const abs = path.join(ctx.repoRoot, file);
|
|
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
|
|
93
|
+
// per run — the folder is judged by the same facts its own findings come from.
|
|
94
|
+
const entitiesInFolder = (ctx, folder) => {
|
|
95
|
+
const entities = new Set();
|
|
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)();
|
|
102
|
+
for (const rel of filesIn(folder, ctx.repoFiles)) {
|
|
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);
|
|
109
|
+
}
|
|
110
|
+
return entities;
|
|
111
|
+
};
|
|
112
|
+
// Whether this folder IS this entity — the node's path as a template, matched
|
|
113
|
+
// against the concrete folder (`apps/backend/{kebab-case}` ← `apps/backend/document`).
|
|
114
|
+
const isOwnPath = (node, folder) => (node.variants ?? [])
|
|
115
|
+
.map((v) => v.path)
|
|
116
|
+
.concat(node.path ? [node.path] : [])
|
|
117
|
+
.some((template) => (0, pattern_1.compilePattern)(template).re.test(folder));
|
|
118
|
+
// Lookalikes answer ONE question: "this folder is declared nowhere — what does it
|
|
119
|
+
// look like?" A folder the architecture already places gets a precise answer from
|
|
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.
|
|
123
|
+
const isDeclaredPath = (arch, folder) => (arch.nodes.all ?? []).some((n) => isOwnPath(n, folder));
|
|
124
|
+
// TWO SIDES OF ONE COMPARISON. The entity must cover most of its OWN shape
|
|
125
|
+
// (`commands` declares two entities and every folder holding both is 2/2 —
|
|
126
|
+
// "looks like a command folder" was true of a whole feature), AND the entity
|
|
127
|
+
// must account for most of what the folder actually holds, or it explains
|
|
128
|
+
// only a corner of it and is not a shape this folder has.
|
|
129
|
+
const resembles = (criteria, present, threshold) => {
|
|
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.
|
|
132
|
+
if (criteria.length < 2)
|
|
133
|
+
return null;
|
|
134
|
+
const hit = criteria.filter((entity) => present.has(entity));
|
|
135
|
+
const score = hit.length / criteria.length;
|
|
136
|
+
if (score < threshold || hit.length / present.size < threshold)
|
|
137
|
+
return null;
|
|
138
|
+
return hit;
|
|
139
|
+
};
|
|
140
|
+
// The offer one entity makes: its shape, measured against what the folder
|
|
141
|
+
// holds. The entity the folder ALREADY is is never a destination: `document`
|
|
142
|
+
// is an instance of `apps/backend/{kebab-case}`, and the variant's own path is
|
|
143
|
+
// a template — comparing it as text never matched, so the offer read "move
|
|
144
|
+
// this feature's controller into this feature".
|
|
145
|
+
// The offer a measured hit earns: the entity's own path, its score, its entities.
|
|
146
|
+
const offerOf = (node, hit, total) => ({
|
|
147
|
+
slug: node.slug,
|
|
148
|
+
path: node.variants?.[0]?.path ?? node.path ?? null,
|
|
149
|
+
score: hit.length / total,
|
|
150
|
+
hit: hit.length,
|
|
151
|
+
total,
|
|
152
|
+
entities: hit,
|
|
153
|
+
});
|
|
154
|
+
const lookalikeOf = (node, folder, match) => {
|
|
155
|
+
const criteria = criteriaOf(match.arch, node);
|
|
156
|
+
const hit = isOwnPath(node, folder) ? null : resembles(criteria, match.present, match.threshold);
|
|
157
|
+
return hit ? offerOf(node, hit, criteria.length) : null;
|
|
158
|
+
};
|
|
159
|
+
// The folder's own entity set, when there is anything to compare: a folder the
|
|
160
|
+
// architecture already declares (or that holds no classifiable code) has no
|
|
161
|
+
// lookalike question to answer.
|
|
162
|
+
const folderEntities = (arch, folder, ctx) => {
|
|
163
|
+
if (!ctx?.project || isDeclaredPath(arch, folder))
|
|
164
|
+
return null;
|
|
165
|
+
const present = entitiesInFolder({ ...ctx, arch }, folder);
|
|
166
|
+
return present.size ? present : null;
|
|
167
|
+
};
|
|
168
|
+
// The declared entities this folder resembles, best first. `score` is the share
|
|
169
|
+
// of the entity's entities the folder already holds. The score-keep-rank walk is
|
|
170
|
+
// the shared `rankedOffers` core.
|
|
171
|
+
const similarNodes = (arch, folder, ctx, threshold = arch.similarity ?? pattern_1.DEFAULT_SIMILARITY) => {
|
|
172
|
+
const present = folderEntities(arch, folder, ctx);
|
|
173
|
+
if (!present)
|
|
174
|
+
return [];
|
|
175
|
+
const match = { arch, present, threshold };
|
|
176
|
+
return (0, rank_1.rankedOffers)(arch.nodes.all ?? [], (node) => lookalikeOf(node, folder, match), (a, b) => b.score - a.score || a.slug.localeCompare(b.slug));
|
|
177
|
+
};
|
|
178
|
+
exports.similarNodes = similarNodes;
|
|
@@ -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;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Arch } from "./entities/architecture";
|
|
2
|
+
import type { FileContext } from "./entities/context";
|
|
3
|
+
import type { Candidate } from "./entities/facts";
|
|
4
|
+
import type { Finding } from "./entities/findings";
|
|
5
|
+
declare const checkEntityHomes: (withEntities: readonly Candidate[], ctx: FileContext, arch: Arch, out: Finding[]) => void;
|
|
6
|
+
export { checkEntityHomes };
|