dependency-change-report 1.4.6 → 1.4.8
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/cli.mjs +22 -4
- package/lib/core/analyzer.mjs +26 -6
- package/lib/generate-html.mjs +2 -1
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -45,7 +45,7 @@ const compare = command(
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// Set up output directory
|
|
48
|
-
let outputDir = compare.flags
|
|
48
|
+
let outputDir = compare.flags.outputDir;
|
|
49
49
|
if (!outputDir) {
|
|
50
50
|
outputDir = workingDir; // Default to working directory
|
|
51
51
|
}
|
|
@@ -90,9 +90,18 @@ const compare = command(
|
|
|
90
90
|
let baseFilename = 'report';
|
|
91
91
|
if (isGitHubActions) {
|
|
92
92
|
const eventName = process.env.GITHUB_EVENT_NAME;
|
|
93
|
-
|
|
93
|
+
let prNumber = process.env.GITHUB_PR_NUMBER;
|
|
94
94
|
const sha = process.env.GITHUB_SHA?.substring(0, 7);
|
|
95
95
|
|
|
96
|
+
// Extract PR number from GITHUB_REF_NAME if not in GITHUB_PR_NUMBER
|
|
97
|
+
if (!prNumber && process.env.GITHUB_REF_NAME) {
|
|
98
|
+
const refName = process.env.GITHUB_REF_NAME;
|
|
99
|
+
const prMatch = refName.match(/^(\d+)\/merge$/);
|
|
100
|
+
if (prMatch) {
|
|
101
|
+
prNumber = prMatch[1];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
96
105
|
if (eventName === 'pull_request' && prNumber) {
|
|
97
106
|
baseFilename = `dependency-report-PR-${prNumber}`;
|
|
98
107
|
} else if (sha) {
|
|
@@ -210,7 +219,7 @@ const auto = command(
|
|
|
210
219
|
}
|
|
211
220
|
|
|
212
221
|
// Set up output directory
|
|
213
|
-
let outputDir = auto.flags
|
|
222
|
+
let outputDir = auto.flags.outputDir;
|
|
214
223
|
if (!outputDir) {
|
|
215
224
|
outputDir = workingDir; // Default to working directory
|
|
216
225
|
}
|
|
@@ -260,9 +269,18 @@ const auto = command(
|
|
|
260
269
|
let baseFilename = 'report';
|
|
261
270
|
if (isGitHubActions) {
|
|
262
271
|
const eventName = process.env.GITHUB_EVENT_NAME;
|
|
263
|
-
|
|
272
|
+
let prNumber = process.env.GITHUB_PR_NUMBER;
|
|
264
273
|
const sha = process.env.GITHUB_SHA?.substring(0, 7);
|
|
265
274
|
|
|
275
|
+
// Extract PR number from GITHUB_REF_NAME if not in GITHUB_PR_NUMBER
|
|
276
|
+
if (!prNumber && process.env.GITHUB_REF_NAME) {
|
|
277
|
+
const refName = process.env.GITHUB_REF_NAME;
|
|
278
|
+
const prMatch = refName.match(/^(\d+)\/merge$/);
|
|
279
|
+
if (prMatch) {
|
|
280
|
+
prNumber = prMatch[1];
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
266
284
|
if (eventName === 'pull_request' && prNumber) {
|
|
267
285
|
baseFilename = `dependency-report-PR-${prNumber}`;
|
|
268
286
|
} else if (sha) {
|
package/lib/core/analyzer.mjs
CHANGED
|
@@ -589,10 +589,20 @@ export const analyzeDependencyChanges = async (repoUrl, olderVersion, newerVersi
|
|
|
589
589
|
const currentBranchName = currentBranch.trim();
|
|
590
590
|
|
|
591
591
|
if (currentBranchName !== olderVersion) {
|
|
592
|
-
|
|
592
|
+
try {
|
|
593
|
+
await executeCommand('git', ['worktree', 'remove', olderVersionDir], process.cwd(), time_1min, 'cleanup older worktree', false);
|
|
594
|
+
} catch (removeError) {
|
|
595
|
+
// If normal remove fails, try with --force
|
|
596
|
+
await executeCommand('git', ['worktree', 'remove', '--force', olderVersionDir], process.cwd(), time_1min, 'force cleanup older worktree', false);
|
|
597
|
+
}
|
|
593
598
|
}
|
|
594
599
|
if (currentBranchName !== newerVersion) {
|
|
595
|
-
|
|
600
|
+
try {
|
|
601
|
+
await executeCommand('git', ['worktree', 'remove', newerVersionDir], process.cwd(), time_1min, 'cleanup newer worktree', false);
|
|
602
|
+
} catch (removeError) {
|
|
603
|
+
// If normal remove fails, try with --force
|
|
604
|
+
await executeCommand('git', ['worktree', 'remove', '--force', newerVersionDir], process.cwd(), time_1min, 'force cleanup newer worktree', false);
|
|
605
|
+
}
|
|
596
606
|
}
|
|
597
607
|
} catch (cleanupError) {
|
|
598
608
|
console.warn(`⚠️ Failed to clean up worktrees: ${cleanupError.message}`);
|
|
@@ -614,15 +624,25 @@ export const analyzeDependencyChanges = async (repoUrl, olderVersion, newerVersi
|
|
|
614
624
|
if (currentBranchName !== olderVersion) {
|
|
615
625
|
try {
|
|
616
626
|
await executeCommand('git', ['worktree', 'remove', olderVersionDir], process.cwd(), time_1min, 'cleanup older worktree', false);
|
|
617
|
-
} catch (
|
|
618
|
-
|
|
627
|
+
} catch (removeError) {
|
|
628
|
+
try {
|
|
629
|
+
// If normal remove fails, try with --force
|
|
630
|
+
await executeCommand('git', ['worktree', 'remove', '--force', olderVersionDir], process.cwd(), time_1min, 'force cleanup older worktree', false);
|
|
631
|
+
} catch (cleanupError) {
|
|
632
|
+
// Ignore cleanup errors
|
|
633
|
+
}
|
|
619
634
|
}
|
|
620
635
|
}
|
|
621
636
|
if (currentBranchName !== newerVersion) {
|
|
622
637
|
try {
|
|
623
638
|
await executeCommand('git', ['worktree', 'remove', newerVersionDir], process.cwd(), time_1min, 'cleanup newer worktree', false);
|
|
624
|
-
} catch (
|
|
625
|
-
|
|
639
|
+
} catch (removeError) {
|
|
640
|
+
try {
|
|
641
|
+
// If normal remove fails, try with --force
|
|
642
|
+
await executeCommand('git', ['worktree', 'remove', '--force', newerVersionDir], process.cwd(), time_1min, 'force cleanup newer worktree', false);
|
|
643
|
+
} catch (cleanupError) {
|
|
644
|
+
// Ignore cleanup errors
|
|
645
|
+
}
|
|
626
646
|
}
|
|
627
647
|
}
|
|
628
648
|
} catch (cleanupError) {
|
package/lib/generate-html.mjs
CHANGED
|
@@ -21,9 +21,10 @@ const generateHtmlReport = async (jsonPath, outputPath = null) => {
|
|
|
21
21
|
|
|
22
22
|
// If no output path specified, create one with a specific naming format
|
|
23
23
|
if (!outputPath) {
|
|
24
|
+
const jsonDir = dirname(jsonPath);
|
|
24
25
|
const packageName = reportJson.repository.split('/').pop().replace('.git', '');
|
|
25
26
|
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
26
|
-
outputPath = `dependency-report-${packageName}-${reportJson.olderVersion}-${reportJson.newerVersion}-${timestamp}.html
|
|
27
|
+
outputPath = join(jsonDir, `dependency-report-${packageName}-${reportJson.olderVersion}-${reportJson.newerVersion}-${timestamp}.html`);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
// Generate HTML content
|