mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
chore: address restructure PR review feedback (#6423)
This commit is contained in:
@@ -6,9 +6,18 @@
|
||||
* Vite automatically layers these `.local` files on top of the committed ones.
|
||||
*
|
||||
* Usage:
|
||||
* tsx scripts/setup-env.ts # ensures .env.local
|
||||
* tsx scripts/setup-env.ts --desktop # also ensures .env.desktop.local
|
||||
* tsx scripts/setup-env.ts --saas # also ensures .env.saas.local
|
||||
* tsx scripts/setup-env.mts # ensures .env.local
|
||||
* tsx scripts/setup-env.mts --desktop # also ensures .env.desktop.local
|
||||
* tsx scripts/setup-env.mts --saas # also ensures .env.saas.local
|
||||
*
|
||||
* Why .mts (and not .ts)?
|
||||
* This script needs `import.meta.url` to resolve paths relative to itself,
|
||||
* because Task invokes it from the workspace root (frontend/) but the .env
|
||||
* files live one level deeper at frontend/editor/. `import.meta` is only
|
||||
* valid in ESM output; `editor/scripts/tsconfig.json` extends the editor
|
||||
* tsconfig which uses `module: node16`, treating plain .ts as CommonJS
|
||||
* (TS1470 error on `import.meta`). The .mts extension explicitly marks
|
||||
* the file as ESM, which tsx already runs at runtime anyway.
|
||||
*/
|
||||
|
||||
import { existsSync, writeFileSync } from "fs";
|
||||
@@ -17,8 +26,6 @@ import { fileURLToPath } from "url";
|
||||
|
||||
// .env files live next to the editor's vite.config.ts (frontend/editor/).
|
||||
// Resolve relative to this script regardless of where the build was invoked.
|
||||
// `import.meta.dirname` would be tidier but isn't available under tsx's CJS
|
||||
// transpilation today, so go via fileURLToPath for portability.
|
||||
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
||||
const root = resolve(scriptDir, "..");
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/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);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user