@md-code/follow-architecture 0.1.0 → 0.3.0
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 +16 -0
- package/LICENSE +202 -0
- package/README.md +597 -126
- package/dist/aliases.d.ts +3 -0
- package/dist/aliases.js +12 -0
- package/dist/args.d.ts +14 -0
- package/dist/args.js +77 -0
- package/dist/bin/follow-architecture.d.ts +2 -0
- package/dist/bin/follow-architecture.js +23 -0
- package/dist/code-roles/classify.d.ts +11 -0
- package/dist/code-roles/classify.js +43 -0
- package/dist/code-roles/connector.d.ts +5 -0
- package/dist/code-roles/connector.js +114 -0
- package/dist/code-roles/project.d.ts +12 -0
- package/dist/code-roles/project.js +122 -0
- package/dist/code-roles/roles.d.ts +8 -0
- package/dist/code-roles/roles.js +190 -0
- package/dist/config-options.d.ts +53 -0
- package/dist/config-options.js +35 -0
- package/dist/config-project.d.ts +4 -0
- package/dist/config-project.js +74 -0
- package/dist/config-report.d.ts +19 -0
- package/dist/config-report.js +134 -0
- package/dist/config-rule.d.ts +70 -0
- package/dist/config-rule.js +118 -0
- package/dist/config-state.d.ts +14 -0
- package/dist/config-state.js +96 -0
- package/dist/config.d.ts +82 -0
- package/dist/config.js +38 -0
- package/dist/css/index.d.ts +27 -0
- package/dist/css/index.js +140 -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 +41 -0
- package/dist/css/syntax/css/reference.d.ts +3 -0
- package/dist/css/syntax/css/reference.js +24 -0
- package/dist/css/syntax/language.d.ts +25 -0
- package/dist/css/syntax/language.js +69 -0
- package/dist/css/syntax/scss/index.d.ts +25 -0
- package/dist/css/syntax/scss/index.js +85 -0
- package/dist/css/syntax/scss/reference.d.ts +3 -0
- package/dist/css/syntax/scss/reference.js +11 -0
- package/dist/css/syntax/styled/document.d.ts +68 -0
- package/dist/css/syntax/styled/document.js +241 -0
- package/dist/css/syntax/styled/markup.d.ts +6 -0
- package/dist/css/syntax/styled/markup.js +76 -0
- package/dist/css/syntax/styled/template.d.ts +23 -0
- package/dist/css/syntax/styled/template.js +61 -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 +69 -0
- package/dist/css/value/expression/block.d.ts +9 -0
- package/dist/css/value/expression/block.js +91 -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 +69 -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 +103 -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 +129 -0
- package/dist/css/value/object/path.d.ts +10 -0
- package/dist/css/value/object/path.js +146 -0
- package/dist/css/value/pieces.d.ts +61 -0
- package/dist/css/value/pieces.js +55 -0
- package/dist/css/value/resolve.d.ts +33 -0
- package/dist/css/value/resolve.js +94 -0
- package/dist/css/value/scope.d.ts +27 -0
- package/dist/css/value/scope.js +187 -0
- package/dist/css/value/substitute.d.ts +10 -0
- package/dist/css/value/substitute.js +113 -0
- package/dist/css/value/values.d.ts +23 -0
- package/dist/css/value/values.js +131 -0
- package/dist/entities/architecture.d.ts +162 -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 +86 -0
- package/dist/entities/ast/assignments-tagged.d.ts +5 -0
- package/dist/entities/ast/assignments-tagged.js +180 -0
- package/dist/entities/ast/assignments.d.ts +9 -0
- package/dist/entities/ast/assignments.js +78 -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 +134 -0
- package/dist/entities/ast/classes.d.ts +5 -0
- package/dist/entities/ast/classes.js +57 -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 +4 -0
- package/dist/entities/ast/comments.js +100 -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 +149 -0
- package/dist/entities/ast/enums.d.ts +6 -0
- package/dist/entities/ast/enums.js +17 -0
- package/dist/entities/ast/file-exports.d.ts +7 -0
- package/dist/entities/ast/file-exports.js +78 -0
- package/dist/entities/ast/file-facts.d.ts +13 -0
- package/dist/entities/ast/file-facts.js +35 -0
- package/dist/entities/ast/file-imports.d.ts +5 -0
- package/dist/entities/ast/file-imports.js +77 -0
- package/dist/entities/ast/file.d.ts +5 -0
- package/dist/entities/ast/file.js +22 -0
- package/dist/entities/ast/functions.d.ts +8 -0
- package/dist/entities/ast/functions.js +102 -0
- package/dist/entities/ast/heritage.d.ts +4 -0
- package/dist/entities/ast/heritage.js +36 -0
- package/dist/entities/ast/index.d.ts +6 -0
- package/dist/entities/ast/index.js +125 -0
- package/dist/entities/ast/kind.d.ts +5 -0
- package/dist/entities/ast/kind.js +28 -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 +75 -0
- package/dist/entities/ast/properties.d.ts +11 -0
- package/dist/entities/ast/properties.js +171 -0
- package/dist/entities/ast/resolve.d.ts +16 -0
- package/dist/entities/ast/resolve.js +307 -0
- package/dist/entities/ast/tree.d.ts +29 -0
- package/dist/entities/ast/tree.js +351 -0
- package/dist/entities/ast/types.d.ts +6 -0
- package/dist/entities/ast/types.js +45 -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 +261 -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 +221 -0
- package/dist/entities/location/homes.d.ts +28 -0
- package/dist/entities/location/homes.js +169 -0
- package/dist/entities/location/place.d.ts +10 -0
- package/dist/entities/location/place.js +56 -0
- package/dist/entities/location/where.d.ts +17 -0
- package/dist/entities/location/where.js +218 -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 +65 -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 +79 -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 +305 -0
- package/dist/entities/repair.d.ts +16 -0
- package/dist/entities/repair.js +23 -0
- package/dist/entities/schema.d.ts +8 -0
- package/dist/entities/schema.js +23 -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 +5 -0
- package/dist/entities/tree/build.js +252 -0
- package/dist/entities/tree/entries.d.ts +7 -0
- package/dist/entities/tree/entries.js +120 -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 +176 -0
- package/dist/frameworks/angular/index.d.ts +7 -0
- package/dist/frameworks/angular/index.js +17 -0
- package/dist/frameworks/facet.d.ts +16 -0
- package/dist/frameworks/facet.js +2 -0
- package/dist/frameworks/index.d.ts +9 -0
- package/dist/frameworks/index.js +120 -0
- package/dist/frameworks/react/index.d.ts +7 -0
- package/dist/frameworks/react/index.js +214 -0
- package/dist/frameworks/vue/index.d.ts +7 -0
- package/dist/frameworks/vue/index.js +17 -0
- package/dist/invariants/index.d.ts +6 -0
- package/dist/invariants/index.js +299 -0
- package/dist/invariants/list-vars.d.ts +5 -0
- package/dist/invariants/list-vars.js +143 -0
- package/dist/invariants/name.d.ts +16 -0
- package/dist/invariants/name.js +18 -0
- package/dist/invariants/normalize.d.ts +4 -0
- package/dist/invariants/normalize.js +95 -0
- package/dist/invariants/vars.d.ts +20 -0
- package/dist/invariants/vars.js +117 -0
- package/dist/main.d.ts +7 -0
- package/dist/main.js +229 -0
- package/dist/nodes/child-roles.d.ts +3 -0
- package/dist/nodes/child-roles.js +12 -0
- package/dist/nodes/children.d.ts +25 -0
- package/dist/nodes/children.js +112 -0
- package/dist/nodes/finally/emit.d.ts +6 -0
- package/dist/nodes/finally/emit.js +55 -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 +22 -0
- package/dist/nodes/finally/relations-access.d.ts +5 -0
- package/dist/nodes/finally/relations-access.js +46 -0
- package/dist/nodes/finally/relations-edge.d.ts +29 -0
- package/dist/nodes/finally/relations-edge.js +125 -0
- package/dist/nodes/finally/relations-group.d.ts +31 -0
- package/dist/nodes/finally/relations-group.js +103 -0
- package/dist/nodes/finally/relations.d.ts +5 -0
- package/dist/nodes/finally/relations.js +81 -0
- package/dist/nodes/finally/required.d.ts +5 -0
- package/dist/nodes/finally/required.js +90 -0
- package/dist/nodes/finally/roles.d.ts +13 -0
- package/dist/nodes/finally/roles.js +41 -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 +156 -0
- package/dist/pipeline-facts.d.ts +11 -0
- package/dist/pipeline-facts.js +112 -0
- package/dist/pipeline-roles.d.ts +6 -0
- package/dist/pipeline-roles.js +75 -0
- package/dist/pipeline-unroled.d.ts +14 -0
- package/dist/pipeline-unroled.js +193 -0
- package/dist/pipeline.d.ts +7 -0
- package/dist/pipeline.js +73 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +3 -0
- package/dist/report/asks.d.ts +55 -0
- package/dist/report/asks.js +50 -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 +98 -0
- package/dist/report/configErrors.js +75 -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 +99 -0
- package/dist/report/errorTypes/destinations.d.ts +38 -0
- package/dist/report/errorTypes/destinations.js +147 -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 +45 -0
- package/dist/report/errorTypes/types/fileContents.d.ts +9 -0
- package/dist/report/errorTypes/types/fileContents.js +34 -0
- package/dist/report/errorTypes/types/unknownRole.d.ts +9 -0
- package/dist/report/errorTypes/types/unknownRole.js +22 -0
- package/dist/report/errorTypes/types/wrongAction.d.ts +22 -0
- package/dist/report/errorTypes/types/wrongAction.js +135 -0
- package/dist/report/errorTypes/types/wrongPlacement.d.ts +9 -0
- package/dist/report/errorTypes/types/wrongPlacement.js +57 -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 +174 -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 +103 -0
- package/dist/report/notices.d.ts +4 -0
- package/dist/report/notices.js +31 -0
- package/dist/report/render-report.d.ts +12 -0
- package/dist/report/render-report.js +142 -0
- package/dist/report/user-report/build/bundle.d.ts +3 -0
- package/dist/report/user-report/build/bundle.js +169 -0
- package/dist/report/user-report/build/bundle.prebuilt.js +760 -0
- package/dist/report/user-report/data/collect.d.ts +4 -0
- package/dist/report/user-report/data/collect.js +80 -0
- package/dist/report/user-report/data/file-tree.d.ts +9 -0
- package/dist/report/user-report/data/file-tree.js +72 -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 +171 -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-helpers.d.ts +7 -0
- package/dist/report/user-report/data/graph-helpers.js +67 -0
- package/dist/report/user-report/data/graph-roles.d.ts +5 -0
- package/dist/report/user-report/data/graph-roles.js +71 -0
- package/dist/report/user-report/data/graph.d.ts +11 -0
- package/dist/report/user-report/data/graph.js +90 -0
- package/dist/report/user-report/data/invariants.d.ts +7 -0
- package/dist/report/user-report/data/invariants.js +62 -0
- package/dist/report/user-report/data/nodes.d.ts +11 -0
- package/dist/report/user-report/data/nodes.js +106 -0
- package/dist/report/user-report/data/role-examples.d.ts +16 -0
- package/dist/report/user-report/data/role-examples.js +94 -0
- package/dist/report/user-report/data/role-filters.d.ts +15 -0
- package/dist/report/user-report/data/role-filters.js +79 -0
- package/dist/report/user-report/data/role-marks.d.ts +5 -0
- package/dist/report/user-report/data/role-marks.js +79 -0
- package/dist/report/user-report/data/roles.d.ts +7 -0
- package/dist/report/user-report/data/roles.js +83 -0
- package/dist/report/user-report/data/scan.d.ts +8 -0
- package/dist/report/user-report/data/scan.js +59 -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 +48 -0
- package/dist/report/user-report/shared/describe.d.ts +7 -0
- package/dist/report/user-report/shared/describe.js +86 -0
- package/dist/scripts/audit-report.d.ts +2 -0
- package/dist/scripts/audit-report.js +147 -0
- package/dist/utils/accumulate.d.ts +6 -0
- package/dist/utils/accumulate.js +18 -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 +87 -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 +12 -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 +73 -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 +13 -0
- package/dist/utils/imports.d.ts +12 -0
- package/dist/utils/imports.js +121 -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/path-label.d.ts +6 -0
- package/dist/utils/path-label.js +35 -0
- package/dist/utils/pattern.d.ts +18 -0
- package/dist/utils/pattern.js +191 -0
- package/dist/utils/permission.d.ts +16 -0
- package/dist/utils/permission.js +16 -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 +16 -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 +8 -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 +13 -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 +62 -19
- package/report/errorTypes/vocabulary/ids.ts +12 -0
- package/report/errorTypes/vocabulary/phrases.ts +161 -0
- package/report/errorTypes/vocabulary/places.ts +46 -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 -82
- package/entities/aliases.js +0 -10
- package/entities/invariants.js +0 -134
- package/entities/nodes.js +0 -112
- package/main.js +0 -95
- package/report.js +0 -73
- package/utils.js +0 -104
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QUANTIFIERS = exports.describePiece = exports.branchOf = exports.collectScalars = exports.listHit = exports.enrichedVars = exports.filterOf = void 0;
|
|
4
|
+
// Report VARIABLES for the invariant runtime: the placeholders a finding's
|
|
5
|
+
// sentence may name. Every variable is read off the facts themselves — the
|
|
6
|
+
// path vars, the scalars a fact carries, the items a filter matched — so no
|
|
7
|
+
// list of known names can fall behind the fact model.
|
|
8
|
+
const queries_1 = require("../entities/queries");
|
|
9
|
+
const field_1 = require("../utils/field");
|
|
10
|
+
const record_1 = require("../utils/record");
|
|
11
|
+
const name_1 = require("./name");
|
|
12
|
+
// A check's `report` is the message template for its findings, not a filter
|
|
13
|
+
// key — strip it before matching so it is not treated as a fact field. The
|
|
14
|
+
// record-minus-keys walk is the shared `recordWithout` core.
|
|
15
|
+
const filterOf = (entry) => (0, record_1.recordWithout)(entry, ["report"]);
|
|
16
|
+
exports.filterOf = filterOf;
|
|
17
|
+
// Report variables for file-level findings: the path vars plus every scalar
|
|
18
|
+
// file fact and every scalar inside a nested fact object (the `path` fact: dir,
|
|
19
|
+
// fileName, …) so a report can say `{files} files` without hardcoding. An array
|
|
20
|
+
// fact reports its LENGTH — `{lines}` is how many lines there are.
|
|
21
|
+
const scalarVarsOf = (facts, vars) => {
|
|
22
|
+
if (!(0, queries_1.isObj)(facts))
|
|
23
|
+
return;
|
|
24
|
+
for (const [k, v] of Object.entries(facts)) {
|
|
25
|
+
if ((0, field_1.isList)(v))
|
|
26
|
+
vars[k] = v.length;
|
|
27
|
+
else if (typeof v === "number" || typeof v === "string")
|
|
28
|
+
vars[k] = v;
|
|
29
|
+
else if ((0, queries_1.isObj)(v))
|
|
30
|
+
nestedScalarVars(v, vars);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const nestedScalarVars = (obj, vars) => {
|
|
34
|
+
for (const [sk, sv] of Object.entries(obj)) {
|
|
35
|
+
if ((0, field_1.isList)(sv))
|
|
36
|
+
vars[sk] = sv.length;
|
|
37
|
+
else if (typeof sv === "number" || typeof sv === "string")
|
|
38
|
+
vars[sk] = sv;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const enrichedVars = (ctx) => {
|
|
42
|
+
const vars = { ...(0, name_1.fileVars)(ctx) };
|
|
43
|
+
scalarVarsOf(ctx.facts ?? {}, vars);
|
|
44
|
+
return vars;
|
|
45
|
+
};
|
|
46
|
+
exports.enrichedVars = enrichedVars;
|
|
47
|
+
// Which items a list entry is talking about: the query engine's own reading
|
|
48
|
+
// (`hitOf`), applied to the field this rule named. No second extraction here —
|
|
49
|
+
// a message naming `{ <field> }` and the check itself cannot disagree.
|
|
50
|
+
const listHit = (list, filter, field, scope) => {
|
|
51
|
+
const sub = (0, queries_1.isObj)(filter) ? filter[field] : undefined;
|
|
52
|
+
if (!(0, queries_1.isObj)(sub))
|
|
53
|
+
return [...list];
|
|
54
|
+
return (0, queries_1.hitOf)(list, sub, scope);
|
|
55
|
+
};
|
|
56
|
+
exports.listHit = listHit;
|
|
57
|
+
// One field's scalar contribution: a list prints as a chain or a joined set;
|
|
58
|
+
// an object is walked one level deeper; a scalar fills the var when unset.
|
|
59
|
+
const scalarEntry = (k, v, vars, depth) => {
|
|
60
|
+
if ((0, field_1.isList)(v)) {
|
|
61
|
+
listVar(v, k, vars);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if ((0, queries_1.isObj)(v)) {
|
|
65
|
+
collectScalars(v, vars, depth + 1);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (vars[k] == null && (typeof v === "string" || typeof v === "number"))
|
|
69
|
+
vars[k] = v;
|
|
70
|
+
};
|
|
71
|
+
// Every scalar a piece carries, wherever it sits (`kind.chain.depth`), becomes a
|
|
72
|
+
// variable — a rule that measured a number can name it, and the report layer
|
|
73
|
+
// never has to know the shape of the fact it came from.
|
|
74
|
+
const collectScalars = (value, vars, depth = 0) => {
|
|
75
|
+
if (value == null || depth > 3)
|
|
76
|
+
return;
|
|
77
|
+
if (!(0, queries_1.isObj)(value) || (0, field_1.isList)(value))
|
|
78
|
+
return;
|
|
79
|
+
for (const [k, v] of Object.entries(value))
|
|
80
|
+
scalarEntry(k, v, vars, depth);
|
|
81
|
+
};
|
|
82
|
+
exports.collectScalars = collectScalars;
|
|
83
|
+
// A list of NAMED things prints as a chain: `kind.chain` is the pieces this
|
|
84
|
+
// code calls through, and a report says "…calls through {chain}…". A list of
|
|
85
|
+
// PLAIN strings is its own answer: `references.files` is the set of files a
|
|
86
|
+
// name is used in, and "move it where it is called" has to say WHERE. Never
|
|
87
|
+
// overwritten: a count already collected for a file-level report keeps its
|
|
88
|
+
// meaning.
|
|
89
|
+
const listVar = (list, key, vars) => {
|
|
90
|
+
const named = list.filter((x) => (0, queries_1.isObj)(x) && typeof x.name === "string");
|
|
91
|
+
if (named.length === list.length && named.length)
|
|
92
|
+
vars[key] = named.map((x) => String(x.name)).join(" → ");
|
|
93
|
+
const strings = list.filter((x) => typeof x === "string" && Boolean(x));
|
|
94
|
+
if (strings.length === list.length && strings.length && vars[key] == null)
|
|
95
|
+
vars[key] = strings.join(", ");
|
|
96
|
+
};
|
|
97
|
+
// A list filter is often wrapped in a QUANTIFIER (`any`/`some`/`every`/`none`):
|
|
98
|
+
// the fields the rule names live inside it, one level further down.
|
|
99
|
+
const QUANTIFIERS = new Set(["any", "some", "every", "none"]);
|
|
100
|
+
exports.QUANTIFIERS = QUANTIFIERS;
|
|
101
|
+
const branchOf = (sub) => {
|
|
102
|
+
if (!(0, queries_1.isObj)(sub))
|
|
103
|
+
return sub;
|
|
104
|
+
const keys = Object.keys(sub);
|
|
105
|
+
if (keys.length === 1 && QUANTIFIERS.has(keys[0]) && (0, queries_1.isObj)(sub[keys[0]]))
|
|
106
|
+
return sub[keys[0]];
|
|
107
|
+
return sub;
|
|
108
|
+
};
|
|
109
|
+
exports.branchOf = branchOf;
|
|
110
|
+
// `{what}` for a piece with no name of its own: what it IS and where it starts,
|
|
111
|
+
// so the sentence can still be followed to a line.
|
|
112
|
+
const describePiece = (c) => {
|
|
113
|
+
const line = c.lines?.[0] ?? 1;
|
|
114
|
+
const tag = c.css?.templates?.[0]?.tag ?? null;
|
|
115
|
+
return tag ? `the ${tag} block at line ${line}` : `the code at line ${line}`;
|
|
116
|
+
};
|
|
117
|
+
exports.describePiece = describePiece;
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Arch, RawArch } from "./entities/architecture";
|
|
2
|
+
import type { RuleOptions } from "./config-options";
|
|
3
|
+
type ArchSections = Pick<RawArch, "nodes" | "codeRoles" | "invariants" | "aliases" | "report">;
|
|
4
|
+
declare const buildArchitecture: (raw: ArchSections | null | undefined) => Arch;
|
|
5
|
+
declare const loadArchitecture: (config: string | RawArch | RuleOptions | null | undefined) => Arch;
|
|
6
|
+
declare const main: (argv: string[]) => number;
|
|
7
|
+
export { main, loadArchitecture, buildArchitecture };
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.buildArchitecture = exports.loadArchitecture = exports.main = void 0;
|
|
27
|
+
const fs = __importStar(require("node:fs"));
|
|
28
|
+
const path = __importStar(require("node:path"));
|
|
29
|
+
const remeda_1 = require("remeda");
|
|
30
|
+
const tree_1 = require("./entities/tree");
|
|
31
|
+
const roles_1 = require("./code-roles/roles");
|
|
32
|
+
const normalize_1 = require("./invariants/normalize");
|
|
33
|
+
const aliases_1 = require("./aliases");
|
|
34
|
+
const pipeline_1 = require("./pipeline");
|
|
35
|
+
const pattern_1 = require("./utils/pattern");
|
|
36
|
+
const cli_report_1 = require("./report/cli-report");
|
|
37
|
+
const config_1 = require("./config");
|
|
38
|
+
const notices_1 = require("./report/notices");
|
|
39
|
+
const user_report_1 = require("./report/user-report");
|
|
40
|
+
const imports_1 = require("./utils/imports");
|
|
41
|
+
const files_1 = require("./utils/files");
|
|
42
|
+
const args_1 = require("./args");
|
|
43
|
+
const keyed_1 = require("./utils/keyed");
|
|
44
|
+
const field_1 = require("./utils/field");
|
|
45
|
+
const configError = __importStar(require("./report/configErrors"));
|
|
46
|
+
const yaml = __importStar(require("js-yaml"));
|
|
47
|
+
// The report layer owns its payload; the input contract is the ONE entity
|
|
48
|
+
// (`entities/overview`), so the rule path and the CLI hand it the same shape.
|
|
49
|
+
const collectOverviewData = user_report_1.collectOverviewData;
|
|
50
|
+
const writeOverview = user_report_1.writeOverview;
|
|
51
|
+
// The nodes section as a list — the shared list-or-map walk, the same one the
|
|
52
|
+
// tree builder reads.
|
|
53
|
+
const nodesOf = (raw) => (0, keyed_1.keyedDefs)(raw.nodes).filter((n) => n != null);
|
|
54
|
+
// Every invariant id must be unique, and every role a node names must exist —
|
|
55
|
+
// a typo would otherwise give a home to a role nothing ever infers.
|
|
56
|
+
const checkBuilt = (arch) => {
|
|
57
|
+
const ids = arch.invariants.map((i) => i.id);
|
|
58
|
+
if (new Set(ids).size !== ids.length)
|
|
59
|
+
throw configError.duplicateInvariantIds(ids);
|
|
60
|
+
const known = new Set(Object.keys(arch.codeRoles));
|
|
61
|
+
for (const role of Object.keys(arch.nodes.roleHomes)) {
|
|
62
|
+
if (!known.has(role))
|
|
63
|
+
throw configError.nodeRoleUnknown(role);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const buildArchitecture = (raw) => {
|
|
67
|
+
if (!(0, field_1.isObj)(raw))
|
|
68
|
+
throw configError.notAnObject();
|
|
69
|
+
const config = raw;
|
|
70
|
+
if (!nodesOf(config).length)
|
|
71
|
+
throw configError.withoutNodes();
|
|
72
|
+
const codeRoles = config.codeRoles ? (0, roles_1.normalizeCodeRoles)(config.codeRoles) : {};
|
|
73
|
+
const tree = (0, tree_1.buildTree)(config.nodes);
|
|
74
|
+
const invariants = (0, remeda_1.pipe)(config.invariants ?? [], (0, remeda_1.map)((i) => (0, normalize_1.normalizeInvariant)(i, new Set(Object.keys(codeRoles)))));
|
|
75
|
+
const arch = {
|
|
76
|
+
nodes: tree,
|
|
77
|
+
codeRoles,
|
|
78
|
+
invariants,
|
|
79
|
+
aliases: (0, aliases_1.normalizeAliases)(config.aliases ?? {}),
|
|
80
|
+
// The config as written, for consumers that show it back (the overview).
|
|
81
|
+
raw: config,
|
|
82
|
+
};
|
|
83
|
+
checkBuilt(arch);
|
|
84
|
+
return arch;
|
|
85
|
+
};
|
|
86
|
+
exports.buildArchitecture = buildArchitecture;
|
|
87
|
+
// An architecture file is DATA — YAML or JSON. JSON is valid YAML, so the
|
|
88
|
+
// extension decides nothing and there is ONE parser. The parser's answer is
|
|
89
|
+
// plain data; the typed view is taken here at the boundary (the same pattern
|
|
90
|
+
// the tree uses for the structure renders), and `buildArchitecture` validates
|
|
91
|
+
// it — a non-object is not a config, and says so.
|
|
92
|
+
const parseArchitecture = (text, file) => {
|
|
93
|
+
try {
|
|
94
|
+
const loaded = yaml.load(text, { filename: file });
|
|
95
|
+
return loaded;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
const e = error;
|
|
99
|
+
throw configError.unparseable({ reason: describeParse(e) });
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
// Where the file itself is wrong — a missing comma, a tab used as indentation.
|
|
103
|
+
// The parser knows the position; the reader needs it, so it travels in the
|
|
104
|
+
// sentence.
|
|
105
|
+
const describeParse = (error) => {
|
|
106
|
+
const reason = String(error.reason ?? error.message ?? error).split("\n")[0];
|
|
107
|
+
const at = error.mark ? ` (line ${error.mark.line + 1}, column ${error.mark.column + 1})` : "";
|
|
108
|
+
return `${reason}${at}`;
|
|
109
|
+
};
|
|
110
|
+
// Every failure between "here is a path" and "here is a usable architecture"
|
|
111
|
+
// happens inside ONE call, so the file is named in ONE place: the sentence says
|
|
112
|
+
// what the key claims, but only the path says which architecture to open. A
|
|
113
|
+
// config error stays a sentence; a bug keeps its stack and never pretends to be
|
|
114
|
+
// about the config.
|
|
115
|
+
const naming = (file, run) => {
|
|
116
|
+
try {
|
|
117
|
+
return run();
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
const e = error;
|
|
121
|
+
if (e.isConfigError)
|
|
122
|
+
e.message = `${e.message}\n in ${file}`;
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const readConfigText = (file) => {
|
|
127
|
+
try {
|
|
128
|
+
return fs.readFileSync(file, "utf8");
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
const e = error;
|
|
132
|
+
throw configError.unreadable({ code: e.code });
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
// A config may arrive as a path, as the raw object, or as the rule's own
|
|
136
|
+
// options bag (which carries the architecture's sections beside the tool's).
|
|
137
|
+
// All three are read here: a `file` key names a path to load; anything else is
|
|
138
|
+
// built from the sections it carries. The sections view is taken at this
|
|
139
|
+
// boundary — the record's keys are the data the normalizers validate.
|
|
140
|
+
const loadArchitecture = (config) => {
|
|
141
|
+
if ((0, field_1.isObj)(config) && typeof config.file === "string")
|
|
142
|
+
return loadArchitecture(config.file);
|
|
143
|
+
if (typeof config !== "string") {
|
|
144
|
+
const sections = config ?? {};
|
|
145
|
+
return buildArchitecture(sections);
|
|
146
|
+
}
|
|
147
|
+
const file = path.resolve(process.cwd(), config);
|
|
148
|
+
return naming(file, () => buildArchitecture(parseArchitecture(readConfigText(file), file)));
|
|
149
|
+
};
|
|
150
|
+
exports.loadArchitecture = loadArchitecture;
|
|
151
|
+
// The files a run checks: `--files` restricts the scan to the given files
|
|
152
|
+
// (agent stop-hooks lint only changed files); otherwise every scanned file.
|
|
153
|
+
const collectedFiles = (repoRoot, scanned, files) => {
|
|
154
|
+
if (files.length) {
|
|
155
|
+
return (0, remeda_1.pipe)(files, (0, remeda_1.map)((rel) => path.resolve(repoRoot, rel)), (0, remeda_1.filter)((abs) => fs.existsSync(abs) && fs.statSync(abs).isFile()), (0, remeda_1.map)((abs) => ({ abs, rel: (0, imports_1.toRel)(repoRoot, abs) })));
|
|
156
|
+
}
|
|
157
|
+
return (0, remeda_1.pipe)(scanned, (0, remeda_1.map)((abs) => ({ abs, rel: (0, imports_1.toRel)(repoRoot, abs) })));
|
|
158
|
+
};
|
|
159
|
+
// The run's findings: every checked file, one shared dedupe store.
|
|
160
|
+
const runFindings = (files, run) => {
|
|
161
|
+
const dedupe = new Map();
|
|
162
|
+
const findings = (0, remeda_1.pipe)(files, (0, remeda_1.filter)((f) => run.shouldCheck(f.rel)), (0, remeda_1.flatMap)((f) => (0, pipeline_1.checkFile)(f.abs, run.arch, run.project, run.repoFiles, dedupe)));
|
|
163
|
+
const orphans = (0, remeda_1.pipe)(files, (0, remeda_1.filter)((f) => !run.shouldCheck(f.rel)), (0, remeda_1.map)((f) => f.rel), (r) => [...r].sort());
|
|
164
|
+
return { findings, orphans };
|
|
165
|
+
};
|
|
166
|
+
const writeOverviewReport = (args, run) => {
|
|
167
|
+
const data = collectOverviewData({
|
|
168
|
+
arch: run.arch,
|
|
169
|
+
findings: run.findings,
|
|
170
|
+
orphans: run.orphans,
|
|
171
|
+
files: run.repoFiles,
|
|
172
|
+
repoFiles: run.repoFiles,
|
|
173
|
+
repoRoot: run.repoRoot,
|
|
174
|
+
architecturePath: typeof run.configPath === "string" ? run.configPath : null,
|
|
175
|
+
project: run.project,
|
|
176
|
+
});
|
|
177
|
+
const written = writeOverview(data, path.resolve(run.repoRoot, args.overview));
|
|
178
|
+
console.log(`wrote ${path.relative(run.repoRoot, written.path)} (${run.findings.length} findings, ${Math.round(written.bytes / 1024)} kB)`);
|
|
179
|
+
const caveats = (0, cli_report_1.renderNotices)((0, notices_1.takeNotices)());
|
|
180
|
+
if (caveats)
|
|
181
|
+
console.log(caveats);
|
|
182
|
+
return args.check && run.findings.length > 0 ? 1 : 0;
|
|
183
|
+
};
|
|
184
|
+
const writeTextReport = (args, run) => {
|
|
185
|
+
const rewritten = (0, cli_report_1.renderReport)(run.findings, run.repoRoot, { orphans: run.orphans });
|
|
186
|
+
const text = `${rewritten}${(0, cli_report_1.renderNotices)((0, notices_1.takeNotices)())}`;
|
|
187
|
+
if (args.out) {
|
|
188
|
+
fs.writeFileSync(args.out, text);
|
|
189
|
+
console.log(`wrote ${args.out} (${run.findings.length} findings)`);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
console.log(text);
|
|
193
|
+
}
|
|
194
|
+
return args.check && run.findings.length > 0 ? 1 : 0;
|
|
195
|
+
};
|
|
196
|
+
const main = (argv) => {
|
|
197
|
+
const args = (0, args_1.parseArgs)(argv);
|
|
198
|
+
if (args.help) {
|
|
199
|
+
console.log("usage: follow-architecture [--config <path>] [--ext <.ext>]... [--ignore <glob>]... [--ignore-dir <name>]... [--files <path>]... [--out <path>] [--overview [path]] [--check]");
|
|
200
|
+
return 0;
|
|
201
|
+
}
|
|
202
|
+
const cwd = path.resolve(args.cwd ?? process.cwd());
|
|
203
|
+
// The repo starts where the architecture file is — the SAME anchor the ESLint
|
|
204
|
+
// rule uses — so `--config ../arch.yaml` scans the repo that file describes.
|
|
205
|
+
// An explicit `--cwd` still decides where the scan begins.
|
|
206
|
+
const configPath = typeof args.config === "string" ? path.resolve(cwd, args.config) : args.config;
|
|
207
|
+
const repoRoot = typeof configPath === "string" && args.cwd == null ? path.dirname(configPath) : cwd;
|
|
208
|
+
const arch = loadArchitecture(configPath);
|
|
209
|
+
arch.repoRoot = repoRoot;
|
|
210
|
+
const shouldCheck = (0, tree_1.matchers)(arch);
|
|
211
|
+
// Scan scope is the TOOL's: its defaults, extended by `--ext`, never by the
|
|
212
|
+
// architecture (which describes code, not how to find it).
|
|
213
|
+
const exts = [...new Set([...pattern_1.DEFAULT_EXTS, ...(args.ext ?? [])])];
|
|
214
|
+
const ignoreDirs = [...new Set([...pattern_1.DEFAULT_IGNORE_DIRS, ...(args.ignoreDir ?? [])])];
|
|
215
|
+
// ONE walk: the scan list, the repo file list and the ts-morph project are the
|
|
216
|
+
// same set of files. `references` asks who uses a name ACROSS files.
|
|
217
|
+
const scanned = (0, files_1.collectFiles)(repoRoot, { exts, ignoreDirs, ignoreGlobs: args.ignore ?? [] });
|
|
218
|
+
const project = (0, config_1.openProject)(repoRoot, scanned, arch);
|
|
219
|
+
const collected = collectedFiles(repoRoot, scanned, args.files);
|
|
220
|
+
// `repoFiles` is the FULL repo file list (for import resolution and folder
|
|
221
|
+
// facts), even when `--files` restricts which files are CHECKED.
|
|
222
|
+
const repoFiles = (0, remeda_1.pipe)(scanned, (0, remeda_1.map)((abs) => (0, imports_1.toRel)(repoRoot, abs)));
|
|
223
|
+
const { findings, orphans } = runFindings(collected, { arch, project, repoFiles, shouldCheck });
|
|
224
|
+
const run = { arch, findings, orphans, repoFiles, repoRoot, configPath, project };
|
|
225
|
+
if (args.overview)
|
|
226
|
+
return writeOverviewReport({ overview: args.overview, check: args.check }, run);
|
|
227
|
+
return writeTextReport({ out: args.out, check: args.check }, { findings, orphans, repoRoot });
|
|
228
|
+
};
|
|
229
|
+
exports.main = main;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rolesOfChild = void 0;
|
|
4
|
+
const rolesOfChild = (arch, child) => {
|
|
5
|
+
if (!child)
|
|
6
|
+
return [];
|
|
7
|
+
if (child.roles?.length)
|
|
8
|
+
return child.roles;
|
|
9
|
+
const target = child.nodeSlug ? arch.nodes.bySlug[child.nodeSlug] : null;
|
|
10
|
+
return target?.roles ?? [];
|
|
11
|
+
};
|
|
12
|
+
exports.rolesOfChild = rolesOfChild;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Arch, ArchChild, ArchNode, ArchVariant, RawChild, RawNode } from "../entities/architecture";
|
|
2
|
+
type FolderContents = {
|
|
3
|
+
present: Set<string>;
|
|
4
|
+
declared: ArchChild[];
|
|
5
|
+
anyDeclared: boolean;
|
|
6
|
+
missing: ArchChild[];
|
|
7
|
+
};
|
|
8
|
+
declare const folderContents: (owner: ArchNode, folder: string, repoFiles: string[] | null | undefined) => FolderContents;
|
|
9
|
+
declare const ancestorChain: (node: ArchNode, arch: Arch) => ArchNode[];
|
|
10
|
+
type ConcreteFolder = (path: string, rel: string | null) => string | null | undefined;
|
|
11
|
+
type RequiredContext = {
|
|
12
|
+
repoFiles: string[] | null | undefined;
|
|
13
|
+
concreteFolder: ConcreteFolder;
|
|
14
|
+
};
|
|
15
|
+
declare const missingRequiredChild: (node: ArchNode, arch: Arch, rel: string, ctx: RequiredContext) => boolean;
|
|
16
|
+
declare const nodePathRe: (template: string) => RegExp;
|
|
17
|
+
type PrefixMatcher = Pick<ArchVariant, "re" | "names" | "literalLen" | "isFile">;
|
|
18
|
+
declare const nodePrefixRe: (template: string) => PrefixMatcher;
|
|
19
|
+
declare const rolesOf: (spec: {
|
|
20
|
+
role?: string | string[] | null;
|
|
21
|
+
} | null | undefined) => string[];
|
|
22
|
+
declare const compileChild: (name: RawChild) => ArchChild;
|
|
23
|
+
export { nodePathRe, nodePrefixRe, compileChild, folderContents, missingRequiredChild, ancestorChain, rolesOf };
|
|
24
|
+
export type { ConcreteFolder };
|
|
25
|
+
export type { RawNode, RawChild };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rolesOf = exports.ancestorChain = exports.missingRequiredChild = exports.folderContents = exports.compileChild = exports.nodePrefixRe = exports.nodePathRe = void 0;
|
|
4
|
+
// Node child handling: a child is either a plain string name or a
|
|
5
|
+
// `{ kind, name? }` matcher. `compileChild` turns a name into a regex with
|
|
6
|
+
// capture groups; `nodePrefixRe` turns a node path into a prefix matcher.
|
|
7
|
+
// Both live here because they are node-specific, not shared machinery.
|
|
8
|
+
const pattern_1 = require("../utils/pattern");
|
|
9
|
+
// A regex that never matches: the placeholder `re` of a `{ node }` child before
|
|
10
|
+
// `buildTree` gives it the referenced node's own pattern. It is always replaced
|
|
11
|
+
// before anything reads it, but the type stays a `RegExp`.
|
|
12
|
+
const DETACHED = /(?!)/;
|
|
13
|
+
const folderContents = (owner, folder, repoFiles) => {
|
|
14
|
+
const present = new Set((repoFiles ?? []).filter((f) => f.startsWith(`${folder}/`)).map((f) => f.slice(folder.length + 1).split("/")[0]));
|
|
15
|
+
const declared = owner.children ?? [];
|
|
16
|
+
const has = (child) => [...present].some((name) => child.re.test(name));
|
|
17
|
+
return {
|
|
18
|
+
present,
|
|
19
|
+
declared,
|
|
20
|
+
anyDeclared: declared.some(has),
|
|
21
|
+
missing: declared.filter((c) => c.required).filter((c) => !has(c)),
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.folderContents = folderContents;
|
|
25
|
+
// The node itself plus every declared parent, nearest first. A `required` child
|
|
26
|
+
// is declared on the folder that owns it, which is usually an ancestor of the
|
|
27
|
+
// deepest node that matched the file.
|
|
28
|
+
const ancestorChain = (node, arch) => {
|
|
29
|
+
const chain = [];
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
for (let cur = node; cur && !seen.has(cur.slug); cur = cur.parents.length === 1 ? arch.nodes.bySlug[cur.parents[0] ?? ""] ?? null : null) {
|
|
32
|
+
seen.add(cur.slug);
|
|
33
|
+
chain.push(cur);
|
|
34
|
+
}
|
|
35
|
+
return chain;
|
|
36
|
+
};
|
|
37
|
+
exports.ancestorChain = ancestorChain;
|
|
38
|
+
const missingRequiredChild = (node, arch, rel, ctx) => {
|
|
39
|
+
for (const owner of ancestorChain(node, arch)) {
|
|
40
|
+
const required = (owner.children ?? []).filter((c) => c.required);
|
|
41
|
+
if (!required.length)
|
|
42
|
+
continue;
|
|
43
|
+
const folder = ctx.concreteFolder(owner.path, rel);
|
|
44
|
+
if (!folder)
|
|
45
|
+
continue;
|
|
46
|
+
if (folderContents(owner, folder, ctx.repoFiles).missing.length)
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
};
|
|
51
|
+
exports.missingRequiredChild = missingRequiredChild;
|
|
52
|
+
// The regex a node's OWN path matches as a folder — `apps/backend/{kebab-case}`
|
|
53
|
+
// → `(?/apps/backend/([^/]+)$`. This is the question "is this folder one of the
|
|
54
|
+
// places this node declares?", asked about the folder itself, without inventing
|
|
55
|
+
// a file name to stand inside it.
|
|
56
|
+
const nodePathRe = (template) => (template === "." ? /^([^/]+)$/ : (0, pattern_1.compilePattern)(template).re);
|
|
57
|
+
exports.nodePathRe = nodePathRe;
|
|
58
|
+
const nodePrefixRe = (template) => {
|
|
59
|
+
if (template === ".")
|
|
60
|
+
return { re: /^([^/]+)(?:\/(.*))?$/, names: [], literalLen: 0, isFile: false };
|
|
61
|
+
const { body, names } = (0, pattern_1.patternBody)(template);
|
|
62
|
+
// A node whose path ends in a file extension is a FILE node: it matches
|
|
63
|
+
// exactly that file, not a folder prefix. `literalLen` is the number of
|
|
64
|
+
// fixed (non-placeholder) characters in the path — the specificity used
|
|
65
|
+
// to rank matches (longer literal prefix wins).
|
|
66
|
+
const isFile = /\.[A-Za-z0-9]+$/.test(String(template).split("/").pop() ?? "");
|
|
67
|
+
const literalLen = String(template).replace(pattern_1.PLACEHOLDER, "").length;
|
|
68
|
+
if (isFile)
|
|
69
|
+
return { re: new RegExp(`^${body}$`), names, literalLen, isFile: true };
|
|
70
|
+
return { re: new RegExp(`^${body}/([^/]+)(?:/(.*))?$`), names, literalLen, isFile: false };
|
|
71
|
+
};
|
|
72
|
+
exports.nodePrefixRe = nodePrefixRe;
|
|
73
|
+
// A child may declare which codeRole(s) live in it: one role, several roles (a
|
|
74
|
+
// file holding both a model and its types), or none. The NODE says where code
|
|
75
|
+
// lives — the codeRole says what code is, never where it goes.
|
|
76
|
+
const rolesOf = (spec) => {
|
|
77
|
+
const raw = spec?.role;
|
|
78
|
+
if (raw == null)
|
|
79
|
+
return [];
|
|
80
|
+
return (Array.isArray(raw) ? raw : [raw]).map(String).filter(Boolean);
|
|
81
|
+
};
|
|
82
|
+
exports.rolesOf = rolesOf;
|
|
83
|
+
// `{ node: slug }` — the child IS another declared node.
|
|
84
|
+
const referencedChild = (spec) => ({ nodeSlug: String(spec.node), name: null, re: DETACHED, captures: [], folder: true, required: Boolean(spec.required), forbidden: Boolean(spec.forbidden), query: null, report: spec.report ?? null, roles: rolesOf(spec) });
|
|
85
|
+
// A child named by a pattern: a FILE child (extension) or a FOLDER child.
|
|
86
|
+
const childOf = (rawName, spec) => {
|
|
87
|
+
const { body, names: captures } = (0, pattern_1.patternBody)(rawName);
|
|
88
|
+
const folder = !/\.[A-Za-z0-9]+$/.test(rawName.split("/").pop() ?? "");
|
|
89
|
+
return {
|
|
90
|
+
name: rawName,
|
|
91
|
+
re: new RegExp(`^${body}$`),
|
|
92
|
+
captures,
|
|
93
|
+
folder,
|
|
94
|
+
required: Boolean(spec?.required),
|
|
95
|
+
forbidden: Boolean(spec?.forbidden),
|
|
96
|
+
nodeSlug: null,
|
|
97
|
+
// A child may be recognised by a QUERY over the file's facts instead of
|
|
98
|
+
// (only) by its name — finally.js uses it to route a file that matches
|
|
99
|
+
// the child's query but sits elsewhere.
|
|
100
|
+
query: spec?.query ?? null,
|
|
101
|
+
report: spec?.report ?? null,
|
|
102
|
+
roles: rolesOf(spec),
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
const compileChild = (name) => {
|
|
106
|
+
// A child is either a bare name or a spec `{ name?, node?, role?, required?, forbidden?, query?, report? }`.
|
|
107
|
+
const spec = name && typeof name === "object" ? name : null;
|
|
108
|
+
if (spec?.node)
|
|
109
|
+
return referencedChild(spec);
|
|
110
|
+
return childOf(String(spec ? spec.name : name), spec);
|
|
111
|
+
};
|
|
112
|
+
exports.compileChild = compileChild;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ArchNode } from "../../entities/architecture";
|
|
2
|
+
import type { FileContext } from "../../entities/context";
|
|
3
|
+
import type { Finding, FindingFrom } from "../../entities/findings";
|
|
4
|
+
import type { Violation } from "./violation";
|
|
5
|
+
declare const emitFindings: (violations: Violation[], ctx: FileContext, node: ArchNode, out: Finding[], findingFrom: FindingFrom) => void;
|
|
6
|
+
export { emitFindings };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitFindings = void 0;
|
|
4
|
+
// A `declare` violation on a line that also carries a `call` to the same
|
|
5
|
+
// target is the same decision seen twice — the call's sentence answers for it.
|
|
6
|
+
const withoutDeclareDuplicates = (violations) => {
|
|
7
|
+
const called = new Set(violations.filter((v) => v.kind === "call").map((v) => `${v.line}|${v.targetPath}`));
|
|
8
|
+
return violations.filter((v) => v.kind !== "declare" || !called.has(`${v.line}|${v.targetPath}`));
|
|
9
|
+
};
|
|
10
|
+
// Same role, several functions: one sentence naming all of them.
|
|
11
|
+
const roleSentence = (v) => {
|
|
12
|
+
const names = (v.names ?? []).filter(Boolean);
|
|
13
|
+
const shown = names.slice(0, 4).map((n) => `\`${n}\``).join(", ");
|
|
14
|
+
const rest = names.length > 4 ? ` and ${names.length - 4} more` : "";
|
|
15
|
+
const tail = v.where ? `they belong in ${v.where}` : `${v.owning ?? "this folder"} declares no home for a \`${v.role}\``;
|
|
16
|
+
const move = v.where ? `Move ${shown}${rest} to ${v.where}.` : null;
|
|
17
|
+
return { ...v, fix: move, text: `This file declares \`${v.role}\` functions (${shown}${rest}): ${tail}.` };
|
|
18
|
+
};
|
|
19
|
+
// One decision per key: a role's many functions merge into one sentence; any
|
|
20
|
+
// other violation is its own decision, keyed by its text.
|
|
21
|
+
const decisionsOf = (violations) => {
|
|
22
|
+
const byText = new Map();
|
|
23
|
+
for (const v of violations) {
|
|
24
|
+
const key = v.role ? `role:${v.role}` : v.text;
|
|
25
|
+
const names = (v.names ?? []).filter(Boolean);
|
|
26
|
+
if (v.role && names.length > 1 && !byText.has(key)) {
|
|
27
|
+
byText.set(key, roleSentence(v));
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (!byText.has(key))
|
|
31
|
+
byText.set(key, v);
|
|
32
|
+
}
|
|
33
|
+
return [...byText.values()].sort((a, b) => a.line - b.line);
|
|
34
|
+
};
|
|
35
|
+
// The structured evidence a relation finding carries — the token the report
|
|
36
|
+
// draws, with the target it names.
|
|
37
|
+
const evidenceOf = (v) => v.kind && v.targetNode
|
|
38
|
+
? { violations: [{ kind: v.kind, targetNode: v.targetNode, targetPath: v.targetPath ?? null, line: v.line, destination: v.destination ?? null, token: v.token ?? null }] }
|
|
39
|
+
: {};
|
|
40
|
+
const emitFindings = (...args) => {
|
|
41
|
+
const [violations, ctx, node, out, findingFrom] = args;
|
|
42
|
+
const kept = withoutDeclareDuplicates(violations);
|
|
43
|
+
violations.length = 0;
|
|
44
|
+
violations.push(...kept);
|
|
45
|
+
if (violations.length === 0)
|
|
46
|
+
return;
|
|
47
|
+
for (const v of decisionsOf(violations)) {
|
|
48
|
+
out.push(findingFrom({
|
|
49
|
+
report: { message: v.text, fix: v.fix ?? null, code: v.ask ?? null },
|
|
50
|
+
line: v.line,
|
|
51
|
+
data: evidenceOf(v),
|
|
52
|
+
}, "finally-follow-architecture", node.slug, `finally:${node.slug}:${ctx.rel}:${v.kind ?? "misc"}:${v.targetNode ?? "-"}:${v.line}`, { path: ctx.rel, node: node.slug, what: ctx.rel }));
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
exports.emitFindings = emitFindings;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EDGE_FACTS } from "../../entities/kinds";
|
|
2
|
+
import { fitsRole } from "./roles";
|
|
3
|
+
import type { Arch, ArchNode } from "../../entities/architecture";
|
|
4
|
+
import type { FileContext } from "../../entities/context";
|
|
5
|
+
import type { Finding, FindingFrom } from "../../entities/findings";
|
|
6
|
+
declare const checkFinally: (ctx: FileContext, arch: Arch, out: Finding[], findingFrom: FindingFrom) => void;
|
|
7
|
+
declare const __exported_missingRequiredChild: (node: ArchNode, arch: Arch, rel: string, files: string[] | null | undefined) => boolean;
|
|
8
|
+
export { checkFinally, fitsRole, __exported_missingRequiredChild as missingRequiredChild, EDGE_FACTS };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EDGE_FACTS = exports.missingRequiredChild = exports.fitsRole = exports.checkFinally = void 0;
|
|
4
|
+
// finally-follow-architecture: the built-in structure rule. Four questions,
|
|
5
|
+
// one module each, no wording (that lives in report/errorTypes).
|
|
6
|
+
const location_1 = require("../../entities/location");
|
|
7
|
+
const tree_1 = require("../../entities/tree");
|
|
8
|
+
const children_1 = require("../children");
|
|
9
|
+
const kinds_1 = require("../../entities/kinds");
|
|
10
|
+
Object.defineProperty(exports, "EDGE_FACTS", { enumerable: true, get: function () { return kinds_1.EDGE_FACTS; } });
|
|
11
|
+
const roles_1 = require("./roles");
|
|
12
|
+
Object.defineProperty(exports, "fitsRole", { enumerable: true, get: function () { return roles_1.fitsRole; } });
|
|
13
|
+
const required_1 = require("./required");
|
|
14
|
+
const queries_1 = require("./queries");
|
|
15
|
+
const relations_1 = require("./relations");
|
|
16
|
+
const emit_1 = require("./emit");
|
|
17
|
+
// The node's own structure questions, asked of the file that matched it: the
|
|
18
|
+
// required children, the child queries, the relations — then one finding per
|
|
19
|
+
// decision.
|
|
20
|
+
const checkNode = (ctx, node, out, findingFrom) => {
|
|
21
|
+
const violations = [];
|
|
22
|
+
(0, required_1.checkRequiredChildren)(ctx, node, out, findingFrom);
|
|
23
|
+
(0, queries_1.checkChildQueries)(ctx, node, violations);
|
|
24
|
+
(0, relations_1.checkRelations)(ctx, ctx.arch, violations);
|
|
25
|
+
(0, emit_1.emitFindings)(violations, ctx, node, out, findingFrom);
|
|
26
|
+
};
|
|
27
|
+
const checkFinally = (ctx, arch, out, findingFrom) => {
|
|
28
|
+
const match = (0, tree_1.deepestMatch)(ctx.rel, arch);
|
|
29
|
+
if (!match)
|
|
30
|
+
return;
|
|
31
|
+
checkNode(ctx, match.node, out, findingFrom);
|
|
32
|
+
};
|
|
33
|
+
exports.checkFinally = checkFinally;
|
|
34
|
+
const __exported_missingRequiredChild = (node, arch, rel, files) => (0, children_1.missingRequiredChild)(node, arch, rel, { repoFiles: files, concreteFolder: location_1.fillTemplate });
|
|
35
|
+
exports.missingRequiredChild = __exported_missingRequiredChild;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ArchNode } from "../../entities/architecture";
|
|
2
|
+
import type { FileContext } from "../../entities/context";
|
|
3
|
+
import type { Violation } from "./violation";
|
|
4
|
+
declare const checkChildQueries: (ctx: FileContext, node: ArchNode, violations: Violation[]) => void;
|
|
5
|
+
export { checkChildQueries };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkChildQueries = void 0;
|
|
4
|
+
// A file that matches a declared child's query but sits outside it.
|
|
5
|
+
const queries_1 = require("../../entities/queries");
|
|
6
|
+
const children_1 = require("../children");
|
|
7
|
+
const location_1 = require("../../entities/location");
|
|
8
|
+
const checkChildQueries = (ctx, node, violations) => {
|
|
9
|
+
for (const child of node.children) {
|
|
10
|
+
if (!child.query)
|
|
11
|
+
continue;
|
|
12
|
+
if (!(0, queries_1.matches)(ctx.facts, child.query))
|
|
13
|
+
continue;
|
|
14
|
+
const childPath = node.path === "." ? child.name : `${node.path}/${child.name}`;
|
|
15
|
+
const { re } = (0, children_1.nodePrefixRe)(childPath ?? "");
|
|
16
|
+
if (re.test(ctx.rel))
|
|
17
|
+
continue; // already in the right place
|
|
18
|
+
const where = (0, location_1.fillTemplate)(childPath, ctx.rel);
|
|
19
|
+
violations.push({ line: 1, text: `this file matches the query of node \`${child.slug ?? child.name}\` and belong in \`${where}\`` });
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
exports.checkChildQueries = checkChildQueries;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Arch, ActionDef } from "../../entities/architecture";
|
|
2
|
+
import type { FileContext } from "../../entities/context";
|
|
3
|
+
import type { Violation } from "./violation";
|
|
4
|
+
declare const checkAccessorImports: (ctx: FileContext, arch: Arch, declared: Map<string, Map<string, ActionDef>>, violations: Violation[]) => void;
|
|
5
|
+
export { checkAccessorImports };
|