@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,332 @@
|
|
|
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.declaredActions = exports.changesState = exports.CHANGES_STATE = exports.EDGE_FACTS = exports.FACT_KINDS = exports.VIA = exports.RELATION = void 0;
|
|
37
|
+
const configError = __importStar(require("@md-code/follow-architecture/report/configErrors"));
|
|
38
|
+
// THE VOCABULARY, as an enum: one name per relation, one spelling everywhere.
|
|
39
|
+
const RELATION = Object.freeze({
|
|
40
|
+
IMPORT: "import",
|
|
41
|
+
EXPORT: "export",
|
|
42
|
+
DECLARE: "declare",
|
|
43
|
+
CALL: "call",
|
|
44
|
+
MUTATE: "mutate",
|
|
45
|
+
ASSIGN: "assign",
|
|
46
|
+
READ: "read",
|
|
47
|
+
TYPE_IMPORT: "typeImport",
|
|
48
|
+
});
|
|
49
|
+
exports.RELATION = RELATION;
|
|
50
|
+
const FACT_KINDS = Object.values(RELATION);
|
|
51
|
+
exports.FACT_KINDS = FACT_KINDS;
|
|
52
|
+
// How a WRITE is spelled in the code — the `via` of a write fact.
|
|
53
|
+
const VIA = Object.freeze({ ASSIGN: "assign", CALL: "call", DELETE: "delete", FREEZE: "freeze", SEAL: "seal" });
|
|
54
|
+
exports.VIA = VIA;
|
|
55
|
+
// The relations that CHANGE state — the only ones that name an OWNER.
|
|
56
|
+
const CHANGES_STATE = new Set([RELATION.MUTATE, RELATION.ASSIGN]);
|
|
57
|
+
exports.CHANGES_STATE = CHANGES_STATE;
|
|
58
|
+
const changesState = (relation) => CHANGES_STATE.has(relation);
|
|
59
|
+
exports.changesState = changesState;
|
|
60
|
+
// The entity of the piece of code a fact belongs to, by the piece's name.
|
|
61
|
+
const entityOfPiece = (facts, piece) => piece ? ((facts.candidates ?? []).find((c) => c.name === piece && c.entity)?.entity ?? null) : null;
|
|
62
|
+
// Is a module path a FILE of this repo?
|
|
63
|
+
const isRepoModule = (facts, module) => Boolean(module) && (facts.repoFiles ?? []).includes(module ?? "");
|
|
64
|
+
// The line a candidate starts on.
|
|
65
|
+
const lineOf = (c) => c.lines?.[0] ?? 1;
|
|
66
|
+
// The shape EVERY edge has: the target, the piece it belongs to and whether the
|
|
67
|
+
// target is a library, plus the structured `fact` and its sentence.
|
|
68
|
+
const edgeOf = (facts, edge) => ({ ...edge, entity: entityOfPiece(facts, edge.piece) });
|
|
69
|
+
const callsOf = (facts) => (facts.candidates ?? []).flatMap((c) => (c.calls ?? [])
|
|
70
|
+
.filter((call) => call.module && !call.receiverOnly)
|
|
71
|
+
.map((call) => ({
|
|
72
|
+
path: call.module,
|
|
73
|
+
line: lineOf(c),
|
|
74
|
+
action: call.action,
|
|
75
|
+
piece: c.name ?? null,
|
|
76
|
+
external: !isRepoModule(facts, call.module),
|
|
77
|
+
fact: { kind: "call", action: call.action ?? null, module: call.module, with: call.arguments ?? [] },
|
|
78
|
+
what: `calls \`${call.action}\` of \`${call.module}\``,
|
|
79
|
+
}))
|
|
80
|
+
.map((edge) => edgeOf(facts, edge)));
|
|
81
|
+
const readsOf = (facts) => (facts.reads ?? []).map((r) => edgeOf(facts, {
|
|
82
|
+
path: r.module,
|
|
83
|
+
line: r.line ?? 1,
|
|
84
|
+
piece: r.piece ?? null,
|
|
85
|
+
external: !isRepoModule(facts, r.module),
|
|
86
|
+
fact: { kind: "read", what: r.what ?? null, module: r.module },
|
|
87
|
+
what: `reads \`${r.what}\` of \`${r.module}\``,
|
|
88
|
+
}));
|
|
89
|
+
const writeWhat = ({ target, module, method, onThis, mutate }) => {
|
|
90
|
+
if (!mutate)
|
|
91
|
+
return `writes into \`${target}\`${method ? ` through \`${method}()\`` : ""}`;
|
|
92
|
+
return onThis ? `changes \`${target}\` of its own file` : `changes \`${target}\` of \`${module}\``;
|
|
93
|
+
};
|
|
94
|
+
const writePath = (facts, a, mutate) => {
|
|
95
|
+
if (!mutate)
|
|
96
|
+
return facts.location.path;
|
|
97
|
+
return a.onThis ? facts.location.path : (a.module ?? null);
|
|
98
|
+
};
|
|
99
|
+
const writeExternal = (facts, a, mutate) => mutate && !a.onThis ? !isRepoModule(facts, a.module) : false;
|
|
100
|
+
const assignmentEdge = (facts, c, a, mutate) => edgeOf(facts, {
|
|
101
|
+
path: writePath(facts, a, mutate),
|
|
102
|
+
line: a.line ?? lineOf(c),
|
|
103
|
+
piece: c.name ?? null,
|
|
104
|
+
external: writeExternal(facts, a, mutate),
|
|
105
|
+
// THE FACT — what the code did, as data.
|
|
106
|
+
fact: {
|
|
107
|
+
kind: mutate ? RELATION.MUTATE : RELATION.ASSIGN,
|
|
108
|
+
target: a.target ?? null,
|
|
109
|
+
module: a.module ?? null,
|
|
110
|
+
method: a.method ?? null,
|
|
111
|
+
onThis: Boolean(a.onThis),
|
|
112
|
+
},
|
|
113
|
+
what: writeWhat({ target: a.target, module: a.module, method: a.method, onThis: Boolean(a.onThis), mutate }),
|
|
114
|
+
});
|
|
115
|
+
const assignmentsOf = (facts, { mutate }) => (facts.candidates ?? []).flatMap((c) => (c.assignments ?? [])
|
|
116
|
+
.filter((a) => a.relation === (mutate ? RELATION.MUTATE : RELATION.ASSIGN))
|
|
117
|
+
.map((a) => assignmentEdge(facts, c, a, mutate)));
|
|
118
|
+
// How an export reads — the ONE place the export vocabulary is spelled.
|
|
119
|
+
const exportWhat = (exp, names) => {
|
|
120
|
+
if (exp.form === "named" && !exp.from)
|
|
121
|
+
return names.length ? `exports \`${names.join("`, `")}\`` : "is exported";
|
|
122
|
+
if (exp.form === "namespace")
|
|
123
|
+
return `re-exports \`${exp.source}\` as \`${names[0]}\``;
|
|
124
|
+
if (exp.form === "star")
|
|
125
|
+
return `re-exports \`${exp.source}\``;
|
|
126
|
+
if (exp.form === "default")
|
|
127
|
+
return "is exported as its default";
|
|
128
|
+
if (exp.form === "equals")
|
|
129
|
+
return "is exported with `export =`";
|
|
130
|
+
if (exp.name)
|
|
131
|
+
return `exports \`${exp.name}\` through CommonJS`;
|
|
132
|
+
return "is exported through CommonJS";
|
|
133
|
+
};
|
|
134
|
+
// The piece an export is about: the published binding, or null for a re-export.
|
|
135
|
+
const exportPiece = (facts, exp, names) => {
|
|
136
|
+
if (exp.piece)
|
|
137
|
+
return exp.piece;
|
|
138
|
+
if (exp.from || names.length !== 1)
|
|
139
|
+
return null;
|
|
140
|
+
return (facts.candidates ?? []).some((c) => c.name === names[0]) ? names[0] : null;
|
|
141
|
+
};
|
|
142
|
+
// The file each re-exported name is declared in (a barrel re-exported by a
|
|
143
|
+
// facade hides the same declaring file as the import it stands for).
|
|
144
|
+
const exportGroups = (exp, names) => {
|
|
145
|
+
const groups = new Map();
|
|
146
|
+
if (!exp.from)
|
|
147
|
+
return groups;
|
|
148
|
+
names.forEach((name, at) => {
|
|
149
|
+
const file = exp.declaring?.[at] ?? null;
|
|
150
|
+
if (!file || file === exp.from)
|
|
151
|
+
return;
|
|
152
|
+
const group = groups.get(file) ?? [];
|
|
153
|
+
group.push(name);
|
|
154
|
+
groups.set(file, group);
|
|
155
|
+
});
|
|
156
|
+
return groups;
|
|
157
|
+
};
|
|
158
|
+
const exportFromEdges = (facts) => (facts.exports ?? []).flatMap((exp) => {
|
|
159
|
+
const names = exp.named ?? [];
|
|
160
|
+
const groups = exportGroups(exp, names);
|
|
161
|
+
const stayed = names.filter((_, at) => {
|
|
162
|
+
const file = exp.declaring?.[at] ?? null;
|
|
163
|
+
return !file || file === exp.from;
|
|
164
|
+
});
|
|
165
|
+
const fact = (resolved) => ({
|
|
166
|
+
kind: "export",
|
|
167
|
+
form: exp.form ?? "named",
|
|
168
|
+
names: stayed,
|
|
169
|
+
name: exp.name ?? null,
|
|
170
|
+
source: exp.source ?? null,
|
|
171
|
+
resolved,
|
|
172
|
+
reExport: Boolean(exp.from),
|
|
173
|
+
});
|
|
174
|
+
const moduleEdge = edgeOf(facts, {
|
|
175
|
+
path: exp.from ?? facts.location.path,
|
|
176
|
+
line: exp.line ?? 1,
|
|
177
|
+
piece: exportPiece(facts, exp, names),
|
|
178
|
+
external: exp.from ? !isRepoModule(facts, exp.from) : false,
|
|
179
|
+
fact: fact(exp.from ?? null),
|
|
180
|
+
what: exportWhat(exp, exp.from && groups.size ? stayed : names),
|
|
181
|
+
});
|
|
182
|
+
const declaredEdges = [...groups].map(([file, grouped]) => edgeOf(facts, {
|
|
183
|
+
path: file,
|
|
184
|
+
line: exp.line ?? 1,
|
|
185
|
+
piece: null,
|
|
186
|
+
external: !isRepoModule(facts, file),
|
|
187
|
+
fact: { ...fact(file), names: grouped, resolved: file },
|
|
188
|
+
what: `re-exports \`${grouped.join("`, `")}\` of \`${file}\``,
|
|
189
|
+
}));
|
|
190
|
+
return [...(groups.size && !stayed.length ? [] : [moduleEdge]), ...declaredEdges];
|
|
191
|
+
});
|
|
192
|
+
const declaredExportEdges = (facts) => (facts.candidates ?? [])
|
|
193
|
+
.filter((c) => c.exported)
|
|
194
|
+
.map((c) => edgeOf(facts, {
|
|
195
|
+
path: facts.location.path,
|
|
196
|
+
line: lineOf(c),
|
|
197
|
+
piece: c.name ?? null,
|
|
198
|
+
external: false,
|
|
199
|
+
fact: {
|
|
200
|
+
kind: "export",
|
|
201
|
+
form: "declared",
|
|
202
|
+
names: c.name ? [c.name] : [],
|
|
203
|
+
name: c.name ?? null,
|
|
204
|
+
source: null,
|
|
205
|
+
reExport: false,
|
|
206
|
+
},
|
|
207
|
+
what: "is exported",
|
|
208
|
+
}));
|
|
209
|
+
// A declaration that only RENAMES another module's value (`const a = b.c`).
|
|
210
|
+
const renamedCall = (c) => {
|
|
211
|
+
const calls = (c.calls ?? []).filter((x) => x.module && !x.receiverOnly);
|
|
212
|
+
const returned = (c.returns ?? [])[0]?.exprKind ?? null;
|
|
213
|
+
const renames = returned === "CallExpression" || returned === "PropertyAccessExpression";
|
|
214
|
+
return calls.length === 1 && renames ? calls[0] : null;
|
|
215
|
+
};
|
|
216
|
+
const declareEdge = (facts, c) => {
|
|
217
|
+
const renames = renamedCall(c);
|
|
218
|
+
return edgeOf(facts, {
|
|
219
|
+
path: renames ? renames.module : facts.location.path,
|
|
220
|
+
line: lineOf(c),
|
|
221
|
+
piece: c.name ?? null,
|
|
222
|
+
external: renames ? !isRepoModule(facts, renames.module) : false,
|
|
223
|
+
fact: { kind: "declare", renames: renames ? { action: renames.action ?? null, module: renames.module } : null },
|
|
224
|
+
what: renames ? `re-declares \`${renames.action}\` of \`${renames.module}\`` : "is declared here",
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
// A named import asks the module to PASS A NAME ON; the law names the file that
|
|
228
|
+
// declares it. Grouping the names by declaring file keeps one edge per target,
|
|
229
|
+
// and a name the chain could not follow stays on the module file.
|
|
230
|
+
const declaredGroups = (imp) => {
|
|
231
|
+
const groups = new Map();
|
|
232
|
+
const module = imp.resolved ?? "";
|
|
233
|
+
(imp.named ?? []).forEach((name, at) => {
|
|
234
|
+
const file = imp.declaring?.[at] ?? null;
|
|
235
|
+
if (!file || file === module)
|
|
236
|
+
return;
|
|
237
|
+
const names = groups.get(file) ?? [];
|
|
238
|
+
names.push(imp.imported?.[at] ?? name);
|
|
239
|
+
groups.set(file, names);
|
|
240
|
+
});
|
|
241
|
+
return groups;
|
|
242
|
+
};
|
|
243
|
+
// The imported TEXT of one target: the module form is unchanged, a declaring
|
|
244
|
+
// file is named with the symbols the file asked it for.
|
|
245
|
+
const importWhat = (imp, file, names) => {
|
|
246
|
+
if (!names?.length || !file)
|
|
247
|
+
return imp.form === "statement" ? `imports \`${imp.resolved}\`` : `requires \`${imp.source}\``;
|
|
248
|
+
return `imports \`${names.join("`, `")}\` of \`${file}\``;
|
|
249
|
+
};
|
|
250
|
+
// Everything a named import touches: the module it wrote (for the names that
|
|
251
|
+
// stayed) plus the file each group of names is declared in.
|
|
252
|
+
const importEdges = (facts, imp, kind) => {
|
|
253
|
+
const groups = declaredGroups(imp);
|
|
254
|
+
const base = { line: imp.line ?? 1, piece: imp.piece ?? null };
|
|
255
|
+
// The plain edge keeps the fact it always had: a target and no symbols.
|
|
256
|
+
const factOf = (file, names) => {
|
|
257
|
+
const base = kind === RELATION.IMPORT
|
|
258
|
+
? { kind, form: imp.form ?? null, source: imp.source ?? null, resolved: file }
|
|
259
|
+
: { kind, source: imp.source ?? null, resolved: file };
|
|
260
|
+
return names?.length ? { ...base, names } : base;
|
|
261
|
+
};
|
|
262
|
+
const edges = [];
|
|
263
|
+
const stayed = (imp.named ?? []).filter((_, at) => !groups.size || !(imp.declaring?.[at] && imp.declaring[at] !== imp.resolved));
|
|
264
|
+
if (stayed.length || !groups.size) {
|
|
265
|
+
edges.push(edgeOf(facts, {
|
|
266
|
+
path: imp.resolved ?? null,
|
|
267
|
+
...base,
|
|
268
|
+
external: !isRepoModule(facts, imp.resolved),
|
|
269
|
+
fact: factOf(imp.resolved ?? null, groups.size ? stayed : null),
|
|
270
|
+
what: importWhat(imp, null, null),
|
|
271
|
+
}));
|
|
272
|
+
}
|
|
273
|
+
for (const [file, names] of groups) {
|
|
274
|
+
edges.push(edgeOf(facts, {
|
|
275
|
+
path: file,
|
|
276
|
+
...base,
|
|
277
|
+
external: !isRepoModule(facts, file),
|
|
278
|
+
fact: factOf(file, names),
|
|
279
|
+
what: importWhat(imp, file, names),
|
|
280
|
+
}));
|
|
281
|
+
}
|
|
282
|
+
return edges;
|
|
283
|
+
};
|
|
284
|
+
const EDGE_FACTS = {
|
|
285
|
+
// `import … from "x"` — a resolved static import.
|
|
286
|
+
[RELATION.IMPORT]: (facts) => (facts.imports ?? [])
|
|
287
|
+
.filter((imp) => imp.resolved && !imp.typeOnly)
|
|
288
|
+
.flatMap((imp) => importEdges(facts, imp, RELATION.IMPORT)),
|
|
289
|
+
// `import type … from "x"` — a TYPE dependency.
|
|
290
|
+
[RELATION.TYPE_IMPORT]: (facts) => (facts.imports ?? [])
|
|
291
|
+
.filter((imp) => imp.resolved && imp.typeOnly)
|
|
292
|
+
.flatMap((imp) => importEdges(facts, imp, RELATION.TYPE_IMPORT)),
|
|
293
|
+
// EVERY way code leaves the module, whatever the spelling.
|
|
294
|
+
[RELATION.EXPORT]: (facts) => [...exportFromEdges(facts), ...declaredExportEdges(facts)],
|
|
295
|
+
// EVERY declaration: `const`/`let`/`var`, `function`, `class`, and a
|
|
296
|
+
// re-declaration that only renames another module's value.
|
|
297
|
+
[RELATION.DECLARE]: (facts) => (facts.candidates ?? []).map((c) => declareEdge(facts, c)),
|
|
298
|
+
// Running another module's code.
|
|
299
|
+
[RELATION.CALL]: callsOf,
|
|
300
|
+
// Writing into a value this file does not own.
|
|
301
|
+
[RELATION.MUTATE]: (facts) => assignmentsOf(facts, { mutate: true }),
|
|
302
|
+
// Writing into the piece's own value.
|
|
303
|
+
[RELATION.ASSIGN]: (facts) => assignmentsOf(facts, { mutate: false }),
|
|
304
|
+
// Reading another module's value.
|
|
305
|
+
[RELATION.READ]: readsOf,
|
|
306
|
+
};
|
|
307
|
+
exports.EDGE_FACTS = EDGE_FACTS;
|
|
308
|
+
// Which entities declare an ACTION for each relation: `Map<factKind, Map<entitySlug,
|
|
309
|
+
// action>>`.
|
|
310
|
+
const declaredActions = (arch) => {
|
|
311
|
+
const byFact = new Map();
|
|
312
|
+
for (const [slug, def] of Object.entries(arch.entities ?? {})) {
|
|
313
|
+
for (const [key, action] of Object.entries(def.actions ?? {})) {
|
|
314
|
+
const factKind = action.of ?? key;
|
|
315
|
+
if (!byFact.has(factKind))
|
|
316
|
+
byFact.set(factKind, new Map());
|
|
317
|
+
byFact.get(factKind)?.set(slug, action);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return byFact;
|
|
321
|
+
};
|
|
322
|
+
exports.declaredActions = declaredActions;
|
|
323
|
+
// An entity may only say `of: <kind>` for a relation the engine can see, and every
|
|
324
|
+
// declared kind must have a producer. Checked at load, so a typo fails loudly.
|
|
325
|
+
for (const kind of FACT_KINDS) {
|
|
326
|
+
if (!EDGE_FACTS[kind])
|
|
327
|
+
throw configError.relationWithoutProducer({ relation: kind });
|
|
328
|
+
}
|
|
329
|
+
for (const kind of Object.keys(EDGE_FACTS)) {
|
|
330
|
+
if (!FACT_KINDS.includes(kind))
|
|
331
|
+
throw configError.undeclaredRelation({ relation: kind });
|
|
332
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Arch, EntityHome } from "@md-code/follow-architecture/entities/architecture";
|
|
2
|
+
declare const homesOf: (arch: Arch, entity: string) => EntityHome[];
|
|
3
|
+
type Destination = {
|
|
4
|
+
slug: string | null;
|
|
5
|
+
path: string | null;
|
|
6
|
+
folder: boolean;
|
|
7
|
+
template: string;
|
|
8
|
+
};
|
|
9
|
+
type Place = {
|
|
10
|
+
path: string;
|
|
11
|
+
concrete: boolean;
|
|
12
|
+
folder: boolean;
|
|
13
|
+
};
|
|
14
|
+
declare const sharedPrefix: (template: string, rel: string | null) => number;
|
|
15
|
+
declare const destinationsIn: (arch: Arch, entity: string, rel: string) => Destination[];
|
|
16
|
+
declare const destinationOf: (arch: Arch, entity: string, rel: string) => Destination | null;
|
|
17
|
+
declare const placeFor: (arch: Arch, entity: string, rel: string) => Place | null;
|
|
18
|
+
declare const entityFitsAt: (arch: Arch, entity: string, rel: string | null | undefined) => boolean;
|
|
19
|
+
declare const entitiesAtPath: (arch: Arch, path: string | null | undefined) => string[];
|
|
20
|
+
declare const homeForEntity: (arch: Arch, entity: string, rel: string) => {
|
|
21
|
+
entity: string;
|
|
22
|
+
path: string;
|
|
23
|
+
folder: boolean;
|
|
24
|
+
concrete: boolean;
|
|
25
|
+
node: string | null;
|
|
26
|
+
} | null;
|
|
27
|
+
export { homesOf, sharedPrefix, destinationsIn, destinationOf, placeFor, entityFitsAt, entitiesAtPath, homeForEntity };
|
|
28
|
+
export type { Destination, Place };
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.homeForEntity = exports.entitiesAtPath = exports.entityFitsAt = exports.placeFor = exports.destinationOf = exports.destinationsIn = exports.sharedPrefix = exports.homesOf = void 0;
|
|
4
|
+
// THE ENTITY → PLACE ANSWER. "Where does code of this entity live" is the SAME
|
|
5
|
+
// question as "what does this place entry resolve to", so this module owns both
|
|
6
|
+
// the declared homes and the concrete place-for-this-file answer.
|
|
7
|
+
//
|
|
8
|
+
// homesOf(arch, entity) — the path templates that entity may occupy
|
|
9
|
+
// placeFor(arch, entity, rel) — where this entity's code belongs FOR THIS FILE
|
|
10
|
+
// destinationOf(arch, entity, rel) — the concrete, hostable place, or null
|
|
11
|
+
//
|
|
12
|
+
// Nothing here is stored on the entity: an entity knows what code IS, never which
|
|
13
|
+
// folder it is in. Anything that needs a location asks the tree.
|
|
14
|
+
const match_1 = require("@md-code/follow-architecture/entities/tree/match");
|
|
15
|
+
const where_1 = require("./where");
|
|
16
|
+
const place_1 = require("./place");
|
|
17
|
+
const rank_1 = require("@md-code/follow-architecture/utils/rank");
|
|
18
|
+
// Every path the tree gives this entity, in the order the config declares them.
|
|
19
|
+
const homesOf = (arch, entity) => arch.nodes.entityHomes[entity] ?? [];
|
|
20
|
+
exports.homesOf = homesOf;
|
|
21
|
+
// How much of the template's start this file shares. Used only to pick which
|
|
22
|
+
// branch of a repeating node the file belongs to — never to allow or deny.
|
|
23
|
+
const sharedPrefix = (template, rel) => {
|
|
24
|
+
const ts = String(template).split("/");
|
|
25
|
+
const rs = String(rel ?? "").split("/");
|
|
26
|
+
let n = 0;
|
|
27
|
+
for (let i = 0; i < ts.length; i += 1) {
|
|
28
|
+
const seg = ts[i];
|
|
29
|
+
if (seg === "**" || /^\{[^}]+\}$/.test(seg)) {
|
|
30
|
+
n += 1;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (seg !== rs[i])
|
|
34
|
+
break;
|
|
35
|
+
n += 1;
|
|
36
|
+
}
|
|
37
|
+
return n;
|
|
38
|
+
};
|
|
39
|
+
exports.sharedPrefix = sharedPrefix;
|
|
40
|
+
// The directory a home names: a file child contributes its parent folder.
|
|
41
|
+
const homeDir = (template) => {
|
|
42
|
+
const segs = String(template)
|
|
43
|
+
.split("/")
|
|
44
|
+
.filter((s) => s !== "**");
|
|
45
|
+
return /\.[A-Za-z0-9]+$/.test(segs[segs.length - 1] ?? "") ? segs.slice(0, -1) : segs;
|
|
46
|
+
};
|
|
47
|
+
// The folder OF A FILE as segments.
|
|
48
|
+
const fileDir = (rel) => (0, place_1.dirOf)(rel).split("/").filter(Boolean);
|
|
49
|
+
const isPlaceholder = (seg) => /^\{[^}]+\}$/.test(seg);
|
|
50
|
+
// Is the file in the SAME BRANCH as this home? One directory is a prefix of the
|
|
51
|
+
// other. `{kebab-case}` matches any single segment, so a feature's instance
|
|
52
|
+
// always answers for its own files.
|
|
53
|
+
const sameBranch = (home, dir) => {
|
|
54
|
+
const [short, long] = home.length <= dir.length ? [home, dir] : [dir, home];
|
|
55
|
+
return short.every((seg, i) => isPlaceholder(seg) || isPlaceholder(long[i] ?? "") || seg === long[i]);
|
|
56
|
+
};
|
|
57
|
+
// Whether this home is in the file's branch. A home that names ONE FILE only
|
|
58
|
+
// answers for files of exactly that folder; a FOLDER home may sit in a general
|
|
59
|
+
// branch (`packages/utils`) that still applies.
|
|
60
|
+
const branchFor = (fileHome, home, dir) => fileHome ? home.length === dir.length && sameBranch(home, dir) : sameBranch(home, dir);
|
|
61
|
+
const scoreEntry = (entry, i, dir, rel) => {
|
|
62
|
+
const home = homeDir(entry.template);
|
|
63
|
+
const last = String(entry.template)
|
|
64
|
+
.split("/")
|
|
65
|
+
.filter((seg) => seg !== "**")
|
|
66
|
+
.pop() ?? "";
|
|
67
|
+
const fileHome = /\.[A-Za-z0-9]+$/.test(last);
|
|
68
|
+
const branch = branchFor(fileHome, home, dir);
|
|
69
|
+
return { entry, i, keep: branch || !fileHome, branch, score: sharedPrefix(entry.template, rel) };
|
|
70
|
+
};
|
|
71
|
+
// The concrete places an entity's code may go FOR THIS FILE, best first. The
|
|
72
|
+
// score-keep-rank walk is the shared `rankedOffers` core — the same one the
|
|
73
|
+
// folder lookalikes use; the scoring policy (branch, prefix, declared order)
|
|
74
|
+
// is this module's own.
|
|
75
|
+
const destinationsIn = (arch, entity, rel) => {
|
|
76
|
+
const entries = homesOf(arch, entity);
|
|
77
|
+
if (!entries.length)
|
|
78
|
+
return [];
|
|
79
|
+
// An entity with ONE declared place has no branch question to answer.
|
|
80
|
+
if (entries.length === 1 && !/\*\*\s*$/.test(entries[0].template)) {
|
|
81
|
+
return [
|
|
82
|
+
{
|
|
83
|
+
slug: entries[0].node,
|
|
84
|
+
path: (0, where_1.fillTemplate)(entries[0].template, rel),
|
|
85
|
+
folder: false,
|
|
86
|
+
template: entries[0].template,
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
const dir = fileDir(rel);
|
|
91
|
+
const destinationOfEntry = (entry) => ({
|
|
92
|
+
slug: entry.node,
|
|
93
|
+
path: (0, where_1.fillTemplate)(entry.template, rel),
|
|
94
|
+
folder: /\*\*\s*$/.test(entry.template),
|
|
95
|
+
template: entry.template,
|
|
96
|
+
});
|
|
97
|
+
const kept = (0, rank_1.rankedOffers)(entries.map((entry, i) => ({ entry, i })), ({ entry, i }) => {
|
|
98
|
+
const scored = scoreEntry(entry, i, dir, rel);
|
|
99
|
+
return scored.keep ? { ...destinationOfEntry(entry), branch: scored.branch, score: scored.score, i } : null;
|
|
100
|
+
}, (a, b) => Number(b.branch) - Number(a.branch) || b.score - a.score || a.i - b.i);
|
|
101
|
+
return kept.map(({ slug, path, folder, template }) => ({ slug, path, folder, template }));
|
|
102
|
+
};
|
|
103
|
+
exports.destinationsIn = destinationsIn;
|
|
104
|
+
// The place an entity's code belongs FOR THIS FILE, and only when that place can
|
|
105
|
+
// exist: the FOLDER has to be a real node instance, while a home that names a
|
|
106
|
+
// FILE may still be created — its parent being an instance is enough.
|
|
107
|
+
// Does the node that owns the folder own it for THIS destination (the node
|
|
108
|
+
// itself, or its declared parent)?
|
|
109
|
+
const ownsDest = (arch, hit, dest) => {
|
|
110
|
+
const parent = arch.nodes.bySlug[dest.slug ?? ""]?.parents[0] ?? null;
|
|
111
|
+
return hit.slug === dest.slug || (parent != null && hit.slug === parent);
|
|
112
|
+
};
|
|
113
|
+
const hostFolder = (dest) => (dest.folder ? (dest.path ?? "") : (0, place_1.dirOf)(dest.path ?? ""));
|
|
114
|
+
const nodeOk = (arch, dest) => {
|
|
115
|
+
const destNode = arch.nodes.bySlug[dest.slug ?? ""];
|
|
116
|
+
return !destNode || (0, match_1.ancestorsAreReal)(destNode, dest.path ?? "", arch);
|
|
117
|
+
};
|
|
118
|
+
const destinationOf = (arch, entity, rel) => {
|
|
119
|
+
for (const dest of destinationsIn(arch, entity, rel)) {
|
|
120
|
+
if (!dest?.slug || !dest.path)
|
|
121
|
+
continue;
|
|
122
|
+
if (!nodeOk(arch, dest))
|
|
123
|
+
continue;
|
|
124
|
+
const folder = hostFolder(dest);
|
|
125
|
+
const hit = (0, match_1.folderOwner)(arch, folder);
|
|
126
|
+
if (!hit || !(0, match_1.instanceAt)(arch, hit.slug, folder))
|
|
127
|
+
continue;
|
|
128
|
+
if (ownsDest(arch, hit, dest))
|
|
129
|
+
return dest;
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
};
|
|
133
|
+
exports.destinationOf = destinationOf;
|
|
134
|
+
// WHERE an entity's code belongs FOR THIS FILE — the ONE answer every caller uses.
|
|
135
|
+
const placeFor = (arch, entity, rel) => {
|
|
136
|
+
const dest = destinationOf(arch, entity, rel);
|
|
137
|
+
if (dest?.path)
|
|
138
|
+
return { path: dest.path, concrete: true, folder: Boolean(dest.folder) };
|
|
139
|
+
const homes = homesOf(arch, entity).map((h) => h.template);
|
|
140
|
+
// An entity with SEVERAL homes and none of them hostable here has no answer for
|
|
141
|
+
// this file: picking one would be a guess dressed as advice.
|
|
142
|
+
if (homes.length !== 1) {
|
|
143
|
+
const nearest = destinationsIn(arch, entity, rel)[0];
|
|
144
|
+
if (!nearest?.template)
|
|
145
|
+
return null;
|
|
146
|
+
const last = nearest.template
|
|
147
|
+
.split("/")
|
|
148
|
+
.filter((seg) => seg !== "**")
|
|
149
|
+
.pop() ?? "";
|
|
150
|
+
const folder = /\*\*\s*$/.test(nearest.template) || !/\.[A-Za-z0-9]+$/.test(last);
|
|
151
|
+
return { path: nearest.template.replace(/\/\*\*$/, ""), concrete: false, folder };
|
|
152
|
+
}
|
|
153
|
+
const only = homes[0];
|
|
154
|
+
if (!/[*{]/.test(only))
|
|
155
|
+
return { path: only, concrete: true, folder: false };
|
|
156
|
+
return { path: only.replace(/\/\*\*$/, ""), concrete: false, folder: true };
|
|
157
|
+
};
|
|
158
|
+
exports.placeFor = placeFor;
|
|
159
|
+
// Does this file sit inside one of the entity's homes, asked THROUGH the tree?
|
|
160
|
+
const entityFitsAt = (arch, entity, rel) => {
|
|
161
|
+
if (!rel)
|
|
162
|
+
return false;
|
|
163
|
+
return (arch.nodes.entityHomes[entity] ?? []).some((h) => (0, where_1.matchesWhere)({ type: "template", template: h.template }, rel, arch, null, null));
|
|
164
|
+
};
|
|
165
|
+
exports.entityFitsAt = entityFitsAt;
|
|
166
|
+
// The entities whose declared home covers this path — MOST SPECIFIC FIRST.
|
|
167
|
+
const entitiesAtPath = (arch, path) => {
|
|
168
|
+
if (!path)
|
|
169
|
+
return [];
|
|
170
|
+
return Object.keys(arch.nodes.entityHomes)
|
|
171
|
+
.filter((entity) => entityFitsAt(arch, entity, path))
|
|
172
|
+
.map((entity, i) => ({
|
|
173
|
+
entity,
|
|
174
|
+
i,
|
|
175
|
+
depth: Math.max(0, ...homesOf(arch, entity).map((h) => sharedPrefix(h.template, path))),
|
|
176
|
+
}))
|
|
177
|
+
.sort((a, b) => b.depth - a.depth || a.i - b.i)
|
|
178
|
+
.map((x) => x.entity);
|
|
179
|
+
};
|
|
180
|
+
exports.entitiesAtPath = entitiesAtPath;
|
|
181
|
+
// Where an entity's code belongs FOR THIS FILE, as the BOX and the PATH together.
|
|
182
|
+
const homeForEntity = (arch, entity, rel) => {
|
|
183
|
+
const place = placeFor(arch, entity, rel);
|
|
184
|
+
if (!place?.path)
|
|
185
|
+
return null;
|
|
186
|
+
const folder = place.folder ? place.path : (0, place_1.dirOf)(place.path);
|
|
187
|
+
return {
|
|
188
|
+
entity,
|
|
189
|
+
path: place.path,
|
|
190
|
+
folder: place.folder,
|
|
191
|
+
concrete: Boolean(place.concrete),
|
|
192
|
+
node: (0, match_1.folderOwner)(arch, folder)?.slug ?? null,
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
exports.homeForEntity = homeForEntity;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Leaf, Place } from "@md-code/follow-architecture/entities/facts";
|
|
2
|
+
declare const wordsIn: (name: string | null | undefined) => string[];
|
|
3
|
+
declare const nameOnly: (name: string | null | undefined) => string;
|
|
4
|
+
declare const segmentsOf: (rel: string | null | undefined) => string[];
|
|
5
|
+
declare const parentOf: (rel: string | null | undefined) => string;
|
|
6
|
+
declare const leafOf: (rel: string | null | undefined) => Leaf;
|
|
7
|
+
declare const placeOf: (rel: string | null | undefined, repoFiles?: string[] | null | undefined) => Place;
|
|
8
|
+
declare const placeholdersOf: (template: string | null | undefined) => string;
|
|
9
|
+
declare const dirOf: (path: string | null | undefined) => string;
|
|
10
|
+
export { wordsIn, nameOnly, segmentsOf, parentOf, leafOf, placeOf, placeholdersOf, dirOf };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dirOf = exports.placeholdersOf = exports.placeOf = exports.leafOf = exports.parentOf = exports.segmentsOf = exports.nameOnly = exports.wordsIn = void 0;
|
|
4
|
+
const split_1 = require("@md-code/follow-architecture/utils/split");
|
|
5
|
+
const wordsIn = (name) => String(name ?? "")
|
|
6
|
+
// camelCase and ALLCAPS runs: `fileName` → file name, `HTMLParser` → HTML Parser
|
|
7
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
8
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2")
|
|
9
|
+
.split(/[^A-Za-z0-9]+/)
|
|
10
|
+
.map((w) => w.toLowerCase())
|
|
11
|
+
.filter(Boolean);
|
|
12
|
+
exports.wordsIn = wordsIn;
|
|
13
|
+
// The name without ANY extension: `x.spec.ts` → `x`. A leading dot is part of
|
|
14
|
+
// the name (`.env` has no extension, it IS a name).
|
|
15
|
+
const nameOnly = (name) => {
|
|
16
|
+
const n = String(name ?? "");
|
|
17
|
+
const dot = n.indexOf(".", n.startsWith(".") ? 1 : 0);
|
|
18
|
+
return dot > 0 ? n.slice(0, dot) : n;
|
|
19
|
+
};
|
|
20
|
+
exports.nameOnly = nameOnly;
|
|
21
|
+
// ONE PATH → its segments. The split is the shared `partsOf` core; a path drops
|
|
22
|
+
// the empty segments a leading/trailing `/` would leave.
|
|
23
|
+
const segmentsOf = (rel) => (0, split_1.partsOf)(rel, "/").all.filter(Boolean);
|
|
24
|
+
exports.segmentsOf = segmentsOf;
|
|
25
|
+
// The PARENT of any path: one segment up. The root has none — `""`.
|
|
26
|
+
const parentOf = (rel) => segmentsOf(rel).slice(0, -1).join("/");
|
|
27
|
+
exports.parentOf = parentOf;
|
|
28
|
+
// ONE PATH → the names it is made of. No folder, no neighbours.
|
|
29
|
+
const leafOf = (rel) => {
|
|
30
|
+
const path = String(rel ?? "");
|
|
31
|
+
const segments = segmentsOf(path);
|
|
32
|
+
const name = segments[segments.length - 1] ?? "";
|
|
33
|
+
const fileName = nameOnly(name);
|
|
34
|
+
// `x.spec.ts` → [".spec", ".ts"]; `.env` is a name, not an extension.
|
|
35
|
+
const exts = fileName === name
|
|
36
|
+
? []
|
|
37
|
+
: name
|
|
38
|
+
.slice(fileName.length)
|
|
39
|
+
.split(".")
|
|
40
|
+
.filter(Boolean)
|
|
41
|
+
.map((e) => `.${e}`);
|
|
42
|
+
return { path, segments, exts, fileName, words: wordsIn(fileName) };
|
|
43
|
+
};
|
|
44
|
+
exports.leafOf = leafOf;
|
|
45
|
+
// The place of a file: its own names, plus the folder it sits in.
|
|
46
|
+
const placeOf = (rel, repoFiles = []) => {
|
|
47
|
+
const leaf = leafOf(rel);
|
|
48
|
+
const dir = parentOf(leaf.path);
|
|
49
|
+
const files = [...new Set((repoFiles ?? []).filter((p) => parentOf(p) === dir))].sort().map(leafOf);
|
|
50
|
+
return { ...leaf, files, siblings: files.filter((f) => f.path !== leaf.path) };
|
|
51
|
+
};
|
|
52
|
+
exports.placeOf = placeOf;
|
|
53
|
+
// The placeholders a template still has (`{kebab-case}`), for a sentence that
|
|
54
|
+
// tells the reader what to fill in.
|
|
55
|
+
const placeholdersOf = (template) => [...new Set(String(template ?? "").match(/\{[^}]+\}/g) ?? [])].map((p) => `\`${p}\``).join(", ") ||
|
|
56
|
+
"its placeholders";
|
|
57
|
+
exports.placeholdersOf = placeholdersOf;
|
|
58
|
+
// The folder of a path: a file contributes its parent, a folder is itself.
|
|
59
|
+
const dirOf = (path) => {
|
|
60
|
+
const p = String(path ?? "");
|
|
61
|
+
return /\.[A-Za-z0-9]+$/.test(p) ? parentOf(p) : p;
|
|
62
|
+
};
|
|
63
|
+
exports.dirOf = dirOf;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Aliases } from "@md-code/follow-architecture/utils/aliases";
|
|
2
|
+
import { toList, type FieldValue } from "@md-code/follow-architecture/utils/field";
|
|
3
|
+
import type { Arch, WhereEntry } from "@md-code/follow-architecture/entities/architecture";
|
|
4
|
+
import type { FileFacts } from "@md-code/follow-architecture/entities/facts";
|
|
5
|
+
type Caps = Record<string, string | undefined>;
|
|
6
|
+
declare const parseWhereEntry: (entry: FieldValue, entities?: Set<string> | null, aliases?: Aliases | null) => WhereEntry;
|
|
7
|
+
declare const parseWhere: (value: FieldValue | null | undefined, entities?: Set<string> | null, aliases?: Aliases | null) => WhereEntry[];
|
|
8
|
+
declare const matchesWhere: (...args: [entry: WhereEntry | null | undefined, rel: string, arch: Arch, facts: FileFacts | null | undefined, targetCaps?: Caps | null]) => boolean;
|
|
9
|
+
declare const checkWhere: (...args: [entries: WhereEntry[] | null | undefined, rel: string, arch: Arch, facts: FileFacts | null | undefined, targetCaps?: Caps | null]) => boolean;
|
|
10
|
+
declare const accessorLabel: (e: {
|
|
11
|
+
scope?: string | null;
|
|
12
|
+
segments?: string[] | null;
|
|
13
|
+
type?: string | null;
|
|
14
|
+
} | null | undefined) => string;
|
|
15
|
+
declare const labelOf: (entry: WhereEntry | null | undefined) => string;
|
|
16
|
+
declare const fillTemplate: (template: string | null | undefined, rel?: string | null, caps?: Caps | null) => string | null;
|
|
17
|
+
declare const entryKey: (entry: WhereEntry, rel: string, arch: Arch, facts: FileFacts | null | undefined) => string | null;
|
|
18
|
+
export { toList, parseWhereEntry, parseWhere, matchesWhere, checkWhere, accessorLabel, labelOf, fillTemplate, entryKey, };
|
|
19
|
+
export type { Caps };
|