diff --git a/esbuild.config.mjs b/esbuild.config.mjs index b1e0f44..3f22e52 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -3,7 +3,7 @@ import process from "process"; import builtins from "builtin-modules"; import sveltePlugin from "esbuild-svelte"; import sveltePreprocess from "svelte-preprocess"; - +import fs from "node:fs"; const banner = `/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin @@ -11,7 +11,8 @@ if you want to view the source, please visit the github repository of this plugi `; const prod = process.argv[2] === "production"; - +const manifestJson = JSON.parse(fs.readFileSync("./manifest.json")); +const packageJson = JSON.parse(fs.readFileSync("./package.json")); esbuild .build({ banner: { @@ -19,6 +20,10 @@ esbuild }, entryPoints: ["src/main.ts"], bundle: true, + define: { + "MANIFEST_VERSION": `"${manifestJson.version}"`, + "PACKAGE_VERSION": `"${packageJson.version}"`, + }, external: ["obsidian", "electron", ...builtins], format: "cjs", watch: !prod, diff --git a/src/main.ts b/src/main.ts index 3e67b7a..e528f33 100644 --- a/src/main.ts +++ b/src/main.ts @@ -218,6 +218,11 @@ export default class ObsidianLiveSyncPlugin extends Plugin { async onload() { setLogger(this.addLog.bind(this)); // Logger moved to global. Logger("loading plugin"); + //@ts-ignore + const manifestVersion = MANIFEST_VERSION || "-"; + //@ts-ignore + const packageVersion = PACKAGE_VERSION || "-"; + Logger(`Self-hosted LiveSync v${manifestVersion} ${packageVersion} `); const lsname = "obsidian-live-sync-ver" + this.getVaultName(); const last_version = localStorage.getItem(lsname); await this.loadSettings();