diff --git a/plugin/package-lock.json b/plugin/package-lock.json index 8803c52..1c82d50 100644 --- a/plugin/package-lock.json +++ b/plugin/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-todoist-plugin", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "obsidian-todoist-plugin", - "version": "2.0.0", + "version": "2.0.1", "license": "ISC", "dependencies": { "@internationalized/date": "^3.5.2", diff --git a/plugin/src/i18n/langs/en.ts b/plugin/src/i18n/langs/en.ts index c300c71..8740901 100644 --- a/plugin/src/i18n/langs/en.ts +++ b/plugin/src/i18n/langs/en.ts @@ -70,6 +70,10 @@ export const en: Translations = { label: "Enable debug logging", description: "Whether debug logging should be enabled", }, + buildStamp: { + label: "Build stamp", + description: "Stamp for the build of this plugin", + }, }, deprecation: { warningMessage: "This setting is deprecated and will be removed in a future release.", diff --git a/plugin/src/i18n/translation.ts b/plugin/src/i18n/translation.ts index 40f014f..d2e81ab 100644 --- a/plugin/src/i18n/translation.ts +++ b/plugin/src/i18n/translation.ts @@ -66,6 +66,10 @@ export type Translations = { label: string; description: string; }; + buildStamp: { + label: string; + description: string; + }; }; deprecation: { warningMessage: string; diff --git a/plugin/src/stamp.ts b/plugin/src/stamp.ts new file mode 100644 index 0000000..2319fd7 --- /dev/null +++ b/plugin/src/stamp.ts @@ -0,0 +1 @@ +export const BuildStamp = "SYNC_WITH_TODOIST_BUILD_STAMP"; diff --git a/plugin/src/ui/settings/index.tsx b/plugin/src/ui/settings/index.tsx index a753245..ec15fc9 100644 --- a/plugin/src/ui/settings/index.tsx +++ b/plugin/src/ui/settings/index.tsx @@ -10,6 +10,7 @@ import { AutoRefreshIntervalControl } from "./AutoRefreshIntervalControl"; import { Setting } from "./SettingItem"; import { TokenChecker } from "./TokenChecker"; import "./styles.scss"; +import { BuildStamp } from "@/stamp"; export class SettingsTab extends PluginSettingTab { private readonly plugin: TodoistPlugin; @@ -188,6 +189,12 @@ const SettingsRoot: React.FC = ({ plugin }) => { > + + {BuildStamp} + ); }; diff --git a/plugin/src/ui/settings/styles.scss b/plugin/src/ui/settings/styles.scss index d48acd4..2ff6c85 100644 --- a/plugin/src/ui/settings/styles.scss +++ b/plugin/src/ui/settings/styles.scss @@ -35,3 +35,7 @@ margin-left: 0.5em; } } + +.setting-item-build-stamp { + font-size: var(--font-smaller); +} \ No newline at end of file diff --git a/plugin/vite.config.mts b/plugin/vite.config.mts index c0176ca..12f62dd 100644 --- a/plugin/vite.config.mts +++ b/plugin/vite.config.mts @@ -1,4 +1,5 @@ -import path, { resolve } from "path"; +import { execSync } from "node:child_process"; +import path, { resolve } from "node:path"; import replace from "@rollup/plugin-replace"; import { loadEnv } from "vite"; import { viteStaticCopy } from "vite-plugin-static-copy"; @@ -19,6 +20,13 @@ function getOutDir(): string | undefined { return path.join(vaultDir, ".obsidian", "plugins", "todoist-sync-plugin"); } +function getBuildStamp(): string { + const commitSha = execSync("git rev-parse --short HEAD").toString().trim(); + const isDirty = execSync("git status --porcelain").toString().trim().length > 0; + const timestamp = new Date().toISOString().slice(2, 16).replace(/[-:]/g, ""); + return `${commitSha}${isDirty ? "-dirty" : ""}-${timestamp}`; +} + export default defineConfig({ plugins: [ tsConfigPaths(), @@ -32,6 +40,7 @@ export default defineConfig({ }), replace({ "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV), + SYNC_WITH_TODOIST_BUILD_STAMP: getBuildStamp(), }), ], build: {