@md-code/follow-architecture 0.1.1 → 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 +584 -141
- 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 +61 -18
- 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 -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,149 @@
|
|
|
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.attachCallDepth = void 0;
|
|
27
|
+
// How many calls deep a piece of code goes before somebody else does the work.
|
|
28
|
+
//
|
|
29
|
+
// A piece that calls an imported function which calls another which calls
|
|
30
|
+
// another is not readable at the call site: nobody can see where the state is
|
|
31
|
+
// finally changed, and no role rule can point at the place that changed it.
|
|
32
|
+
// The chain is what this fact measures — `toggleLineAction → applyDecorations →
|
|
33
|
+
// applyActiveEditorDecorations → …` is a depth of 5, and a rule may refuse it.
|
|
34
|
+
//
|
|
35
|
+
// The walk follows the facts the AST already produces: a bare-identifier call
|
|
36
|
+
// carries `target: { path, name }`, so the next piece is found by parsing that
|
|
37
|
+
// module and looking for the name. Files are parsed once per run and every
|
|
38
|
+
// (file, name) pair is memoised, so a chain is walked once however often it is
|
|
39
|
+
// asked about. A cycle stops the walk (a recursive helper is not "deeper").
|
|
40
|
+
const fs = __importStar(require("node:fs"));
|
|
41
|
+
const path = __importStar(require("node:path"));
|
|
42
|
+
const index_1 = require("./index");
|
|
43
|
+
const frameworks_1 = require("../../frameworks");
|
|
44
|
+
const notices_1 = require("../../report/notices");
|
|
45
|
+
const try_read_1 = require("../../utils/try-read");
|
|
46
|
+
const reason_1 = require("../../utils/reason");
|
|
47
|
+
// A link's target: an imported name names its module (followed only when the
|
|
48
|
+
// module is a repo file); a local name is walked in this file. A link back to
|
|
49
|
+
// the piece itself is not a step.
|
|
50
|
+
const follow = (link, at, ctx, stack) => {
|
|
51
|
+
if (link.module)
|
|
52
|
+
return (ctx.repoFiles ?? []).includes(link.module) ? depthOf(link.module, link.name, ctx, stack) : null;
|
|
53
|
+
if (at.local.has(link.name) && link.name !== at.name)
|
|
54
|
+
return depthOf(at.rel, link.name, ctx, stack);
|
|
55
|
+
return null;
|
|
56
|
+
};
|
|
57
|
+
// Where a CALL leads next: an imported symbol names its module; otherwise the
|
|
58
|
+
// invoked member is followed when it names a piece in this file — a bare call
|
|
59
|
+
// (`f()`) and a member call (`new B().n()`, `this.step()`) are both ways one
|
|
60
|
+
// piece hands work to another.
|
|
61
|
+
const nextOf = (call, at, ctx, stack) => follow({ name: call.target?.path ? (call.target.name ?? "") : (call.action ?? ""), module: call.target?.path ?? null }, at, ctx, stack);
|
|
62
|
+
// The longest chain among everything a piece hands work to: the calls it makes
|
|
63
|
+
// and the components it renders. A framework that reads markup supplies its
|
|
64
|
+
// links as facts (`framework.links`); the walk needs no framework of its own.
|
|
65
|
+
const deepestLink = (piece, at, ctx, stack) => {
|
|
66
|
+
let best = { depth: 0, chain: [] };
|
|
67
|
+
for (const call of piece.calls ?? []) {
|
|
68
|
+
const next = nextOf(call, at, ctx, stack);
|
|
69
|
+
if (next && next.depth > best.depth)
|
|
70
|
+
best = next;
|
|
71
|
+
}
|
|
72
|
+
for (const link of piece.framework?.links ?? []) {
|
|
73
|
+
const next = follow(link, at, ctx, stack);
|
|
74
|
+
if (next && next.depth > best.depth)
|
|
75
|
+
best = next;
|
|
76
|
+
}
|
|
77
|
+
return best;
|
|
78
|
+
};
|
|
79
|
+
const depthOf = (rel, name, ctx, stack) => {
|
|
80
|
+
const key = `${rel}#${name}`;
|
|
81
|
+
const memo = ctx.cache?.memo.get(key);
|
|
82
|
+
if (memo)
|
|
83
|
+
return memo;
|
|
84
|
+
if (stack.has(key))
|
|
85
|
+
return { depth: 0, chain: [] };
|
|
86
|
+
stack.add(key);
|
|
87
|
+
// ONE name may be several candidates — a `const f = () => …` is the variable
|
|
88
|
+
// AND the arrow — and only the arrow carries the calls, so every candidate of
|
|
89
|
+
// that name is walked and the longest chain wins.
|
|
90
|
+
const candidates = candidatesIn(rel, ctx);
|
|
91
|
+
const pieces = candidates.filter((c) => c.name === name);
|
|
92
|
+
const local = new Set(candidates.map((c) => c.name).filter((n) => Boolean(n)));
|
|
93
|
+
let best = { depth: 0, chain: [] };
|
|
94
|
+
for (const piece of pieces) {
|
|
95
|
+
const next = deepestLink(piece, { rel, name, local }, ctx, stack);
|
|
96
|
+
if (next.depth > best.depth)
|
|
97
|
+
best = next;
|
|
98
|
+
}
|
|
99
|
+
stack.delete(key);
|
|
100
|
+
const out = { depth: best.depth + 1, chain: [name, ...best.chain] };
|
|
101
|
+
ctx.cache?.memo.set(key, out);
|
|
102
|
+
return out;
|
|
103
|
+
};
|
|
104
|
+
// The candidates of one repo file, parsed once per run. An unreadable file
|
|
105
|
+
// (generated, outside the project) has no chain: the fact is about code the
|
|
106
|
+
// tool can actually read. The reason is reported, so a missing chain never
|
|
107
|
+
// passes for a shallow one.
|
|
108
|
+
const candidatesIn = (rel, ctx) => {
|
|
109
|
+
const cached = ctx.cache?.files.get(rel);
|
|
110
|
+
if (cached)
|
|
111
|
+
return cached;
|
|
112
|
+
const read = () => {
|
|
113
|
+
const abs = path.join(ctx.repoRoot, rel);
|
|
114
|
+
const text = fs.readFileSync(abs, "utf8");
|
|
115
|
+
const sf = (0, index_1.loadSourceFile)(ctx.project, abs, text);
|
|
116
|
+
const importMap = (0, index_1.importNameModules)(sf, ctx.repoRoot, ctx.aliases ?? {}, ctx.repoFiles);
|
|
117
|
+
const candidates = (0, index_1.collectCandidates)(sf, importMap, rel, ctx.repoRoot);
|
|
118
|
+
// The facets read the same file the walk does, so a rendered component is a
|
|
119
|
+
// link here exactly as it is in the invariants. The import map is handed over
|
|
120
|
+
// so a tag imported from another module names that module.
|
|
121
|
+
(0, frameworks_1.enrich)(candidates, { rel, sf, text, repoRoot: ctx.repoRoot, importMap });
|
|
122
|
+
return candidates;
|
|
123
|
+
};
|
|
124
|
+
const out = (0, try_read_1.readOrFallback)(rel, read, [], (e) => (0, notices_1.notice)(`the import chain of ${rel} could not be read`, (0, reason_1.reasonOf)(e)));
|
|
125
|
+
ctx.cache?.files.set(rel, out);
|
|
126
|
+
return out;
|
|
127
|
+
};
|
|
128
|
+
// Give every candidate its `kind.chain` — how many pieces the call chain passes
|
|
129
|
+
// through (this one included) and their names, outermost first. It lives under
|
|
130
|
+
// `kind` because it describes the SHAPE of the code, next to `own` and
|
|
131
|
+
// `descendants`; a top-level fact of its own would be a second vocabulary for
|
|
132
|
+
// the same question.
|
|
133
|
+
const attachCallDepth = (candidates, ctx) => {
|
|
134
|
+
for (const c of candidates) {
|
|
135
|
+
if (!c.name)
|
|
136
|
+
continue;
|
|
137
|
+
const { chain } = depthOf(ctx.rel, c.name, ctx, new Set());
|
|
138
|
+
// The chain as ONE string: a finding names it, so a rule can print it
|
|
139
|
+
// without the report layer knowing about arrays.
|
|
140
|
+
// The chain is a LIST of links, and nothing more: how deep it counts, where it
|
|
141
|
+
// stops being interesting, what it may not pass through — that is a FILTER's
|
|
142
|
+
// job, and the filter language already has the operators for it. The engine
|
|
143
|
+
// answers "what is called next", never "is that too deep".
|
|
144
|
+
const flat = chain.filter((n, i) => n !== chain[i - 1]);
|
|
145
|
+
c.kind = { ...(c.kind ?? {}), chain: flat.map((n) => ({ name: n })) };
|
|
146
|
+
}
|
|
147
|
+
return candidates;
|
|
148
|
+
};
|
|
149
|
+
exports.attachCallDepth = attachCallDepth;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Node } from "ts-morph";
|
|
2
|
+
import type { LooseNode } from "./loose";
|
|
3
|
+
import type { Candidate } from "../facts";
|
|
4
|
+
declare const isEnumNode: (n: Node) => boolean;
|
|
5
|
+
declare const enumFact: (node: LooseNode, rel: string) => Candidate;
|
|
6
|
+
export { enumFact, isEnumNode };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEnumNode = exports.enumFact = void 0;
|
|
4
|
+
// An `enum` is a declaration with a shape: a closed set of names, each bound to
|
|
5
|
+
// a value. It is a candidate like a type — a node may host it, a rule may count
|
|
6
|
+
// its members — and `const`/`declare` are its modifiers.
|
|
7
|
+
const declaration_1 = require("./declaration");
|
|
8
|
+
const membersOf = (node) => (node.getMembers?.() ?? []).map((m) => {
|
|
9
|
+
const initializer = m.getInitializer?.();
|
|
10
|
+
const name = m.getName?.() ?? null;
|
|
11
|
+
return { name, value: initializer ? initializer.getText() : null, line: m.getStartLineNumber() };
|
|
12
|
+
});
|
|
13
|
+
const isEnumNode = (n) => n.getKindName() === "EnumDeclaration";
|
|
14
|
+
exports.isEnumNode = isEnumNode;
|
|
15
|
+
// `const enum` is a MODIFIER, and `kind` carries every modifier.
|
|
16
|
+
const enumFact = (node, rel) => (0, declaration_1.declarationFact)(node, rel, membersOf(node));
|
|
17
|
+
exports.enumFact = enumFact;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type SourceFile } from "ts-morph";
|
|
2
|
+
import type { CollectOptions } from "./file-facts";
|
|
3
|
+
import type { ExportFact } from "../facts";
|
|
4
|
+
type ResolveCtx = Omit<CollectOptions, "candidates">;
|
|
5
|
+
declare const exportsOf: (sf: SourceFile, importMap: ReadonlyMap<string, string>, ctx: ResolveCtx) => ExportFact[];
|
|
6
|
+
export { exportsOf };
|
|
7
|
+
export type { ResolveCtx };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exportsOf = void 0;
|
|
4
|
+
// EVERY way code leaves the module — one list, `form` says which spelling:
|
|
5
|
+
// named `export { a, b as c }` (of local code, or a re-export)
|
|
6
|
+
// namespace `export * as ns from "x"`
|
|
7
|
+
// star `export * from "x"`
|
|
8
|
+
// default `export default <expr>`
|
|
9
|
+
// equals `export = <expr>`
|
|
10
|
+
// commonjs `module.exports = …`, `module.exports.x = …`, `exports.x = …`
|
|
11
|
+
const ts_morph_1 = require("ts-morph");
|
|
12
|
+
const tree_1 = require("./tree");
|
|
13
|
+
const properties_1 = require("./properties");
|
|
14
|
+
const imports_1 = require("../../utils/imports");
|
|
15
|
+
// The form of one `export …` statement: a namespace re-export, a star
|
|
16
|
+
// re-export, or named exports.
|
|
17
|
+
const formOf = (exp) => {
|
|
18
|
+
if (exp.getNamespaceExport())
|
|
19
|
+
return "namespace";
|
|
20
|
+
if (exp.hasModuleSpecifier() && !exp.hasNamedExports())
|
|
21
|
+
return "star";
|
|
22
|
+
return "named";
|
|
23
|
+
};
|
|
24
|
+
const statementExport = (exp, importMap, ctx) => {
|
|
25
|
+
const named = exp.getNamedExports().map((el) => el.getAliasNode()?.getText() ?? el.getName());
|
|
26
|
+
const entry = {
|
|
27
|
+
form: formOf(exp),
|
|
28
|
+
named,
|
|
29
|
+
from: null,
|
|
30
|
+
source: null,
|
|
31
|
+
name: null,
|
|
32
|
+
// `export type { … } from` / `export type * from` erase at compile time
|
|
33
|
+
// and bind nothing at runtime — a rule that forbids VALUE re-exports must
|
|
34
|
+
// tell them apart, so record which spelling this is.
|
|
35
|
+
typeOnly: exp.isTypeOnly(),
|
|
36
|
+
line: (0, tree_1.startLine)(exp),
|
|
37
|
+
piece: (0, properties_1.enclosingPiece)(exp),
|
|
38
|
+
};
|
|
39
|
+
if (exp.getModuleSpecifierValue()) {
|
|
40
|
+
entry.source = exp.getModuleSpecifierValue();
|
|
41
|
+
entry.from = (0, imports_1.resolveImport)(exp.getSourceFile(), entry.source, ctx);
|
|
42
|
+
}
|
|
43
|
+
const ns = exp.getNamespaceExport();
|
|
44
|
+
// `export * as ns from ...` — the binding is the name after `as`, not the
|
|
45
|
+
// whole `* as ns` text.
|
|
46
|
+
if (ns)
|
|
47
|
+
entry.named = [ns.getName()];
|
|
48
|
+
// `export { a as b }` with no specifier, where `a` was IMPORTED: that is a
|
|
49
|
+
// re-export like any other — the code being published is not this file's.
|
|
50
|
+
if (!entry.from && entry.named?.length === 1 && importMap.has(entry.named[0]))
|
|
51
|
+
entry.from = importMap.get(entry.named[0]) ?? null;
|
|
52
|
+
return entry;
|
|
53
|
+
};
|
|
54
|
+
// `export default <expr>` / `export = <expr>`: no declaration modifier to find,
|
|
55
|
+
// so the statement itself is the site. When the expression is an imported
|
|
56
|
+
// binding, the export is a pass-through of that module.
|
|
57
|
+
const assignmentExport = (ea, importMap) => {
|
|
58
|
+
const text = ea.getExpression()?.getText() ?? "";
|
|
59
|
+
return { form: ea.isExportEquals() ? "equals" : "default", named: [], source: null, from: text ? (importMap.get(text) ?? null) : null, name: null, line: (0, tree_1.startLine)(ea), piece: (0, properties_1.enclosingPiece)(ea) };
|
|
60
|
+
};
|
|
61
|
+
// CommonJS, in every form it is still written in.
|
|
62
|
+
const commonJsExport = (d) => {
|
|
63
|
+
const m = /^(?:module\.)?exports(?:\.([A-Za-z0-9_$]+))?$/.exec(d.getLeft().getText());
|
|
64
|
+
if (!m)
|
|
65
|
+
return null;
|
|
66
|
+
return { form: "commonjs", named: [], source: null, from: null, name: m[1] ?? null, line: d.getStartLineNumber(), piece: (0, properties_1.enclosingPiece)(d) };
|
|
67
|
+
};
|
|
68
|
+
const exportsOf = (sf, importMap, ctx) => {
|
|
69
|
+
const statementExports = sf.getExportDeclarations().map((exp) => statementExport(exp, importMap, ctx));
|
|
70
|
+
const assignmentExports = sf.getExportAssignments().map((ea) => assignmentExport(ea, importMap));
|
|
71
|
+
const commonJsExports = sf
|
|
72
|
+
.getDescendants()
|
|
73
|
+
.filter((d) => ts_morph_1.Node.isBinaryExpression(d) && d.getOperatorToken().getText() === "=")
|
|
74
|
+
.map(commonJsExport)
|
|
75
|
+
.filter((e) => e != null);
|
|
76
|
+
return [...statementExports, ...assignmentExports, ...commonJsExports].sort((a, b) => a.line - b.line);
|
|
77
|
+
};
|
|
78
|
+
exports.exportsOf = exportsOf;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type SourceFile } from "ts-morph";
|
|
2
|
+
import type { AliasMap } from "./project";
|
|
3
|
+
import type { FileFacts, Candidate } from "../facts";
|
|
4
|
+
interface CollectOptions {
|
|
5
|
+
rel: string;
|
|
6
|
+
repoFiles?: string[];
|
|
7
|
+
aliases?: AliasMap;
|
|
8
|
+
repoRoot: string;
|
|
9
|
+
candidates?: Candidate[];
|
|
10
|
+
}
|
|
11
|
+
declare const collectFileFacts: (sf: SourceFile, options: CollectOptions) => FileFacts;
|
|
12
|
+
export { collectFileFacts };
|
|
13
|
+
export type { CollectOptions };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectFileFacts = void 0;
|
|
4
|
+
const tree_1 = require("./tree");
|
|
5
|
+
const properties_1 = require("./properties");
|
|
6
|
+
const resolve_1 = require("./resolve");
|
|
7
|
+
const file_imports_1 = require("./file-imports");
|
|
8
|
+
const file_exports_1 = require("./file-exports");
|
|
9
|
+
const location_1 = require("../location");
|
|
10
|
+
const collectFileFacts = (sf, options) => {
|
|
11
|
+
const { rel, repoFiles, aliases, repoRoot, candidates } = options;
|
|
12
|
+
// The import map is rebuilt here because reads are a FILE fact, not a
|
|
13
|
+
// per-candidate one: a read is a property of the file's surface.
|
|
14
|
+
const importMap = (0, resolve_1.importNameModules)(sf, repoRoot, aliases, repoFiles);
|
|
15
|
+
const exports = (0, file_exports_1.exportsOf)(sf, importMap, options);
|
|
16
|
+
const imports = (0, file_imports_1.importsOf)(sf, options);
|
|
17
|
+
const reads = (0, properties_1.readsFact)(sf, importMap);
|
|
18
|
+
return {
|
|
19
|
+
// The whole file, as one array of lines: `lines[0]` is the first,
|
|
20
|
+
// `lines.length` the count.
|
|
21
|
+
lines: (0, tree_1.linesOf)(sf),
|
|
22
|
+
imports,
|
|
23
|
+
exports,
|
|
24
|
+
// WHERE this file is — one fact, built by `entities/location.placeOf`: the
|
|
25
|
+
// names it is made of, its parts, its folder, its parent, its neighbours and
|
|
26
|
+
// its position among them. Nothing about the place is computed here.
|
|
27
|
+
location: (0, location_1.placeOf)(rel, repoFiles),
|
|
28
|
+
reads,
|
|
29
|
+
// What is in the file: its own node, and every node below it.
|
|
30
|
+
kind: { own: (0, tree_1.descriptor)(sf), descendants: (0, tree_1.descendantsOf)(sf) },
|
|
31
|
+
candidates: candidates ?? [],
|
|
32
|
+
roles: [...new Set((candidates ?? []).map((c) => c.role).filter((r) => Boolean(r)))],
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.collectFileFacts = collectFileFacts;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.importsOf = void 0;
|
|
4
|
+
// EVERY way a module is brought in — one list, `form` says which spelling:
|
|
5
|
+
// statement `import … from "x"`
|
|
6
|
+
// require `require("x")` — CommonJS
|
|
7
|
+
// dynamic `import("x")` — the dynamic form
|
|
8
|
+
// equals `import x = require("y")` / `import x = A.B`
|
|
9
|
+
// heritage `extends`/`implements` — a type dependency with no import
|
|
10
|
+
// A `require`/`import()` sits INSIDE a function, so its `piece` says which
|
|
11
|
+
// code depends on the module; a statement is the file's own, `piece` is null.
|
|
12
|
+
const ts_morph_1 = require("ts-morph");
|
|
13
|
+
const tree_1 = require("./tree");
|
|
14
|
+
const properties_1 = require("./properties");
|
|
15
|
+
const heritage_1 = require("./heritage");
|
|
16
|
+
const imports_1 = require("../../utils/imports");
|
|
17
|
+
const statementImport = (imp, ctx) => {
|
|
18
|
+
const source = imp.getModuleSpecifierValue();
|
|
19
|
+
// Named imports carry the LOCAL binding name (`b as c` → "c").
|
|
20
|
+
const entry = { form: "statement", source, typeOnly: imp.isTypeOnly(), named: imp.getNamedImports().map((el) => el.getAliasNode()?.getText() ?? el.getName()), line: (0, tree_1.startLine)(imp), piece: null };
|
|
21
|
+
const def = imp.getDefaultImport();
|
|
22
|
+
if (def)
|
|
23
|
+
entry.defaultName = def.getText();
|
|
24
|
+
const ns = imp.getNamespaceImport();
|
|
25
|
+
if (ns)
|
|
26
|
+
entry.namespaceName = ns.getText();
|
|
27
|
+
entry.resolved = (0, imports_1.resolveImport)(imp.getSourceFile(), source, ctx);
|
|
28
|
+
return entry;
|
|
29
|
+
};
|
|
30
|
+
// `require("x")` / `import("x")` — the call forms, only when the first argument
|
|
31
|
+
// is a static string.
|
|
32
|
+
const callImport = (call, ctx) => {
|
|
33
|
+
const callee = call.getExpression();
|
|
34
|
+
const isRequire = callee.getKind() === tree_1.SK.Identifier && callee.getText() === "require";
|
|
35
|
+
const isDynamic = callee.getKind() === tree_1.SK.ImportKeyword;
|
|
36
|
+
if (!isRequire && !isDynamic)
|
|
37
|
+
return null;
|
|
38
|
+
const arg = call.getArguments()[0];
|
|
39
|
+
if (!arg || arg.getKind() !== tree_1.SK.StringLiteral)
|
|
40
|
+
return null;
|
|
41
|
+
const entry = { form: isDynamic ? "dynamic" : "require", source: (0, tree_1.nodeText)(arg) || null, typeOnly: false, named: [], line: call.getStartLineNumber(), piece: (0, properties_1.enclosingPiece)(call) };
|
|
42
|
+
entry.resolved = (0, imports_1.resolveImport)(call.getSourceFile(), entry.source ?? "", ctx);
|
|
43
|
+
return entry;
|
|
44
|
+
};
|
|
45
|
+
// `import x = require("y")` / `import x = A.B` — the CommonJS spelling of a
|
|
46
|
+
// dependency, which is a `require` in everything but the keyword.
|
|
47
|
+
const equalsImport = (decl, ctx) => {
|
|
48
|
+
// `import x = require("y")` vs `import x = A.B`: only the first names a module.
|
|
49
|
+
const moduleRef = decl.getModuleReference();
|
|
50
|
+
const isExternal = String(moduleRef.getKindName()) === "ExternalModuleReference";
|
|
51
|
+
const expr = isExternal && ts_morph_1.Node.isExternalModuleReference(moduleRef) ? moduleRef.getExpression() : null;
|
|
52
|
+
const source = (0, tree_1.nodeText)(expr ?? moduleRef) || null;
|
|
53
|
+
return {
|
|
54
|
+
form: isExternal ? "require" : "equals",
|
|
55
|
+
source,
|
|
56
|
+
typeOnly: decl.isTypeOnly?.() ?? false,
|
|
57
|
+
named: [],
|
|
58
|
+
line: (0, tree_1.startLine)(decl),
|
|
59
|
+
piece: null,
|
|
60
|
+
resolved: source ? (0, imports_1.resolveImport)(decl.getSourceFile(), source, ctx) : null,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const importsOf = (sf, ctx) => {
|
|
64
|
+
// A type dependency written in the declaration itself (`extends`/`implements`),
|
|
65
|
+
// with no import statement to see it.
|
|
66
|
+
const heritage = (0, heritage_1.heritageOf)(sf, sf.getProject().getTypeChecker(), ctx.repoRoot, ctx.rel ?? "");
|
|
67
|
+
return [
|
|
68
|
+
...sf.getImportDeclarations().map((imp) => statementImport(imp, ctx)),
|
|
69
|
+
...sf
|
|
70
|
+
.getDescendantsOfKind(tree_1.SK.CallExpression)
|
|
71
|
+
.map((call) => callImport(call, ctx))
|
|
72
|
+
.filter((e) => e != null),
|
|
73
|
+
...heritage,
|
|
74
|
+
...sf.getDescendantsOfKind(tree_1.SK.ImportEqualsDeclaration).map((decl) => equalsImport(decl, ctx)),
|
|
75
|
+
].sort((a, b) => a.line - b.line);
|
|
76
|
+
};
|
|
77
|
+
exports.importsOf = importsOf;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createTsProject, loadSourceFile } from "./project";
|
|
2
|
+
export { importNameModules, declaredFileOfNode, declaredFileOf, declaredFileOfType, declaredFileOfExpr, repoRelative, inRepo } from "./resolve";
|
|
3
|
+
export { collectFileFacts } from "./file-facts";
|
|
4
|
+
export type { DeclInfo } from "./resolve";
|
|
5
|
+
export type { AliasMap } from "./project";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectFileFacts = exports.inRepo = exports.repoRelative = exports.declaredFileOfExpr = exports.declaredFileOfType = exports.declaredFileOf = exports.declaredFileOfNode = exports.importNameModules = exports.loadSourceFile = exports.createTsProject = void 0;
|
|
4
|
+
// A source file: how it is loaded, and everything that is true about it. The
|
|
5
|
+
// entity is split by question, each half in its own module, re-exported here so
|
|
6
|
+
// every consumer keeps importing `entities/ast/file`:
|
|
7
|
+
// • `./project` — loading: the run's Project, one parsed file per path;
|
|
8
|
+
// • `./resolve` — import resolution and "which file declares this value";
|
|
9
|
+
// • `./file-facts` — fact collection: the whole file's imports/exports/reads.
|
|
10
|
+
var project_1 = require("./project");
|
|
11
|
+
Object.defineProperty(exports, "createTsProject", { enumerable: true, get: function () { return project_1.createTsProject; } });
|
|
12
|
+
Object.defineProperty(exports, "loadSourceFile", { enumerable: true, get: function () { return project_1.loadSourceFile; } });
|
|
13
|
+
var resolve_1 = require("./resolve");
|
|
14
|
+
Object.defineProperty(exports, "importNameModules", { enumerable: true, get: function () { return resolve_1.importNameModules; } });
|
|
15
|
+
Object.defineProperty(exports, "declaredFileOfNode", { enumerable: true, get: function () { return resolve_1.declaredFileOfNode; } });
|
|
16
|
+
Object.defineProperty(exports, "declaredFileOf", { enumerable: true, get: function () { return resolve_1.declaredFileOf; } });
|
|
17
|
+
Object.defineProperty(exports, "declaredFileOfType", { enumerable: true, get: function () { return resolve_1.declaredFileOfType; } });
|
|
18
|
+
Object.defineProperty(exports, "declaredFileOfExpr", { enumerable: true, get: function () { return resolve_1.declaredFileOfExpr; } });
|
|
19
|
+
Object.defineProperty(exports, "repoRelative", { enumerable: true, get: function () { return resolve_1.repoRelative; } });
|
|
20
|
+
Object.defineProperty(exports, "inRepo", { enumerable: true, get: function () { return resolve_1.inRepo; } });
|
|
21
|
+
var file_facts_1 = require("./file-facts");
|
|
22
|
+
Object.defineProperty(exports, "collectFileFacts", { enumerable: true, get: function () { return file_facts_1.collectFileFacts; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Node, type SourceFile } from "ts-morph";
|
|
2
|
+
import type { LooseNode } from "./loose";
|
|
3
|
+
import type { ReturnFact, ParameterFact } from "../facts";
|
|
4
|
+
declare const nearestFunction: (node: Node) => Node | null;
|
|
5
|
+
declare const nameOf: (fn: LooseNode) => string | null;
|
|
6
|
+
declare const returnsFact: (node: LooseNode) => ReturnFact[];
|
|
7
|
+
declare const parametersFact: (node: LooseNode, sf: SourceFile, repoRoot: string) => ParameterFact[];
|
|
8
|
+
export { nearestFunction, nameOf, returnsFact, parametersFact };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parametersFact = exports.returnsFact = exports.nameOf = exports.nearestFunction = void 0;
|
|
4
|
+
// Function-like entities — declaration, expression, arrow, method, accessor.
|
|
5
|
+
// What a function RECEIVES, YIELDS, DECLARES and how its body is shaped. Every
|
|
6
|
+
// "is it a helper / an action / an entry point?" is a rule's question asked in
|
|
7
|
+
// the YAML; nothing here decides.
|
|
8
|
+
const ts_morph_1 = require("ts-morph");
|
|
9
|
+
const tree_1 = require("./tree");
|
|
10
|
+
const properties_1 = require("./properties");
|
|
11
|
+
const file_1 = require("./file");
|
|
12
|
+
const dispatch_1 = require("../../utils/dispatch");
|
|
13
|
+
// The nearest function-like ancestor of a node, or null.
|
|
14
|
+
const nearestFunction = (node) => {
|
|
15
|
+
let n = node?.getParent();
|
|
16
|
+
while (n) {
|
|
17
|
+
if ((0, tree_1.isFunctionNode)(n))
|
|
18
|
+
return n;
|
|
19
|
+
n = n.getParent();
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
};
|
|
23
|
+
exports.nearestFunction = nearestFunction;
|
|
24
|
+
// The name a function-like node carries, when it has one. Arrows and function
|
|
25
|
+
// expressions take the name of the variable / property / field they are
|
|
26
|
+
// assigned to. The reading dispatches on the parser's kind (the shared
|
|
27
|
+
// `dispatchOn`): a named kind answers its OWN name — final, even when it has
|
|
28
|
+
// none — anything else asks its parent, and only a naming parent's name counts.
|
|
29
|
+
const NAMED_KINDS = new Set([tree_1.SK.FunctionDeclaration, tree_1.SK.MethodDeclaration]);
|
|
30
|
+
const NAME_PARENT_KINDS = new Set([tree_1.SK.VariableDeclaration, tree_1.SK.PropertyAssignment, tree_1.SK.PropertyDeclaration, tree_1.SK.PropertySignature]);
|
|
31
|
+
const ownName = (fn) => fn.getName?.() ?? null;
|
|
32
|
+
const parentName = (fn) => {
|
|
33
|
+
const p = fn?.getParent();
|
|
34
|
+
if (!p || !NAME_PARENT_KINDS.has(p.getKind()))
|
|
35
|
+
return null;
|
|
36
|
+
return p.getName?.() ?? null;
|
|
37
|
+
};
|
|
38
|
+
const NAME_READERS = new Map([...NAMED_KINDS].map((kind) => [kind, ownName]));
|
|
39
|
+
const nameOf = (fn) => (0, dispatch_1.dispatchOn)(fn, (node) => node.getKind(), NAME_READERS, parentName);
|
|
40
|
+
exports.nameOf = nameOf;
|
|
41
|
+
// ── Returns ─────────────────────────────────────────────────────────────────
|
|
42
|
+
// A value a function yields: each `return <expr>;` statement plus, for an
|
|
43
|
+
// expression-body function (`() => ({...})`), the expression body itself. A bare
|
|
44
|
+
// `return;` / `() => {}` yields no value.
|
|
45
|
+
//
|
|
46
|
+
// kind — where the value comes from: "ReturnStatement" or
|
|
47
|
+
// "ExpressionBody" (synthetic: an arrow's body IS the value,
|
|
48
|
+
// the parser has no return node for it).
|
|
49
|
+
// exprKind — the parser's kind of the yielded expression (null when the
|
|
50
|
+
// function yields no value there).
|
|
51
|
+
// origin — the origin of the yielded chain (`t.model({})` → "t.model").
|
|
52
|
+
// members — for an object-literal value: raw per-member facts.
|
|
53
|
+
const returnsFact = (node) => {
|
|
54
|
+
const bodyNode = node.getBody() ?? null;
|
|
55
|
+
const hasExpressionBody = bodyNode !== null && bodyNode.getKind() !== tree_1.SK.Block;
|
|
56
|
+
const returnStatements = node.getDescendantsOfKind(tree_1.SK.ReturnStatement);
|
|
57
|
+
const returnEntry = (kind, expr) => ({
|
|
58
|
+
kind,
|
|
59
|
+
exprKind: expr ? (0, tree_1.kindName)(expr) : null,
|
|
60
|
+
origin: (0, properties_1.leftmostOrigin)(expr),
|
|
61
|
+
members: expr && ts_morph_1.Node.isObjectLiteralExpression(expr) ? (0, tree_1.memberFacts)(expr) : [],
|
|
62
|
+
});
|
|
63
|
+
const returns = returnStatements.map((r) => returnEntry("ReturnStatement", r.getExpression() ?? null));
|
|
64
|
+
if (hasExpressionBody && bodyNode)
|
|
65
|
+
returns.push(returnEntry("ExpressionBody", (0, tree_1.unwrapParens)(bodyNode)));
|
|
66
|
+
return returns;
|
|
67
|
+
};
|
|
68
|
+
exports.returnsFact = returnsFact;
|
|
69
|
+
// ── Parameters ──────────────────────────────────────────────────────────────
|
|
70
|
+
// `typeFile` is the file that declares the parameter's TYPE, resolved by the
|
|
71
|
+
// checker through imports and aliases — the same answer `writes` uses. That is
|
|
72
|
+
// how a role can say "this function receives data from the host layer" without
|
|
73
|
+
// naming a folder and without naming a type.
|
|
74
|
+
//
|
|
75
|
+
// A destructured parameter (`{ a, b }`) is ONE parameter whose name is the whole
|
|
76
|
+
// pattern, so its FIELDS are listed beside it: each binding answers about its own
|
|
77
|
+
// type, and `rest` says a `...args` was handed over rather than a value.
|
|
78
|
+
const bindingsOf = (p, checker, repoRoot) => {
|
|
79
|
+
const nameNode = p.getNameNode?.() ?? null;
|
|
80
|
+
const kind = nameNode?.getKindName?.();
|
|
81
|
+
if (kind !== "ObjectBindingPattern" && kind !== "ArrayBindingPattern")
|
|
82
|
+
return [];
|
|
83
|
+
return (nameNode?.getElements?.() ?? []).map((el) => {
|
|
84
|
+
const typeNode = el.getTypeNode?.() ?? null;
|
|
85
|
+
return { name: el.getName?.() ?? null, type: typeNode ? typeNode.getText() : null, typeFile: typeNode ? ((0, file_1.declaredFileOfNode)(typeNode, checker, repoRoot)?.file ?? null) : null };
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
const typeTextOfParam = (p) => p.getTypeNode?.()?.getText() ?? (0, tree_1.typeText)(p);
|
|
89
|
+
const optionalOf = (p) => (typeof p.isOptional === "function" ? p.isOptional() : false);
|
|
90
|
+
const restOf = (p) => (p.getChildrenOfKind?.(tree_1.SK.DotDotDotToken) ?? []).length > 0;
|
|
91
|
+
const parametersFact = (node, sf, repoRoot) => {
|
|
92
|
+
const checker = sf.getProject().getTypeChecker();
|
|
93
|
+
return (node.getParameters?.() ?? []).map((p) => ({
|
|
94
|
+
name: p.getName?.() ?? "",
|
|
95
|
+
type: typeTextOfParam(p),
|
|
96
|
+
typeFile: (0, file_1.declaredFileOf)(p, checker, repoRoot)?.file ?? null,
|
|
97
|
+
optional: optionalOf(p),
|
|
98
|
+
rest: restOf(p),
|
|
99
|
+
bindings: bindingsOf(p, checker, repoRoot),
|
|
100
|
+
}));
|
|
101
|
+
};
|
|
102
|
+
exports.parametersFact = parametersFact;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.heritageOf = void 0;
|
|
4
|
+
// A dependency WITHOUT an `import`: `interface X extends Imported` and
|
|
5
|
+
// `class X implements Imported` name another module's type in the declaration
|
|
6
|
+
// itself. The arrow is the same as an `import type`, so the fact has the same
|
|
7
|
+
// shape — only `form` differs, and a rule can tell the two apart.
|
|
8
|
+
const tree_1 = require("./tree");
|
|
9
|
+
const file_1 = require("./file");
|
|
10
|
+
const heritageClauses = (decl) => [decl.getExtends?.(), ...(decl.getImplements?.() ?? [])].flat().filter((c) => c != null);
|
|
11
|
+
const fileOfClause = (clause, checker, repoRoot) => {
|
|
12
|
+
const expr = clause.getExpression?.() ?? clause;
|
|
13
|
+
const found = (0, file_1.declaredFileOfType)(expr.getType(), checker, repoRoot)?.file ?? null;
|
|
14
|
+
return found && (0, file_1.inRepo)(found, repoRoot) ? (0, file_1.repoRelative)(found, repoRoot) : null;
|
|
15
|
+
};
|
|
16
|
+
const heritageOf = (sf, checker, repoRoot, rel) => {
|
|
17
|
+
const out = [];
|
|
18
|
+
const owners = [...sf.getInterfaces(), ...sf.getClasses()];
|
|
19
|
+
for (const decl of owners) {
|
|
20
|
+
for (const clause of heritageClauses(decl)) {
|
|
21
|
+
const file = fileOfClause(clause, checker, repoRoot);
|
|
22
|
+
// A type of THIS file is not a dependency; one outside the repo is not one
|
|
23
|
+
// the architecture can describe.
|
|
24
|
+
if (!file)
|
|
25
|
+
continue;
|
|
26
|
+
if (file === rel)
|
|
27
|
+
continue;
|
|
28
|
+
if (!(0, file_1.inRepo)(file, repoRoot))
|
|
29
|
+
continue;
|
|
30
|
+
const name = (clause.getExpression?.() ?? clause).getText();
|
|
31
|
+
out.push({ form: "heritage", source: name, typeOnly: true, named: [name], line: (0, tree_1.startLine)(clause), piece: null, resolved: file });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
};
|
|
36
|
+
exports.heritageOf = heritageOf;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type SourceFile } from "ts-morph";
|
|
2
|
+
import { createTsProject, loadSourceFile, importNameModules, collectFileFacts } from "./file";
|
|
3
|
+
import type { Candidate } from "../facts";
|
|
4
|
+
type ImportMap = ReadonlyMap<string, string>;
|
|
5
|
+
declare const collectCandidates: (sf: SourceFile, importMap: ImportMap, rel: string | null, repoRoot: string) => Candidate[];
|
|
6
|
+
export { createTsProject, loadSourceFile, importNameModules, collectFileFacts, collectCandidates };
|