@ankhorage/dependency-graph 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +5 -3
- package/dist/features/source-graph/application/projectSourceFeatures.js +8 -1
- package/dist/features/source-graph/application/projectSourceFeatures.js.map +1 -1
- package/dist/features/source-graph/composition/createProjectAnalysisSnapshotAsync.d.ts.map +1 -1
- package/dist/features/source-graph/composition/createProjectAnalysisSnapshotAsync.js +51 -6
- package/dist/features/source-graph/composition/createProjectAnalysisSnapshotAsync.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ankhorage/dependency-graph
|
|
2
2
|
|
|
3
|
+
## 1.5.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e8398e3: Exclude incidental package-cache trees from project analysis snapshots.
|
|
8
|
+
|
|
9
|
+
## 1.5.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 09f66ba: Reject non-declaration source graph nodes as feature evidence.
|
|
14
|
+
|
|
3
15
|
## 1.5.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# @ankhorage/dependency-graph
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Project-aware dependency analysis that produces canonical Ankhorage graphs.
|
|
9
9
|
|
|
@@ -16,16 +16,18 @@ Project-aware dependency analysis that produces canonical Ankhorage graphs.
|
|
|
16
16
|
- [Module relationships](././paradox/diagrams/module-relationships.mmd)
|
|
17
17
|
- [Export graph](././paradox/diagrams/export-graph.mmd)
|
|
18
18
|
- [createProjectAnalysisSnapshotAsync sequence](././paradox/diagrams/sequences/create-project-analysis-snapshot-async.mmd)
|
|
19
|
+
- [createSourceFeatureProjectionIndex sequence](././paradox/diagrams/sequences/create-source-feature-projection-index.mmd)
|
|
19
20
|
- [createSourceGraph sequence](././paradox/diagrams/sequences/create-source-graph.mmd)
|
|
20
21
|
- [createSourceGraphIndex sequence](././paradox/diagrams/sequences/create-source-graph-index.mmd)
|
|
21
22
|
- [createSourceRollupIndex sequence](././paradox/diagrams/sequences/create-source-rollup-index.mmd)
|
|
22
|
-
- [deserializeProjectAnalysisSnapshot sequence](././paradox/diagrams/sequences/deserialize-project-analysis-snapshot.mmd)
|
|
23
23
|
- [deserializeSourceGraph sequence](././paradox/diagrams/sequences/deserialize-source-graph.mmd)
|
|
24
24
|
- [findRolledUpDependency sequence](././paradox/diagrams/sequences/find-rolled-up-dependency.mmd)
|
|
25
25
|
- [findSourceRelationsBetween sequence](././paradox/diagrams/sequences/find-source-relations-between.mmd)
|
|
26
26
|
- [incomingSourceRelations sequence](././paradox/diagrams/sequences/incoming-source-relations.mmd)
|
|
27
|
+
- [listSourceFeatureMembers sequence](././paradox/diagrams/sequences/list-source-feature-members.mmd)
|
|
28
|
+
- [listSourceFeatures sequence](././paradox/diagrams/sequences/list-source-features.mmd)
|
|
27
29
|
- [outgoingSourceRelations sequence](././paradox/diagrams/sequences/outgoing-source-relations.mmd)
|
|
30
|
+
- [projectSourceFeatures sequence](././paradox/diagrams/sequences/project-source-features.mmd)
|
|
28
31
|
- [rollupSourceRelations sequence](././paradox/diagrams/sequences/rollup-source-relations.mmd)
|
|
29
|
-
- [serializeProjectAnalysisSnapshot sequence](././paradox/diagrams/sequences/serialize-project-analysis-snapshot.mmd)
|
|
30
32
|
- [serializeSourceGraph sequence](././paradox/diagrams/sequences/serialize-source-graph.mmd)
|
|
31
33
|
- [summarizeSourceNode sequence](././paradox/diagrams/sequences/summarize-source-node.mmd)
|
|
@@ -16,7 +16,10 @@ export function projectSourceFeatures(sourceGraph) {
|
|
|
16
16
|
}
|
|
17
17
|
/*** Accept only the published one-token feature tag contract from TypeScript declarations. */
|
|
18
18
|
function featureEvidence(data, analyzerId) {
|
|
19
|
-
if (analyzerId !== 'typescript' ||
|
|
19
|
+
if (analyzerId !== 'typescript' ||
|
|
20
|
+
!isDeclaration(data.kind) ||
|
|
21
|
+
data.filePath === undefined ||
|
|
22
|
+
data.location === undefined)
|
|
20
23
|
return {};
|
|
21
24
|
const tags = data.documentation?.tags.feature ?? [];
|
|
22
25
|
if (tags.length === 0)
|
|
@@ -48,6 +51,10 @@ function featureEvidence(data, analyzerId) {
|
|
|
48
51
|
},
|
|
49
52
|
};
|
|
50
53
|
}
|
|
54
|
+
/*** Accept feature metadata only from canonical declaration nodes, never graph containers. */
|
|
55
|
+
function isDeclaration(kind) {
|
|
56
|
+
return kind !== 'project' && kind !== 'package' && kind !== 'directory' && kind !== 'file';
|
|
57
|
+
}
|
|
51
58
|
/*** Build deterministic project-scoped features without treating absent tags as negative evidence. */
|
|
52
59
|
function featuresFromMembers(members) {
|
|
53
60
|
const grouped = new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projectSourceFeatures.js","sourceRoot":"","sources":["../../../../src/features/source-graph/application/projectSourceFeatures.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,mGAAmG;AACnG,MAAM,UAAU,qBAAqB,CAAC,WAAwB;IAC5D,MAAM,eAAe,GAAG,IAAI,GAAG,CAC7B,WAAW,CAAC,KAAK,CAAC,KAAK;SACpB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC;SACzE,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAChF,CAAC;IACF,MAAM,QAAQ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SAAS,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC,CAC9F,CAAC;AACN,CAAC;AAED,kFAAkF;AAClF,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,6BAA6B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC;AAED,qGAAqG;AACrG,SAAS,sBAAsB,CAAC,EAAU;IACxC,OAAO,kBAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACpD,CAAC;AAED,qFAAqF;AACrF,SAAS,OAAO,CAAC,SAAiB,EAAE,QAA4B;IAC9D,OAAO,GAAG,SAAS,SAAS,QAAQ,IAAI,EAAE,EAAE,CAAC;AAC/C,CAAC;AAED,sFAAsF;AACtF,SAAS,iBAAiB,CAAC,IAA6B,EAAE,KAA8B;IACtF,OAAO,WAAW,CAChB,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,OAAO,EAAE,EACtC,GAAG,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,OAAO,EAAE,CACzC,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,SAAS,WAAW,CAAC,IAAY,EAAE,KAAa;IAC9C,IAAI,IAAI,GAAG,KAAK;QAAE,OAAO,CAAC,CAAC,CAAC;IAC5B,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import type {\n SourceFeature,\n SourceFeatureCapability,\n SourceFeatureDiagnostic,\n SourceFeatureProjection,\n SourceGraph,\n SourceNodeData,\n} from '../../../types/sourceGraph.js';\nimport { sourceSemanticPath } from '../domain/sourceSemanticPath.js';\n\n/*** Project only explicit TypeScript `@feature <name>` declaration evidence from a SourceGraph. */\nexport function projectSourceFeatures(sourceGraph: SourceGraph): SourceFeatureProjection {\n const analyzersByFile = new Map(\n sourceGraph.graph.nodes\n .filter(({ data }) => data.kind === 'file' && data.filePath !== undefined)\n .map(({ data }) => [fileKey(data.projectId, data.filePath), data.analyzerId]),\n );\n const evidence = sourceGraph.graph.nodes.flatMap(({ data }) =>\n featureEvidence(data, analyzersByFile.get(fileKey(data.projectId, data.filePath))),\n );\n const diagnostics = evidence.flatMap(({ diagnostic }) =>\n diagnostic === undefined ? [] : [diagnostic],\n );\n const members = evidence.flatMap(({ member }) => (member === undefined ? [] : [member]));\n return {\n version: 1,\n capabilities: featureCapabilities(sourceGraph),\n diagnostics: diagnostics.sort(compareDiagnostic),\n features: featuresFromMembers(members),\n };\n}\n\ninterface FeatureEvidence {\n readonly diagnostic?: SourceFeatureDiagnostic;\n readonly member?: {\n readonly featureName: string;\n readonly featureId: string;\n readonly member: SourceFeature['members'][number];\n };\n}\n\n/*** Accept only the published one-token feature tag contract from TypeScript declarations. */\nfunction featureEvidence(data: SourceNodeData, analyzerId: string | undefined): FeatureEvidence {\n if (analyzerId !== 'typescript' || data.filePath === undefined || data.location === undefined)\n return {};\n const tags = data.documentation?.tags.feature ?? [];\n if (tags.length === 0) return {};\n const names = tags.map((tag) => tag.trim());\n const [name] = names;\n if (names.length !== 1 || name === undefined || !isFeatureName(name)) {\n return {\n diagnostic: {\n analyzerId,\n projectId: data.projectId,\n filePath: data.filePath,\n location: data.location,\n semanticPath: data.semanticPath,\n message: 'A TypeScript feature declaration must have exactly one @feature <name> tag.',\n },\n };\n }\n return {\n member: {\n featureName: name,\n featureId: sourceSemanticPath('feature', data.projectId, name),\n member: {\n analyzerId,\n filePath: data.filePath,\n evidence: data.location,\n semanticPath: data.semanticPath,\n },\n },\n };\n}\n\n/*** Build deterministic project-scoped features without treating absent tags as negative evidence. */\nfunction featuresFromMembers(\n members: readonly NonNullable<FeatureEvidence['member']>[],\n): readonly SourceFeature[] {\n const grouped = new Map<\n string,\n {\n readonly id: string;\n readonly name: string;\n readonly projectId: string;\n readonly members: SourceFeature['members'][number][];\n }\n >();\n for (const item of members) {\n const existing = grouped.get(item.featureId);\n if (existing === undefined) {\n grouped.set(item.featureId, {\n id: item.featureId,\n name: item.featureName,\n projectId: projectIdFromFeatureId(item.featureId),\n members: [item.member],\n });\n } else existing.members.push(item.member);\n }\n return [...grouped.values()]\n .map(({ members: groupedMembers, ...feature }) => ({\n ...feature,\n members: [...groupedMembers].sort((left, right) =>\n compareText(left.semanticPath, right.semanticPath),\n ),\n }))\n .sort((left, right) => compareText(left.id, right.id));\n}\n\n/*** Preserve analyzer-level unavailable states instead of guessing feature support from source shape. */\nfunction featureCapabilities(sourceGraph: SourceGraph): readonly SourceFeatureCapability[] {\n return sourceGraph.capabilities\n .map(({ analyzerId, projectId, available }) => ({\n analyzerId,\n projectId,\n state:\n analyzerId === 'typescript' &&\n available.includes('declarations') &&\n available.includes('documentation') &&\n available.includes('source-locations')\n ? ('available' as const)\n : ('unavailable' as const),\n }))\n .sort((left, right) =>\n compareText(`${left.projectId}:${left.analyzerId}`, `${right.projectId}:${right.analyzerId}`),\n );\n}\n\n/*** Reject spaces and prose so a feature identity remains portable and stable. */\nfunction isFeatureName(value: string): boolean {\n return /^[A-Za-z][A-Za-z0-9._/-]*$/u.test(value);\n}\n\n/*** Recover the encoded project identity already embedded in the canonical feature semantic path. */\nfunction projectIdFromFeatureId(id: string): string {\n return decodeURIComponent(id.split(':')[1] ?? '');\n}\n\n/*** Scope an analyzed file lookup without conflating equally named project files. */\nfunction fileKey(projectId: string, filePath: string | undefined): string {\n return `${projectId}\\u0000${filePath ?? ''}`;\n}\n\n/*** Keep diagnostic order reproducible across fresh and restored source snapshots. */\nfunction compareDiagnostic(left: SourceFeatureDiagnostic, right: SourceFeatureDiagnostic): number {\n return compareText(\n `${left.semanticPath}:${left.message}`,\n `${right.semanticPath}:${right.message}`,\n );\n}\n\n/*** Compare portable identities without host locale effects. */\nfunction compareText(left: string, right: string): number {\n if (left < right) return -1;\n return left > right ? 1 : 0;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"projectSourceFeatures.js","sourceRoot":"","sources":["../../../../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/C,CAAC;AAED,sFAAsF;AACtF,SAAS,iBAAiB,CAAC,IAA6B,EAAE,KAA8B;IACtF,OAAO,WAAW,CAChB,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,OAAO,EAAE,EACtC,GAAG,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,OAAO,EAAE,CACzC,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,SAAS,WAAW,CAAC,IAAY,EAAE,KAAa;IAC9C,IAAI,IAAI,GAAG,KAAK;QAAE,OAAO,CAAC,CAAC,CAAC;IAC5B,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import type {\n SourceFeature,\n SourceFeatureCapability,\n SourceFeatureDiagnostic,\n SourceFeatureProjection,\n SourceGraph,\n SourceNodeData,\n} from '../../../types/sourceGraph.js';\nimport { sourceSemanticPath } from '../domain/sourceSemanticPath.js';\n\n/*** Project only explicit TypeScript `@feature <name>` declaration evidence from a SourceGraph. */\nexport function projectSourceFeatures(sourceGraph: SourceGraph): SourceFeatureProjection {\n const analyzersByFile = new Map(\n sourceGraph.graph.nodes\n .filter(({ data }) => data.kind === 'file' && data.filePath !== undefined)\n .map(({ data }) => [fileKey(data.projectId, data.filePath), data.analyzerId]),\n );\n const evidence = sourceGraph.graph.nodes.flatMap(({ data }) =>\n featureEvidence(data, analyzersByFile.get(fileKey(data.projectId, data.filePath))),\n );\n const diagnostics = evidence.flatMap(({ diagnostic }) =>\n diagnostic === undefined ? [] : [diagnostic],\n );\n const members = evidence.flatMap(({ member }) => (member === undefined ? [] : [member]));\n return {\n version: 1,\n capabilities: featureCapabilities(sourceGraph),\n diagnostics: diagnostics.sort(compareDiagnostic),\n features: featuresFromMembers(members),\n };\n}\n\ninterface FeatureEvidence {\n readonly diagnostic?: SourceFeatureDiagnostic;\n readonly member?: {\n readonly featureName: string;\n readonly featureId: string;\n readonly member: SourceFeature['members'][number];\n };\n}\n\n/*** Accept only the published one-token feature tag contract from TypeScript declarations. */\nfunction featureEvidence(data: SourceNodeData, analyzerId: string | undefined): FeatureEvidence {\n if (\n analyzerId !== 'typescript' ||\n !isDeclaration(data.kind) ||\n data.filePath === undefined ||\n data.location === undefined\n )\n return {};\n const tags = data.documentation?.tags.feature ?? [];\n if (tags.length === 0) return {};\n const names = tags.map((tag) => tag.trim());\n const [name] = names;\n if (names.length !== 1 || name === undefined || !isFeatureName(name)) {\n return {\n diagnostic: {\n analyzerId,\n projectId: data.projectId,\n filePath: data.filePath,\n location: data.location,\n semanticPath: data.semanticPath,\n message: 'A TypeScript feature declaration must have exactly one @feature <name> tag.',\n },\n };\n }\n return {\n member: {\n featureName: name,\n featureId: sourceSemanticPath('feature', data.projectId, name),\n member: {\n analyzerId,\n filePath: data.filePath,\n evidence: data.location,\n semanticPath: data.semanticPath,\n },\n },\n };\n}\n\n/*** Accept feature metadata only from canonical declaration nodes, never graph containers. */\nfunction isDeclaration(kind: SourceNodeData['kind']): boolean {\n return kind !== 'project' && kind !== 'package' && kind !== 'directory' && kind !== 'file';\n}\n\n/*** Build deterministic project-scoped features without treating absent tags as negative evidence. */\nfunction featuresFromMembers(\n members: readonly NonNullable<FeatureEvidence['member']>[],\n): readonly SourceFeature[] {\n const grouped = new Map<\n string,\n {\n readonly id: string;\n readonly name: string;\n readonly projectId: string;\n readonly members: SourceFeature['members'][number][];\n }\n >();\n for (const item of members) {\n const existing = grouped.get(item.featureId);\n if (existing === undefined) {\n grouped.set(item.featureId, {\n id: item.featureId,\n name: item.featureName,\n projectId: projectIdFromFeatureId(item.featureId),\n members: [item.member],\n });\n } else existing.members.push(item.member);\n }\n return [...grouped.values()]\n .map(({ members: groupedMembers, ...feature }) => ({\n ...feature,\n members: [...groupedMembers].sort((left, right) =>\n compareText(left.semanticPath, right.semanticPath),\n ),\n }))\n .sort((left, right) => compareText(left.id, right.id));\n}\n\n/*** Preserve analyzer-level unavailable states instead of guessing feature support from source shape. */\nfunction featureCapabilities(sourceGraph: SourceGraph): readonly SourceFeatureCapability[] {\n return sourceGraph.capabilities\n .map(({ analyzerId, projectId, available }) => ({\n analyzerId,\n projectId,\n state:\n analyzerId === 'typescript' &&\n available.includes('declarations') &&\n available.includes('documentation') &&\n available.includes('source-locations')\n ? ('available' as const)\n : ('unavailable' as const),\n }))\n .sort((left, right) =>\n compareText(`${left.projectId}:${left.analyzerId}`, `${right.projectId}:${right.analyzerId}`),\n );\n}\n\n/*** Reject spaces and prose so a feature identity remains portable and stable. */\nfunction isFeatureName(value: string): boolean {\n return /^[A-Za-z][A-Za-z0-9._/-]*$/u.test(value);\n}\n\n/*** Recover the encoded project identity already embedded in the canonical feature semantic path. */\nfunction projectIdFromFeatureId(id: string): string {\n return decodeURIComponent(id.split(':')[1] ?? '');\n}\n\n/*** Scope an analyzed file lookup without conflating equally named project files. */\nfunction fileKey(projectId: string, filePath: string | undefined): string {\n return `${projectId}\\u0000${filePath ?? ''}`;\n}\n\n/*** Keep diagnostic order reproducible across fresh and restored source snapshots. */\nfunction compareDiagnostic(left: SourceFeatureDiagnostic, right: SourceFeatureDiagnostic): number {\n return compareText(\n `${left.semanticPath}:${left.message}`,\n `${right.semanticPath}:${right.message}`,\n );\n}\n\n/*** Compare portable identities without host locale effects. */\nfunction compareText(left: string, right: string): number {\n if (left < right) return -1;\n return left > right ? 1 : 0;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createProjectAnalysisSnapshotAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createProjectAnalysisSnapshotAsync.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,kCAAkC,EAClC,uBAAuB,EACxB,MAAM,2CAA2C,CAAC;AASnD,kGAAkG;AAClG,wBAAsB,kCAAkC,CACtD,KAAK,EAAE,kCAAkC,GAAG;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GAC5E,OAAO,CAAC,uBAAuB,CAAC,
|
|
1
|
+
{"version":3,"file":"createProjectAnalysisSnapshotAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createProjectAnalysisSnapshotAsync.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,kCAAkC,EAClC,uBAAuB,EACxB,MAAM,2CAA2C,CAAC;AASnD,kGAAkG;AAClG,wBAAsB,kCAAkC,CACtD,KAAK,EAAE,kCAAkC,GAAG;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GAC5E,OAAO,CAAC,uBAAuB,CAAC,CAuClC"}
|
|
@@ -16,21 +16,22 @@ export async function createProjectAnalysisSnapshotAsync(input) {
|
|
|
16
16
|
});
|
|
17
17
|
if (!inspection.complete)
|
|
18
18
|
throw new Error(`Project analysis inspection is incomplete for ${input.id}.`);
|
|
19
|
-
const
|
|
19
|
+
const scopedInspection = createScopedInspection(inspection);
|
|
20
|
+
const analyzedFiles = await readProjectFilesAsync(input.id, scopedInspection, input.signal);
|
|
20
21
|
const analyzerIds = new Set([
|
|
21
22
|
'project-detector',
|
|
22
|
-
...
|
|
23
|
+
...scopedInspection.packages.flatMap(({ detection }) => detection.languages.map(({ id }) => id)),
|
|
23
24
|
...analyzedFiles.map(({ analyzerId }) => analyzerId),
|
|
24
25
|
]);
|
|
25
26
|
return {
|
|
26
27
|
version: 1,
|
|
27
28
|
projectId: input.id,
|
|
28
|
-
directories: [...
|
|
29
|
-
files: [...
|
|
30
|
-
packages:
|
|
29
|
+
directories: [...scopedInspection.directories].sort(compareText),
|
|
30
|
+
files: [...scopedInspection.files].sort(compareText),
|
|
31
|
+
packages: scopedInspection.packages
|
|
31
32
|
.map(({ rootPath, name }) => ({ rootPath, ...(name === undefined ? {} : { name }) }))
|
|
32
33
|
.sort((left, right) => compareText(left.rootPath, right.rootPath)),
|
|
33
|
-
workspaces:
|
|
34
|
+
workspaces: scopedInspection.workspaces
|
|
34
35
|
.map(({ rootPath, packagePaths }) => ({
|
|
35
36
|
rootPath,
|
|
36
37
|
packagePaths: [...packagePaths].sort(compareText),
|
|
@@ -44,6 +45,50 @@ export async function createProjectAnalysisSnapshotAsync(input) {
|
|
|
44
45
|
.sort((left, right) => compareText(left.path, right.path)),
|
|
45
46
|
};
|
|
46
47
|
}
|
|
48
|
+
/*** Retain the root package and its declared workspace members, excluding discovered caches. */
|
|
49
|
+
function createScopedInspection(inspection) {
|
|
50
|
+
const packageRoots = selectedPackageRoots(inspection);
|
|
51
|
+
const packages = inspection.packages.filter(({ rootPath }) => packageRoots.has(rootPath));
|
|
52
|
+
const workspaces = inspection.workspaces.filter(({ rootPath }) => packageRoots.has(rootPath));
|
|
53
|
+
const isOwnedBySelectedPackage = (candidate) => {
|
|
54
|
+
const owner = owningPackageRoot(candidate, inspection.packages);
|
|
55
|
+
return owner === undefined || packageRoots.has(owner);
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
...inspection,
|
|
59
|
+
directories: inspection.directories.filter(isOwnedBySelectedPackage),
|
|
60
|
+
files: inspection.files.filter(isOwnedBySelectedPackage),
|
|
61
|
+
packages,
|
|
62
|
+
workspaces,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/*** Select the root project package and recursively declared workspace package roots. */
|
|
66
|
+
function selectedPackageRoots(inspection) {
|
|
67
|
+
if (!inspection.packages.some(({ rootPath }) => rootPath === '.'))
|
|
68
|
+
return new Set(inspection.packages.map(({ rootPath }) => rootPath));
|
|
69
|
+
const roots = new Set(['.']);
|
|
70
|
+
let changed = true;
|
|
71
|
+
while (changed) {
|
|
72
|
+
changed = false;
|
|
73
|
+
for (const workspace of inspection.workspaces) {
|
|
74
|
+
if (!roots.has(workspace.rootPath))
|
|
75
|
+
continue;
|
|
76
|
+
for (const rootPath of workspace.packagePaths) {
|
|
77
|
+
if (roots.has(rootPath))
|
|
78
|
+
continue;
|
|
79
|
+
roots.add(rootPath);
|
|
80
|
+
changed = true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return roots;
|
|
85
|
+
}
|
|
86
|
+
/*** Resolve the nearest inspected package boundary that owns a project-relative path. */
|
|
87
|
+
function owningPackageRoot(candidate, packages) {
|
|
88
|
+
return packages
|
|
89
|
+
.filter(({ rootPath }) => rootPath === '.' || candidate === rootPath || candidate.startsWith(`${rootPath}/`))
|
|
90
|
+
.sort((left, right) => right.rootPath.length - left.rootPath.length)[0]?.rootPath;
|
|
91
|
+
}
|
|
47
92
|
/*** Read project-relative source files once and retain only portable analyzer facts. */
|
|
48
93
|
async function readProjectFilesAsync(projectId, inspection, signal) {
|
|
49
94
|
const declarations = await readPackageDeclarationsAsync(inspection);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createProjectAnalysisSnapshotAsync.js","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createProjectAnalysisSnapshotAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAQvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4EAA4E,CAAC;AACpH,OAAO,EAAE,8BAA8B,EAAE,MAAM,0FAA0F,CAAC;AAC1I,OAAO,EAAE,4BAA4B,EAAE,MAAM,wFAAwF,CAAC;AACtI,OAAO,EAAE,+BAA+B,EAAE,MAAM,qEAAqE,CAAC;AACtH,OAAO,EAAE,yBAAyB,EAAE,MAAM,mDAAmD,CAAC;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAErF,kGAAkG;AAClG,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,KAA6E;IAE7E,MAAM,UAAU,GACd,YAAY,IAAI,KAAK;QACnB,CAAC,CAAC,KAAK,CAAC,UAAU;QAClB,CAAC,CAAC,MAAM,mBAAmB,CAAC,KAAK,CA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IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACrF,OAAO,QAAQ,CAAC;IAClB,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,8FAA8F;AAC9F,SAAS,kBAAkB,CAAC,UAAkB;IAC5C,IAAI,UAAU,KAAK,MAAM;QAAE,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;IACzD,IAAI,UAAU,KAAK,QAAQ;QAAE,OAAO,CAAC,iBAAiB,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACpE,IAAI,UAAU,KAAK,QAAQ;QAAE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACxD,IAAI,UAAU,KAAK,QAAQ;QAAE,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,gFAAgF;AAChF,SAAS,WAAW,CAAC,IAAY,EAAE,KAAa;IAC9C,IAAI,IAAI,GAAG,KAAK;QAAE,OAAO,CAAC,CAAC,CAAC;IAC5B,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import { readFile } from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { inspectProjectAsync } from '@ankhorage/project-detector/node';\nimport type { ProjectInspection } from '@ankhorage/project-detector/types';\n\nimport type {\n CreateProjectAnalysisSnapshotInput,\n ProjectAnalysisSnapshot,\n} from '../../../types/projectAnalysisSnapshot.js';\nimport type { SourceAnalyzedFile } from '../../../types/sourceGraph.js';\nimport { extractJavaSourceFacts } from '../../dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.js';\nimport { createTypeScriptImportResolver } from '../../dependency-analysis/adapters/outbound/typescript/createTypeScriptImportResolver.js';\nimport { extractTypeScriptSourceFacts } from '../../dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.js';\nimport { readDependencyDeclarationsAsync } from '../../dependency-analysis/domain/readDependencyDeclarationsAsync.js';\nimport { extractOtherLanguageFacts } from '../adapters/outbound/extractOtherLanguageFacts.js';\nimport { sourceAnalyzerCapabilities } from '../domain/sourceAnalyzerCapabilities.js';\n\n/*** Analyze one bounded project into facts that remain valid after its source root is removed. */\nexport async function createProjectAnalysisSnapshotAsync(\n input: CreateProjectAnalysisSnapshotInput & { readonly signal?: AbortSignal },\n): Promise<ProjectAnalysisSnapshot> {\n const inspection =\n 'inspection' in input\n ? input.inspection\n : await inspectProjectAsync(input.rootPath, {\n ...(input.signal === undefined ? {} : { signal: input.signal }),\n });\n if (!inspection.complete)\n throw new Error(`Project analysis inspection is incomplete for ${input.id}.`);\n const analyzedFiles = await readProjectFilesAsync(input.id, inspection, input.signal);\n const analyzerIds = new Set([\n 'project-detector',\n ...inspection.detection.languages.map(({ id }) => id),\n ...analyzedFiles.map(({ analyzerId }) => analyzerId),\n ]);\n return {\n version: 1,\n projectId: input.id,\n directories: [...inspection.directories].sort(compareText),\n files: [...inspection.files].sort(compareText),\n packages: inspection.packages\n .map(({ rootPath, name }) => ({ rootPath, ...(name === undefined ? {} : { name }) }))\n .sort((left, right) => compareText(left.rootPath, right.rootPath)),\n workspaces: inspection.workspaces\n .map(({ rootPath, packagePaths }) => ({\n rootPath,\n packagePaths: [...packagePaths].sort(compareText),\n }))\n .sort((left, right) => compareText(left.rootPath, right.rootPath)),\n analyzers: [...analyzerIds]\n .sort(compareText)\n .map((id) => ({ id, capabilities: sourceAnalyzerCapabilities(id) })),\n analyzedFiles: analyzedFiles\n .map(({ projectId: _, ...file }) => file)\n .sort((left, right) => compareText(left.path, right.path)),\n };\n}\n\n/*** Read project-relative source files once and retain only portable analyzer facts. */\nasync function readProjectFilesAsync(\n projectId: string,\n inspection: ProjectInspection,\n signal: AbortSignal | undefined,\n): Promise<readonly SourceAnalyzedFile[]> {\n const declarations = await readPackageDeclarationsAsync(inspection);\n const resolveTypeScriptImports = createTypeScriptImportResolver(inspection.rootPath);\n return Promise.all(\n inspection.files.flatMap((file) => {\n const analyzerId = analyzerForPath(file);\n if (analyzerId === undefined) return [];\n const [owner] = inspection.packages\n .filter(({ rootPath }) => rootPath === '.' || file.startsWith(`${rootPath}/`))\n .sort((left, right) => right.rootPath.length - left.rootPath.length);\n const root = owner?.rootPath ?? '.';\n const sourceRoots =\n owner?.detection.languages.find(({ id }) => id === analyzerId)?.sourceRoots ??\n defaultSourceRoots(analyzerId);\n const relative = root === '.' ? file : file.slice(root.length + 1);\n if (\n !sourceRoots.some(\n (sourceRoot) => sourceRoot === '.' || relative.startsWith(`${sourceRoot}/`),\n )\n )\n return [];\n return [\n readAnalyzedFileAsync({\n projectId,\n file,\n analyzerId,\n projectRoot: inspection.rootPath,\n packageRoot: path.resolve(inspection.rootPath, root),\n sourceRoots,\n declaredDependencies: declarations.get(root),\n resolveTypeScriptImports,\n signal,\n }),\n ];\n }),\n );\n}\n\n/*** Preserve manifest declarations as project-relative import evidence. */\nasync function readPackageDeclarationsAsync(\n inspection: ProjectInspection,\n): Promise<ReadonlyMap<string, SourceAnalyzedFile['declaredDependencies']>> {\n const entries = await Promise.all(\n inspection.packages.map(\n async (item) =>\n [\n item.rootPath,\n item.manifestPath.endsWith('.json')\n ? await readDependencyDeclarationsAsync(\n path.join(inspection.rootPath, item.manifestPath),\n )\n : {},\n ] as const,\n ),\n );\n return new Map(entries);\n}\n\ninterface ReadSourceFileInput {\n readonly projectId: string;\n readonly projectRoot: string;\n readonly packageRoot: string;\n readonly sourceRoots: readonly string[];\n readonly file: string;\n readonly analyzerId: Exclude<ReturnType<typeof analyzerForPath>, undefined>;\n readonly declaredDependencies: SourceAnalyzedFile['declaredDependencies'];\n readonly resolveTypeScriptImports: ReturnType<typeof createTypeScriptImportResolver>;\n readonly signal: AbortSignal | undefined;\n}\n\n/*** Read one source file at the materialization boundary and discard its absolute path afterward. */\nasync function readAnalyzedFileAsync(input: ReadSourceFileInput): Promise<SourceAnalyzedFile> {\n input.signal?.throwIfAborted();\n const absolute = path.resolve(input.projectRoot, ...input.file.split('/'));\n const content = await readFile(absolute, 'utf8');\n input.signal?.throwIfAborted();\n return {\n projectId: input.projectId,\n path: input.file,\n analyzerId: input.analyzerId,\n ...(input.declaredDependencies === undefined\n ? {}\n : { declaredDependencies: input.declaredDependencies }),\n facts:\n input.analyzerId === 'java'\n ? extractJavaSourceFacts(content)\n : input.analyzerId === 'typescript'\n ? input.resolveTypeScriptImports(\n absolute,\n input.packageRoot,\n extractTypeScriptSourceFacts(input.file, content),\n )\n : extractOtherLanguageFacts(\n input.analyzerId,\n content,\n absolute,\n input.packageRoot,\n input.sourceRoots,\n ),\n };\n}\n\n/*** Select the implemented language analyzer from a project-relative source filename. */\nfunction analyzerForPath(\n file: string,\n): 'java' | 'typescript' | 'cpp' | 'delphi' | 'kotlin' | 'python' | undefined {\n if (file.endsWith('.java')) return 'java';\n if (['.ts', '.tsx', '.mts', '.cts'].some((extension) => file.endsWith(extension)))\n return 'typescript';\n if (file.endsWith('.kt') || file.endsWith('.kts')) return 'kotlin';\n if (file.endsWith('.py') || file.endsWith('.pyi')) return 'python';\n if (['.cpp', '.cc', '.cxx', '.h', '.hpp', '.hxx'].some((extension) => file.endsWith(extension)))\n return 'cpp';\n if (['.pas', '.pp', '.dpr'].some((extension) => file.toLowerCase().endsWith(extension)))\n return 'delphi';\n return undefined;\n}\n\n/*** Keep established default source roots for analyzers without explicit project metadata. */\nfunction defaultSourceRoots(analyzerId: string): readonly string[] {\n if (analyzerId === 'java') return ['src/main/java', '.'];\n if (analyzerId === 'kotlin') return ['src/main/kotlin', 'src', '.'];\n if (analyzerId === 'python') return ['src', 'app', '.'];\n if (analyzerId === 'delphi') return ['src', 'Source', '.'];\n return ['.'];\n}\n\n/*** Compare portable identities deterministically without host locale rules. */\nfunction compareText(left: string, right: string): number {\n if (left < right) return -1;\n return left > right ? 1 : 0;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createProjectAnalysisSnapshotAsync.js","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createProjectAnalysisSnapshotAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAQvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4EAA4E,CAAC;AACpH,OAAO,EAAE,8BAA8B,EAAE,MAAM,0FAA0F,CAAC;AAC1I,OAAO,EAAE,4BAA4B,EAAE,MAAM,wFAAwF,CAAC;AACtI,OAAO,EAAE,+BAA+B,EAAE,MAAM,qEAAqE,CAAC;AACtH,OAAO,EAAE,yBAAyB,EAAE,MAAM,mDAAmD,CAAC;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAErF,kGAAkG;AAClG,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,KAA6E;IAE7E,MAAM,UAAU,GACd,YAAY,IAAI,KAAK;QACnB,CAAC,CAAC,KAAK,CAAC,UAAU;QAClB,CAAC,CAAC,MAAM,mBAAmB,CAAC,KAAK,CAAC,QAAQ,EAAE;YACxC,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;SAChE,CAAC,CAAC;IACT,IAAI,CAAC,UAAU,CAAC,QAAQ;QACtB,MAAM,IAAI,KAAK,CAAC,iDAAiD,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;IAChF,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,aAAa,GAAG,MAAM,qBAAqB,CAAC,KAAK,CAAC,EAAE,EAAE,gBAAgB,EAAE,KAAK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D,OAAO,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,gFAAgF;AAChF,SAAS,WAAW,CAAC,IAAY,EAAE,KAAa;IAC9C,IAAI,IAAI,GAAG,KAAK;QAAE,OAAO,CAAC,CAAC,CAAC;IAC5B,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import { readFile } from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { inspectProjectAsync } from '@ankhorage/project-detector/node';\nimport type { InspectedPackage, ProjectInspection } from '@ankhorage/project-detector/types';\n\nimport type {\n CreateProjectAnalysisSnapshotInput,\n ProjectAnalysisSnapshot,\n} from '../../../types/projectAnalysisSnapshot.js';\nimport type { SourceAnalyzedFile } from '../../../types/sourceGraph.js';\nimport { extractJavaSourceFacts } from '../../dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.js';\nimport { createTypeScriptImportResolver } from '../../dependency-analysis/adapters/outbound/typescript/createTypeScriptImportResolver.js';\nimport { extractTypeScriptSourceFacts } from '../../dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.js';\nimport { readDependencyDeclarationsAsync } from '../../dependency-analysis/domain/readDependencyDeclarationsAsync.js';\nimport { extractOtherLanguageFacts } from '../adapters/outbound/extractOtherLanguageFacts.js';\nimport { sourceAnalyzerCapabilities } from '../domain/sourceAnalyzerCapabilities.js';\n\n/*** Analyze one bounded project into facts that remain valid after its source root is removed. */\nexport async function createProjectAnalysisSnapshotAsync(\n input: CreateProjectAnalysisSnapshotInput & { readonly signal?: AbortSignal },\n): Promise<ProjectAnalysisSnapshot> {\n const inspection =\n 'inspection' in input\n ? input.inspection\n : await inspectProjectAsync(input.rootPath, {\n ...(input.signal === undefined ? {} : { signal: input.signal }),\n });\n if (!inspection.complete)\n throw new Error(`Project analysis inspection is incomplete for ${input.id}.`);\n const scopedInspection = createScopedInspection(inspection);\n const analyzedFiles = await readProjectFilesAsync(input.id, scopedInspection, input.signal);\n const analyzerIds = new Set([\n 'project-detector',\n ...scopedInspection.packages.flatMap(({ detection }) =>\n detection.languages.map(({ id }) => id),\n ),\n ...analyzedFiles.map(({ analyzerId }) => analyzerId),\n ]);\n return {\n version: 1,\n projectId: input.id,\n directories: [...scopedInspection.directories].sort(compareText),\n files: [...scopedInspection.files].sort(compareText),\n packages: scopedInspection.packages\n .map(({ rootPath, name }) => ({ rootPath, ...(name === undefined ? {} : { name }) }))\n .sort((left, right) => compareText(left.rootPath, right.rootPath)),\n workspaces: scopedInspection.workspaces\n .map(({ rootPath, packagePaths }) => ({\n rootPath,\n packagePaths: [...packagePaths].sort(compareText),\n }))\n .sort((left, right) => compareText(left.rootPath, right.rootPath)),\n analyzers: [...analyzerIds]\n .sort(compareText)\n .map((id) => ({ id, capabilities: sourceAnalyzerCapabilities(id) })),\n analyzedFiles: analyzedFiles\n .map(({ projectId: _, ...file }) => file)\n .sort((left, right) => compareText(left.path, right.path)),\n };\n}\n\n/*** Retain the root package and its declared workspace members, excluding discovered caches. */\nfunction createScopedInspection(inspection: ProjectInspection): ProjectInspection {\n const packageRoots = selectedPackageRoots(inspection);\n const packages = inspection.packages.filter(({ rootPath }) => packageRoots.has(rootPath));\n const workspaces = inspection.workspaces.filter(({ rootPath }) => packageRoots.has(rootPath));\n const isOwnedBySelectedPackage = (candidate: string): boolean => {\n const owner = owningPackageRoot(candidate, inspection.packages);\n return owner === undefined || packageRoots.has(owner);\n };\n return {\n ...inspection,\n directories: inspection.directories.filter(isOwnedBySelectedPackage),\n files: inspection.files.filter(isOwnedBySelectedPackage),\n packages,\n workspaces,\n };\n}\n\n/*** Select the root project package and recursively declared workspace package roots. */\nfunction selectedPackageRoots(inspection: ProjectInspection): ReadonlySet<string> {\n if (!inspection.packages.some(({ rootPath }) => rootPath === '.'))\n return new Set(inspection.packages.map(({ rootPath }) => rootPath));\n const roots = new Set<string>(['.']);\n let changed = true;\n while (changed) {\n changed = false;\n for (const workspace of inspection.workspaces) {\n if (!roots.has(workspace.rootPath)) continue;\n for (const rootPath of workspace.packagePaths) {\n if (roots.has(rootPath)) continue;\n roots.add(rootPath);\n changed = true;\n }\n }\n }\n return roots;\n}\n\n/*** Resolve the nearest inspected package boundary that owns a project-relative path. */\nfunction owningPackageRoot(\n candidate: string,\n packages: readonly InspectedPackage[],\n): string | undefined {\n return packages\n .filter(\n ({ rootPath }) =>\n rootPath === '.' || candidate === rootPath || candidate.startsWith(`${rootPath}/`),\n )\n .sort((left, right) => right.rootPath.length - left.rootPath.length)[0]?.rootPath;\n}\n\n/*** Read project-relative source files once and retain only portable analyzer facts. */\nasync function readProjectFilesAsync(\n projectId: string,\n inspection: ProjectInspection,\n signal: AbortSignal | undefined,\n): Promise<readonly SourceAnalyzedFile[]> {\n const declarations = await readPackageDeclarationsAsync(inspection);\n const resolveTypeScriptImports = createTypeScriptImportResolver(inspection.rootPath);\n return Promise.all(\n inspection.files.flatMap((file) => {\n const analyzerId = analyzerForPath(file);\n if (analyzerId === undefined) return [];\n const [owner] = inspection.packages\n .filter(({ rootPath }) => rootPath === '.' || file.startsWith(`${rootPath}/`))\n .sort((left, right) => right.rootPath.length - left.rootPath.length);\n const root = owner?.rootPath ?? '.';\n const sourceRoots =\n owner?.detection.languages.find(({ id }) => id === analyzerId)?.sourceRoots ??\n defaultSourceRoots(analyzerId);\n const relative = root === '.' ? file : file.slice(root.length + 1);\n if (\n !sourceRoots.some(\n (sourceRoot) => sourceRoot === '.' || relative.startsWith(`${sourceRoot}/`),\n )\n )\n return [];\n return [\n readAnalyzedFileAsync({\n projectId,\n file,\n analyzerId,\n projectRoot: inspection.rootPath,\n packageRoot: path.resolve(inspection.rootPath, root),\n sourceRoots,\n declaredDependencies: declarations.get(root),\n resolveTypeScriptImports,\n signal,\n }),\n ];\n }),\n );\n}\n\n/*** Preserve manifest declarations as project-relative import evidence. */\nasync function readPackageDeclarationsAsync(\n inspection: ProjectInspection,\n): Promise<ReadonlyMap<string, SourceAnalyzedFile['declaredDependencies']>> {\n const entries = await Promise.all(\n inspection.packages.map(\n async (item) =>\n [\n item.rootPath,\n item.manifestPath.endsWith('.json')\n ? await readDependencyDeclarationsAsync(\n path.join(inspection.rootPath, item.manifestPath),\n )\n : {},\n ] as const,\n ),\n );\n return new Map(entries);\n}\n\ninterface ReadSourceFileInput {\n readonly projectId: string;\n readonly projectRoot: string;\n readonly packageRoot: string;\n readonly sourceRoots: readonly string[];\n readonly file: string;\n readonly analyzerId: Exclude<ReturnType<typeof analyzerForPath>, undefined>;\n readonly declaredDependencies: SourceAnalyzedFile['declaredDependencies'];\n readonly resolveTypeScriptImports: ReturnType<typeof createTypeScriptImportResolver>;\n readonly signal: AbortSignal | undefined;\n}\n\n/*** Read one source file at the materialization boundary and discard its absolute path afterward. */\nasync function readAnalyzedFileAsync(input: ReadSourceFileInput): Promise<SourceAnalyzedFile> {\n input.signal?.throwIfAborted();\n const absolute = path.resolve(input.projectRoot, ...input.file.split('/'));\n const content = await readFile(absolute, 'utf8');\n input.signal?.throwIfAborted();\n return {\n projectId: input.projectId,\n path: input.file,\n analyzerId: input.analyzerId,\n ...(input.declaredDependencies === undefined\n ? {}\n : { declaredDependencies: input.declaredDependencies }),\n facts:\n input.analyzerId === 'java'\n ? extractJavaSourceFacts(content)\n : input.analyzerId === 'typescript'\n ? input.resolveTypeScriptImports(\n absolute,\n input.packageRoot,\n extractTypeScriptSourceFacts(input.file, content),\n )\n : extractOtherLanguageFacts(\n input.analyzerId,\n content,\n absolute,\n input.packageRoot,\n input.sourceRoots,\n ),\n };\n}\n\n/*** Select the implemented language analyzer from a project-relative source filename. */\nfunction analyzerForPath(\n file: string,\n): 'java' | 'typescript' | 'cpp' | 'delphi' | 'kotlin' | 'python' | undefined {\n if (file.endsWith('.java')) return 'java';\n if (['.ts', '.tsx', '.mts', '.cts'].some((extension) => file.endsWith(extension)))\n return 'typescript';\n if (file.endsWith('.kt') || file.endsWith('.kts')) return 'kotlin';\n if (file.endsWith('.py') || file.endsWith('.pyi')) return 'python';\n if (['.cpp', '.cc', '.cxx', '.h', '.hpp', '.hxx'].some((extension) => file.endsWith(extension)))\n return 'cpp';\n if (['.pas', '.pp', '.dpr'].some((extension) => file.toLowerCase().endsWith(extension)))\n return 'delphi';\n return undefined;\n}\n\n/*** Keep established default source roots for analyzers without explicit project metadata. */\nfunction defaultSourceRoots(analyzerId: string): readonly string[] {\n if (analyzerId === 'java') return ['src/main/java', '.'];\n if (analyzerId === 'kotlin') return ['src/main/kotlin', 'src', '.'];\n if (analyzerId === 'python') return ['src', 'app', '.'];\n if (analyzerId === 'delphi') return ['src', 'Source', '.'];\n return ['.'];\n}\n\n/*** Compare portable identities deterministically without host locale rules. */\nfunction compareText(left: string, right: string): number {\n if (left < right) return -1;\n return left > right ? 1 : 0;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/dependency-graph",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Project-aware dependency analysis that produces canonical Ankhorage graphs.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"typescript": "~6.0.3"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@ankhorage/devtools": "^
|
|
72
|
+
"@ankhorage/devtools": "^2.10.5",
|
|
73
73
|
"@ankhorage/paradox": "^0.1.26",
|
|
74
74
|
"@types/bun": "^1.4.2",
|
|
75
75
|
"@types/node": "^26.5.1"
|