update build process and versioning

This commit is contained in:
Nystik
2026-05-26 02:55:24 +02:00
parent 28effab1ed
commit d5fb9e1e1d
11 changed files with 83 additions and 36 deletions

View File

@@ -11,4 +11,4 @@ demo-vaults
data
tmp
**/dist
packages/bridge/main.js
apps/ignis-server/server/build-info.json

2
.gitignore vendored
View File

@@ -3,6 +3,6 @@ dist/
investigation/
vaults/
packages/*/dist/
packages/bridge/main.js
apps/ignis-server/server/build-info.json
demo-vaults/
data/

View File

@@ -53,6 +53,7 @@ COPY packages/server-core/src/ ./packages/server-core/src/
# Built artifacts from the build stage.
COPY --from=build /app/packages/shim/dist/shim-loader.js ./packages/shim/dist/shim-loader.js
COPY --from=build /app/packages/ui/dist/ignis-ui.js ./packages/ui/dist/ignis-ui.js
COPY --from=build /app/apps/ignis-server/server/build-info.json ./apps/ignis-server/server/build-info.json
COPY --from=build /app/apps/ignis-server/server/plugins/headless-sync/obsidian/dist/ ./apps/ignis-server/server/plugins/headless-sync/obsidian/dist/
RUN chmod +x /app/apps/ignis-server/scripts/entrypoint.sh

View File

@@ -103,7 +103,6 @@ module.exports = {
const assetsPath =
process.env.OBSIDIAN_ASSETS_PATH ||
path.join(__dirname, "..", "investigation", "obsidian_1.12.7_unpacked");
q;
try {
const pkg = JSON.parse(
fs.readFileSync(path.join(assetsPath, "package.json"), "utf-8"),

View File

@@ -1,6 +1,6 @@
{
"id": "ignis-headless-sync",
"name": "Ignis Headless Sync",
"name": "Headless Sync",
"version": "0.3.0",
"minAppVersion": "1.12.4",
"description": "Client-side companion for server-side Obsidian Sync",

View File

@@ -1,15 +1,14 @@
const express = require("express");
const { getVersion } = require("../version");
const { getSemver, getBuild } = require("../version");
const config = require("../config");
const router = express.Router();
// `version` is the display-friendly SemVer. `build` is the per-build stamp for cache-bust.
router.get("/", (req, res) => {
const pkg = require("../../package.json");
res.json({
version: getVersion(),
semver: pkg.version,
version: getSemver(),
build: getBuild(),
obsidianVersion: config.obsidianVersion,
});
});

View File

@@ -1,23 +1,51 @@
const fs = require("fs");
const path = require("path");
const { execSync } = require("child_process");
let cached = null;
function load() {
if (cached) {
return cached;
}
// Production: root build.js writes this next to us.
try {
cached = JSON.parse(
fs.readFileSync(path.join(__dirname, "build-info.json"), "utf-8"),
);
return cached;
} catch {}
// Local dev fallback. Read root package.json.
try {
const pkg = JSON.parse(
fs.readFileSync(
path.join(__dirname, "..", "..", "..", "package.json"),
"utf-8",
),
);
cached = {
semver: pkg.version,
build: "dev",
version: `${pkg.version}-dev`,
};
return cached;
} catch {}
cached = { semver: "0.0.0", build: "unknown", version: "0.0.0-unknown" };
return cached;
}
function getVersion() {
const pkg = JSON.parse(
fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf-8"),
);
const semver = pkg.version;
let hash;
try {
hash = execSync("git rev-parse --short=7 HEAD", {
encoding: "utf-8",
}).trim();
} catch (e) {
hash = Date.now().toString(36).slice(-7);
return load().version;
}
return `${semver}-${hash}`;
function getSemver() {
return load().semver;
}
module.exports = { getVersion };
function getBuild() {
return load().build;
}
module.exports = { getVersion, getSemver, getBuild };

View File

@@ -12,6 +12,27 @@ const headlessSyncDir = path.join(
"obsidian",
);
// Compute version info once and share across per-package builds.
const { version: semver } = require("./package.json");
const build = process.env.IGNIS_BUILD || Date.now().toString(36).slice(-7);
const version = `${semver}+${build}`;
const buildInfoPath = path.join(
__dirname,
"apps",
"ignis-server",
"server",
"build-info.json",
);
fs.writeFileSync(
buildInfoPath,
JSON.stringify({ semver, build, version }, null, 2),
);
// Used by packages.
process.env.IGNIS_BUILD_RESOLVED = build;
Promise.all([
// Build shim-loader.js (delegated to packages/shim)
require("./packages/shim/build.js"),

View File

@@ -4,13 +4,8 @@ const GITHUB_URL = "https://github.com/Nystik-gh/ignis";
const GITHUB_API_LATEST =
"https://api.github.com/repos/Nystik-gh/ignis/releases/latest";
function getVersion(app) {
try {
const manifest = app.plugins.getPlugin("ignis-bridge")?.manifest;
return manifest?.version || "unknown";
} catch {
return "unknown";
}
function getVersion() {
return window.__ignis?.version || "unknown";
}
// SemVer build metadata (`+xyz`) is informational and ignored for precedence.
@@ -41,7 +36,7 @@ async function checkForUpdate(currentVersion) {
}
function display(containerEl, app) {
const version = getVersion(app);
const version = getVersion();
const header = containerEl.createDiv("ignis-header");

View File

@@ -1,7 +1,10 @@
const esbuild = require("esbuild");
const path = require("path");
const { version: ignisVersion } = require("../../package.json");
const { version: semver } = require("../../package.json");
// Root build.js sets IGNIS_BUILD_RESOLVED when it runs first; standalone invocation falls back to a dev stamp.
const build = process.env.IGNIS_BUILD_RESOLVED || "dev";
module.exports = esbuild.build({
entryPoints: [path.join(__dirname, "src", "loader.js")],
@@ -18,7 +21,8 @@ module.exports = esbuild.build({
},
external: ["obsidian", "fs"],
define: {
__IGNIS_VERSION__: JSON.stringify(ignisVersion),
__IGNIS_VERSION__: JSON.stringify(semver),
__IGNIS_BUILD__: JSON.stringify(build),
},
logLevel: "info",
});

View File

@@ -13,8 +13,8 @@ import {
import { wsClient } from "./ws-client.js";
import { installIgnisApi } from "./ignis-api.js";
// __IGNIS_VERSION__ is replaced at build time from package.json.
window.__ignis = { version: __IGNIS_VERSION__ };
// __IGNIS_VERSION__ (semver) and __IGNIS_BUILD__ are replaced at build time.
window.__ignis = { version: __IGNIS_VERSION__, build: __IGNIS_BUILD__ };
window.__ignis_registerUI = registerUI;
installIgnisApi(wsClient);