@ecoma-io/archkeep 0.13.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/LICENSE +202 -0
- package/README.md +262 -0
- package/cli.mjs +2792 -0
- package/index.mjs +85 -0
- package/lsp.mjs +81 -0
- package/nx.mjs +24 -0
- package/package.json +81 -0
- package/presets/clean-architecture.json +78 -0
- package/presets/ddd-bounded-contexts.json +88 -0
- package/presets/hexagonal.json +68 -0
- package/presets/layered.json +92 -0
- package/presets/modular-monolith.json +85 -0
- package/presets/vertical-slice.json +68 -0
- package/src/analysis/analyze.mjs +218 -0
- package/src/analysis/contract.md +259 -0
- package/src/analysis/go.mjs +414 -0
- package/src/analysis/manifest-util.mjs +68 -0
- package/src/analysis/python.mjs +1266 -0
- package/src/analysis/registry.mjs +74 -0
- package/src/analysis/rust.mjs +674 -0
- package/src/analysis/source-util.mjs +230 -0
- package/src/analysis/typescript.mjs +1034 -0
- package/src/analysis/vue.mjs +156 -0
- package/src/architecture-intent/intent-fingerprint.mjs +29 -0
- package/src/architecture-intent/judge.mjs +539 -0
- package/src/architecture-intent/model.mjs +703 -0
- package/src/architecture-intent/selectors.mjs +170 -0
- package/src/canonical.mjs +48 -0
- package/src/commands/README.md +266 -0
- package/src/commands/adr.mjs +248 -0
- package/src/commands/check.mjs +989 -0
- package/src/commands/context-command.mjs +212 -0
- package/src/commands/context.mjs +790 -0
- package/src/commands/custom-rules.mjs +428 -0
- package/src/commands/debt.mjs +218 -0
- package/src/commands/diff.mjs +523 -0
- package/src/commands/discover.mjs +159 -0
- package/src/commands/drift.mjs +473 -0
- package/src/commands/edge-constraints.mjs +355 -0
- package/src/commands/explain.mjs +359 -0
- package/src/commands/fitness.mjs +226 -0
- package/src/commands/graph.mjs +297 -0
- package/src/commands/health.mjs +213 -0
- package/src/commands/history.mjs +614 -0
- package/src/commands/impact.mjs +226 -0
- package/src/commands/plan-context-command.mjs +496 -0
- package/src/commands/policy.mjs +138 -0
- package/src/commands/provenance-command.mjs +352 -0
- package/src/commands/provenance.mjs +159 -0
- package/src/commands/reconcile.mjs +219 -0
- package/src/commands/report.mjs +553 -0
- package/src/commands/snapshot-meta.mjs +107 -0
- package/src/commands/waivers.mjs +240 -0
- package/src/config.mjs +1308 -0
- package/src/containment.mjs +234 -0
- package/src/custom-rules/evidence.mjs +340 -0
- package/src/custom-rules/host.mjs +1023 -0
- package/src/custom-rules/values.mjs +43 -0
- package/src/entry-point.mjs +55 -0
- package/src/errors.mjs +36 -0
- package/src/eslint-config.mjs +542 -0
- package/src/go-work.mjs +394 -0
- package/src/governance/adr-registry.mjs +539 -0
- package/src/governance/clock.mjs +69 -0
- package/src/governance/debt-ledger.mjs +274 -0
- package/src/governance/discovery-proposal.mjs +423 -0
- package/src/governance/fitness-registry.mjs +504 -0
- package/src/governance/fitness-rules.mjs +668 -0
- package/src/governance/metrics.mjs +392 -0
- package/src/governance/preset-fingerprints.json +16 -0
- package/src/governance/profile-registry.mjs +366 -0
- package/src/governance/provenance-record.mjs +177 -0
- package/src/governance/reconcile-candidates.mjs +301 -0
- package/src/governance/reconcile-score.mjs +503 -0
- package/src/governance/row-schema.mjs +208 -0
- package/src/governance/verdict.mjs +127 -0
- package/src/governance/waiver.mjs +105 -0
- package/src/graph/create-dependencies.mjs +96 -0
- package/src/intent/intent-manifest.json +347 -0
- package/src/intent/mask-non-code.mjs +640 -0
- package/src/lsp/boundary-config.mjs +225 -0
- package/src/lsp/diagnose.mjs +202 -0
- package/src/lsp/diagnostics.mjs +241 -0
- package/src/lsp/protocol.mjs +215 -0
- package/src/lsp/server.mjs +922 -0
- package/src/lsp/workspace-index.mjs +891 -0
- package/src/nx-json.mjs +95 -0
- package/src/options.mjs +611 -0
- package/src/process.mjs +91 -0
- package/src/providers/moon.mjs +733 -0
- package/src/providers/native/README.md +204 -0
- package/src/providers/native/coverage.mjs +74 -0
- package/src/providers/native/differential.fixtures.mjs +1277 -0
- package/src/providers/native/discover.mjs +431 -0
- package/src/providers/native/graph.mjs +234 -0
- package/src/providers/native/index.mjs +152 -0
- package/src/providers/native/model.mjs +755 -0
- package/src/providers/nx.mjs +178 -0
- package/src/report/README.md +89 -0
- package/src/report/adr-text.mjs +129 -0
- package/src/report/context-text.mjs +109 -0
- package/src/report/debt-text.mjs +105 -0
- package/src/report/diff-text.mjs +219 -0
- package/src/report/discover-text.mjs +186 -0
- package/src/report/drift-text.mjs +194 -0
- package/src/report/envelope-shape.mjs +161 -0
- package/src/report/evidence.mjs +157 -0
- package/src/report/explain-text.mjs +159 -0
- package/src/report/graph-text.mjs +116 -0
- package/src/report/health-text.mjs +123 -0
- package/src/report/history-text.mjs +204 -0
- package/src/report/impact-text.mjs +128 -0
- package/src/report/json.mjs +173 -0
- package/src/report/plan-context-text.mjs +159 -0
- package/src/report/provenance-text.mjs +78 -0
- package/src/report/reconcile-text.mjs +159 -0
- package/src/report/report-text.mjs +264 -0
- package/src/report/sarif.mjs +953 -0
- package/src/report/text.mjs +823 -0
- package/src/report/waivers-text.mjs +100 -0
- package/src/rules/README.md +123 -0
- package/src/rules/index.mjs +962 -0
- package/src/rules/match.mjs +1708 -0
- package/src/rules/messages.mjs +73 -0
- package/src/rules/reachability.mjs +224 -0
- package/src/rules/specifiers.mjs +300 -0
- package/src/rules/tags.mjs +238 -0
- package/src/rules/topology.mjs +333 -0
- package/src/tsconfig-paths.mjs +237 -0
- package/src/verdict.mjs +145 -0
- package/src/workspace.mjs +580 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The extension → language table, held apart from `./analyze.mjs` so that
|
|
3
|
+
* asking "what language is this file" never pays for loading every language's
|
|
4
|
+
* analyzer.
|
|
5
|
+
*
|
|
6
|
+
* `analyze.mjs` imports every `ANALYZER_BY_LANGUAGE` entry eagerly, and one of
|
|
7
|
+
* those — `analyzeTypeScript` — imports the `typescript` npm package at module
|
|
8
|
+
* scope. A caller that only wants `languageOf`/`LANGUAGE_BY_EXTENSION` (the
|
|
9
|
+
* native provider's coverage judgment, `../providers/native/coverage.mjs`, is
|
|
10
|
+
* exactly this: it classifies files to decide which are "analyzable" without
|
|
11
|
+
* ever calling an analyzer) has no reason to load a compiler it may not even
|
|
12
|
+
* have installed for. `../process.mjs` is the same split for the same reason,
|
|
13
|
+
* one layer over: module-scope imports are a cost every importer pays whether
|
|
14
|
+
* or not it uses what they load.
|
|
15
|
+
*
|
|
16
|
+
* `analyze.mjs` re-exports both names from here, so nothing that already
|
|
17
|
+
* imports them from `analyze.mjs` has to change, and the rule — an extension
|
|
18
|
+
* names a language — is still stated in exactly one place.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* File extension → the language whose analyzer owns it. The one place an
|
|
23
|
+
* extension is mapped: a language whose analyzer arrives registers here and
|
|
24
|
+
* nowhere else.
|
|
25
|
+
*
|
|
26
|
+
* Dispatch is on the extension alone. Not on content — sniffing would be a
|
|
27
|
+
* second, weaker answer to a question the filename already settles — and not
|
|
28
|
+
* on the owning project's tags, because a tag describes a project's boundary,
|
|
29
|
+
* not the syntax of the files inside it.
|
|
30
|
+
*
|
|
31
|
+
* `.mjs`/`.cjs` are listed beside `.js` rather than folded into it: this
|
|
32
|
+
* workspace's own tools are `.mjs`, so leaving them out would exempt the
|
|
33
|
+
* enforcer from itself.
|
|
34
|
+
*
|
|
35
|
+
* `.vue` names its own language rather than folding into `typescript`. A `.vue`
|
|
36
|
+
* file is not TypeScript — its imports live inside `<script>` blocks that have
|
|
37
|
+
* to be located before anything can read them, and the block's `lang` decides
|
|
38
|
+
* which of TypeScript's four dialects applies. The Vue analyzer does that and
|
|
39
|
+
* then hands the block to the TypeScript one; the sharing belongs there, not
|
|
40
|
+
* in this table.
|
|
41
|
+
*/
|
|
42
|
+
export const LANGUAGE_BY_EXTENSION = Object.freeze({
|
|
43
|
+
".ts": "typescript",
|
|
44
|
+
".tsx": "typescript",
|
|
45
|
+
".mts": "typescript",
|
|
46
|
+
".cts": "typescript",
|
|
47
|
+
".js": "typescript",
|
|
48
|
+
".jsx": "typescript",
|
|
49
|
+
".mjs": "typescript",
|
|
50
|
+
".cjs": "typescript",
|
|
51
|
+
".vue": "vue",
|
|
52
|
+
".go": "go",
|
|
53
|
+
".rs": "rust",
|
|
54
|
+
".py": "python",
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The language owning `sourceFile`, or `null` when no analyzer claims its
|
|
59
|
+
* extension. Exported because a caller that walks a project's tracked files
|
|
60
|
+
* wants to skip the ones nothing can read before paying to read them.
|
|
61
|
+
*
|
|
62
|
+
* Matched on the last dot of the basename, so a dotted filename
|
|
63
|
+
* (`foo.config.mjs`) resolves by its real extension and a dotfile with no
|
|
64
|
+
* extension (`.gitignore`) resolves to `null` rather than to itself.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} sourceFile Workspace-relative path.
|
|
67
|
+
* @returns {string|null}
|
|
68
|
+
*/
|
|
69
|
+
export function languageOf(sourceFile) {
|
|
70
|
+
const base = sourceFile.slice(sourceFile.lastIndexOf("/") + 1);
|
|
71
|
+
const dot = base.lastIndexOf(".");
|
|
72
|
+
if (dot <= 0) return null; // no extension, or a dotfile that is all extension
|
|
73
|
+
return LANGUAGE_BY_EXTENSION[base.slice(dot)] ?? null;
|
|
74
|
+
}
|