@md-code/follow-architecture 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +1310 -472
- package/dist/args.d.ts +4 -0
- package/dist/args.js +18 -1
- package/dist/bin/follow-architecture.js +3 -3
- package/dist/closure-project.d.ts +4 -0
- package/dist/closure-project.js +132 -0
- package/dist/code-entities/classify.d.ts +11 -0
- package/dist/code-entities/classify.js +45 -0
- package/dist/code-entities/connector.d.ts +8 -0
- package/dist/code-entities/connector.js +119 -0
- package/dist/code-entities/entities.d.ts +9 -0
- package/dist/{code-roles/roles.js → code-entities/entities.js} +98 -61
- package/dist/code-entities/project.d.ts +21 -0
- package/dist/code-entities/project.js +259 -0
- package/dist/code-entities/walk.d.ts +31 -0
- package/dist/code-entities/walk.js +105 -0
- package/dist/config-options.d.ts +23 -0
- package/dist/config-options.js +18 -1
- package/dist/config-project.js +27 -9
- package/dist/config-report.d.ts +1 -1
- package/dist/config-report.js +37 -10
- package/dist/config-rule.d.ts +25 -0
- package/dist/config-rule.js +106 -13
- package/dist/config-state.d.ts +14 -3
- package/dist/config-state.js +197 -24
- package/dist/config.d.ts +25 -0
- package/dist/css/index.d.ts +11 -7
- package/dist/css/index.js +141 -30
- package/dist/css/syntax/css/gate.js +5 -5
- package/dist/css/syntax/css/index.d.ts +1 -1
- package/dist/css/syntax/css/index.js +18 -8
- package/dist/css/syntax/css/reference.d.ts +1 -1
- package/dist/css/syntax/css/reference.js +15 -3
- package/dist/css/syntax/language.d.ts +1 -1
- package/dist/css/syntax/language.js +21 -9
- package/dist/css/syntax/scss/index.d.ts +2 -2
- package/dist/css/syntax/scss/index.js +18 -8
- package/dist/css/syntax/scss/reference.d.ts +1 -1
- package/dist/css/syntax/scss/reference.js +7 -1
- package/dist/css/syntax/styled/document.d.ts +3 -3
- package/dist/css/syntax/styled/document.js +34 -14
- package/dist/css/syntax/styled/markup.d.ts +1 -1
- package/dist/css/syntax/styled/markup.js +22 -14
- package/dist/css/syntax/styled/tags.d.ts +2 -0
- package/dist/css/syntax/styled/tags.js +22 -0
- package/dist/css/syntax/styled/template.js +10 -4
- package/dist/css/syntax/tailwind/tailwind.js +4 -4
- package/dist/css/value/check.d.ts +1 -1
- package/dist/css/value/check.js +1 -1
- package/dist/css/value/expression/arithmetic.d.ts +2 -2
- package/dist/css/value/expression/arithmetic.js +7 -3
- package/dist/css/value/expression/block.d.ts +2 -2
- package/dist/css/value/expression/block.js +4 -3
- package/dist/css/value/expression/conditional.d.ts +2 -2
- package/dist/css/value/expression/conditional.js +1 -1
- package/dist/css/value/expression/index.d.ts +2 -2
- package/dist/css/value/expression/index.js +10 -6
- package/dist/css/value/expression/map.d.ts +2 -2
- package/dist/css/value/expression/map.js +2 -2
- package/dist/css/value/object/index.d.ts +2 -2
- package/dist/css/value/object/index.js +14 -4
- package/dist/css/value/object/members.d.ts +2 -2
- package/dist/css/value/object/node.js +9 -4
- package/dist/css/value/object/path.d.ts +3 -3
- package/dist/css/value/object/path.js +10 -4
- package/dist/css/value/pieces.d.ts +3 -3
- package/dist/css/value/pieces.js +14 -4
- package/dist/css/value/resolve.js +15 -5
- package/dist/css/value/scope.d.ts +3 -2
- package/dist/css/value/scope.js +25 -7
- package/dist/css/value/substitute.js +43 -11
- package/dist/entities/architecture.d.ts +28 -25
- package/dist/entities/ast/assignments-raw.d.ts +1 -1
- package/dist/entities/ast/assignments-raw.js +61 -8
- package/dist/entities/ast/assignments-tagged.d.ts +1 -1
- package/dist/entities/ast/assignments-tagged.js +22 -7
- package/dist/entities/ast/assignments.d.ts +1 -1
- package/dist/entities/ast/assignments.js +6 -4
- package/dist/entities/ast/branches.d.ts +1 -1
- package/dist/entities/ast/calls.d.ts +1 -1
- package/dist/entities/ast/calls.js +19 -3
- package/dist/entities/ast/classes.d.ts +1 -1
- package/dist/entities/ast/classes.js +5 -1
- package/dist/entities/ast/comments.d.ts +3 -2
- package/dist/entities/ast/comments.js +47 -17
- package/dist/entities/ast/declaration.d.ts +1 -1
- package/dist/entities/ast/depth.d.ts +2 -2
- package/dist/entities/ast/depth.js +32 -15
- package/dist/entities/ast/enums.d.ts +1 -1
- package/dist/entities/ast/export-chain.d.ts +15 -0
- package/dist/entities/ast/export-chain.js +171 -0
- package/dist/entities/ast/file-exports.d.ts +1 -1
- package/dist/entities/ast/file-exports.js +26 -3
- package/dist/entities/ast/file-facts.d.ts +6 -3
- package/dist/entities/ast/file-facts.js +33 -4
- package/dist/entities/ast/file-imports.d.ts +1 -1
- package/dist/entities/ast/file-imports.js +26 -3
- package/dist/entities/ast/file.d.ts +2 -2
- package/dist/entities/ast/file.js +2 -1
- package/dist/entities/ast/functions.d.ts +1 -1
- package/dist/entities/ast/functions.js +13 -4
- package/dist/entities/ast/heritage.d.ts +1 -1
- package/dist/entities/ast/heritage.js +9 -1
- package/dist/entities/ast/index.d.ts +6 -3
- package/dist/entities/ast/index.js +82 -26
- package/dist/entities/ast/kind.d.ts +1 -1
- package/dist/entities/ast/kind.js +7 -1
- package/dist/entities/ast/modifiers.d.ts +1 -1
- package/dist/entities/ast/modifiers.js +4 -4
- package/dist/entities/ast/project.js +33 -2
- package/dist/entities/ast/properties.d.ts +1 -1
- package/dist/entities/ast/properties.js +10 -5
- package/dist/entities/ast/resolve.d.ts +1 -1
- package/dist/entities/ast/resolve.js +21 -11
- package/dist/entities/ast/tree.d.ts +4 -2
- package/dist/entities/ast/tree.js +184 -17
- package/dist/entities/ast/types.d.ts +1 -1
- package/dist/entities/ast/types.js +2 -1
- package/dist/entities/ast/usage.d.ts +1 -1
- package/dist/entities/ast/usage.js +1 -1
- package/dist/entities/ast/variables.d.ts +1 -1
- package/dist/entities/context.d.ts +4 -4
- package/dist/entities/facts.d.ts +36 -13
- package/dist/entities/findings.d.ts +3 -3
- package/dist/entities/kinds.d.ts +1 -1
- package/dist/entities/kinds.js +148 -37
- package/dist/entities/location/homes.d.ts +10 -10
- package/dist/entities/location/homes.js +74 -48
- package/dist/entities/location/place.d.ts +1 -1
- package/dist/entities/location/place.js +10 -3
- package/dist/entities/location/where.d.ts +10 -8
- package/dist/entities/location/where.js +89 -30
- package/dist/entities/location.d.ts +3 -3
- package/dist/entities/location.js +17 -17
- package/dist/entities/operators.js +1 -1
- package/dist/entities/overview/data.d.ts +6 -6
- package/dist/entities/overview/decision.d.ts +11 -11
- package/dist/entities/overview/finding.d.ts +10 -10
- package/dist/entities/overview/graph.d.ts +28 -11
- package/dist/entities/overview/input.d.ts +2 -2
- package/dist/entities/overview/summaries.d.ts +17 -15
- package/dist/entities/queries.d.ts +1 -1
- package/dist/entities/queries.js +89 -19
- package/dist/entities/repair.d.ts +1 -1
- package/dist/entities/repair.js +8 -2
- package/dist/entities/schema.d.ts +17 -3
- package/dist/entities/schema.js +74 -16
- package/dist/entities/story.d.ts +5 -5
- package/dist/entities/structure-facts.d.ts +1 -1
- package/dist/entities/token.d.ts +4 -4
- package/dist/entities/tree/build.d.ts +4 -3
- package/dist/entities/tree/build.js +112 -51
- package/dist/entities/tree/entries.d.ts +4 -4
- package/dist/entities/tree/entries.js +41 -16
- package/dist/entities/tree/index.d.ts +2 -2
- package/dist/entities/tree/index.js +1 -1
- package/dist/entities/tree/match.d.ts +2 -2
- package/dist/entities/tree/match.js +26 -12
- package/dist/fa-index.d.ts +16 -0
- package/dist/fa-index.js +165 -0
- package/dist/fa-open.d.ts +51 -0
- package/dist/fa-open.js +242 -0
- package/dist/fa-store.d.ts +22 -0
- package/dist/fa-store.js +232 -0
- package/dist/fa-values.d.ts +37 -0
- package/dist/fa-values.js +104 -0
- package/dist/facts-record.d.ts +45 -0
- package/dist/facts-record.js +297 -0
- package/dist/frameworks/angular/index.d.ts +2 -2
- package/dist/frameworks/angular/index.js +2 -1
- package/dist/frameworks/facet.d.ts +3 -1
- package/dist/frameworks/facet.js +13 -0
- package/dist/frameworks/index.d.ts +1 -1
- package/dist/frameworks/index.js +25 -11
- package/dist/frameworks/react/index.d.ts +2 -2
- package/dist/frameworks/react/index.js +33 -10
- package/dist/frameworks/test/index.d.ts +6 -0
- package/dist/frameworks/test/index.js +157 -0
- package/dist/frameworks/vue/index.d.ts +2 -2
- package/dist/frameworks/vue/index.js +2 -1
- package/dist/ignore.d.ts +3 -0
- package/dist/ignore.js +62 -0
- package/dist/index-file.d.ts +43 -0
- package/dist/index-file.js +218 -0
- package/dist/index-run.d.ts +39 -0
- package/dist/index-run.js +217 -0
- package/dist/index-zone.d.ts +25 -0
- package/dist/index-zone.js +219 -0
- package/dist/main.d.ts +5 -2
- package/dist/main.js +223 -41
- package/dist/nodes/child-entities.d.ts +3 -0
- package/dist/nodes/child-entities.js +12 -0
- package/dist/nodes/children.d.ts +4 -4
- package/dist/nodes/children.js +64 -11
- package/dist/nodes/finally/emit.d.ts +4 -4
- package/dist/nodes/finally/emit.js +26 -10
- package/dist/nodes/finally/entities.d.ts +13 -0
- package/dist/nodes/finally/entities.js +42 -0
- package/dist/nodes/finally/index.d.ts +6 -6
- package/dist/nodes/finally/index.js +8 -8
- package/dist/nodes/finally/queries.d.ts +2 -2
- package/dist/nodes/finally/queries.js +7 -4
- package/dist/nodes/finally/relations-access.d.ts +2 -2
- package/dist/nodes/finally/relations-access.js +22 -18
- package/dist/nodes/finally/relations-edge.d.ts +5 -5
- package/dist/nodes/finally/relations-edge.js +67 -44
- package/dist/nodes/finally/relations-group.d.ts +7 -7
- package/dist/nodes/finally/relations-group.js +28 -25
- package/dist/nodes/finally/relations.d.ts +2 -2
- package/dist/nodes/finally/relations.js +16 -12
- package/dist/nodes/finally/required.d.ts +3 -3
- package/dist/nodes/finally/required.js +9 -7
- package/dist/nodes/finally/violation.d.ts +2 -2
- package/dist/nodes/similar.d.ts +3 -3
- package/dist/nodes/similar.js +78 -56
- package/dist/piece-forms.d.ts +9 -0
- package/dist/piece-forms.js +68 -0
- package/dist/{pipeline-roles.d.ts → pipeline-entities.d.ts} +2 -2
- package/dist/{pipeline-roles.js → pipeline-entities.js} +32 -28
- package/dist/pipeline-facts.d.ts +4 -3
- package/dist/pipeline-facts.js +64 -62
- package/dist/{pipeline-unroled.d.ts → pipeline-unclassified.d.ts} +2 -2
- package/dist/{pipeline-unroled.js → pipeline-unclassified.js} +58 -63
- package/dist/pipeline.d.ts +1 -1
- package/dist/pipeline.js +19 -64
- package/dist/release-file.d.ts +3 -0
- package/dist/release-file.js +13 -0
- package/dist/report/asks.d.ts +3 -3
- package/dist/report/asks.js +16 -6
- package/dist/report/configErrors.d.ts +55 -27
- package/dist/report/configErrors.js +81 -35
- package/dist/report/errorTypes/codes/structure.d.ts +1 -1
- package/dist/report/errorTypes/codes/structure.js +9 -9
- package/dist/report/errorTypes/decision-maker.d.ts +5 -5
- package/dist/report/errorTypes/decision-maker.js +21 -11
- package/dist/report/errorTypes/destinations.d.ts +5 -5
- package/dist/report/errorTypes/destinations.js +52 -34
- package/dist/report/errorTypes/finding-type.d.ts +3 -3
- package/dist/report/errorTypes/index.d.ts +1 -1
- package/dist/report/errorTypes/index.js +17 -7
- package/dist/report/errorTypes/types/fileContents.d.ts +4 -4
- package/dist/report/errorTypes/types/fileContents.js +11 -5
- package/dist/report/errorTypes/types/unknownEntity.d.ts +9 -0
- package/dist/report/errorTypes/types/{unknownRole.js → unknownEntity.js} +12 -7
- package/dist/report/errorTypes/types/wrongAction.d.ts +5 -5
- package/dist/report/errorTypes/types/wrongAction.js +18 -13
- package/dist/report/errorTypes/types/wrongPlacement.d.ts +4 -4
- package/dist/report/errorTypes/types/wrongPlacement.js +19 -9
- package/dist/report/errorTypes/vocabulary/ids.d.ts +2 -2
- package/dist/report/errorTypes/vocabulary/ids.js +3 -3
- package/dist/report/errorTypes/vocabulary/phrases.d.ts +2 -2
- package/dist/report/errorTypes/vocabulary/phrases.js +39 -26
- package/dist/report/errorTypes/vocabulary/places.d.ts +3 -3
- package/dist/report/errorTypes/vocabulary/places.js +13 -13
- package/dist/report/finding-from.d.ts +3 -3
- package/dist/report/finding-from.js +14 -9
- package/dist/report/notices.d.ts +6 -1
- package/dist/report/notices.js +46 -20
- package/dist/report/observed.d.ts +19 -0
- package/dist/report/observed.js +87 -0
- package/dist/report/render-report.d.ts +1 -1
- package/dist/report/render-report.js +33 -30
- package/dist/report/user-report/build/bundle.js +26 -7
- package/dist/report/user-report/build/bundle.prebuilt.js +799 -297
- package/dist/report/user-report/data/collect.d.ts +2 -2
- package/dist/report/user-report/data/collect.js +32 -19
- package/dist/report/user-report/data/entities.d.ts +7 -0
- package/dist/report/user-report/data/{roles.js → entities.js} +27 -22
- package/dist/report/user-report/data/{role-examples.d.ts → entity-examples.d.ts} +3 -3
- package/dist/report/user-report/data/entity-examples.js +136 -0
- package/dist/report/user-report/data/{role-filters.d.ts → entity-filters.d.ts} +2 -2
- package/dist/report/user-report/data/{role-filters.js → entity-filters.js} +7 -7
- package/dist/report/user-report/data/entity-marks.d.ts +5 -0
- package/dist/report/user-report/data/{role-marks.js → entity-marks.js} +11 -11
- package/dist/report/user-report/data/file-tree.d.ts +3 -3
- package/dist/report/user-report/data/file-tree.js +13 -5
- package/dist/report/user-report/data/finding-boundary.d.ts +4 -4
- package/dist/report/user-report/data/finding-boundary.js +2 -2
- package/dist/report/user-report/data/finding-plan.d.ts +5 -5
- package/dist/report/user-report/data/finding-plan.js +10 -10
- package/dist/report/user-report/data/finding-title.d.ts +2 -2
- package/dist/report/user-report/data/finding-title.js +8 -8
- package/dist/report/user-report/data/findings.d.ts +4 -4
- package/dist/report/user-report/data/findings.js +30 -20
- package/dist/report/user-report/data/graph-edges.d.ts +4 -4
- package/dist/report/user-report/data/graph-edges.js +19 -19
- package/dist/report/user-report/data/graph-entities.d.ts +6 -0
- package/dist/report/user-report/data/graph-entities.js +158 -0
- package/dist/report/user-report/data/graph-helpers.d.ts +5 -5
- package/dist/report/user-report/data/graph-helpers.js +15 -15
- package/dist/report/user-report/data/graph.d.ts +5 -4
- package/dist/report/user-report/data/graph.js +28 -21
- package/dist/report/user-report/data/nodes.d.ts +2 -2
- package/dist/report/user-report/data/nodes.js +33 -23
- package/dist/report/user-report/data/rules.d.ts +7 -0
- package/dist/report/user-report/data/{invariants.js → rules.js} +13 -13
- package/dist/report/user-report/data/scan.d.ts +1 -1
- package/dist/report/user-report/data/scan.js +19 -9
- package/dist/report/user-report/html/shell.d.ts +1 -1
- package/dist/report/user-report/html/shell.js +1 -1
- package/dist/report/user-report/index.d.ts +1 -1
- package/dist/report/user-report/index.js +17 -7
- package/dist/report/user-report/shared/describe.d.ts +1 -1
- package/dist/report/user-report/shared/describe.js +6 -6
- package/dist/rules/index.d.ts +7 -0
- package/dist/{invariants → rules}/index.js +85 -57
- package/dist/{invariants → rules}/list-vars.d.ts +2 -2
- package/dist/{invariants → rules}/list-vars.js +9 -3
- package/dist/{invariants → rules}/name.js +2 -2
- package/dist/rules/normalize.d.ts +5 -0
- package/dist/rules/normalize.js +108 -0
- package/dist/{invariants → rules}/vars.d.ts +9 -7
- package/dist/{invariants → rules}/vars.js +5 -5
- package/dist/scan-run.d.ts +20 -0
- package/dist/scan-run.js +130 -0
- package/dist/scripts/audit-report.js +19 -9
- package/dist/usage-index.d.ts +4 -0
- package/dist/usage-index.js +282 -0
- package/dist/usage-mode.d.ts +7 -0
- package/dist/usage-mode.js +16 -0
- package/dist/usage-pass.d.ts +19 -0
- package/dist/usage-pass.js +136 -0
- package/dist/usage-prepare.d.ts +2 -0
- package/dist/usage-prepare.js +22 -0
- package/dist/usage-sweep.d.ts +10 -0
- package/dist/usage-sweep.js +264 -0
- package/dist/utils/aliases.d.ts +22 -0
- package/dist/utils/aliases.js +173 -0
- package/dist/utils/classify.d.ts +2 -2
- package/dist/utils/classify.js +4 -4
- package/dist/utils/configs.js +17 -7
- package/dist/utils/distinct.js +4 -2
- package/dist/utils/files.js +41 -37
- package/dist/utils/fixpoint.js +2 -2
- package/dist/utils/host.d.ts +1 -1
- package/dist/utils/host.js +4 -1
- package/dist/utils/imports.js +83 -19
- package/dist/utils/keyed.js +2 -2
- package/dist/utils/map-record.js +2 -2
- package/dist/utils/packages.d.ts +15 -0
- package/dist/utils/packages.js +207 -0
- package/dist/utils/path-label.js +3 -1
- package/dist/utils/pattern.d.ts +5 -4
- package/dist/utils/pattern.js +55 -15
- package/dist/utils/permission.d.ts +3 -3
- package/dist/utils/permission.js +4 -2
- package/dist/utils/plural.js +2 -2
- package/dist/utils/qualified.js +4 -4
- package/dist/utils/rank.js +2 -2
- package/dist/utils/record.js +1 -1
- package/dist/utils/search.js +7 -2
- package/dist/utils/speak.js +1 -1
- package/dist/utils/split.js +14 -1
- package/dist/utils/template.d.ts +1 -1
- package/dist/utils/template.js +1 -1
- package/dist/utils/tokenize.js +6 -1
- package/dist/utils/typed-field.js +2 -2
- package/dist/utils/verdicts.js +1 -1
- package/entities/operators.ts +1 -1
- package/package.json +101 -90
- package/report/errorTypes/vocabulary/ids.ts +7 -2
- package/report/errorTypes/vocabulary/phrases.ts +47 -27
- package/report/errorTypes/vocabulary/places.ts +21 -16
- package/report/user-report/shared/describe.ts +7 -7
- package/dist/code-roles/classify.d.ts +0 -11
- package/dist/code-roles/classify.js +0 -43
- package/dist/code-roles/connector.d.ts +0 -5
- package/dist/code-roles/connector.js +0 -114
- package/dist/code-roles/project.d.ts +0 -12
- package/dist/code-roles/project.js +0 -122
- package/dist/code-roles/roles.d.ts +0 -8
- package/dist/invariants/index.d.ts +0 -6
- package/dist/invariants/normalize.d.ts +0 -4
- package/dist/invariants/normalize.js +0 -95
- package/dist/nodes/child-roles.d.ts +0 -3
- package/dist/nodes/child-roles.js +0 -12
- package/dist/nodes/finally/roles.d.ts +0 -13
- package/dist/nodes/finally/roles.js +0 -41
- package/dist/report/errorTypes/types/unknownRole.d.ts +0 -9
- package/dist/report/user-report/data/graph-roles.d.ts +0 -5
- package/dist/report/user-report/data/graph-roles.js +0 -71
- package/dist/report/user-report/data/invariants.d.ts +0 -7
- package/dist/report/user-report/data/role-examples.js +0 -94
- package/dist/report/user-report/data/role-marks.d.ts +0 -5
- package/dist/report/user-report/data/roles.d.ts +0 -7
- /package/dist/{invariants → rules}/name.d.ts +0 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enrich = exports.applies = exports.id = void 0;
|
|
4
|
+
// Tests: what a file written for a test runner is.
|
|
5
|
+
//
|
|
6
|
+
// The engine sees `describe(...)`, `it(...)`, `expect(...)` as calls like any
|
|
7
|
+
// other; this facet reads them as a test file's facts, so an entity can be
|
|
8
|
+
// inferred from what the file DOES rather than from where it happens to live:
|
|
9
|
+
//
|
|
10
|
+
// runner the module the test API was imported from (`vitest` → "vitest",
|
|
11
|
+
// `@jest/globals` → "jest")
|
|
12
|
+
// cases `it`/`test` calls — the tests themselves
|
|
13
|
+
// asserts `expect` calls
|
|
14
|
+
// hooks the `before*`/`after*` hooks the file installs, by name
|
|
15
|
+
// snapshots `toMatchSnapshot`/`toMatchInlineSnapshot` calls
|
|
16
|
+
// mocks `vi.*`/`jest.*` mock calls
|
|
17
|
+
//
|
|
18
|
+
// A TYPE-only import is a TypeScript reading, not a test: `import type { Mock }
|
|
19
|
+
// from "vitest"` — or a `type` specifier — brings no runtime, so a file that only
|
|
20
|
+
// borrows a test type stays a plain module.
|
|
21
|
+
//
|
|
22
|
+
// The facts are the FILE's: a test file is a test file in every piece it declares,
|
|
23
|
+
// the same way the vue and angular gates attach their base to every candidate. The
|
|
24
|
+
// namespace is written through `attach`, so a component reading already on the
|
|
25
|
+
// candidate (a `.tsx` test that renders) keeps its id and its jsx — the test facts
|
|
26
|
+
// sit beside it instead of replacing them.
|
|
27
|
+
const ts_morph_1 = require("ts-morph");
|
|
28
|
+
const tree_1 = require("@md-code/follow-architecture/entities/ast/tree");
|
|
29
|
+
const properties_1 = require("@md-code/follow-architecture/entities/ast/properties");
|
|
30
|
+
const facet_1 = require("@md-code/follow-architecture/frameworks/facet");
|
|
31
|
+
const id = "test";
|
|
32
|
+
exports.id = id;
|
|
33
|
+
// The modules a test runtime is imported FROM, and the id the fact carries. A
|
|
34
|
+
// reader's vocabulary, not the engine's: another runner is one entry here.
|
|
35
|
+
const RUNNERS = new Map([
|
|
36
|
+
["vitest", "vitest"],
|
|
37
|
+
["@jest/globals", "jest"],
|
|
38
|
+
]);
|
|
39
|
+
// Does the import bring a VALUE binding? A `type`-only declaration, or one whose
|
|
40
|
+
// every named specifier is `type`, is the type checker's business only.
|
|
41
|
+
const hasValueBinding = (declaration) => {
|
|
42
|
+
if (declaration.isTypeOnly())
|
|
43
|
+
return false;
|
|
44
|
+
const named = declaration.getNamedImports();
|
|
45
|
+
if (named.length === 0)
|
|
46
|
+
return true;
|
|
47
|
+
return named.some((specifier) => !specifier.isTypeOnly());
|
|
48
|
+
};
|
|
49
|
+
const runnerOf = (sf) => {
|
|
50
|
+
for (const declaration of sf.getImportDeclarations()) {
|
|
51
|
+
const runner = RUNNERS.get(declaration.getModuleSpecifierValue());
|
|
52
|
+
if (runner && hasValueBinding(declaration))
|
|
53
|
+
return runner;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
};
|
|
57
|
+
// The call NAMES a test file is written with — the runners' own vocabulary, so it
|
|
58
|
+
// lives here rather than in the engine. A name is read as its chain's ROOT
|
|
59
|
+
// (`it.each(…)` is a case, `expect(x).toMatchSnapshot()` is an assertion), and the
|
|
60
|
+
// terminal member is kept for the matchers.
|
|
61
|
+
const CASES = new Set(["it", "test"]);
|
|
62
|
+
const ASSERTS = new Set(["expect"]);
|
|
63
|
+
const HOOKS = new Set(["beforeAll", "beforeEach", "afterAll", "afterEach"]);
|
|
64
|
+
const SNAPSHOTS = new Set(["toMatchSnapshot", "toMatchInlineSnapshot"]);
|
|
65
|
+
const MOCKS = new Set([
|
|
66
|
+
"mock",
|
|
67
|
+
"doMock",
|
|
68
|
+
"unmock",
|
|
69
|
+
"doUnmock",
|
|
70
|
+
"fn",
|
|
71
|
+
"spyOn",
|
|
72
|
+
"stubGlobal",
|
|
73
|
+
"mocked",
|
|
74
|
+
"importActual",
|
|
75
|
+
"importMock",
|
|
76
|
+
]);
|
|
77
|
+
const MOCK_ROOTS = new Set(["vi", "jest"]);
|
|
78
|
+
// A chain is ONE call. `expect(x).toBe(y)` is a single assertion and its inner
|
|
79
|
+
// `expect(x)` is where that assertion begins — counting both would double every
|
|
80
|
+
// number the reader reports, so a call that is a chain's first link is skipped and
|
|
81
|
+
// the outermost call speaks for it.
|
|
82
|
+
const isChainStart = (call) => {
|
|
83
|
+
const parent = call.getParent();
|
|
84
|
+
if (!parent)
|
|
85
|
+
return false;
|
|
86
|
+
if (ts_morph_1.Node.isPropertyAccessExpression(parent) || ts_morph_1.Node.isElementAccessExpression(parent))
|
|
87
|
+
return parent.getExpression() === call;
|
|
88
|
+
if (ts_morph_1.Node.isCallExpression(parent))
|
|
89
|
+
return parent.getExpression() === call;
|
|
90
|
+
if (ts_morph_1.Node.isTaggedTemplateExpression(parent))
|
|
91
|
+
return parent.getTag() === call;
|
|
92
|
+
return false;
|
|
93
|
+
};
|
|
94
|
+
const rootOf = (expr) => {
|
|
95
|
+
const origin = (0, properties_1.leftmostOrigin)(expr);
|
|
96
|
+
return origin ? origin.split(".")[0] : null;
|
|
97
|
+
};
|
|
98
|
+
// One call, one bucket — the bucket its root names (`vi.mock` is a mock, `it` a
|
|
99
|
+
// case, `expect` an assertion). A chain speaks once: the outermost call is counted,
|
|
100
|
+
// the inner `expect(x)` is the same assertion beginning.
|
|
101
|
+
const tally = (target, counts, hooks) => {
|
|
102
|
+
const root = rootOf(target);
|
|
103
|
+
const member = (0, properties_1.lastMemberName)(target);
|
|
104
|
+
if (!root)
|
|
105
|
+
return;
|
|
106
|
+
if (CASES.has(root))
|
|
107
|
+
counts.cases += 1;
|
|
108
|
+
if (HOOKS.has(root))
|
|
109
|
+
hooks.add(root);
|
|
110
|
+
if (MOCK_ROOTS.has(root) && member !== null && MOCKS.has(member))
|
|
111
|
+
counts.mocks += 1;
|
|
112
|
+
if (!ASSERTS.has(root))
|
|
113
|
+
return;
|
|
114
|
+
// A snapshot match IS an assertion — counted as both, because the two questions
|
|
115
|
+
// a rule asks ("is anything asserted here?" and "does this file pin output?")
|
|
116
|
+
// have different answers.
|
|
117
|
+
counts.asserts += 1;
|
|
118
|
+
if (member !== null && SNAPSHOTS.has(member))
|
|
119
|
+
counts.snapshots += 1;
|
|
120
|
+
};
|
|
121
|
+
// What the file's calls say: one walk over the calls it makes.
|
|
122
|
+
const countsOf = (sf) => {
|
|
123
|
+
const counts = { cases: 0, asserts: 0, snapshots: 0, mocks: 0 };
|
|
124
|
+
const hooks = new Set();
|
|
125
|
+
for (const call of sf.getDescendantsOfKind(tree_1.SK.CallExpression)) {
|
|
126
|
+
if (!isChainStart(call))
|
|
127
|
+
tally(call.getExpression(), counts, hooks);
|
|
128
|
+
}
|
|
129
|
+
return { ...counts, hooks: [...hooks] };
|
|
130
|
+
};
|
|
131
|
+
// The file's test facts — or nothing at all. A file with no test runtime and no
|
|
132
|
+
// test call is not a test file, so it gets no `framework.test` (an absent fact is
|
|
133
|
+
// never a false one).
|
|
134
|
+
const testFactsOf = (sf) => {
|
|
135
|
+
const runner = runnerOf(sf);
|
|
136
|
+
const counts = countsOf(sf);
|
|
137
|
+
if (!runner && !counts.cases && !counts.asserts)
|
|
138
|
+
return null;
|
|
139
|
+
return { runner, ...counts };
|
|
140
|
+
};
|
|
141
|
+
const enrich = (candidates, ctx) => {
|
|
142
|
+
const test = ctx.sf ? testFactsOf(ctx.sf) : null;
|
|
143
|
+
if (!test)
|
|
144
|
+
return candidates;
|
|
145
|
+
for (const candidate of candidates) {
|
|
146
|
+
// The component readers own `id` where they spoke; the test reader names the
|
|
147
|
+
// file only where nobody else did.
|
|
148
|
+
(0, facet_1.attach)(candidate, { id: candidate.framework?.id ?? id, test });
|
|
149
|
+
}
|
|
150
|
+
return candidates;
|
|
151
|
+
};
|
|
152
|
+
exports.enrich = enrich;
|
|
153
|
+
// Cheap gate: a test runtime imported, or a call spelled like a test API (the
|
|
154
|
+
// globals-only flavour — a jest file that imports nothing). A .ts helper pays a
|
|
155
|
+
// text scan and, when it calls nothing test-shaped, one import read.
|
|
156
|
+
const applies = ({ sf }) => Boolean(sf) && (runnerOf(sf) !== null || /(^|[^\w$.])(it|test|expect)\s*\(/.test(sf.getFullText()));
|
|
157
|
+
exports.applies = applies;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Candidate } from "
|
|
2
|
-
import type
|
|
1
|
+
import type { Candidate } from "@md-code/follow-architecture/entities/facts";
|
|
2
|
+
import { type FacetContext } from "@md-code/follow-architecture/frameworks/facet";
|
|
3
3
|
declare const id = "vue";
|
|
4
4
|
declare const enrich: (candidates: Candidate[]) => Candidate[];
|
|
5
5
|
declare const applies: ({ rel, text }: FacetContext) => boolean;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.enrich = exports.classAttributes = exports.applies = exports.id = void 0;
|
|
4
|
+
const facet_1 = require("@md-code/follow-architecture/frameworks/facet");
|
|
4
5
|
const id = "vue";
|
|
5
6
|
exports.id = id;
|
|
6
7
|
const enrich = (candidates) => {
|
|
7
8
|
for (const candidate of candidates) {
|
|
8
|
-
candidate
|
|
9
|
+
(0, facet_1.attach)(candidate, { id, component: false, props: [], forwarded: [] });
|
|
9
10
|
}
|
|
10
11
|
return candidates;
|
|
11
12
|
};
|
package/dist/ignore.d.ts
ADDED
package/dist/ignore.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IGNORE_PATHS = exports.IGNORE_DIRS = void 0;
|
|
4
|
+
// THE SCAN SCOPE OF THE TOOL, for directories. One list, two callers: the CLI
|
|
5
|
+
// (`--ignore-dir` ADDS to it) and the ESLint rule (`ignoreDirs` ADDS to it), so
|
|
6
|
+
// a lint run and a scan run look at the same files — they used to disagree, and
|
|
7
|
+
// the rule's extra entries existed only because its scan was repo-wide.
|
|
8
|
+
//
|
|
9
|
+
// Every entry is a directory NAME, matched at any depth (see `walk`): generated
|
|
10
|
+
// output, installed dependencies and tooling/config folders, none of which is
|
|
11
|
+
// under the architecture contract. `utils/node/files` keeps dot-entries out by
|
|
12
|
+
// default; the dot folders that ARE scanned here (`.github`, `.changeset`, …)
|
|
13
|
+
// are listed precisely because the walk visits dot-entries for this tool.
|
|
14
|
+
const IGNORE_DIRS = [
|
|
15
|
+
"node_modules",
|
|
16
|
+
".git",
|
|
17
|
+
".vscode-test",
|
|
18
|
+
"out",
|
|
19
|
+
"dist",
|
|
20
|
+
"build",
|
|
21
|
+
"coverage",
|
|
22
|
+
".next",
|
|
23
|
+
".keystone",
|
|
24
|
+
"reports",
|
|
25
|
+
".turbo",
|
|
26
|
+
".artifacts",
|
|
27
|
+
"screenshots",
|
|
28
|
+
".agent",
|
|
29
|
+
".changeset",
|
|
30
|
+
".github",
|
|
31
|
+
];
|
|
32
|
+
exports.IGNORE_DIRS = IGNORE_DIRS;
|
|
33
|
+
// THE SCAN SCOPE OF THE TOOL, for paths. `IGNORE_DIRS` above matches a NAME at
|
|
34
|
+
// any depth; this list names the repo-relative places that are not under the
|
|
35
|
+
// architecture contract yet: the deployable apps, the platform packages only
|
|
36
|
+
// those apps consume, the tooling scripts and the root config files. Paths and
|
|
37
|
+
// globs, not names, on purpose — `packages/native` is out of scope while
|
|
38
|
+
// `packages/follow-architecture/report/user-report/cli-report.ts` and
|
|
39
|
+
// `packages/follow-architecture/tests/cli/` are IN it, and a folder name cannot
|
|
40
|
+
// tell them apart.
|
|
41
|
+
//
|
|
42
|
+
// One list, three consumers: the CLI (`--ignore` ADDS to it), the ESLint rule
|
|
43
|
+
// (`ignores` ADDS to it) and the flat config's global `ignores` in
|
|
44
|
+
// `packages/eslint/base.js`. A scan, a lint run and the editor's server therefore
|
|
45
|
+
// see the same files. Every entry is a minimatch pattern against a path relative
|
|
46
|
+
// to the repo root.
|
|
47
|
+
const IGNORE_PATHS = [
|
|
48
|
+
"apps/**",
|
|
49
|
+
"packages/api/**",
|
|
50
|
+
"packages/native/**",
|
|
51
|
+
"packages/cli/**",
|
|
52
|
+
"packages/infrastructure/**",
|
|
53
|
+
"packages/stylelint/**",
|
|
54
|
+
"scripts/**",
|
|
55
|
+
// Every JS file, at any depth: the repo's sources are TypeScript, so a `.js`,
|
|
56
|
+
// `.cjs` or `.mjs` here is a config or a build artifact, not contract code. This
|
|
57
|
+
// also covers the root configs (`eslint.config.mjs`, `*.config.js`).
|
|
58
|
+
"**/*.js",
|
|
59
|
+
"**/*.cjs",
|
|
60
|
+
"**/*.mjs",
|
|
61
|
+
];
|
|
62
|
+
exports.IGNORE_PATHS = IGNORE_PATHS;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type FileRecord } from "./facts-record";
|
|
2
|
+
import { type ProjectEntityIndex } from "./code-entities/project";
|
|
3
|
+
import { type Index } from "./fa-index";
|
|
4
|
+
import { type Light, type Summary } from "./fa-values";
|
|
5
|
+
import type { Arch } from "./entities/architecture";
|
|
6
|
+
import type { Candidate } from "./entities/facts";
|
|
7
|
+
import type { Finding } from "./entities/findings";
|
|
8
|
+
import type { RunArgs } from "./index-run";
|
|
9
|
+
import type { Project } from "ts-morph";
|
|
10
|
+
import type { SeenStore } from "./utils/seen";
|
|
11
|
+
declare const emptyRegistry: () => ProjectEntityIndex;
|
|
12
|
+
declare const addSummary: (index: ProjectEntityIndex, abs: string, rel: string, summary: Summary) => void;
|
|
13
|
+
declare const addPieces: (index: ProjectEntityIndex, candidates: readonly Candidate[]) => void;
|
|
14
|
+
declare const registryFromIndex: (index: Index, arch: Arch, absFiles: readonly string[], repoFiles: readonly string[]) => ProjectEntityIndex;
|
|
15
|
+
declare const readOne: (abs: string, run: {
|
|
16
|
+
arch: Arch;
|
|
17
|
+
repoFiles: string[];
|
|
18
|
+
}, project: Project) => FileRecord;
|
|
19
|
+
type ScanArgs = {
|
|
20
|
+
run: RunArgs;
|
|
21
|
+
index: Index;
|
|
22
|
+
light: Map<string, Light>;
|
|
23
|
+
kept: Map<string, FileRecord>;
|
|
24
|
+
absFiles: readonly string[];
|
|
25
|
+
live: ReadonlySet<string>;
|
|
26
|
+
projectOpen: boolean;
|
|
27
|
+
};
|
|
28
|
+
declare const recordFor: (args: ScanArgs, abs: string) => FileRecord;
|
|
29
|
+
type FileAt = {
|
|
30
|
+
abs: string;
|
|
31
|
+
entry: Light | undefined;
|
|
32
|
+
fresh: boolean;
|
|
33
|
+
};
|
|
34
|
+
declare const checkOne: (args: ScanArgs, file: FileAt, findings: Finding[]) => boolean;
|
|
35
|
+
type OneFileRun = {
|
|
36
|
+
arch: Arch;
|
|
37
|
+
repoFiles: string[];
|
|
38
|
+
dedupe: SeenStore;
|
|
39
|
+
index: Index | null;
|
|
40
|
+
};
|
|
41
|
+
declare const checkIndexed: (abs: string, run: OneFileRun, buffer?: string | null) => Finding[];
|
|
42
|
+
export { emptyRegistry, addSummary, addPieces, readOne, recordFor, checkOne, checkIndexed, registryFromIndex };
|
|
43
|
+
export type { ScanArgs };
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registryFromIndex = exports.checkIndexed = exports.checkOne = exports.recordFor = exports.readOne = exports.addPieces = exports.addSummary = exports.emptyRegistry = void 0;
|
|
4
|
+
// ONE FILE, AS THE INDEXED RUN NEEDS IT: the project-wide index a summary feeds,
|
|
5
|
+
// the record of a file this run has to read again, and the check that turns that
|
|
6
|
+
// record into the verdicts stored in the light section. Nothing here opens or
|
|
7
|
+
// drives the index — `index-run.ts` decides what is read and in which order.
|
|
8
|
+
const facts_record_1 = require("./facts-record");
|
|
9
|
+
const classify_1 = require("./code-entities/classify");
|
|
10
|
+
const project_1 = require("./code-entities/project");
|
|
11
|
+
const fa_index_1 = require("./fa-index");
|
|
12
|
+
const rules_1 = require("./rules");
|
|
13
|
+
const notices_1 = require("./report/notices");
|
|
14
|
+
const release_file_1 = require("./release-file");
|
|
15
|
+
const scan_run_1 = require("./scan-run");
|
|
16
|
+
const closure_project_1 = require("./closure-project");
|
|
17
|
+
const ast_1 = require("./entities/ast");
|
|
18
|
+
const group_1 = require("./utils/group");
|
|
19
|
+
const fa_values_1 = require("./fa-values");
|
|
20
|
+
// The project-wide index, rebuilt from summaries. Every piece here was produced by
|
|
21
|
+
// the same per-file classification the AST pass runs, so the answers are the ones
|
|
22
|
+
// that pass would give — without reading a single record.
|
|
23
|
+
const emptyRegistry = () => ({
|
|
24
|
+
bySlug: new Map(),
|
|
25
|
+
objectsBySlug: new Map(),
|
|
26
|
+
entitiesByFile: new Map(),
|
|
27
|
+
});
|
|
28
|
+
exports.emptyRegistry = emptyRegistry;
|
|
29
|
+
// One file's summary, handed to the registry: no parse, only grouping. The pieces
|
|
30
|
+
// are not in a summary (they are the bulk of the index), so `bySlug` stays empty
|
|
31
|
+
// until `addPieces` is called — which a run does only when a rule names a code
|
|
32
|
+
// entity, the same condition that makes the checks ask for `entityScope`.
|
|
33
|
+
const addSummary = (index, abs, rel, summary) => {
|
|
34
|
+
for (const object of summary.objects)
|
|
35
|
+
(0, group_1.pushGroup)(index.objectsBySlug, object.entity, { ...object, path: abs });
|
|
36
|
+
index.entitiesByFile.set(rel, new Set(summary.entities));
|
|
37
|
+
};
|
|
38
|
+
exports.addSummary = addSummary;
|
|
39
|
+
// One file's classified pieces, for the `entity` scope: the owners of names, keyed
|
|
40
|
+
// by entity, exactly the grouping the unfiled pass builds from the same list.
|
|
41
|
+
const addPieces = (index, candidates) => {
|
|
42
|
+
for (const candidate of candidates) {
|
|
43
|
+
if (candidate.entity)
|
|
44
|
+
(0, group_1.pushGroup)(index.bySlug, candidate.entity, candidate);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.addPieces = addPieces;
|
|
48
|
+
// The project-wide index as the INDEX holds it: every file's summary, plus the
|
|
49
|
+
// pieces when a rule names a code entity — the same two sections a scan reads
|
|
50
|
+
// before its checks. The rule path asks about one file at a time and never walks
|
|
51
|
+
// the tree, so this is where its `entity` scope and its objects come from; the run
|
|
52
|
+
// caches the answer by its file list, so a lint session reads these sections once.
|
|
53
|
+
const registryFromIndex = (index, arch, absFiles, repoFiles) => {
|
|
54
|
+
const light = (0, fa_index_1.readLight)(index, absFiles);
|
|
55
|
+
const registry = emptyRegistry();
|
|
56
|
+
for (let at = 0; at < absFiles.length; at += 1) {
|
|
57
|
+
const entry = light.get(absFiles[at]);
|
|
58
|
+
if (entry !== undefined)
|
|
59
|
+
addSummary(registry, absFiles[at], repoFiles[at], entry.summary);
|
|
60
|
+
}
|
|
61
|
+
if ((0, facts_record_1.namesCodeEntity)(arch.rules)) {
|
|
62
|
+
for (const list of (0, fa_index_1.readPeers)(index, (0, fa_index_1.pieceFiles)(light, (0, rules_1.namedEntitySlugs)(arch.rules))).values())
|
|
63
|
+
addPieces(registry, list);
|
|
64
|
+
}
|
|
65
|
+
return registry;
|
|
66
|
+
};
|
|
67
|
+
exports.registryFromIndex = registryFromIndex;
|
|
68
|
+
// One file's record as a run needs it before checking: facts, classified pieces,
|
|
69
|
+
// the literals' places. The syntax is released on the way out — facts, objects and
|
|
70
|
+
// the templates' positions are what a check needs, never the tree.
|
|
71
|
+
const readOne = (abs, run, project) => {
|
|
72
|
+
const record = (0, facts_record_1.extractFileFacts)(abs, { arch: run.arch, project, repoFiles: run.repoFiles });
|
|
73
|
+
// Classify NOW, not in the scan pass: the project-wide index is rebuilt from
|
|
74
|
+
// these values before any file is checked, and it is the entity of a piece that
|
|
75
|
+
// decides which entity owns which object literal.
|
|
76
|
+
const classified = (0, classify_1.classifyEntities)(record.candidates, run.arch.entities, run.arch, record.facts);
|
|
77
|
+
record.candidates = classified.candidates;
|
|
78
|
+
record.facts.entities = [...new Set(classified.present)];
|
|
79
|
+
const sf = project.getSourceFile(abs) ?? null;
|
|
80
|
+
record.objects = (0, project_1.fileObjects)(sf, classified.candidates);
|
|
81
|
+
if (sf !== null)
|
|
82
|
+
(0, release_file_1.releaseFile)(sf);
|
|
83
|
+
return record;
|
|
84
|
+
};
|
|
85
|
+
exports.readOne = readOne;
|
|
86
|
+
// The record this check reads: read again by this run, stored by an earlier one, or
|
|
87
|
+
// — when the index may not be written — still held by the extraction. A record that
|
|
88
|
+
// cannot be read back at all is read again here rather than losing the answer.
|
|
89
|
+
const recordFor = (args, abs) => args.kept.get(abs) ?? (0, fa_index_1.recordAt)(args.index, abs) ?? readOne(abs, args.run, (0, scan_run_1.wholeRepoProject)());
|
|
90
|
+
exports.recordFor = recordFor;
|
|
91
|
+
// The live project answers the lookalike layer, and only about a file this run
|
|
92
|
+
// read again: a stored record was checked against the syntax of its own run.
|
|
93
|
+
// The lookalike nodes are the one answer this run may not be able to ask for:
|
|
94
|
+
// without a project they come from the verdicts stored with the record.
|
|
95
|
+
const nodesOf = (project, parts, stored) => project === null ? stored : parts.nodes;
|
|
96
|
+
// The verdicts, stored where the next run reads them: the light section.
|
|
97
|
+
const storeVerdict = (args, file, record, parts) => {
|
|
98
|
+
const summary = file.entry?.summary ?? (0, fa_values_1.summaryOf)(record);
|
|
99
|
+
const verdict = { findings: parts, notices: [...record.notices], summary };
|
|
100
|
+
args.light.set(file.abs, verdict);
|
|
101
|
+
return (0, fa_index_1.keepVerdict)(args.index, file.abs, verdict);
|
|
102
|
+
};
|
|
103
|
+
// Check one file against the state of this run. The record is dropped with the
|
|
104
|
+
// chunk it was read in: a check reads its OWN record and the registry (`bySlug`,
|
|
105
|
+
// objects, entities per file), never another file's facts.
|
|
106
|
+
const checkOne = (args, file, findings) => {
|
|
107
|
+
const { run, projectOpen, index } = args;
|
|
108
|
+
const record = recordFor(args, file.abs);
|
|
109
|
+
const project = projectOpen ? (0, scan_run_1.wholeRepoProject)() : null;
|
|
110
|
+
// The file's record already carries its literals' places, and its checker
|
|
111
|
+
// answers come from the run's usage pass: nothing here needs this file's syntax.
|
|
112
|
+
const usage = index === null ? null : (0, fa_index_1.usageAt)(index, file.abs);
|
|
113
|
+
const stored = file.entry?.findings?.nodes ?? [];
|
|
114
|
+
const parts = (0, facts_record_1.checkRecord)(record, {
|
|
115
|
+
arch: run.arch,
|
|
116
|
+
project,
|
|
117
|
+
repoFiles: run.repoFiles,
|
|
118
|
+
dedupe: run.dedupe,
|
|
119
|
+
sf: null,
|
|
120
|
+
usage,
|
|
121
|
+
});
|
|
122
|
+
findings.push(...parts.before, ...nodesOf(project, parts, stored), ...parts.after);
|
|
123
|
+
return storeVerdict(args, file, record, parts);
|
|
124
|
+
};
|
|
125
|
+
exports.checkOne = checkOne;
|
|
126
|
+
// The buffer's own syntax, in a project of its own: the run's project holds the
|
|
127
|
+
// files as they are on disk, and rewriting one of them would answer for the others
|
|
128
|
+
// with text nobody saved.
|
|
129
|
+
const bufferProject = (abs, text, arch) => {
|
|
130
|
+
const project = (0, ast_1.createTsProject)({ repoRoot: arch.repoRoot ?? ".", aliases: arch.aliases });
|
|
131
|
+
(0, ast_1.loadSourceFile)(project, abs, text);
|
|
132
|
+
return project;
|
|
133
|
+
};
|
|
134
|
+
// The file's own syntax, in a project of its own: `buffer` is text the index has
|
|
135
|
+
// never seen, and rewriting the run's project would answer for the others with it.
|
|
136
|
+
const fromBuffer = (abs, text, run) => {
|
|
137
|
+
const project = bufferProject(abs, text, run.arch);
|
|
138
|
+
return {
|
|
139
|
+
record: (0, facts_record_1.extractFileFacts)(abs, { arch: run.arch, project, repoFiles: run.repoFiles, text }),
|
|
140
|
+
project,
|
|
141
|
+
source: project.getSourceFile(abs) ?? null,
|
|
142
|
+
fromDisk: false,
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
// The project a file without a record is read in. A run that already opened the
|
|
146
|
+
// whole repo (the scan, or the lookalike question) reuses it — the CLI pays
|
|
147
|
+
// nothing new. A rule on one file builds that file's own closure instead: the
|
|
148
|
+
// files its syntax reaches, which is what its css values and its parameter types
|
|
149
|
+
// are answered from, without the repo-wide parse that made the first check after
|
|
150
|
+
// an edit take seconds. With no index at all the checker's own answers (who calls
|
|
151
|
+
// a name) have to come from a project holding the repo — a closure would answer
|
|
152
|
+
// "nobody" for a helper the rest of the repo calls — so the whole one opens, as
|
|
153
|
+
// it always did.
|
|
154
|
+
const projectFor = (abs, run) => {
|
|
155
|
+
const open = (0, scan_run_1.openWholeRepoProject)();
|
|
156
|
+
if (open !== null)
|
|
157
|
+
return open;
|
|
158
|
+
if (run.index === null)
|
|
159
|
+
return (0, scan_run_1.wholeRepoProject)();
|
|
160
|
+
return (0, closure_project_1.openClosure)(abs, run.arch, run.repoFiles);
|
|
161
|
+
};
|
|
162
|
+
const loadOne = (abs, run, buffer) => {
|
|
163
|
+
if (buffer !== undefined && buffer !== null)
|
|
164
|
+
return fromBuffer(abs, buffer, run);
|
|
165
|
+
const fromIndex = run.index === null ? null : (0, fa_index_1.recordAt)(run.index, abs);
|
|
166
|
+
// The record answers on its own; only a file this index cannot answer for is
|
|
167
|
+
// read, and in a project of its own closure.
|
|
168
|
+
if (fromIndex !== null)
|
|
169
|
+
return { record: fromIndex, project: null, source: null, fromDisk: true };
|
|
170
|
+
const project = projectFor(abs, run);
|
|
171
|
+
return {
|
|
172
|
+
record: (0, facts_record_1.extractFileFacts)(abs, { arch: run.arch, project, repoFiles: run.repoFiles }),
|
|
173
|
+
project,
|
|
174
|
+
source: project.getSourceFile(abs) ?? null,
|
|
175
|
+
fromDisk: true,
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
// THE ONE-FILE PATH (the ESLint rule): the answer for THIS file, from a record when
|
|
179
|
+
// the index has a fresh one and from its syntax when it does not. `sf` is that
|
|
180
|
+
// syntax, handed in by the caller because the rule may hold the editor's buffer
|
|
181
|
+
// instead of the file on disk; the checker's answers are asked here, on it, when
|
|
182
|
+
// the index has none stored.
|
|
183
|
+
// THE RULE ONLY READS. A record derived here answers for the project it was derived
|
|
184
|
+
// in — a file's closure, or the editor's buffer — and the CLI's warm run must never
|
|
185
|
+
// replay such an answer as if the whole repo had given it: `off` would stop matching
|
|
186
|
+
// `warm` depending on what was edited in which order. Writing the index stays the
|
|
187
|
+
// CLI's alone, so the file the CLI wrote is the file every reader meets.
|
|
188
|
+
// The scan already answered this file, and the index still holds that answer:
|
|
189
|
+
// the verdict IS the answer. Re-deriving it here would ask the questions that
|
|
190
|
+
// needed the project (the lookalike folder, an object literal's resolution)
|
|
191
|
+
// again — without one, the answer would quietly be a different one.
|
|
192
|
+
const replayed = (abs, run, buffer) => {
|
|
193
|
+
if (buffer !== undefined && buffer !== null)
|
|
194
|
+
return null;
|
|
195
|
+
const stored = run.index === null ? null : (0, fa_index_1.lightAt)(run.index, abs);
|
|
196
|
+
if (stored === null || stored.findings === null)
|
|
197
|
+
return null;
|
|
198
|
+
(0, notices_1.replayNotices)(stored.notices);
|
|
199
|
+
return [...stored.findings.before, ...stored.findings.nodes, ...stored.findings.after];
|
|
200
|
+
};
|
|
201
|
+
const checkIndexed = (abs, run, buffer) => {
|
|
202
|
+
const answer = replayed(abs, run, buffer);
|
|
203
|
+
if (answer !== null)
|
|
204
|
+
return answer;
|
|
205
|
+
const loaded = loadOne(abs, run, buffer);
|
|
206
|
+
const parts = (0, facts_record_1.checkRecord)(loaded.record, {
|
|
207
|
+
arch: run.arch,
|
|
208
|
+
project: loaded.project,
|
|
209
|
+
repoFiles: run.repoFiles,
|
|
210
|
+
dedupe: run.dedupe,
|
|
211
|
+
sf: loaded.source,
|
|
212
|
+
usage: run.index === null ? null : (0, fa_index_1.usageAt)(run.index, abs),
|
|
213
|
+
});
|
|
214
|
+
if (!loaded.fromDisk && loaded.source !== null)
|
|
215
|
+
(0, release_file_1.releaseFile)(loaded.source);
|
|
216
|
+
return [...parts.before, ...parts.nodes, ...parts.after];
|
|
217
|
+
};
|
|
218
|
+
exports.checkIndexed = checkIndexed;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ScanScope } from "./fa-index";
|
|
2
|
+
import type { Arch } from "./entities/architecture";
|
|
3
|
+
import type { Finding } from "./entities/findings";
|
|
4
|
+
import type { SeenStore } from "./utils/seen";
|
|
5
|
+
type RunArgs = {
|
|
6
|
+
arch: Arch;
|
|
7
|
+
repoFiles: string[];
|
|
8
|
+
absFiles: readonly string[];
|
|
9
|
+
scope: ScanScope;
|
|
10
|
+
option: string | boolean | null | undefined;
|
|
11
|
+
dedupe: SeenStore;
|
|
12
|
+
shouldCheck?: ((abs: string) => boolean) | null;
|
|
13
|
+
usage?: string;
|
|
14
|
+
};
|
|
15
|
+
type RunStats = {
|
|
16
|
+
mode: "warm" | "hybrid" | "cold";
|
|
17
|
+
stale: number;
|
|
18
|
+
zone: number;
|
|
19
|
+
extracted: number;
|
|
20
|
+
written: number;
|
|
21
|
+
bytes: number;
|
|
22
|
+
chunks: number;
|
|
23
|
+
compactions: number;
|
|
24
|
+
pruned: number;
|
|
25
|
+
warning: string | null;
|
|
26
|
+
compactionWarning: string | null;
|
|
27
|
+
usageFiles: number;
|
|
28
|
+
usageNames: number;
|
|
29
|
+
projectsOpened: number;
|
|
30
|
+
checksProjects: number;
|
|
31
|
+
};
|
|
32
|
+
type RunOut = {
|
|
33
|
+
findings: Finding[];
|
|
34
|
+
stats: RunStats;
|
|
35
|
+
};
|
|
36
|
+
declare const runIndexed: (run: RunArgs) => RunOut | null;
|
|
37
|
+
export { runIndexed };
|
|
38
|
+
export { checkIndexed, registryFromIndex } from "./index-file";
|
|
39
|
+
export type { RunArgs, RunOut, RunStats };
|