@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,207 @@
|
|
|
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.publicSources = exports.sourceOf = exports.typesVersionPath = exports.exportsPath = exports.manifestOf = exports.folderOf = exports.isFile = exports.norm = exports.ENTRY_FILE = void 0;
|
|
37
|
+
// What a package folder says about its own entry points. An alias target is a
|
|
38
|
+
// folder or an entry file; a SUBPATH of that package is described by the package's
|
|
39
|
+
// manifest (`exports`, `typesVersions`), which names BUILD artifacts — while the
|
|
40
|
+
// architecture talks about the sources those artifacts were built from. So the
|
|
41
|
+
// artifact's path tail is matched against the scanned files of that package.
|
|
42
|
+
//
|
|
43
|
+
// This is the ONE reader of a package manifest: the import resolver and the
|
|
44
|
+
// config's alias patterns both ask it, so neither grows its own copy.
|
|
45
|
+
const fs = __importStar(require("node:fs"));
|
|
46
|
+
const path = __importStar(require("node:path"));
|
|
47
|
+
const field_1 = require("@md-code/follow-architecture/utils/field");
|
|
48
|
+
// A target that ends in a source extension names a FILE; anything else a folder.
|
|
49
|
+
const ENTRY_FILE = /\.[cm]?[jt]sx?$/;
|
|
50
|
+
exports.ENTRY_FILE = ENTRY_FILE;
|
|
51
|
+
const norm = (p) => String(p ?? "")
|
|
52
|
+
.replace(/\\/g, "/")
|
|
53
|
+
.replace(/^\.\//, "")
|
|
54
|
+
.replace(/\/+$/, "");
|
|
55
|
+
exports.norm = norm;
|
|
56
|
+
const isFile = (p) => ENTRY_FILE.test(norm(p));
|
|
57
|
+
exports.isFile = isFile;
|
|
58
|
+
// The folder an alias target names: the target itself, or the entry file's own.
|
|
59
|
+
const folderOf = (target) => (isFile(target) ? norm(target).replace(/\/[^/]*$/, "") : norm(target));
|
|
60
|
+
exports.folderOf = folderOf;
|
|
61
|
+
// Read once per folder per process: a run asks the same package hundreds of times
|
|
62
|
+
// (one question per import) and the file cannot change under a run.
|
|
63
|
+
const manifests = new Map();
|
|
64
|
+
const manifestOf = (repoRoot, folder) => {
|
|
65
|
+
if (repoRoot == null)
|
|
66
|
+
return null;
|
|
67
|
+
const key = `${repoRoot}\u0000${folder}`;
|
|
68
|
+
const cached = manifests.get(key);
|
|
69
|
+
if (cached !== undefined)
|
|
70
|
+
return cached;
|
|
71
|
+
let manifest = null;
|
|
72
|
+
try {
|
|
73
|
+
manifest = JSON.parse(fs.readFileSync(path.join(repoRoot, folder, "package.json"), "utf8"));
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// A package without a manifest publishes no subpaths; the folder reading
|
|
77
|
+
// still answers, so this is not worth a notice.
|
|
78
|
+
manifest = null;
|
|
79
|
+
}
|
|
80
|
+
manifests.set(key, manifest);
|
|
81
|
+
return manifest;
|
|
82
|
+
};
|
|
83
|
+
exports.manifestOf = manifestOf;
|
|
84
|
+
// The path a condition object names. `types` first: the source mirror is what the
|
|
85
|
+
// architecture talks about, the built file is an artifact of it.
|
|
86
|
+
const CONDITIONS = ["types", "import", "default", "node", "require"];
|
|
87
|
+
const pathIn = (value) => {
|
|
88
|
+
if (typeof value === "string")
|
|
89
|
+
return value;
|
|
90
|
+
if ((0, field_1.isList)(value)) {
|
|
91
|
+
for (const item of value) {
|
|
92
|
+
const found = pathIn(item);
|
|
93
|
+
if (found)
|
|
94
|
+
return found;
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
if (!(0, field_1.isObj)(value))
|
|
99
|
+
return null;
|
|
100
|
+
for (const condition of CONDITIONS) {
|
|
101
|
+
const found = pathIn(value[condition]);
|
|
102
|
+
if (found)
|
|
103
|
+
return found;
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
};
|
|
107
|
+
// `exports["./subpath"]` — the public entry a subpath names, if the package has
|
|
108
|
+
// one. An import may spell the built file's extension (`@pkg/chip.js`); the
|
|
109
|
+
// manifest never does, so the extension-less spelling is asked too.
|
|
110
|
+
const exportsPath = (manifest, rest) => {
|
|
111
|
+
const entries = manifest?.exports;
|
|
112
|
+
if (!(0, field_1.isObj)(entries))
|
|
113
|
+
return null;
|
|
114
|
+
const bare = norm(rest).replace(ENTRY_FILE, "");
|
|
115
|
+
for (const name of bare === rest ? [rest] : [rest, bare]) {
|
|
116
|
+
for (const key of [`./${name}`, `./${name}.js`, `./${name}/index`, `./${name}.ts`]) {
|
|
117
|
+
const found = key in entries ? pathIn(entries[key]) : null;
|
|
118
|
+
if (found)
|
|
119
|
+
return found;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
};
|
|
124
|
+
exports.exportsPath = exportsPath;
|
|
125
|
+
// One `typesVersions` pattern: an exact name, or a `*` that captures the middle.
|
|
126
|
+
const fromPattern = (pattern, target, rest) => {
|
|
127
|
+
const name = norm(pattern);
|
|
128
|
+
const star = name.indexOf("*");
|
|
129
|
+
if (star === -1)
|
|
130
|
+
return name === rest ? pathIn(target) : null;
|
|
131
|
+
const head = name.slice(0, star);
|
|
132
|
+
const tail = name.slice(star + 1);
|
|
133
|
+
if (!rest.startsWith(head) || !rest.endsWith(tail))
|
|
134
|
+
return null;
|
|
135
|
+
const found = pathIn(target);
|
|
136
|
+
const captured = rest.slice(head.length, rest.length - tail.length);
|
|
137
|
+
return found ? norm(found).replace("*", captured) : null;
|
|
138
|
+
};
|
|
139
|
+
// `typesVersions[version][pattern]` — the second place a package may describe a
|
|
140
|
+
// subpath, read with the SAME tail rule once a pattern names a path.
|
|
141
|
+
const typesVersionPath = (manifest, rest) => {
|
|
142
|
+
const versions = manifest?.typesVersions;
|
|
143
|
+
if (!(0, field_1.isObj)(versions))
|
|
144
|
+
return null;
|
|
145
|
+
for (const table of Object.values(versions)) {
|
|
146
|
+
if (!(0, field_1.isObj)(table))
|
|
147
|
+
continue;
|
|
148
|
+
for (const [pattern, target] of Object.entries(table)) {
|
|
149
|
+
const found = fromPattern(pattern, target, rest);
|
|
150
|
+
if (found)
|
|
151
|
+
return found;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
};
|
|
156
|
+
exports.typesVersionPath = typesVersionPath;
|
|
157
|
+
// ── artifact → source ───────────────────────────────────────────────────────
|
|
158
|
+
const SOURCE_EXTS = [".tsx", ".ts", ".d.ts"];
|
|
159
|
+
const scannedSets = new WeakMap();
|
|
160
|
+
const scannedOf = (repoFiles) => {
|
|
161
|
+
let scanned = scannedSets.get(repoFiles);
|
|
162
|
+
if (!scanned) {
|
|
163
|
+
scanned = new Set(repoFiles.map(norm));
|
|
164
|
+
scannedSets.set(repoFiles, scanned);
|
|
165
|
+
}
|
|
166
|
+
return scanned;
|
|
167
|
+
};
|
|
168
|
+
// The scanned file an artifact was built from: the artifact's own segments, tried
|
|
169
|
+
// from the LONGEST suffix down, against the files of that package. The build
|
|
170
|
+
// folder (`dist/types/…`) is in no source path, so the first suffix a source file
|
|
171
|
+
// ends with is the answer.
|
|
172
|
+
const sourceOf = (folder, artifact, repoFiles) => {
|
|
173
|
+
const segments = norm(artifact)
|
|
174
|
+
.replace(/\.d\.ts$/, "")
|
|
175
|
+
.replace(ENTRY_FILE, "")
|
|
176
|
+
.split("/")
|
|
177
|
+
.filter(Boolean);
|
|
178
|
+
const scanned = scannedOf(repoFiles);
|
|
179
|
+
for (let i = 0; i < segments.length; i += 1) {
|
|
180
|
+
const tail = segments.slice(i).join("/");
|
|
181
|
+
for (const ext of SOURCE_EXTS) {
|
|
182
|
+
const file = `${folder}/${tail}${ext}`;
|
|
183
|
+
if (scanned.has(file))
|
|
184
|
+
return file;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return null;
|
|
188
|
+
};
|
|
189
|
+
exports.sourceOf = sourceOf;
|
|
190
|
+
// Every public subpath a package publishes, as sources — what `@pkg/*` means for
|
|
191
|
+
// a package that has no folders to walk.
|
|
192
|
+
const publicSources = (folder, manifest, repoFiles) => {
|
|
193
|
+
const entries = manifest?.exports;
|
|
194
|
+
if (!(0, field_1.isObj)(entries))
|
|
195
|
+
return [];
|
|
196
|
+
const out = [];
|
|
197
|
+
for (const [key, value] of Object.entries(entries)) {
|
|
198
|
+
if (!key.startsWith("./"))
|
|
199
|
+
continue;
|
|
200
|
+
const artifact = pathIn(value);
|
|
201
|
+
const source = artifact ? sourceOf(folder, artifact, repoFiles) : null;
|
|
202
|
+
if (source)
|
|
203
|
+
out.push(source);
|
|
204
|
+
}
|
|
205
|
+
return out;
|
|
206
|
+
};
|
|
207
|
+
exports.publicSources = publicSources;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const pathTemplate: (paths: readonly (string | null | undefined)[] | null | undefined) => string;
|
|
2
|
+
declare const tailPath: (template: string | null | undefined, keep?: number) => string;
|
|
3
|
+
declare const nodeLabel: (node: {
|
|
4
|
+
paths?: readonly (string | null | undefined)[] | null;
|
|
5
|
+
} | null | undefined, keep?: number) => string;
|
|
6
|
+
export { pathTemplate, tailPath, nodeLabel };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nodeLabel = exports.tailPath = exports.pathTemplate = void 0;
|
|
4
|
+
// A PATH LABEL is one mechanism: a node's path(s) read as the shortest string
|
|
5
|
+
// that still says WHERE it is. A node that fans out over several parents reads
|
|
6
|
+
// as a template (`apps/backend/*/store.ts`); the label keeps the last N
|
|
7
|
+
// segments. The browser labels boxes / cards / badges (`utils/format`); any
|
|
8
|
+
// consumer that names a place asks the same question. The walk lives here once.
|
|
9
|
+
// One label for a node's path(s): a template when the node fans out over
|
|
10
|
+
// several parents, otherwise the path itself.
|
|
11
|
+
const pathTemplate = (paths) => {
|
|
12
|
+
const list = (paths ?? []).filter((p) => Boolean(p));
|
|
13
|
+
if (!list.length)
|
|
14
|
+
return "";
|
|
15
|
+
if (list.length === 1)
|
|
16
|
+
return list[0];
|
|
17
|
+
const split = list.map((p) => p.split("/"));
|
|
18
|
+
const len = Math.max(...split.map((p) => p.length));
|
|
19
|
+
const out = [];
|
|
20
|
+
for (let i = 0; i < len; i += 1) {
|
|
21
|
+
const seg = split[0][i];
|
|
22
|
+
out.push(split.every((p) => p[i] === seg) ? seg : "*");
|
|
23
|
+
}
|
|
24
|
+
return out.join("/");
|
|
25
|
+
};
|
|
26
|
+
exports.pathTemplate = pathTemplate;
|
|
27
|
+
// Shortest label that still says WHERE it is: the last N path segments.
|
|
28
|
+
const tailPath = (template, keep = 2) => {
|
|
29
|
+
const segs = String(template ?? "")
|
|
30
|
+
.split("/")
|
|
31
|
+
.filter(Boolean);
|
|
32
|
+
return segs.length <= keep ? segs.join("/") : segs.slice(-keep).join("/");
|
|
33
|
+
};
|
|
34
|
+
exports.tailPath = tailPath;
|
|
35
|
+
// The label for a node-like `{ paths }`: its template, shortened to the tail.
|
|
36
|
+
const nodeLabel = (node, keep = 2) => tailPath(pathTemplate(node?.paths), keep);
|
|
37
|
+
exports.nodeLabel = nodeLabel;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const DEFAULT_IGNORE_DIRS: readonly string[];
|
|
2
|
+
declare const DEFAULT_IGNORE_PATHS: readonly string[];
|
|
3
|
+
declare const DEFAULT_SIMILARITY = 0.6;
|
|
4
|
+
declare const DEFAULT_EXTS: string[];
|
|
5
|
+
declare const expandBraces: (s: string) => string[];
|
|
6
|
+
declare const globToRegex: (glob: string) => string;
|
|
7
|
+
declare const conventionOf: (name: string) => string | null;
|
|
8
|
+
declare const placeholderRe: (n: string) => string;
|
|
9
|
+
declare const PLACEHOLDER: RegExp;
|
|
10
|
+
declare const patternBody: (pattern: string) => {
|
|
11
|
+
body: string;
|
|
12
|
+
names: readonly string[];
|
|
13
|
+
};
|
|
14
|
+
declare const compilePattern: (pattern: string) => {
|
|
15
|
+
re: RegExp;
|
|
16
|
+
names: readonly string[];
|
|
17
|
+
};
|
|
18
|
+
declare const checkRegex: (p: string, where: string) => void;
|
|
19
|
+
export { DEFAULT_EXTS, DEFAULT_SIMILARITY, DEFAULT_IGNORE_DIRS, DEFAULT_IGNORE_PATHS, globToRegex, conventionOf, placeholderRe, compilePattern, patternBody, PLACEHOLDER, expandBraces, checkRegex, };
|
|
@@ -0,0 +1,231 @@
|
|
|
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.checkRegex = exports.expandBraces = exports.PLACEHOLDER = exports.patternBody = exports.compilePattern = exports.placeholderRe = exports.conventionOf = exports.globToRegex = exports.DEFAULT_IGNORE_PATHS = exports.DEFAULT_IGNORE_DIRS = exports.DEFAULT_SIMILARITY = exports.DEFAULT_EXTS = void 0;
|
|
37
|
+
const configError = __importStar(require("@md-code/follow-architecture/report/configErrors"));
|
|
38
|
+
const ignore_1 = require("@md-code/follow-architecture/ignore");
|
|
39
|
+
// Glob → regex and the naming-convention placeholder machinery shared by
|
|
40
|
+
// every entity that matches file paths (nodes, rules, fileSpecs).
|
|
41
|
+
// Directories that never contain source code. The list lives in `ignore.ts`
|
|
42
|
+
// because the ESLint rule skips exactly the same folders; a repo may add more
|
|
43
|
+
// via `ignoreDirs`.
|
|
44
|
+
const DEFAULT_IGNORE_DIRS = ignore_1.IGNORE_DIRS;
|
|
45
|
+
exports.DEFAULT_IGNORE_DIRS = DEFAULT_IGNORE_DIRS;
|
|
46
|
+
// Repo-relative paths that are outside the contract, from the same list: the CLI
|
|
47
|
+
// and the rule skip them unless a caller adds its own `--ignore` / `ignores`.
|
|
48
|
+
const DEFAULT_IGNORE_PATHS = ignore_1.IGNORE_PATHS;
|
|
49
|
+
exports.DEFAULT_IGNORE_PATHS = DEFAULT_IGNORE_PATHS;
|
|
50
|
+
// Source extensions the TOOL scans by default. Scan scope is a tool concern, not
|
|
51
|
+
// architecture (the yaml must not carry it) — and it is an option, not a fact of
|
|
52
|
+
// the tool's code: `--ext <ext>` / the rule's `exts` add to this list.
|
|
53
|
+
// How much a folder has to look like a declared entity before a rule may offer it
|
|
54
|
+
// as a destination (see nodes/similar.js). A rule option; this is the default.
|
|
55
|
+
const DEFAULT_SIMILARITY = 0.6;
|
|
56
|
+
exports.DEFAULT_SIMILARITY = DEFAULT_SIMILARITY;
|
|
57
|
+
const DEFAULT_EXTS = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".vue", ".svelte"];
|
|
58
|
+
exports.DEFAULT_EXTS = DEFAULT_EXTS;
|
|
59
|
+
// Brace expansion: `{a,b,c}` → alternation of the alternatives. Nested
|
|
60
|
+
// braces are not supported (no architecture needs them).
|
|
61
|
+
const expandBraces = (s) => {
|
|
62
|
+
const open = s.indexOf("{");
|
|
63
|
+
if (open === -1)
|
|
64
|
+
return [s];
|
|
65
|
+
const close = s.indexOf("}", open);
|
|
66
|
+
if (close === -1)
|
|
67
|
+
return [s];
|
|
68
|
+
const prefix = s.slice(0, open);
|
|
69
|
+
const suffix = s.slice(close + 1);
|
|
70
|
+
const parts = s
|
|
71
|
+
.slice(open + 1, close)
|
|
72
|
+
.split(",")
|
|
73
|
+
.map((p) => p.trim());
|
|
74
|
+
const out = [];
|
|
75
|
+
for (const p of parts)
|
|
76
|
+
for (const rest of expandBraces(prefix + p + suffix))
|
|
77
|
+
out.push(rest);
|
|
78
|
+
return out;
|
|
79
|
+
};
|
|
80
|
+
exports.expandBraces = expandBraces;
|
|
81
|
+
const braceToken = (glob, i) => {
|
|
82
|
+
if (glob[i] !== "{")
|
|
83
|
+
return null;
|
|
84
|
+
const close = glob.indexOf("}", i);
|
|
85
|
+
if (close === -1)
|
|
86
|
+
return null;
|
|
87
|
+
const alts = expandBraces(glob.slice(i, close + 1)).map((a) => globToRegex(a));
|
|
88
|
+
return { text: alts.length > 1 ? `(?:${alts.join("|")})` : alts[0], next: close };
|
|
89
|
+
};
|
|
90
|
+
const globToken = (glob, i) => {
|
|
91
|
+
const c = glob[i];
|
|
92
|
+
if (glob.startsWith("**/", i))
|
|
93
|
+
return { text: "(?:.*/)?", advance: 3 };
|
|
94
|
+
if (glob.startsWith("**", i))
|
|
95
|
+
return { text: ".*", advance: 2 };
|
|
96
|
+
if (c === "*")
|
|
97
|
+
return { text: "[^/]*", advance: 1 };
|
|
98
|
+
if (c === "?")
|
|
99
|
+
return { text: "[^/]", advance: 1 };
|
|
100
|
+
if ("\\.+^$|()[]".includes(c))
|
|
101
|
+
return { text: `\\${c}`, advance: 1 };
|
|
102
|
+
return { text: c, advance: 1 };
|
|
103
|
+
};
|
|
104
|
+
const globToRegex = (glob) => {
|
|
105
|
+
let out = "";
|
|
106
|
+
for (let i = 0; i < glob.length;) {
|
|
107
|
+
const brace = braceToken(glob, i);
|
|
108
|
+
if (brace) {
|
|
109
|
+
out += brace.text;
|
|
110
|
+
i = brace.next + 1;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const tok = globToken(glob, i);
|
|
114
|
+
out += tok.text;
|
|
115
|
+
i += tok.advance;
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
};
|
|
119
|
+
exports.globToRegex = globToRegex;
|
|
120
|
+
// A placeholder is written IN the convention it asks for, so the convention is
|
|
121
|
+
// read off the name itself: `{kebab-case}` is kebab because it is spelled in
|
|
122
|
+
// kebab, and `{feature-name}` means the same thing for the same reason. There is
|
|
123
|
+
// no list of known conventions to keep in sync — add `{UPPER_CASE}`,
|
|
124
|
+
// `{snake_case}`, `{myCase}`, `{PascalCase}` and they all compile.
|
|
125
|
+
const CASES = {
|
|
126
|
+
// lowercase, joined by dashes: `feature-name`
|
|
127
|
+
kebab: "[a-z0-9]+(?:-[a-z0-9]+)*",
|
|
128
|
+
// lowercase, joined by underscores: `feature_name`
|
|
129
|
+
snake: "[a-z0-9]+(?:_[a-z0-9]+)*",
|
|
130
|
+
// uppercase, joined by underscores: `FEATURE_NAME`
|
|
131
|
+
screaming: "[A-Z0-9]+(?:_[A-Z0-9]+)*",
|
|
132
|
+
// uppercase, joined by dashes: `FEATURE-NAME`
|
|
133
|
+
screamingKebab: "[A-Z0-9]+(?:-[A-Z0-9]+)*",
|
|
134
|
+
// one lowercase word, then capitals: `featureName`
|
|
135
|
+
camel: "[a-z][a-zA-Z0-9]*",
|
|
136
|
+
// a capitalised word: `FeatureName`, and `NAME`
|
|
137
|
+
pascal: "[A-Z][a-zA-Z0-9]*",
|
|
138
|
+
};
|
|
139
|
+
const allMatch = (words, re) => words.length > 0 && words.every((w) => re.test(w));
|
|
140
|
+
// The convention a placeholder NAME states, or null when it states none (a
|
|
141
|
+
// single word with mixed case, a digit-only name, anything unrecognised) — then
|
|
142
|
+
// the placeholder still captures, it just enforces nothing.
|
|
143
|
+
const underscoreConvention = (words) => {
|
|
144
|
+
if (allMatch(words, /^[A-Z0-9]+$/))
|
|
145
|
+
return CASES.screaming;
|
|
146
|
+
if (allMatch(words, /^[a-z0-9]+$/))
|
|
147
|
+
return CASES.snake;
|
|
148
|
+
return null;
|
|
149
|
+
};
|
|
150
|
+
const dashConvention = (words) => {
|
|
151
|
+
if (allMatch(words, /^[a-z0-9]+$/))
|
|
152
|
+
return CASES.kebab;
|
|
153
|
+
if (allMatch(words, /^[A-Z0-9]+$/))
|
|
154
|
+
return CASES.screamingKebab;
|
|
155
|
+
return null;
|
|
156
|
+
};
|
|
157
|
+
const conventionOf = (name) => {
|
|
158
|
+
if (name.includes("_"))
|
|
159
|
+
return underscoreConvention(name.split("_"));
|
|
160
|
+
if (name.includes("-"))
|
|
161
|
+
return dashConvention(name.split("-"));
|
|
162
|
+
if (/^[A-Z0-9]+$/.test(name))
|
|
163
|
+
return CASES.pascal; // `NAME`, `ID2`
|
|
164
|
+
if (/^[a-z0-9]+$/.test(name))
|
|
165
|
+
return CASES.kebab; // `name` — kebab, snake and camel of one word agree
|
|
166
|
+
if (/^[a-z][a-zA-Z0-9]*$/.test(name))
|
|
167
|
+
return CASES.camel; // `featureName`
|
|
168
|
+
if (/^[A-Za-z0-9]+$/.test(name))
|
|
169
|
+
return CASES.pascal; // `FeatureName`
|
|
170
|
+
return null;
|
|
171
|
+
};
|
|
172
|
+
exports.conventionOf = conventionOf;
|
|
173
|
+
const placeholderRe = (n) => conventionOf(n) ?? "[^/]+";
|
|
174
|
+
exports.placeholderRe = placeholderRe;
|
|
175
|
+
// What a placeholder looks like inside a path template: `{kebab-case}`,
|
|
176
|
+
// `{camelCase}`, `{UPPER_CASE}`, `{anything-you-like}`.
|
|
177
|
+
const PLACEHOLDER = /\{([A-Za-z][A-Za-z0-9_-]*)\}/g;
|
|
178
|
+
exports.PLACEHOLDER = PLACEHOLDER;
|
|
179
|
+
// The regex BODY a path template compiles to, plus the placeholder names it
|
|
180
|
+
// captured — the ONE implementation of "placeholders inside a glob", shared by
|
|
181
|
+
// patterns, node paths and node children. A placeholder is swapped for a sentinel
|
|
182
|
+
// before the glob is compiled so its own characters survive, then put back as a
|
|
183
|
+
// capture group of the convention it asks for.
|
|
184
|
+
// The same templates are compiled again and again: every file is matched against
|
|
185
|
+
// every node path, every finding against the rule's patterns. Compilation is pure
|
|
186
|
+
// (a template always yields the same body and names), so it is memoised; the
|
|
187
|
+
// produced expressions have no `g` flag, so one instance is safe to reuse.
|
|
188
|
+
// The memo is MODULE-wide and grows to the number of distinct templates the run
|
|
189
|
+
// meets (bounded by the working tree — a CLI run dies with it); the captured
|
|
190
|
+
// names are handed out READ-ONLY, so one caller cannot edit another's.
|
|
191
|
+
const bodies = new Map();
|
|
192
|
+
const patternBody = (pattern) => {
|
|
193
|
+
const key = String(pattern);
|
|
194
|
+
const cached = bodies.get(key);
|
|
195
|
+
if (cached)
|
|
196
|
+
return cached;
|
|
197
|
+
const names = [];
|
|
198
|
+
const glob = String(pattern)
|
|
199
|
+
.replace(/\\/g, "/")
|
|
200
|
+
.replace(PLACEHOLDER, (_, n) => {
|
|
201
|
+
names.push(n);
|
|
202
|
+
return `\u0000${n}\u0000`;
|
|
203
|
+
});
|
|
204
|
+
const body = globToRegex(glob).replace(/\u0000([A-Za-z][A-Za-z0-9_-]*)\u0000/g, (_, n) => `(${placeholderRe(n)})`);
|
|
205
|
+
const compiled = { body, names };
|
|
206
|
+
bodies.set(key, compiled);
|
|
207
|
+
return compiled;
|
|
208
|
+
};
|
|
209
|
+
exports.patternBody = patternBody;
|
|
210
|
+
const patterns = new Map();
|
|
211
|
+
const compilePattern = (pattern) => {
|
|
212
|
+
const key = String(pattern);
|
|
213
|
+
const cached = patterns.get(key);
|
|
214
|
+
if (cached)
|
|
215
|
+
return cached;
|
|
216
|
+
const { body, names } = patternBody(pattern);
|
|
217
|
+
const compiled = { re: new RegExp(`^${body}$`), names };
|
|
218
|
+
patterns.set(key, compiled);
|
|
219
|
+
return compiled;
|
|
220
|
+
};
|
|
221
|
+
exports.compilePattern = compilePattern;
|
|
222
|
+
const checkRegex = (p, where) => {
|
|
223
|
+
try {
|
|
224
|
+
new RegExp(p);
|
|
225
|
+
}
|
|
226
|
+
catch (err) {
|
|
227
|
+
const e = err;
|
|
228
|
+
throw configError.invalidPattern({ where, pattern: p, reason: e.message ?? String(e) });
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
exports.checkRegex = checkRegex;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Arch, ActionDef } from "@md-code/follow-architecture/entities/architecture";
|
|
2
|
+
import type { FileFacts } from "@md-code/follow-architecture/entities/facts";
|
|
3
|
+
import type { Caps } from "@md-code/follow-architecture/entities/location/where";
|
|
4
|
+
type Permission = {
|
|
5
|
+
allowed: boolean;
|
|
6
|
+
denied: boolean;
|
|
7
|
+
};
|
|
8
|
+
type PermissionAsk = {
|
|
9
|
+
rel: string;
|
|
10
|
+
arch: Arch;
|
|
11
|
+
scope: FileFacts | null | undefined;
|
|
12
|
+
caps: Caps | null;
|
|
13
|
+
};
|
|
14
|
+
declare const permissionOf: (action: ActionDef, ask: PermissionAsk) => Permission;
|
|
15
|
+
export { permissionOf };
|
|
16
|
+
export type { Permission };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.permissionOf = void 0;
|
|
4
|
+
// A PERMISSION is one mechanism: an action's `where` says who may do it, and
|
|
5
|
+
// its `except` says when that allowance stops. The relation check asks it of
|
|
6
|
+
// one edge (`nodes/finally/relations-edge`); any consumer that judges an act
|
|
7
|
+
// against a declared allowance asks the same two questions. The walk — allow
|
|
8
|
+
// when some `where` entry admits, then refuse when some `except` entry admits —
|
|
9
|
+
// lives here once. What the entries MEAN is the shared `where` grammar's own.
|
|
10
|
+
const location_1 = require("@md-code/follow-architecture/entities/location");
|
|
11
|
+
const permissionOf = (action, ask) => {
|
|
12
|
+
const allowed = !(0, location_1.checkWhere)(action.where, ask.rel, ask.arch, ask.scope, ask.caps);
|
|
13
|
+
const denied = (action.except ?? []).length
|
|
14
|
+
? !(0, location_1.checkWhere)(action.except, ask.rel, ask.arch, ask.scope, ask.caps)
|
|
15
|
+
: false;
|
|
16
|
+
return { allowed, denied };
|
|
17
|
+
};
|
|
18
|
+
exports.permissionOf = permissionOf;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.plural = void 0;
|
|
4
|
+
// A PLURAL is one mechanism: a count read as "1 thing" / "N things". The browser
|
|
5
|
+
// counts entities / rules / matches (`utils/format`); any consumer that names a
|
|
6
|
+
// count asks the same question. The irregular plural is the caller's own; the
|
|
7
|
+
// regular one adds `s`.
|
|
8
|
+
const plural = (n, one, many) => `${n} ${n === 1 ? one : (many ?? `${one}s`)}`;
|
|
9
|
+
exports.plural = plural;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.answerWhenAllPass = void 0;
|
|
4
|
+
// A QUALIFIED ANSWER is one mechanism: a subject must pass every guard before
|
|
5
|
+
// it earns an answer; the first guard that refuses ends the question with
|
|
6
|
+
// nothing. A misfit entity is a named candidate of a declared entity with homes
|
|
7
|
+
// that sits outside them (`pipeline-entities`); a scope accessor is a record whose
|
|
8
|
+
// scope is one of the declared kinds (`code-entities/entities`). The walk is the same
|
|
9
|
+
// — ask each guard in order, answer only when all pass — so it lives here once.
|
|
10
|
+
// What the guards ARE and what the answer is is the caller's own; nothing here
|
|
11
|
+
// knows entities or accessors.
|
|
12
|
+
// The answer when every guard passes; null the moment one refuses. Guards are
|
|
13
|
+
// asked in order, so a cheap refusal short-circuits the rest.
|
|
14
|
+
const answerWhenAllPass = (subject, guards, answer) => {
|
|
15
|
+
for (const guard of guards) {
|
|
16
|
+
if (!guard(subject))
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return answer(subject);
|
|
20
|
+
};
|
|
21
|
+
exports.answerWhenAllPass = answerWhenAllPass;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rankedOffers = void 0;
|
|
4
|
+
// A RANKED SHORTLIST is one mechanism: candidates are scored against a subject,
|
|
5
|
+
// the ones below the bar are dropped, and the rest are offered best first. A
|
|
6
|
+
// entity's destinations are its homes scored by branch and prefix
|
|
7
|
+
// (`entities/location/homes`); a folder's lookalikes are the declared entities
|
|
8
|
+
// scored by the share of their entities it holds (`nodes/similar`). The walk is
|
|
9
|
+
// the same — score, keep, rank — so it lives here once. What a candidate IS,
|
|
10
|
+
// how it is scored and what the bar means are the caller's own.
|
|
11
|
+
// Score every candidate, keep the ones the scorer offers (non-null), and sort
|
|
12
|
+
// them by the caller's ranking. The scorer's own verdict decides inclusion;
|
|
13
|
+
// nothing here knows homes or entities.
|
|
14
|
+
const rankedOffers = (candidates, offer, rank) => {
|
|
15
|
+
const offers = [];
|
|
16
|
+
for (const candidate of candidates) {
|
|
17
|
+
const hit = offer(candidate);
|
|
18
|
+
if (hit != null)
|
|
19
|
+
offers.push(hit);
|
|
20
|
+
}
|
|
21
|
+
offers.sort(rank);
|
|
22
|
+
return offers;
|
|
23
|
+
};
|
|
24
|
+
exports.rankedOffers = rankedOffers;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type FieldValue } from "./field";
|
|
2
|
+
declare const stringField: (record: FieldValue, key: string, fallback?: string) => string;
|
|
3
|
+
declare const numberField: (record: FieldValue, key: string, fallback?: number) => number;
|
|
4
|
+
declare const booleanField: (record: FieldValue, key: string, fallback?: boolean) => boolean;
|
|
5
|
+
declare const recordField: (record: FieldValue, key: string) => {
|
|
6
|
+
readonly [key: string]: FieldValue;
|
|
7
|
+
} | null;
|
|
8
|
+
declare const recordListField: (record: FieldValue, key: string) => {
|
|
9
|
+
readonly [key: string]: FieldValue;
|
|
10
|
+
}[];
|
|
11
|
+
declare const stringListField: (record: FieldValue, key: string) => string[];
|
|
12
|
+
export { stringField, numberField, booleanField, recordField, recordListField, stringListField };
|