singularity-forge/scripts/version-stamp.mjs
Mikael Hugo 6744f6d254 chore: update version and changelog scripts
💘 Generated with Crush

Assisted-by: GLM-5.1 via Crush <crush@charm.land>
2026-05-02 06:19:16 +02:00

21 lines
951 B
JavaScript

import { readFileSync, writeFileSync } from "fs";
import { execFileSync, execSync } from "child_process";
import { resolve } from "path";
const __dirname = import.meta.dirname;
const root = resolve(__dirname, "..");
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}`);
// 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}`);