@rainy-updates/cli 0.5.6 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +133 -0
- package/README.md +90 -31
- package/dist/bin/cli.js +24 -482
- package/dist/bin/dispatch.d.ts +16 -0
- package/dist/bin/dispatch.js +147 -0
- package/dist/bin/help.d.ts +1 -0
- package/dist/bin/help.js +314 -0
- package/dist/cache/cache.js +13 -11
- package/dist/commands/audit/parser.js +2 -2
- package/dist/commands/audit/runner.js +27 -46
- package/dist/commands/audit/targets.js +13 -13
- package/dist/commands/bisect/oracle.js +28 -11
- package/dist/commands/bisect/parser.js +3 -3
- package/dist/commands/bisect/runner.js +15 -8
- package/dist/commands/changelog/fetcher.js +11 -5
- package/dist/commands/dashboard/parser.js +103 -1
- package/dist/commands/dashboard/runner.d.ts +2 -2
- package/dist/commands/dashboard/runner.js +67 -37
- package/dist/commands/doctor/parser.js +15 -4
- package/dist/commands/doctor/runner.js +6 -3
- package/dist/commands/ga/parser.js +4 -4
- package/dist/commands/ga/runner.js +13 -7
- package/dist/commands/health/parser.js +2 -2
- package/dist/commands/licenses/runner.js +4 -4
- package/dist/commands/resolve/runner.js +9 -4
- package/dist/commands/review/parser.js +57 -4
- package/dist/commands/review/runner.js +31 -5
- package/dist/commands/snapshot/runner.js +17 -17
- package/dist/commands/snapshot/store.d.ts +0 -12
- package/dist/commands/snapshot/store.js +26 -38
- package/dist/commands/unused/runner.js +6 -7
- package/dist/commands/unused/scanner.js +17 -20
- package/dist/config/loader.d.ts +2 -2
- package/dist/config/loader.js +2 -5
- package/dist/config/policy.js +20 -11
- package/dist/core/analysis/options.d.ts +6 -0
- package/dist/core/analysis/options.js +69 -0
- package/dist/core/analysis/review-items.d.ts +4 -0
- package/dist/core/analysis/review-items.js +128 -0
- package/dist/core/analysis/run-silenced.d.ts +1 -0
- package/dist/core/analysis/run-silenced.js +13 -0
- package/dist/core/analysis-bundle.js +3 -211
- package/dist/core/artifacts.js +6 -5
- package/dist/core/baseline.js +3 -5
- package/dist/core/check.js +2 -2
- package/dist/core/ci.js +52 -1
- package/dist/core/decision-plan.d.ts +14 -0
- package/dist/core/decision-plan.js +107 -0
- package/dist/core/doctor/findings.d.ts +2 -0
- package/dist/core/doctor/findings.js +166 -0
- package/dist/core/doctor/render.d.ts +3 -0
- package/dist/core/doctor/render.js +44 -0
- package/dist/core/doctor/result.d.ts +2 -0
- package/dist/core/doctor/result.js +58 -0
- package/dist/core/doctor/score.d.ts +5 -0
- package/dist/core/doctor/score.js +28 -0
- package/dist/core/fix-pr-batch.js +38 -28
- package/dist/core/fix-pr.js +27 -24
- package/dist/core/init-ci.js +25 -21
- package/dist/core/options.js +95 -4
- package/dist/core/review-model.d.ts +3 -3
- package/dist/core/review-model.js +6 -67
- package/dist/core/review-verdict.d.ts +2 -0
- package/dist/core/review-verdict.js +14 -0
- package/dist/core/summary.js +12 -0
- package/dist/core/upgrade.js +64 -2
- package/dist/core/verification.d.ts +2 -0
- package/dist/core/verification.js +106 -0
- package/dist/core/warm-cache.js +2 -2
- package/dist/output/format.js +22 -0
- package/dist/output/github.js +10 -0
- package/dist/output/sarif.js +16 -12
- package/dist/parsers/package-json.js +2 -4
- package/dist/pm/detect.d.ts +3 -1
- package/dist/pm/detect.js +24 -12
- package/dist/pm/install.d.ts +2 -1
- package/dist/pm/install.js +15 -16
- package/dist/registry/npm.js +34 -76
- package/dist/rup +0 -0
- package/dist/types/index.d.ts +104 -5
- package/dist/ui/tui.d.ts +4 -1
- package/dist/ui/tui.js +5 -4
- package/dist/utils/io.js +5 -6
- package/dist/utils/lockfile.js +24 -19
- package/dist/utils/runtime-paths.d.ts +4 -0
- package/dist/utils/runtime-paths.js +35 -0
- package/dist/utils/runtime.d.ts +7 -0
- package/dist/utils/runtime.js +32 -0
- package/dist/workspace/discover.js +55 -51
- package/package.json +16 -16
- package/dist/ui/dashboard/DashboardTUI.d.ts +0 -6
- package/dist/ui/dashboard/DashboardTUI.js +0 -34
- package/dist/ui/dashboard/components/DetailPanel.d.ts +0 -4
- package/dist/ui/dashboard/components/DetailPanel.js +0 -30
- package/dist/ui/dashboard/components/Footer.d.ts +0 -4
- package/dist/ui/dashboard/components/Footer.js +0 -9
- package/dist/ui/dashboard/components/Header.d.ts +0 -4
- package/dist/ui/dashboard/components/Header.js +0 -12
- package/dist/ui/dashboard/components/Sidebar.d.ts +0 -4
- package/dist/ui/dashboard/components/Sidebar.js +0 -23
- package/dist/ui/dashboard/store.d.ts +0 -34
- package/dist/ui/dashboard/store.js +0 -148
package/dist/core/init-ci.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mkdir } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { detectPackageManager } from "../pm/detect.js";
|
|
3
4
|
export async function initCiWorkflow(cwd, force, options) {
|
|
4
5
|
const workflowPath = path.join(cwd, ".github", "workflows", "rainy-updates.yml");
|
|
5
6
|
try {
|
|
6
7
|
if (!force) {
|
|
7
|
-
await
|
|
8
|
-
|
|
8
|
+
if (await Bun.file(workflowPath).exists()) {
|
|
9
|
+
return { path: workflowPath, created: false };
|
|
10
|
+
}
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
13
|
catch {
|
|
12
14
|
// missing file, continue create
|
|
13
15
|
}
|
|
14
|
-
const
|
|
16
|
+
const detected = await detectPackageManager(cwd);
|
|
17
|
+
const packageManager = detected === "unknown" || detected === "yarn" ? "npm" : detected;
|
|
15
18
|
const scheduleBlock = renderScheduleBlock(options.schedule);
|
|
16
19
|
const workflow = options.mode === "minimal"
|
|
17
20
|
? minimalWorkflowTemplate(scheduleBlock, packageManager)
|
|
@@ -19,19 +22,9 @@ export async function initCiWorkflow(cwd, force, options) {
|
|
|
19
22
|
? strictWorkflowTemplate(scheduleBlock, packageManager)
|
|
20
23
|
: enterpriseWorkflowTemplate(scheduleBlock, packageManager);
|
|
21
24
|
await mkdir(path.dirname(workflowPath), { recursive: true });
|
|
22
|
-
await
|
|
25
|
+
await Bun.write(workflowPath, workflow);
|
|
23
26
|
return { path: workflowPath, created: true };
|
|
24
27
|
}
|
|
25
|
-
async function detectPackageManager(cwd) {
|
|
26
|
-
const pnpmLock = path.join(cwd, "pnpm-lock.yaml");
|
|
27
|
-
try {
|
|
28
|
-
await access(pnpmLock);
|
|
29
|
-
return "pnpm";
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
return "npm";
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
28
|
function renderScheduleBlock(schedule) {
|
|
36
29
|
if (schedule === "off") {
|
|
37
30
|
return " workflow_dispatch:";
|
|
@@ -40,20 +33,31 @@ function renderScheduleBlock(schedule) {
|
|
|
40
33
|
return ` schedule:\n - cron: '${cron}'\n workflow_dispatch:`;
|
|
41
34
|
}
|
|
42
35
|
function installStep(packageManager) {
|
|
36
|
+
if (packageManager === "bun") {
|
|
37
|
+
return ` - name: Install dependencies\n run: bun install`;
|
|
38
|
+
}
|
|
43
39
|
if (packageManager === "pnpm") {
|
|
44
40
|
return ` - name: Setup pnpm\n uses: pnpm/action-setup@v4\n with:\n version: 9\n\n - name: Install dependencies\n run: pnpm install --frozen-lockfile`;
|
|
45
41
|
}
|
|
46
42
|
return ` - name: Install dependencies\n run: npm ci`;
|
|
47
43
|
}
|
|
48
44
|
function minimalWorkflowTemplate(scheduleBlock, packageManager) {
|
|
49
|
-
return `name: Rainy Updates\n\non:\n${scheduleBlock}\n\njobs:\n dependency-check:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout\n uses: actions/checkout@v4\n\n - name: Setup
|
|
45
|
+
return `name: Rainy Updates\n\non:\n${scheduleBlock}\n\njobs:\n dependency-check:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout\n uses: actions/checkout@v4\n\n - name: Setup Bun\n uses: oven-sh/setup-bun@v1\n\n${installStep(packageManager)}\n\n - name: Run dependency check\n run: |\n bunx --bun @rainy-updates/cli ci \\\n --workspace \\\n --mode minimal \\\n --gate check \\\n --ci \\\n --stream \\\n --registry-timeout-ms 12000 \\\n --registry-retries 4 \\\n --format table\n`;
|
|
50
46
|
}
|
|
51
47
|
function strictWorkflowTemplate(scheduleBlock, packageManager) {
|
|
52
|
-
return `name: Rainy Updates\n\non:\n${scheduleBlock}\n\npermissions:\n contents: read\n security-events: write\n\njobs:\n dependency-check:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout\n uses: actions/checkout@v4\n\n - name: Setup
|
|
48
|
+
return `name: Rainy Updates\n\non:\n${scheduleBlock}\n\npermissions:\n contents: read\n security-events: write\n\njobs:\n dependency-check:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout\n uses: actions/checkout@v4\n\n - name: Setup Bun\n uses: oven-sh/setup-bun@v1\n\n${installStep(packageManager)}\n\n - name: Warm cache\n run: bunx --bun @rainy-updates/cli warm-cache --workspace --concurrency 32 --registry-timeout-ms 12000 --registry-retries 4\n\n - name: Generate reviewed decision plan\n run: |\n bunx --bun @rainy-updates/cli ci \\\n --workspace \\\n --mode strict \\\n --gate review \\\n --plan-file .artifacts/decision-plan.json \\\n --ci \\\n --concurrency 32 \\\n --stream \\\n --registry-timeout-ms 12000 \\\n --registry-retries 4 \\\n --format github \\\n --json-file .artifacts/deps-report.json \\\n --pr-report-file .artifacts/deps-report.md \\\n --sarif-file .artifacts/deps-report.sarif \\\n --github-output $GITHUB_OUTPUT\n\n - name: Upload report artifacts\n uses: actions/upload-artifact@v4\n with:\n name: rainy-updates-report\n path: .artifacts/\n\n - name: Upload SARIF\n uses: github/codeql-action/upload-sarif@v3\n with:\n sarif_file: .artifacts/deps-report.sarif\n`;
|
|
53
49
|
}
|
|
54
50
|
function enterpriseWorkflowTemplate(scheduleBlock, packageManager) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
let detectedPmInstall = "npm ci";
|
|
52
|
+
let testCmd = "npm test";
|
|
53
|
+
if (packageManager === "pnpm") {
|
|
54
|
+
detectedPmInstall =
|
|
55
|
+
"corepack enable && corepack prepare pnpm@9 --activate && pnpm install --frozen-lockfile";
|
|
56
|
+
testCmd = "pnpm test";
|
|
57
|
+
}
|
|
58
|
+
else if (packageManager === "bun") {
|
|
59
|
+
detectedPmInstall = "bun install";
|
|
60
|
+
testCmd = "bun test";
|
|
61
|
+
}
|
|
62
|
+
return `name: Rainy Updates Enterprise\n\non:\n${scheduleBlock}\n\npermissions:\n contents: read\n security-events: write\n actions: read\n\nconcurrency:\n group: rainy-updates-\${{ github.ref }}\n cancel-in-progress: false\n\njobs:\n dependency-check:\n runs-on: ubuntu-latest\n strategy:\n fail-fast: false\n matrix:\n node: [20, 22]\n steps:\n - name: Checkout\n uses: actions/checkout@v4\n\n - name: Setup Node\n uses: actions/setup-node@v4\n with:\n node-version: \${{ matrix.node }}\n\n - name: Setup Bun\n uses: oven-sh/setup-bun@v1\n\n - name: Install dependencies\n run: ${detectedPmInstall}\n\n - name: Warm cache\n run: bunx --bun @rainy-updates/cli warm-cache --workspace --concurrency 32 --registry-timeout-ms 12000 --registry-retries 4\n\n - name: Generate reviewed decision plan\n run: |\n bunx --bun @rainy-updates/cli ci \\\n --workspace \\\n --mode enterprise \\\n --gate review \\\n --plan-file .artifacts/decision-plan.json \\\n --concurrency 32 \\\n --stream \\\n --registry-timeout-ms 12000 \\\n --registry-retries 4 \\\n --lockfile-mode preserve \\\n --format github \\\n --fail-on minor \\\n --max-updates 50 \\\n --json-file .artifacts/deps-report-node-\${{ matrix.node }}.json \\\n --pr-report-file .artifacts/deps-report-node-\${{ matrix.node }}.md \\\n --sarif-file .artifacts/deps-report-node-\${{ matrix.node }}.sarif \\\n --github-output $GITHUB_OUTPUT\n\n - name: Replay approved plan with verification\n run: |\n bunx --bun @rainy-updates/cli ci \\\n --workspace \\\n --mode enterprise \\\n --gate upgrade \\\n --from-plan .artifacts/decision-plan.json \\\n --verify test \\\n --test-command "${testCmd}" \\\n --verification-report-file .artifacts/verification-node-\${{ matrix.node }}.json\n\n - name: Upload report artifacts\n uses: actions/upload-artifact@v4\n with:\n name: rainy-updates-report-node-\${{ matrix.node }}\n path: .artifacts/\n retention-days: 14\n\n - name: Upload SARIF\n uses: github/codeql-action/upload-sarif@v3\n with:\n sarif_file: .artifacts/deps-report-node-\${{ matrix.node }}.sarif\n`;
|
|
59
63
|
}
|
package/dist/core/options.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import process from "node:process";
|
|
3
2
|
import { loadConfig } from "../config/loader.js";
|
|
3
|
+
import { getRuntimeCwd } from "../utils/runtime.js";
|
|
4
4
|
const DEFAULT_INCLUDE_KINDS = [
|
|
5
5
|
"dependencies",
|
|
6
6
|
"devDependencies",
|
|
@@ -83,7 +83,7 @@ export async function parseCliArgs(argv) {
|
|
|
83
83
|
return { command, options: parseGaArgs(args) };
|
|
84
84
|
}
|
|
85
85
|
const base = {
|
|
86
|
-
cwd:
|
|
86
|
+
cwd: getRuntimeCwd(),
|
|
87
87
|
target: "latest",
|
|
88
88
|
filter: undefined,
|
|
89
89
|
reject: undefined,
|
|
@@ -122,6 +122,11 @@ export async function parseCliArgs(argv) {
|
|
|
122
122
|
interactive: false,
|
|
123
123
|
showImpact: false,
|
|
124
124
|
showHomepage: false,
|
|
125
|
+
decisionPlanFile: undefined,
|
|
126
|
+
verify: "none",
|
|
127
|
+
testCommand: undefined,
|
|
128
|
+
verificationReportFile: undefined,
|
|
129
|
+
ciGate: "check",
|
|
125
130
|
};
|
|
126
131
|
let force = false;
|
|
127
132
|
let initCiMode = "enterprise";
|
|
@@ -492,6 +497,54 @@ export async function parseCliArgs(argv) {
|
|
|
492
497
|
if (current === "--file") {
|
|
493
498
|
throw new Error("Missing value for --file");
|
|
494
499
|
}
|
|
500
|
+
if (current === "--plan-file" && next) {
|
|
501
|
+
base.decisionPlanFile = path.resolve(base.cwd, next);
|
|
502
|
+
index += 1;
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
if (current === "--plan-file") {
|
|
506
|
+
throw new Error("Missing value for --plan-file");
|
|
507
|
+
}
|
|
508
|
+
if (current === "--from-plan" && next) {
|
|
509
|
+
base.decisionPlanFile = path.resolve(base.cwd, next);
|
|
510
|
+
index += 1;
|
|
511
|
+
continue;
|
|
512
|
+
}
|
|
513
|
+
if (current === "--from-plan") {
|
|
514
|
+
throw new Error("Missing value for --from-plan");
|
|
515
|
+
}
|
|
516
|
+
if (current === "--verify" && next) {
|
|
517
|
+
base.verify = ensureVerificationMode(next);
|
|
518
|
+
index += 1;
|
|
519
|
+
continue;
|
|
520
|
+
}
|
|
521
|
+
if (current === "--verify") {
|
|
522
|
+
throw new Error("Missing value for --verify");
|
|
523
|
+
}
|
|
524
|
+
if (current === "--test-command" && next) {
|
|
525
|
+
base.testCommand = next;
|
|
526
|
+
index += 1;
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
if (current === "--test-command") {
|
|
530
|
+
throw new Error("Missing value for --test-command");
|
|
531
|
+
}
|
|
532
|
+
if (current === "--verification-report-file" && next) {
|
|
533
|
+
base.verificationReportFile = path.resolve(base.cwd, next);
|
|
534
|
+
index += 1;
|
|
535
|
+
continue;
|
|
536
|
+
}
|
|
537
|
+
if (current === "--verification-report-file") {
|
|
538
|
+
throw new Error("Missing value for --verification-report-file");
|
|
539
|
+
}
|
|
540
|
+
if (current === "--gate" && next) {
|
|
541
|
+
base.ciGate = ensureCiGate(next);
|
|
542
|
+
index += 1;
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
if (current === "--gate") {
|
|
546
|
+
throw new Error("Missing value for --gate");
|
|
547
|
+
}
|
|
495
548
|
if (current.startsWith("-")) {
|
|
496
549
|
throw new Error(`Unknown option: ${current}`);
|
|
497
550
|
}
|
|
@@ -526,6 +579,7 @@ export async function parseCliArgs(argv) {
|
|
|
526
579
|
install: args.includes("--install") || resolvedConfig.install === true,
|
|
527
580
|
packageManager: cliPm === "auto" ? (configPm ?? "auto") : cliPm,
|
|
528
581
|
sync: args.includes("--sync") || resolvedConfig.sync === true,
|
|
582
|
+
fromPlanFile: base.decisionPlanFile,
|
|
529
583
|
};
|
|
530
584
|
return { command, options: upgradeOptions };
|
|
531
585
|
}
|
|
@@ -687,16 +741,35 @@ function applyConfig(base, config) {
|
|
|
687
741
|
if (typeof config.showHomepage === "boolean") {
|
|
688
742
|
base.showHomepage = config.showHomepage;
|
|
689
743
|
}
|
|
744
|
+
if (typeof config.decisionPlanFile === "string") {
|
|
745
|
+
base.decisionPlanFile = path.resolve(base.cwd, config.decisionPlanFile);
|
|
746
|
+
}
|
|
747
|
+
if (typeof config.verify === "string") {
|
|
748
|
+
base.verify = ensureVerificationMode(config.verify);
|
|
749
|
+
}
|
|
750
|
+
if (typeof config.testCommand === "string") {
|
|
751
|
+
base.testCommand = config.testCommand;
|
|
752
|
+
}
|
|
753
|
+
if (typeof config.verificationReportFile === "string") {
|
|
754
|
+
base.verificationReportFile = path.resolve(base.cwd, config.verificationReportFile);
|
|
755
|
+
}
|
|
756
|
+
if (typeof config.ciGate === "string") {
|
|
757
|
+
base.ciGate = ensureCiGate(config.ciGate);
|
|
758
|
+
}
|
|
690
759
|
}
|
|
691
760
|
function parsePackageManager(args) {
|
|
692
761
|
const index = args.indexOf("--pm");
|
|
693
762
|
if (index === -1)
|
|
694
763
|
return "auto";
|
|
695
764
|
const value = args[index + 1] ?? "auto";
|
|
696
|
-
if (value === "auto" ||
|
|
765
|
+
if (value === "auto" ||
|
|
766
|
+
value === "bun" ||
|
|
767
|
+
value === "npm" ||
|
|
768
|
+
value === "pnpm" ||
|
|
769
|
+
value === "yarn") {
|
|
697
770
|
return value;
|
|
698
771
|
}
|
|
699
|
-
throw new Error("--pm must be auto, npm or
|
|
772
|
+
throw new Error("--pm must be auto, bun, npm, pnpm or yarn");
|
|
700
773
|
}
|
|
701
774
|
function ensureTarget(value) {
|
|
702
775
|
if (value === "patch" ||
|
|
@@ -800,3 +873,21 @@ export function ensureRiskLevel(value) {
|
|
|
800
873
|
}
|
|
801
874
|
throw new Error("--risk must be critical, high, medium or low");
|
|
802
875
|
}
|
|
876
|
+
function ensureVerificationMode(value) {
|
|
877
|
+
if (value === "none" ||
|
|
878
|
+
value === "install" ||
|
|
879
|
+
value === "test" ||
|
|
880
|
+
value === "install,test") {
|
|
881
|
+
return value;
|
|
882
|
+
}
|
|
883
|
+
throw new Error("--verify must be none, install, test or install,test");
|
|
884
|
+
}
|
|
885
|
+
function ensureCiGate(value) {
|
|
886
|
+
if (value === "check" ||
|
|
887
|
+
value === "doctor" ||
|
|
888
|
+
value === "review" ||
|
|
889
|
+
value === "upgrade") {
|
|
890
|
+
return value;
|
|
891
|
+
}
|
|
892
|
+
throw new Error("--gate must be check, doctor, review or upgrade");
|
|
893
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CheckOptions, DoctorOptions,
|
|
1
|
+
import type { CheckOptions, DoctorOptions, ReviewOptions, ReviewResult } from "../types/index.js";
|
|
2
|
+
export { createDoctorResult } from "./doctor/result.js";
|
|
3
|
+
export { renderDoctorAgentReport, renderDoctorResult, } from "./doctor/render.js";
|
|
2
4
|
export declare function buildReviewResult(options: ReviewOptions | DoctorOptions | CheckOptions): Promise<ReviewResult>;
|
|
3
|
-
export declare function createDoctorResult(review: ReviewResult): DoctorResult;
|
|
4
5
|
export declare function renderReviewResult(review: ReviewResult): string;
|
|
5
|
-
export declare function renderDoctorResult(result: DoctorResult, verdictOnly?: boolean): string;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { createSummary, finalizeSummary } from "./summary.js";
|
|
3
3
|
import { buildAnalysisBundle } from "./analysis-bundle.js";
|
|
4
|
+
export { createDoctorResult } from "./doctor/result.js";
|
|
5
|
+
export { renderDoctorAgentReport, renderDoctorResult, } from "./doctor/render.js";
|
|
6
|
+
import { deriveReviewVerdict } from "./review-verdict.js";
|
|
4
7
|
export async function buildReviewResult(options) {
|
|
5
8
|
const includeChangelog = ("showChangelog" in options && options.showChangelog === true) ||
|
|
6
9
|
("includeChangelog" in options && options.includeChangelog === true) ||
|
|
@@ -48,17 +51,6 @@ export async function buildReviewResult(options) {
|
|
|
48
51
|
],
|
|
49
52
|
};
|
|
50
53
|
}
|
|
51
|
-
export function createDoctorResult(review) {
|
|
52
|
-
const verdict = review.summary.verdict ?? deriveVerdict(review.items, review.errors);
|
|
53
|
-
const primaryFindings = buildPrimaryFindings(review);
|
|
54
|
-
return {
|
|
55
|
-
verdict,
|
|
56
|
-
summary: review.summary,
|
|
57
|
-
review,
|
|
58
|
-
primaryFindings,
|
|
59
|
-
recommendedCommand: recommendCommand(review, verdict),
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
54
|
export function renderReviewResult(review) {
|
|
63
55
|
const lines = [];
|
|
64
56
|
lines.push(`Project: ${review.projectPath}`);
|
|
@@ -117,16 +109,8 @@ export function renderReviewResult(review) {
|
|
|
117
109
|
}
|
|
118
110
|
lines.push("");
|
|
119
111
|
lines.push(`Summary: ${review.summary.updatesFound} updates, riskPackages=${review.summary.riskPackages ?? 0}, securityPackages=${review.summary.securityPackages ?? 0}, peerConflictPackages=${review.summary.peerConflictPackages ?? 0}`);
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
export function renderDoctorResult(result, verdictOnly = false) {
|
|
123
|
-
const lines = [
|
|
124
|
-
`State: ${result.verdict}`,
|
|
125
|
-
`PrimaryRisk: ${result.primaryFindings[0] ?? "No blocking findings."}`,
|
|
126
|
-
`NextAction: ${result.recommendedCommand}`,
|
|
127
|
-
];
|
|
128
|
-
if (!verdictOnly) {
|
|
129
|
-
lines.push(`Counts: updates=${result.summary.updatesFound}, security=${result.summary.securityPackages ?? 0}, risk=${result.summary.riskPackages ?? 0}, peer=${result.summary.peerConflictPackages ?? 0}, license=${result.summary.licenseViolationPackages ?? 0}`);
|
|
112
|
+
if (review.summary.decisionPlan) {
|
|
113
|
+
lines.push(`DecisionPlan: ${review.summary.decisionPlan}`);
|
|
130
114
|
}
|
|
131
115
|
return lines.join("\n");
|
|
132
116
|
}
|
|
@@ -196,51 +180,6 @@ function createReviewSummary(base, items, errors, warnings, interactiveSession,
|
|
|
196
180
|
summary.monitorPackages = items.filter((item) => item.update.policyAction === "monitor").length;
|
|
197
181
|
summary.decisionPackages = items.length;
|
|
198
182
|
summary.degradedSources = degradedSources;
|
|
199
|
-
summary.verdict =
|
|
183
|
+
summary.verdict = deriveReviewVerdict(items, errors);
|
|
200
184
|
return summary;
|
|
201
185
|
}
|
|
202
|
-
function deriveVerdict(items, errors) {
|
|
203
|
-
if (items.some((item) => item.update.peerConflictSeverity === "error" ||
|
|
204
|
-
item.update.licenseStatus === "denied")) {
|
|
205
|
-
return "blocked";
|
|
206
|
-
}
|
|
207
|
-
if (items.some((item) => item.advisories.length > 0 || item.update.riskLevel === "critical")) {
|
|
208
|
-
return "actionable";
|
|
209
|
-
}
|
|
210
|
-
if (errors.length > 0 ||
|
|
211
|
-
items.some((item) => item.update.riskLevel === "high" || item.update.diffType === "major")) {
|
|
212
|
-
return "review";
|
|
213
|
-
}
|
|
214
|
-
return "safe";
|
|
215
|
-
}
|
|
216
|
-
function buildPrimaryFindings(review) {
|
|
217
|
-
const findings = [];
|
|
218
|
-
if ((review.summary.peerConflictPackages ?? 0) > 0) {
|
|
219
|
-
findings.push(`${review.summary.peerConflictPackages} package(s) have peer conflicts.`);
|
|
220
|
-
}
|
|
221
|
-
if ((review.summary.licenseViolationPackages ?? 0) > 0) {
|
|
222
|
-
findings.push(`${review.summary.licenseViolationPackages} package(s) violate license policy.`);
|
|
223
|
-
}
|
|
224
|
-
if ((review.summary.securityPackages ?? 0) > 0) {
|
|
225
|
-
findings.push(`${review.summary.securityPackages} package(s) have security advisories.`);
|
|
226
|
-
}
|
|
227
|
-
if ((review.summary.riskPackages ?? 0) > 0) {
|
|
228
|
-
findings.push(`${review.summary.riskPackages} package(s) are high risk.`);
|
|
229
|
-
}
|
|
230
|
-
if (review.errors.length > 0) {
|
|
231
|
-
findings.push(`${review.errors.length} execution error(s) need review before treating the result as clean.`);
|
|
232
|
-
}
|
|
233
|
-
if (findings.length === 0) {
|
|
234
|
-
findings.push("No blocking findings; remaining updates are low-risk.");
|
|
235
|
-
}
|
|
236
|
-
return findings;
|
|
237
|
-
}
|
|
238
|
-
function recommendCommand(review, verdict) {
|
|
239
|
-
if (verdict === "blocked")
|
|
240
|
-
return "rup review --interactive";
|
|
241
|
-
if ((review.summary.securityPackages ?? 0) > 0)
|
|
242
|
-
return "rup review --security-only";
|
|
243
|
-
if (review.errors.length > 0 || review.items.length > 0)
|
|
244
|
-
return "rup review --interactive";
|
|
245
|
-
return "rup check";
|
|
246
|
-
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function deriveReviewVerdict(items, errors) {
|
|
2
|
+
if (items.some((item) => item.update.peerConflictSeverity === "error" ||
|
|
3
|
+
item.update.licenseStatus === "denied")) {
|
|
4
|
+
return "blocked";
|
|
5
|
+
}
|
|
6
|
+
if (items.some((item) => item.advisories.length > 0 || item.update.riskLevel === "critical")) {
|
|
7
|
+
return "actionable";
|
|
8
|
+
}
|
|
9
|
+
if (errors.length > 0 ||
|
|
10
|
+
items.some((item) => item.update.riskLevel === "high" || item.update.diffType === "major")) {
|
|
11
|
+
return "review";
|
|
12
|
+
}
|
|
13
|
+
return "safe";
|
|
14
|
+
}
|
package/dist/core/summary.js
CHANGED
|
@@ -63,6 +63,18 @@ export function createSummary(input) {
|
|
|
63
63
|
cacheBackend: undefined,
|
|
64
64
|
binaryRecommended: false,
|
|
65
65
|
gaReady: undefined,
|
|
66
|
+
dependencyHealthScore: undefined,
|
|
67
|
+
findingCountsByCategory: undefined,
|
|
68
|
+
findingCountsBySeverity: undefined,
|
|
69
|
+
primaryFindingCode: undefined,
|
|
70
|
+
primaryFindingCategory: undefined,
|
|
71
|
+
nextActionReason: undefined,
|
|
72
|
+
suggestedCommand: undefined,
|
|
73
|
+
decisionPlan: undefined,
|
|
74
|
+
interactiveSurface: undefined,
|
|
75
|
+
queueFocus: undefined,
|
|
76
|
+
verificationState: "not-run",
|
|
77
|
+
verificationFailures: 0,
|
|
66
78
|
};
|
|
67
79
|
}
|
|
68
80
|
export function finalizeSummary(summary) {
|
package/dist/core/upgrade.js
CHANGED
|
@@ -5,17 +5,25 @@ import { detectPackageManager } from "../pm/detect.js";
|
|
|
5
5
|
import { applyRangeStyle, parseVersion, compareVersions } from "../utils/semver.js";
|
|
6
6
|
import { buildWorkspaceGraph } from "../workspace/graph.js";
|
|
7
7
|
import { captureLockfileSnapshot, changedLockfiles, validateLockfileMode } from "../utils/lockfile.js";
|
|
8
|
+
import { createSummary, finalizeSummary } from "./summary.js";
|
|
9
|
+
import { readDecisionPlan, selectedUpdatesFromPlan } from "./decision-plan.js";
|
|
10
|
+
import { runVerification } from "./verification.js";
|
|
8
11
|
export async function upgrade(options) {
|
|
9
12
|
validateLockfileMode(options.lockfileMode, options.install);
|
|
10
13
|
const lockfilesBefore = await captureLockfileSnapshot(options.cwd);
|
|
11
|
-
const checkResult =
|
|
14
|
+
const checkResult = options.fromPlanFile
|
|
15
|
+
? await createUpgradeResultFromPlan(options)
|
|
16
|
+
: await check(options);
|
|
12
17
|
if (checkResult.updates.length === 0) {
|
|
13
18
|
return {
|
|
14
19
|
...checkResult,
|
|
15
20
|
changed: false,
|
|
16
21
|
};
|
|
17
22
|
}
|
|
18
|
-
|
|
23
|
+
const selectedUpdates = options.fromPlanFile
|
|
24
|
+
? checkResult.updates
|
|
25
|
+
: checkResult.updates;
|
|
26
|
+
await applySelectedUpdates(options, selectedUpdates);
|
|
19
27
|
const lockfileChanges = await changedLockfiles(options.cwd, lockfilesBefore);
|
|
20
28
|
if (lockfileChanges.length > 0 && (options.lockfileMode === "preserve" || options.lockfileMode === "error")) {
|
|
21
29
|
throw new Error(`Lockfile changes detected in ${options.lockfileMode} mode: ${lockfileChanges.join(", ")}`);
|
|
@@ -23,6 +31,18 @@ export async function upgrade(options) {
|
|
|
23
31
|
if (lockfileChanges.length > 0 && options.lockfileMode === "update") {
|
|
24
32
|
checkResult.warnings.push(`Lockfiles changed: ${lockfileChanges.map((item) => item.split("/").pop()).join(", ")}`);
|
|
25
33
|
}
|
|
34
|
+
if (options.verify !== "none") {
|
|
35
|
+
const verification = await runVerification(options);
|
|
36
|
+
checkResult.summary.verificationState = verification.passed
|
|
37
|
+
? "passed"
|
|
38
|
+
: "failed";
|
|
39
|
+
checkResult.summary.verificationFailures = verification.checks.filter((check) => !check.passed).length;
|
|
40
|
+
if (!verification.passed) {
|
|
41
|
+
checkResult.errors.push(...verification.checks
|
|
42
|
+
.filter((check) => !check.passed)
|
|
43
|
+
.map((check) => `Verification failed for ${check.name}: ${check.error ?? check.command}`));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
26
46
|
return {
|
|
27
47
|
...checkResult,
|
|
28
48
|
changed: true,
|
|
@@ -59,6 +79,48 @@ export async function applySelectedUpdates(options, updates) {
|
|
|
59
79
|
await installDependencies(options.cwd, options.packageManager, detected);
|
|
60
80
|
}
|
|
61
81
|
}
|
|
82
|
+
async function createUpgradeResultFromPlan(options) {
|
|
83
|
+
if (!options.fromPlanFile) {
|
|
84
|
+
throw new Error("Missing decision plan file.");
|
|
85
|
+
}
|
|
86
|
+
const plan = await readDecisionPlan(options.fromPlanFile);
|
|
87
|
+
const packageManager = await detectPackageManager(options.cwd);
|
|
88
|
+
const updates = selectedUpdatesFromPlan(plan);
|
|
89
|
+
const packagePaths = Array.from(new Set(updates.map((update) => update.packagePath))).sort((left, right) => left.localeCompare(right));
|
|
90
|
+
const summary = finalizeSummary(createSummary({
|
|
91
|
+
scannedPackages: packagePaths.length,
|
|
92
|
+
totalDependencies: updates.length,
|
|
93
|
+
checkedDependencies: updates.length,
|
|
94
|
+
updatesFound: updates.length,
|
|
95
|
+
upgraded: 0,
|
|
96
|
+
skipped: 0,
|
|
97
|
+
warmedPackages: 0,
|
|
98
|
+
errors: [],
|
|
99
|
+
warnings: [],
|
|
100
|
+
durations: {
|
|
101
|
+
totalMs: 0,
|
|
102
|
+
discoveryMs: 0,
|
|
103
|
+
registryMs: 0,
|
|
104
|
+
cacheMs: 0,
|
|
105
|
+
},
|
|
106
|
+
}));
|
|
107
|
+
summary.decisionPlan = options.fromPlanFile;
|
|
108
|
+
summary.interactiveSurface = plan.interactiveSurface;
|
|
109
|
+
summary.queueFocus = plan.focus;
|
|
110
|
+
summary.updatesFound = updates.length;
|
|
111
|
+
return {
|
|
112
|
+
projectPath: options.cwd,
|
|
113
|
+
packagePaths,
|
|
114
|
+
packageManager,
|
|
115
|
+
target: plan.target,
|
|
116
|
+
timestamp: new Date().toISOString(),
|
|
117
|
+
summary,
|
|
118
|
+
updates,
|
|
119
|
+
errors: [],
|
|
120
|
+
warnings: [],
|
|
121
|
+
changed: false,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
62
124
|
function applyWorkspaceSync(manifestsByPath, orderedPaths, localPackageNames, includeKinds, updates) {
|
|
63
125
|
const desiredByPackage = new Map();
|
|
64
126
|
for (const update of updates) {
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { detectPackageManager, resolvePackageManager } from "../pm/detect.js";
|
|
2
|
+
import { installDependencies } from "../pm/install.js";
|
|
3
|
+
import { stableStringify } from "../utils/stable-json.js";
|
|
4
|
+
import { writeFileAtomic } from "../utils/io.js";
|
|
5
|
+
import { readEnv } from "../utils/runtime.js";
|
|
6
|
+
export async function runVerification(options) {
|
|
7
|
+
const mode = options.verify;
|
|
8
|
+
if (mode === "none") {
|
|
9
|
+
const result = {
|
|
10
|
+
mode,
|
|
11
|
+
passed: true,
|
|
12
|
+
checks: [],
|
|
13
|
+
};
|
|
14
|
+
await maybeWriteVerificationReport(options.verificationReportFile, result);
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
const checks = [];
|
|
18
|
+
const detected = await detectPackageManager(options.cwd);
|
|
19
|
+
if (includesInstall(mode)) {
|
|
20
|
+
checks.push(await runCheck("install", `${resolvePackageManager(options.packageManager, detected)} install`, async () => {
|
|
21
|
+
await installDependencies(options.cwd, options.packageManager, detected);
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
if (includesTest(mode)) {
|
|
25
|
+
const command = options.testCommand ??
|
|
26
|
+
defaultTestCommand(options.packageManager, detected);
|
|
27
|
+
checks.push(await runShellCheck(options.cwd, command));
|
|
28
|
+
}
|
|
29
|
+
const result = {
|
|
30
|
+
mode,
|
|
31
|
+
passed: checks.every((check) => check.passed),
|
|
32
|
+
checks,
|
|
33
|
+
};
|
|
34
|
+
await maybeWriteVerificationReport(options.verificationReportFile, result);
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
function includesInstall(mode) {
|
|
38
|
+
return mode === "install" || mode === "install,test";
|
|
39
|
+
}
|
|
40
|
+
function includesTest(mode) {
|
|
41
|
+
return mode === "test" || mode === "install,test";
|
|
42
|
+
}
|
|
43
|
+
function defaultTestCommand(packageManager, detected) {
|
|
44
|
+
return `${resolvePackageManager(packageManager, detected, "bun")} test`;
|
|
45
|
+
}
|
|
46
|
+
async function runShellCheck(cwd, command) {
|
|
47
|
+
const startedAt = Date.now();
|
|
48
|
+
try {
|
|
49
|
+
const shell = readEnv("SHELL") || "sh";
|
|
50
|
+
const proc = Bun.spawn([shell, "-lc", command], {
|
|
51
|
+
cwd,
|
|
52
|
+
stdin: "inherit",
|
|
53
|
+
stdout: "inherit",
|
|
54
|
+
stderr: "inherit",
|
|
55
|
+
});
|
|
56
|
+
const exitCode = await proc.exited;
|
|
57
|
+
return {
|
|
58
|
+
name: "test",
|
|
59
|
+
command,
|
|
60
|
+
passed: exitCode === 0,
|
|
61
|
+
exitCode,
|
|
62
|
+
durationMs: Math.max(0, Date.now() - startedAt),
|
|
63
|
+
error: exitCode === 0
|
|
64
|
+
? undefined
|
|
65
|
+
: `${command} failed with exit code ${exitCode}`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
return {
|
|
70
|
+
name: "test",
|
|
71
|
+
command,
|
|
72
|
+
passed: false,
|
|
73
|
+
exitCode: 1,
|
|
74
|
+
durationMs: Math.max(0, Date.now() - startedAt),
|
|
75
|
+
error: String(error),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function runCheck(name, command, action) {
|
|
80
|
+
const startedAt = Date.now();
|
|
81
|
+
try {
|
|
82
|
+
await action();
|
|
83
|
+
return {
|
|
84
|
+
name,
|
|
85
|
+
command,
|
|
86
|
+
passed: true,
|
|
87
|
+
exitCode: 0,
|
|
88
|
+
durationMs: Math.max(0, Date.now() - startedAt),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
return {
|
|
93
|
+
name,
|
|
94
|
+
command,
|
|
95
|
+
passed: false,
|
|
96
|
+
exitCode: 1,
|
|
97
|
+
durationMs: Math.max(0, Date.now() - startedAt),
|
|
98
|
+
error: String(error),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async function maybeWriteVerificationReport(filePath, result) {
|
|
103
|
+
if (!filePath)
|
|
104
|
+
return;
|
|
105
|
+
await writeFileAtomic(filePath, stableStringify(result, 2) + "\n");
|
|
106
|
+
}
|
package/dist/core/warm-cache.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
1
|
import { collectDependencies, readManifest } from "../parsers/package-json.js";
|
|
3
2
|
import { matchesPattern } from "../utils/pattern.js";
|
|
4
3
|
import { VersionCache } from "../cache/cache.js";
|
|
@@ -7,6 +6,7 @@ import { detectPackageManager } from "../pm/detect.js";
|
|
|
7
6
|
import { discoverPackageDirs } from "../workspace/discover.js";
|
|
8
7
|
import { createSummary, finalizeSummary } from "./summary.js";
|
|
9
8
|
import { formatClassifiedMessage } from "./errors.js";
|
|
9
|
+
import { writeStdout } from "../utils/runtime.js";
|
|
10
10
|
export async function warmCache(options) {
|
|
11
11
|
const startedAt = Date.now();
|
|
12
12
|
let discoveryMs = 0;
|
|
@@ -39,7 +39,7 @@ export async function warmCache(options) {
|
|
|
39
39
|
if (!options.stream)
|
|
40
40
|
return;
|
|
41
41
|
streamedEvents += 1;
|
|
42
|
-
|
|
42
|
+
writeStdout(`${message}\n`);
|
|
43
43
|
};
|
|
44
44
|
for (const packageDir of packageDirs) {
|
|
45
45
|
try {
|
package/dist/output/format.js
CHANGED
|
@@ -70,6 +70,16 @@ export function renderResult(result, format, display = {}) {
|
|
|
70
70
|
`cache_backend=${result.summary.cacheBackend ?? ""}`,
|
|
71
71
|
`degraded_sources=${(result.summary.degradedSources ?? []).join(",")}`,
|
|
72
72
|
`ga_ready=${result.summary.gaReady === true ? "1" : "0"}`,
|
|
73
|
+
`dependency_health_score=${result.summary.dependencyHealthScore ?? ""}`,
|
|
74
|
+
`primary_finding_code=${result.summary.primaryFindingCode ?? ""}`,
|
|
75
|
+
`primary_finding_category=${result.summary.primaryFindingCategory ?? ""}`,
|
|
76
|
+
`next_action_reason=${result.summary.nextActionReason ?? ""}`,
|
|
77
|
+
`suggested_command=${result.summary.suggestedCommand ?? ""}`,
|
|
78
|
+
`decision_plan=${result.summary.decisionPlan ?? ""}`,
|
|
79
|
+
`interactive_surface=${result.summary.interactiveSurface ?? ""}`,
|
|
80
|
+
`queue_focus=${result.summary.queueFocus ?? ""}`,
|
|
81
|
+
`verification_state=${result.summary.verificationState ?? "not-run"}`,
|
|
82
|
+
`verification_failures=${result.summary.verificationFailures ?? 0}`,
|
|
73
83
|
].join("\n");
|
|
74
84
|
}
|
|
75
85
|
const lines = [];
|
|
@@ -130,6 +140,18 @@ export function renderResult(result, format, display = {}) {
|
|
|
130
140
|
if (result.summary.verdict) {
|
|
131
141
|
lines.push(`Verdict=${result.summary.verdict}, riskPackages=${result.summary.riskPackages ?? 0}, securityPackages=${result.summary.securityPackages ?? 0}, peerConflictPackages=${result.summary.peerConflictPackages ?? 0}, licenseViolationPackages=${result.summary.licenseViolationPackages ?? 0}`);
|
|
132
142
|
}
|
|
143
|
+
if (typeof result.summary.dependencyHealthScore === "number") {
|
|
144
|
+
lines.push(`DependencyHealthScore=${result.summary.dependencyHealthScore}, primaryFinding=${result.summary.primaryFindingCode ?? "none"}, category=${result.summary.primaryFindingCategory ?? "none"}`);
|
|
145
|
+
}
|
|
146
|
+
if (result.summary.suggestedCommand) {
|
|
147
|
+
lines.push(`SuggestedCommand=${result.summary.suggestedCommand}`);
|
|
148
|
+
}
|
|
149
|
+
if (result.summary.decisionPlan) {
|
|
150
|
+
lines.push(`DecisionPlan=${result.summary.decisionPlan}, surface=${result.summary.interactiveSurface ?? "none"}, focus=${result.summary.queueFocus ?? "all"}`);
|
|
151
|
+
}
|
|
152
|
+
if (result.summary.verificationState && result.summary.verificationState !== "not-run") {
|
|
153
|
+
lines.push(`Verification=${result.summary.verificationState}, failures=${result.summary.verificationFailures ?? 0}`);
|
|
154
|
+
}
|
|
133
155
|
if (result.summary.runId) {
|
|
134
156
|
lines.push(`RunId=${result.summary.runId}, artifactManifest=${result.summary.artifactManifest ?? "none"}, blockedPackages=${result.summary.blockedPackages ?? 0}, reviewPackages=${result.summary.reviewPackages ?? 0}, monitorPackages=${result.summary.monitorPackages ?? 0}`);
|
|
135
157
|
}
|