2026-03-18 00:40:06 -06:00
|
|
|
import { readFileSync, writeFileSync } from "fs";
|
2026-04-13 08:56:12 -04:00
|
|
|
import { execFileSync, execSync } from "child_process";
|
|
|
|
|
import { fileURLToPath } from "url";
|
|
|
|
|
import { dirname, resolve } from "path";
|
|
|
|
|
|
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
|
|
const root = resolve(__dirname, "..");
|
2026-03-18 00:40:06 -06:00
|
|
|
|
|
|
|
|
const pkgPath = new URL("../package.json", import.meta.url);
|
|
|
|
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
|
|
|
|
|
|
|
|
const shortSha = execFileSync("git", ["rev-parse", "--short", "HEAD"], { encoding: "utf8" }).trim();
|
|
|
|
|
const devVersion = `${pkg.version}-dev.${shortSha}`;
|
|
|
|
|
|
|
|
|
|
pkg.version = devVersion;
|
|
|
|
|
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
|
|
|
console.log(`Stamped version: ${devVersion}`);
|
2026-04-13 08:56:12 -04:00
|
|
|
|
|
|
|
|
// Regenerate package-lock.json to reflect the stamped dev version.
|
|
|
|
|
// --package-lock-only updates the lockfile in-place without touching node_modules.
|
|
|
|
|
execSync("npm install --package-lock-only --ignore-scripts", { cwd: root, stdio: "inherit" });
|
|
|
|
|
console.log(`[version-stamp] package-lock.json regenerated at ${devVersion}`);
|