Report application and runtime build identity
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.
This commit is contained in:
1 parent
a0122818ed
commit
3f9ecb4fd7
15 files changed
+292
-31
No files matched your search
@@ -87,6 +87,7 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Application packaging also populates the fpm/AppImage tool cache.
|
||||
node scripts/write-build-info.js
|
||||
npx --yes electron-builder@26.15.3 --linux rpm AppImage --x64 --publish never
|
||||
bash packaging/runtime/build-runtime-appimage.sh
|
||||
bash packaging/runtime/build-runtime-rpm.sh
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
# Node artifact files
|
||||
node_modules/
|
||||
dist/
|
||||
/.build/
|
||||
|
||||
# Compiled Java class files
|
||||
*.class
|
||||
|
||||
@@ -3,6 +3,17 @@
|
||||
All notable changes to muSRFlow are recorded here. The project follows the
|
||||
release path documented in [`TODO.md`](TODO.md).
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Quick Start now identifies the exact muSRFlow version, desktop/web edition,
|
||||
Git build revision, active runtime provider, musrfit version, and ROOT
|
||||
version. Development and locally packaged modified trees are marked as such.
|
||||
- Electron packages embed build provenance during Linux and Windows packaging;
|
||||
web deployment stamps equivalent provenance from the deployed checkout and
|
||||
configured server tools.
|
||||
- Parameter-plot controls are hidden by default and toggle with a deliberate
|
||||
tap or click on all pointer types; drag gestures remain reserved for plots.
|
||||
|
||||
## 1.0.0 (2026-11-03)
|
||||
|
||||
### Stable release
|
||||
|
||||
@@ -3263,6 +3263,32 @@ body.quick-start-document {
|
||||
padding-left: 22px;
|
||||
}
|
||||
|
||||
.quick-start-identity {
|
||||
color: var(--mu-green-dark);
|
||||
font-size: 105%;
|
||||
}
|
||||
|
||||
.quick-start-build-details {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.quick-start-build-details > div {
|
||||
display: grid;
|
||||
grid-template-columns: 5.5rem minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.quick-start-build-details dt {
|
||||
color: var(--mu-green-muted);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.quick-start-build-details dd {
|
||||
margin: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.quick-start-section-active {
|
||||
background: rgba(47, 111, 62, 0.08);
|
||||
border-left-color: var(--mu-green);
|
||||
|
||||
@@ -53,6 +53,45 @@ let quickStartWindow = null;
|
||||
let mainWindow = null;
|
||||
let pendingSharedConfigurationURL = "";
|
||||
|
||||
// Packaged applications contain build-info.json, generated immediately before
|
||||
// electron-builder runs. A development checkout instead reports its live Git
|
||||
// revision and whether local edits make it differ from that commit.
|
||||
let cachedApplicationBuildInfo = null;
|
||||
function applicationBuildInfo(runtimeInfo) {
|
||||
if (!cachedApplicationBuildInfo) {
|
||||
let revision = "unrecorded";
|
||||
let modified = false;
|
||||
try {
|
||||
const packaged = JSON.parse(fs.readFileSync(path.join(__dirname, "build-info.json"), "utf8"));
|
||||
if (packaged && /^[0-9a-f]{40}$/i.test(packaged.revision || "")) {
|
||||
revision = packaged.revision.slice(0, 12).toLowerCase();
|
||||
modified = packaged.modified === true;
|
||||
}
|
||||
} catch (error) {
|
||||
if (!app.isPackaged) {
|
||||
try {
|
||||
revision = childProcess.execFileSync("git", ["rev-parse", "--short=12", "HEAD"], {
|
||||
cwd: __dirname, encoding: "utf8", timeout: 2000
|
||||
}).trim();
|
||||
modified = childProcess.execFileSync("git", ["status", "--porcelain"], {
|
||||
cwd: __dirname, encoding: "utf8", timeout: 2000
|
||||
}).trim() !== "";
|
||||
} catch (gitError) {
|
||||
revision = "development source";
|
||||
}
|
||||
}
|
||||
}
|
||||
const platformNames = { win32: "Windows", darwin: "macOS", linux: "Linux" };
|
||||
cachedApplicationBuildInfo = {
|
||||
version: app.getVersion(),
|
||||
edition: "Electron/" + (platformNames[process.platform] || process.platform),
|
||||
revision: revision,
|
||||
modified: modified
|
||||
};
|
||||
}
|
||||
return Object.assign({}, runtimeInfo || {}, cachedApplicationBuildInfo);
|
||||
}
|
||||
|
||||
// Remember the last folder used by the Open/Save MSR dialogs, so a repeated
|
||||
// open or save starts where the previous one finished instead of the process
|
||||
// working directory. The remember is a tiny JSON file under userData; if it is
|
||||
@@ -335,11 +374,14 @@ function createWindow () {
|
||||
{
|
||||
label: 'About muSRFlow',
|
||||
click () {
|
||||
const build = applicationBuildInfo();
|
||||
dialog.showMessageBox(win, {
|
||||
type: 'info',
|
||||
title: 'About muSRFlow',
|
||||
message: `muSRFlow ${app.getVersion()}`,
|
||||
detail: 'Desktop and web workflow for musrfit\n\nAuthor: Zaher Salman\nCopyright (C) 2026 Zaher Salman\nGNU GPL version 3 or later',
|
||||
detail: build.edition + ' · build ' + build.revision
|
||||
+ (build.modified ? ' (modified)' : '')
|
||||
+ '\n\nDesktop and web workflow for musrfit\n\nAuthor: Zaher Salman\nCopyright (C) 2026 Zaher Salman\nGNU GPL version 3 or later',
|
||||
icon: path.join(__dirname, 'assets', 'musrflow-icon.png')
|
||||
});
|
||||
}
|
||||
@@ -671,10 +713,11 @@ ipcMain.on("openParameterPlotWindow", (event, options) => {
|
||||
// shell as parameter plots. Reopening Help focuses the existing window.
|
||||
ipcMain.on("openQuickStartWindow", (event, options) => {
|
||||
const sectionId = options && options.sectionId ? options.sectionId : "helpRuns";
|
||||
const buildInfo = applicationBuildInfo(options && options.buildInfo);
|
||||
if (quickStartWindow && !quickStartWindow.isDestroyed()) {
|
||||
quickStartWindow.show();
|
||||
quickStartWindow.focus();
|
||||
quickStartWindow.webContents.send("quickStartSection", { sectionId: sectionId });
|
||||
quickStartWindow.webContents.send("quickStartSection", { sectionId: sectionId, buildInfo: buildInfo });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -686,7 +729,7 @@ ipcMain.on("openQuickStartWindow", (event, options) => {
|
||||
minHeight: 360,
|
||||
file: "quick-start.html",
|
||||
dataChannel: "quickStartSection",
|
||||
data: { sectionId: sectionId, version: app.getVersion() }
|
||||
data: { sectionId: sectionId, buildInfo: buildInfo }
|
||||
});
|
||||
quickStartWindow.on("closed", () => {
|
||||
quickStartWindow = null;
|
||||
|
||||
@@ -316,6 +316,39 @@ function openElectronAuxiliaryWindow(kind, options = {}) {
|
||||
}
|
||||
window.openElectronAuxiliaryWindow = openElectronAuxiliaryWindow;
|
||||
|
||||
let cachedQuickStartRuntimeInfo = null;
|
||||
function electronQuickStartRuntimeInfo() {
|
||||
if (cachedQuickStartRuntimeInfo) return Object.assign({}, cachedQuickStartRuntimeInfo);
|
||||
let configured = typeof getConfiguredBinDir === "function" ? getConfiguredBinDir() : "";
|
||||
let provider = configured ? "configured tools" : "system tools";
|
||||
if (!configured && isWslRuntimeHost()) {
|
||||
provider = "bundled WSL runtime";
|
||||
} else if (!configured && bundledRuntimeRoot()) {
|
||||
provider = "bundled runtime";
|
||||
} else if (!configured && systemRuntimeRoot()) {
|
||||
provider = "system runtime";
|
||||
}
|
||||
let info = { runtimeProvider: provider, musrfit: "not reported", root: "not reported" };
|
||||
let command = resolveLocalCommand("musrfit");
|
||||
let launch = prepareLocalLaunch(command, ["--version"]);
|
||||
let result = nodeChildProcess.spawnSync(launch.command, launch.args, {
|
||||
env: buildToolEnvironment(),
|
||||
encoding: "utf8",
|
||||
shell: false,
|
||||
timeout: 5000
|
||||
});
|
||||
if (!result.error && result.status === 0) {
|
||||
let output = (result.stdout || "") + "\n" + (result.stderr || "");
|
||||
let musrfit = output.match(/musrfit version:\s*([^,\s]+)/i);
|
||||
let root = output.match(/ROOT version:\s*([^,\s]+)/i);
|
||||
if (musrfit) info.musrfit = musrfit[1];
|
||||
if (root) info.root = root[1].replace("/", ".");
|
||||
}
|
||||
cachedQuickStartRuntimeInfo = info;
|
||||
return Object.assign({}, info);
|
||||
}
|
||||
window.getMuSRFlowBuildInfo = electronQuickStartRuntimeInfo;
|
||||
|
||||
// Parameter-plot opening is the only part of the plotting workflow owned by
|
||||
// the main Electron renderer. The actual plot UI is rendered by the shared
|
||||
// muSRFitParameterPlot.js inside the auxiliary BrowserWindow.
|
||||
|
||||
+5
-1
@@ -7227,7 +7227,11 @@ function showQuickStartHelp() {
|
||||
// This helper exists only in the Electron renderer, so do not rely on the
|
||||
// generic amIWeb() test here.
|
||||
if (typeof window.openElectronAuxiliaryWindow === "function") {
|
||||
if (window.openElectronAuxiliaryWindow("quickStart", { sectionId: sectionId })) return;
|
||||
let options = { sectionId: sectionId };
|
||||
if (typeof window.getMuSRFlowBuildInfo === "function") {
|
||||
options.buildInfo = window.getMuSRFlowBuildInfo();
|
||||
}
|
||||
if (window.openElectronAuxiliaryWindow("quickStart", options)) return;
|
||||
}
|
||||
|
||||
// The browser keeps Help modeless so the main application remains usable.
|
||||
|
||||
+9
-4
@@ -5,14 +5,15 @@
|
||||
"description": "A desktop and web workflow for musrfit",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"build:identity": "node scripts/write-build-info.js",
|
||||
"start": "electron .",
|
||||
"test": "npm run test:electron && node tests/cgi-hardening.test.js && node tests/cgi-startup.test.js && node tests/cgi-run-download.test.js && node tests/cgi-integration.test.js && node tests/integration-musrfit.test.js",
|
||||
"dist:linux": "npm run test:electron && npx --yes electron-builder@26.15.3 --linux rpm AppImage --x64 && bash packaging/runtime/build-runtime-appimage.sh && bash packaging/runtime/build-runtime-rpm.sh && bash packaging/runtime/build-runtime-archive.sh",
|
||||
"dist:rpm": "npm run test:electron && npx --yes electron-builder@26.15.3 --linux rpm --x64 && bash packaging/runtime/build-runtime-rpm.sh && bash packaging/runtime/build-runtime-archive.sh",
|
||||
"dist:appimage": "npm run test:electron && npx --yes electron-builder@26.15.3 --linux AppImage --x64 && bash packaging/runtime/build-runtime-appimage.sh && bash packaging/runtime/build-runtime-archive.sh",
|
||||
"dist:linux": "npm run test:electron && npm run build:identity && npx --yes electron-builder@26.15.3 --linux rpm AppImage --x64 && bash packaging/runtime/build-runtime-appimage.sh && bash packaging/runtime/build-runtime-rpm.sh && bash packaging/runtime/build-runtime-archive.sh",
|
||||
"dist:rpm": "npm run test:electron && npm run build:identity && npx --yes electron-builder@26.15.3 --linux rpm --x64 && bash packaging/runtime/build-runtime-rpm.sh && bash packaging/runtime/build-runtime-archive.sh",
|
||||
"dist:appimage": "npm run test:electron && npm run build:identity && npx --yes electron-builder@26.15.3 --linux AppImage --x64 && bash packaging/runtime/build-runtime-appimage.sh && bash packaging/runtime/build-runtime-archive.sh",
|
||||
"dist:runtime": "bash packaging/runtime/build-runtime-appimage.sh && bash packaging/runtime/build-runtime-rpm.sh && bash packaging/runtime/build-runtime-archive.sh",
|
||||
"dist:runtime:archive": "bash packaging/runtime/build-runtime-archive.sh",
|
||||
"dist:win": "npm run test:electron && npx --yes electron-builder@26.15.3 --win nsis --x64",
|
||||
"dist:win": "npm run test:electron && npm run build:identity && npx --yes electron-builder@26.15.3 --win nsis --x64",
|
||||
"checksums:md5": "sh -c 'd=dist; [ -d \"$d\" ] || exit 0; for f in \"$d\"/*; do [ -f \"$f\" ] || continue; case \"$f\" in *.rpm|*.AppImage) base=$(basename \"$f\"); (cd \"$d\" && md5sum \"$base\" > \"$base.md5\");; esac; done'",
|
||||
"checksums:sha256": "sh -c 'd=dist; [ -d \"$d\" ] || exit 0; for f in \"$d\"/*; do [ -f \"$f\" ] || continue; case \"$f\" in *.rpm|*.AppImage) base=$(basename \"$f\"); (cd \"$d\" && sha256sum \"$base\" > \"$base.sha256\");; esac; done'",
|
||||
"checksums": "npm run checksums:md5 && npm run checksums:sha256",
|
||||
@@ -63,6 +64,10 @@
|
||||
"assets/**/*",
|
||||
"LICENSE",
|
||||
"package.json",
|
||||
{
|
||||
"from": ".build/build-info.json",
|
||||
"to": "build-info.json"
|
||||
},
|
||||
"node_modules/**/*"
|
||||
],
|
||||
"directories": {
|
||||
|
||||
@@ -43,6 +43,7 @@ container_id=$("$engine" create --name "musrflow-windows-$$-$RANDOM" \
|
||||
node --version
|
||||
wine --version
|
||||
npm ci --no-audit --no-fund
|
||||
node scripts/write-build-info.js
|
||||
npx --yes electron-builder@26.15.3 --win nsis --x64 --publish never
|
||||
')
|
||||
"$engine" start -a "$container_id"
|
||||
|
||||
@@ -38,6 +38,7 @@ const ALLOWED_RECEIVE_CHANNELS = [
|
||||
"startupXmlSelected",
|
||||
"binFolderSelected",
|
||||
"parameterPlotData",
|
||||
"quickStartSection",
|
||||
"wslRuntimeStatus"
|
||||
];
|
||||
|
||||
|
||||
+41
-12
@@ -52,7 +52,16 @@
|
||||
|
||||
<section class="quick-start-section" id="helpAbout">
|
||||
<h3>About muSRFlow</h3>
|
||||
<p><b>muSRFlow <span id="musrflowVersion">__MUSRFLOW_VERSION__</span></b> is a desktop and web workflow for musrfit.</p>
|
||||
<p class="quick-start-identity"><b>muSRFlow <span id="musrflowVersion">__MUSRFLOW_VERSION__</span></b>
|
||||
<span aria-hidden="true">·</span> <span id="musrflowEdition">__MUSRFLOW_EDITION__</span>
|
||||
<span aria-hidden="true">·</span> build <span id="musrflowRevision">__MUSRFLOW_REVISION__</span><span id="musrflowModified">__MUSRFLOW_MODIFIED__</span>
|
||||
</p>
|
||||
<p>Desktop and web workflow for musrfit.</p>
|
||||
<dl class="quick-start-build-details">
|
||||
<div><dt>Runtime</dt><dd id="musrflowRuntime">__MUSRFLOW_RUNTIME__</dd></div>
|
||||
<div><dt>musrfit</dt><dd id="musrfitVersion">__MUSRFIT_VERSION__</dd></div>
|
||||
<div><dt>ROOT</dt><dd id="rootVersion">__ROOT_VERSION__</dd></div>
|
||||
</dl>
|
||||
<p>Author: <a href="mailto:zaher.salman@psi.ch">Zaher Salman</a>. Copyright (C) 2026 Zaher Salman. GNU GPL version 3 or later.</p>
|
||||
</section>
|
||||
</main>
|
||||
@@ -78,28 +87,48 @@
|
||||
}, 0);
|
||||
}
|
||||
|
||||
var versionSpan = document.getElementById("musrflowVersion");
|
||||
function setVersion(version) {
|
||||
if (!versionSpan) return;
|
||||
if (version) {
|
||||
versionSpan.textContent = version;
|
||||
} else if (versionSpan.textContent.indexOf("__MUSRFLOW_VERSION__") !== -1) {
|
||||
versionSpan.textContent = "development build";
|
||||
function displayValue(id, value, fallback) {
|
||||
let element = document.getElementById(id);
|
||||
if (!element) return;
|
||||
let current = element.textContent || "";
|
||||
if (value) element.textContent = value;
|
||||
else if (/^__.+__$/.test(current)) element.textContent = fallback;
|
||||
}
|
||||
|
||||
function setBuildInfo(info) {
|
||||
info = info || {};
|
||||
displayValue("musrflowVersion", info.version, "development source");
|
||||
displayValue("musrflowEdition", info.edition, "Web source");
|
||||
displayValue("musrflowRevision", info.revision, "unrecorded");
|
||||
displayValue("musrflowRuntime", info.runtimeProvider, "not reported");
|
||||
displayValue("musrfitVersion", info.musrfit, "not reported");
|
||||
displayValue("rootVersion", info.root, "not reported");
|
||||
let modified = document.getElementById("musrflowModified");
|
||||
if (modified && typeof info.modified === "boolean") {
|
||||
modified.textContent = info.modified ? " (modified)" : "";
|
||||
} else if (modified && /^__.+__$/.test(modified.textContent || "")) {
|
||||
modified.textContent = "";
|
||||
}
|
||||
}
|
||||
|
||||
window.focusQuickStartSection = focusSection;
|
||||
setVersion();
|
||||
setBuildInfo();
|
||||
focusSection(window.location.hash ? window.location.hash.slice(1) : "helpRuns");
|
||||
window.addEventListener("hashchange", function() {
|
||||
focusSection(window.location.hash ? window.location.hash.slice(1) : "helpRuns");
|
||||
});
|
||||
|
||||
if (typeof require === "function") {
|
||||
function receiveQuickStartPayload(payload) {
|
||||
focusSection(payload && payload.sectionId ? payload.sectionId : "helpRuns");
|
||||
setBuildInfo(payload && payload.buildInfo);
|
||||
}
|
||||
|
||||
if (window.electronAPI && window.electronAPI.ipc) {
|
||||
window.electronAPI.ipc.on("quickStartSection", receiveQuickStartPayload);
|
||||
} else if (typeof require === "function") {
|
||||
try {
|
||||
require("electron").ipcRenderer.on("quickStartSection", function(event, payload) {
|
||||
focusSection(payload && payload.sectionId ? payload.sectionId : "helpRuns");
|
||||
setVersion(payload && payload.version);
|
||||
receiveQuickStartPayload(payload);
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("Could not attach Quick Start Electron channel:", error);
|
||||
|
||||
+28
-8
@@ -44,20 +44,40 @@ cp -R "$docs_source/." "$web_target/docs/"
|
||||
find "$web_target/docs" -type d -exec chmod 0755 {} +
|
||||
find "$web_target/docs" -type f -exec chmod 0644 {} +
|
||||
|
||||
# Brand the installed help page with the current release version, matching the
|
||||
# About dialog in the Electron edition. The source keeps a __MUSRFLOW_VERSION__
|
||||
# token that renders as "development build" when left unsubstituted; the
|
||||
# installed copy is rewritten with the version from package.json. Idempotent:
|
||||
# an already-branded file contains no token, so re-running matches nothing.
|
||||
# Stamp the deployed help with reproducible application and runtime identity.
|
||||
# The Git revision identifies the exact deployed source; musrfit reports both
|
||||
# its own and ROOT's versions using the same executable configured for the CGI.
|
||||
if command -v node >/dev/null 2>&1; then
|
||||
version="$(node -p 'require(process.argv[1]).version' "$project_root/package.json")"
|
||||
revision="$(git -C "$project_root" rev-parse --short=12 HEAD 2>/dev/null || printf 'unrecorded')"
|
||||
modified=""
|
||||
if [ -n "$(git -C "$project_root" status --porcelain 2>/dev/null || true)" ]; then
|
||||
modified=" (modified)"
|
||||
fi
|
||||
musrfit_bin="${MUSRFIT_BIN:-/usr/local/bin/musrfit}"
|
||||
musrfit_output=""
|
||||
if [ -x "$musrfit_bin" ]; then
|
||||
musrfit_output="$("$musrfit_bin" --version 2>/dev/null || true)"
|
||||
fi
|
||||
musrfit_version="$(printf '%s\n' "$musrfit_output" | sed -n 's/.*musrfit version:[[:space:]]*\([^,[:space:]]*\).*/\1/p' | head -n 1)"
|
||||
root_version="$(printf '%s\n' "$musrfit_output" | sed -n 's/.*ROOT version:[[:space:]]*\([^,[:space:]]*\).*/\1/p' | head -n 1 | tr / .)"
|
||||
musrfit_version="${musrfit_version:-not reported}"
|
||||
root_version="${root_version:-not reported}"
|
||||
tmp_qs="$(mktemp)"
|
||||
sed "s#__MUSRFLOW_VERSION__#$version#g" "$web_target/quick-start.html" > "$tmp_qs"
|
||||
sed -e "s#__MUSRFLOW_VERSION__#$version#g" \
|
||||
-e "s#__MUSRFLOW_EDITION__#Web#g" \
|
||||
-e "s#__MUSRFLOW_REVISION__#$revision#g" \
|
||||
-e "s#__MUSRFLOW_MODIFIED__#$modified#g" \
|
||||
-e "s#__MUSRFLOW_RUNTIME__#server tools#g" \
|
||||
-e "s#__MUSRFIT_VERSION__#$musrfit_version#g" \
|
||||
-e "s#__ROOT_VERSION__#$root_version#g" \
|
||||
"$web_target/quick-start.html" > "$tmp_qs"
|
||||
install -m 0644 "$tmp_qs" "$web_target/quick-start.html"
|
||||
rm -f "$tmp_qs"
|
||||
printf 'Branded %s with muSRFlow version %s\n' "$web_target/quick-start.html" "$version"
|
||||
printf 'Branded %s with muSRFlow %s · Web · build %s\n' \
|
||||
"$web_target/quick-start.html" "$version" "$revision"
|
||||
else
|
||||
printf 'node not found; quick-start.html keeps the source version token\n'
|
||||
printf 'node not found; quick-start.html keeps its development-source identity\n'
|
||||
fi
|
||||
|
||||
# Apache executes the runner through the existing /cgi-bin ScriptAlias.
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// 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)" : ""));
|
||||
@@ -16,6 +16,7 @@ function testSharedHelpWindowInfrastructure() {
|
||||
const html = fs.readFileSync(path.join(repoRoot, "index.html"), "utf8");
|
||||
const help = fs.readFileSync(path.join(repoRoot, "quick-start.html"), "utf8");
|
||||
const deploy = fs.readFileSync(path.join(repoRoot, "scripts", "deploy-web.sh"), "utf8");
|
||||
const preload = fs.readFileSync(path.join(repoRoot, "preload.js"), "utf8");
|
||||
|
||||
assert.match(main, /function createAuxiliaryWindow/);
|
||||
assert.match(main, /createParameterPlotWindow[\s\S]*createAuxiliaryWindow/);
|
||||
@@ -38,12 +39,23 @@ function testSharedHelpWindowInfrastructure() {
|
||||
assert.match(help, /id="helpAbout"/);
|
||||
assert.match(help, /About muSRFlow/);
|
||||
assert.match(help, /id="musrflowVersion"/);
|
||||
assert.match(help, /setVersion\(payload && payload\.version\)/);
|
||||
assert.match(help, /id="musrflowRevision"/);
|
||||
assert.match(help, /id="musrflowRuntime"/);
|
||||
assert.match(help, /setBuildInfo\(payload && payload\.buildInfo\)/);
|
||||
assert.match(help, /window\.electronAPI\.ipc\.on\("quickStartSection"/);
|
||||
assert.match(preload, /"quickStartSection"/);
|
||||
assert.match(main, /version: app\.getVersion\(\)/);
|
||||
assert.match(main, /Electron\/.*platformNames/);
|
||||
assert.match(main, /build-info\.json/);
|
||||
assert.match(elec, /electronQuickStartRuntimeInfo/);
|
||||
assert.match(elec, /musrfit version:/);
|
||||
assert.match(elec, /ROOT version:/);
|
||||
assert.match(main, /shell\.openExternal/);
|
||||
assert.match(main, /setWindowOpenHandler/);
|
||||
assert.match(deploy, /quick-start\.html/);
|
||||
assert.match(deploy, /__MUSRFLOW_VERSION__/);
|
||||
assert.match(deploy, /__MUSRFLOW_REVISION__/);
|
||||
assert.match(deploy, /git -C "\$project_root" rev-parse --short=12 HEAD/);
|
||||
assert.match(deploy, /node -p 'require\(process\.argv\[1\]\)\.version'/);
|
||||
assert.doesNotMatch(lib, /musrfit-gui|bitbucket\.org\/zaher-salman\/musrfit-gui/);
|
||||
}
|
||||
@@ -64,12 +76,14 @@ function testDocumentationDeployment() {
|
||||
"muSRFitParameterPlot.js", "muSRFitlib.js", "assets/musrflow-favicon.png", "assets/musrflow-icon.png",
|
||||
"cgi/single_musrfit.cgi", "cgi/musrfit_startup.xml"];
|
||||
for (const file of assets) fs.writeFileSync(path.join(source, file), "fixture\n");
|
||||
fs.copyFileSync(path.join(repoRoot, "quick-start.html"), path.join(source, "quick-start.html"));
|
||||
fs.writeFileSync(path.join(source, "package.json"), JSON.stringify({ version: "1.2.3" }));
|
||||
const options = { encoding: "utf8", env: { ...process.env,
|
||||
MUSRFLOW_WEB_TARGET: path.join(target, "web"),
|
||||
MUSRFLOW_CGI_TARGET: path.join(target, "runner.cgi"),
|
||||
MUSRFLOW_STARTUP_XML_TARGET: path.join(target, "startup.xml"),
|
||||
MUSRFLOW_WEB_OWNER: "", MUSRFLOW_WEB_GROUP: "", MUSRFLOW_DATA_ROOT: "" } };
|
||||
MUSRFLOW_WEB_OWNER: "", MUSRFLOW_WEB_GROUP: "", MUSRFLOW_DATA_ROOT: "",
|
||||
MUSRFIT_BIN: path.join(source, "missing-musrfit") } };
|
||||
const script = path.join(source, "scripts/deploy-web.sh");
|
||||
const missing = spawnSync("bash", [script], options);
|
||||
assert.strictEqual(missing.status, 1, missing.stderr);
|
||||
@@ -85,6 +99,11 @@ function testDocumentationDeployment() {
|
||||
const deployed = spawnSync("bash", [script], options);
|
||||
assert.strictEqual(deployed.status, 0, deployed.stderr);
|
||||
assert.match(deployed.stdout, /Installed muSRFlow HTML manual/);
|
||||
const installedHelp = fs.readFileSync(path.join(target, "web/quick-start.html"), "utf8");
|
||||
assert.match(installedHelp, /id="musrflowVersion">1\.2\.3</);
|
||||
assert.match(installedHelp, /id="musrflowEdition">Web</);
|
||||
assert.match(installedHelp, /id="musrflowRevision">unrecorded</);
|
||||
assert.doesNotMatch(installedHelp, /__MUSRFLOW_|__MUSRFIT_|__ROOT_/);
|
||||
for (const file of pages) {
|
||||
const installed = path.join(target, "web/docs", file);
|
||||
assert.strictEqual(fs.readFileSync(installed, "utf8"), file);
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const root = path.resolve(__dirname, '..');
|
||||
const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
||||
@@ -23,6 +25,8 @@ assert(!pkg.build.rpm.artifactName.includes('${productName}'), 'RPM artifact nam
|
||||
assert(pkg.build.rpm.fpm.some(function(arg) { return arg === '--rpm-rpmbuild-define=_build_id_links none'; }), 'RPM must not package build-id links');
|
||||
assert(pkg.scripts['dist:rpm'].includes('electron-builder@26.15.3'));
|
||||
assert(pkg.scripts['dist:appimage'].includes('electron-builder@26.15.3'));
|
||||
assert(pkg.scripts['dist:rpm'].includes('npm run build:identity'));
|
||||
assert(pkg.scripts['dist:win'].includes('npm run build:identity'));
|
||||
assert(pkg.scripts['checksums:md5'].includes('md5sum'));
|
||||
assert(pkg.scripts['checksums:sha256'].includes('sha256sum'));
|
||||
assert.strictEqual(pkg.scripts.checksums, 'npm run checksums:md5 && npm run checksums:sha256');
|
||||
@@ -73,8 +77,27 @@ for (const script of [
|
||||
assert(fs.existsSync(path.join(root, script)), `runtime packaging file is missing: ${script}`);
|
||||
}
|
||||
|
||||
assert(pkg.build.files.some(function(file) {
|
||||
return typeof file === 'object' && file.from === '.build/build-info.json' && file.to === 'build-info.json';
|
||||
}), 'packaged apps must contain their generated source identity');
|
||||
assert(fs.existsSync(path.join(root, 'scripts/write-build-info.js')));
|
||||
const identityDirectory = fs.mkdtempSync(path.join(os.tmpdir(), 'musrflow-build-identity-'));
|
||||
try {
|
||||
const identityPath = path.join(identityDirectory, 'build-info.json');
|
||||
const generated = spawnSync(process.execPath,
|
||||
[path.join(root, 'scripts/write-build-info.js'), identityPath], {
|
||||
encoding: 'utf8', env: { ...process.env,
|
||||
MUSRFLOW_BUILD_REVISION: 'a'.repeat(40), MUSRFLOW_BUILD_MODIFIED: '0' }
|
||||
});
|
||||
assert.strictEqual(generated.status, 0, generated.stderr);
|
||||
assert.deepStrictEqual(JSON.parse(fs.readFileSync(identityPath, 'utf8')), {
|
||||
schemaVersion: 1, version: pkg.version, revision: 'a'.repeat(40), modified: false
|
||||
});
|
||||
} finally {
|
||||
fs.rmSync(identityDirectory, { recursive: true, force: true });
|
||||
}
|
||||
for (const file of pkg.build.files) {
|
||||
if (file.includes('*') || file === 'package.json') continue;
|
||||
if (typeof file !== 'string' || file.includes('*') || file === 'package.json') continue;
|
||||
assert(fs.existsSync(path.join(root, file)), `packaged file is missing: ${file}`);
|
||||
}
|
||||
|
||||
@@ -93,6 +116,7 @@ assert(packageWorkflow.includes('actions/download-artifact@'));
|
||||
assert(packageWorkflow.includes('actions/upload-artifact@'));
|
||||
assert(!packageWorkflow.includes('build_runtime:'));
|
||||
assert(packageWorkflow.includes('--publish never'));
|
||||
assert(packageWorkflow.includes('node scripts/write-build-info.js'));
|
||||
assert(packageWorkflow.indexOf('node scripts/ci-restore-runtime.js') < packageWorkflow.indexOf('npx --yes electron-builder'));
|
||||
assert(packageWorkflow.includes('cp "dist/$file" "dist/$file.md5" "dist/$file.sha256" artifacts/'));
|
||||
assert(!packageWorkflow.includes('|| true'));
|
||||
|
||||
Reference in new issue
Block a user