@ankhorage/dependency-graph 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/dependencyGraph.d.ts +2 -1
- package/dist/dependencyGraph.d.ts.map +1 -1
- package/dist/dependencyGraph.js +1 -0
- package/dist/dependencyGraph.js.map +1 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.d.ts.map +1 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.js +2 -2
- package/dist/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.js.map +1 -1
- package/dist/features/dependency-analysis/adapters/outbound/delphi/analyzeDelphiProjectAsync.js +2 -2
- package/dist/features/dependency-analysis/adapters/outbound/delphi/analyzeDelphiProjectAsync.js.map +1 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/analyzeJavaProjectAsync.js +2 -2
- package/dist/features/dependency-analysis/adapters/outbound/java/analyzeJavaProjectAsync.js.map +1 -1
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/analyzeKotlinProjectAsync.js +2 -2
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/analyzeKotlinProjectAsync.js.map +1 -1
- package/dist/features/dependency-analysis/adapters/outbound/python/analyzePythonProjectAsync.js +2 -2
- package/dist/features/dependency-analysis/adapters/outbound/python/analyzePythonProjectAsync.js.map +1 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.js +2 -2
- package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.js.map +1 -1
- package/dist/features/dependency-analysis/application/assertDependencyGraphProjectIds.d.ts +5 -0
- package/dist/features/dependency-analysis/application/assertDependencyGraphProjectIds.d.ts.map +1 -0
- package/dist/features/dependency-analysis/application/assertDependencyGraphProjectIds.js +14 -0
- package/dist/features/dependency-analysis/application/assertDependencyGraphProjectIds.js.map +1 -0
- package/dist/features/dependency-analysis/application/createDependencyGraphAsync.d.ts +1 -1
- package/dist/features/dependency-analysis/application/createDependencyGraphAsync.d.ts.map +1 -1
- package/dist/features/dependency-analysis/application/createDependencyGraphAsync.js +14 -113
- package/dist/features/dependency-analysis/application/createDependencyGraphAsync.js.map +1 -1
- package/dist/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.d.ts +6 -0
- package/dist/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.d.ts.map +1 -0
- package/dist/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.js +104 -0
- package/dist/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.js.map +1 -0
- package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.d.ts +4 -0
- package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.d.ts.map +1 -0
- package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.js +36 -0
- package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.js.map +1 -0
- package/dist/types/dependencyGraph.d.ts +9 -0
- package/dist/types/dependencyGraph.d.ts.map +1 -1
- package/dist/types/dependencyGraph.js.map +1 -1
- package/package.json +2 -2
- package/dist/features/dependency-analysis/adapters/outbound/cpp/collectCppFilesAsync.d.ts +0 -3
- package/dist/features/dependency-analysis/adapters/outbound/cpp/collectCppFilesAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/collectCppFilesAsync.js +0 -43
- package/dist/features/dependency-analysis/adapters/outbound/cpp/collectCppFilesAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/delphi/collectDelphiFilesAsync.d.ts +0 -3
- package/dist/features/dependency-analysis/adapters/outbound/delphi/collectDelphiFilesAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/delphi/collectDelphiFilesAsync.js +0 -43
- package/dist/features/dependency-analysis/adapters/outbound/delphi/collectDelphiFilesAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/collectJavaFilesAsync.d.ts +0 -3
- package/dist/features/dependency-analysis/adapters/outbound/java/collectJavaFilesAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/collectJavaFilesAsync.js +0 -41
- package/dist/features/dependency-analysis/adapters/outbound/java/collectJavaFilesAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/collectKotlinFilesAsync.d.ts +0 -3
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/collectKotlinFilesAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/collectKotlinFilesAsync.js +0 -41
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/collectKotlinFilesAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/python/collectPythonFilesAsync.d.ts +0 -3
- package/dist/features/dependency-analysis/adapters/outbound/python/collectPythonFilesAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/python/collectPythonFilesAsync.js +0 -50
- package/dist/features/dependency-analysis/adapters/outbound/python/collectPythonFilesAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/collectTypeScriptFilesAsync.d.ts +0 -3
- package/dist/features/dependency-analysis/adapters/outbound/typescript/collectTypeScriptFilesAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/collectTypeScriptFilesAsync.js +0 -52
- package/dist/features/dependency-analysis/adapters/outbound/typescript/collectTypeScriptFilesAsync.js.map +0 -1
|
@@ -1,118 +1,19 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { createGraph } from '@ankhorage/graph';
|
|
3
1
|
import { inspectProjectAsync } from '@ankhorage/project-detector/node';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { kotlinDependencyGraphAnalyzer } from '../adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.js';
|
|
8
|
-
import { pythonDependencyGraphAnalyzer } from '../adapters/outbound/python/pythonDependencyGraphAnalyzer.js';
|
|
9
|
-
import { typescriptDependencyGraphAnalyzer } from '../adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js';
|
|
10
|
-
import { createFocusPackageNode } from '../domain/createFocusPackageNode.js';
|
|
11
|
-
import { readDependencyDeclarationsAsync } from '../domain/readDependencyDeclarationsAsync.js';
|
|
12
|
-
/*** Inspect projects, run supported analyzers and combine their evidence into one canonical graph. */
|
|
2
|
+
import { assertDependencyGraphProjectIds } from './assertDependencyGraphProjectIds.js';
|
|
3
|
+
import { createDependencyGraphFromInspectionsAsync } from './createDependencyGraphFromInspectionsAsync.js';
|
|
4
|
+
/*** Inspect project roots, then delegate dependency topology construction to the inspection API. */
|
|
13
5
|
export async function createDependencyGraphAsync(input) {
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const focusPackages = createFocusPackageMap(packages);
|
|
26
|
-
const fragments = await analyzePackagesAsync(inspected, analyzers, focusPackages, input.signal);
|
|
27
|
-
const nodes = new Map(packages.map((packageContext) => {
|
|
28
|
-
const node = createFocusPackageNode(packageContext);
|
|
29
|
-
return [node.id, node];
|
|
30
|
-
}));
|
|
31
|
-
for (const node of fragments.flatMap(({ nodes: fragmentNodes }) => fragmentNodes)) {
|
|
32
|
-
if (!nodes.has(node.id))
|
|
33
|
-
nodes.set(node.id, node);
|
|
34
|
-
}
|
|
35
|
-
const edges = fragments.flatMap(({ edges: fragmentEdges }) => fragmentEdges);
|
|
36
|
-
return createGraph({ nodes: [...nodes.values()], edges });
|
|
37
|
-
}
|
|
38
|
-
/*** Inspect one input and normalize its package/workspace contexts. */
|
|
39
|
-
async function inspectProjectInputAsync(project, signal) {
|
|
40
|
-
const inspection = await inspectProjectAsync(project.rootPath, {
|
|
41
|
-
excludeDirectories: ['.ankh'],
|
|
42
|
-
...(signal === undefined ? {} : { signal }),
|
|
6
|
+
assertDependencyGraphProjectIds(input.projects);
|
|
7
|
+
const projects = await Promise.all(input.projects.map(async (project) => ({
|
|
8
|
+
id: project.id,
|
|
9
|
+
inspection: await inspectProjectAsync(project.rootPath, {
|
|
10
|
+
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
11
|
+
}),
|
|
12
|
+
})));
|
|
13
|
+
return createDependencyGraphFromInspectionsAsync({
|
|
14
|
+
projects,
|
|
15
|
+
...(input.analyzers === undefined ? {} : { analyzers: input.analyzers }),
|
|
16
|
+
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
43
17
|
});
|
|
44
|
-
if (!inspection.complete) {
|
|
45
|
-
throw new Error(`Dependency graph inspection is incomplete for "${project.id}": ${inspection.diagnostics
|
|
46
|
-
.map(({ message }) => message)
|
|
47
|
-
.join('; ')}`);
|
|
48
|
-
}
|
|
49
|
-
const detectedPackages = inspection.packages.length > 0
|
|
50
|
-
? inspection.packages
|
|
51
|
-
: [{ rootPath: '.', detection: inspection.detection, manifestPath: '' }];
|
|
52
|
-
const packages = await Promise.all(detectedPackages.map(async (detected) => {
|
|
53
|
-
const relativeRoot = detected.rootPath;
|
|
54
|
-
const id = `${project.id}:${relativeRoot}`;
|
|
55
|
-
const manifestPath = detected.manifestPath === ''
|
|
56
|
-
? undefined
|
|
57
|
-
: path.join(inspection.rootPath, detected.manifestPath);
|
|
58
|
-
return {
|
|
59
|
-
id,
|
|
60
|
-
nodeId: `package:${id}`,
|
|
61
|
-
projectId: project.id,
|
|
62
|
-
rootPath: path.resolve(inspection.rootPath, relativeRoot),
|
|
63
|
-
relativeRoot,
|
|
64
|
-
...(detected.name === undefined ? {} : { name: detected.name }),
|
|
65
|
-
detection: detected.detection,
|
|
66
|
-
declarations: await readDependencyDeclarationsAsync(manifestPath),
|
|
67
|
-
};
|
|
68
|
-
}));
|
|
69
|
-
return { inspection, packages };
|
|
70
|
-
}
|
|
71
|
-
/*** Analyze each package with the first compatible analyzer and retain mixed-language packages safely. */
|
|
72
|
-
async function analyzePackagesAsync(inspected, analyzers, focusPackages, signal) {
|
|
73
|
-
const tasks = inspected.flatMap(({ inspection, packages }) => packages.flatMap((packageContext) => {
|
|
74
|
-
const analyzer = analyzers.find(({ supports }) => supports(packageContext.detection));
|
|
75
|
-
if (analyzer === undefined)
|
|
76
|
-
return [];
|
|
77
|
-
const excludedRoots = packages
|
|
78
|
-
.filter((candidate) => candidate.id !== packageContext.id &&
|
|
79
|
-
candidate.rootPath.startsWith(`${packageContext.rootPath}${path.sep}`))
|
|
80
|
-
.map(({ rootPath }) => rootPath);
|
|
81
|
-
return [
|
|
82
|
-
analyzer.analyzeAsync({
|
|
83
|
-
package: packageContext,
|
|
84
|
-
inspection,
|
|
85
|
-
focusPackages,
|
|
86
|
-
excludedRoots: [path.join(packageContext.rootPath, '.ankh'), ...excludedRoots],
|
|
87
|
-
...(signal === undefined ? {} : { signal }),
|
|
88
|
-
}),
|
|
89
|
-
];
|
|
90
|
-
}));
|
|
91
|
-
if (tasks.length === 0) {
|
|
92
|
-
throw new Error('No dependency graph analyzer supports the supplied projects.');
|
|
93
|
-
}
|
|
94
|
-
return Promise.all(tasks);
|
|
95
|
-
}
|
|
96
|
-
/*** Build a unique package-name map for focus routing across repositories and workspaces. */
|
|
97
|
-
function createFocusPackageMap(packages) {
|
|
98
|
-
const named = packages.filter((packageContext) => packageContext.name !== undefined);
|
|
99
|
-
const duplicates = named.filter((item, index) => named.findIndex(({ name }) => name === item.name) !== index);
|
|
100
|
-
if (duplicates.length > 0) {
|
|
101
|
-
throw new Error(`Duplicate focus package name: ${duplicates[0]?.name ?? 'unknown'}.`);
|
|
102
|
-
}
|
|
103
|
-
return new Map(named.map(({ name, nodeId }) => [name, nodeId]));
|
|
104
|
-
}
|
|
105
|
-
/*** Reject ambiguous project IDs before filesystem inspection. */
|
|
106
|
-
function assertProjectInputs(projects) {
|
|
107
|
-
if (projects.length === 0) {
|
|
108
|
-
throw new Error('At least one dependency graph project is required.');
|
|
109
|
-
}
|
|
110
|
-
const ids = projects.map(({ id }) => id);
|
|
111
|
-
if (ids.some((id) => id.trim() === '')) {
|
|
112
|
-
throw new Error('Dependency graph project IDs must be non-empty.');
|
|
113
|
-
}
|
|
114
|
-
if (new Set(ids).size !== ids.length) {
|
|
115
|
-
throw new Error('Dependency graph project IDs must be unique.');
|
|
116
|
-
}
|
|
117
18
|
}
|
|
118
19
|
//# sourceMappingURL=createDependencyGraphAsync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDependencyGraphAsync.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/application/createDependencyGraphAsync.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAWvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wDAAwD,CAAC;AACpG,OAAO,EAAE,6BAA6B,EAAE,MAAM,8DAA8D,CAAC;AAC7G,OAAO,EAAE,2BAA2B,EAAE,MAAM,0DAA0D,CAAC;AACvG,OAAO,EAAE,6BAA6B,EAAE,MAAM,8DAA8D,CAAC;AAC7G,OAAO,EAAE,6BAA6B,EAAE,MAAM,8DAA8D,CAAC;AAC7G,OAAO,EAAE,iCAAiC,EAAE,MAAM,sEAAsE,CAAC;AACzH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,+BAA+B,EAAE,MAAM,8CAA8C,CAAC;AAE/F,sGAAsG;AACtG,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,KAAiC;IAEjC,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI;QACnC,iCAAiC;QACjC,0BAA0B;QAC1B,6BAA6B;QAC7B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CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,kEAAkE;AAClE,SAAS,mBAAmB,CAAC,QAAgD;IAC3E,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;IACzC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;AACH,CAAC","sourcesContent":["import path from 'node:path';\n\nimport { createGraph } from '@ankhorage/graph';\nimport { inspectProjectAsync } from '@ankhorage/project-detector/node';\nimport type { InspectedPackage, ProjectInspection } from '@ankhorage/project-detector/types';\n\nimport type {\n CreateDependencyGraphInput,\n DependencyGraph,\n DependencyGraphAnalyzer,\n DependencyGraphFragment,\n DependencyGraphPackage,\n DependencyGraphProjectInput,\n} from '../../../types/dependencyGraph.js';\nimport { cppDependencyGraphAnalyzer } from '../adapters/outbound/cpp/cppDependencyGraphAnalyzer.js';\nimport { delphiDependencyGraphAnalyzer } from '../adapters/outbound/delphi/delphiDependencyGraphAnalyzer.js';\nimport { javaDependencyGraphAnalyzer } from '../adapters/outbound/java/javaDependencyGraphAnalyzer.js';\nimport { kotlinDependencyGraphAnalyzer } from '../adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.js';\nimport { pythonDependencyGraphAnalyzer } from '../adapters/outbound/python/pythonDependencyGraphAnalyzer.js';\nimport { typescriptDependencyGraphAnalyzer } from '../adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js';\nimport { createFocusPackageNode } from '../domain/createFocusPackageNode.js';\nimport { readDependencyDeclarationsAsync } from '../domain/readDependencyDeclarationsAsync.js';\n\n/*** Inspect projects, run supported analyzers and combine their evidence into one canonical graph. */\nexport async function createDependencyGraphAsync(\n input: CreateDependencyGraphInput,\n): Promise<DependencyGraph> {\n assertProjectInputs(input.projects);\n const analyzers = input.analyzers ?? [\n typescriptDependencyGraphAnalyzer,\n cppDependencyGraphAnalyzer,\n delphiDependencyGraphAnalyzer,\n javaDependencyGraphAnalyzer,\n kotlinDependencyGraphAnalyzer,\n pythonDependencyGraphAnalyzer,\n ];\n const inspected = await Promise.all(\n input.projects.map((project) => inspectProjectInputAsync(project, input.signal)),\n );\n const packages = inspected.flatMap(({ packages }) => packages);\n const focusPackages = createFocusPackageMap(packages);\n const fragments = await analyzePackagesAsync(inspected, analyzers, focusPackages, input.signal);\n const nodes = new Map(\n packages.map((packageContext) => {\n const node = createFocusPackageNode(packageContext);\n return [node.id, node] as const;\n }),\n );\n\n for (const node of fragments.flatMap(({ nodes: fragmentNodes }) => fragmentNodes)) {\n if (!nodes.has(node.id)) nodes.set(node.id, node);\n }\n\n const edges = fragments.flatMap(({ edges: fragmentEdges }) => fragmentEdges);\n return createGraph({ nodes: [...nodes.values()], edges });\n}\n\ninterface InspectedInput {\n readonly inspection: ProjectInspection;\n readonly packages: readonly DependencyGraphPackage[];\n}\n\n/*** Inspect one input and normalize its package/workspace contexts. */\nasync function inspectProjectInputAsync(\n project: DependencyGraphProjectInput,\n signal: AbortSignal | undefined,\n): Promise<InspectedInput> {\n const inspection = await inspectProjectAsync(project.rootPath, {\n excludeDirectories: ['.ankh'],\n ...(signal === undefined ? {} : { signal }),\n });\n if (!inspection.complete) {\n throw new Error(\n `Dependency graph inspection is incomplete for \"${project.id}\": ${inspection.diagnostics\n .map(({ message }) => message)\n .join('; ')}`,\n );\n }\n\n const detectedPackages: readonly InspectedPackage[] =\n inspection.packages.length > 0\n ? inspection.packages\n : [{ rootPath: '.', detection: inspection.detection, manifestPath: '' }];\n\n const packages = await Promise.all(\n detectedPackages.map(async (detected) => {\n const relativeRoot = detected.rootPath;\n const id = `${project.id}:${relativeRoot}`;\n const manifestPath =\n detected.manifestPath === ''\n ? undefined\n : path.join(inspection.rootPath, detected.manifestPath);\n\n return {\n id,\n nodeId: `package:${id}`,\n projectId: project.id,\n rootPath: path.resolve(inspection.rootPath, relativeRoot),\n relativeRoot,\n ...(detected.name === undefined ? {} : { name: detected.name }),\n detection: detected.detection,\n declarations: await readDependencyDeclarationsAsync(manifestPath),\n } satisfies DependencyGraphPackage;\n }),\n );\n return { inspection, packages };\n}\n\n/*** Analyze each package with the first compatible analyzer and retain mixed-language packages safely. */\nasync function analyzePackagesAsync(\n inspected: readonly InspectedInput[],\n analyzers: readonly DependencyGraphAnalyzer[],\n focusPackages: ReadonlyMap<string, string>,\n signal: AbortSignal | undefined,\n): Promise<readonly DependencyGraphFragment[]> {\n const tasks = inspected.flatMap(({ inspection, packages }) =>\n packages.flatMap((packageContext) => {\n const analyzer = analyzers.find(({ supports }) => supports(packageContext.detection));\n if (analyzer === undefined) return [];\n\n const excludedRoots = packages\n .filter(\n (candidate) =>\n candidate.id !== packageContext.id &&\n candidate.rootPath.startsWith(`${packageContext.rootPath}${path.sep}`),\n )\n .map(({ rootPath }) => rootPath);\n\n return [\n analyzer.analyzeAsync({\n package: packageContext,\n inspection,\n focusPackages,\n excludedRoots: [path.join(packageContext.rootPath, '.ankh'), ...excludedRoots],\n ...(signal === undefined ? {} : { signal }),\n }),\n ];\n }),\n );\n\n if (tasks.length === 0) {\n throw new Error('No dependency graph analyzer supports the supplied projects.');\n }\n return Promise.all(tasks);\n}\n\n/*** Build a unique package-name map for focus routing across repositories and workspaces. */\nfunction createFocusPackageMap(\n packages: readonly DependencyGraphPackage[],\n): ReadonlyMap<string, string> {\n const named = packages.filter(\n (packageContext): packageContext is DependencyGraphPackage & { readonly name: string } =>\n packageContext.name !== undefined,\n );\n const duplicates = named.filter(\n (item, index) => named.findIndex(({ name }) => name === item.name) !== index,\n );\n if (duplicates.length > 0) {\n throw new Error(`Duplicate focus package name: ${duplicates[0]?.name ?? 'unknown'}.`);\n }\n return new Map(named.map(({ name, nodeId }) => [name, nodeId]));\n}\n\n/*** Reject ambiguous project IDs before filesystem inspection. */\nfunction assertProjectInputs(projects: readonly DependencyGraphProjectInput[]): void {\n if (projects.length === 0) {\n throw new Error('At least one dependency graph project is required.');\n }\n\n const ids = projects.map(({ id }) => id);\n if (ids.some((id) => id.trim() === '')) {\n throw new Error('Dependency graph project IDs must be non-empty.');\n }\n if (new Set(ids).size !== ids.length) {\n throw new Error('Dependency graph project IDs must be unique.');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createDependencyGraphAsync.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/application/createDependencyGraphAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAMvE,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,yCAAyC,EAAE,MAAM,gDAAgD,CAAC;AAE3G,oGAAoG;AACpG,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,KAAiC;IAEjC,+BAA+B,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAChC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;QACrC,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,UAAU,EAAE,MAAM,mBAAmB,CAAC,OAAO,CAAC,QAAQ,EAAE;YACtD,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;SAChE,CAAC;KACH,CAAC,CAAC,CACJ,CAAC;IAEF,OAAO,yCAAyC,CAAC;QAC/C,QAAQ;QACR,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;QACxE,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;KAChE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { inspectProjectAsync } from '@ankhorage/project-detector/node';\n\nimport type {\n CreateDependencyGraphInput,\n DependencyGraph,\n} from '../../../types/dependencyGraph.js';\nimport { assertDependencyGraphProjectIds } from './assertDependencyGraphProjectIds.js';\nimport { createDependencyGraphFromInspectionsAsync } from './createDependencyGraphFromInspectionsAsync.js';\n\n/*** Inspect project roots, then delegate dependency topology construction to the inspection API. */\nexport async function createDependencyGraphAsync(\n input: CreateDependencyGraphInput,\n): Promise<DependencyGraph> {\n assertDependencyGraphProjectIds(input.projects);\n const projects = await Promise.all(\n input.projects.map(async (project) => ({\n id: project.id,\n inspection: await inspectProjectAsync(project.rootPath, {\n ...(input.signal === undefined ? {} : { signal: input.signal }),\n }),\n })),\n );\n\n return createDependencyGraphFromInspectionsAsync({\n projects,\n ...(input.analyzers === undefined ? {} : { analyzers: input.analyzers }),\n ...(input.signal === undefined ? {} : { signal: input.signal }),\n });\n}\n"]}
|
package/dist/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CreateDependencyGraphFromInspectionsInput, DependencyGraph } from '../../../types/dependencyGraph.js';
|
|
2
|
+
/***
|
|
3
|
+
* Build one canonical dependency graph from already-inspected projects without rescanning them.
|
|
4
|
+
*/
|
|
5
|
+
export declare function createDependencyGraphFromInspectionsAsync(input: CreateDependencyGraphFromInspectionsInput): Promise<DependencyGraph>;
|
|
6
|
+
//# sourceMappingURL=createDependencyGraphFromInspectionsAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDependencyGraphFromInspectionsAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,yCAAyC,EACzC,eAAe,EAKhB,MAAM,mCAAmC,CAAC;AAW3C;;GAEG;AACH,wBAAsB,yCAAyC,CAC7D,KAAK,EAAE,yCAAyC,GAC/C,OAAO,CAAC,eAAe,CAAC,CA2B1B"}
|
package/dist/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { createGraph } from '@ankhorage/graph';
|
|
3
|
+
import { cppDependencyGraphAnalyzer } from '../adapters/outbound/cpp/cppDependencyGraphAnalyzer.js';
|
|
4
|
+
import { delphiDependencyGraphAnalyzer } from '../adapters/outbound/delphi/delphiDependencyGraphAnalyzer.js';
|
|
5
|
+
import { javaDependencyGraphAnalyzer } from '../adapters/outbound/java/javaDependencyGraphAnalyzer.js';
|
|
6
|
+
import { kotlinDependencyGraphAnalyzer } from '../adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.js';
|
|
7
|
+
import { pythonDependencyGraphAnalyzer } from '../adapters/outbound/python/pythonDependencyGraphAnalyzer.js';
|
|
8
|
+
import { typescriptDependencyGraphAnalyzer } from '../adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js';
|
|
9
|
+
import { createFocusPackageNode } from '../domain/createFocusPackageNode.js';
|
|
10
|
+
import { readDependencyDeclarationsAsync } from '../domain/readDependencyDeclarationsAsync.js';
|
|
11
|
+
import { assertDependencyGraphProjectIds } from './assertDependencyGraphProjectIds.js';
|
|
12
|
+
/***
|
|
13
|
+
* Build one canonical dependency graph from already-inspected projects without rescanning them.
|
|
14
|
+
*/
|
|
15
|
+
export async function createDependencyGraphFromInspectionsAsync(input) {
|
|
16
|
+
assertDependencyGraphProjectIds(input.projects);
|
|
17
|
+
const analyzers = input.analyzers ?? [
|
|
18
|
+
typescriptDependencyGraphAnalyzer,
|
|
19
|
+
cppDependencyGraphAnalyzer,
|
|
20
|
+
delphiDependencyGraphAnalyzer,
|
|
21
|
+
javaDependencyGraphAnalyzer,
|
|
22
|
+
kotlinDependencyGraphAnalyzer,
|
|
23
|
+
pythonDependencyGraphAnalyzer,
|
|
24
|
+
];
|
|
25
|
+
const inspected = await Promise.all(input.projects.map(createInspectedInputAsync));
|
|
26
|
+
const packages = inspected.flatMap(({ packages: projectPackages }) => projectPackages);
|
|
27
|
+
const focusPackages = createFocusPackageMap(packages);
|
|
28
|
+
const fragments = await analyzePackagesAsync(inspected, analyzers, focusPackages, input.signal);
|
|
29
|
+
const nodes = new Map(packages.map((packageContext) => {
|
|
30
|
+
const node = createFocusPackageNode(packageContext);
|
|
31
|
+
return [node.id, node];
|
|
32
|
+
}));
|
|
33
|
+
for (const node of fragments.flatMap(({ nodes: fragmentNodes }) => fragmentNodes)) {
|
|
34
|
+
if (!nodes.has(node.id))
|
|
35
|
+
nodes.set(node.id, node);
|
|
36
|
+
}
|
|
37
|
+
const edges = fragments.flatMap(({ edges: fragmentEdges }) => fragmentEdges);
|
|
38
|
+
return createGraph({ nodes: [...nodes.values()], edges });
|
|
39
|
+
}
|
|
40
|
+
/*** Normalize one supplied inspection into dependency-analysis package contexts. */
|
|
41
|
+
async function createInspectedInputAsync(project) {
|
|
42
|
+
const { inspection } = project;
|
|
43
|
+
if (!inspection.complete) {
|
|
44
|
+
throw new Error(`Dependency graph inspection is incomplete for "${project.id}": ${inspection.diagnostics
|
|
45
|
+
.map(({ message }) => message)
|
|
46
|
+
.join('; ')}`);
|
|
47
|
+
}
|
|
48
|
+
const detectedPackages = inspection.packages.length > 0
|
|
49
|
+
? inspection.packages
|
|
50
|
+
: [{ rootPath: '.', detection: inspection.detection, manifestPath: '' }];
|
|
51
|
+
const packages = await Promise.all(detectedPackages.map(async (detected) => {
|
|
52
|
+
const relativeRoot = detected.rootPath;
|
|
53
|
+
const id = `${project.id}:${relativeRoot}`;
|
|
54
|
+
const manifestPath = detected.manifestPath === ''
|
|
55
|
+
? undefined
|
|
56
|
+
: path.join(inspection.rootPath, detected.manifestPath);
|
|
57
|
+
return {
|
|
58
|
+
id,
|
|
59
|
+
nodeId: `package:${id}`,
|
|
60
|
+
projectId: project.id,
|
|
61
|
+
rootPath: path.resolve(inspection.rootPath, relativeRoot),
|
|
62
|
+
relativeRoot,
|
|
63
|
+
...(detected.name === undefined ? {} : { name: detected.name }),
|
|
64
|
+
detection: detected.detection,
|
|
65
|
+
declarations: await readDependencyDeclarationsAsync(manifestPath),
|
|
66
|
+
};
|
|
67
|
+
}));
|
|
68
|
+
return { inspection, packages };
|
|
69
|
+
}
|
|
70
|
+
/*** Analyze each package with the first compatible analyzer while preserving mixed-language inputs. */
|
|
71
|
+
async function analyzePackagesAsync(inspected, analyzers, focusPackages, signal) {
|
|
72
|
+
const tasks = inspected.flatMap(({ inspection, packages }) => packages.flatMap((packageContext) => {
|
|
73
|
+
const analyzer = analyzers.find(({ supports }) => supports(packageContext.detection));
|
|
74
|
+
if (analyzer === undefined)
|
|
75
|
+
return [];
|
|
76
|
+
const excludedRoots = packages
|
|
77
|
+
.filter((candidate) => candidate.id !== packageContext.id &&
|
|
78
|
+
candidate.rootPath.startsWith(`${packageContext.rootPath}${path.sep}`))
|
|
79
|
+
.map(({ rootPath }) => rootPath);
|
|
80
|
+
return [
|
|
81
|
+
analyzer.analyzeAsync({
|
|
82
|
+
package: packageContext,
|
|
83
|
+
inspection,
|
|
84
|
+
focusPackages,
|
|
85
|
+
excludedRoots,
|
|
86
|
+
...(signal === undefined ? {} : { signal }),
|
|
87
|
+
}),
|
|
88
|
+
];
|
|
89
|
+
}));
|
|
90
|
+
if (tasks.length === 0) {
|
|
91
|
+
throw new Error('No dependency graph analyzer supports the supplied projects.');
|
|
92
|
+
}
|
|
93
|
+
return Promise.all(tasks);
|
|
94
|
+
}
|
|
95
|
+
/*** Build a unique package-name map for focus routing across repositories and workspaces. */
|
|
96
|
+
function createFocusPackageMap(packages) {
|
|
97
|
+
const named = packages.filter((packageContext) => packageContext.name !== undefined);
|
|
98
|
+
const duplicates = named.filter((item, index) => named.findIndex(({ name }) => name === item.name) !== index);
|
|
99
|
+
if (duplicates.length > 0) {
|
|
100
|
+
throw new Error(`Duplicate focus package name: ${duplicates[0]?.name ?? 'unknown'}.`);
|
|
101
|
+
}
|
|
102
|
+
return new Map(named.map(({ name, nodeId }) => [name, nodeId]));
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=createDependencyGraphFromInspectionsAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDependencyGraphFromInspectionsAsync.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAW/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,wDAAwD,CAAC;AACpG,OAAO,EAAE,6BAA6B,EAAE,MAAM,8DAA8D,CAAC;AAC7G,OAAO,EAAE,2BAA2B,EAAE,MAAM,0DAA0D,CAAC;AACvG,OAAO,EAAE,6BAA6B,EAAE,MAAM,8DAA8D,CAAC;AAC7G,OAAO,EAAE,6BAA6B,EAAE,MAAM,8DAA8D,CAAC;AAC7G,OAAO,EAAE,iCAAiC,EAAE,MAAM,s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;IACD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import path from 'node:path';\n\nimport { createGraph } from '@ankhorage/graph';\nimport type { InspectedPackage, ProjectInspection } from '@ankhorage/project-detector/types';\n\nimport type {\n CreateDependencyGraphFromInspectionsInput,\n DependencyGraph,\n DependencyGraphAnalyzer,\n DependencyGraphFragment,\n DependencyGraphInspectionProjectInput,\n DependencyGraphPackage,\n} from '../../../types/dependencyGraph.js';\nimport { cppDependencyGraphAnalyzer } from '../adapters/outbound/cpp/cppDependencyGraphAnalyzer.js';\nimport { delphiDependencyGraphAnalyzer } from '../adapters/outbound/delphi/delphiDependencyGraphAnalyzer.js';\nimport { javaDependencyGraphAnalyzer } from '../adapters/outbound/java/javaDependencyGraphAnalyzer.js';\nimport { kotlinDependencyGraphAnalyzer } from '../adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.js';\nimport { pythonDependencyGraphAnalyzer } from '../adapters/outbound/python/pythonDependencyGraphAnalyzer.js';\nimport { typescriptDependencyGraphAnalyzer } from '../adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js';\nimport { createFocusPackageNode } from '../domain/createFocusPackageNode.js';\nimport { readDependencyDeclarationsAsync } from '../domain/readDependencyDeclarationsAsync.js';\nimport { assertDependencyGraphProjectIds } from './assertDependencyGraphProjectIds.js';\n\n/***\n * Build one canonical dependency graph from already-inspected projects without rescanning them.\n */\nexport async function createDependencyGraphFromInspectionsAsync(\n input: CreateDependencyGraphFromInspectionsInput,\n): Promise<DependencyGraph> {\n assertDependencyGraphProjectIds(input.projects);\n const analyzers = input.analyzers ?? [\n typescriptDependencyGraphAnalyzer,\n cppDependencyGraphAnalyzer,\n delphiDependencyGraphAnalyzer,\n javaDependencyGraphAnalyzer,\n kotlinDependencyGraphAnalyzer,\n pythonDependencyGraphAnalyzer,\n ];\n const inspected = await Promise.all(input.projects.map(createInspectedInputAsync));\n const packages = inspected.flatMap(({ packages: projectPackages }) => projectPackages);\n const focusPackages = createFocusPackageMap(packages);\n const fragments = await analyzePackagesAsync(inspected, analyzers, focusPackages, input.signal);\n const nodes = new Map(\n packages.map((packageContext) => {\n const node = createFocusPackageNode(packageContext);\n return [node.id, node] as const;\n }),\n );\n\n for (const node of fragments.flatMap(({ nodes: fragmentNodes }) => fragmentNodes)) {\n if (!nodes.has(node.id)) nodes.set(node.id, node);\n }\n\n const edges = fragments.flatMap(({ edges: fragmentEdges }) => fragmentEdges);\n return createGraph({ nodes: [...nodes.values()], edges });\n}\n\ninterface InspectedInput {\n readonly inspection: ProjectInspection;\n readonly packages: readonly DependencyGraphPackage[];\n}\n\n/*** Normalize one supplied inspection into dependency-analysis package contexts. */\nasync function createInspectedInputAsync(\n project: DependencyGraphInspectionProjectInput,\n): Promise<InspectedInput> {\n const { inspection } = project;\n if (!inspection.complete) {\n throw new Error(\n `Dependency graph inspection is incomplete for \"${project.id}\": ${inspection.diagnostics\n .map(({ message }) => message)\n .join('; ')}`,\n );\n }\n\n const detectedPackages: readonly InspectedPackage[] =\n inspection.packages.length > 0\n ? inspection.packages\n : [{ rootPath: '.', detection: inspection.detection, manifestPath: '' }];\n\n const packages = await Promise.all(\n detectedPackages.map(async (detected) => {\n const relativeRoot = detected.rootPath;\n const id = `${project.id}:${relativeRoot}`;\n const manifestPath =\n detected.manifestPath === ''\n ? undefined\n : path.join(inspection.rootPath, detected.manifestPath);\n\n return {\n id,\n nodeId: `package:${id}`,\n projectId: project.id,\n rootPath: path.resolve(inspection.rootPath, relativeRoot),\n relativeRoot,\n ...(detected.name === undefined ? {} : { name: detected.name }),\n detection: detected.detection,\n declarations: await readDependencyDeclarationsAsync(manifestPath),\n } satisfies DependencyGraphPackage;\n }),\n );\n\n return { inspection, packages };\n}\n\n/*** Analyze each package with the first compatible analyzer while preserving mixed-language inputs. */\nasync function analyzePackagesAsync(\n inspected: readonly InspectedInput[],\n analyzers: readonly DependencyGraphAnalyzer[],\n focusPackages: ReadonlyMap<string, string>,\n signal: AbortSignal | undefined,\n): Promise<readonly DependencyGraphFragment[]> {\n const tasks = inspected.flatMap(({ inspection, packages }) =>\n packages.flatMap((packageContext) => {\n const analyzer = analyzers.find(({ supports }) => supports(packageContext.detection));\n if (analyzer === undefined) return [];\n\n const excludedRoots = packages\n .filter(\n (candidate) =>\n candidate.id !== packageContext.id &&\n candidate.rootPath.startsWith(`${packageContext.rootPath}${path.sep}`),\n )\n .map(({ rootPath }) => rootPath);\n\n return [\n analyzer.analyzeAsync({\n package: packageContext,\n inspection,\n focusPackages,\n excludedRoots,\n ...(signal === undefined ? {} : { signal }),\n }),\n ];\n }),\n );\n\n if (tasks.length === 0) {\n throw new Error('No dependency graph analyzer supports the supplied projects.');\n }\n return Promise.all(tasks);\n}\n\n/*** Build a unique package-name map for focus routing across repositories and workspaces. */\nfunction createFocusPackageMap(\n packages: readonly DependencyGraphPackage[],\n): ReadonlyMap<string, string> {\n const named = packages.filter(\n (packageContext): packageContext is DependencyGraphPackage & { readonly name: string } =>\n packageContext.name !== undefined,\n );\n const duplicates = named.filter(\n (item, index) => named.findIndex(({ name }) => name === item.name) !== index,\n );\n if (duplicates.length > 0) {\n throw new Error(`Duplicate focus package name: ${duplicates[0]?.name ?? 'unknown'}.`);\n }\n return new Map(named.map(({ name, nodeId }) => [name, nodeId]));\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DependencyGraphAnalyzerContext } from '../../../types/dependencyGraph.js';
|
|
2
|
+
/*** Select source files from Project Detector's pruned scan without traversing the filesystem again. */
|
|
3
|
+
export declare function collectInspectedSourceFiles(context: DependencyGraphAnalyzerContext, sourceRoots: readonly string[], isSourceFile: (file: string) => boolean, ignoredDirectoryNames: readonly string[]): readonly string[];
|
|
4
|
+
//# sourceMappingURL=collectInspectedSourceFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectInspectedSourceFiles.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/utils/collectInspectedSourceFiles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAExF,wGAAwG;AACxG,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,8BAA8B,EACvC,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,EACvC,qBAAqB,EAAE,SAAS,MAAM,EAAE,GACvC,SAAS,MAAM,EAAE,CAmBnB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { toPortablePath } from '@ankhorage/utility/node/path';
|
|
3
|
+
/*** Select source files from Project Detector's pruned scan without traversing the filesystem again. */
|
|
4
|
+
export function collectInspectedSourceFiles(context, sourceRoots, isSourceFile, ignoredDirectoryNames) {
|
|
5
|
+
const ignored = new Set(ignoredDirectoryNames);
|
|
6
|
+
return context.inspection.files
|
|
7
|
+
.flatMap((file) => {
|
|
8
|
+
context.signal?.throwIfAborted();
|
|
9
|
+
const absolute = path.resolve(context.inspection.rootPath, ...file.split('/'));
|
|
10
|
+
const relative = path.relative(context.package.rootPath, absolute);
|
|
11
|
+
if (relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const portable = toPortablePath(relative);
|
|
15
|
+
if (!isSourceFile(portable))
|
|
16
|
+
return [];
|
|
17
|
+
if (context.excludedRoots.some((root) => absolute.startsWith(`${root}${path.sep}`))) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
if (!sourceRoots.some((root) => isWithinSourceRoot(portable, root, ignored)))
|
|
21
|
+
return [];
|
|
22
|
+
return [absolute];
|
|
23
|
+
})
|
|
24
|
+
.sort();
|
|
25
|
+
}
|
|
26
|
+
/*** Apply an analyzer's source-root and ignored-directory rules to one inspected file. */
|
|
27
|
+
function isWithinSourceRoot(relative, sourceRoot, ignored) {
|
|
28
|
+
if (sourceRoot !== '.' && !relative.startsWith(`${sourceRoot}/`))
|
|
29
|
+
return false;
|
|
30
|
+
const withinRoot = sourceRoot === '.' ? relative : relative.slice(sourceRoot.length + 1);
|
|
31
|
+
return !withinRoot
|
|
32
|
+
.split('/')
|
|
33
|
+
.slice(0, -1)
|
|
34
|
+
.some((directory) => ignored.has(directory));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=collectInspectedSourceFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectInspectedSourceFiles.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/utils/collectInspectedSourceFiles.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAI9D,wGAAwG;AACxG,MAAM,UAAU,2BAA2B,CACzC,OAAuC,EACvC,WAA8B,EAC9B,YAAuC,EACvC,qBAAwC;IAExC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,qBAAqB,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC,UAAU,CAAC,KAAK;SAC5B,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/E,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACnE,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,CAAC,UAAU,CA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C,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import path from 'node:path';\n\nimport { toPortablePath } from '@ankhorage/utility/node/path';\n\nimport type { DependencyGraphAnalyzerContext } from '../../../types/dependencyGraph.js';\n\n/*** Select source files from Project Detector's pruned scan without traversing the filesystem again. */\nexport function collectInspectedSourceFiles(\n context: DependencyGraphAnalyzerContext,\n sourceRoots: readonly string[],\n isSourceFile: (file: string) => boolean,\n ignoredDirectoryNames: readonly string[],\n): readonly string[] {\n const ignored = new Set(ignoredDirectoryNames);\n return context.inspection.files\n .flatMap((file) => {\n context.signal?.throwIfAborted();\n const absolute = path.resolve(context.inspection.rootPath, ...file.split('/'));\n const relative = path.relative(context.package.rootPath, absolute);\n if (relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {\n return [];\n }\n const portable = toPortablePath(relative);\n if (!isSourceFile(portable)) return [];\n if (context.excludedRoots.some((root) => absolute.startsWith(`${root}${path.sep}`))) {\n return [];\n }\n if (!sourceRoots.some((root) => isWithinSourceRoot(portable, root, ignored))) return [];\n return [absolute];\n })\n .sort();\n}\n\n/*** Apply an analyzer's source-root and ignored-directory rules to one inspected file. */\nfunction isWithinSourceRoot(\n relative: string,\n sourceRoot: string,\n ignored: ReadonlySet<string>,\n): boolean {\n if (sourceRoot !== '.' && !relative.startsWith(`${sourceRoot}/`)) return false;\n const withinRoot = sourceRoot === '.' ? relative : relative.slice(sourceRoot.length + 1);\n return !withinRoot\n .split('/')\n .slice(0, -1)\n .some((directory) => ignored.has(directory));\n}\n"]}
|
|
@@ -35,6 +35,10 @@ export interface DependencyGraphProjectInput {
|
|
|
35
35
|
readonly id: string;
|
|
36
36
|
readonly rootPath: string;
|
|
37
37
|
}
|
|
38
|
+
export interface DependencyGraphInspectionProjectInput {
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly inspection: ProjectInspection;
|
|
41
|
+
}
|
|
38
42
|
export interface DependencyGraphPackage {
|
|
39
43
|
readonly id: string;
|
|
40
44
|
readonly nodeId: string;
|
|
@@ -66,4 +70,9 @@ export interface CreateDependencyGraphInput {
|
|
|
66
70
|
readonly analyzers?: readonly DependencyGraphAnalyzer[];
|
|
67
71
|
readonly signal?: AbortSignal;
|
|
68
72
|
}
|
|
73
|
+
export interface CreateDependencyGraphFromInspectionsInput {
|
|
74
|
+
readonly projects: readonly DependencyGraphInspectionProjectInput[];
|
|
75
|
+
readonly analyzers?: readonly DependencyGraphAnalyzer[];
|
|
76
|
+
readonly signal?: AbortSignal;
|
|
77
|
+
}
|
|
69
78
|
//# sourceMappingURL=dependencyGraph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencyGraph.d.ts","sourceRoot":"","sources":["../../src/types/dependencyGraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE7F,MAAM,MAAM,4BAA4B,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC9E,MAAM,MAAM,iCAAiC,GAAG,4BAA4B,GAAG,OAAO,CAAC;AACvF,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,SAAS,CAAC;AACtD,MAAM,MAAM,yBAAyB,GACnC,YAAY,GAAG,eAAe,GAAG,oBAAoB,GAAG,gBAAgB,CAAC;AAE3E,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,yBAAyB,CAAC;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,iCAAiC,CAAC;IAC3D,QAAQ,CAAC,YAAY,EAAE,SAAS,q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,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,gBAAgB,KAAK,OAAO,CAAC;IAC5D,QAAQ,CAAC,YAAY,EAAE,CACrB,OAAO,EAAE,8BAA8B,KACpC,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,QAAQ,EAAE,SAAS,2BAA2B,EAAE,CAAC;IAC1D,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,uBAAuB,EAAE,CAAC;IACxD,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,WAAW,yCAAyC;IACxD,QAAQ,CAAC,QAAQ,EAAE,SAAS,qCAAqC,EAAE,CAAC;IACpE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,uBAAuB,EAAE,CAAC;IACxD,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencyGraph.js","sourceRoot":"","sources":["../../src/types/dependencyGraph.ts"],"names":[],"mappings":"","sourcesContent":["import type { Graph, GraphEdge, GraphNode } from '@ankhorage/graph';\nimport type { ProjectDetection, ProjectInspection } from '@ankhorage/project-detector/types';\n\nexport type DependencyNodeClassification = 'intrinsic' | 'unknown' | 'vendor';\nexport type DependencyReferenceClassification = DependencyNodeClassification | 'focus';\nexport type DependencyNodeKind = 'module' | 'package';\nexport type DependencyDeclarationKind =\n 'dependency' | 'devDependency' | 'optionalDependency' | 'peerDependency';\n\nexport interface DependencyDeclaration {\n readonly kind: DependencyDeclarationKind;\n readonly range: string;\n}\n\nexport interface DependencyImportEvidence {\n readonly sourceFile: string;\n readonly specifier: string;\n readonly classification: DependencyReferenceClassification;\n readonly declarations: readonly DependencyDeclaration[];\n}\n\nexport interface DependencyGraphNodeData {\n readonly kind: DependencyNodeKind;\n readonly classification: DependencyNodeClassification;\n readonly focus: boolean;\n readonly label: string;\n readonly projectId?: string;\n readonly packageName?: string;\n readonly path?: string;\n readonly parentPath?: string;\n}\n\nexport interface DependencyGraphEdgeData {\n readonly kind: 'import';\n readonly analyzerId: string;\n readonly weight: number;\n readonly evidence: readonly DependencyImportEvidence[];\n}\n\nexport type DependencyGraph = Graph<DependencyGraphNodeData, DependencyGraphEdgeData>;\n\nexport interface DependencyGraphProjectInput {\n readonly id: string;\n readonly rootPath: string;\n}\n\nexport interface DependencyGraphPackage {\n readonly id: string;\n readonly nodeId: string;\n readonly projectId: string;\n readonly rootPath: string;\n readonly relativeRoot: string;\n readonly name?: string;\n readonly detection: ProjectDetection;\n readonly declarations: Readonly<Record<string, readonly DependencyDeclaration[]>>;\n}\n\nexport interface DependencyGraphFragment {\n readonly nodes: readonly GraphNode<DependencyGraphNodeData>[];\n readonly edges: readonly GraphEdge<DependencyGraphEdgeData>[];\n}\n\nexport interface DependencyGraphAnalyzerContext {\n readonly package: DependencyGraphPackage;\n readonly inspection: ProjectInspection;\n readonly focusPackages: ReadonlyMap<string, string>;\n readonly excludedRoots: readonly string[];\n readonly signal?: AbortSignal;\n}\n\nexport interface DependencyGraphAnalyzer {\n readonly id: string;\n readonly supports: (detection: ProjectDetection) => boolean;\n readonly analyzeAsync: (\n context: DependencyGraphAnalyzerContext,\n ) => Promise<DependencyGraphFragment>;\n}\n\nexport interface CreateDependencyGraphInput {\n readonly projects: readonly DependencyGraphProjectInput[];\n readonly analyzers?: readonly DependencyGraphAnalyzer[];\n readonly signal?: AbortSignal;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dependencyGraph.js","sourceRoot":"","sources":["../../src/types/dependencyGraph.ts"],"names":[],"mappings":"","sourcesContent":["import type { Graph, GraphEdge, GraphNode } from '@ankhorage/graph';\nimport type { ProjectDetection, ProjectInspection } from '@ankhorage/project-detector/types';\n\nexport type DependencyNodeClassification = 'intrinsic' | 'unknown' | 'vendor';\nexport type DependencyReferenceClassification = DependencyNodeClassification | 'focus';\nexport type DependencyNodeKind = 'module' | 'package';\nexport type DependencyDeclarationKind =\n 'dependency' | 'devDependency' | 'optionalDependency' | 'peerDependency';\n\nexport interface DependencyDeclaration {\n readonly kind: DependencyDeclarationKind;\n readonly range: string;\n}\n\nexport interface DependencyImportEvidence {\n readonly sourceFile: string;\n readonly specifier: string;\n readonly classification: DependencyReferenceClassification;\n readonly declarations: readonly DependencyDeclaration[];\n}\n\nexport interface DependencyGraphNodeData {\n readonly kind: DependencyNodeKind;\n readonly classification: DependencyNodeClassification;\n readonly focus: boolean;\n readonly label: string;\n readonly projectId?: string;\n readonly packageName?: string;\n readonly path?: string;\n readonly parentPath?: string;\n}\n\nexport interface DependencyGraphEdgeData {\n readonly kind: 'import';\n readonly analyzerId: string;\n readonly weight: number;\n readonly evidence: readonly DependencyImportEvidence[];\n}\n\nexport type DependencyGraph = Graph<DependencyGraphNodeData, DependencyGraphEdgeData>;\n\nexport interface DependencyGraphProjectInput {\n readonly id: string;\n readonly rootPath: string;\n}\n\nexport interface DependencyGraphInspectionProjectInput {\n readonly id: string;\n readonly inspection: ProjectInspection;\n}\n\nexport interface DependencyGraphPackage {\n readonly id: string;\n readonly nodeId: string;\n readonly projectId: string;\n readonly rootPath: string;\n readonly relativeRoot: string;\n readonly name?: string;\n readonly detection: ProjectDetection;\n readonly declarations: Readonly<Record<string, readonly DependencyDeclaration[]>>;\n}\n\nexport interface DependencyGraphFragment {\n readonly nodes: readonly GraphNode<DependencyGraphNodeData>[];\n readonly edges: readonly GraphEdge<DependencyGraphEdgeData>[];\n}\n\nexport interface DependencyGraphAnalyzerContext {\n readonly package: DependencyGraphPackage;\n readonly inspection: ProjectInspection;\n readonly focusPackages: ReadonlyMap<string, string>;\n readonly excludedRoots: readonly string[];\n readonly signal?: AbortSignal;\n}\n\nexport interface DependencyGraphAnalyzer {\n readonly id: string;\n readonly supports: (detection: ProjectDetection) => boolean;\n readonly analyzeAsync: (\n context: DependencyGraphAnalyzerContext,\n ) => Promise<DependencyGraphFragment>;\n}\n\nexport interface CreateDependencyGraphInput {\n readonly projects: readonly DependencyGraphProjectInput[];\n readonly analyzers?: readonly DependencyGraphAnalyzer[];\n readonly signal?: AbortSignal;\n}\n\nexport interface CreateDependencyGraphFromInspectionsInput {\n readonly projects: readonly DependencyGraphInspectionProjectInput[];\n readonly analyzers?: readonly DependencyGraphAnalyzer[];\n readonly signal?: AbortSignal;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/dependency-graph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Project-aware dependency analysis that produces canonical Ankhorage graphs.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@ankhorage/graph": "^0.1.0",
|
|
60
|
-
"@ankhorage/project-detector": "^0.
|
|
60
|
+
"@ankhorage/project-detector": "^0.3.0",
|
|
61
61
|
"@ankhorage/utility": "^0.8.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/*** Collect deterministic C++ source/header files without following symlinks or nested package roots. */
|
|
2
|
-
export declare function collectCppFilesAsync(rootPath: string, sourceRoots: readonly string[], excludedRoots: readonly string[], signal: AbortSignal | undefined): Promise<readonly string[]>;
|
|
3
|
-
//# sourceMappingURL=collectCppFilesAsync.d.ts.map
|
package/dist/features/dependency-analysis/adapters/outbound/cpp/collectCppFilesAsync.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collectCppFilesAsync.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/cpp/collectCppFilesAsync.ts"],"names":[],"mappings":"AAGA,yGAAyG;AACzG,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAW5B"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { opendir } from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
/*** Collect deterministic C++ source/header files without following symlinks or nested package roots. */
|
|
4
|
-
export async function collectCppFilesAsync(rootPath, sourceRoots, excludedRoots, signal) {
|
|
5
|
-
const files = await Promise.all(sourceRoots.map((sourceRoot) => visitDirectoryAsync(sourceRoot === '.' ? rootPath : path.resolve(rootPath, sourceRoot), new Set(excludedRoots), signal)));
|
|
6
|
-
return [...new Set(files.flat())].sort();
|
|
7
|
-
}
|
|
8
|
-
const excludedDirectoryNames = new Set(['.git', 'build', 'coverage', 'dist', 'out']);
|
|
9
|
-
const cppExtensions = ['.cpp', '.cc', '.cxx', '.h', '.hpp', '.hxx'];
|
|
10
|
-
/*** Recursively collect supported C++ files from one source root. */
|
|
11
|
-
async function visitDirectoryAsync(directory, excludedRoots, signal) {
|
|
12
|
-
signal?.throwIfAborted();
|
|
13
|
-
try {
|
|
14
|
-
const handle = await opendir(directory);
|
|
15
|
-
const files = [];
|
|
16
|
-
for await (const entry of handle) {
|
|
17
|
-
signal?.throwIfAborted();
|
|
18
|
-
const target = path.join(directory, entry.name);
|
|
19
|
-
if (entry.isSymbolicLink())
|
|
20
|
-
continue;
|
|
21
|
-
if (entry.isDirectory()) {
|
|
22
|
-
if (excludedDirectoryNames.has(entry.name) || excludedRoots.has(target))
|
|
23
|
-
continue;
|
|
24
|
-
files.push(...(await visitDirectoryAsync(target, excludedRoots, signal)));
|
|
25
|
-
}
|
|
26
|
-
else if (entry.isFile() &&
|
|
27
|
-
cppExtensions.some((extension) => entry.name.endsWith(extension))) {
|
|
28
|
-
files.push(target);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return files;
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
if (isMissingPathError(error))
|
|
35
|
-
return [];
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/*** Treat absent optional detector source roots as empty instead of analysis failures. */
|
|
40
|
-
function isMissingPathError(error) {
|
|
41
|
-
return error instanceof Error && 'code' in error && error.code === 'ENOENT';
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=collectCppFilesAsync.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collectCppFilesAsync.js","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/cpp/collectCppFilesAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,yGAAyG;AACzG,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAgB,EAChB,WAA8B,EAC9B,aAAgC,EAChC,MAA+B;IAE/B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAC7B,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAC7B,mBAAmB,CACjB,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,EAClE,IAAI,GAAG,CAAC,aAAa,CAAC,EACtB,MAAM,CACP,CACF,CACF,CAAC;IACF,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CA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CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,kBAAkB,CAAC,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QACzC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,0FAA0F;AAC1F,SAAS,kBAAkB,CAAC,KAAc;IACxC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9E,CAAC","sourcesContent":["import { opendir } from 'node:fs/promises';\nimport path from 'node:path';\n\n/*** Collect deterministic C++ source/header files without following symlinks or nested package roots. */\nexport async function collectCppFilesAsync(\n rootPath: string,\n sourceRoots: readonly string[],\n excludedRoots: readonly string[],\n signal: AbortSignal | undefined,\n): Promise<readonly string[]> {\n const files = await Promise.all(\n sourceRoots.map((sourceRoot) =>\n visitDirectoryAsync(\n sourceRoot === '.' ? rootPath : path.resolve(rootPath, sourceRoot),\n new Set(excludedRoots),\n signal,\n ),\n ),\n );\n return [...new Set(files.flat())].sort();\n}\n\nconst excludedDirectoryNames = new Set(['.git', 'build', 'coverage', 'dist', 'out']);\n\nconst cppExtensions = ['.cpp', '.cc', '.cxx', '.h', '.hpp', '.hxx'];\n\n/*** Recursively collect supported C++ files from one source root. */\nasync function visitDirectoryAsync(\n directory: string,\n excludedRoots: ReadonlySet<string>,\n signal: AbortSignal | undefined,\n): Promise<readonly string[]> {\n signal?.throwIfAborted();\n try {\n const handle = await opendir(directory);\n const files: string[] = [];\n for await (const entry of handle) {\n signal?.throwIfAborted();\n const target = path.join(directory, entry.name);\n if (entry.isSymbolicLink()) continue;\n if (entry.isDirectory()) {\n if (excludedDirectoryNames.has(entry.name) || excludedRoots.has(target)) continue;\n files.push(...(await visitDirectoryAsync(target, excludedRoots, signal)));\n } else if (\n entry.isFile() &&\n cppExtensions.some((extension) => entry.name.endsWith(extension))\n ) {\n files.push(target);\n }\n }\n return files;\n } catch (error) {\n if (isMissingPathError(error)) return [];\n throw error;\n }\n}\n\n/*** Treat absent optional detector source roots as empty instead of analysis failures. */\nfunction isMissingPathError(error: unknown): boolean {\n return error instanceof Error && 'code' in error && error.code === 'ENOENT';\n}\n"]}
|
package/dist/features/dependency-analysis/adapters/outbound/delphi/collectDelphiFilesAsync.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/*** Collect deterministic Delphi source files without following symlinks or nested package roots. */
|
|
2
|
-
export declare function collectDelphiFilesAsync(rootPath: string, sourceRoots: readonly string[], excludedRoots: readonly string[], signal: AbortSignal | undefined): Promise<readonly string[]>;
|
|
3
|
-
//# sourceMappingURL=collectDelphiFilesAsync.d.ts.map
|
package/dist/features/dependency-analysis/adapters/outbound/delphi/collectDelphiFilesAsync.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collectDelphiFilesAsync.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/delphi/collectDelphiFilesAsync.ts"],"names":[],"mappings":"AAGA,qGAAqG;AACrG,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAW5B"}
|
package/dist/features/dependency-analysis/adapters/outbound/delphi/collectDelphiFilesAsync.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { opendir } from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
/*** Collect deterministic Delphi source files without following symlinks or nested package roots. */
|
|
4
|
-
export async function collectDelphiFilesAsync(rootPath, sourceRoots, excludedRoots, signal) {
|
|
5
|
-
const files = await Promise.all(sourceRoots.map((sourceRoot) => visitDirectoryAsync(sourceRoot === '.' ? rootPath : path.resolve(rootPath, sourceRoot), new Set(excludedRoots), signal)));
|
|
6
|
-
return [...new Set(files.flat())].sort();
|
|
7
|
-
}
|
|
8
|
-
const excludedDirectoryNames = new Set(['.git', 'build', 'coverage', 'dist', 'lib']);
|
|
9
|
-
const delphiExtensions = ['.pas', '.pp', '.dpr'];
|
|
10
|
-
/*** Recursively collect supported Delphi files from one source root. */
|
|
11
|
-
async function visitDirectoryAsync(directory, excludedRoots, signal) {
|
|
12
|
-
signal?.throwIfAborted();
|
|
13
|
-
try {
|
|
14
|
-
const handle = await opendir(directory);
|
|
15
|
-
const files = [];
|
|
16
|
-
for await (const entry of handle) {
|
|
17
|
-
signal?.throwIfAborted();
|
|
18
|
-
const target = path.join(directory, entry.name);
|
|
19
|
-
if (entry.isSymbolicLink())
|
|
20
|
-
continue;
|
|
21
|
-
if (entry.isDirectory()) {
|
|
22
|
-
if (excludedDirectoryNames.has(entry.name) || excludedRoots.has(target))
|
|
23
|
-
continue;
|
|
24
|
-
files.push(...(await visitDirectoryAsync(target, excludedRoots, signal)));
|
|
25
|
-
}
|
|
26
|
-
else if (entry.isFile() &&
|
|
27
|
-
delphiExtensions.some((extension) => entry.name.toLowerCase().endsWith(extension))) {
|
|
28
|
-
files.push(target);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return files;
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
if (isMissingPathError(error))
|
|
35
|
-
return [];
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/*** Treat absent optional detector source roots as empty instead of analysis failures. */
|
|
40
|
-
function isMissingPathError(error) {
|
|
41
|
-
return error instanceof Error && 'code' in error && error.code === 'ENOENT';
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=collectDelphiFilesAsync.js.map
|
package/dist/features/dependency-analysis/adapters/outbound/delphi/collectDelphiFilesAsync.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collectDelphiFilesAsync.js","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/delphi/collectDelphiFilesAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,qGAAqG;AACrG,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,QAAgB,EAChB,WAA8B,EAC9B,aAAgC,EAChC,MAA+B;IAE/B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAC7B,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAC7B,mBAAmB,CACjB,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,EAClE,IAAI,GAAG,CAAC,aAAa,CAAC,EACtB,MAAM,CACP,CACF,CACF,CAAC;IACF,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC3C,CAAC;AAED,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAErF,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAEjD,wEAAwE;AACxE,KAAK,UAAU,mBAAmB,CAChC,SAAiB,EACjB,aAAkC,EAClC,MAA+B;IAE/B,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;QACxC,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YACjC,MAAM,EAAE,cAAc,EAAE,CAAC;YACzB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YAChD,IAAI,KAAK,CAAC,cAAc,EAAE;gBAAE,SAAS;YACrC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;gBACxB,IAAI,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC;oBAAE,SAAS;gBAClF,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,mBAAmB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;YAC5E,CAAC;iBAAM,IACL,KAAK,CAAC,MAAM,EAAE;gBACd,gBAAgB,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAClF,CAAC;gBACD,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,kBAAkB,CAAC,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QACzC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,0FAA0F;AAC1F,SAAS,kBAAkB,CAAC,KAAc;IACxC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9E,CAAC","sourcesContent":["import { opendir } from 'node:fs/promises';\nimport path from 'node:path';\n\n/*** Collect deterministic Delphi source files without following symlinks or nested package roots. */\nexport async function collectDelphiFilesAsync(\n rootPath: string,\n sourceRoots: readonly string[],\n excludedRoots: readonly string[],\n signal: AbortSignal | undefined,\n): Promise<readonly string[]> {\n const files = await Promise.all(\n sourceRoots.map((sourceRoot) =>\n visitDirectoryAsync(\n sourceRoot === '.' ? rootPath : path.resolve(rootPath, sourceRoot),\n new Set(excludedRoots),\n signal,\n ),\n ),\n );\n return [...new Set(files.flat())].sort();\n}\n\nconst excludedDirectoryNames = new Set(['.git', 'build', 'coverage', 'dist', 'lib']);\n\nconst delphiExtensions = ['.pas', '.pp', '.dpr'];\n\n/*** Recursively collect supported Delphi files from one source root. */\nasync function visitDirectoryAsync(\n directory: string,\n excludedRoots: ReadonlySet<string>,\n signal: AbortSignal | undefined,\n): Promise<readonly string[]> {\n signal?.throwIfAborted();\n try {\n const handle = await opendir(directory);\n const files: string[] = [];\n for await (const entry of handle) {\n signal?.throwIfAborted();\n const target = path.join(directory, entry.name);\n if (entry.isSymbolicLink()) continue;\n if (entry.isDirectory()) {\n if (excludedDirectoryNames.has(entry.name) || excludedRoots.has(target)) continue;\n files.push(...(await visitDirectoryAsync(target, excludedRoots, signal)));\n } else if (\n entry.isFile() &&\n delphiExtensions.some((extension) => entry.name.toLowerCase().endsWith(extension))\n ) {\n files.push(target);\n }\n }\n return files;\n } catch (error) {\n if (isMissingPathError(error)) return [];\n throw error;\n }\n}\n\n/*** Treat absent optional detector source roots as empty instead of analysis failures. */\nfunction isMissingPathError(error: unknown): boolean {\n return error instanceof Error && 'code' in error && error.code === 'ENOENT';\n}\n"]}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/*** Collect deterministic Java source files without following symlinks or nested package roots. */
|
|
2
|
-
export declare function collectJavaFilesAsync(rootPath: string, sourceRoots: readonly string[], excludedRoots: readonly string[], signal: AbortSignal | undefined): Promise<readonly string[]>;
|
|
3
|
-
//# sourceMappingURL=collectJavaFilesAsync.d.ts.map
|
package/dist/features/dependency-analysis/adapters/outbound/java/collectJavaFilesAsync.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collectJavaFilesAsync.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/java/collectJavaFilesAsync.ts"],"names":[],"mappings":"AAGA,mGAAmG;AACnG,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAW5B"}
|