Show version, edition, Git revision, runtime provider, musrfit, and ROOT in Quick Start across Electron and web deployments. Embed source provenance in Linux and Windows packages, repair the hardened help-window IPC path, and make Plotly controls toggle consistently by tap or click.
44 lines
1.6 KiB
JavaScript
44 lines
1.6 KiB
JavaScript
// Copyright (C) 2026 Zaher Salman
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
// Generate immutable application provenance immediately before electron-builder
|
|
// packages the source. Keeping this outside package.json avoids changing release
|
|
// metadata merely to record which commit produced a particular binary.
|
|
const childProcess = require("child_process");
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
const projectRoot = path.resolve(__dirname, "..");
|
|
const output = path.resolve(process.argv[2] || path.join(projectRoot, ".build", "build-info.json"));
|
|
const packageMetadata = require(path.join(projectRoot, "package.json"));
|
|
|
|
let revision = String(process.env.MUSRFLOW_BUILD_REVISION || "").trim();
|
|
if (!revision) {
|
|
revision = childProcess.execFileSync("git", ["rev-parse", "HEAD"], {
|
|
cwd: projectRoot,
|
|
encoding: "utf8"
|
|
}).trim();
|
|
}
|
|
if (!/^[0-9a-f]{40}$/i.test(revision)) {
|
|
throw new Error("muSRFlow build revision is not a full Git commit hash");
|
|
}
|
|
let modified;
|
|
if (/^[01]$/.test(process.env.MUSRFLOW_BUILD_MODIFIED || "")) {
|
|
modified = process.env.MUSRFLOW_BUILD_MODIFIED === "1";
|
|
} else {
|
|
modified = childProcess.execFileSync("git", ["status", "--porcelain"], {
|
|
cwd: projectRoot,
|
|
encoding: "utf8"
|
|
}).trim() !== "";
|
|
}
|
|
|
|
fs.mkdirSync(path.dirname(output), { recursive: true });
|
|
fs.writeFileSync(output, JSON.stringify({
|
|
schemaVersion: 1,
|
|
version: packageMetadata.version,
|
|
revision: revision.toLowerCase(),
|
|
modified: modified
|
|
}, null, 2) + "\n");
|
|
console.log("Wrote muSRFlow build identity " + packageMetadata.version + " @ " + revision.slice(0, 12)
|
|
+ (modified ? " (modified)" : ""));
|