@beignet/cli 0.0.40 → 0.0.42
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 +19 -0
- package/README.md +139 -17
- package/dist/analysis/source-index.d.ts +38 -0
- package/dist/analysis/source-index.d.ts.map +1 -0
- package/dist/analysis/source-index.js +271 -0
- package/dist/analysis/source-index.js.map +1 -0
- package/dist/analysis/workspace.d.ts +16 -0
- package/dist/analysis/workspace.d.ts.map +1 -0
- package/dist/analysis/workspace.js +134 -0
- package/dist/analysis/workspace.js.map +1 -0
- package/dist/app-map-schema.d.ts +5 -0
- package/dist/app-map-schema.d.ts.map +1 -0
- package/dist/app-map-schema.js +26 -0
- package/dist/app-map-schema.js.map +1 -0
- package/dist/app-map.d.ts +96 -0
- package/dist/app-map.d.ts.map +1 -0
- package/dist/app-map.js +1141 -0
- package/dist/app-map.js.map +1 -0
- package/dist/check.d.ts +7 -0
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +20 -5
- package/dist/check.js.map +1 -1
- package/dist/choices.d.ts +18 -0
- package/dist/choices.d.ts.map +1 -1
- package/dist/choices.js +35 -0
- package/dist/choices.js.map +1 -1
- package/dist/db.d.ts +49 -13
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +202 -21
- package/dist/db.js.map +1 -1
- package/dist/doctor-fixes.d.ts +64 -0
- package/dist/doctor-fixes.d.ts.map +1 -0
- package/dist/doctor-fixes.js +142 -0
- package/dist/doctor-fixes.js.map +1 -0
- package/dist/explain.d.ts +100 -0
- package/dist/explain.d.ts.map +1 -0
- package/dist/explain.js +606 -0
- package/dist/explain.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +165 -21
- package/dist/index.js.map +1 -1
- package/dist/inspect.d.ts +33 -9
- package/dist/inspect.d.ts.map +1 -1
- package/dist/inspect.js +406 -119
- package/dist/inspect.js.map +1 -1
- package/dist/lib.d.ts +10 -2
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +5 -2
- package/dist/lib.js.map +1 -1
- package/dist/make/shared.js +3 -3
- package/dist/make/shared.js.map +1 -1
- package/dist/make.d.ts.map +1 -1
- package/dist/make.js +63 -2
- package/dist/make.js.map +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +188 -12
- package/dist/mcp.js.map +1 -1
- package/dist/preflight.d.ts.map +1 -1
- package/dist/preflight.js +10 -0
- package/dist/preflight.js.map +1 -1
- package/dist/provider-add.d.ts.map +1 -1
- package/dist/provider-add.js +167 -13
- package/dist/provider-add.js.map +1 -1
- package/dist/provider-audit.d.ts +6 -0
- package/dist/provider-audit.d.ts.map +1 -1
- package/dist/provider-audit.js +63 -15
- package/dist/provider-audit.js.map +1 -1
- package/dist/templates/agents.d.ts.map +1 -1
- package/dist/templates/agents.js +35 -6
- package/dist/templates/agents.js.map +1 -1
- package/dist/templates/base.d.ts.map +1 -1
- package/dist/templates/base.js +13 -7
- package/dist/templates/base.js.map +1 -1
- package/dist/templates/index.d.ts +1 -1
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +8 -1
- package/dist/templates/index.js.map +1 -1
- package/dist/templates/server.d.ts +3 -0
- package/dist/templates/server.d.ts.map +1 -1
- package/dist/templates/server.js +55 -1
- package/dist/templates/server.js.map +1 -1
- package/dist/templates/shared.d.ts +2 -1
- package/dist/templates/shared.d.ts.map +1 -1
- package/dist/templates/shared.js +8 -5
- package/dist/templates/shared.js.map +1 -1
- package/package.json +3 -2
- package/skills/app-structure/SKILL.md +48 -6
- package/src/analysis/source-index.ts +395 -0
- package/src/analysis/workspace.ts +180 -0
- package/src/app-map-schema.ts +28 -0
- package/src/app-map.ts +1705 -0
- package/src/check.ts +27 -4
- package/src/choices.ts +57 -0
- package/src/db.ts +276 -28
- package/src/doctor-fixes.ts +252 -0
- package/src/explain.ts +894 -0
- package/src/index.ts +237 -31
- package/src/inspect.ts +567 -147
- package/src/lib.ts +64 -1
- package/src/make/shared.ts +3 -3
- package/src/make.ts +90 -2
- package/src/mcp.ts +292 -12
- package/src/preflight.ts +14 -0
- package/src/provider-add.ts +211 -12
- package/src/provider-audit.ts +127 -22
- package/src/templates/agents.ts +35 -6
- package/src/templates/base.ts +25 -6
- package/src/templates/index.ts +18 -1
- package/src/templates/server.ts +58 -1
- package/src/templates/shared.ts +15 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/templates/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GAEnB,MAAM,aAAa,CAAC;AAErB,MAAM,UAAU,eAAe,CAAC,GAAoB;IAClD,MAAM,EAAE,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG;QACd,qCAAqC;QACrC,6DAA6D;QAC7D,gFAAgF;QAChF,YAAY,EAAE,CAAC,eAAe,yCAAyC,EAAE,CAAC,OAAO,IAAI;QACrF,kBAAkB,CAAC,GAAG,EAAE,cAAc,CAAC;YACrC,CAAC,CAAC,6EAA6E;YAC/E,CAAC,CAAC,SAAS;QACb,2EAA2E;QAC3E,kBAAkB,CAAC,GAAG,EAAE,aAAa,CAAC;YACpC,CAAC,CAAC,2EAA2E;YAC7E,CAAC,CAAC,SAAS;QACb,kBAAkB,CAAC,GAAG,EAAE,oBAAoB,CAAC;YAC3C,CAAC,CAAC,wFAAwF;YAC1F,CAAC,CAAC,SAAS;QACb,8CAA8C;QAC9C,qDAAqD;QACrD,gEAAgE;QAChE,2CAA2C;QAC3C,oEAAoE;KACrE,CAAC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAElD,MAAM,OAAO,GAAG;QACd,6BAA6B;QAC7B,kEAAkE;QAClE,+BAA+B;QAC/B,KAAK,E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;;;;;;;;;;;CA8DhB;IACC,YAAY,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Cf;IACC,gBAAgB,EAAE;;;;;CAKnB;IACC,WAAW,EAAE;;;;;;;;;;;;;;;;CAgBd;IACC,UAAU,EAAE;;;;;;;;;;;;;;CAcb;IACC,aAAa,EAAE;;;;;;;;;;;CAWhB;IACC,YAAY,EAAE;;;;;;;;;CASf;IACC,SAAS,EAAE;;;;;;;;;;;;;;;;;;;;;CAqBZ;IACC,YAAY,EAAE;;;;;;;;CAQf;IACC,2EAA2E;IAC3E,wEAAwE;IACxE,4EAA4E;IAC5E,SAAS,EAAE;;;;;;;;;;;;;;;;;;;;;;;CAuBZ;IACC,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BV;IACC,cAAc,EAAE;;;;;CAKjB;CACA,CAAC;AAEF,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,CAAC"}
|
|
@@ -59,8 +59,9 @@ export declare const externalVersions: {
|
|
|
59
59
|
upstashRateLimit: string;
|
|
60
60
|
upstashRedis: string;
|
|
61
61
|
};
|
|
62
|
-
export declare const legacyGeneratedPackageScripts: Record<string, string>;
|
|
62
|
+
export declare const legacyGeneratedPackageScripts: Record<string, readonly string[]>;
|
|
63
63
|
export declare const currentGeneratedPackageScripts: Record<string, string>;
|
|
64
|
+
export declare function isLegacyGeneratedPackageScript(name: string, command: string | undefined): boolean;
|
|
64
65
|
/**
|
|
65
66
|
* Dialect-specific names used when rendering database-aware templates.
|
|
66
67
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/templates/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,mBAAmB,EACpB,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CA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K,EAAE,OAAO,GAAG,MAAM,CAE3C"}
|
package/dist/templates/shared.js
CHANGED
|
@@ -16,7 +16,7 @@ export const externalVersions = {
|
|
|
16
16
|
bullmq: "^5.0.0",
|
|
17
17
|
drizzleKit: "^0.31.10",
|
|
18
18
|
drizzleOrm: "^0.45.2",
|
|
19
|
-
inngest: "^
|
|
19
|
+
inngest: "^4.12.1",
|
|
20
20
|
libsqlClient: "^0.14.0",
|
|
21
21
|
vercelBlob: "^2.5.0",
|
|
22
22
|
mysql2: "^3.12.0",
|
|
@@ -35,15 +35,18 @@ export const externalVersions = {
|
|
|
35
35
|
upstashRedis: "^1.0.0",
|
|
36
36
|
};
|
|
37
37
|
export const legacyGeneratedPackageScripts = {
|
|
38
|
-
"db:reset": "bun infra/db/reset.ts",
|
|
39
|
-
"db:seed": "bun server/seed.ts",
|
|
40
|
-
test: "bun test",
|
|
38
|
+
"db:reset": ["bun infra/db/reset.ts"],
|
|
39
|
+
"db:seed": ["bun server/seed.ts"],
|
|
40
|
+
test: ["bun test", "tsx lib/beignet-test-runner.ts"],
|
|
41
41
|
};
|
|
42
42
|
export const currentGeneratedPackageScripts = {
|
|
43
43
|
"db:reset": "tsx infra/db/reset.ts",
|
|
44
44
|
"db:seed": "tsx server/seed.ts",
|
|
45
|
-
test: "tsx lib/beignet-test-runner.ts",
|
|
45
|
+
test: "node --import tsx lib/beignet-test-runner.ts",
|
|
46
46
|
};
|
|
47
|
+
export function isLegacyGeneratedPackageScript(name, command) {
|
|
48
|
+
return legacyGeneratedPackageScripts[name]?.includes(command ?? "") ?? false;
|
|
49
|
+
}
|
|
47
50
|
const databaseDescriptors = {
|
|
48
51
|
sqlite: {
|
|
49
52
|
name: "sqlite",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/templates/shared.ts"],"names":[],"mappings":"AAgCA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,KAAK,EAAE,SAAS;IAChB,IAA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;KAClC;IACD,aAAa,EAAE;QACb,+BAA+B,EAAE,EAAE;QACnC,MAAM,EAAE,gBAAgB,CAAC,MAAM;KAChC;IACD,oBAAoB,EAAE;QACpB,sCAAsC,EAAE,EAAE;QAC1C,oBAAoB,EAAE,gBAAgB,CAAC,gBAAgB;QACvD,gBAAgB,EAAE,gBAAgB,CAAC,YAAY;KAChD;CACF,CAAC;AAEF,MAAM,UAAU,kBAAkB,CAChC,GAAoB,EACpB,QAA6B;IAE7B,OAAO,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,KAAc;IACjC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;AAClD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beignet/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.42",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI for creating and maintaining Beignet apps.",
|
|
6
6
|
"main": "./dist/lib.js",
|
|
@@ -69,10 +69,11 @@
|
|
|
69
69
|
"tsx": "^4.22.4"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@beignet/core": "^0.0.
|
|
72
|
+
"@beignet/core": "^0.0.42",
|
|
73
73
|
"@clack/prompts": "^1.5.1",
|
|
74
74
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
75
75
|
"@stricli/core": "^1.2.7",
|
|
76
|
+
"diff": "^8.0.4",
|
|
76
77
|
"jiti": "^2.7.0",
|
|
77
78
|
"typescript": "^5.3.0",
|
|
78
79
|
"zod": "^4.0.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: app-structure
|
|
3
|
-
description: "Maintain Beignet app structure with @beignet/cli: create starter output, make generators, full-slice feature recipes, db schema sync, TenantScope resources, workflow registries, runtime-integrity manifests, beignet.config paths, routes inspection, lint dependency boundaries, doctor drift checks and fixes, MCP tools, generated AGENTS.md guidance, Intent package skills, and generated-app validation. Use when scaffolding, generating, fixing, or reviewing a Beignet app's structure."
|
|
3
|
+
description: "Maintain Beignet app structure with @beignet/cli: deterministic app maps, create starter output, make generators, full-slice feature recipes, db schema sync, TenantScope resources, workflow registries, runtime-integrity manifests, beignet.config paths, routes inspection, lint dependency boundaries, doctor drift checks and fixes, MCP tools, generated AGENTS.md guidance, Intent package skills, and generated-app validation. Use when scaffolding, generating, fixing, or reviewing a Beignet app's structure."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Beignet CLI App Structure
|
|
@@ -91,8 +91,11 @@ Feature route groups should import the app-bound `defineRouteGroup` from
|
|
|
91
91
|
`lib/routes.ts`. `doctor` checks both that feature routes use that builder and
|
|
92
92
|
that the builder itself calls `createRoutes<AppContext>()`.
|
|
93
93
|
|
|
94
|
-
Run `beignet doctor --strict` after hand edits. Use
|
|
95
|
-
|
|
94
|
+
Run `beignet doctor --strict` after hand edits. Use
|
|
95
|
+
`beignet doctor --fix --dry-run` to inspect exact low-risk repair patches, then
|
|
96
|
+
apply the returned plan with `beignet doctor --fix --plan <plan-id>` and
|
|
97
|
+
optional `--only <operation-ids>`. Plain `doctor --fix` remains the apply-all
|
|
98
|
+
shortcut.
|
|
96
99
|
|
|
97
100
|
## Path Config
|
|
98
101
|
|
|
@@ -129,6 +132,11 @@ relocated implicitly; override each path the app has moved, such as
|
|
|
129
132
|
|
|
130
133
|
## Lint And Doctor
|
|
131
134
|
|
|
135
|
+
Start unfamiliar app work with `beignet map`. Its human output summarizes each
|
|
136
|
+
feature; `beignet map --json` returns the versioned graph with source evidence,
|
|
137
|
+
registration status, doctor/lint findings, and unresolved references. Use
|
|
138
|
+
`--feature <name>` or `--kind route,use-case,event` to bound agent context.
|
|
139
|
+
|
|
132
140
|
`beignet lint` enforces dependency direction:
|
|
133
141
|
|
|
134
142
|
- domain and use cases must not import infra, routes, server, providers, React,
|
|
@@ -172,9 +180,32 @@ Generated apps register:
|
|
|
172
180
|
}
|
|
173
181
|
```
|
|
174
182
|
|
|
175
|
-
The MCP server exposes `
|
|
176
|
-
`
|
|
177
|
-
|
|
183
|
+
The MCP server exposes `app_map`, `explain`, `check`, `db`,
|
|
184
|
+
`db_schema_sync`, `routes`, `doctor`, `doctor_fix_plan`, `doctor_fix`, `lint`,
|
|
185
|
+
`make`, and `provider_add`.
|
|
186
|
+
`doctor_fix_plan` is read-only and returns guarded repair operation IDs,
|
|
187
|
+
hashes, patches, a plan ID, and current diagnostics; pass that ID and optional
|
|
188
|
+
`fixIds` to `doctor_fix`. Guarded apply returns the same plan metadata and
|
|
189
|
+
inspection payload as the CLI. `app_map` accepts feature and
|
|
190
|
+
node-kind projections. `explain` accepts `{ kind, target }` for any mapped
|
|
191
|
+
concept or diagnostic and returns the same deterministic result as
|
|
192
|
+
`beignet explain <kind> <target> --json`. Explain accepts every app-map node
|
|
193
|
+
kind plus `diagnostic`; targets may use stable IDs, runtime or declaration
|
|
194
|
+
names, source selectors, and applicable aliases. `check` accepts optional
|
|
195
|
+
`{ preflight?: boolean, timeoutMs?: number }`, bounds failure output, cancels
|
|
196
|
+
the active script with the MCP request, and returns the same versioned result
|
|
197
|
+
as `beignet check --json`. It does not apply Beignet fixes, but app package
|
|
198
|
+
scripts retain their normal side effects. `db` accepts
|
|
199
|
+
`{ command: "generate" | "migrate" | "seed" | "reset", dryRun?, timeoutMs? }`
|
|
200
|
+
and returns the matching versioned `beignet db <command> --json` report with
|
|
201
|
+
bounded output, cancellation, and process-tree timeouts. `db_schema_sync`
|
|
202
|
+
accepts `{ dialect?, tables?, output?, dryRun? }` and returns the matching
|
|
203
|
+
`beignet db schema sync --json` report. For lifecycle commands, `dryRun`
|
|
204
|
+
validates and reports the app-owned script without executing it; it does not
|
|
205
|
+
simulate SQL or data changes. `reset` remains environment-sensitive even
|
|
206
|
+
though the generated entrypoint has a production guard. `doctor`, `lint`, and
|
|
207
|
+
their JSON output match the CLI's `--json` shape. Run MCP clients from the app
|
|
208
|
+
root so the local CLI version is used.
|
|
178
209
|
|
|
179
210
|
## Validation Loop
|
|
180
211
|
|
|
@@ -182,12 +213,23 @@ After structural changes:
|
|
|
182
213
|
|
|
183
214
|
```bash
|
|
184
215
|
beignet routes
|
|
216
|
+
beignet map
|
|
217
|
+
beignet explain feature <name>
|
|
218
|
+
beignet explain use-case <feature.action>
|
|
219
|
+
beignet explain task <feature.action>
|
|
220
|
+
beignet explain port <name>
|
|
185
221
|
beignet lint
|
|
186
222
|
beignet doctor --strict
|
|
187
223
|
bun run test
|
|
188
224
|
bun run typecheck
|
|
189
225
|
```
|
|
190
226
|
|
|
227
|
+
When MCP is available, call `check` after edits to run the full validation loop
|
|
228
|
+
through the app-local CLI without reconstructing these commands individually.
|
|
229
|
+
For a generated persistent resource, the complete structured workflow is
|
|
230
|
+
`app_map` → `explain` → `make` → `db_schema_sync` when provider tables changed
|
|
231
|
+
→ `db` generate → `db` migrate → `check`.
|
|
232
|
+
|
|
191
233
|
For generated app template changes inside the Beignet monorepo, also run:
|
|
192
234
|
|
|
193
235
|
```bash
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { type AnalysisWorkspace, resolveLocalSourceFile } from "./workspace.js";
|
|
3
|
+
|
|
4
|
+
export type AnalysisSourceLocation = {
|
|
5
|
+
file: string;
|
|
6
|
+
exportName?: string;
|
|
7
|
+
line?: number;
|
|
8
|
+
column?: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type ResolvedSourceReference = {
|
|
12
|
+
file: string;
|
|
13
|
+
exportName: string;
|
|
14
|
+
declaration?: ts.Declaration;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type LocalImportReference = {
|
|
18
|
+
file: string;
|
|
19
|
+
importPath: string;
|
|
20
|
+
resolvedFile: string;
|
|
21
|
+
kind: "type" | "value";
|
|
22
|
+
line: number;
|
|
23
|
+
column: number;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type ImportBinding =
|
|
27
|
+
| { kind: "named"; file: string; exportName: string }
|
|
28
|
+
| { kind: "namespace"; file: string };
|
|
29
|
+
|
|
30
|
+
type FileIndex = {
|
|
31
|
+
declarations: Map<string, ts.Declaration>;
|
|
32
|
+
imports: Map<string, ImportBinding>;
|
|
33
|
+
reexports: Map<string, { file: string; exportName: string }>;
|
|
34
|
+
exportStars: string[];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type SourceIndex = {
|
|
38
|
+
resolveName(
|
|
39
|
+
file: string,
|
|
40
|
+
name: string,
|
|
41
|
+
): Promise<ResolvedSourceReference | undefined>;
|
|
42
|
+
resolveExpression(
|
|
43
|
+
file: string,
|
|
44
|
+
expression: ts.Expression,
|
|
45
|
+
): Promise<ResolvedSourceReference | undefined>;
|
|
46
|
+
resolveExport(
|
|
47
|
+
file: string,
|
|
48
|
+
exportName: string,
|
|
49
|
+
): Promise<ResolvedSourceReference | undefined>;
|
|
50
|
+
sourceLocation(
|
|
51
|
+
file: string,
|
|
52
|
+
node: ts.Node,
|
|
53
|
+
exportName?: string,
|
|
54
|
+
): Promise<AnalysisSourceLocation>;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export function createSourceIndex(workspace: AnalysisWorkspace): SourceIndex {
|
|
58
|
+
const indexes = new Map<string, FileIndex>();
|
|
59
|
+
|
|
60
|
+
const readIndex = async (file: string): Promise<FileIndex> => {
|
|
61
|
+
const cached = indexes.get(file);
|
|
62
|
+
if (cached) return cached;
|
|
63
|
+
|
|
64
|
+
const sourceFile = await workspace.readSourceFile(file);
|
|
65
|
+
const index: FileIndex = {
|
|
66
|
+
declarations: new Map(),
|
|
67
|
+
imports: new Map(),
|
|
68
|
+
reexports: new Map(),
|
|
69
|
+
exportStars: [],
|
|
70
|
+
};
|
|
71
|
+
indexes.set(file, index);
|
|
72
|
+
|
|
73
|
+
for (const statement of sourceFile.statements) {
|
|
74
|
+
if (ts.isImportDeclaration(statement)) {
|
|
75
|
+
const source = moduleText(statement.moduleSpecifier);
|
|
76
|
+
const target = source
|
|
77
|
+
? resolveLocalSourceFile(workspace, file, source)
|
|
78
|
+
: undefined;
|
|
79
|
+
if (!target || !statement.importClause) continue;
|
|
80
|
+
|
|
81
|
+
if (statement.importClause.name) {
|
|
82
|
+
index.imports.set(statement.importClause.name.text, {
|
|
83
|
+
kind: "named",
|
|
84
|
+
file: target,
|
|
85
|
+
exportName: "default",
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const bindings = statement.importClause.namedBindings;
|
|
90
|
+
if (bindings && ts.isNamespaceImport(bindings)) {
|
|
91
|
+
index.imports.set(bindings.name.text, {
|
|
92
|
+
kind: "namespace",
|
|
93
|
+
file: target,
|
|
94
|
+
});
|
|
95
|
+
} else if (bindings && ts.isNamedImports(bindings)) {
|
|
96
|
+
for (const element of bindings.elements) {
|
|
97
|
+
index.imports.set(element.name.text, {
|
|
98
|
+
kind: "named",
|
|
99
|
+
file: target,
|
|
100
|
+
exportName: element.propertyName?.text ?? element.name.text,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (ts.isExportDeclaration(statement)) {
|
|
108
|
+
const source = statement.moduleSpecifier
|
|
109
|
+
? moduleText(statement.moduleSpecifier)
|
|
110
|
+
: undefined;
|
|
111
|
+
const target = source
|
|
112
|
+
? resolveLocalSourceFile(workspace, file, source)
|
|
113
|
+
: undefined;
|
|
114
|
+
if (!target) continue;
|
|
115
|
+
|
|
116
|
+
if (!statement.exportClause) {
|
|
117
|
+
index.exportStars.push(target);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (ts.isNamedExports(statement.exportClause)) {
|
|
122
|
+
for (const element of statement.exportClause.elements) {
|
|
123
|
+
index.reexports.set(element.name.text, {
|
|
124
|
+
file: target,
|
|
125
|
+
exportName: element.propertyName?.text ?? element.name.text,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (ts.isVariableStatement(statement) && hasExportModifier(statement)) {
|
|
133
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
134
|
+
if (ts.isIdentifier(declaration.name)) {
|
|
135
|
+
index.declarations.set(declaration.name.text, declaration);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (
|
|
142
|
+
(ts.isFunctionDeclaration(statement) ||
|
|
143
|
+
ts.isClassDeclaration(statement) ||
|
|
144
|
+
ts.isInterfaceDeclaration(statement) ||
|
|
145
|
+
ts.isTypeAliasDeclaration(statement) ||
|
|
146
|
+
ts.isEnumDeclaration(statement)) &&
|
|
147
|
+
hasExportModifier(statement) &&
|
|
148
|
+
statement.name
|
|
149
|
+
) {
|
|
150
|
+
index.declarations.set(statement.name.text, statement);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return index;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const resolveExport = async (
|
|
158
|
+
file: string,
|
|
159
|
+
exportName: string,
|
|
160
|
+
visited = new Set<string>(),
|
|
161
|
+
): Promise<ResolvedSourceReference | undefined> => {
|
|
162
|
+
const key = `${file}#${exportName}`;
|
|
163
|
+
if (visited.has(key)) return undefined;
|
|
164
|
+
visited.add(key);
|
|
165
|
+
|
|
166
|
+
const index = await readIndex(file);
|
|
167
|
+
const declaration = index.declarations.get(exportName);
|
|
168
|
+
if (declaration) return { file, exportName, declaration };
|
|
169
|
+
|
|
170
|
+
const reexport = index.reexports.get(exportName);
|
|
171
|
+
if (reexport) {
|
|
172
|
+
return (
|
|
173
|
+
(await resolveExport(reexport.file, reexport.exportName, visited)) ?? {
|
|
174
|
+
file: reexport.file,
|
|
175
|
+
exportName: reexport.exportName,
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
for (const target of index.exportStars) {
|
|
181
|
+
const resolved = await resolveExport(target, exportName, visited);
|
|
182
|
+
if (resolved) return resolved;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return undefined;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
async resolveName(file, name) {
|
|
190
|
+
const index = await readIndex(file);
|
|
191
|
+
const local = index.declarations.get(name);
|
|
192
|
+
if (local) {
|
|
193
|
+
return { file, exportName: name, declaration: local };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const binding = index.imports.get(name);
|
|
197
|
+
if (binding?.kind !== "named") return undefined;
|
|
198
|
+
return (
|
|
199
|
+
(await resolveExport(binding.file, binding.exportName)) ?? {
|
|
200
|
+
file: binding.file,
|
|
201
|
+
exportName: binding.exportName,
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
},
|
|
205
|
+
async resolveExpression(file, rawExpression) {
|
|
206
|
+
const expression = unwrapExpression(rawExpression);
|
|
207
|
+
const index = await readIndex(file);
|
|
208
|
+
if (ts.isIdentifier(expression)) {
|
|
209
|
+
const local = index.declarations.get(expression.text);
|
|
210
|
+
if (local) {
|
|
211
|
+
return { file, exportName: expression.text, declaration: local };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const binding = index.imports.get(expression.text);
|
|
215
|
+
if (binding?.kind !== "named") return undefined;
|
|
216
|
+
return (
|
|
217
|
+
(await resolveExport(binding.file, binding.exportName)) ?? {
|
|
218
|
+
file: binding.file,
|
|
219
|
+
exportName: binding.exportName,
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (
|
|
225
|
+
ts.isPropertyAccessExpression(expression) &&
|
|
226
|
+
ts.isIdentifier(expression.expression)
|
|
227
|
+
) {
|
|
228
|
+
const binding = index.imports.get(expression.expression.text);
|
|
229
|
+
if (binding?.kind !== "namespace") return undefined;
|
|
230
|
+
return (
|
|
231
|
+
(await resolveExport(binding.file, expression.name.text)) ?? {
|
|
232
|
+
file: binding.file,
|
|
233
|
+
exportName: expression.name.text,
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return undefined;
|
|
239
|
+
},
|
|
240
|
+
resolveExport(file, exportName) {
|
|
241
|
+
return resolveExport(file, exportName);
|
|
242
|
+
},
|
|
243
|
+
async sourceLocation(file, node, exportName) {
|
|
244
|
+
const sourceFile = await workspace.readSourceFile(file);
|
|
245
|
+
const position = sourceFile.getLineAndCharacterOfPosition(
|
|
246
|
+
node.getStart(),
|
|
247
|
+
);
|
|
248
|
+
return {
|
|
249
|
+
file,
|
|
250
|
+
...(exportName ? { exportName } : {}),
|
|
251
|
+
line: position.line + 1,
|
|
252
|
+
column: position.character + 1,
|
|
253
|
+
};
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export function exportedVariableDeclarations(
|
|
259
|
+
sourceFile: ts.SourceFile,
|
|
260
|
+
): Array<{ exportName: string; declaration: ts.VariableDeclaration }> {
|
|
261
|
+
const declarations: Array<{
|
|
262
|
+
exportName: string;
|
|
263
|
+
declaration: ts.VariableDeclaration;
|
|
264
|
+
}> = [];
|
|
265
|
+
|
|
266
|
+
for (const statement of sourceFile.statements) {
|
|
267
|
+
if (!ts.isVariableStatement(statement) || !hasExportModifier(statement)) {
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
271
|
+
if (ts.isIdentifier(declaration.name)) {
|
|
272
|
+
declarations.push({
|
|
273
|
+
exportName: declaration.name.text,
|
|
274
|
+
declaration,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return declarations;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export function literalText(node: ts.Node | undefined): string | undefined {
|
|
284
|
+
return node &&
|
|
285
|
+
(ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node))
|
|
286
|
+
? node.text
|
|
287
|
+
: undefined;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export function propertyAssignment(
|
|
291
|
+
object: ts.ObjectLiteralExpression,
|
|
292
|
+
name: string,
|
|
293
|
+
): ts.PropertyAssignment | undefined {
|
|
294
|
+
return object.properties.find(
|
|
295
|
+
(property): property is ts.PropertyAssignment =>
|
|
296
|
+
ts.isPropertyAssignment(property) && propertyName(property.name) === name,
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export function propertyName(node: ts.PropertyName): string | undefined {
|
|
301
|
+
if (ts.isIdentifier(node) || ts.isStringLiteral(node)) return node.text;
|
|
302
|
+
return undefined;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export function visitCalls(
|
|
306
|
+
node: ts.Node,
|
|
307
|
+
visit: (call: ts.CallExpression) => void,
|
|
308
|
+
): void {
|
|
309
|
+
const walk = (current: ts.Node) => {
|
|
310
|
+
if (ts.isCallExpression(current)) visit(current);
|
|
311
|
+
current.forEachChild(walk);
|
|
312
|
+
};
|
|
313
|
+
walk(node);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export async function localImportReferences(
|
|
317
|
+
workspace: AnalysisWorkspace,
|
|
318
|
+
file: string,
|
|
319
|
+
): Promise<LocalImportReference[]> {
|
|
320
|
+
const sourceFile = await workspace.readSourceFile(file);
|
|
321
|
+
const references: LocalImportReference[] = [];
|
|
322
|
+
|
|
323
|
+
for (const statement of sourceFile.statements) {
|
|
324
|
+
if (
|
|
325
|
+
!ts.isImportDeclaration(statement) &&
|
|
326
|
+
!ts.isExportDeclaration(statement)
|
|
327
|
+
) {
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
if (!statement.moduleSpecifier) continue;
|
|
331
|
+
|
|
332
|
+
const importPath = moduleText(statement.moduleSpecifier);
|
|
333
|
+
const resolvedFile = importPath
|
|
334
|
+
? resolveLocalSourceFile(workspace, file, importPath)
|
|
335
|
+
: undefined;
|
|
336
|
+
if (!importPath || !resolvedFile) continue;
|
|
337
|
+
|
|
338
|
+
const position = sourceFile.getLineAndCharacterOfPosition(
|
|
339
|
+
statement.getStart(sourceFile),
|
|
340
|
+
);
|
|
341
|
+
const typeOnly = ts.isImportDeclaration(statement)
|
|
342
|
+
? Boolean(
|
|
343
|
+
statement.importClause?.isTypeOnly ||
|
|
344
|
+
(statement.importClause?.namedBindings &&
|
|
345
|
+
ts.isNamedImports(statement.importClause.namedBindings) &&
|
|
346
|
+
statement.importClause.namedBindings.elements.length > 0 &&
|
|
347
|
+
statement.importClause.namedBindings.elements.every(
|
|
348
|
+
(element) => element.isTypeOnly,
|
|
349
|
+
)),
|
|
350
|
+
)
|
|
351
|
+
: statement.isTypeOnly ||
|
|
352
|
+
(statement.exportClause &&
|
|
353
|
+
ts.isNamedExports(statement.exportClause) &&
|
|
354
|
+
statement.exportClause.elements.length > 0 &&
|
|
355
|
+
statement.exportClause.elements.every(
|
|
356
|
+
(element) => element.isTypeOnly,
|
|
357
|
+
));
|
|
358
|
+
references.push({
|
|
359
|
+
file,
|
|
360
|
+
importPath,
|
|
361
|
+
resolvedFile,
|
|
362
|
+
kind: typeOnly ? "type" : "value",
|
|
363
|
+
line: position.line + 1,
|
|
364
|
+
column: position.character + 1,
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
return references;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function moduleText(node: ts.Expression): string | undefined {
|
|
372
|
+
return ts.isStringLiteral(node) ? node.text : undefined;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function hasExportModifier(node: ts.Node): boolean {
|
|
376
|
+
return Boolean(
|
|
377
|
+
ts.canHaveModifiers(node) &&
|
|
378
|
+
ts
|
|
379
|
+
.getModifiers(node)
|
|
380
|
+
?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword),
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function unwrapExpression(expression: ts.Expression): ts.Expression {
|
|
385
|
+
let current = expression;
|
|
386
|
+
while (
|
|
387
|
+
ts.isAsExpression(current) ||
|
|
388
|
+
ts.isSatisfiesExpression(current) ||
|
|
389
|
+
ts.isParenthesizedExpression(current) ||
|
|
390
|
+
ts.isNonNullExpression(current)
|
|
391
|
+
) {
|
|
392
|
+
current = current.expression;
|
|
393
|
+
}
|
|
394
|
+
return current;
|
|
395
|
+
}
|