From 97e2dc2c68c95c4ee8048913becbc798a75f39a1 Mon Sep 17 00:00:00 2001 From: Ludy Date: Wed, 22 Apr 2026 12:50:01 +0200 Subject: [PATCH] chore(frontend): replace platform-specific update:minor script with cross-platform Node.js implementation (#6155) --- frontend/package.json | 2 +- frontend/scripts/update-minor.js | 54 ++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 frontend/scripts/update-minor.js diff --git a/frontend/package.json b/frontend/package.json index a26b3315fd..2b41366fb0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -80,7 +80,7 @@ "web-vitals": "^5.1.0" }, "scripts": { - "update:minor": "npm outdated || npm update --before=$(date -v-7d +%Y-%m-%d) && (npm audit fix --before=$(date -v-7d +%Y-%m-%d) || true) && npm test", + "update:minor": "node scripts/update-minor.js", "update:major": "npx npm-check-updates -u && npm install", "update:interactive": "npx npm-check-updates -i", "update:minor-strict": "npx npm-check-updates -u --target minor && npm install" diff --git a/frontend/scripts/update-minor.js b/frontend/scripts/update-minor.js new file mode 100644 index 0000000000..3765265656 --- /dev/null +++ b/frontend/scripts/update-minor.js @@ -0,0 +1,54 @@ +#!/usr/bin/env node + +/** + * Cross-platform update:minor script + * Calculates date from 7 days ago and runs npm update/audit with that date + */ + +const { spawn } = require("child_process"); + +// Calculate date from 7 days ago in YYYY-MM-DD format +const date = new Date(); +date.setDate(date.getDate() - 7); +const beforeDate = date.toISOString().split("T")[0]; + +console.log(`Updating packages modified before: ${beforeDate}`); + +let lastExitCode = 0; + +// Run npm outdated first +const outdated = spawn("npm", ["outdated"], { stdio: "inherit", shell: true }); + +outdated.on("close", (_code) => { + // npm outdated returns exit code 1 if updates are available, so we ignore it + + // Run npm update with before date + const update = spawn("npm", ["update", `--before=${beforeDate}`], { + stdio: "inherit", + shell: true, + }); + + update.on("close", (updateCode) => { + // Track update failures + if (updateCode !== 0) { + lastExitCode = updateCode; + } + + // Run npm audit fix with before date + const audit = spawn("npm", ["audit", "fix", `--before=${beforeDate}`], { + stdio: "inherit", + shell: true, + }); + + audit.on("close", (auditCode) => { + // Track audit failures (but don't override critical update failures) + if (auditCode !== 0 && lastExitCode === 0) { + lastExitCode = auditCode; + } + + // Update complete - report with tracked exit code + console.log("\nPackage update complete!"); + process.exit(lastExitCode); + }); + }); +});