Imprinting version numbers to boot log.

This commit is contained in:
vorotamoroz
2022-07-21 13:06:42 +09:00
parent cb406e2db6
commit bb6d787607
2 changed files with 12 additions and 2 deletions

View File

@@ -3,7 +3,7 @@ import process from "process";
import builtins from "builtin-modules"; import builtins from "builtin-modules";
import sveltePlugin from "esbuild-svelte"; import sveltePlugin from "esbuild-svelte";
import sveltePreprocess from "svelte-preprocess"; import sveltePreprocess from "svelte-preprocess";
import fs from "node:fs";
const banner = `/* const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin 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 prod = process.argv[2] === "production";
const manifestJson = JSON.parse(fs.readFileSync("./manifest.json"));
const packageJson = JSON.parse(fs.readFileSync("./package.json"));
esbuild esbuild
.build({ .build({
banner: { banner: {
@@ -19,6 +20,10 @@ esbuild
}, },
entryPoints: ["src/main.ts"], entryPoints: ["src/main.ts"],
bundle: true, bundle: true,
define: {
"MANIFEST_VERSION": `"${manifestJson.version}"`,
"PACKAGE_VERSION": `"${packageJson.version}"`,
},
external: ["obsidian", "electron", ...builtins], external: ["obsidian", "electron", ...builtins],
format: "cjs", format: "cjs",
watch: !prod, watch: !prod,

View File

@@ -218,6 +218,11 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
async onload() { async onload() {
setLogger(this.addLog.bind(this)); // Logger moved to global. setLogger(this.addLog.bind(this)); // Logger moved to global.
Logger("loading plugin"); 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 lsname = "obsidian-live-sync-ver" + this.getVaultName();
const last_version = localStorage.getItem(lsname); const last_version = localStorage.getItem(lsname);
await this.loadSettings(); await this.loadSettings();