@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,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.article = exports.pluralize = exports.relationMessage = exports.whyText = exports.subjectText = exports.factText = void 0;
|
|
4
|
+
// Facts → words: a relation fact becomes a phrase, a subject and a reason.
|
|
5
|
+
// The fact is the engine's own (`entities/kinds` producers); the words here are
|
|
6
|
+
// the ONE spelling the text and the picture read. Every field is read through
|
|
7
|
+
// the shared field readers — a fact is plain data, never an `any`.
|
|
8
|
+
const kinds_1 = require("@md-code/follow-architecture/entities/kinds");
|
|
9
|
+
const field_1 = require("@md-code/follow-architecture/utils/field");
|
|
10
|
+
const read_field_1 = require("@md-code/follow-architecture/utils/read-field");
|
|
11
|
+
const article_1 = require("@md-code/follow-architecture/utils/article");
|
|
12
|
+
Object.defineProperty(exports, "article", { enumerable: true, get: function () { return article_1.article; } });
|
|
13
|
+
const q = (s) => (s == null ? "—" : `\`${s}\``);
|
|
14
|
+
const list = (xs) => xs.map(q).join(", ");
|
|
15
|
+
// A sentence about SEVERAL pieces takes the plural: "`a`, `b` change …".
|
|
16
|
+
const PLURALS = {
|
|
17
|
+
"changes ": "change ",
|
|
18
|
+
"writes into ": "write into ",
|
|
19
|
+
"calls ": "call ",
|
|
20
|
+
"imports ": "import ",
|
|
21
|
+
"exports ": "export ",
|
|
22
|
+
"re-exports ": "re-export ",
|
|
23
|
+
"re-declares ": "re-declare ",
|
|
24
|
+
"names a type of ": "name a type of ",
|
|
25
|
+
"reads ": "read ",
|
|
26
|
+
"is exported": "are exported",
|
|
27
|
+
"is declared here": "are declared here",
|
|
28
|
+
};
|
|
29
|
+
const pluralize = (text) => {
|
|
30
|
+
for (const [one, many] of Object.entries(PLURALS)) {
|
|
31
|
+
if (text.startsWith(one))
|
|
32
|
+
return many + text.slice(one.length);
|
|
33
|
+
}
|
|
34
|
+
return text;
|
|
35
|
+
};
|
|
36
|
+
exports.pluralize = pluralize;
|
|
37
|
+
// The export forms that read as a re-export of a whole module / a default.
|
|
38
|
+
const exportFormText = (fact) => {
|
|
39
|
+
const form = (0, read_field_1.stringField)(fact, "form");
|
|
40
|
+
if (form === "namespace")
|
|
41
|
+
return `re-exports ${q((0, field_1.fieldOf)(fact, "source"))} as ${q((0, read_field_1.stringListField)(fact, "names")[0] ?? (0, field_1.fieldOf)(fact, "name"))}`;
|
|
42
|
+
if (form === "star")
|
|
43
|
+
return `re-exports ${q((0, field_1.fieldOf)(fact, "source"))}`;
|
|
44
|
+
if (form === "default")
|
|
45
|
+
return "is exported as its default";
|
|
46
|
+
if (form === "equals")
|
|
47
|
+
return "is exported with `export =`";
|
|
48
|
+
if (form === "declared")
|
|
49
|
+
return "is exported";
|
|
50
|
+
return null;
|
|
51
|
+
};
|
|
52
|
+
const exportText = (fact) => {
|
|
53
|
+
const form = exportFormText(fact);
|
|
54
|
+
if (form)
|
|
55
|
+
return form;
|
|
56
|
+
const names = (0, read_field_1.stringListField)(fact, "names");
|
|
57
|
+
if ((0, read_field_1.booleanField)(fact, "reExport")) {
|
|
58
|
+
const from = (0, field_1.fieldOf)(fact, "resolved") ?? (0, field_1.fieldOf)(fact, "source");
|
|
59
|
+
const what = names.length ? `re-exports ${list(names)}` : "re-exports its whole module";
|
|
60
|
+
return from ? `${what} from ${q(from)}` : what;
|
|
61
|
+
}
|
|
62
|
+
if (names.length)
|
|
63
|
+
return `exports ${list(names)}`;
|
|
64
|
+
const name = (0, field_1.fieldOf)(fact, "name");
|
|
65
|
+
if (name)
|
|
66
|
+
return `exports ${q(name)} through CommonJS`;
|
|
67
|
+
return "is exported through CommonJS";
|
|
68
|
+
};
|
|
69
|
+
// WHAT a call was given: the values that made it illegal. A built `.d.ts` names
|
|
70
|
+
// a shape, not a value with an owner, so it is left out.
|
|
71
|
+
const callGiven = (fact) => {
|
|
72
|
+
const given = (0, read_field_1.recordListField)(fact, "with")
|
|
73
|
+
.filter((w) => {
|
|
74
|
+
const type = (0, read_field_1.stringField)(w, "type");
|
|
75
|
+
return Boolean(type) && !type.endsWith(".d.ts");
|
|
76
|
+
})
|
|
77
|
+
.map((w) => `${q((0, field_1.fieldOf)(w, "text"))} of ${q((0, field_1.fieldOf)(w, "type"))}`);
|
|
78
|
+
return given.length ? ` with ${given.join(", ")}` : "";
|
|
79
|
+
};
|
|
80
|
+
const callText = (fact) => `calls ${q((0, field_1.fieldOf)(fact, "action"))} of ${q((0, field_1.fieldOf)(fact, "module"))}${callGiven(fact)}`;
|
|
81
|
+
const mutateText = (fact) => {
|
|
82
|
+
if ((0, read_field_1.booleanField)(fact, "onThis"))
|
|
83
|
+
return `changes ${q((0, field_1.fieldOf)(fact, "target"))} of its own file`;
|
|
84
|
+
const ownerEntity = (0, field_1.fieldOf)(fact, "ownerEntity");
|
|
85
|
+
if (ownerEntity)
|
|
86
|
+
return `changes ${q((0, field_1.fieldOf)(fact, "target"))} of the ${q(ownerEntity)} (${q((0, field_1.fieldOf)(fact, "module"))})`;
|
|
87
|
+
return `changes ${q((0, field_1.fieldOf)(fact, "target"))} of ${q((0, field_1.fieldOf)(fact, "module"))}`;
|
|
88
|
+
};
|
|
89
|
+
const declareText = (fact) => {
|
|
90
|
+
const renames = (0, read_field_1.recordField)(fact, "renames");
|
|
91
|
+
if (renames)
|
|
92
|
+
return `re-declares ${q((0, field_1.fieldOf)(renames, "action"))} of ${q((0, field_1.fieldOf)(renames, "module"))}`;
|
|
93
|
+
return "is declared here";
|
|
94
|
+
};
|
|
95
|
+
// A named import names the SYMBOLS it takes (and the file that declares them):
|
|
96
|
+
// `imports `codeEditor` of `packages/styles/themes/editor.ts``. A module-level
|
|
97
|
+
// import keeps its one-word form.
|
|
98
|
+
const importText = (fact) => {
|
|
99
|
+
if ((0, read_field_1.stringField)(fact, "form") !== "statement")
|
|
100
|
+
return `requires ${q((0, field_1.fieldOf)(fact, "source"))}`;
|
|
101
|
+
const names = (0, field_1.fieldOf)(fact, "names");
|
|
102
|
+
const symbols = Array.isArray(names) ? names.filter((name) => typeof name === "string") : [];
|
|
103
|
+
return symbols.length
|
|
104
|
+
? `imports ${list(symbols)} of ${q((0, field_1.fieldOf)(fact, "resolved"))}`
|
|
105
|
+
: `imports ${q((0, field_1.fieldOf)(fact, "resolved"))}`;
|
|
106
|
+
};
|
|
107
|
+
const assignText = (fact) => {
|
|
108
|
+
const method = (0, field_1.fieldOf)(fact, "method");
|
|
109
|
+
return `writes into ${q((0, field_1.fieldOf)(fact, "target"))}${method ? ` through ${q(`${method}()`)}` : ""}`;
|
|
110
|
+
};
|
|
111
|
+
const readText = (fact) => {
|
|
112
|
+
const module = (0, field_1.fieldOf)(fact, "module");
|
|
113
|
+
return `reads ${q((0, field_1.fieldOf)(fact, "what"))}${module ? ` of ${q(module)}` : ""}`;
|
|
114
|
+
};
|
|
115
|
+
const factText = (fact) => {
|
|
116
|
+
if (!(0, field_1.isObj)(fact))
|
|
117
|
+
return "does something the architecture does not describe";
|
|
118
|
+
const kind = (0, read_field_1.stringField)(fact, "kind");
|
|
119
|
+
if (kind === kinds_1.RELATION.IMPORT)
|
|
120
|
+
return importText(fact);
|
|
121
|
+
if (kind === kinds_1.RELATION.TYPE_IMPORT)
|
|
122
|
+
return `names a type of ${q((0, field_1.fieldOf)(fact, "resolved"))}`;
|
|
123
|
+
if (kind === kinds_1.RELATION.EXPORT)
|
|
124
|
+
return exportText(fact);
|
|
125
|
+
if (kind === kinds_1.RELATION.DECLARE)
|
|
126
|
+
return declareText(fact);
|
|
127
|
+
if (kind === kinds_1.RELATION.CALL)
|
|
128
|
+
return callText(fact);
|
|
129
|
+
if (kind === kinds_1.RELATION.MUTATE)
|
|
130
|
+
return mutateText(fact);
|
|
131
|
+
if (kind === kinds_1.RELATION.ASSIGN)
|
|
132
|
+
return assignText(fact);
|
|
133
|
+
if (kind === kinds_1.RELATION.READ)
|
|
134
|
+
return readText(fact);
|
|
135
|
+
return `does a \`${kind}\` the architecture does not describe`;
|
|
136
|
+
};
|
|
137
|
+
exports.factText = factText;
|
|
138
|
+
const entitiesSuffix = (entities) => {
|
|
139
|
+
if (!entities.length)
|
|
140
|
+
return "";
|
|
141
|
+
return entities.length === 1 ? ` (${entities[0]})` : ` (${entities.join(" / ")})`;
|
|
142
|
+
};
|
|
143
|
+
const subjectText = (subject, file) => {
|
|
144
|
+
const entityNames = (0, read_field_1.stringListField)(subject, "entities").filter(Boolean);
|
|
145
|
+
const entities = entityNames.map(q);
|
|
146
|
+
const entitiesPart = entitiesSuffix(entities);
|
|
147
|
+
if (!(0, field_1.isObj)(subject) || (0, read_field_1.booleanField)(subject, "scope")) {
|
|
148
|
+
return `the module scope of ${q(file)}${entitiesPart}`;
|
|
149
|
+
}
|
|
150
|
+
const pieces = (0, read_field_1.stringListField)(subject, "pieces").filter(Boolean).map(q);
|
|
151
|
+
if (!pieces.length)
|
|
152
|
+
return `the module scope of ${q(file)}${entitiesPart}`;
|
|
153
|
+
const who = entityNames.length === 1 ? ` (${(0, article_1.article)(entityNames[0])} ${q(entityNames[0])})` : entitiesPart;
|
|
154
|
+
return `${pieces.join(", ")}${who || " (which no entity describes)"}`;
|
|
155
|
+
};
|
|
156
|
+
exports.subjectText = subjectText;
|
|
157
|
+
// WHY it is refused — a code from the engine, not a sentence.
|
|
158
|
+
const whyText = (why) => {
|
|
159
|
+
if (!(0, field_1.isObj)(why))
|
|
160
|
+
return "it is not allowed";
|
|
161
|
+
if ((0, read_field_1.stringField)(why, "code") === "silent")
|
|
162
|
+
return "nothing in the architecture allows it";
|
|
163
|
+
const same = new Set((0, read_field_1.stringListField)(why, "sameEntities"));
|
|
164
|
+
// An entity the rule limits to the SAME feature instance says so: without the
|
|
165
|
+
// limit the sentence reads as "this entity may not do it at all", which is the
|
|
166
|
+
// opposite of what the architecture declares.
|
|
167
|
+
const entities = (0, read_field_1.stringListField)(why, "entities")
|
|
168
|
+
.filter(Boolean)
|
|
169
|
+
.map((r) => (same.has(r) ? `${q(r)} in the same feature` : q(r)));
|
|
170
|
+
// The entity DOES allow the call — what it refuses is the value handed over.
|
|
171
|
+
if ((0, read_field_1.booleanField)(why, "outward"))
|
|
172
|
+
return "that value may not be handed to it";
|
|
173
|
+
if (!entities.length)
|
|
174
|
+
return (0, read_field_1.stringField)(why, "code") === "nobody" ? "no code may do it" : "it is not allowed";
|
|
175
|
+
if ((0, read_field_1.booleanField)(why, "self"))
|
|
176
|
+
return `only ${entities.join(", ")} may do it`;
|
|
177
|
+
return `only ${entities.join(", ")} may do it with ${q((0, field_1.fieldOf)(why, "targetNode"))} code`;
|
|
178
|
+
};
|
|
179
|
+
exports.whyText = whyText;
|
|
180
|
+
// The one sentence a refused relation gets.
|
|
181
|
+
const relationMessage = (token, ctx = {}) => {
|
|
182
|
+
const subject = (0, field_1.fieldOf)(token, "subject");
|
|
183
|
+
const what = factText((0, field_1.fieldOf)(token, "fact"));
|
|
184
|
+
const plural = (0, field_1.isObj)(subject) && (0, read_field_1.booleanField)(subject, "plural");
|
|
185
|
+
return `${subjectText(subject, ctx.file ?? "")} ${plural ? pluralize(what) : what}, but ${whyText((0, field_1.fieldOf)(token, "why"))}`;
|
|
186
|
+
};
|
|
187
|
+
exports.relationMessage = relationMessage;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Arch } from "@md-code/follow-architecture/entities/architecture";
|
|
2
|
+
import type { NodeSummary } from "@md-code/follow-architecture/entities/overview/summaries";
|
|
3
|
+
import type { Places } from "@md-code/follow-architecture/entities/overview/decision";
|
|
4
|
+
declare const make: ({ nodes, arch }: {
|
|
5
|
+
nodes: NodeSummary[];
|
|
6
|
+
arch: Arch;
|
|
7
|
+
}) => Places;
|
|
8
|
+
export { make };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.make = void 0;
|
|
4
|
+
// Engine names → report names: entity → box, place → node.
|
|
5
|
+
// ONE source for every place question. `homeFor`, `nodeAtPath`, `homeTemplates`
|
|
6
|
+
// and `pathOf` used to be spelled again here, in a second wording, next to the
|
|
7
|
+
// real ones in `entities/location.js` — the report and the engine then disagreed
|
|
8
|
+
// about where an entity lives. This file only NAMES things now.
|
|
9
|
+
const location_1 = require("@md-code/follow-architecture/entities/location");
|
|
10
|
+
const make = ({ nodes, arch }) => {
|
|
11
|
+
const folderOf = (slug) => {
|
|
12
|
+
if (!slug)
|
|
13
|
+
return null;
|
|
14
|
+
if (nodes.some((n) => n.slug === slug))
|
|
15
|
+
return slug;
|
|
16
|
+
return (0, location_1.homesOf)(arch, slug)[0]?.node ?? null;
|
|
17
|
+
};
|
|
18
|
+
// A node slug as the path a human recognises.
|
|
19
|
+
const pathOf = (slug) => nodes.find((n) => n.slug === slug)?.paths?.[0] ?? slug;
|
|
20
|
+
// EVERY entity that declares a place — the set a destination decision chooses
|
|
21
|
+
// from: everything the tree says could be here.
|
|
22
|
+
const entities = () => Object.keys(arch.nodes.entityHomes);
|
|
23
|
+
// Entities whose declared home covers this path, most specific first: what this
|
|
24
|
+
// file already IS, according to the tree.
|
|
25
|
+
const entitiesAtPath = (rel) => (0, location_1.entitiesAtPath)(arch, rel);
|
|
26
|
+
// The path templates an entity declares (`…/constants.ts`, `…/actions/**`).
|
|
27
|
+
const homeTemplates = (entity) => (0, location_1.homesOf)(arch, entity).map((h) => h.template);
|
|
28
|
+
// Where this entity's code belongs FOR THIS FILE, and the box that hosts it —
|
|
29
|
+
// the engine's own answer, never a folder invented here.
|
|
30
|
+
const homeFor = (entity, rel) => (0, location_1.homeForEntity)(arch, entity, rel);
|
|
31
|
+
// The box that HOLDS a path — `apps/backend/document/store.ts` → the node that
|
|
32
|
+
// owns `apps/backend/document`.
|
|
33
|
+
const nodeAtPath = (path) => (0, location_1.boxOfPlace)(arch, path);
|
|
34
|
+
return { folderOf, pathOf, entities, entitiesAtPath, homeTemplates, homeFor, nodeAtPath };
|
|
35
|
+
};
|
|
36
|
+
exports.make = make;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare const VERBS: Record<string, string>;
|
|
2
|
+
declare const NOUNS: Record<string, string>;
|
|
3
|
+
declare const BASES: Record<string, string>;
|
|
4
|
+
declare const verbOf: (kind: string) => string;
|
|
5
|
+
declare const nounOf: (kind: string) => string;
|
|
6
|
+
declare const baseVerbOf: (kind: string) => string;
|
|
7
|
+
export { VERBS, NOUNS, BASES, verbOf, nounOf, baseVerbOf };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.baseVerbOf = exports.nounOf = exports.verbOf = exports.BASES = exports.NOUNS = exports.VERBS = void 0;
|
|
4
|
+
// The words a relation is said with — third person, noun, and base form — as
|
|
5
|
+
// ONE table keyed by relation, so the three views below can never drift apart.
|
|
6
|
+
// A new relation is added once, here. The columns are DERIVED from the table,
|
|
7
|
+
// so a column and the table can never disagree.
|
|
8
|
+
const WORD = {
|
|
9
|
+
import: { verb: "imports", noun: "import", base: "import" },
|
|
10
|
+
typeImport: { verb: "names a type of", noun: "type import", base: "name a type of" },
|
|
11
|
+
export: { verb: "exports", noun: "export", base: "export" },
|
|
12
|
+
declare: { verb: "declares a name from", noun: "declaration", base: "declare a name from" },
|
|
13
|
+
call: { verb: "calls", noun: "call", base: "call" },
|
|
14
|
+
mutate: { verb: "changes", noun: "mutation", base: "change" },
|
|
15
|
+
assign: { verb: "writes into", noun: "assignment", base: "write into" },
|
|
16
|
+
read: { verb: "reads", noun: "read", base: "read" },
|
|
17
|
+
};
|
|
18
|
+
const column = (field) => Object.fromEntries(Object.entries(WORD).map(([kind, words]) => [kind, words[field]]));
|
|
19
|
+
const VERBS = column("verb");
|
|
20
|
+
exports.VERBS = VERBS;
|
|
21
|
+
const NOUNS = column("noun");
|
|
22
|
+
exports.NOUNS = NOUNS;
|
|
23
|
+
const BASES = column("base");
|
|
24
|
+
exports.BASES = BASES;
|
|
25
|
+
const verbOf = (kind) => VERBS[kind] ?? `uses (${kind})`;
|
|
26
|
+
exports.verbOf = verbOf;
|
|
27
|
+
const nounOf = (kind) => NOUNS[kind] ?? `use (${kind})`;
|
|
28
|
+
exports.nounOf = nounOf;
|
|
29
|
+
const baseVerbOf = (kind) => BASES[kind] ?? `use (${kind})`;
|
|
30
|
+
exports.baseVerbOf = baseVerbOf;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { substitute, type TemplateVars } from "@md-code/follow-architecture/utils/template";
|
|
2
|
+
import type { FindingFrom } from "@md-code/follow-architecture/entities/findings";
|
|
3
|
+
import type { ReportObject } from "@md-code/follow-architecture/entities/architecture";
|
|
4
|
+
declare const renderSpec: (spec: ReportObject | string, vars: TemplateVars) => {
|
|
5
|
+
message: string | null;
|
|
6
|
+
fix: string | null;
|
|
7
|
+
};
|
|
8
|
+
declare const findingFrom: FindingFrom;
|
|
9
|
+
export { findingFrom, renderSpec, substitute };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.substitute = exports.renderSpec = exports.findingFrom = void 0;
|
|
4
|
+
// ONE finding, built from what a checker states. A producer states the repair
|
|
5
|
+
// structurally (`to` boxes, `path`, `ask`) and `findingFrom` carries it as
|
|
6
|
+
// `data.repair` — the SAME object the CLI prints and the picture draws. A
|
|
7
|
+
// producer that only wrote a sentence still ends up with a repair (`rules` with
|
|
8
|
+
// no destination), so downstream never has to guess what a sentence meant.
|
|
9
|
+
//
|
|
10
|
+
// The report spec is the engine's own (`ReportObject`); the substitution is the
|
|
11
|
+
// shared template walk; the repair shape is the ONE contract in entities/repair.
|
|
12
|
+
const asks_1 = require("./asks");
|
|
13
|
+
const template_1 = require("@md-code/follow-architecture/utils/template");
|
|
14
|
+
Object.defineProperty(exports, "substitute", { enumerable: true, get: function () { return template_1.substitute; } });
|
|
15
|
+
const field_1 = require("@md-code/follow-architecture/utils/field");
|
|
16
|
+
const read_field_1 = require("@md-code/follow-architecture/utils/read-field");
|
|
17
|
+
const resolve_1 = require("@md-code/follow-architecture/utils/resolve");
|
|
18
|
+
// The fix text a spec states: a bare string, or the structured `{ message }`.
|
|
19
|
+
const fixTextOf = (spec) => {
|
|
20
|
+
const fix = spec.fix;
|
|
21
|
+
if (typeof fix === "string")
|
|
22
|
+
return fix;
|
|
23
|
+
return (0, field_1.isObj)(fix) ? (0, read_field_1.stringField)(fix, "message") || null : null;
|
|
24
|
+
};
|
|
25
|
+
const renderSpec = (spec, vars) => {
|
|
26
|
+
if (typeof spec === "string")
|
|
27
|
+
return { message: (0, template_1.substitute)(spec, vars), fix: null };
|
|
28
|
+
const message = spec.description ?? spec.message ?? null;
|
|
29
|
+
const fixText = fixTextOf(spec);
|
|
30
|
+
return {
|
|
31
|
+
message: message != null ? (0, template_1.substitute)(message, vars) : null,
|
|
32
|
+
fix: fixText != null ? (0, template_1.substitute)(fixText, vars) : null,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.renderSpec = renderSpec;
|
|
36
|
+
// The spec a finding item carries: an explicit `report`, or the legacy flat
|
|
37
|
+
// `message`/`fix` spelling on the item itself.
|
|
38
|
+
const specOf = (item) => {
|
|
39
|
+
if (item.report != null)
|
|
40
|
+
return item.report;
|
|
41
|
+
const message = item.message ?? "";
|
|
42
|
+
const fix = item.fix ?? "";
|
|
43
|
+
// The legacy flat spelling carries the WHOLE item as the spec — its `ask`,
|
|
44
|
+
// `to`, `from`, `path` are the repair the producer stated, not only words.
|
|
45
|
+
if (message || fix)
|
|
46
|
+
return { ...item, message: message || null, fix: fix || null };
|
|
47
|
+
return null;
|
|
48
|
+
};
|
|
49
|
+
// The place a spec names: `place` (already resolved) or `path`, never parsed
|
|
50
|
+
// out of the sentence. A string spec names no place.
|
|
51
|
+
const placeOf = (spec) => (0, resolve_1.resolveReference)(spec, (s) => (typeof s === "string" ? null : s), (s) => s.place ?? s.path ?? null);
|
|
52
|
+
// The finding's identity and subject: what it is about, and which entity.
|
|
53
|
+
const subjectOf = (item, key, vars) => ({
|
|
54
|
+
what: (0, read_field_1.stringField)(vars, "what") || null,
|
|
55
|
+
entity: /^entity:([^:]+)/.exec(key)?.[1] ?? item.entity ?? null,
|
|
56
|
+
});
|
|
57
|
+
// The message and fix sentences a finding carries: the rendered spec's, or the
|
|
58
|
+
// run's own vars, or the fallback.
|
|
59
|
+
const scopeOf = (vars, place) => place ? { ...vars, destination: place } : vars;
|
|
60
|
+
const sentencesOf = (item, vars) => {
|
|
61
|
+
const spec = specOf(item);
|
|
62
|
+
const place = placeOf(spec);
|
|
63
|
+
const rep = spec != null ? renderSpec(spec, scopeOf(vars, place)) : null;
|
|
64
|
+
return {
|
|
65
|
+
message: rep?.message ?? ((0, read_field_1.stringField)(vars, "message") || "architecture violation"),
|
|
66
|
+
fix: rep?.fix ?? ((0, read_field_1.stringField)(vars, "fix") || null),
|
|
67
|
+
place,
|
|
68
|
+
spec: spec != null && typeof spec !== "string" ? spec : null,
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
// The evidence bag with the stated repair attached — the SAME object the CLI
|
|
72
|
+
// prints and the picture draws.
|
|
73
|
+
const dataOf = (item, spec, fix, place) => {
|
|
74
|
+
const stated = spec != null
|
|
75
|
+
? (0, asks_1.repair)({ code: spec.code ?? spec.ask, fix }, { to: spec.to ?? [], from: spec.from ?? null, path: place })
|
|
76
|
+
: null;
|
|
77
|
+
const evidence = (0, field_1.isObj)(item.data) ? item.data : null;
|
|
78
|
+
return stated ? { ...(evidence ?? {}), repair: { ...stated, text: fix } } : evidence;
|
|
79
|
+
};
|
|
80
|
+
// The span a matched fact named (set by the report-vars walk), so the browser can
|
|
81
|
+
// highlight the exact offending text in the sentence. Absent when none was named.
|
|
82
|
+
const highlightOf = (vars) => {
|
|
83
|
+
const text = (0, read_field_1.stringField)(vars, "highlightText");
|
|
84
|
+
const start = (0, read_field_1.numberField)(vars, "spanStart", -1);
|
|
85
|
+
const end = (0, read_field_1.numberField)(vars, "spanEnd", -1);
|
|
86
|
+
if (!text || start < 0 || end < start)
|
|
87
|
+
return null;
|
|
88
|
+
return { text, start, end, kind: (0, read_field_1.stringField)(vars, "highlightKind") || "problem" };
|
|
89
|
+
};
|
|
90
|
+
const findingFrom = (...args) => {
|
|
91
|
+
const [item, rule, node, key, vars] = args;
|
|
92
|
+
const { message, fix, place, spec } = sentencesOf(item, vars);
|
|
93
|
+
const highlight = highlightOf(vars);
|
|
94
|
+
return {
|
|
95
|
+
file: (0, read_field_1.stringField)(vars, "path") || node,
|
|
96
|
+
node,
|
|
97
|
+
rule,
|
|
98
|
+
key: item.key ?? key,
|
|
99
|
+
dedupeKey: key,
|
|
100
|
+
data: dataOf(item, spec, fix, place),
|
|
101
|
+
...subjectOf(item, key, vars),
|
|
102
|
+
message,
|
|
103
|
+
fix,
|
|
104
|
+
pos: { line: item.line ?? 1, column: 1 },
|
|
105
|
+
...(highlight ? { highlight } : {}),
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
exports.findingFrom = findingFrom;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const notice: (subject: string, reason: string) => string;
|
|
2
|
+
declare const beginNotices: () => {
|
|
3
|
+
lines: string[];
|
|
4
|
+
end: () => string[];
|
|
5
|
+
};
|
|
6
|
+
declare const replayNotices: (lines: readonly string[] | null | undefined) => void;
|
|
7
|
+
declare const takeNotices: () => string[];
|
|
8
|
+
declare const resetNotices: () => void;
|
|
9
|
+
export { notice, beginNotices, replayNotices, takeNotices, resetNotices };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetNotices = exports.takeNotices = exports.replayNotices = exports.beginNotices = exports.notice = void 0;
|
|
4
|
+
const sink = () => ({ lines: [], seen: new Set() });
|
|
5
|
+
const run = sink();
|
|
6
|
+
// The sink of the file being read, when a reading owns one; `null` means a line
|
|
7
|
+
// goes straight into the run's list.
|
|
8
|
+
let reading = null;
|
|
9
|
+
const keep = (line) => {
|
|
10
|
+
const target = reading ?? run;
|
|
11
|
+
if (target.seen.has(line))
|
|
12
|
+
return;
|
|
13
|
+
target.seen.add(line);
|
|
14
|
+
target.lines.push(line);
|
|
15
|
+
};
|
|
16
|
+
const notice = (subject, reason) => {
|
|
17
|
+
const line = `${subject}: ${reason}`;
|
|
18
|
+
keep(line);
|
|
19
|
+
return line;
|
|
20
|
+
};
|
|
21
|
+
exports.notice = notice;
|
|
22
|
+
// A reading takes the lines it produces: `end()` closes the capture and hands
|
|
23
|
+
// back what was read, so the record can carry them.
|
|
24
|
+
const beginNotices = () => {
|
|
25
|
+
const previous = reading;
|
|
26
|
+
const mine = sink();
|
|
27
|
+
reading = mine;
|
|
28
|
+
return {
|
|
29
|
+
lines: mine.lines,
|
|
30
|
+
end: () => {
|
|
31
|
+
reading = previous;
|
|
32
|
+
return mine.lines;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.beginNotices = beginNotices;
|
|
37
|
+
// A record repeats what its reading produced, once per run: dedupe keeps a line
|
|
38
|
+
// that the run already printed out of the list a second time.
|
|
39
|
+
const replayNotices = (lines) => {
|
|
40
|
+
for (const line of lines ?? [])
|
|
41
|
+
keep(line);
|
|
42
|
+
};
|
|
43
|
+
exports.replayNotices = replayNotices;
|
|
44
|
+
// The run hands its notices to the report and starts clean: the dedupe is the
|
|
45
|
+
// memory of ONE report, so it goes with the lines it kept out of it.
|
|
46
|
+
const takeNotices = () => {
|
|
47
|
+
const lines = run.lines.splice(0, run.lines.length);
|
|
48
|
+
run.seen.clear();
|
|
49
|
+
return lines;
|
|
50
|
+
};
|
|
51
|
+
exports.takeNotices = takeNotices;
|
|
52
|
+
const resetNotices = () => {
|
|
53
|
+
run.lines.length = 0;
|
|
54
|
+
run.seen.clear();
|
|
55
|
+
reading = null;
|
|
56
|
+
};
|
|
57
|
+
exports.resetNotices = resetNotices;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ObservedEdge, ObservedPlace } from "@md-code/follow-architecture/entities/overview/graph";
|
|
2
|
+
declare const beginObserved: (file: string, repo: string) => void;
|
|
3
|
+
declare const recordObserved: (kind: string, from: string, to: string, verdict: {
|
|
4
|
+
broken: boolean;
|
|
5
|
+
place: ObservedPlace;
|
|
6
|
+
}) => void;
|
|
7
|
+
declare const recordJudged: (at: {
|
|
8
|
+
kind: string;
|
|
9
|
+
file: string;
|
|
10
|
+
line: number;
|
|
11
|
+
sentence: string;
|
|
12
|
+
}, sources: readonly string[], pairs: readonly {
|
|
13
|
+
targetSlug: string;
|
|
14
|
+
violation: boolean;
|
|
15
|
+
}[]) => void;
|
|
16
|
+
declare const endObserved: (file: string) => void;
|
|
17
|
+
declare const observedFor: (repo: string) => ObservedEdge[];
|
|
18
|
+
declare const resetObserved: () => void;
|
|
19
|
+
export { beginObserved, recordObserved, recordJudged, endObserved, observedFor, resetObserved };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetObserved = exports.observedFor = exports.endObserved = exports.recordJudged = exports.recordObserved = exports.beginObserved = void 0;
|
|
4
|
+
// file key → its rows. A file that produced no relation keeps an EMPTY answer, so a
|
|
5
|
+
// scan that stops seeing an edge drops it instead of remembering it.
|
|
6
|
+
const files = new Map();
|
|
7
|
+
// The file being scanned right now. Runs are sequential, so one entry is open.
|
|
8
|
+
const open = new Map();
|
|
9
|
+
const keyOf = (kind, from, to) => `${kind}|${from}|${to}`;
|
|
10
|
+
// The place that comes first in the report: the earlier file, then the earlier line.
|
|
11
|
+
const before = (a, b) => a.file < b.file || (a.file === b.file && a.line < b.line);
|
|
12
|
+
// Start recording for one file of one repository.
|
|
13
|
+
const beginObserved = (file, repo) => {
|
|
14
|
+
open.set(file, { repo, rows: new Map() });
|
|
15
|
+
};
|
|
16
|
+
exports.beginObserved = beginObserved;
|
|
17
|
+
// One judged place: a relation of `kind` from one entity to another, allowed or
|
|
18
|
+
// refused, at the place the fact named.
|
|
19
|
+
const recordObserved = (kind, from, to, verdict) => {
|
|
20
|
+
const { broken, place } = verdict;
|
|
21
|
+
const at = open.get(place.file);
|
|
22
|
+
if (!at)
|
|
23
|
+
return;
|
|
24
|
+
const rows = at.rows;
|
|
25
|
+
const key = keyOf(kind, from, to);
|
|
26
|
+
const row = rows.get(key);
|
|
27
|
+
if (!row) {
|
|
28
|
+
rows.set(key, { kind, from, to, count: 1, broken: broken ? 1 : 0, sample: place });
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
row.count += 1;
|
|
32
|
+
if (broken)
|
|
33
|
+
row.broken += 1;
|
|
34
|
+
if (before(place, row.sample))
|
|
35
|
+
row.sample = place;
|
|
36
|
+
};
|
|
37
|
+
exports.recordObserved = recordObserved;
|
|
38
|
+
// One judged edge: every (source entity, target entity) pair it resolved, at the
|
|
39
|
+
// place the fact named. Allowed and refused alike — the judgment keeps only the
|
|
40
|
+
// refused ones for the findings, the graph wants both.
|
|
41
|
+
const recordJudged = (at, sources, pairs) => {
|
|
42
|
+
const place = { file: at.file, line: at.line, sentence: at.sentence };
|
|
43
|
+
for (const pair of pairs) {
|
|
44
|
+
for (const from of sources)
|
|
45
|
+
recordObserved(at.kind, from, pair.targetSlug, { broken: pair.violation, place });
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.recordJudged = recordJudged;
|
|
49
|
+
// Commit the file's answer (empty when the file had no judged relation).
|
|
50
|
+
const endObserved = (file) => {
|
|
51
|
+
const at = open.get(file);
|
|
52
|
+
open.delete(file);
|
|
53
|
+
if (!at)
|
|
54
|
+
return;
|
|
55
|
+
const rows = [...at.rows.values()].sort((a, b) => a.from.localeCompare(b.from) || a.to.localeCompare(b.to) || a.kind.localeCompare(b.kind));
|
|
56
|
+
files.set(`${at.repo}::${file}`, { repo: at.repo, rows });
|
|
57
|
+
};
|
|
58
|
+
exports.endObserved = endObserved;
|
|
59
|
+
// Every pair the scan observed in this repository, merged across files. Stable
|
|
60
|
+
// order (from, to, kind) so the payload — and every test over it — is deterministic.
|
|
61
|
+
const observedFor = (repo) => {
|
|
62
|
+
const merged = new Map();
|
|
63
|
+
for (const entry of files.values()) {
|
|
64
|
+
if (entry.repo !== repo)
|
|
65
|
+
continue;
|
|
66
|
+
for (const row of entry.rows) {
|
|
67
|
+
const key = keyOf(row.kind, row.from, row.to);
|
|
68
|
+
const at = merged.get(key);
|
|
69
|
+
if (!at) {
|
|
70
|
+
merged.set(key, { ...row, sample: { ...row.sample } });
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
at.count += row.count;
|
|
74
|
+
at.broken += row.broken;
|
|
75
|
+
if (before(row.sample, at.sample))
|
|
76
|
+
at.sample = { ...row.sample };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return [...merged.values()].sort((a, b) => a.from.localeCompare(b.from) || a.to.localeCompare(b.to) || a.kind.localeCompare(b.kind));
|
|
80
|
+
};
|
|
81
|
+
exports.observedFor = observedFor;
|
|
82
|
+
// Forget everything: a test's own sandbox, and the start of an explicit re-run.
|
|
83
|
+
const resetObserved = () => {
|
|
84
|
+
files.clear();
|
|
85
|
+
open.clear();
|
|
86
|
+
};
|
|
87
|
+
exports.resetObserved = resetObserved;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Finding } from "@md-code/follow-architecture/entities/findings";
|
|
2
|
+
declare const renderReport: (findings: readonly Finding[], repoRoot: string, opts?: {
|
|
3
|
+
orphans?: readonly string[];
|
|
4
|
+
}) => string;
|
|
5
|
+
declare const renderNotices: (notices: readonly string[] | null | undefined) => string;
|
|
6
|
+
declare const renderConfigError: (error: {
|
|
7
|
+
message?: string;
|
|
8
|
+
} | null | undefined) => string;
|
|
9
|
+
declare const renderCrashError: (error: {
|
|
10
|
+
stack?: string;
|
|
11
|
+
} | null | undefined) => string;
|
|
12
|
+
export { renderReport, renderNotices, renderConfigError, renderCrashError };
|