mirror of
https://github.com/Nystik-gh/ignis.git
synced 2026-06-17 04:35:53 +00:00
update build process and versioning
This commit is contained in:
@@ -11,4 +11,4 @@ demo-vaults
|
|||||||
data
|
data
|
||||||
tmp
|
tmp
|
||||||
**/dist
|
**/dist
|
||||||
packages/bridge/main.js
|
apps/ignis-server/server/build-info.json
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,6 +3,6 @@ dist/
|
|||||||
investigation/
|
investigation/
|
||||||
vaults/
|
vaults/
|
||||||
packages/*/dist/
|
packages/*/dist/
|
||||||
packages/bridge/main.js
|
apps/ignis-server/server/build-info.json
|
||||||
demo-vaults/
|
demo-vaults/
|
||||||
data/
|
data/
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ COPY packages/server-core/src/ ./packages/server-core/src/
|
|||||||
# Built artifacts from the build stage.
|
# 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/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/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/
|
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
|
RUN chmod +x /app/apps/ignis-server/scripts/entrypoint.sh
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ module.exports = {
|
|||||||
const assetsPath =
|
const assetsPath =
|
||||||
process.env.OBSIDIAN_ASSETS_PATH ||
|
process.env.OBSIDIAN_ASSETS_PATH ||
|
||||||
path.join(__dirname, "..", "investigation", "obsidian_1.12.7_unpacked");
|
path.join(__dirname, "..", "investigation", "obsidian_1.12.7_unpacked");
|
||||||
q;
|
|
||||||
try {
|
try {
|
||||||
const pkg = JSON.parse(
|
const pkg = JSON.parse(
|
||||||
fs.readFileSync(path.join(assetsPath, "package.json"), "utf-8"),
|
fs.readFileSync(path.join(assetsPath, "package.json"), "utf-8"),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"id": "ignis-headless-sync",
|
"id": "ignis-headless-sync",
|
||||||
"name": "Ignis Headless Sync",
|
"name": "Headless Sync",
|
||||||
"version": "0.3.0",
|
"version": "0.3.0",
|
||||||
"minAppVersion": "1.12.4",
|
"minAppVersion": "1.12.4",
|
||||||
"description": "Client-side companion for server-side Obsidian Sync",
|
"description": "Client-side companion for server-side Obsidian Sync",
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
const express = require("express");
|
const express = require("express");
|
||||||
const { getVersion } = require("../version");
|
const { getSemver, getBuild } = require("../version");
|
||||||
const config = require("../config");
|
const config = require("../config");
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
// `version` is the display-friendly SemVer. `build` is the per-build stamp for cache-bust.
|
||||||
router.get("/", (req, res) => {
|
router.get("/", (req, res) => {
|
||||||
const pkg = require("../../package.json");
|
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
version: getVersion(),
|
version: getSemver(),
|
||||||
semver: pkg.version,
|
build: getBuild(),
|
||||||
obsidianVersion: config.obsidianVersion,
|
obsidianVersion: config.obsidianVersion,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,23 +1,51 @@
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const { execSync } = require("child_process");
|
|
||||||
|
|
||||||
function getVersion() {
|
let cached = null;
|
||||||
const pkg = JSON.parse(
|
|
||||||
fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf-8"),
|
|
||||||
);
|
|
||||||
const semver = pkg.version;
|
|
||||||
|
|
||||||
let hash;
|
function load() {
|
||||||
try {
|
if (cached) {
|
||||||
hash = execSync("git rev-parse --short=7 HEAD", {
|
return cached;
|
||||||
encoding: "utf-8",
|
|
||||||
}).trim();
|
|
||||||
} catch (e) {
|
|
||||||
hash = Date.now().toString(36).slice(-7);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${semver}-${hash}`;
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { getVersion };
|
function getVersion() {
|
||||||
|
return load().version;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSemver() {
|
||||||
|
return load().semver;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBuild() {
|
||||||
|
return load().build;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { getVersion, getSemver, getBuild };
|
||||||
|
|||||||
21
build.js
21
build.js
@@ -12,6 +12,27 @@ const headlessSyncDir = path.join(
|
|||||||
"obsidian",
|
"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([
|
Promise.all([
|
||||||
// Build shim-loader.js (delegated to packages/shim)
|
// Build shim-loader.js (delegated to packages/shim)
|
||||||
require("./packages/shim/build.js"),
|
require("./packages/shim/build.js"),
|
||||||
|
|||||||
@@ -4,13 +4,8 @@ const GITHUB_URL = "https://github.com/Nystik-gh/ignis";
|
|||||||
const GITHUB_API_LATEST =
|
const GITHUB_API_LATEST =
|
||||||
"https://api.github.com/repos/Nystik-gh/ignis/releases/latest";
|
"https://api.github.com/repos/Nystik-gh/ignis/releases/latest";
|
||||||
|
|
||||||
function getVersion(app) {
|
function getVersion() {
|
||||||
try {
|
return window.__ignis?.version || "unknown";
|
||||||
const manifest = app.plugins.getPlugin("ignis-bridge")?.manifest;
|
|
||||||
return manifest?.version || "unknown";
|
|
||||||
} catch {
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SemVer build metadata (`+xyz`) is informational and ignored for precedence.
|
// SemVer build metadata (`+xyz`) is informational and ignored for precedence.
|
||||||
@@ -41,7 +36,7 @@ async function checkForUpdate(currentVersion) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function display(containerEl, app) {
|
function display(containerEl, app) {
|
||||||
const version = getVersion(app);
|
const version = getVersion();
|
||||||
|
|
||||||
const header = containerEl.createDiv("ignis-header");
|
const header = containerEl.createDiv("ignis-header");
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
const esbuild = require("esbuild");
|
const esbuild = require("esbuild");
|
||||||
const path = require("path");
|
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({
|
module.exports = esbuild.build({
|
||||||
entryPoints: [path.join(__dirname, "src", "loader.js")],
|
entryPoints: [path.join(__dirname, "src", "loader.js")],
|
||||||
@@ -18,7 +21,8 @@ module.exports = esbuild.build({
|
|||||||
},
|
},
|
||||||
external: ["obsidian", "fs"],
|
external: ["obsidian", "fs"],
|
||||||
define: {
|
define: {
|
||||||
__IGNIS_VERSION__: JSON.stringify(ignisVersion),
|
__IGNIS_VERSION__: JSON.stringify(semver),
|
||||||
|
__IGNIS_BUILD__: JSON.stringify(build),
|
||||||
},
|
},
|
||||||
logLevel: "info",
|
logLevel: "info",
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import {
|
|||||||
import { wsClient } from "./ws-client.js";
|
import { wsClient } from "./ws-client.js";
|
||||||
import { installIgnisApi } from "./ignis-api.js";
|
import { installIgnisApi } from "./ignis-api.js";
|
||||||
|
|
||||||
// __IGNIS_VERSION__ is replaced at build time from package.json.
|
// __IGNIS_VERSION__ (semver) and __IGNIS_BUILD__ are replaced at build time.
|
||||||
window.__ignis = { version: __IGNIS_VERSION__ };
|
window.__ignis = { version: __IGNIS_VERSION__, build: __IGNIS_BUILD__ };
|
||||||
window.__ignis_registerUI = registerUI;
|
window.__ignis_registerUI = registerUI;
|
||||||
|
|
||||||
installIgnisApi(wsClient);
|
installIgnisApi(wsClient);
|
||||||
|
|||||||
Reference in New Issue
Block a user