forked from blisstown/campfire
feat: add git commit hash
This commit is contained in:
parent
daaa819e6c
commit
1d4b121ea5
2 changed files with 9 additions and 2 deletions
|
@ -28,6 +28,7 @@
|
||||||
import FollowersIcon from '@cf/icons/followers.svg';
|
import FollowersIcon from '@cf/icons/followers.svg';
|
||||||
|
|
||||||
const VERSION = APP_VERSION;
|
const VERSION = APP_VERSION;
|
||||||
|
const COMMIT = APP_COMMIT;
|
||||||
const lang = Lang();
|
const lang = Lang();
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
@ -184,7 +185,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<span class="version">
|
<span class="version">
|
||||||
campfire v{VERSION}
|
campfire v{VERSION} ({COMMIT})
|
||||||
<br>
|
<br>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="https://git.arimelody.me/blisstown/campfire">{lang.string('source')}</a></li>
|
<li><a href="https://git.arimelody.me/blisstown/campfire">{lang.string('source')}</a></li>
|
||||||
|
|
|
@ -3,11 +3,16 @@ import { defineConfig } from 'vite';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import svg from '@poppanator/sveltekit-svg'
|
import svg from '@poppanator/sveltekit-svg'
|
||||||
|
import { execSync } from 'child_process';
|
||||||
|
|
||||||
|
// get ver from package.json
|
||||||
const packageFile = fileURLToPath(new URL('package.json', import.meta.url));
|
const packageFile = fileURLToPath(new URL('package.json', import.meta.url));
|
||||||
const packageData = readFileSync(packageFile, 'utf8');
|
const packageData = readFileSync(packageFile, 'utf8');
|
||||||
const packageJSON = JSON.parse(packageData);
|
const packageJSON = JSON.parse(packageData);
|
||||||
|
|
||||||
|
// get git commit hash
|
||||||
|
const commitHash = execSync("git rev-parse HEAD")
|
||||||
|
.toString().trim().slice(0, 10)
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
|
@ -15,7 +20,8 @@ export default defineConfig({
|
||||||
svg()
|
svg()
|
||||||
],
|
],
|
||||||
define: {
|
define: {
|
||||||
APP_VERSION: JSON.stringify(packageJSON.version)
|
APP_VERSION: JSON.stringify(packageJSON.version),
|
||||||
|
APP_COMMIT: `"${commitHash}"`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue