Files
wehub-resource-sync bf122cd71b
AI Engine CI / engine (push) Failing after 0s
Check generated models / generated-models (push) Failing after 1s
Enterprise E2E (Playwright) / pick (push) Failing after 8s
Enterprise E2E (Playwright) / playwright-e2e-enterprise (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:59:14 +08:00

55 lines
1.5 KiB
JavaScript

#!/usr/bin/env node
/**
* Cross-platform update:minor script
* Calculates date from 7 days ago and runs npm update/audit with that date
*/
import { spawn } from "node: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);
});
});
});