mirror of
https://github.com/jlengrand/Maestro.git
synced 2026-03-10 08:31:19 +00:00
## CHANGES
- Version stamping now includes package.json version plus short git hash 🧩 - Local build label switched to clearer “(local)” suffix for sanity 🏷️ - Script now reads package.json robustly with safe “unknown” fallback 🛡️ - Added proper ESM path resolution using fileURLToPath/dirname utilities 🧭
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user