@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,25 @@
|
|
|
1
|
+
import type { Arch, ArchChild, ArchNode, ArchVariant, RawChild, RawNode } from "@md-code/follow-architecture/entities/architecture";
|
|
2
|
+
type FolderContents = {
|
|
3
|
+
present: Set<string>;
|
|
4
|
+
declared: ArchChild[];
|
|
5
|
+
anyDeclared: boolean;
|
|
6
|
+
missing: ArchChild[];
|
|
7
|
+
};
|
|
8
|
+
declare const folderContents: (owner: ArchNode, folder: string, repoFiles: string[] | null | undefined) => FolderContents;
|
|
9
|
+
declare const ancestorChain: (node: ArchNode, arch: Arch) => ArchNode[];
|
|
10
|
+
type ConcreteFolder = (path: string, rel: string | null) => string | null | undefined;
|
|
11
|
+
type RequiredContext = {
|
|
12
|
+
repoFiles: string[] | null | undefined;
|
|
13
|
+
concreteFolder: ConcreteFolder;
|
|
14
|
+
};
|
|
15
|
+
declare const missingRequiredChild: (node: ArchNode, arch: Arch, rel: string, ctx: RequiredContext) => boolean;
|
|
16
|
+
declare const nodePathRe: (template: string) => RegExp;
|
|
17
|
+
type PrefixMatcher = Pick<ArchVariant, "re" | "names" | "literalLen" | "isFile">;
|
|
18
|
+
declare const nodePrefixRe: (template: string) => PrefixMatcher;
|
|
19
|
+
declare const entitiesOf: (spec: {
|
|
20
|
+
entity?: string | string[] | null;
|
|
21
|
+
} | null | undefined) => string[];
|
|
22
|
+
declare const compileChild: (name: RawChild) => ArchChild;
|
|
23
|
+
export { nodePathRe, nodePrefixRe, compileChild, folderContents, missingRequiredChild, ancestorChain, entitiesOf };
|
|
24
|
+
export type { ConcreteFolder };
|
|
25
|
+
export type { RawNode, RawChild };
|
|
@@ -0,0 +1,165 @@
|
|
|
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.entitiesOf = exports.ancestorChain = exports.missingRequiredChild = exports.folderContents = exports.compileChild = exports.nodePrefixRe = exports.nodePathRe = void 0;
|
|
37
|
+
// Node child handling: a child is either a plain string name or a
|
|
38
|
+
// `{ kind, name? }` matcher. `compileChild` turns a name into a regex with
|
|
39
|
+
// capture groups; `nodePrefixRe` turns a node path into a prefix matcher.
|
|
40
|
+
// Both live here because they are node-specific, not shared machinery.
|
|
41
|
+
const pattern_1 = require("@md-code/follow-architecture/utils/pattern");
|
|
42
|
+
const schema_1 = require("@md-code/follow-architecture/entities/schema");
|
|
43
|
+
const configError = __importStar(require("@md-code/follow-architecture/report/configErrors"));
|
|
44
|
+
// A regex that never matches: the placeholder `re` of a `{ node }` child before
|
|
45
|
+
// `buildTree` gives it the referenced node's own pattern. It is always replaced
|
|
46
|
+
// before anything reads it, but the type stays a `RegExp`.
|
|
47
|
+
const DETACHED = /(?!)/;
|
|
48
|
+
const folderContents = (owner, folder, repoFiles) => {
|
|
49
|
+
const present = new Set((repoFiles ?? []).filter((f) => f.startsWith(`${folder}/`)).map((f) => f.slice(folder.length + 1).split("/")[0]));
|
|
50
|
+
const declared = owner.children ?? [];
|
|
51
|
+
const has = (child) => [...present].some((name) => child.re.test(name));
|
|
52
|
+
return {
|
|
53
|
+
present,
|
|
54
|
+
declared,
|
|
55
|
+
anyDeclared: declared.some(has),
|
|
56
|
+
missing: declared.filter((c) => c.required).filter((c) => !has(c)),
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
exports.folderContents = folderContents;
|
|
60
|
+
// The node itself plus every declared parent, nearest first. A `required` child
|
|
61
|
+
// is declared on the folder that owns it, which is usually an ancestor of the
|
|
62
|
+
// deepest node that matched the file.
|
|
63
|
+
const ancestorChain = (node, arch) => {
|
|
64
|
+
const chain = [];
|
|
65
|
+
const seen = new Set();
|
|
66
|
+
for (let cur = node; cur && !seen.has(cur.slug); cur = cur.parents.length === 1 ? (arch.nodes.bySlug[cur.parents[0] ?? ""] ?? null) : null) {
|
|
67
|
+
seen.add(cur.slug);
|
|
68
|
+
chain.push(cur);
|
|
69
|
+
}
|
|
70
|
+
return chain;
|
|
71
|
+
};
|
|
72
|
+
exports.ancestorChain = ancestorChain;
|
|
73
|
+
const missingRequiredChild = (node, arch, rel, ctx) => {
|
|
74
|
+
for (const owner of ancestorChain(node, arch)) {
|
|
75
|
+
const required = (owner.children ?? []).filter((c) => c.required);
|
|
76
|
+
if (!required.length)
|
|
77
|
+
continue;
|
|
78
|
+
const folder = ctx.concreteFolder(owner.path, rel);
|
|
79
|
+
if (!folder)
|
|
80
|
+
continue;
|
|
81
|
+
if (folderContents(owner, folder, ctx.repoFiles).missing.length)
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
};
|
|
86
|
+
exports.missingRequiredChild = missingRequiredChild;
|
|
87
|
+
// The regex a node's OWN path matches as a folder — `apps/backend/{kebab-case}`
|
|
88
|
+
// → `(?/apps/backend/([^/]+)$`. This is the question "is this folder one of the
|
|
89
|
+
// places this node declares?", asked about the folder itself, without inventing
|
|
90
|
+
// a file name to stand inside it.
|
|
91
|
+
const nodePathRe = (template) => (template === "." ? /^([^/]+)$/ : (0, pattern_1.compilePattern)(template).re);
|
|
92
|
+
exports.nodePathRe = nodePathRe;
|
|
93
|
+
const nodePrefixRe = (template) => {
|
|
94
|
+
if (template === ".")
|
|
95
|
+
return { re: /^([^/]+)(?:\/(.*))?$/, names: [], literalLen: 0, isFile: false };
|
|
96
|
+
const { body, names } = (0, pattern_1.patternBody)(template);
|
|
97
|
+
// A node whose path ends in a file extension is a FILE node: it matches
|
|
98
|
+
// exactly that file, not a folder prefix. `literalLen` is the number of
|
|
99
|
+
// fixed (non-placeholder) characters in the path — the specificity used
|
|
100
|
+
// to rank matches (longer literal prefix wins).
|
|
101
|
+
const isFile = /\.[A-Za-z0-9]+$/.test(String(template).split("/").pop() ?? "");
|
|
102
|
+
const literalLen = String(template).replace(pattern_1.PLACEHOLDER, "").length;
|
|
103
|
+
if (isFile)
|
|
104
|
+
return { re: new RegExp(`^${body}$`), names, literalLen, isFile: true };
|
|
105
|
+
return { re: new RegExp(`^${body}/([^/]+)(?:/(.*))?$`), names, literalLen, isFile: false };
|
|
106
|
+
};
|
|
107
|
+
exports.nodePrefixRe = nodePrefixRe;
|
|
108
|
+
// A child may declare which entity(s) live in it: one entity, several entities (a
|
|
109
|
+
// file holding both a model and its types), or none. The NODE says where code
|
|
110
|
+
// lives — the entity says what code is, never where it goes.
|
|
111
|
+
const entitiesOf = (spec) => {
|
|
112
|
+
const raw = spec?.entity;
|
|
113
|
+
if (raw == null)
|
|
114
|
+
return [];
|
|
115
|
+
return (Array.isArray(raw) ? raw : [raw]).map(String).filter(Boolean);
|
|
116
|
+
};
|
|
117
|
+
exports.entitiesOf = entitiesOf;
|
|
118
|
+
// `{ node: slug }` — the child IS another declared node.
|
|
119
|
+
const referencedChild = (spec) => ({
|
|
120
|
+
nodeSlug: String(spec.node),
|
|
121
|
+
name: null,
|
|
122
|
+
re: DETACHED,
|
|
123
|
+
captures: [],
|
|
124
|
+
folder: true,
|
|
125
|
+
required: Boolean(spec.required),
|
|
126
|
+
forbidden: Boolean(spec.forbidden),
|
|
127
|
+
query: null,
|
|
128
|
+
report: spec.report ?? null,
|
|
129
|
+
entities: entitiesOf(spec),
|
|
130
|
+
});
|
|
131
|
+
// A child named by a pattern: a FILE child (extension) or a FOLDER child.
|
|
132
|
+
const childOf = (rawName, spec) => {
|
|
133
|
+
const { body, names: captures } = (0, pattern_1.patternBody)(rawName);
|
|
134
|
+
const folder = !/\.[A-Za-z0-9]+$/.test(rawName.split("/").pop() ?? "");
|
|
135
|
+
return {
|
|
136
|
+
name: rawName,
|
|
137
|
+
re: new RegExp(`^${body}$`),
|
|
138
|
+
captures,
|
|
139
|
+
folder,
|
|
140
|
+
required: Boolean(spec?.required),
|
|
141
|
+
forbidden: Boolean(spec?.forbidden),
|
|
142
|
+
nodeSlug: null,
|
|
143
|
+
// A child may be recognised by a QUERY over the file's facts instead of
|
|
144
|
+
// (only) by its name — finally.js uses it to route a file that matches
|
|
145
|
+
// the child's query but sits elsewhere.
|
|
146
|
+
query: spec?.query ?? null,
|
|
147
|
+
report: spec?.report ?? null,
|
|
148
|
+
entities: entitiesOf(spec),
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
const compileChild = (name) => {
|
|
152
|
+
// A child is either a bare name or a spec `{ name?, node?, entity?, required?, forbidden?, query?, report? }`.
|
|
153
|
+
const spec = name && typeof name === "object" ? name : null;
|
|
154
|
+
if (spec) {
|
|
155
|
+
const known = new Set(schema_1.SCHEMA.child);
|
|
156
|
+
for (const key of Object.keys(spec)) {
|
|
157
|
+
if (!known.has(key))
|
|
158
|
+
throw configError.unknownChildKey({ node: String(spec.name ?? spec.node ?? "child"), key });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (spec?.node)
|
|
162
|
+
return referencedChild(spec);
|
|
163
|
+
return childOf(String(spec ? spec.name : name), spec);
|
|
164
|
+
};
|
|
165
|
+
exports.compileChild = compileChild;
|
|
@@ -0,0 +1,6 @@
|
|
|
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
|
+
import type { Violation } from "./violation";
|
|
5
|
+
declare const emitFindings: (...args: [violations: Violation[], ctx: FileContext, node: ArchNode, out: Finding[], findingFrom: FindingFrom]) => void;
|
|
6
|
+
export { emitFindings };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitFindings = void 0;
|
|
4
|
+
// A `declare` violation on a line that also carries a `call` to the same
|
|
5
|
+
// target is the same decision seen twice — the call's sentence answers for it.
|
|
6
|
+
const withoutDeclareDuplicates = (violations) => {
|
|
7
|
+
const called = new Set(violations.filter((v) => v.kind === "call").map((v) => `${v.line}|${v.targetPath}`));
|
|
8
|
+
return violations.filter((v) => v.kind !== "declare" || !called.has(`${v.line}|${v.targetPath}`));
|
|
9
|
+
};
|
|
10
|
+
// Same entity, several functions: one sentence naming all of them.
|
|
11
|
+
const entitySentence = (v) => {
|
|
12
|
+
const names = (v.names ?? []).filter(Boolean);
|
|
13
|
+
const shown = names
|
|
14
|
+
.slice(0, 4)
|
|
15
|
+
.map((n) => `\`${n}\``)
|
|
16
|
+
.join(", ");
|
|
17
|
+
const rest = names.length > 4 ? ` and ${names.length - 4} more` : "";
|
|
18
|
+
const tail = v.where
|
|
19
|
+
? `they belong in ${v.where}`
|
|
20
|
+
: `${v.owning ?? "this folder"} declares no home for a \`${v.entity}\``;
|
|
21
|
+
const move = v.where ? `Move ${shown}${rest} to ${v.where}.` : null;
|
|
22
|
+
return { ...v, fix: move, text: `This file declares \`${v.entity}\` functions (${shown}${rest}): ${tail}.` };
|
|
23
|
+
};
|
|
24
|
+
// One decision per key: an entity's many functions merge into one sentence; any
|
|
25
|
+
// other violation is its own decision, keyed by its text.
|
|
26
|
+
const decisionsOf = (violations) => {
|
|
27
|
+
const byText = new Map();
|
|
28
|
+
for (const v of violations) {
|
|
29
|
+
const key = v.entity ? `entity:${v.entity}` : v.text;
|
|
30
|
+
const names = (v.names ?? []).filter(Boolean);
|
|
31
|
+
if (v.entity && names.length > 1 && !byText.has(key)) {
|
|
32
|
+
byText.set(key, entitySentence(v));
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (!byText.has(key))
|
|
36
|
+
byText.set(key, v);
|
|
37
|
+
}
|
|
38
|
+
return [...byText.values()].sort((a, b) => a.line - b.line);
|
|
39
|
+
};
|
|
40
|
+
// The structured evidence a relation finding carries — the token the report
|
|
41
|
+
// draws, with the target it names.
|
|
42
|
+
const evidenceOf = (v) => v.kind && v.targetNode
|
|
43
|
+
? {
|
|
44
|
+
violations: [
|
|
45
|
+
{
|
|
46
|
+
kind: v.kind,
|
|
47
|
+
targetNode: v.targetNode,
|
|
48
|
+
targetPath: v.targetPath ?? null,
|
|
49
|
+
line: v.line,
|
|
50
|
+
destination: v.destination ?? null,
|
|
51
|
+
token: v.token ?? null,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
}
|
|
55
|
+
: {};
|
|
56
|
+
const emitFindings = (...args) => {
|
|
57
|
+
const [violations, ctx, node, out, findingFrom] = args;
|
|
58
|
+
const kept = withoutDeclareDuplicates(violations);
|
|
59
|
+
violations.length = 0;
|
|
60
|
+
violations.push(...kept);
|
|
61
|
+
if (violations.length === 0)
|
|
62
|
+
return;
|
|
63
|
+
for (const v of decisionsOf(violations)) {
|
|
64
|
+
out.push(findingFrom({
|
|
65
|
+
report: { message: v.text, fix: v.fix ?? null, code: v.ask ?? null },
|
|
66
|
+
line: v.line,
|
|
67
|
+
data: evidenceOf(v),
|
|
68
|
+
}, "finally-follow-architecture", node.slug, `finally:${node.slug}:${ctx.rel}:${v.kind ?? "misc"}:${v.targetNode ?? "-"}:${v.line}`, { path: ctx.rel, node: node.slug, what: ctx.rel }));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
exports.emitFindings = emitFindings;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Arch, WhereEntry } from "@md-code/follow-architecture/entities/architecture";
|
|
2
|
+
import type { Caps } from "@md-code/follow-architecture/entities/location/where";
|
|
3
|
+
declare const fitsEntity: (entitySlug: string, arch: Arch, rel: string) => boolean;
|
|
4
|
+
type AllowedPlace = {
|
|
5
|
+
entity: string | null;
|
|
6
|
+
paths: string[];
|
|
7
|
+
anywhere?: boolean;
|
|
8
|
+
same?: boolean;
|
|
9
|
+
filter?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare const allowedPlaces: (entries: WhereEntry[] | null | undefined, arch: Arch, targetCaps: Caps | null) => AllowedPlace[];
|
|
12
|
+
export { fitsEntity, allowedPlaces };
|
|
13
|
+
export type { AllowedPlace };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allowedPlaces = exports.fitsEntity = void 0;
|
|
4
|
+
// Entity ↔ place: is this file a home for that entity, and which paths may an
|
|
5
|
+
// action's `from:` list name.
|
|
6
|
+
const location_1 = require("@md-code/follow-architecture/entities/location");
|
|
7
|
+
const gate_1 = require("@md-code/follow-architecture/utils/gate");
|
|
8
|
+
// Does this file sit in one of the entity's homes? The home question is the ONE
|
|
9
|
+
// implementation in `entities/location/homes` (`entityFitsAt`, asked through the
|
|
10
|
+
// shared `where` grammar). The two exemptions are the shared gate: an entity
|
|
11
|
+
// nobody declares, or one with no home, restricts nothing — when neither
|
|
12
|
+
// rejection fires, the home answer decides.
|
|
13
|
+
const fitsEntity = (entitySlug, arch, rel) => !(0, gate_1.admitsWhenNoneReject)(entitySlug, [(slug) => !arch.entities?.[slug], (slug) => !(0, location_1.homesOf)(arch, slug).length]) ||
|
|
14
|
+
(0, location_1.entityFitsAt)(arch, entitySlug, rel);
|
|
15
|
+
exports.fitsEntity = fitsEntity;
|
|
16
|
+
const entityPlace = (entry, arch, targetCaps) => {
|
|
17
|
+
const homes = (0, location_1.homesOf)(arch, entry.entity ?? "");
|
|
18
|
+
const paths = homes.map((h) => (0, location_1.fillTemplate)(h.template, null, targetCaps)).filter((p) => Boolean(p));
|
|
19
|
+
// `same: true` is part of the RULE, not decoration: an orchestrator may
|
|
20
|
+
// call an action only inside its own feature. The message has to say so,
|
|
21
|
+
// or it reads as "orchestrators may not call actions at all".
|
|
22
|
+
return { entity: entry.entity ?? null, paths, anywhere: !homes.length, same: Boolean(entry.same) };
|
|
23
|
+
};
|
|
24
|
+
const nodePlace = (entry, arch, targetCaps) => {
|
|
25
|
+
const path = (0, location_1.fillTemplate)(arch.nodes?.bySlug?.[entry.node ?? ""]?.path, null, targetCaps);
|
|
26
|
+
return { entity: null, paths: path ? [path] : [] };
|
|
27
|
+
};
|
|
28
|
+
const allowedPlaces = (entries, arch, targetCaps) => {
|
|
29
|
+
const out = [];
|
|
30
|
+
for (const entry of entries ?? []) {
|
|
31
|
+
if (entry.type === "entity")
|
|
32
|
+
out.push(entityPlace(entry, arch, targetCaps));
|
|
33
|
+
else if (entry.type === "node")
|
|
34
|
+
out.push(nodePlace(entry, arch, targetCaps));
|
|
35
|
+
else if (entry.type === "glob")
|
|
36
|
+
out.push({ entity: null, paths: entry.glob ? [entry.glob] : [] });
|
|
37
|
+
else
|
|
38
|
+
out.push({ entity: null, paths: [], filter: true });
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
};
|
|
42
|
+
exports.allowedPlaces = allowedPlaces;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EDGE_FACTS } from "@md-code/follow-architecture/entities/kinds";
|
|
2
|
+
import { fitsEntity } from "./entities";
|
|
3
|
+
import type { Arch, ArchNode } from "@md-code/follow-architecture/entities/architecture";
|
|
4
|
+
import type { FileContext } from "@md-code/follow-architecture/entities/context";
|
|
5
|
+
import type { Finding, FindingFrom } from "@md-code/follow-architecture/entities/findings";
|
|
6
|
+
declare const checkFinally: (ctx: FileContext, arch: Arch, out: Finding[], findingFrom: FindingFrom) => void;
|
|
7
|
+
declare const __exported_missingRequiredChild: (node: ArchNode, arch: Arch, rel: string, files: string[] | null | undefined) => boolean;
|
|
8
|
+
export { checkFinally, fitsEntity, __exported_missingRequiredChild as missingRequiredChild, EDGE_FACTS };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EDGE_FACTS = exports.missingRequiredChild = exports.fitsEntity = exports.checkFinally = void 0;
|
|
4
|
+
// finally-follow-architecture: the built-in structure rule. Four questions,
|
|
5
|
+
// one module each, no wording (that lives in report/errorTypes).
|
|
6
|
+
const location_1 = require("@md-code/follow-architecture/entities/location");
|
|
7
|
+
const index_1 = require("@md-code/follow-architecture/entities/tree/index");
|
|
8
|
+
const children_1 = require("@md-code/follow-architecture/nodes/children");
|
|
9
|
+
const kinds_1 = require("@md-code/follow-architecture/entities/kinds");
|
|
10
|
+
Object.defineProperty(exports, "EDGE_FACTS", { enumerable: true, get: function () { return kinds_1.EDGE_FACTS; } });
|
|
11
|
+
const entities_1 = require("./entities");
|
|
12
|
+
Object.defineProperty(exports, "fitsEntity", { enumerable: true, get: function () { return entities_1.fitsEntity; } });
|
|
13
|
+
const required_1 = require("./required");
|
|
14
|
+
const queries_1 = require("./queries");
|
|
15
|
+
const relations_1 = require("./relations");
|
|
16
|
+
const emit_1 = require("./emit");
|
|
17
|
+
// The node's own structure questions, asked of the file that matched it: the
|
|
18
|
+
// required children, the child queries, the relations — then one finding per
|
|
19
|
+
// decision.
|
|
20
|
+
const checkNode = (ctx, node, out, findingFrom) => {
|
|
21
|
+
const violations = [];
|
|
22
|
+
(0, required_1.checkRequiredChildren)(ctx, node, out, findingFrom);
|
|
23
|
+
(0, queries_1.checkChildQueries)(ctx, node, violations);
|
|
24
|
+
(0, relations_1.checkRelations)(ctx, ctx.arch, violations);
|
|
25
|
+
(0, emit_1.emitFindings)(violations, ctx, node, out, findingFrom);
|
|
26
|
+
};
|
|
27
|
+
const checkFinally = (ctx, arch, out, findingFrom) => {
|
|
28
|
+
const match = (0, index_1.deepestMatch)(ctx.rel, arch);
|
|
29
|
+
if (!match)
|
|
30
|
+
return;
|
|
31
|
+
checkNode(ctx, match.node, out, findingFrom);
|
|
32
|
+
};
|
|
33
|
+
exports.checkFinally = checkFinally;
|
|
34
|
+
const __exported_missingRequiredChild = (node, arch, rel, files) => (0, children_1.missingRequiredChild)(node, arch, rel, { repoFiles: files, concreteFolder: location_1.fillTemplate });
|
|
35
|
+
exports.missingRequiredChild = __exported_missingRequiredChild;
|
|
@@ -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 { Violation } from "./violation";
|
|
4
|
+
declare const checkChildQueries: (ctx: FileContext, node: ArchNode, violations: Violation[]) => void;
|
|
5
|
+
export { checkChildQueries };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkChildQueries = void 0;
|
|
4
|
+
// A file that matches a declared child's query but sits outside it.
|
|
5
|
+
const queries_1 = require("@md-code/follow-architecture/entities/queries");
|
|
6
|
+
const children_1 = require("@md-code/follow-architecture/nodes/children");
|
|
7
|
+
const location_1 = require("@md-code/follow-architecture/entities/location");
|
|
8
|
+
const checkChildQueries = (ctx, node, violations) => {
|
|
9
|
+
for (const child of node.children) {
|
|
10
|
+
if (!child.query)
|
|
11
|
+
continue;
|
|
12
|
+
if (!(0, queries_1.matches)(ctx.facts, child.query))
|
|
13
|
+
continue;
|
|
14
|
+
const childPath = node.path === "." ? child.name : `${node.path}/${child.name}`;
|
|
15
|
+
const { re } = (0, children_1.nodePrefixRe)(childPath ?? "");
|
|
16
|
+
if (re.test(ctx.rel))
|
|
17
|
+
continue; // already in the right place
|
|
18
|
+
const where = (0, location_1.fillTemplate)(childPath, ctx.rel);
|
|
19
|
+
violations.push({
|
|
20
|
+
line: 1,
|
|
21
|
+
text: `this file matches the query of node \`${child.slug ?? child.name}\` and belong in \`${where}\``,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.checkChildQueries = checkChildQueries;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Arch, ActionDef } 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 checkAccessorImports: (ctx: FileContext, arch: Arch, declared: Map<string, Map<string, ActionDef>>, violations: Violation[]) => void;
|
|
5
|
+
export { checkAccessorImports };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkAccessorImports = void 0;
|
|
4
|
+
// The accessor-import check: an entity handed out ONLY through declared accessors
|
|
5
|
+
// (`scopeAccess`) may not be imported by name. The rule is the architecture's
|
|
6
|
+
// own — the engine only reads which accessors an entity declares and which names
|
|
7
|
+
// an import takes out.
|
|
8
|
+
const queries_1 = require("@md-code/follow-architecture/entities/queries");
|
|
9
|
+
const location_1 = require("@md-code/follow-architecture/entities/location");
|
|
10
|
+
const kinds_1 = require("@md-code/follow-architecture/entities/kinds");
|
|
11
|
+
const entities_1 = require("@md-code/follow-architecture/code-entities/entities");
|
|
12
|
+
// The function-scope accessors an entity declares — the only names it is handed
|
|
13
|
+
// out as.
|
|
14
|
+
const accessorsOf = (action) => (action?.scopeAccess ?? []).filter((x) => x.scope === entities_1.SCOPE.FUNCTION).map((x) => x.segments[0]);
|
|
15
|
+
// The entity's own concrete homes (no placeholders): where an import of it may
|
|
16
|
+
// resolve to.
|
|
17
|
+
const ownFilesOf = (arch, entitySlug) => (0, location_1.homesOf)(arch, entitySlug)
|
|
18
|
+
.map((h) => h.template)
|
|
19
|
+
.filter((t) => !/[*{]/.test(t));
|
|
20
|
+
// One entity's accessor rule, asked of the file's imports.
|
|
21
|
+
const checkEntityAccess = (ctx, entitySlug, accessors, violations) => {
|
|
22
|
+
const arch = ctx.arch;
|
|
23
|
+
const ownFile = ownFilesOf(arch, entitySlug);
|
|
24
|
+
const importFilter = {
|
|
25
|
+
resolved: { in: ownFile },
|
|
26
|
+
typeOnly: { equals: false },
|
|
27
|
+
named: { any: { not: { in: accessors } } },
|
|
28
|
+
};
|
|
29
|
+
const repoImports = ctx.facts?.imports ?? [];
|
|
30
|
+
const scope = { arch, fileRel: ctx.rel };
|
|
31
|
+
for (const imp of (0, queries_1.hitOf)(repoImports, { any: importFilter }, scope)) {
|
|
32
|
+
const bad = (0, queries_1.hitOf)(imp.named ?? [], { any: { not: { in: accessors } } }, scope);
|
|
33
|
+
if (!bad.length)
|
|
34
|
+
continue;
|
|
35
|
+
violations.push({
|
|
36
|
+
line: imp.line ?? 1,
|
|
37
|
+
text: `\`${bad.join("`, `")}\` is taken out of \`${imp.resolved}\`, but \`${entitySlug}\` is handed out only as ${accessors.map((a) => `\`${a}(…)\``).join(", ")}`,
|
|
38
|
+
fix: `Import one of the declared accessors (${accessors.join(", ")}) instead of \`${bad[0]}\`.`,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const checkAccessorImports = (ctx, arch, declared, violations) => {
|
|
43
|
+
for (const entitySlug of Object.keys(arch.entities ?? {})) {
|
|
44
|
+
const accessors = accessorsOf(declared.get(kinds_1.RELATION.CALL)?.get(entitySlug));
|
|
45
|
+
if (!accessors.length)
|
|
46
|
+
continue;
|
|
47
|
+
checkEntityAccess(ctx, entitySlug, accessors, violations);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
exports.checkAccessorImports = checkAccessorImports;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Edge } from "@md-code/follow-architecture/entities/kinds";
|
|
2
|
+
import type { Arch, ActionDef } from "@md-code/follow-architecture/entities/architecture";
|
|
3
|
+
import type { FileContext } from "@md-code/follow-architecture/entities/context";
|
|
4
|
+
import type { Caps } from "@md-code/follow-architecture/entities/location/where";
|
|
5
|
+
import type { RelationGroup } from "./relations-group";
|
|
6
|
+
type Pair = {
|
|
7
|
+
targetSlug: string;
|
|
8
|
+
action: ActionDef & {
|
|
9
|
+
missing?: boolean;
|
|
10
|
+
};
|
|
11
|
+
caps: Caps;
|
|
12
|
+
violation: boolean;
|
|
13
|
+
outward?: boolean;
|
|
14
|
+
};
|
|
15
|
+
type EdgeJudgment = {
|
|
16
|
+
key: string;
|
|
17
|
+
group: RelationGroup;
|
|
18
|
+
};
|
|
19
|
+
type JudgeCtx = {
|
|
20
|
+
ctx: FileContext;
|
|
21
|
+
arch: Arch;
|
|
22
|
+
kind: string;
|
|
23
|
+
actionDecls: Map<string, ActionDef>;
|
|
24
|
+
fileEntities: string[];
|
|
25
|
+
};
|
|
26
|
+
declare const judgeEdge: (edge: Edge, jctx: JudgeCtx) => EdgeJudgment | null;
|
|
27
|
+
declare const joinGroup: (group: RelationGroup, edge: Edge) => void;
|
|
28
|
+
export { judgeEdge, joinGroup };
|
|
29
|
+
export type { EdgeJudgment, Pair };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.joinGroup = exports.judgeEdge = void 0;
|
|
4
|
+
// ONE edge, judged by the entity that owns its target: which target entities could
|
|
5
|
+
// allow it, what each declares, and whether every one of them refuses. The
|
|
6
|
+
// ranking picks the refusal that explains the rule best; only when EVERY
|
|
7
|
+
// target refuses is there a finding to group.
|
|
8
|
+
const location_1 = require("@md-code/follow-architecture/entities/location");
|
|
9
|
+
const index_1 = require("@md-code/follow-architecture/entities/tree/index");
|
|
10
|
+
const kinds_1 = require("@md-code/follow-architecture/entities/kinds");
|
|
11
|
+
const verdicts_1 = require("@md-code/follow-architecture/utils/verdicts");
|
|
12
|
+
const permission_1 = require("@md-code/follow-architecture/utils/permission");
|
|
13
|
+
const entities_1 = require("./entities");
|
|
14
|
+
const observed_1 = require("@md-code/follow-architecture/report/observed");
|
|
15
|
+
// The entities the edge's SOURCE speaks with: the piece's own entity when it has
|
|
16
|
+
// one; a file-level statement speaks with the file's entities; an unclassified piece
|
|
17
|
+
// speaks with none.
|
|
18
|
+
const sourceEntitiesOf = (edge, fileEntities) => {
|
|
19
|
+
const own = edge.entity ? [edge.entity] : [...fileEntities];
|
|
20
|
+
return edge.piece && !edge.entity ? [] : own;
|
|
21
|
+
};
|
|
22
|
+
// The entities the TARGET may be judged by: a self-statement keeps the source's
|
|
23
|
+
// own entities; anything else asks the tree what is declared at the target path.
|
|
24
|
+
const targetEntitiesOf = (edge, jctx, selfStatement) => {
|
|
25
|
+
if (!selfStatement)
|
|
26
|
+
return (0, location_1.entitiesAtPath)(jctx.arch, edge.path);
|
|
27
|
+
if (edge.entity)
|
|
28
|
+
return [edge.entity];
|
|
29
|
+
return jctx.fileEntities.length ? jctx.fileEntities : (0, location_1.entitiesAtPath)(jctx.arch, edge.path);
|
|
30
|
+
};
|
|
31
|
+
// The scope one action is judged in: the file's facts, the source's entities,
|
|
32
|
+
// and the edge itself (the call may need WHAT was passed).
|
|
33
|
+
const scopeOf = (ctx, sourceEntities, edge) => {
|
|
34
|
+
const facts = ctx.facts;
|
|
35
|
+
const base = facts ?? {
|
|
36
|
+
lines: [],
|
|
37
|
+
imports: [],
|
|
38
|
+
exports: [],
|
|
39
|
+
location: { path: ctx.rel, segments: [], exts: [], fileName: "", words: [], files: [], siblings: [] },
|
|
40
|
+
reads: [],
|
|
41
|
+
kind: { own: { is: "SourceFile" }, descendants: [] },
|
|
42
|
+
candidates: [],
|
|
43
|
+
entities: [],
|
|
44
|
+
};
|
|
45
|
+
return { ...base, entities: sourceEntities, edge: edge.fact ?? null };
|
|
46
|
+
};
|
|
47
|
+
// One target entity's verdict: the action it declares for this fact kind (or a
|
|
48
|
+
// missing one), and whether the source may do it. The allow/except walk is the
|
|
49
|
+
// shared `permissionOf` core; a source with no entities is granted nothing.
|
|
50
|
+
const pairOf = (targetSlug, edge, sourceEntities, jctx) => {
|
|
51
|
+
const { ctx, arch } = jctx;
|
|
52
|
+
const caps = (0, index_1.targetCapsFor)(edge.path ?? "", arch);
|
|
53
|
+
const action = jctx.actionDecls.get(targetSlug);
|
|
54
|
+
if (!action)
|
|
55
|
+
return { targetSlug, action: { where: [], missing: true }, caps, violation: true };
|
|
56
|
+
const { allowed, denied } = (0, permission_1.permissionOf)(action, {
|
|
57
|
+
rel: ctx.rel,
|
|
58
|
+
arch,
|
|
59
|
+
scope: scopeOf(ctx, sourceEntities, edge),
|
|
60
|
+
caps,
|
|
61
|
+
});
|
|
62
|
+
const violation = sourceEntities.length ? !allowed || denied : true;
|
|
63
|
+
return { targetSlug, action, caps, violation, outward: denied };
|
|
64
|
+
};
|
|
65
|
+
// An entity that NAMES who may do it explains the rule best; a declared action
|
|
66
|
+
// beats a missing one; fewer conditions beat more.
|
|
67
|
+
const rankPairs = (a, b) => Number(Boolean(b.action.where?.length)) - Number(Boolean(a.action.where?.length)) ||
|
|
68
|
+
Number(!b.action.missing) - Number(!a.action.missing) ||
|
|
69
|
+
(a.action.where ?? []).length - (b.action.where ?? []).length;
|
|
70
|
+
// The route the architecture DOES allow to the same code, if it names one:
|
|
71
|
+
// a `call` permission with a declared accessor.
|
|
72
|
+
const routeOf = (targetSlug, jctx, caps) => {
|
|
73
|
+
const { ctx, arch } = jctx;
|
|
74
|
+
const callDecl = declaredCall(jctx, targetSlug);
|
|
75
|
+
const callOk = callDecl?.where ? !(0, location_1.checkWhere)(callDecl.where, ctx.rel, arch, ctx.facts, caps) : false;
|
|
76
|
+
const route = callOk ? ((callDecl?.scopeAccess ?? [])[0] ?? null) : null;
|
|
77
|
+
return route ? (0, location_1.accessorLabel)(route) : null;
|
|
78
|
+
};
|
|
79
|
+
const declaredCall = (jctx, targetSlug) => jctx.ctx.arch.entities[targetSlug]?.actions[kinds_1.RELATION.CALL] ?? null;
|
|
80
|
+
// The concrete destinations the refusal can offer: the allowed places that
|
|
81
|
+
// are not the target itself, not this file, not this folder.
|
|
82
|
+
const destOf = (places, targetSlug, rel) => {
|
|
83
|
+
const others = places.filter((p) => p.entity !== targetSlug);
|
|
84
|
+
const spots = (others.length ? others : places)
|
|
85
|
+
.filter((pl) => !pl.filter)
|
|
86
|
+
.flatMap((pl) => pl.paths.map((path) => ({ entity: pl.entity, path })))
|
|
87
|
+
.filter((sp) => sp.path !== rel && sp.path !== (0, location_1.dirOf)(rel) && sp.entity !== targetSlug);
|
|
88
|
+
return spots[0]?.path ?? null;
|
|
89
|
+
};
|
|
90
|
+
// The group one refused edge starts or joins. The allowed entities are the
|
|
91
|
+
// places WITHOUT the target itself (the target cannot allow its own refusal);
|
|
92
|
+
// only when no other place exists does the target's own list stand.
|
|
93
|
+
const groupOf = (edge, pair, jctx, all) => {
|
|
94
|
+
const { ctx, kind } = jctx;
|
|
95
|
+
const route = routeOf(pair.targetSlug, jctx, pair.caps);
|
|
96
|
+
const others = all.filter((p) => p.entity !== pair.targetSlug);
|
|
97
|
+
const places = others.length ? others : all;
|
|
98
|
+
return {
|
|
99
|
+
kind,
|
|
100
|
+
targetNode: pair.targetSlug,
|
|
101
|
+
allowedEntities: [...new Set(places.map((pl) => pl.entity).filter((r) => Boolean(r)))],
|
|
102
|
+
sameEntities: [
|
|
103
|
+
...new Set(places
|
|
104
|
+
.filter((pl) => pl.same)
|
|
105
|
+
.map((pl) => pl.entity)
|
|
106
|
+
.filter((r) => Boolean(r))),
|
|
107
|
+
],
|
|
108
|
+
via: (pair.action.scopeAccess ?? []).map(location_1.accessorLabel),
|
|
109
|
+
route,
|
|
110
|
+
dest: destOf(all, pair.targetSlug, ctx.rel),
|
|
111
|
+
lines: [],
|
|
112
|
+
what: new Set(),
|
|
113
|
+
path: edge.path,
|
|
114
|
+
pieces: new Map(),
|
|
115
|
+
piece: edge.piece ?? null,
|
|
116
|
+
pieceEntity: edge.entity ?? null,
|
|
117
|
+
silent: Boolean(pair.action.missing) || !(pair.action.where ?? []).length,
|
|
118
|
+
filtered: Boolean(pair.outward),
|
|
119
|
+
self: edge.path === ctx.rel,
|
|
120
|
+
fact: edge.fact ?? null,
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
// What the scan SAW is recorded before the judgment drops the allowed edges below:
|
|
124
|
+
// the graph draws them, and this is the only place both halves are still together.
|
|
125
|
+
// Judge one edge: every target entity's verdict, ranked; when ALL refuse, the
|
|
126
|
+
// best-explaining one names the group.
|
|
127
|
+
const judgeEdge = (edge, jctx) => {
|
|
128
|
+
const sourceEntities = sourceEntitiesOf(edge, jctx.fileEntities);
|
|
129
|
+
const selfStatement = edge.path === jctx.ctx.rel;
|
|
130
|
+
const pairs = targetEntitiesOf(edge, jctx, selfStatement).map((slug) => pairOf(slug, edge, sourceEntities, jctx));
|
|
131
|
+
(0, observed_1.recordJudged)({ kind: jctx.kind, file: jctx.ctx.rel, line: edge.line ?? 1, sentence: edge.what }, sourceEntities, pairs);
|
|
132
|
+
const worst = (0, verdicts_1.worstWhenAllRefuse)(pairs, rankPairs);
|
|
133
|
+
if (!worst)
|
|
134
|
+
return null;
|
|
135
|
+
const places = (0, entities_1.allowedPlaces)(worst.action.where, jctx.arch, worst.caps);
|
|
136
|
+
const group = groupOf(edge, worst, jctx, places);
|
|
137
|
+
const key = `${jctx.kind}|${worst.targetSlug}|${edge.what}`;
|
|
138
|
+
return { key, group };
|
|
139
|
+
};
|
|
140
|
+
exports.judgeEdge = judgeEdge;
|
|
141
|
+
// Merge one edge into its group: the line, the what, the piece.
|
|
142
|
+
const joinGroup = (group, edge) => {
|
|
143
|
+
group.lines.push(edge.line ?? 1);
|
|
144
|
+
group.what.add(edge.what);
|
|
145
|
+
if (edge.piece)
|
|
146
|
+
group.pieces.set(edge.piece, edge.entity ?? null);
|
|
147
|
+
};
|
|
148
|
+
exports.joinGroup = joinGroup;
|