|
@ -1,6 +1,30 @@ |
|
|
import pkg from './package.json' |
|
|
import pkg from './package.json' |
|
|
import { execSync } from 'child_process' |
|
|
import { execSync } from 'child_process' |
|
|
|
|
|
|
|
|
const gitVersion = execSync("git describe --tags `git rev-list --tags --max-count=1`").toString() |
|
|
|
|
|
console.log(gitVersion) |
|
|
|
|
|
console.log(`vite.config.js loaded ${JSON.stringify(pkg.version)}`) |
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
|
define: { |
|
|
|
|
|
APP_TITLE: pkg.name, |
|
|
|
|
|
APP_VERSION: buildVersion(), |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// FUNCTIONS
|
|
|
|
|
|
//----------
|
|
|
|
|
|
|
|
|
|
|
|
function buildVersion(): string { |
|
|
|
|
|
const version = pkg.version |
|
|
|
|
|
if (!isGitCommand()) { |
|
|
|
|
|
return version |
|
|
|
|
|
} |
|
|
|
|
|
const dirty = execSync("git status -s | wc -l").toString() |
|
|
|
|
|
return `${version}…${dirty}` |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function isGitCommand() { |
|
|
|
|
|
try { |
|
|
|
|
|
execSync("command -v git") |
|
|
|
|
|
return true |
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
} |