From b6e0d14059e19952c32b92900655b0a6522826a3 Mon Sep 17 00:00:00 2001 From: Pedram Amini Date: Mon, 29 Dec 2025 08:03:50 -0600 Subject: [PATCH] =?UTF-8?q?##=20CHANGES=20-=20Version=20stamping=20now=20i?= =?UTF-8?q?ncludes=20package.json=20version=20plus=20short=20git=20hash=20?= =?UTF-8?q?=F0=9F=A7=A9=20-=20Local=20build=20label=20switched=20to=20clea?= =?UTF-8?q?rer=20=E2=80=9C(local)=E2=80=9D=20suffix=20for=20sanity=20?= =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20-=20Script=20now=20reads=20package.json?= =?UTF-8?q?=20robustly=20with=20safe=20=E2=80=9Cunknown=E2=80=9D=20fallbac?= =?UTF-8?q?k=20=F0=9F=9B=A1=EF=B8=8F=20-=20Added=20proper=20ESM=20path=20r?= =?UTF-8?q?esolution=20using=20fileURLToPath/dirname=20utilities=20?= =?UTF-8?q?=F0=9F=A7=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/set-version.mjs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/set-version.mjs b/scripts/set-version.mjs index cedefc4f..f9a6811f 100644 --- a/scripts/set-version.mjs +++ b/scripts/set-version.mjs @@ -8,8 +8,14 @@ */ import { execFileSync, spawn } from 'child_process'; +import { readFileSync } from 'fs'; +import { fileURLToPath } from 'url'; +import { dirname, join } from 'path'; import process from 'process'; +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + function getGitHash() { try { const hash = execFileSync('git', ['rev-parse', '--short=8', 'HEAD'], { @@ -22,8 +28,18 @@ function getGitHash() { } } +function getPackageVersion() { + try { + const packageJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8')); + return packageJson.version; + } catch { + return 'unknown'; + } +} + const gitHash = getGitHash(); -const version = `LOCAL ${gitHash}`; +const packageVersion = getPackageVersion(); +const version = `${packageVersion} ${gitHash} (local)`; // Set environment variable process.env.VITE_APP_VERSION = version;