@flaid/devmap 0.5.0 → 0.6.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/dist/analyzers/analysis/tsMorphAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/analysis/tsMorphAnalyzer.js +94 -1
- package/dist/analyzers/analysis/tsMorphAnalyzer.js.map +1 -1
- package/dist/analyzers/detectors/databaseDetector.d.ts +3 -0
- package/dist/analyzers/detectors/databaseDetector.d.ts.map +1 -1
- package/dist/analyzers/detectors/databaseDetector.js +101 -13
- package/dist/analyzers/detectors/databaseDetector.js.map +1 -1
- package/dist/analyzers/graph/aliasResolver.d.ts.map +1 -1
- package/dist/analyzers/graph/aliasResolver.js +58 -0
- package/dist/analyzers/graph/aliasResolver.js.map +1 -1
- package/dist/analyzers/graph/dependencyGraph.d.ts.map +1 -1
- package/dist/analyzers/graph/dependencyGraph.js +37 -53
- package/dist/analyzers/graph/dependencyGraph.js.map +1 -1
- package/dist/analyzers/graph/entryPoints.d.ts +8 -1
- package/dist/analyzers/graph/entryPoints.d.ts.map +1 -1
- package/dist/analyzers/graph/entryPoints.js +54 -3
- package/dist/analyzers/graph/entryPoints.js.map +1 -1
- package/dist/analyzers/graph/index.d.ts +2 -0
- package/dist/analyzers/graph/index.d.ts.map +1 -1
- package/dist/analyzers/graph/index.js +1 -0
- package/dist/analyzers/graph/index.js.map +1 -1
- package/dist/analyzers/graph/localPaths.d.ts +4 -0
- package/dist/analyzers/graph/localPaths.d.ts.map +1 -0
- package/dist/analyzers/graph/localPaths.js +50 -0
- package/dist/analyzers/graph/localPaths.js.map +1 -0
- package/dist/analyzers/graph/nuxtAutoImports.d.ts +33 -0
- package/dist/analyzers/graph/nuxtAutoImports.d.ts.map +1 -0
- package/dist/analyzers/graph/nuxtAutoImports.js +222 -0
- package/dist/analyzers/graph/nuxtAutoImports.js.map +1 -0
- package/dist/analyzers/graph/packageManifests.d.ts +49 -0
- package/dist/analyzers/graph/packageManifests.d.ts.map +1 -0
- package/dist/analyzers/graph/packageManifests.js +322 -0
- package/dist/analyzers/graph/packageManifests.js.map +1 -0
- package/dist/analyzers/pipeline/projectMap.d.ts.map +1 -1
- package/dist/analyzers/pipeline/projectMap.js +2 -2
- package/dist/analyzers/pipeline/projectMap.js.map +1 -1
- package/dist/commands/analyze.js +3 -0
- package/dist/commands/analyze.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { isDeclaredAlias, resolveAliasCandidates } from "./aliasResolver.js";
|
|
2
|
+
import { matchLocalPath, normalizePath } from "./localPaths.js";
|
|
3
|
+
import { addNuxtAutoImportEdges } from "./nuxtAutoImports.js";
|
|
4
|
+
import { indexPackages, readPackageManifests, resolveSubpathImport, resolveWorkspaceSpecifier } from "./packageManifests.js";
|
|
2
5
|
// Static imports, re-exports, require() and dynamic import() with a literal.
|
|
3
6
|
const IMPORT_RE = /(?:\bimport\s+(?:[^'"]+\s+from\s+)?|\bexport\s+[^'"]+\s+from\s+|\b(?:require|import)\s*\(\s*)['"]([^'"]+)['"]/g;
|
|
4
7
|
export function buildDependencyGraph(files, analyses = {}, aliasMappings = []) {
|
|
5
8
|
const graph = {};
|
|
6
9
|
const localPaths = new Set(files.map((file) => file.path));
|
|
10
|
+
const packages = indexPackages(readPackageManifests(files));
|
|
7
11
|
const diagnostics = {
|
|
8
12
|
unresolvedAliases: [],
|
|
9
13
|
parserFallbacks: [],
|
|
@@ -13,7 +17,10 @@ export function buildDependencyGraph(files, analyses = {}, aliasMappings = []) {
|
|
|
13
17
|
// or a static and a dynamic import) is still one dependency edge.
|
|
14
18
|
const edges = new Set();
|
|
15
19
|
const importSpecifiers = analyses[file.path]?.imports ?? findImportSpecifiers(file.content);
|
|
16
|
-
for (const
|
|
20
|
+
for (const rawSpecifier of importSpecifiers) {
|
|
21
|
+
// Bundler suffixes (`./icon.svg?react`, `./worker.ts?worker`) are not
|
|
22
|
+
// part of the file name.
|
|
23
|
+
const specifier = stripQuery(rawSpecifier);
|
|
17
24
|
if (specifier.startsWith(".")) {
|
|
18
25
|
const resolved = resolveImport(file.path, specifier, localPaths);
|
|
19
26
|
if (resolved && resolved !== file.path) {
|
|
@@ -21,15 +28,33 @@ export function buildDependencyGraph(files, analyses = {}, aliasMappings = []) {
|
|
|
21
28
|
}
|
|
22
29
|
continue;
|
|
23
30
|
}
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
const resolved =
|
|
31
|
+
// package.json "imports": `#internal/db` is local by definition. Other
|
|
32
|
+
// `#` specifiers (Nuxt's `#shared/...`) are aliases and fall through.
|
|
33
|
+
if (specifier.startsWith("#")) {
|
|
34
|
+
const resolved = resolveSubpathImport(specifier, file.path, packages, localPaths);
|
|
28
35
|
if (resolved) {
|
|
29
36
|
if (resolved !== file.path)
|
|
30
37
|
edges.add(resolved);
|
|
38
|
+
continue;
|
|
31
39
|
}
|
|
32
|
-
|
|
40
|
+
}
|
|
41
|
+
// Try alias resolution for non-relative imports
|
|
42
|
+
const candidates = resolveAliasCandidates(specifier, aliasMappings, file.path);
|
|
43
|
+
const aliasResolved = candidates.length > 0 ? firstResolved(candidates, localPaths) : null;
|
|
44
|
+
if (aliasResolved) {
|
|
45
|
+
if (aliasResolved !== file.path)
|
|
46
|
+
edges.add(aliasResolved);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
// A package that lives in this repo (workspace member): import by name.
|
|
50
|
+
const workspaceResolved = resolveWorkspaceSpecifier(specifier, packages, localPaths);
|
|
51
|
+
if (workspaceResolved) {
|
|
52
|
+
if (workspaceResolved !== file.path)
|
|
53
|
+
edges.add(workspaceResolved);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (candidates.length > 0) {
|
|
57
|
+
if (isDeclaredAlias(specifier, aliasMappings, file.path)) {
|
|
33
58
|
diagnostics.unresolvedAliases.push({ file: file.path, specifier });
|
|
34
59
|
}
|
|
35
60
|
}
|
|
@@ -45,6 +70,8 @@ export function buildDependencyGraph(files, analyses = {}, aliasMappings = []) {
|
|
|
45
70
|
diagnostics.parserFallbacks.push(file.path);
|
|
46
71
|
}
|
|
47
72
|
}
|
|
73
|
+
// Frameworks that connect files without import statements.
|
|
74
|
+
addNuxtAutoImportEdges(graph, files, analyses);
|
|
48
75
|
return { graph, diagnostics };
|
|
49
76
|
}
|
|
50
77
|
export function countReferences(graph) {
|
|
@@ -56,6 +83,10 @@ export function countReferences(graph) {
|
|
|
56
83
|
}
|
|
57
84
|
return counts;
|
|
58
85
|
}
|
|
86
|
+
function stripQuery(specifier) {
|
|
87
|
+
const query = specifier.indexOf("?");
|
|
88
|
+
return query === -1 ? specifier : specifier.slice(0, query);
|
|
89
|
+
}
|
|
59
90
|
function findImportSpecifiers(content) {
|
|
60
91
|
const matches = [];
|
|
61
92
|
IMPORT_RE.lastIndex = 0;
|
|
@@ -97,51 +128,4 @@ function firstResolved(rootRelativePaths, localPaths) {
|
|
|
97
128
|
}
|
|
98
129
|
return null;
|
|
99
130
|
}
|
|
100
|
-
const SOURCE_EXTENSIONS = [
|
|
101
|
-
".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".vue", ".svelte", ".astro",
|
|
102
|
-
".py", ".rb", ".php"
|
|
103
|
-
];
|
|
104
|
-
const INDEX_EXTENSIONS = [
|
|
105
|
-
".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".vue", ".svelte", ".astro",
|
|
106
|
-
".py", ".rb", ".php"
|
|
107
|
-
];
|
|
108
|
-
// TypeScript ESM writes the emitted extension in the specifier.
|
|
109
|
-
const EMITTED_EXTENSION_SOURCES = [
|
|
110
|
-
[".js", [".ts", ".tsx"]],
|
|
111
|
-
[".jsx", [".tsx"]],
|
|
112
|
-
[".mjs", [".mts"]],
|
|
113
|
-
[".cjs", [".cts"]]
|
|
114
|
-
];
|
|
115
|
-
function matchLocalPath(normalized, localPaths) {
|
|
116
|
-
const candidates = [
|
|
117
|
-
normalized,
|
|
118
|
-
...SOURCE_EXTENSIONS.map((extension) => `${normalized}${extension}`),
|
|
119
|
-
...INDEX_EXTENSIONS.map((extension) => `${normalized}/index${extension}`),
|
|
120
|
-
`${normalized}/__init__.py`
|
|
121
|
-
];
|
|
122
|
-
for (const [emitted, sources] of EMITTED_EXTENSION_SOURCES) {
|
|
123
|
-
if (normalized.endsWith(emitted)) {
|
|
124
|
-
const withoutExtension = normalized.slice(0, -emitted.length);
|
|
125
|
-
candidates.push(...sources.map((source) => `${withoutExtension}${source}`));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return candidates.find((candidate) => localPaths.has(candidate)) ?? null;
|
|
129
|
-
}
|
|
130
|
-
/** Collapse `.` and `..`; null when the path climbs above the project root. */
|
|
131
|
-
function normalizePath(path) {
|
|
132
|
-
const parts = [];
|
|
133
|
-
for (const part of path.split("/")) {
|
|
134
|
-
if (part === "." || part === "") {
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
if (part === "..") {
|
|
138
|
-
if (parts.length === 0)
|
|
139
|
-
return null;
|
|
140
|
-
parts.pop();
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
parts.push(part);
|
|
144
|
-
}
|
|
145
|
-
return parts.join("/");
|
|
146
|
-
}
|
|
147
131
|
//# sourceMappingURL=dependencyGraph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencyGraph.js","sourceRoot":"","sources":["../../../src/analyzers/graph/dependencyGraph.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"dependencyGraph.js","sourceRoot":"","sources":["../../../src/analyzers/graph/dependencyGraph.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,aAA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CAAC;IAEjD,KAAK,MAAM,IAAI,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC;QAChC,KAAK,MAAM,SAAS,IAAI,CAAC,GAAG,IAAI,GAAG,UAAU,KAAK,EAAE,GAAG,IAAI,GAAG,UAAU,cAAc,CAAC,EAAE,CAAC;YACxF,IAAI,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC;gBAAE,OAAO,SAAS,CAAC;QAClD,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,aAAa,CAAC,iBAA2B,EAAE,UAAuB;IACzE,KAAK,MAAM,gBAAgB,IAAI,iBAAiB,EAAE,CAAC;QACjD,MAAM,UAAU,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAC;QACnD,IAAI,UAAU,KAAK,IAAI;YAAE,SAAS;QAClC,MAAM,QAAQ,GAAG,cAAc,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACxD,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;IAChC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import type { FileGraph } from "./dependencyGraph.js";
|
|
2
|
-
|
|
2
|
+
import type { ManifestEntry } from "./packageManifests.js";
|
|
3
|
+
/**
|
|
4
|
+
* `manifestEntries` come from package.json (`bin`, `main`/`exports`, scripts).
|
|
5
|
+
* A `main` file that another source file imports is just shared plumbing, so
|
|
6
|
+
* it only counts while nothing imports it; `bin` and script entries are
|
|
7
|
+
* started from outside and always count.
|
|
8
|
+
*/
|
|
9
|
+
export declare function detectEntryPoints(graph: FileGraph, manifestEntries?: ManifestEntry[]): string[];
|
|
3
10
|
//# sourceMappingURL=entryPoints.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entryPoints.d.ts","sourceRoot":"","sources":["../../../src/analyzers/graph/entryPoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"entryPoints.d.ts","sourceRoot":"","sources":["../../../src/analyzers/graph/entryPoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AA4D3D;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,eAAe,GAAE,aAAa,EAAO,GAAG,MAAM,EAAE,CAsCnG"}
|
|
@@ -6,11 +6,35 @@ const ENTRY_PATTERNS = [
|
|
|
6
6
|
/(^|\/)(server|app|index|main)\.[cm]?[jt]sx?$/,
|
|
7
7
|
/(^|\/)route\.[jt]s$/
|
|
8
8
|
];
|
|
9
|
+
// Files a framework loads by convention. They only count while no source file
|
|
10
|
+
// imports them: a Vue SPA's `pages/Home.vue` pulled in by its router is a
|
|
11
|
+
// component, while a Nuxt page that nothing references is where a route starts.
|
|
12
|
+
const FRAMEWORK_LOADED_PATTERNS = [
|
|
13
|
+
/(^|\/)app\.vue$/,
|
|
14
|
+
/(^|\/)\+(?:page|layout)\.svelte$/,
|
|
15
|
+
/(^|\/)\+server\.[jt]s$/,
|
|
16
|
+
/(^|\/)hooks\.(?:server|client)\.[jt]s$/,
|
|
17
|
+
/(^|\/)app\/root\.[jt]sx?$/,
|
|
18
|
+
/(^|\/)entry\.(?:client|server)\.[jt]sx?$/,
|
|
19
|
+
/(^|\/)pages\/.+\.(?:vue|astro)$/,
|
|
20
|
+
/(^|\/)pages\/(?:_app|_document)\.[jt]sx?$/,
|
|
21
|
+
/(^|\/)server\/(?:api|routes|middleware)\/.+\.[cm]?[jt]s$/
|
|
22
|
+
];
|
|
9
23
|
const ENTRY_PATTERN_SCORES = [
|
|
10
24
|
{ pattern: /(^|\/)layout\.[jt]sx?$/, score: 0 },
|
|
25
|
+
{ pattern: /(^|\/)app\/root\.[jt]sx?$/, score: 0 },
|
|
26
|
+
{ pattern: /(^|\/)\+layout\.svelte$/, score: 0 },
|
|
27
|
+
{ pattern: /(^|\/)app\.vue$/, score: 0 },
|
|
28
|
+
{ pattern: /(^|\/)pages\/(?:_app|_document)\.[jt]sx?$/, score: 0 },
|
|
29
|
+
{ pattern: /(^|\/)pages\/.+\.(?:vue|astro)$/, score: 1 },
|
|
11
30
|
{ pattern: /(^|\/)page\.[jt]sx?$/, score: 1 },
|
|
31
|
+
{ pattern: /(^|\/)\+page\.svelte$/, score: 1 },
|
|
12
32
|
{ pattern: /(^|\/)route\.[jt]s$/, score: 2 },
|
|
33
|
+
{ pattern: /(^|\/)\+server\.[jt]s$/, score: 2 },
|
|
34
|
+
{ pattern: /(^|\/)server\/(?:api|routes|middleware)\/.+\.[cm]?[jt]s$/, score: 2 },
|
|
13
35
|
{ pattern: /(^|\/)middleware\.[jt]s$/, score: 3 },
|
|
36
|
+
{ pattern: /(^|\/)hooks\.(?:server|client)\.[jt]s$/, score: 3 },
|
|
37
|
+
{ pattern: /(^|\/)entry\.(?:client|server)\.[jt]sx?$/, score: 3 },
|
|
14
38
|
{ pattern: /(^|\/)(app|server)\.[cm]?[jt]sx?$/, score: 4 },
|
|
15
39
|
{ pattern: /(^|\/)(index|main)\.[cm]?[jt]sx?$/, score: 5 },
|
|
16
40
|
];
|
|
@@ -21,17 +45,42 @@ function entryPointScore(path) {
|
|
|
21
45
|
}
|
|
22
46
|
return 10;
|
|
23
47
|
}
|
|
24
|
-
|
|
48
|
+
// Declared entries rank above guesses: a CLI's `bin` is the way in, a package's
|
|
49
|
+
// `main` is its public face, and a script runs the file on purpose.
|
|
50
|
+
const MANIFEST_SCORES = {
|
|
51
|
+
bin: -2,
|
|
52
|
+
main: -1,
|
|
53
|
+
script: 6.5
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* `manifestEntries` come from package.json (`bin`, `main`/`exports`, scripts).
|
|
57
|
+
* A `main` file that another source file imports is just shared plumbing, so
|
|
58
|
+
* it only counts while nothing imports it; `bin` and script entries are
|
|
59
|
+
* started from outside and always count.
|
|
60
|
+
*/
|
|
61
|
+
export function detectEntryPoints(graph, manifestEntries = []) {
|
|
25
62
|
// Only production code counts as a consumer: a barrel that nothing but its
|
|
26
63
|
// own tests imports (or a root index.ts that tests import) is still an
|
|
27
64
|
// entry, while a barrel re-exported through the app is just plumbing.
|
|
28
65
|
const imported = new Set(Object.entries(graph)
|
|
29
66
|
.filter(([path]) => isArchitectureSource(path))
|
|
30
67
|
.flatMap(([, imports]) => imports));
|
|
68
|
+
const declared = new Map();
|
|
69
|
+
for (const entry of manifestEntries) {
|
|
70
|
+
if (!(entry.path in graph) || !isSourceFile(entry.path) || !isArchitectureSource(entry.path))
|
|
71
|
+
continue;
|
|
72
|
+
if (entry.kind === "main" && imported.has(entry.path))
|
|
73
|
+
continue;
|
|
74
|
+
const score = MANIFEST_SCORES[entry.kind];
|
|
75
|
+
declared.set(entry.path, Math.min(score, declared.get(entry.path) ?? score));
|
|
76
|
+
}
|
|
77
|
+
const scoreOf = (path) => declared.get(path) ?? entryPointScore(path);
|
|
31
78
|
return Object.keys(graph)
|
|
32
79
|
.filter((path) => isSourceFile(path))
|
|
33
80
|
.filter((path) => isArchitectureSource(path))
|
|
34
81
|
.filter((path) => {
|
|
82
|
+
if (declared.has(path))
|
|
83
|
+
return true;
|
|
35
84
|
const unimportedWithImports = !imported.has(path) && (graph[path]?.length ?? 0) > 0;
|
|
36
85
|
// index.* is also the conventional barrel file; it is an entry only when
|
|
37
86
|
// nothing else imports it. A top-level index (index.ts, src/index.ts) is
|
|
@@ -39,9 +88,11 @@ export function detectEntryPoints(graph) {
|
|
|
39
88
|
if (/(^|\/)index\.[cm]?[jt]sx?$/.test(path)) {
|
|
40
89
|
return !imported.has(path) && ((graph[path]?.length ?? 0) > 0 || path.split("/").length <= 2);
|
|
41
90
|
}
|
|
42
|
-
return ENTRY_PATTERNS.some((pattern) => pattern.test(path))
|
|
91
|
+
return ENTRY_PATTERNS.some((pattern) => pattern.test(path))
|
|
92
|
+
|| (!imported.has(path) && FRAMEWORK_LOADED_PATTERNS.some((pattern) => pattern.test(path)))
|
|
93
|
+
|| unimportedWithImports;
|
|
43
94
|
})
|
|
44
|
-
.sort((a, b) =>
|
|
95
|
+
.sort((a, b) => scoreOf(a) - scoreOf(b) || a.localeCompare(b))
|
|
45
96
|
.slice(0, 20);
|
|
46
97
|
}
|
|
47
98
|
function isSourceFile(path) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entryPoints.js","sourceRoot":"","sources":["../../../src/analyzers/graph/entryPoints.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entryPoints.js","sourceRoot":"","sources":["../../../src/analyzers/graph/entryPoints.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,cAAc,GAAG;IACrB,sBAAsB;IACtB,wBAAwB;IACxB,0BAA0B;IAC1B,8CAA8C;IAC9C,qBAAqB;CACtB,CAAC;AAEF,8EAA8E;AAC9E,0EAA0E;AAC1E,gFAAgF;AAChF,MAAM,yBAAyB,GAAG;IAChC,iBAAiB;IACjB,kCAAkC;IAClC,wBAAwB;IACxB,wCAAwC;IACxC,2BAA2B;IAC3B,0CAA0C;IAC1C,iCAAiC;IACjC,2CAA2C;IAC3C,0DAA0D;CAC3D,CAAC;AAEF,MAAM,oBAAoB,GAA8C;IACtE,EAAE,OAAO,EAAE,wBAAwB,EAAE,KAAK,EAAE,CAAC,EAAE;IAC/C,EAAE,OAAO,EAAE,2BAA2B,EAAE,KAAK,EAAE,CAAC,EAAE;IAClD,EAAE,OAAO,EAAE,yBAAyB,EAAE,KAAK,EAAE,CAAC,EAAE;IAChD,EAAE,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,EAAE;IACxC,EAAE,OAAO,EAAE,2CAA2C,EAAE,KAAK,EAAE,CAAC,EAAE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@ export type { FileGraph, DependencyGraphDiagnostics, } from "./dependencyGraph.j
|
|
|
3
3
|
export { loadAliasMappings, resolveAlias, resolveAliasCandidates, isDeclaredAlias, } from "./aliasResolver.js";
|
|
4
4
|
export type { AliasMapping, } from "./aliasResolver.js";
|
|
5
5
|
export { detectEntryPoints, } from "./entryPoints.js";
|
|
6
|
+
export { indexPackages, manifestEntryPoints, readPackageManifests, resolveSubpathImport, resolveWorkspaceSpecifier, } from "./packageManifests.js";
|
|
7
|
+
export type { ManifestEntry, PackageIndex, PackageManifest, } from "./packageManifests.js";
|
|
6
8
|
export { isArchitectureSource, isTestPath, } from "./sourceScope.js";
|
|
7
9
|
export { buildReverseGraph, buildBoundedTree, collectNodesWithinDepth, DEFAULT_MAX_CHILDREN, } from "./dependencyMap.js";
|
|
8
10
|
export type { MapTreeNode, } from "./dependencyMap.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/analyzers/graph/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,SAAS,EACT,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,sBAAsB,EACtB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,oBAAoB,EACpB,UAAU,GACX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,WAAW,GACZ,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/analyzers/graph/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,SAAS,EACT,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,sBAAsB,EACtB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,aAAa,EACb,YAAY,EACZ,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,oBAAoB,EACpB,UAAU,GACX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,WAAW,GACZ,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { buildDependencyGraph, countReferences, } from "./dependencyGraph.js";
|
|
2
2
|
export { loadAliasMappings, resolveAlias, resolveAliasCandidates, isDeclaredAlias, } from "./aliasResolver.js";
|
|
3
3
|
export { detectEntryPoints, } from "./entryPoints.js";
|
|
4
|
+
export { indexPackages, manifestEntryPoints, readPackageManifests, resolveSubpathImport, resolveWorkspaceSpecifier, } from "./packageManifests.js";
|
|
4
5
|
export { isArchitectureSource, isTestPath, } from "./sourceScope.js";
|
|
5
6
|
export { buildReverseGraph, buildBoundedTree, collectNodesWithinDepth, DEFAULT_MAX_CHILDREN, } from "./dependencyMap.js";
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/analyzers/graph/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,sBAAsB,EACtB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EACL,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,oBAAoB,EACpB,UAAU,GACX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/analyzers/graph/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,sBAAsB,EACtB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EACL,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EACL,oBAAoB,EACpB,UAAU,GACX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function matchLocalPath(normalized: string, localPaths: Set<string>): string | null;
|
|
2
|
+
/** Collapse `.` and `..`; null when the path climbs above the project root. */
|
|
3
|
+
export declare function normalizePath(path: string): string | null;
|
|
4
|
+
//# sourceMappingURL=localPaths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localPaths.d.ts","sourceRoot":"","sources":["../../../src/analyzers/graph/localPaths.ts"],"names":[],"mappings":"AAoBA,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,CAgBzF;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkBzD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Shared path matching for graph resolution: turn an import target (no
|
|
2
|
+
// extension, directory, or emitted `.js`) into a scanned source file.
|
|
3
|
+
const SOURCE_EXTENSIONS = [
|
|
4
|
+
".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".vue", ".svelte", ".astro",
|
|
5
|
+
".py", ".rb", ".php"
|
|
6
|
+
];
|
|
7
|
+
const INDEX_EXTENSIONS = [
|
|
8
|
+
".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".vue", ".svelte", ".astro",
|
|
9
|
+
".py", ".rb", ".php"
|
|
10
|
+
];
|
|
11
|
+
// TypeScript ESM writes the emitted extension in the specifier.
|
|
12
|
+
const EMITTED_EXTENSION_SOURCES = [
|
|
13
|
+
[".js", [".ts", ".tsx"]],
|
|
14
|
+
[".jsx", [".tsx"]],
|
|
15
|
+
[".mjs", [".mts"]],
|
|
16
|
+
[".cjs", [".cts"]]
|
|
17
|
+
];
|
|
18
|
+
export function matchLocalPath(normalized, localPaths) {
|
|
19
|
+
const candidates = [
|
|
20
|
+
normalized,
|
|
21
|
+
...SOURCE_EXTENSIONS.map((extension) => `${normalized}${extension}`),
|
|
22
|
+
...INDEX_EXTENSIONS.map((extension) => `${normalized}/index${extension}`),
|
|
23
|
+
`${normalized}/__init__.py`
|
|
24
|
+
];
|
|
25
|
+
for (const [emitted, sources] of EMITTED_EXTENSION_SOURCES) {
|
|
26
|
+
if (normalized.endsWith(emitted)) {
|
|
27
|
+
const withoutExtension = normalized.slice(0, -emitted.length);
|
|
28
|
+
candidates.push(...sources.map((source) => `${withoutExtension}${source}`));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return candidates.find((candidate) => localPaths.has(candidate)) ?? null;
|
|
32
|
+
}
|
|
33
|
+
/** Collapse `.` and `..`; null when the path climbs above the project root. */
|
|
34
|
+
export function normalizePath(path) {
|
|
35
|
+
const parts = [];
|
|
36
|
+
for (const part of path.split("/")) {
|
|
37
|
+
if (part === "." || part === "") {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (part === "..") {
|
|
41
|
+
if (parts.length === 0)
|
|
42
|
+
return null;
|
|
43
|
+
parts.pop();
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
parts.push(part);
|
|
47
|
+
}
|
|
48
|
+
return parts.join("/");
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=localPaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localPaths.js","sourceRoot":"","sources":["../../../src/analyzers/graph/localPaths.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,sEAAsE;AAEtE,MAAM,iBAAiB,GAAG;IACxB,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ;IACzF,KAAK,EAAE,KAAK,EAAE,MAAM;CACrB,CAAC;AACF,MAAM,gBAAgB,GAAG;IACvB,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ;IACzF,KAAK,EAAE,KAAK,EAAE,MAAM;CACrB,CAAC;AAEF,gEAAgE;AAChE,MAAM,yBAAyB,GAA8B;IAC3D,CAAC,KAAK,EAAE,CAAC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IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;YAChC,SAAS;QACX,CAAC;QAED,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;YACpC,KAAK,CAAC,GAAG,EAAE,CAAC;YACZ,SAAS;QACX,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { FileAnalysis, ScannedFile } from "../analysis/index.js";
|
|
2
|
+
import type { FileGraph } from "./dependencyGraph.js";
|
|
3
|
+
/**
|
|
4
|
+
* Nuxt wires files together without import statements: components, composables
|
|
5
|
+
* and utils are picked up from their folders, and `~/` points at `app/` (Nuxt
|
|
6
|
+
* 4) or the project root (Nuxt 3), not at `src/`. Without modelling that, a
|
|
7
|
+
* Nuxt project looks like a pile of files that never reference each other.
|
|
8
|
+
*/
|
|
9
|
+
export interface NuxtApp {
|
|
10
|
+
/** Project-root-relative directory holding nuxt.config (`""` for the root). */
|
|
11
|
+
dir: string;
|
|
12
|
+
/** Source directory, relative to `dir` (`""` or `"app"`, or a custom srcDir). */
|
|
13
|
+
srcDir: string;
|
|
14
|
+
/** `@pinia/nuxt` is installed: `stores/` is auto-imported too. */
|
|
15
|
+
pinia: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The source directory a Nuxt project uses. An explicit `srcDir` in the config
|
|
19
|
+
* wins; otherwise `app/` when the Nuxt 4 layout is present, else the root.
|
|
20
|
+
* `hasPath` answers whether a path (or, with a trailing slash, a folder)
|
|
21
|
+
* exists under the config's directory.
|
|
22
|
+
*/
|
|
23
|
+
export declare function pickNuxtSrcDir(configText: string, hasPath: (relative: string) => boolean): string;
|
|
24
|
+
export declare function detectNuxtApps(files: ScannedFile[]): NuxtApp[];
|
|
25
|
+
/**
|
|
26
|
+
* Add the edges Nuxt creates implicitly: a file that renders `<AccountAvatar>`
|
|
27
|
+
* or calls `useUser()` depends on the component / composable file that
|
|
28
|
+
* provides it. Mutates `graph`; existing explicit imports are untouched.
|
|
29
|
+
*/
|
|
30
|
+
export declare function addNuxtAutoImportEdges(graph: FileGraph, files: ScannedFile[], analyses: Record<string, FileAnalysis>): void;
|
|
31
|
+
/** Nuxt's component name: folder path + file name, overlap dropped. */
|
|
32
|
+
export declare function componentName(relativeToComponents: string): string | null;
|
|
33
|
+
//# sourceMappingURL=nuxtAutoImports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nuxtAutoImports.d.ts","sourceRoot":"","sources":["../../../src/analyzers/graph/nuxtAutoImports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;;;;GAKG;AAEH,MAAM,WAAW,OAAO;IACtB,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAC;IACZ,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,KAAK,EAAE,OAAO,CAAC;CAChB;AAaD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,CAOjG;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,EAAE,CAoB9D;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,WAAW,EAAE,EACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GACrC,IAAI,CAoGN;AAID,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,oBAAoB,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAuBzE"}
|