@getcodesentinel/codesentinel 1.31.0 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html-report-app/assets/index-CH1ayI_3.js +9 -0
- package/dist/html-report-app/assets/index-Dkq-kKM9.css +2 -0
- package/dist/html-report-app/index.html +2 -2
- package/dist/index.js +678 -98
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/html-report-app/assets/index-BVFLpD3q.css +0 -2
- package/dist/html-report-app/assets/index-CzioVJuu.js +0 -9
package/dist/index.js
CHANGED
|
@@ -13,6 +13,8 @@ import { join as join2 } from "path";
|
|
|
13
13
|
import { createHash } from "crypto";
|
|
14
14
|
import { mkdir, readdir, readFile, rename, stat, unlink, writeFile } from "fs/promises";
|
|
15
15
|
import { join as join3 } from "path";
|
|
16
|
+
import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2, statSync } from "fs";
|
|
17
|
+
import { basename, join as join5, relative, resolve } from "path";
|
|
16
18
|
var round4 = (value) => Number(value.toFixed(4));
|
|
17
19
|
var normalizeNodes = (nodes) => {
|
|
18
20
|
const byName = /* @__PURE__ */ new Map();
|
|
@@ -115,7 +117,81 @@ var collectTransitiveDependencies = (rootName, nodeByName) => {
|
|
|
115
117
|
}
|
|
116
118
|
return [...seen].sort((a, b) => a.localeCompare(b));
|
|
117
119
|
};
|
|
118
|
-
var
|
|
120
|
+
var hasHighRiskSignals = (dependency, config) => dependency.ownRiskSignals.includes("abandoned") || dependency.ownRiskSignals.filter(
|
|
121
|
+
(signal) => signal === "high_centrality" || signal === "deep_chain" || signal === "high_fanout"
|
|
122
|
+
).length >= 2 || dependency.ownRiskSignals.includes("single_maintainer") && ((dependency.daysSinceLastRelease ?? 0) >= config.abandonedDaysThreshold / 2 || (dependency.repositoryActivity30d ?? 1) <= 0);
|
|
123
|
+
var buildWorkspaceExposureSummaries = (workspaceManifests, allByName, nodeByName, config) => {
|
|
124
|
+
if (workspaceManifests.length === 0) {
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
const workspaceNames = new Set(workspaceManifests.map((workspace) => workspace.name));
|
|
128
|
+
const externalDependencyNamesByWorkspace = /* @__PURE__ */ new Map();
|
|
129
|
+
const workspaceCountByDependency = /* @__PURE__ */ new Map();
|
|
130
|
+
for (const workspace of workspaceManifests) {
|
|
131
|
+
const dependencyNames = [
|
|
132
|
+
...new Set(
|
|
133
|
+
workspace.directDependencies.map((dependency) => dependency.name).filter((dependencyName) => !workspaceNames.has(dependencyName))
|
|
134
|
+
)
|
|
135
|
+
].sort((a, b) => a.localeCompare(b));
|
|
136
|
+
externalDependencyNamesByWorkspace.set(workspace.path, dependencyNames);
|
|
137
|
+
for (const dependencyName of dependencyNames) {
|
|
138
|
+
workspaceCountByDependency.set(
|
|
139
|
+
dependencyName,
|
|
140
|
+
(workspaceCountByDependency.get(dependencyName) ?? 0) + 1
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return [...workspaceManifests].map((workspace) => {
|
|
145
|
+
const dependencyNames = externalDependencyNamesByWorkspace.get(workspace.path) ?? [];
|
|
146
|
+
const directSpecByName = new Map(
|
|
147
|
+
workspace.directDependencies.map((dependency) => [dependency.name, dependency])
|
|
148
|
+
);
|
|
149
|
+
const resolvedDependencies = dependencyNames.map((dependencyName) => allByName.get(dependencyName)).filter((dependency) => dependency !== void 0);
|
|
150
|
+
const unresolvedDependencies = dependencyNames.filter(
|
|
151
|
+
(dependencyName) => !allByName.has(dependencyName)
|
|
152
|
+
);
|
|
153
|
+
const highRiskDependencies = resolvedDependencies.filter(
|
|
154
|
+
(dependency) => (directSpecByName.get(dependency.name)?.scope ?? dependency.dependencyScope) === "prod" && hasHighRiskSignals(dependency, config)
|
|
155
|
+
).map((dependency) => dependency.name).sort((a, b) => a.localeCompare(b));
|
|
156
|
+
const highRiskDevelopmentDependencies = resolvedDependencies.filter(
|
|
157
|
+
(dependency) => (directSpecByName.get(dependency.name)?.scope ?? dependency.dependencyScope) === "dev" && hasHighRiskSignals(dependency, config)
|
|
158
|
+
).map((dependency) => dependency.name).sort((a, b) => a.localeCompare(b));
|
|
159
|
+
const transitiveExposureDependencies = resolvedDependencies.filter((dependency) => {
|
|
160
|
+
const transitiveDependencies = collectTransitiveDependencies(dependency.name, nodeByName);
|
|
161
|
+
return transitiveDependencies.some((transitiveName) => {
|
|
162
|
+
const transitive = allByName.get(transitiveName);
|
|
163
|
+
return transitive?.riskSignals.some(canPropagateSignal) ?? false;
|
|
164
|
+
});
|
|
165
|
+
}).map((dependency) => dependency.name).sort((a, b) => a.localeCompare(b));
|
|
166
|
+
const singleMaintainerDependencies = resolvedDependencies.filter((dependency) => dependency.ownRiskSignals.includes("single_maintainer")).map((dependency) => dependency.name).sort((a, b) => a.localeCompare(b));
|
|
167
|
+
const abandonedDependencies = resolvedDependencies.filter((dependency) => dependency.ownRiskSignals.includes("abandoned")).map((dependency) => dependency.name).sort((a, b) => a.localeCompare(b));
|
|
168
|
+
return {
|
|
169
|
+
name: workspace.name,
|
|
170
|
+
path: workspace.path,
|
|
171
|
+
kind: workspace.kind,
|
|
172
|
+
directDependencies: dependencyNames.length,
|
|
173
|
+
directProductionDependencies: dependencyNames.filter(
|
|
174
|
+
(dependencyName) => directSpecByName.get(dependencyName)?.scope === "prod"
|
|
175
|
+
).length,
|
|
176
|
+
directDevelopmentDependencies: dependencyNames.filter(
|
|
177
|
+
(dependencyName) => directSpecByName.get(dependencyName)?.scope === "dev"
|
|
178
|
+
).length,
|
|
179
|
+
unresolvedDependencies,
|
|
180
|
+
dependencyNames,
|
|
181
|
+
sharedDependencies: dependencyNames.filter(
|
|
182
|
+
(dependencyName) => (workspaceCountByDependency.get(dependencyName) ?? 0) > 1
|
|
183
|
+
),
|
|
184
|
+
highRiskDependencies,
|
|
185
|
+
highRiskDevelopmentDependencies,
|
|
186
|
+
transitiveExposureDependencies,
|
|
187
|
+
singleMaintainerDependencies,
|
|
188
|
+
abandonedDependencies
|
|
189
|
+
};
|
|
190
|
+
}).sort(
|
|
191
|
+
(a, b) => b.highRiskDependencies.length - a.highRiskDependencies.length || b.transitiveExposureDependencies.length - a.transitiveExposureDependencies.length || b.directDependencies - a.directDependencies || a.path.localeCompare(b.path)
|
|
192
|
+
);
|
|
193
|
+
};
|
|
194
|
+
var buildExternalAnalysisSummary = (targetPath, extraction, metadataByKey, config, workspaceManifests = []) => {
|
|
119
195
|
const nodes = normalizeNodes(extraction.nodes);
|
|
120
196
|
const directNames = new Set(extraction.directDependencies.map((dep) => dep.name));
|
|
121
197
|
const directSpecByName = new Map(extraction.directDependencies.map((dep) => [dep.name, dep]));
|
|
@@ -235,6 +311,13 @@ var buildExternalAnalysisSummary = (targetPath, extraction, metadataByKey, confi
|
|
|
235
311
|
).map((dep) => dep.name);
|
|
236
312
|
const singleMaintainerDependencies = dependencies.filter((dep) => dep.ownRiskSignals.includes("single_maintainer")).map((dep) => dep.name).sort((a, b) => a.localeCompare(b));
|
|
237
313
|
const abandonedDependencies = dependencies.filter((dep) => dep.ownRiskSignals.includes("abandoned")).map((dep) => dep.name).sort((a, b) => a.localeCompare(b));
|
|
314
|
+
const workspaces = buildWorkspaceExposureSummaries(
|
|
315
|
+
workspaceManifests,
|
|
316
|
+
allByName,
|
|
317
|
+
nodeByName,
|
|
318
|
+
config
|
|
319
|
+
);
|
|
320
|
+
const workspaceSummary2 = workspaces.length > 0 ? { workspaces } : {};
|
|
238
321
|
return {
|
|
239
322
|
targetPath,
|
|
240
323
|
available: true,
|
|
@@ -253,6 +336,7 @@ var buildExternalAnalysisSummary = (targetPath, extraction, metadataByKey, confi
|
|
|
253
336
|
metadataCoverage: allDependencies.length === 0 ? 0 : round4(metadataAvailableCount / allDependencies.length)
|
|
254
337
|
},
|
|
255
338
|
dependencies,
|
|
339
|
+
...workspaceSummary2,
|
|
256
340
|
highRiskDependencies,
|
|
257
341
|
highRiskDevelopmentDependencies,
|
|
258
342
|
transitiveExposureDependencies,
|
|
@@ -1423,6 +1507,136 @@ var prepareDependencyExtraction = async (repositoryPath) => {
|
|
|
1423
1507
|
extraction: parseLockfileExtraction(lockfile.kind, lockfile.raw, directSpecs)
|
|
1424
1508
|
};
|
|
1425
1509
|
};
|
|
1510
|
+
var normalizePath = (pathValue) => pathValue.replaceAll("\\", "/");
|
|
1511
|
+
var stripQuotes2 = (value) => value.replace(/^['"]|['"]$/g, "");
|
|
1512
|
+
var readPackageJson = (path) => {
|
|
1513
|
+
try {
|
|
1514
|
+
return JSON.parse(readFileSync2(path, "utf8"));
|
|
1515
|
+
} catch {
|
|
1516
|
+
return null;
|
|
1517
|
+
}
|
|
1518
|
+
};
|
|
1519
|
+
var inferWorkspaceKind = (workspacePath) => {
|
|
1520
|
+
const segments = workspacePath.split("/");
|
|
1521
|
+
const first = segments[0] ?? "";
|
|
1522
|
+
if (first === "apps" || first === "app") {
|
|
1523
|
+
return "app";
|
|
1524
|
+
}
|
|
1525
|
+
if (first === "packages" || first === "package") {
|
|
1526
|
+
return "package";
|
|
1527
|
+
}
|
|
1528
|
+
if (first === "docs" || first === "documentation") {
|
|
1529
|
+
return "docs";
|
|
1530
|
+
}
|
|
1531
|
+
if (first === "examples" || first === "example-apps" || first === "playground") {
|
|
1532
|
+
return "example";
|
|
1533
|
+
}
|
|
1534
|
+
if (first === "tooling" || first === "tools") {
|
|
1535
|
+
return "tooling";
|
|
1536
|
+
}
|
|
1537
|
+
return "unknown";
|
|
1538
|
+
};
|
|
1539
|
+
var readWorkspacePatternsFromPackageJson = (projectRoot) => {
|
|
1540
|
+
const packageJson = readPackageJson(join5(projectRoot, "package.json"));
|
|
1541
|
+
if (packageJson?.workspaces === void 0) {
|
|
1542
|
+
return [];
|
|
1543
|
+
}
|
|
1544
|
+
const workspaces = packageJson.workspaces;
|
|
1545
|
+
if (Array.isArray(workspaces)) {
|
|
1546
|
+
const workspaceArray = workspaces;
|
|
1547
|
+
return workspaceArray.filter((workspace) => typeof workspace === "string");
|
|
1548
|
+
}
|
|
1549
|
+
const workspaceObject = workspaces;
|
|
1550
|
+
return workspaceObject.packages ?? [];
|
|
1551
|
+
};
|
|
1552
|
+
var readWorkspacePatternsFromPnpmWorkspace = (projectRoot) => {
|
|
1553
|
+
const workspacePath = join5(projectRoot, "pnpm-workspace.yaml");
|
|
1554
|
+
if (!existsSync2(workspacePath)) {
|
|
1555
|
+
return [];
|
|
1556
|
+
}
|
|
1557
|
+
const patterns = [];
|
|
1558
|
+
const lines = readFileSync2(workspacePath, "utf8").split("\n");
|
|
1559
|
+
let readingPackages = false;
|
|
1560
|
+
for (const line of lines) {
|
|
1561
|
+
const trimmed = line.trim();
|
|
1562
|
+
if (trimmed.length === 0 || trimmed.startsWith("#")) {
|
|
1563
|
+
continue;
|
|
1564
|
+
}
|
|
1565
|
+
if (!line.startsWith(" ") && !line.startsWith("-")) {
|
|
1566
|
+
readingPackages = trimmed === "packages:";
|
|
1567
|
+
continue;
|
|
1568
|
+
}
|
|
1569
|
+
if (!readingPackages) {
|
|
1570
|
+
continue;
|
|
1571
|
+
}
|
|
1572
|
+
const match = trimmed.match(/^-\s+(.+)$/);
|
|
1573
|
+
if (match?.[1] !== void 0) {
|
|
1574
|
+
patterns.push(stripQuotes2(match[1].trim()));
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
return patterns;
|
|
1578
|
+
};
|
|
1579
|
+
var expandPattern = (projectRoot, pattern) => {
|
|
1580
|
+
const segments = normalizePath(pattern).split("/").filter((segment) => segment.length > 0);
|
|
1581
|
+
let current = [projectRoot];
|
|
1582
|
+
for (const segment of segments) {
|
|
1583
|
+
const next = [];
|
|
1584
|
+
if (segment === "*") {
|
|
1585
|
+
for (const directory of current) {
|
|
1586
|
+
if (!existsSync2(directory)) {
|
|
1587
|
+
continue;
|
|
1588
|
+
}
|
|
1589
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
1590
|
+
if (entry.isDirectory()) {
|
|
1591
|
+
next.push(join5(directory, entry.name));
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
} else {
|
|
1596
|
+
for (const directory of current) {
|
|
1597
|
+
const candidate = join5(directory, segment);
|
|
1598
|
+
if (existsSync2(candidate) && statSync(candidate).isDirectory()) {
|
|
1599
|
+
next.push(candidate);
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
current = next;
|
|
1604
|
+
}
|
|
1605
|
+
return current;
|
|
1606
|
+
};
|
|
1607
|
+
var loadWorkspaceDependencyManifests = (projectRoot) => {
|
|
1608
|
+
const absoluteRoot = resolve(projectRoot);
|
|
1609
|
+
const packageJsonPatterns = readWorkspacePatternsFromPackageJson(absoluteRoot);
|
|
1610
|
+
const pnpmPatterns = readWorkspacePatternsFromPnpmWorkspace(absoluteRoot);
|
|
1611
|
+
const patterns = packageJsonPatterns.length > 0 ? packageJsonPatterns : pnpmPatterns;
|
|
1612
|
+
const includePatterns = patterns.filter((pattern) => !pattern.startsWith("!"));
|
|
1613
|
+
const excludePatterns = patterns.filter((pattern) => pattern.startsWith("!")).map((pattern) => pattern.slice(1));
|
|
1614
|
+
const excludedPaths = new Set(
|
|
1615
|
+
excludePatterns.flatMap((pattern) => expandPattern(absoluteRoot, pattern)).map((path) => normalizePath(relative(absoluteRoot, path)))
|
|
1616
|
+
);
|
|
1617
|
+
const manifestsByPath = /* @__PURE__ */ new Map();
|
|
1618
|
+
for (const pattern of includePatterns) {
|
|
1619
|
+
for (const absoluteWorkspacePath of expandPattern(absoluteRoot, pattern)) {
|
|
1620
|
+
const relativePath = normalizePath(relative(absoluteRoot, absoluteWorkspacePath));
|
|
1621
|
+
if (relativePath.length === 0 || relativePath.startsWith("..") || excludedPaths.has(relativePath)) {
|
|
1622
|
+
continue;
|
|
1623
|
+
}
|
|
1624
|
+
const packageJsonPath2 = join5(absoluteWorkspacePath, "package.json");
|
|
1625
|
+
if (!existsSync2(packageJsonPath2)) {
|
|
1626
|
+
continue;
|
|
1627
|
+
}
|
|
1628
|
+
const rawPackageJson = readFileSync2(packageJsonPath2, "utf8");
|
|
1629
|
+
const packageJson = readPackageJson(packageJsonPath2);
|
|
1630
|
+
manifestsByPath.set(relativePath, {
|
|
1631
|
+
name: packageJson?.name ?? basename(absoluteWorkspacePath),
|
|
1632
|
+
path: relativePath,
|
|
1633
|
+
kind: inferWorkspaceKind(relativePath),
|
|
1634
|
+
directDependencies: parsePackageJson(rawPackageJson)
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
return [...manifestsByPath.values()].sort((a, b) => a.path.localeCompare(b.path));
|
|
1639
|
+
};
|
|
1426
1640
|
var withDefaults = (overrides) => ({
|
|
1427
1641
|
...DEFAULT_EXTERNAL_ANALYSIS_CONFIG,
|
|
1428
1642
|
...overrides
|
|
@@ -1467,7 +1681,8 @@ var analyzeDependencyExposure = async (input, metadataProvider, onProgress) => {
|
|
|
1467
1681
|
input.repositoryPath,
|
|
1468
1682
|
extraction,
|
|
1469
1683
|
metadataByKey,
|
|
1470
|
-
config
|
|
1684
|
+
config,
|
|
1685
|
+
loadWorkspaceDependencyManifests(input.repositoryPath)
|
|
1471
1686
|
);
|
|
1472
1687
|
if (summary.available) {
|
|
1473
1688
|
onProgress?.({
|
|
@@ -1753,7 +1968,7 @@ var analyzeDependencyCandidateFromRegistry = async (input) => {
|
|
|
1753
1968
|
};
|
|
1754
1969
|
|
|
1755
1970
|
// ../reporter/dist/index.js
|
|
1756
|
-
import { basename, posix } from "path";
|
|
1971
|
+
import { basename as basename2, posix } from "path";
|
|
1757
1972
|
var SNAPSHOT_SCHEMA_VERSION = "codesentinel.snapshot.v1";
|
|
1758
1973
|
var REPORT_SCHEMA_VERSION = "codesentinel.report.v1";
|
|
1759
1974
|
var RISK_MODEL_VERSION = "deterministic-v1";
|
|
@@ -2391,13 +2606,97 @@ var repositoryDimensionScores = (snapshot) => {
|
|
|
2391
2606
|
interactions: interactionScore
|
|
2392
2607
|
};
|
|
2393
2608
|
};
|
|
2609
|
+
var workspaceSummary = (snapshot) => ({
|
|
2610
|
+
structural: [...snapshot.analysis.structural.workspaces ?? []].sort(
|
|
2611
|
+
(a, b) => b.incomingEdgeCount + b.outgoingEdgeCount + b.internalEdgeCount - (a.incomingEdgeCount + a.outgoingEdgeCount + a.internalEdgeCount) || b.fileCount - a.fileCount || a.path.localeCompare(b.path)
|
|
2612
|
+
).map((workspace) => ({
|
|
2613
|
+
name: workspace.name,
|
|
2614
|
+
path: workspace.path,
|
|
2615
|
+
kind: workspace.kind,
|
|
2616
|
+
fileCount: workspace.fileCount,
|
|
2617
|
+
internalEdgeCount: workspace.internalEdgeCount,
|
|
2618
|
+
incomingEdgeCount: workspace.incomingEdgeCount,
|
|
2619
|
+
outgoingEdgeCount: workspace.outgoingEdgeCount
|
|
2620
|
+
})),
|
|
2621
|
+
risk: [...snapshot.analysis.risk.workspaceScores].sort((a, b) => b.score - a.score || a.path.localeCompare(b.path)).map((workspace) => ({
|
|
2622
|
+
name: workspace.name,
|
|
2623
|
+
path: workspace.path,
|
|
2624
|
+
kind: workspace.kind,
|
|
2625
|
+
score: workspace.score,
|
|
2626
|
+
normalizedScore: workspace.normalizedScore,
|
|
2627
|
+
fileCount: workspace.fileCount,
|
|
2628
|
+
averageFileRisk: workspace.averageFileRisk,
|
|
2629
|
+
peakFileRisk: workspace.peakFileRisk,
|
|
2630
|
+
internalEdgeCount: workspace.internalEdgeCount,
|
|
2631
|
+
incomingEdgeCount: workspace.incomingEdgeCount,
|
|
2632
|
+
outgoingEdgeCount: workspace.outgoingEdgeCount,
|
|
2633
|
+
topFiles: workspace.topFiles.slice(0, 5).map((file) => ({
|
|
2634
|
+
file: file.file,
|
|
2635
|
+
score: file.score
|
|
2636
|
+
}))
|
|
2637
|
+
})),
|
|
2638
|
+
evolution: snapshot.analysis.evolution.available ? [...snapshot.analysis.evolution.workspaces ?? []].sort(
|
|
2639
|
+
(a, b) => b.recentVolatility - a.recentVolatility || b.churnTotal - a.churnTotal || b.commitCount - a.commitCount || a.path.localeCompare(b.path)
|
|
2640
|
+
).map((workspace) => ({
|
|
2641
|
+
name: workspace.name,
|
|
2642
|
+
path: workspace.path,
|
|
2643
|
+
kind: workspace.kind,
|
|
2644
|
+
fileCount: workspace.fileCount,
|
|
2645
|
+
commitCount: workspace.commitCount,
|
|
2646
|
+
churnTotal: workspace.churnTotal,
|
|
2647
|
+
recentCommitCount: workspace.recentCommitCount,
|
|
2648
|
+
recentVolatility: workspace.recentVolatility,
|
|
2649
|
+
topAuthorShareByCommits: workspace.topAuthorShareByCommits,
|
|
2650
|
+
busFactorByCommits: workspace.busFactorByCommits,
|
|
2651
|
+
hotspotCount: workspace.hotspotCount,
|
|
2652
|
+
topHotspots: workspace.topHotspots.slice(0, 5).map((hotspot) => ({
|
|
2653
|
+
filePath: hotspot.filePath,
|
|
2654
|
+
rank: hotspot.rank,
|
|
2655
|
+
commitCount: hotspot.commitCount,
|
|
2656
|
+
churnTotal: hotspot.churnTotal
|
|
2657
|
+
})),
|
|
2658
|
+
internalCouplingPairCount: workspace.internalCouplingPairCount,
|
|
2659
|
+
incomingCouplingPairCount: workspace.incomingCouplingPairCount,
|
|
2660
|
+
outgoingCouplingPairCount: workspace.outgoingCouplingPairCount
|
|
2661
|
+
})) : [],
|
|
2662
|
+
external: snapshot.analysis.external.available ? [...snapshot.analysis.external.workspaces ?? []].sort(
|
|
2663
|
+
(a, b) => b.highRiskDependencies.length - a.highRiskDependencies.length || b.transitiveExposureDependencies.length - a.transitiveExposureDependencies.length || b.directDependencies - a.directDependencies || a.path.localeCompare(b.path)
|
|
2664
|
+
).map((workspace) => ({
|
|
2665
|
+
name: workspace.name,
|
|
2666
|
+
path: workspace.path,
|
|
2667
|
+
kind: workspace.kind,
|
|
2668
|
+
directDependencies: workspace.directDependencies,
|
|
2669
|
+
directProductionDependencies: workspace.directProductionDependencies,
|
|
2670
|
+
directDevelopmentDependencies: workspace.directDevelopmentDependencies,
|
|
2671
|
+
unresolvedDependencies: [...workspace.unresolvedDependencies].sort(
|
|
2672
|
+
(a, b) => a.localeCompare(b)
|
|
2673
|
+
),
|
|
2674
|
+
dependencyNames: [...workspace.dependencyNames].sort((a, b) => a.localeCompare(b)),
|
|
2675
|
+
sharedDependencies: [...workspace.sharedDependencies].sort((a, b) => a.localeCompare(b)),
|
|
2676
|
+
highRiskDependencies: [...workspace.highRiskDependencies].sort(
|
|
2677
|
+
(a, b) => a.localeCompare(b)
|
|
2678
|
+
),
|
|
2679
|
+
highRiskDevelopmentDependencies: [...workspace.highRiskDevelopmentDependencies].sort(
|
|
2680
|
+
(a, b) => a.localeCompare(b)
|
|
2681
|
+
),
|
|
2682
|
+
transitiveExposureDependencies: [...workspace.transitiveExposureDependencies].sort(
|
|
2683
|
+
(a, b) => a.localeCompare(b)
|
|
2684
|
+
),
|
|
2685
|
+
singleMaintainerDependencies: [...workspace.singleMaintainerDependencies].sort(
|
|
2686
|
+
(a, b) => a.localeCompare(b)
|
|
2687
|
+
),
|
|
2688
|
+
abandonedDependencies: [...workspace.abandonedDependencies].sort(
|
|
2689
|
+
(a, b) => a.localeCompare(b)
|
|
2690
|
+
)
|
|
2691
|
+
})) : []
|
|
2692
|
+
});
|
|
2394
2693
|
var createReport = (snapshot, diff) => {
|
|
2395
2694
|
const external = snapshot.analysis.external;
|
|
2396
2695
|
return {
|
|
2397
2696
|
schemaVersion: REPORT_SCHEMA_VERSION,
|
|
2398
2697
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2399
2698
|
repository: {
|
|
2400
|
-
name:
|
|
2699
|
+
name: basename2(snapshot.analysis.structural.targetPath) || snapshot.analysis.structural.targetPath,
|
|
2401
2700
|
targetPath: snapshot.analysis.structural.targetPath,
|
|
2402
2701
|
riskScore: snapshot.analysis.risk.riskScore,
|
|
2403
2702
|
normalizedScore: snapshot.analysis.risk.normalizedScore,
|
|
@@ -2407,6 +2706,7 @@ var createReport = (snapshot, diff) => {
|
|
|
2407
2706
|
dimensionScores: repositoryDimensionScores(snapshot)
|
|
2408
2707
|
},
|
|
2409
2708
|
health: snapshot.analysis.health,
|
|
2709
|
+
workspaces: workspaceSummary(snapshot),
|
|
2410
2710
|
hotspots: hotspotItems(snapshot),
|
|
2411
2711
|
structural: {
|
|
2412
2712
|
cycleCount: snapshot.analysis.structural.metrics.cycleCount,
|
|
@@ -2480,6 +2780,55 @@ var renderTextDiff = (report) => {
|
|
|
2480
2780
|
` resolvedCycles: ${report.diff.resolvedCycles.join(", ") || "none"}`
|
|
2481
2781
|
];
|
|
2482
2782
|
};
|
|
2783
|
+
var renderTextWorkspaceSummary = (report) => {
|
|
2784
|
+
const workspaceCount = Math.max(
|
|
2785
|
+
report.workspaces.structural.length,
|
|
2786
|
+
report.workspaces.risk.length,
|
|
2787
|
+
report.workspaces.evolution.length,
|
|
2788
|
+
report.workspaces.external.length
|
|
2789
|
+
);
|
|
2790
|
+
if (workspaceCount === 0) {
|
|
2791
|
+
return [];
|
|
2792
|
+
}
|
|
2793
|
+
const lines = ["", "Workspace Summary"];
|
|
2794
|
+
lines.push(" topRisk:");
|
|
2795
|
+
for (const workspace of report.workspaces.risk.slice(0, 5)) {
|
|
2796
|
+
lines.push(
|
|
2797
|
+
` - ${workspace.path} | score=${workspace.score} files=${workspace.fileCount} peakFileRisk=${workspace.peakFileRisk}`
|
|
2798
|
+
);
|
|
2799
|
+
}
|
|
2800
|
+
if (report.workspaces.risk.length === 0) {
|
|
2801
|
+
lines.push(" - none");
|
|
2802
|
+
}
|
|
2803
|
+
lines.push(" structuralCoupling:");
|
|
2804
|
+
for (const workspace of report.workspaces.structural.slice(0, 5)) {
|
|
2805
|
+
lines.push(
|
|
2806
|
+
` - ${workspace.path} | internal=${workspace.internalEdgeCount} incoming=${workspace.incomingEdgeCount} outgoing=${workspace.outgoingEdgeCount}`
|
|
2807
|
+
);
|
|
2808
|
+
}
|
|
2809
|
+
if (report.workspaces.structural.length === 0) {
|
|
2810
|
+
lines.push(" - none");
|
|
2811
|
+
}
|
|
2812
|
+
lines.push(" evolutionHotspots:");
|
|
2813
|
+
for (const workspace of report.workspaces.evolution.slice(0, 5)) {
|
|
2814
|
+
lines.push(
|
|
2815
|
+
` - ${workspace.path} | commits=${workspace.commitCount} churn=${workspace.churnTotal} recentVolatility=${workspace.recentVolatility}`
|
|
2816
|
+
);
|
|
2817
|
+
}
|
|
2818
|
+
if (report.workspaces.evolution.length === 0) {
|
|
2819
|
+
lines.push(" - none");
|
|
2820
|
+
}
|
|
2821
|
+
lines.push(" dependencyExposure:");
|
|
2822
|
+
for (const workspace of report.workspaces.external.slice(0, 5)) {
|
|
2823
|
+
lines.push(
|
|
2824
|
+
` - ${workspace.path} | direct=${workspace.directDependencies} shared=${workspace.sharedDependencies.length} highRisk=${workspace.highRiskDependencies.length} transitiveExposure=${workspace.transitiveExposureDependencies.length}`
|
|
2825
|
+
);
|
|
2826
|
+
}
|
|
2827
|
+
if (report.workspaces.external.length === 0) {
|
|
2828
|
+
lines.push(" - none");
|
|
2829
|
+
}
|
|
2830
|
+
return lines;
|
|
2831
|
+
};
|
|
2483
2832
|
var renderTextReport = (report) => {
|
|
2484
2833
|
const lines = [];
|
|
2485
2834
|
lines.push("Repository Summary");
|
|
@@ -2545,6 +2894,7 @@ var renderTextReport = (report) => {
|
|
|
2545
2894
|
lines.push(` cycleCount: ${report.structural.cycleCount}`);
|
|
2546
2895
|
lines.push(` cycles: ${report.structural.cycles.join(" ; ") || "none"}`);
|
|
2547
2896
|
lines.push(` fragileClusters: ${report.structural.fragileClusters.length}`);
|
|
2897
|
+
lines.push(...renderTextWorkspaceSummary(report));
|
|
2548
2898
|
lines.push("");
|
|
2549
2899
|
lines.push("External Exposure");
|
|
2550
2900
|
if (!report.external.available) {
|
|
@@ -2587,6 +2937,59 @@ var renderMarkdownDiff = (report) => {
|
|
|
2587
2937
|
`- resolvedCycles: ${report.diff.resolvedCycles.map((item) => `\`${item}\``).join(", ") || "none"}`
|
|
2588
2938
|
];
|
|
2589
2939
|
};
|
|
2940
|
+
var renderMarkdownWorkspaceSummary = (report) => {
|
|
2941
|
+
const workspaceCount = Math.max(
|
|
2942
|
+
report.workspaces.structural.length,
|
|
2943
|
+
report.workspaces.risk.length,
|
|
2944
|
+
report.workspaces.evolution.length,
|
|
2945
|
+
report.workspaces.external.length
|
|
2946
|
+
);
|
|
2947
|
+
if (workspaceCount === 0) {
|
|
2948
|
+
return [];
|
|
2949
|
+
}
|
|
2950
|
+
const lines = ["", "## Workspace Summary"];
|
|
2951
|
+
lines.push("- top risk:");
|
|
2952
|
+
if (report.workspaces.risk.length === 0) {
|
|
2953
|
+
lines.push(" - none");
|
|
2954
|
+
} else {
|
|
2955
|
+
for (const workspace of report.workspaces.risk.slice(0, 5)) {
|
|
2956
|
+
lines.push(
|
|
2957
|
+
` - \`${workspace.path}\`: score=\`${workspace.score}\`, files=\`${workspace.fileCount}\`, peak file risk=\`${workspace.peakFileRisk}\``
|
|
2958
|
+
);
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
lines.push("- structural coupling:");
|
|
2962
|
+
if (report.workspaces.structural.length === 0) {
|
|
2963
|
+
lines.push(" - none");
|
|
2964
|
+
} else {
|
|
2965
|
+
for (const workspace of report.workspaces.structural.slice(0, 5)) {
|
|
2966
|
+
lines.push(
|
|
2967
|
+
` - \`${workspace.path}\`: internal=\`${workspace.internalEdgeCount}\`, incoming=\`${workspace.incomingEdgeCount}\`, outgoing=\`${workspace.outgoingEdgeCount}\``
|
|
2968
|
+
);
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
lines.push("- evolution hotspots:");
|
|
2972
|
+
if (report.workspaces.evolution.length === 0) {
|
|
2973
|
+
lines.push(" - none");
|
|
2974
|
+
} else {
|
|
2975
|
+
for (const workspace of report.workspaces.evolution.slice(0, 5)) {
|
|
2976
|
+
lines.push(
|
|
2977
|
+
` - \`${workspace.path}\`: commits=\`${workspace.commitCount}\`, churn=\`${workspace.churnTotal}\`, recent volatility=\`${workspace.recentVolatility}\``
|
|
2978
|
+
);
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2981
|
+
lines.push("- dependency exposure:");
|
|
2982
|
+
if (report.workspaces.external.length === 0) {
|
|
2983
|
+
lines.push(" - none");
|
|
2984
|
+
} else {
|
|
2985
|
+
for (const workspace of report.workspaces.external.slice(0, 5)) {
|
|
2986
|
+
lines.push(
|
|
2987
|
+
` - \`${workspace.path}\`: direct=\`${workspace.directDependencies}\`, shared=\`${workspace.sharedDependencies.length}\`, high risk=\`${workspace.highRiskDependencies.length}\`, transitive exposure=\`${workspace.transitiveExposureDependencies.length}\``
|
|
2988
|
+
);
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
return lines;
|
|
2992
|
+
};
|
|
2590
2993
|
var renderMarkdownReport = (report) => {
|
|
2591
2994
|
const lines = [];
|
|
2592
2995
|
lines.push("# CodeSentinel Report");
|
|
@@ -2658,6 +3061,7 @@ var renderMarkdownReport = (report) => {
|
|
|
2658
3061
|
`- cycles: ${report.structural.cycles.map((cycle) => `\`${cycle}\``).join(", ") || "none"}`
|
|
2659
3062
|
);
|
|
2660
3063
|
lines.push(`- fragile clusters: \`${report.structural.fragileClusters.length}\``);
|
|
3064
|
+
lines.push(...renderMarkdownWorkspaceSummary(report));
|
|
2661
3065
|
lines.push("");
|
|
2662
3066
|
lines.push("## External Exposure Summary");
|
|
2663
3067
|
if (!report.external.available) {
|
|
@@ -2724,7 +3128,7 @@ var formatReport = (report, format) => {
|
|
|
2724
3128
|
|
|
2725
3129
|
// ../governance/dist/index.js
|
|
2726
3130
|
import { mkdirSync, rmSync } from "fs";
|
|
2727
|
-
import { basename as
|
|
3131
|
+
import { basename as basename3, join as join6, resolve as resolve2 } from "path";
|
|
2728
3132
|
import { execFile } from "child_process";
|
|
2729
3133
|
import { promisify } from "util";
|
|
2730
3134
|
var EXIT_CODES = {
|
|
@@ -3245,10 +3649,10 @@ var tryRunGit = async (repositoryPath, args) => {
|
|
|
3245
3649
|
}
|
|
3246
3650
|
};
|
|
3247
3651
|
var buildWorktreePath = (repoRoot, sha) => {
|
|
3248
|
-
const tmpRoot =
|
|
3652
|
+
const tmpRoot = join6(repoRoot, SENTINEL_TMP_DIR, WORKTREE_DIR);
|
|
3249
3653
|
mkdirSync(tmpRoot, { recursive: true });
|
|
3250
3654
|
const baseName = `baseline-${sha.slice(0, 12)}-${process.pid}`;
|
|
3251
|
-
const candidate =
|
|
3655
|
+
const candidate = resolve2(tmpRoot, baseName);
|
|
3252
3656
|
return candidate;
|
|
3253
3657
|
};
|
|
3254
3658
|
var sanitizeSnapshotForWorktree = (snapshot, worktreePath, canonicalPath) => {
|
|
@@ -3281,7 +3685,7 @@ var sanitizeSnapshotForWorktree = (snapshot, worktreePath, canonicalPath) => {
|
|
|
3281
3685
|
};
|
|
3282
3686
|
};
|
|
3283
3687
|
var resolveBaselineSnapshotFromRef = async (input) => {
|
|
3284
|
-
const repositoryPath =
|
|
3688
|
+
const repositoryPath = resolve2(input.repositoryPath);
|
|
3285
3689
|
const ref = input.baselineRef.trim();
|
|
3286
3690
|
if (ref.length === 0) {
|
|
3287
3691
|
throw new BaselineRefResolutionError("baseline-ref cannot be empty");
|
|
@@ -3313,7 +3717,7 @@ var resolveBaselineSnapshotFromRef = async (input) => {
|
|
|
3313
3717
|
}
|
|
3314
3718
|
};
|
|
3315
3719
|
var resolveAutoBaselineRef = async (input) => {
|
|
3316
|
-
const repositoryPath =
|
|
3720
|
+
const repositoryPath = resolve2(input.repositoryPath);
|
|
3317
3721
|
const repoRoot = await runGit(repositoryPath, ["rev-parse", "--show-toplevel"]);
|
|
3318
3722
|
try {
|
|
3319
3723
|
return await resolveAutoBaseline({
|
|
@@ -3336,9 +3740,9 @@ var resolveAutoBaselineRef = async (input) => {
|
|
|
3336
3740
|
};
|
|
3337
3741
|
|
|
3338
3742
|
// src/index.ts
|
|
3339
|
-
import { readFileSync as
|
|
3743
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
3340
3744
|
import { readFile as readFile7, writeFile as writeFile7 } from "fs/promises";
|
|
3341
|
-
import { dirname as dirname3, resolve as
|
|
3745
|
+
import { dirname as dirname3, resolve as resolve7 } from "path";
|
|
3342
3746
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
3343
3747
|
|
|
3344
3748
|
// src/application/format-analyze-output.ts
|
|
@@ -3357,6 +3761,40 @@ var toHealthTier2 = (score) => {
|
|
|
3357
3761
|
}
|
|
3358
3762
|
return "excellent";
|
|
3359
3763
|
};
|
|
3764
|
+
var createWorkspaceSummaryShape = (summary) => ({
|
|
3765
|
+
structuralTop: [...summary.structural.workspaces ?? []].sort(
|
|
3766
|
+
(a, b) => b.incomingEdgeCount + b.outgoingEdgeCount + b.internalEdgeCount - (a.incomingEdgeCount + a.outgoingEdgeCount + a.internalEdgeCount) || b.fileCount - a.fileCount || a.path.localeCompare(b.path)
|
|
3767
|
+
).slice(0, 5).map((workspace) => ({
|
|
3768
|
+
path: workspace.path,
|
|
3769
|
+
fileCount: workspace.fileCount,
|
|
3770
|
+
internalEdgeCount: workspace.internalEdgeCount,
|
|
3771
|
+
incomingEdgeCount: workspace.incomingEdgeCount,
|
|
3772
|
+
outgoingEdgeCount: workspace.outgoingEdgeCount
|
|
3773
|
+
})),
|
|
3774
|
+
riskTop: [...summary.risk.workspaceScores].sort((a, b) => b.score - a.score || a.path.localeCompare(b.path)).slice(0, 5).map((workspace) => ({
|
|
3775
|
+
path: workspace.path,
|
|
3776
|
+
score: workspace.score,
|
|
3777
|
+
fileCount: workspace.fileCount,
|
|
3778
|
+
peakFileRisk: workspace.peakFileRisk
|
|
3779
|
+
})),
|
|
3780
|
+
evolutionTop: summary.evolution.available ? [...summary.evolution.workspaces ?? []].sort(
|
|
3781
|
+
(a, b) => b.recentVolatility - a.recentVolatility || b.churnTotal - a.churnTotal || b.commitCount - a.commitCount || a.path.localeCompare(b.path)
|
|
3782
|
+
).slice(0, 5).map((workspace) => ({
|
|
3783
|
+
path: workspace.path,
|
|
3784
|
+
commitCount: workspace.commitCount,
|
|
3785
|
+
churnTotal: workspace.churnTotal,
|
|
3786
|
+
recentVolatility: workspace.recentVolatility
|
|
3787
|
+
})) : [],
|
|
3788
|
+
dependencyExposureTop: summary.external.available ? [...summary.external.workspaces ?? []].sort(
|
|
3789
|
+
(a, b) => b.highRiskDependencies.length - a.highRiskDependencies.length || b.transitiveExposureDependencies.length - a.transitiveExposureDependencies.length || b.directDependencies - a.directDependencies || a.path.localeCompare(b.path)
|
|
3790
|
+
).slice(0, 5).map((workspace) => ({
|
|
3791
|
+
path: workspace.path,
|
|
3792
|
+
directDependencies: workspace.directDependencies,
|
|
3793
|
+
sharedDependencies: workspace.sharedDependencies.length,
|
|
3794
|
+
highRiskDependencies: workspace.highRiskDependencies.length,
|
|
3795
|
+
transitiveExposureDependencies: workspace.transitiveExposureDependencies.length
|
|
3796
|
+
})) : []
|
|
3797
|
+
});
|
|
3360
3798
|
var createSummaryShape = (summary) => ({
|
|
3361
3799
|
targetPath: summary.structural.targetPath,
|
|
3362
3800
|
structural: summary.structural.metrics,
|
|
@@ -3394,6 +3832,7 @@ var createSummaryShape = (summary) => ({
|
|
|
3394
3832
|
fragileClusterCount: summary.risk.fragileClusters.length,
|
|
3395
3833
|
dependencyAmplificationZoneCount: summary.risk.dependencyAmplificationZones.length
|
|
3396
3834
|
},
|
|
3835
|
+
workspaces: createWorkspaceSummaryShape(summary),
|
|
3397
3836
|
health: {
|
|
3398
3837
|
healthScore: summary.health.healthScore,
|
|
3399
3838
|
healthTier: toHealthTier2(summary.health.healthScore),
|
|
@@ -3748,11 +4187,11 @@ var parseLogLevel = (value) => {
|
|
|
3748
4187
|
import { spawn } from "child_process";
|
|
3749
4188
|
import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
3750
4189
|
import { homedir as homedir2 } from "os";
|
|
3751
|
-
import { dirname, join as
|
|
4190
|
+
import { dirname, join as join7 } from "path";
|
|
3752
4191
|
import { stderr, stdin } from "process";
|
|
3753
4192
|
import { clearScreenDown, cursorTo, emitKeypressEvents } from "readline";
|
|
3754
4193
|
var UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
3755
|
-
var UPDATE_CACHE_PATH =
|
|
4194
|
+
var UPDATE_CACHE_PATH = join7(homedir2(), ".cache", "codesentinel", "update-check.json");
|
|
3756
4195
|
var SEMVER_PATTERN = /^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(?:-(?<prerelease>[0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
3757
4196
|
var ANSI = {
|
|
3758
4197
|
reset: "\x1B[0m",
|
|
@@ -3984,7 +4423,7 @@ var promptInstall = async (packageName, latestVersion, currentVersion) => {
|
|
|
3984
4423
|
);
|
|
3985
4424
|
return "skip";
|
|
3986
4425
|
}
|
|
3987
|
-
return await new Promise((
|
|
4426
|
+
return await new Promise((resolve8) => {
|
|
3988
4427
|
emitKeypressEvents(stdin);
|
|
3989
4428
|
let selectedIndex = 0;
|
|
3990
4429
|
const previousRawMode = stdin.isRaw;
|
|
@@ -4009,7 +4448,7 @@ var promptInstall = async (packageName, latestVersion, currentVersion) => {
|
|
|
4009
4448
|
} else {
|
|
4010
4449
|
stderr.write("\n");
|
|
4011
4450
|
}
|
|
4012
|
-
|
|
4451
|
+
resolve8(choice);
|
|
4013
4452
|
};
|
|
4014
4453
|
const onKeypress = (_str, key) => {
|
|
4015
4454
|
if (key.ctrl === true && key.name === "c") {
|
|
@@ -4203,7 +4642,7 @@ var promptSelection = async (currentVersion, actions) => {
|
|
|
4203
4642
|
if (!stdin2.isTTY || !stderr2.isTTY || typeof stdin2.setRawMode !== "function") {
|
|
4204
4643
|
return "exit";
|
|
4205
4644
|
}
|
|
4206
|
-
return await new Promise((
|
|
4645
|
+
return await new Promise((resolve8) => {
|
|
4207
4646
|
emitKeypressEvents2(stdin2);
|
|
4208
4647
|
let selectedIndex = 0;
|
|
4209
4648
|
const previousRawMode = stdin2.isRaw;
|
|
@@ -4218,7 +4657,7 @@ var promptSelection = async (currentVersion, actions) => {
|
|
|
4218
4657
|
stdin2.setRawMode(previousRawMode);
|
|
4219
4658
|
clearTerminal();
|
|
4220
4659
|
showCursor2();
|
|
4221
|
-
|
|
4660
|
+
resolve8(selection);
|
|
4222
4661
|
};
|
|
4223
4662
|
const onKeypress = (_str, key) => {
|
|
4224
4663
|
if (key.ctrl === true && key.name === "c") {
|
|
@@ -4311,7 +4750,7 @@ var waitForReturnToMenu = async () => {
|
|
|
4311
4750
|
}
|
|
4312
4751
|
stderr2.write(`
|
|
4313
4752
|
${PROMPT_PADDING}Press enter to return to the menu...`);
|
|
4314
|
-
await new Promise((
|
|
4753
|
+
await new Promise((resolve8) => {
|
|
4315
4754
|
emitKeypressEvents2(stdin2);
|
|
4316
4755
|
const previousRawMode = stdin2.isRaw;
|
|
4317
4756
|
const cleanup = () => {
|
|
@@ -4320,7 +4759,7 @@ ${PROMPT_PADDING}Press enter to return to the menu...`);
|
|
|
4320
4759
|
stdin2.setRawMode(previousRawMode);
|
|
4321
4760
|
showCursor2();
|
|
4322
4761
|
stderr2.write("\n");
|
|
4323
|
-
|
|
4762
|
+
resolve8();
|
|
4324
4763
|
};
|
|
4325
4764
|
const onKeypress = (_str, key) => {
|
|
4326
4765
|
if (key.ctrl === true && key.name === "c") {
|
|
@@ -4338,7 +4777,7 @@ ${PROMPT_PADDING}Press enter to return to the menu...`);
|
|
|
4338
4777
|
});
|
|
4339
4778
|
};
|
|
4340
4779
|
var runCliCommand = async (scriptPath2, args) => {
|
|
4341
|
-
return await new Promise((
|
|
4780
|
+
return await new Promise((resolve8, reject) => {
|
|
4342
4781
|
const child = spawn2(process.execPath, [...process.execArgv, scriptPath2, ...args], {
|
|
4343
4782
|
stdio: ["inherit", "pipe", "pipe"],
|
|
4344
4783
|
env: {
|
|
@@ -4352,7 +4791,7 @@ var runCliCommand = async (scriptPath2, args) => {
|
|
|
4352
4791
|
reject(error);
|
|
4353
4792
|
});
|
|
4354
4793
|
child.on("close", (code) => {
|
|
4355
|
-
|
|
4794
|
+
resolve8(code ?? 1);
|
|
4356
4795
|
});
|
|
4357
4796
|
});
|
|
4358
4797
|
};
|
|
@@ -4423,14 +4862,14 @@ ${PROMPT_PADDING}Command exited with code ${exitCode}.
|
|
|
4423
4862
|
};
|
|
4424
4863
|
|
|
4425
4864
|
// src/application/run-analyze-command.ts
|
|
4426
|
-
import { resolve as
|
|
4865
|
+
import { resolve as resolve4 } from "path";
|
|
4427
4866
|
|
|
4428
4867
|
// ../code-graph/dist/index.js
|
|
4429
|
-
import { existsSync as
|
|
4430
|
-
import { extname, isAbsolute, join as
|
|
4868
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
4869
|
+
import { extname, isAbsolute, join as join8, relative as relative2, resolve as resolve3 } from "path";
|
|
4431
4870
|
import * as ts from "typescript";
|
|
4432
|
-
import { existsSync as existsSync22, readdirSync, readFileSync as readFileSync22, statSync } from "fs";
|
|
4433
|
-
import { basename as
|
|
4871
|
+
import { existsSync as existsSync22, readdirSync as readdirSync2, readFileSync as readFileSync22, statSync as statSync2 } from "fs";
|
|
4872
|
+
import { basename as basename4, join as join22, relative as relative22, resolve as resolve22 } from "path";
|
|
4434
4873
|
var edgeKey = (from, to) => `${from}\0${to}`;
|
|
4435
4874
|
var createGraphData = (nodes, rawEdges) => {
|
|
4436
4875
|
const sortedNodes = [...nodes].sort((a, b) => a.id.localeCompare(b.id));
|
|
@@ -4798,10 +5237,10 @@ var IGNORED_SEGMENTS = /* @__PURE__ */ new Set([
|
|
|
4798
5237
|
".cache",
|
|
4799
5238
|
"out"
|
|
4800
5239
|
]);
|
|
4801
|
-
var
|
|
4802
|
-
var
|
|
5240
|
+
var normalizePath2 = (pathValue) => pathValue.replaceAll("\\", "/");
|
|
5241
|
+
var readPackageJson2 = (packageJsonPath2) => {
|
|
4803
5242
|
try {
|
|
4804
|
-
return JSON.parse(
|
|
5243
|
+
return JSON.parse(readFileSync3(packageJsonPath2, "utf8"));
|
|
4805
5244
|
} catch {
|
|
4806
5245
|
return null;
|
|
4807
5246
|
}
|
|
@@ -4811,11 +5250,11 @@ var isProjectSourceFile = (filePath, projectRoot) => {
|
|
|
4811
5250
|
if (!SOURCE_EXTENSIONS.has(extension)) {
|
|
4812
5251
|
return false;
|
|
4813
5252
|
}
|
|
4814
|
-
const relativePath =
|
|
5253
|
+
const relativePath = relative2(projectRoot, filePath);
|
|
4815
5254
|
if (relativePath.startsWith("..")) {
|
|
4816
5255
|
return false;
|
|
4817
5256
|
}
|
|
4818
|
-
const normalizedRelativePath =
|
|
5257
|
+
const normalizedRelativePath = normalizePath2(relativePath);
|
|
4819
5258
|
const segments = normalizedRelativePath.split("/");
|
|
4820
5259
|
return !segments.some((segment) => IGNORED_SEGMENTS.has(segment));
|
|
4821
5260
|
};
|
|
@@ -4826,7 +5265,7 @@ var discoverSourceFilesByScan = (projectRoot) => {
|
|
|
4826
5265
|
SCAN_EXCLUDES,
|
|
4827
5266
|
SCAN_INCLUDES
|
|
4828
5267
|
);
|
|
4829
|
-
return files.map((filePath) =>
|
|
5268
|
+
return files.map((filePath) => resolve3(filePath));
|
|
4830
5269
|
};
|
|
4831
5270
|
var parseTsConfigFile = (configPath) => {
|
|
4832
5271
|
const parsedCommandLine = ts.getParsedCommandLineOfConfigFile(
|
|
@@ -4857,7 +5296,7 @@ var collectFilesFromTsConfigGraph = (projectRoot) => {
|
|
|
4857
5296
|
const collectedFiles = /* @__PURE__ */ new Set();
|
|
4858
5297
|
let rootOptions = null;
|
|
4859
5298
|
const visitConfig = (configPath) => {
|
|
4860
|
-
const absoluteConfigPath =
|
|
5299
|
+
const absoluteConfigPath = resolve3(configPath);
|
|
4861
5300
|
if (visitedConfigPaths.has(absoluteConfigPath)) {
|
|
4862
5301
|
return;
|
|
4863
5302
|
}
|
|
@@ -4867,10 +5306,10 @@ var collectFilesFromTsConfigGraph = (projectRoot) => {
|
|
|
4867
5306
|
rootOptions = parsed.options;
|
|
4868
5307
|
}
|
|
4869
5308
|
for (const filePath of parsed.fileNames) {
|
|
4870
|
-
collectedFiles.add(
|
|
5309
|
+
collectedFiles.add(resolve3(filePath));
|
|
4871
5310
|
}
|
|
4872
5311
|
for (const reference of parsed.projectReferences ?? []) {
|
|
4873
|
-
const referencePath =
|
|
5312
|
+
const referencePath = resolve3(reference.path);
|
|
4874
5313
|
const referenceConfigPath = ts.sys.directoryExists(referencePath) ? ts.findConfigFile(
|
|
4875
5314
|
referencePath,
|
|
4876
5315
|
(filePath) => ts.sys.fileExists(filePath),
|
|
@@ -5013,7 +5452,7 @@ var parseWorkspaceSpecifier = (specifier, workspaceNames) => {
|
|
|
5013
5452
|
var expandFileCandidates = (pathWithoutExtension) => [
|
|
5014
5453
|
pathWithoutExtension,
|
|
5015
5454
|
...[...SOURCE_EXTENSIONS].map((extension) => `${pathWithoutExtension}${extension}`),
|
|
5016
|
-
...[...SOURCE_EXTENSIONS].map((extension) =>
|
|
5455
|
+
...[...SOURCE_EXTENSIONS].map((extension) => join8(pathWithoutExtension, `index${extension}`))
|
|
5017
5456
|
];
|
|
5018
5457
|
var isExportArray = (value) => Array.isArray(value);
|
|
5019
5458
|
var isExportMap = (value) => typeof value !== "string" && !isExportArray(value);
|
|
@@ -5074,8 +5513,8 @@ var collectPackageExportCandidates = (packageJson, subpath) => {
|
|
|
5074
5513
|
var resolveFirstAnalyzedCandidate = (candidates, sourceFilePathSet) => {
|
|
5075
5514
|
for (const candidate of candidates) {
|
|
5076
5515
|
for (const expanded of expandFileCandidates(candidate)) {
|
|
5077
|
-
const normalized =
|
|
5078
|
-
if (sourceFilePathSet.has(normalized) &&
|
|
5516
|
+
const normalized = normalizePath2(expanded);
|
|
5517
|
+
if (sourceFilePathSet.has(normalized) && existsSync3(normalized)) {
|
|
5079
5518
|
return normalized;
|
|
5080
5519
|
}
|
|
5081
5520
|
}
|
|
@@ -5094,8 +5533,8 @@ var createWorkspaceResolver = (projectRoot, workspaces, sourceFilePathSet) => {
|
|
|
5094
5533
|
if (workspace === void 0) {
|
|
5095
5534
|
return void 0;
|
|
5096
5535
|
}
|
|
5097
|
-
const workspaceRoot =
|
|
5098
|
-
const packageJson =
|
|
5536
|
+
const workspaceRoot = resolve3(projectRoot, workspace.path);
|
|
5537
|
+
const packageJson = readPackageJson2(join8(workspaceRoot, "package.json"));
|
|
5099
5538
|
const candidates = parsed.subpath === null ? [
|
|
5100
5539
|
...collectPackageExportCandidates(packageJson, null),
|
|
5101
5540
|
packageJson?.source,
|
|
@@ -5108,10 +5547,10 @@ var createWorkspaceResolver = (projectRoot, workspaces, sourceFilePathSet) => {
|
|
|
5108
5547
|
].filter((candidate) => candidate !== void 0) : [
|
|
5109
5548
|
...collectPackageExportCandidates(packageJson, parsed.subpath),
|
|
5110
5549
|
parsed.subpath,
|
|
5111
|
-
|
|
5550
|
+
join8("src", parsed.subpath)
|
|
5112
5551
|
];
|
|
5113
5552
|
return resolveFirstAnalyzedCandidate(
|
|
5114
|
-
candidates.map((candidate) =>
|
|
5553
|
+
candidates.map((candidate) => resolve3(workspaceRoot, candidate)),
|
|
5115
5554
|
sourceFilePathSet
|
|
5116
5555
|
);
|
|
5117
5556
|
};
|
|
@@ -5140,7 +5579,7 @@ var createTsPathAliasResolver = (projectRoot, options, sourceFilePathSet) => {
|
|
|
5140
5579
|
}
|
|
5141
5580
|
const replacement = hasWildcard ? specifier.slice(prefix.length, specifier.length - suffix.length) : "";
|
|
5142
5581
|
const candidates = substitutions.map(
|
|
5143
|
-
(substitution) =>
|
|
5582
|
+
(substitution) => resolve3(baseUrl, hasWildcard ? substitution.replaceAll("*", replacement) : substitution)
|
|
5144
5583
|
);
|
|
5145
5584
|
const resolved = resolveFirstAnalyzedCandidate(candidates, sourceFilePathSet);
|
|
5146
5585
|
if (resolved !== void 0) {
|
|
@@ -5151,10 +5590,10 @@ var createTsPathAliasResolver = (projectRoot, options, sourceFilePathSet) => {
|
|
|
5151
5590
|
};
|
|
5152
5591
|
};
|
|
5153
5592
|
var parseTypescriptProject = (projectPath, onProgress, workspaces = []) => {
|
|
5154
|
-
const projectRoot = isAbsolute(projectPath) ? projectPath :
|
|
5593
|
+
const projectRoot = isAbsolute(projectPath) ? projectPath : resolve3(projectPath);
|
|
5155
5594
|
const { fileNames, options, tsconfigCount, usedFallbackScan } = parseTsConfig(projectRoot);
|
|
5156
5595
|
onProgress?.({ stage: "config_resolved", tsconfigCount, usedFallbackScan });
|
|
5157
|
-
const sourceFilePaths = fileNames.filter((filePath) => isProjectSourceFile(filePath, projectRoot)).map((filePath) =>
|
|
5596
|
+
const sourceFilePaths = fileNames.filter((filePath) => isProjectSourceFile(filePath, projectRoot)).map((filePath) => normalizePath2(resolve3(filePath)));
|
|
5158
5597
|
const uniqueSourceFilePaths = [...new Set(sourceFilePaths)].sort((a, b) => a.localeCompare(b));
|
|
5159
5598
|
const sourceFilePathSet = new Set(uniqueSourceFilePaths);
|
|
5160
5599
|
onProgress?.({ stage: "files_discovered", totalSourceFiles: uniqueSourceFilePaths.length });
|
|
@@ -5165,7 +5604,7 @@ var parseTypescriptProject = (projectPath, onProgress, workspaces = []) => {
|
|
|
5165
5604
|
onProgress?.({ stage: "program_created", totalSourceFiles: uniqueSourceFilePaths.length });
|
|
5166
5605
|
const nodeByAbsolutePath = /* @__PURE__ */ new Map();
|
|
5167
5606
|
for (const sourcePath of uniqueSourceFilePaths) {
|
|
5168
|
-
const relativePath =
|
|
5607
|
+
const relativePath = normalizePath2(relative2(projectRoot, sourcePath));
|
|
5169
5608
|
const nodeId = relativePath;
|
|
5170
5609
|
nodeByAbsolutePath.set(sourcePath, {
|
|
5171
5610
|
id: nodeId,
|
|
@@ -5202,7 +5641,7 @@ var parseTypescriptProject = (projectPath, onProgress, workspaces = []) => {
|
|
|
5202
5641
|
ts.sys
|
|
5203
5642
|
).resolvedModule;
|
|
5204
5643
|
if (resolved !== void 0) {
|
|
5205
|
-
resolvedPath =
|
|
5644
|
+
resolvedPath = normalizePath2(resolve3(resolved.resolvedFileName));
|
|
5206
5645
|
}
|
|
5207
5646
|
if (resolvedPath === void 0 || !sourceFilePathSet.has(resolvedPath)) {
|
|
5208
5647
|
resolvedPath = resolveTsPathAlias(specifier);
|
|
@@ -5237,16 +5676,16 @@ var parseTypescriptProject = (projectPath, onProgress, workspaces = []) => {
|
|
|
5237
5676
|
edges
|
|
5238
5677
|
};
|
|
5239
5678
|
};
|
|
5240
|
-
var
|
|
5241
|
-
var
|
|
5242
|
-
var
|
|
5679
|
+
var normalizePath22 = (pathValue) => pathValue.replaceAll("\\", "/");
|
|
5680
|
+
var stripQuotes3 = (value) => value.replace(/^['"]|['"]$/g, "");
|
|
5681
|
+
var readPackageJson22 = (path) => {
|
|
5243
5682
|
try {
|
|
5244
5683
|
return JSON.parse(readFileSync22(path, "utf8"));
|
|
5245
5684
|
} catch {
|
|
5246
5685
|
return null;
|
|
5247
5686
|
}
|
|
5248
5687
|
};
|
|
5249
|
-
var
|
|
5688
|
+
var inferWorkspaceKind2 = (workspacePath) => {
|
|
5250
5689
|
const segments = workspacePath.split("/");
|
|
5251
5690
|
const first = segments[0] ?? "";
|
|
5252
5691
|
if (first === "apps" || first === "app") {
|
|
@@ -5266,8 +5705,8 @@ var inferWorkspaceKind = (workspacePath) => {
|
|
|
5266
5705
|
}
|
|
5267
5706
|
return "unknown";
|
|
5268
5707
|
};
|
|
5269
|
-
var
|
|
5270
|
-
const packageJson =
|
|
5708
|
+
var readWorkspacePatternsFromPackageJson2 = (projectRoot) => {
|
|
5709
|
+
const packageJson = readPackageJson22(join22(projectRoot, "package.json"));
|
|
5271
5710
|
if (packageJson?.workspaces === void 0) {
|
|
5272
5711
|
return [];
|
|
5273
5712
|
}
|
|
@@ -5279,7 +5718,7 @@ var readWorkspacePatternsFromPackageJson = (projectRoot) => {
|
|
|
5279
5718
|
const workspaceObject = workspaces;
|
|
5280
5719
|
return workspaceObject.packages ?? [];
|
|
5281
5720
|
};
|
|
5282
|
-
var
|
|
5721
|
+
var readWorkspacePatternsFromPnpmWorkspace2 = (projectRoot) => {
|
|
5283
5722
|
const workspacePath = join22(projectRoot, "pnpm-workspace.yaml");
|
|
5284
5723
|
if (!existsSync22(workspacePath)) {
|
|
5285
5724
|
return [];
|
|
@@ -5301,13 +5740,13 @@ var readWorkspacePatternsFromPnpmWorkspace = (projectRoot) => {
|
|
|
5301
5740
|
}
|
|
5302
5741
|
const match = trimmed.match(/^-\s+(.+)$/);
|
|
5303
5742
|
if (match?.[1] !== void 0) {
|
|
5304
|
-
patterns.push(
|
|
5743
|
+
patterns.push(stripQuotes3(match[1].trim()));
|
|
5305
5744
|
}
|
|
5306
5745
|
}
|
|
5307
5746
|
return patterns;
|
|
5308
5747
|
};
|
|
5309
|
-
var
|
|
5310
|
-
const segments =
|
|
5748
|
+
var expandPattern2 = (projectRoot, pattern) => {
|
|
5749
|
+
const segments = normalizePath22(pattern).split("/").filter((segment) => segment.length > 0);
|
|
5311
5750
|
let current = [projectRoot];
|
|
5312
5751
|
for (const segment of segments) {
|
|
5313
5752
|
const next = [];
|
|
@@ -5316,7 +5755,7 @@ var expandPattern = (projectRoot, pattern) => {
|
|
|
5316
5755
|
if (!existsSync22(directory)) {
|
|
5317
5756
|
continue;
|
|
5318
5757
|
}
|
|
5319
|
-
for (const entry of
|
|
5758
|
+
for (const entry of readdirSync2(directory, { withFileTypes: true })) {
|
|
5320
5759
|
if (entry.isDirectory()) {
|
|
5321
5760
|
next.push(join22(directory, entry.name));
|
|
5322
5761
|
}
|
|
@@ -5325,7 +5764,7 @@ var expandPattern = (projectRoot, pattern) => {
|
|
|
5325
5764
|
} else {
|
|
5326
5765
|
for (const directory of current) {
|
|
5327
5766
|
const candidate = join22(directory, segment);
|
|
5328
|
-
if (existsSync22(candidate) &&
|
|
5767
|
+
if (existsSync22(candidate) && statSync2(candidate).isDirectory()) {
|
|
5329
5768
|
next.push(candidate);
|
|
5330
5769
|
}
|
|
5331
5770
|
}
|
|
@@ -5336,18 +5775,18 @@ var expandPattern = (projectRoot, pattern) => {
|
|
|
5336
5775
|
};
|
|
5337
5776
|
var discoverWorkspacePackages = (projectRoot) => {
|
|
5338
5777
|
const absoluteRoot = resolve22(projectRoot);
|
|
5339
|
-
const packageJsonPatterns =
|
|
5340
|
-
const pnpmPatterns =
|
|
5778
|
+
const packageJsonPatterns = readWorkspacePatternsFromPackageJson2(absoluteRoot);
|
|
5779
|
+
const pnpmPatterns = readWorkspacePatternsFromPnpmWorkspace2(absoluteRoot);
|
|
5341
5780
|
const patterns = packageJsonPatterns.length > 0 ? packageJsonPatterns : pnpmPatterns;
|
|
5342
5781
|
const includePatterns = patterns.filter((pattern) => !pattern.startsWith("!"));
|
|
5343
5782
|
const excludePatterns = patterns.filter((pattern) => pattern.startsWith("!")).map((pattern) => pattern.slice(1));
|
|
5344
5783
|
const excludedPaths = new Set(
|
|
5345
|
-
excludePatterns.flatMap((pattern) =>
|
|
5784
|
+
excludePatterns.flatMap((pattern) => expandPattern2(absoluteRoot, pattern)).map((path) => normalizePath22(relative22(absoluteRoot, path)))
|
|
5346
5785
|
);
|
|
5347
5786
|
const packagesByPath = /* @__PURE__ */ new Map();
|
|
5348
5787
|
for (const pattern of includePatterns) {
|
|
5349
|
-
for (const absoluteWorkspacePath of
|
|
5350
|
-
const relativePath =
|
|
5788
|
+
for (const absoluteWorkspacePath of expandPattern2(absoluteRoot, pattern)) {
|
|
5789
|
+
const relativePath = normalizePath22(relative22(absoluteRoot, absoluteWorkspacePath));
|
|
5351
5790
|
if (relativePath.length === 0 || relativePath.startsWith("..") || excludedPaths.has(relativePath)) {
|
|
5352
5791
|
continue;
|
|
5353
5792
|
}
|
|
@@ -5355,11 +5794,11 @@ var discoverWorkspacePackages = (projectRoot) => {
|
|
|
5355
5794
|
if (!existsSync22(packageJsonPath2)) {
|
|
5356
5795
|
continue;
|
|
5357
5796
|
}
|
|
5358
|
-
const packageJson =
|
|
5797
|
+
const packageJson = readPackageJson22(packageJsonPath2);
|
|
5359
5798
|
packagesByPath.set(relativePath, {
|
|
5360
|
-
name: packageJson?.name ??
|
|
5799
|
+
name: packageJson?.name ?? basename4(absoluteWorkspacePath),
|
|
5361
5800
|
path: relativePath,
|
|
5362
|
-
kind:
|
|
5801
|
+
kind: inferWorkspaceKind2(relativePath)
|
|
5363
5802
|
});
|
|
5364
5803
|
}
|
|
5365
5804
|
}
|
|
@@ -5794,6 +6233,101 @@ var analyzeRepositoryEvolution = (input, historyProvider, onProgress) => {
|
|
|
5794
6233
|
onProgress?.({ stage: "analysis_completed", available: summary.available });
|
|
5795
6234
|
return summary;
|
|
5796
6235
|
};
|
|
6236
|
+
var normalizePath3 = (pathValue) => pathValue.replaceAll("\\", "/");
|
|
6237
|
+
var findWorkspaceForFile2 = (filePath, workspaces) => {
|
|
6238
|
+
let match = null;
|
|
6239
|
+
for (const workspace of workspaces) {
|
|
6240
|
+
if (filePath === workspace.path || filePath.startsWith(`${workspace.path}/`)) {
|
|
6241
|
+
if (match === null || workspace.path.length > match.path.length) {
|
|
6242
|
+
match = workspace;
|
|
6243
|
+
}
|
|
6244
|
+
}
|
|
6245
|
+
}
|
|
6246
|
+
return match;
|
|
6247
|
+
};
|
|
6248
|
+
var enrichEvolutionSummaryWithWorkspaces = (structural, evolution) => {
|
|
6249
|
+
if (!evolution.available || structural.workspaces === void 0) {
|
|
6250
|
+
return evolution;
|
|
6251
|
+
}
|
|
6252
|
+
const workspaces = structural.workspaces;
|
|
6253
|
+
const workspaceByFile = /* @__PURE__ */ new Map();
|
|
6254
|
+
const structuralWorkspacePaths = new Set(workspaces.map((workspace) => workspace.path));
|
|
6255
|
+
for (const file of evolution.files) {
|
|
6256
|
+
const workspace = findWorkspaceForFile2(normalizePath3(file.filePath), workspaces);
|
|
6257
|
+
if (workspace !== null) {
|
|
6258
|
+
workspaceByFile.set(normalizePath3(file.filePath), workspace);
|
|
6259
|
+
}
|
|
6260
|
+
}
|
|
6261
|
+
const internalCouplingPairCountByWorkspace = /* @__PURE__ */ new Map();
|
|
6262
|
+
const incomingCouplingPairCountByWorkspace = /* @__PURE__ */ new Map();
|
|
6263
|
+
const outgoingCouplingPairCountByWorkspace = /* @__PURE__ */ new Map();
|
|
6264
|
+
for (const pair of evolution.coupling.pairs) {
|
|
6265
|
+
const fromWorkspace = workspaceByFile.get(normalizePath3(pair.fileA));
|
|
6266
|
+
const toWorkspace = workspaceByFile.get(normalizePath3(pair.fileB));
|
|
6267
|
+
if (fromWorkspace === void 0 && toWorkspace === void 0) {
|
|
6268
|
+
continue;
|
|
6269
|
+
}
|
|
6270
|
+
if (fromWorkspace?.path === toWorkspace?.path && fromWorkspace !== void 0) {
|
|
6271
|
+
internalCouplingPairCountByWorkspace.set(
|
|
6272
|
+
fromWorkspace.path,
|
|
6273
|
+
(internalCouplingPairCountByWorkspace.get(fromWorkspace.path) ?? 0) + 1
|
|
6274
|
+
);
|
|
6275
|
+
continue;
|
|
6276
|
+
}
|
|
6277
|
+
if (fromWorkspace !== void 0) {
|
|
6278
|
+
outgoingCouplingPairCountByWorkspace.set(
|
|
6279
|
+
fromWorkspace.path,
|
|
6280
|
+
(outgoingCouplingPairCountByWorkspace.get(fromWorkspace.path) ?? 0) + 1
|
|
6281
|
+
);
|
|
6282
|
+
}
|
|
6283
|
+
if (toWorkspace !== void 0) {
|
|
6284
|
+
incomingCouplingPairCountByWorkspace.set(
|
|
6285
|
+
toWorkspace.path,
|
|
6286
|
+
(incomingCouplingPairCountByWorkspace.get(toWorkspace.path) ?? 0) + 1
|
|
6287
|
+
);
|
|
6288
|
+
}
|
|
6289
|
+
}
|
|
6290
|
+
const workspaceSummaries = workspaces.filter((workspace) => structuralWorkspacePaths.has(workspace.path)).map((workspace) => {
|
|
6291
|
+
const files = evolution.files.filter(
|
|
6292
|
+
(file) => workspaceByFile.get(normalizePath3(file.filePath))?.path === workspace.path
|
|
6293
|
+
).sort((a, b) => a.filePath.localeCompare(b.filePath));
|
|
6294
|
+
const commitCount = files.reduce((sum, file) => sum + file.commitCount, 0);
|
|
6295
|
+
const recentCommitCount = files.reduce((sum, file) => sum + file.recentCommitCount, 0);
|
|
6296
|
+
const churnAdded = files.reduce((sum, file) => sum + file.churnAdded, 0);
|
|
6297
|
+
const churnDeleted = files.reduce((sum, file) => sum + file.churnDeleted, 0);
|
|
6298
|
+
const churnTotal = churnAdded + churnDeleted;
|
|
6299
|
+
const topAuthorShareByCommits = files.length === 0 ? 0 : Math.max(...files.map((file) => file.topAuthorShareByCommits));
|
|
6300
|
+
const busFactorByCommits = files.length === 0 ? 0 : Math.min(...files.map((file) => file.busFactorByCommits));
|
|
6301
|
+
const topHotspots = evolution.hotspots.filter(
|
|
6302
|
+
(hotspot) => workspaceByFile.get(normalizePath3(hotspot.filePath))?.path === workspace.path
|
|
6303
|
+
);
|
|
6304
|
+
return {
|
|
6305
|
+
name: workspace.name,
|
|
6306
|
+
path: workspace.path,
|
|
6307
|
+
kind: workspace.kind,
|
|
6308
|
+
fileCount: files.length,
|
|
6309
|
+
commitCount,
|
|
6310
|
+
churnAdded,
|
|
6311
|
+
churnDeleted,
|
|
6312
|
+
churnTotal,
|
|
6313
|
+
recentCommitCount,
|
|
6314
|
+
recentVolatility: commitCount === 0 ? 0 : Number((recentCommitCount / commitCount).toFixed(4)),
|
|
6315
|
+
topAuthorShareByCommits,
|
|
6316
|
+
busFactorByCommits,
|
|
6317
|
+
hotspotCount: topHotspots.length,
|
|
6318
|
+
topHotspots,
|
|
6319
|
+
internalCouplingPairCount: internalCouplingPairCountByWorkspace.get(workspace.path) ?? 0,
|
|
6320
|
+
incomingCouplingPairCount: incomingCouplingPairCountByWorkspace.get(workspace.path) ?? 0,
|
|
6321
|
+
outgoingCouplingPairCount: outgoingCouplingPairCountByWorkspace.get(workspace.path) ?? 0
|
|
6322
|
+
};
|
|
6323
|
+
}).sort(
|
|
6324
|
+
(a, b) => b.commitCount - a.commitCount || b.churnTotal - a.churnTotal || a.path.localeCompare(b.path)
|
|
6325
|
+
);
|
|
6326
|
+
return {
|
|
6327
|
+
...evolution,
|
|
6328
|
+
workspaces: workspaceSummaries
|
|
6329
|
+
};
|
|
6330
|
+
};
|
|
5797
6331
|
var GitCommandError = class extends Error {
|
|
5798
6332
|
args;
|
|
5799
6333
|
constructor(message, args) {
|
|
@@ -6070,9 +6604,9 @@ var createDimensionTrace = (dimension, health, factors) => ({
|
|
|
6070
6604
|
factors: factors.map((factor) => toFactorTrace(factor))
|
|
6071
6605
|
});
|
|
6072
6606
|
var filePaths = (structural) => structural.files.map((file) => file.relativePath);
|
|
6073
|
-
var
|
|
6607
|
+
var normalizePath4 = (value) => value.replaceAll("\\", "/").toLowerCase();
|
|
6074
6608
|
var isTestPath = (path) => {
|
|
6075
|
-
const normalized =
|
|
6609
|
+
const normalized = normalizePath4(path);
|
|
6076
6610
|
return normalized.includes("/__tests__/") || normalized.includes("/tests/") || normalized.includes("/test/") || normalized.includes(".test.") || normalized.includes(".spec.");
|
|
6077
6611
|
};
|
|
6078
6612
|
var isSourcePath = (path) => {
|
|
@@ -6082,7 +6616,7 @@ var isSourcePath = (path) => {
|
|
|
6082
6616
|
return !isTestPath(path);
|
|
6083
6617
|
};
|
|
6084
6618
|
var hasTestDirectory = (paths) => paths.some((path) => {
|
|
6085
|
-
const normalized =
|
|
6619
|
+
const normalized = normalizePath4(path);
|
|
6086
6620
|
return normalized.includes("/__tests__/") || normalized.includes("/tests/") || normalized.includes("/test/");
|
|
6087
6621
|
});
|
|
6088
6622
|
var moduleNameFromPath = (path) => {
|
|
@@ -6972,7 +7506,7 @@ var normalizeWithScale = (value, scale) => {
|
|
|
6972
7506
|
}
|
|
6973
7507
|
return toUnitInterval((value - scale.lower) / (scale.upper - scale.lower));
|
|
6974
7508
|
};
|
|
6975
|
-
var
|
|
7509
|
+
var normalizePath5 = (path) => path.replaceAll("\\", "/");
|
|
6976
7510
|
var computeAggregatorAttenuation = (input) => {
|
|
6977
7511
|
const { fanIn, fanOut, inCycle, evolutionMetrics, config } = input;
|
|
6978
7512
|
if (!config.enabled || inCycle > 0) {
|
|
@@ -7047,7 +7581,7 @@ var computeEvolutionHistoryConfidence = (structural, evolution, evolutionByFile)
|
|
|
7047
7581
|
}
|
|
7048
7582
|
let coveredFiles = 0;
|
|
7049
7583
|
for (const file of structural.files) {
|
|
7050
|
-
if (evolutionByFile.has(
|
|
7584
|
+
if (evolutionByFile.has(normalizePath5(file.id))) {
|
|
7051
7585
|
coveredFiles += 1;
|
|
7052
7586
|
}
|
|
7053
7587
|
}
|
|
@@ -7241,7 +7775,7 @@ var mapEvolutionByFile = (evolution) => {
|
|
|
7241
7775
|
return /* @__PURE__ */ new Map();
|
|
7242
7776
|
}
|
|
7243
7777
|
return new Map(
|
|
7244
|
-
evolution.files.map((fileMetrics) => [
|
|
7778
|
+
evolution.files.map((fileMetrics) => [normalizePath5(fileMetrics.filePath), fileMetrics])
|
|
7245
7779
|
);
|
|
7246
7780
|
};
|
|
7247
7781
|
var computeEvolutionScales = (evolutionByFile, config) => {
|
|
@@ -7265,7 +7799,7 @@ var computeEvolutionScales = (evolutionByFile, config) => {
|
|
|
7265
7799
|
};
|
|
7266
7800
|
};
|
|
7267
7801
|
var inferModuleName = (filePath, config) => {
|
|
7268
|
-
const normalized =
|
|
7802
|
+
const normalized = normalizePath5(filePath);
|
|
7269
7803
|
const parts = normalized.split("/").filter((part) => part.length > 0);
|
|
7270
7804
|
if (parts.length <= 1) {
|
|
7271
7805
|
return config.module.rootLabel;
|
|
@@ -7286,7 +7820,7 @@ var buildFragileClusters = (structural, evolution, fileScoresByFile, config) =>
|
|
|
7286
7820
|
const clusters = [];
|
|
7287
7821
|
let cycleClusterCount = 0;
|
|
7288
7822
|
for (const cycle of structural.cycles) {
|
|
7289
|
-
const files = [...new Set(cycle.nodes.map((node) =>
|
|
7823
|
+
const files = [...new Set(cycle.nodes.map((node) => normalizePath5(node)))].filter(
|
|
7290
7824
|
(filePath) => fileScoresByFile.has(filePath)
|
|
7291
7825
|
);
|
|
7292
7826
|
if (files.length < 2) {
|
|
@@ -7318,8 +7852,8 @@ var buildFragileClusters = (structural, evolution, fileScoresByFile, config) =>
|
|
|
7318
7852
|
)
|
|
7319
7853
|
);
|
|
7320
7854
|
const selectedPairs = candidates.filter((pair) => pair.couplingScore >= threshold).map((pair) => ({
|
|
7321
|
-
fileA:
|
|
7322
|
-
fileB:
|
|
7855
|
+
fileA: normalizePath5(pair.fileA),
|
|
7856
|
+
fileB: normalizePath5(pair.fileB),
|
|
7323
7857
|
couplingScore: pair.couplingScore
|
|
7324
7858
|
})).filter(
|
|
7325
7859
|
(pair) => pair.fileA !== pair.fileB && fileScoresByFile.has(pair.fileA) && fileScoresByFile.has(pair.fileB)
|
|
@@ -7385,6 +7919,49 @@ var buildFragileClusters = (structural, evolution, fileScoresByFile, config) =>
|
|
|
7385
7919
|
(a, b) => b.score - a.score || a.kind.localeCompare(b.kind) || a.id.localeCompare(b.id)
|
|
7386
7920
|
);
|
|
7387
7921
|
};
|
|
7922
|
+
var buildWorkspaceRiskScores = (structural, fileScoresByFile) => {
|
|
7923
|
+
if (structural.workspaces === void 0 || structural.workspaces.length === 0) {
|
|
7924
|
+
return [];
|
|
7925
|
+
}
|
|
7926
|
+
const maxIncomingEdges = structural.workspaces.reduce(
|
|
7927
|
+
(max, workspace) => Math.max(max, workspace.incomingEdgeCount),
|
|
7928
|
+
0
|
|
7929
|
+
);
|
|
7930
|
+
const maxOutgoingEdges = structural.workspaces.reduce(
|
|
7931
|
+
(max, workspace) => Math.max(max, workspace.outgoingEdgeCount),
|
|
7932
|
+
0
|
|
7933
|
+
);
|
|
7934
|
+
return structural.workspaces.map((workspace) => {
|
|
7935
|
+
const workspaceFileScores = [...fileScoresByFile.values()].filter(
|
|
7936
|
+
(fileScore) => fileScore.file === workspace.path || fileScore.file.startsWith(`${workspace.path}/`)
|
|
7937
|
+
).sort((a, b) => b.score - a.score || a.file.localeCompare(b.file));
|
|
7938
|
+
const averageFileRisk = average3(
|
|
7939
|
+
workspaceFileScores.map((fileScore) => fileScore.normalizedScore)
|
|
7940
|
+
);
|
|
7941
|
+
const peakFileRisk = workspaceFileScores.reduce(
|
|
7942
|
+
(max, fileScore) => Math.max(max, fileScore.normalizedScore),
|
|
7943
|
+
0
|
|
7944
|
+
);
|
|
7945
|
+
const incomingPressure = maxIncomingEdges <= 0 ? 0 : toUnitInterval(workspace.incomingEdgeCount / maxIncomingEdges);
|
|
7946
|
+
const outgoingPressure = maxOutgoingEdges <= 0 ? 0 : toUnitInterval(workspace.outgoingEdgeCount / maxOutgoingEdges);
|
|
7947
|
+
const structuralPressure = toUnitInterval(incomingPressure * 0.7 + outgoingPressure * 0.3);
|
|
7948
|
+
const normalizedScore = toUnitInterval(
|
|
7949
|
+
averageFileRisk * 0.5 + peakFileRisk * 0.3 + structuralPressure * 0.2
|
|
7950
|
+
);
|
|
7951
|
+
return {
|
|
7952
|
+
...workspace,
|
|
7953
|
+
score: round46(normalizedScore * 100),
|
|
7954
|
+
normalizedScore: round46(normalizedScore),
|
|
7955
|
+
averageFileRisk: round46(averageFileRisk),
|
|
7956
|
+
peakFileRisk: round46(peakFileRisk),
|
|
7957
|
+
topFiles: workspaceFileScores.slice(0, 5).map((fileScore) => ({
|
|
7958
|
+
file: fileScore.file,
|
|
7959
|
+
score: fileScore.score,
|
|
7960
|
+
factors: fileScore.factors
|
|
7961
|
+
}))
|
|
7962
|
+
};
|
|
7963
|
+
}).sort((a, b) => b.score - a.score || a.path.localeCompare(b.path));
|
|
7964
|
+
};
|
|
7388
7965
|
var computeRiskSummary = (structural, evolution, external, config, traceCollector) => {
|
|
7389
7966
|
const collector = traceCollector;
|
|
7390
7967
|
const dependencyComputation = computeDependencyScores(external, config);
|
|
@@ -7397,7 +7974,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
7397
7974
|
);
|
|
7398
7975
|
const evolutionScales = computeEvolutionScales(evolutionByFile, config);
|
|
7399
7976
|
const cycleFileSet = new Set(
|
|
7400
|
-
structural.cycles.flatMap((cycle) => cycle.nodes.map((node) =>
|
|
7977
|
+
structural.cycles.flatMap((cycle) => cycle.nodes.map((node) => normalizePath5(node)))
|
|
7401
7978
|
);
|
|
7402
7979
|
const fanInScale = buildQuantileScale(
|
|
7403
7980
|
structural.files.map((file) => logScale(file.fanIn)),
|
|
@@ -7420,7 +7997,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
7420
7997
|
external: external.available
|
|
7421
7998
|
});
|
|
7422
7999
|
const fileRiskContexts = structural.files.map((file) => {
|
|
7423
|
-
const filePath =
|
|
8000
|
+
const filePath = normalizePath5(file.id);
|
|
7424
8001
|
const inCycle = cycleFileSet.has(filePath) ? 1 : 0;
|
|
7425
8002
|
const fanInRisk = normalizeWithScale(logScale(file.fanIn), fanInScale);
|
|
7426
8003
|
const fanOutRisk = normalizeWithScale(logScale(file.fanOut), fanOutScale);
|
|
@@ -7689,6 +8266,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
7689
8266
|
collector.record(buildTargetTrace("module", module, totalScore, normalizedScore, factors));
|
|
7690
8267
|
}
|
|
7691
8268
|
}
|
|
8269
|
+
const workspaceScores = buildWorkspaceRiskScores(structural, fileScoresByFile);
|
|
7692
8270
|
const fragileClusters = buildFragileClusters(structural, evolution, fileScoresByFile, config);
|
|
7693
8271
|
const externalPressures = fileScores.map((fileScore) => fileScore.factors.external);
|
|
7694
8272
|
const pressureThreshold = Math.max(
|
|
@@ -7919,6 +8497,7 @@ var computeRiskSummary = (structural, evolution, external, config, traceCollecto
|
|
|
7919
8497
|
dependencyAmplificationZones,
|
|
7920
8498
|
fileScores,
|
|
7921
8499
|
moduleScores,
|
|
8500
|
+
workspaceScores,
|
|
7922
8501
|
dependencyScores: dependencyComputation.dependencyScores
|
|
7923
8502
|
};
|
|
7924
8503
|
};
|
|
@@ -8037,7 +8616,7 @@ var evaluateRepositoryRisk = (input, options = {}) => {
|
|
|
8037
8616
|
};
|
|
8038
8617
|
|
|
8039
8618
|
// src/application/run-analyze-command.ts
|
|
8040
|
-
var resolveTargetPath = (inputPath, cwd) =>
|
|
8619
|
+
var resolveTargetPath = (inputPath, cwd) => resolve4(cwd, inputPath ?? ".");
|
|
8041
8620
|
var scoringProfileConfig = {
|
|
8042
8621
|
default: void 0,
|
|
8043
8622
|
personal: {
|
|
@@ -8186,7 +8765,7 @@ var collectAnalysisInputs = async (inputPath, authorIdentityMode, options = {},
|
|
|
8186
8765
|
`structural metrics: nodes=${structural.metrics.nodeCount}, edges=${structural.metrics.edgeCount}, cycles=${structural.metrics.cycleCount}`
|
|
8187
8766
|
);
|
|
8188
8767
|
logger.info(`analyzing git evolution (author identity: ${authorIdentityMode})`);
|
|
8189
|
-
const
|
|
8768
|
+
const repositoryEvolution = analyzeRepositoryEvolutionFromGit(
|
|
8190
8769
|
{
|
|
8191
8770
|
repositoryPath: targetPath,
|
|
8192
8771
|
config: {
|
|
@@ -8196,6 +8775,7 @@ var collectAnalysisInputs = async (inputPath, authorIdentityMode, options = {},
|
|
|
8196
8775
|
},
|
|
8197
8776
|
createEvolutionProgressReporter(logger)
|
|
8198
8777
|
);
|
|
8778
|
+
const evolution = enrichEvolutionSummaryWithWorkspaces(structural, repositoryEvolution);
|
|
8199
8779
|
if (evolution.available) {
|
|
8200
8780
|
logger.debug(
|
|
8201
8781
|
`evolution metrics: commits=${evolution.metrics.totalCommits}, files=${evolution.metrics.totalFiles}, hotspotThreshold=${evolution.metrics.hotspotThresholdCommitCount}`
|
|
@@ -8379,7 +8959,7 @@ var runCheckCommand = async (inputPath, authorIdentityMode, options, logger = cr
|
|
|
8379
8959
|
|
|
8380
8960
|
// src/application/run-ci-command.ts
|
|
8381
8961
|
import { readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
|
|
8382
|
-
import { relative as relative3, resolve as
|
|
8962
|
+
import { relative as relative3, resolve as resolve5 } from "path";
|
|
8383
8963
|
var isPathOutsideBase = (value) => {
|
|
8384
8964
|
return value === ".." || value.startsWith("../") || value.startsWith("..\\");
|
|
8385
8965
|
};
|
|
@@ -8392,7 +8972,7 @@ var runCiCommand = async (inputPath, authorIdentityMode, options, logger = creat
|
|
|
8392
8972
|
if (options.baselineSha !== void 0 && options.baselineRef !== "auto") {
|
|
8393
8973
|
throw new GovernanceConfigurationError("baseline-sha requires --baseline-ref auto");
|
|
8394
8974
|
}
|
|
8395
|
-
const resolvedTargetPath =
|
|
8975
|
+
const resolvedTargetPath = resolve5(inputPath ?? process.cwd());
|
|
8396
8976
|
logger.info("building current snapshot");
|
|
8397
8977
|
const current = await buildAnalysisSnapshot(
|
|
8398
8978
|
inputPath,
|
|
@@ -8452,7 +9032,7 @@ var runCiCommand = async (inputPath, authorIdentityMode, options, logger = creat
|
|
|
8452
9032
|
`target path is outside git repository root: ${resolvedTargetPath}`
|
|
8453
9033
|
);
|
|
8454
9034
|
}
|
|
8455
|
-
const baselineTargetPath = relativeTargetPath.length === 0 || relativeTargetPath === "." ? worktreePath :
|
|
9035
|
+
const baselineTargetPath = relativeTargetPath.length === 0 || relativeTargetPath === "." ? worktreePath : resolve5(worktreePath, relativeTargetPath);
|
|
8456
9036
|
return buildAnalysisSnapshot(
|
|
8457
9037
|
baselineTargetPath,
|
|
8458
9038
|
authorIdentityMode,
|
|
@@ -8526,15 +9106,15 @@ ${ciMarkdown}`;
|
|
|
8526
9106
|
};
|
|
8527
9107
|
|
|
8528
9108
|
// src/application/run-report-command.ts
|
|
8529
|
-
import { join as
|
|
9109
|
+
import { join as join10 } from "path";
|
|
8530
9110
|
import { readFile as readFile6, writeFile as writeFile6 } from "fs/promises";
|
|
8531
9111
|
|
|
8532
9112
|
// src/application/html-report.ts
|
|
8533
9113
|
import { mkdir as mkdir3, readFile as readFile5, rm, stat as stat2, writeFile as writeFile5 } from "fs/promises";
|
|
8534
|
-
import { dirname as dirname2, join as
|
|
9114
|
+
import { dirname as dirname2, join as join9, resolve as resolve6 } from "path";
|
|
8535
9115
|
import { fileURLToPath } from "url";
|
|
8536
9116
|
var HTML_REPORT_DIR = ".codesentinel/report";
|
|
8537
|
-
var getBundledHtmlAppPath = () =>
|
|
9117
|
+
var getBundledHtmlAppPath = () => resolve6(dirname2(fileURLToPath(import.meta.url)), "html-report-app");
|
|
8538
9118
|
var serializeReportBootstrap = (report) => `window.__CODESENTINEL_REPORT__ = ${JSON.stringify(report).replaceAll("</", "<\\/")};
|
|
8539
9119
|
`;
|
|
8540
9120
|
var escapeInlineScript = (script) => script.replaceAll("</script", "<\\/script").replaceAll("<script", "\\x3Cscript").replaceAll("<!--", "\\x3C!--").replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029");
|
|
@@ -8548,18 +9128,18 @@ var readReferencedAssets = async (appPath, indexHtml) => {
|
|
|
8548
9128
|
(value) => value !== void 0 && !/^https?:\/\//.test(value) && !value.startsWith("//")
|
|
8549
9129
|
);
|
|
8550
9130
|
const styles = await Promise.all(
|
|
8551
|
-
stylesheetPaths.map(async (href) => readFile5(
|
|
9131
|
+
stylesheetPaths.map(async (href) => readFile5(resolve6(appPath, href), "utf8"))
|
|
8552
9132
|
);
|
|
8553
9133
|
const scriptPaths = [...indexHtml.matchAll(/<script[^>]+src=["']([^"']+)["'][^>]*><\/script>/g)].map((match) => match[1]).filter(
|
|
8554
9134
|
(value) => value !== void 0 && !/^https?:\/\//.test(value) && !value.startsWith("//")
|
|
8555
9135
|
);
|
|
8556
9136
|
const scripts = await Promise.all(
|
|
8557
|
-
scriptPaths.map(async (src) => readFile5(
|
|
9137
|
+
scriptPaths.map(async (src) => readFile5(resolve6(appPath, src), "utf8"))
|
|
8558
9138
|
);
|
|
8559
9139
|
return { styles, scripts };
|
|
8560
9140
|
};
|
|
8561
9141
|
var inlineBuiltHtml = async (appPath, report) => {
|
|
8562
|
-
const indexHtml = await readFile5(
|
|
9142
|
+
const indexHtml = await readFile5(resolve6(appPath, "index.html"), "utf8");
|
|
8563
9143
|
const { styles, scripts } = await readReferencedAssets(appPath, indexHtml);
|
|
8564
9144
|
const htmlWithoutExternalAssets = indexHtml.replace(
|
|
8565
9145
|
/\s*<link[^>]+rel=["']stylesheet["'][^>]*>\s*/g,
|
|
@@ -8594,7 +9174,7 @@ var assertHtmlAppAssets = async (assetPath) => {
|
|
|
8594
9174
|
};
|
|
8595
9175
|
var resolveHtmlReportOutputPath = (repositoryPath, outputPath) => {
|
|
8596
9176
|
const invocationCwd = process.env["INIT_CWD"] ?? process.cwd();
|
|
8597
|
-
return
|
|
9177
|
+
return resolve6(invocationCwd, outputPath ?? join9(repositoryPath, HTML_REPORT_DIR));
|
|
8598
9178
|
};
|
|
8599
9179
|
var writeHtmlReportBundle = async (report, options) => {
|
|
8600
9180
|
const bundledAppPath = options.bundledAppPath ?? getBundledHtmlAppPath();
|
|
@@ -8603,7 +9183,7 @@ var writeHtmlReportBundle = async (report, options) => {
|
|
|
8603
9183
|
await rm(outputPath, { recursive: true, force: true });
|
|
8604
9184
|
await ensureDirectory(outputPath);
|
|
8605
9185
|
await writeFile5(
|
|
8606
|
-
|
|
9186
|
+
resolve6(outputPath, "index.html"),
|
|
8607
9187
|
await inlineBuiltHtml(bundledAppPath, report),
|
|
8608
9188
|
"utf8"
|
|
8609
9189
|
);
|
|
@@ -8630,15 +9210,15 @@ var openPath = async (targetPath) => {
|
|
|
8630
9210
|
if (command === void 0) {
|
|
8631
9211
|
return false;
|
|
8632
9212
|
}
|
|
8633
|
-
return new Promise((
|
|
9213
|
+
return new Promise((resolve8) => {
|
|
8634
9214
|
const child = spawn3(command.command, command.args, {
|
|
8635
9215
|
detached: true,
|
|
8636
9216
|
stdio: "ignore"
|
|
8637
9217
|
});
|
|
8638
|
-
child.once("error", () =>
|
|
9218
|
+
child.once("error", () => resolve8(false));
|
|
8639
9219
|
child.once("spawn", () => {
|
|
8640
9220
|
child.unref();
|
|
8641
|
-
|
|
9221
|
+
resolve8(true);
|
|
8642
9222
|
});
|
|
8643
9223
|
});
|
|
8644
9224
|
};
|
|
@@ -8676,7 +9256,7 @@ var runReportCommand = async (inputPath, authorIdentityMode, options, logger = c
|
|
|
8676
9256
|
...options.outputPath === void 0 ? {} : { outputPath: options.outputPath }
|
|
8677
9257
|
});
|
|
8678
9258
|
if (options.open === true) {
|
|
8679
|
-
const opened = await openPath(
|
|
9259
|
+
const opened = await openPath(join10(bundlePath, "index.html"));
|
|
8680
9260
|
if (!opened) {
|
|
8681
9261
|
logger.warn("unable to open html report automatically on this platform");
|
|
8682
9262
|
}
|
|
@@ -8767,8 +9347,8 @@ var runExplainCommand = async (inputPath, authorIdentityMode, options, logger =
|
|
|
8767
9347
|
|
|
8768
9348
|
// src/index.ts
|
|
8769
9349
|
var program = new Command();
|
|
8770
|
-
var packageJsonPath =
|
|
8771
|
-
var { version } = JSON.parse(
|
|
9350
|
+
var packageJsonPath = resolve7(dirname3(fileURLToPath2(import.meta.url)), "../package.json");
|
|
9351
|
+
var { version } = JSON.parse(readFileSync4(packageJsonPath, "utf8"));
|
|
8772
9352
|
var parseRecentWindowDays = (value) => {
|
|
8773
9353
|
const parsed = Number.parseInt(value, 10);
|
|
8774
9354
|
if (!Number.isInteger(parsed) || parsed <= 0) {
|