-
-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve injection of build info into the UI (#2828)
- Loading branch information
1 parent
96f3810
commit 331f794
Showing
7 changed files
with
39 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import util from 'node:util' | ||
import { exec } from 'node:child_process' | ||
import fs from 'node:fs' | ||
|
||
const promisifiedExec = util.promisify(exec); | ||
|
||
const env = process.env.NODE_ENV || 'development'; | ||
|
||
const timestamp = new Date().toISOString().slice(0, 16).replaceAll(/[T:-]/g, ""); | ||
let version = process.argv[2] || (env === 'production' ? timestamp : 'development'); | ||
if (version.endsWith('SNAPSHOT')) version += '-' + timestamp; | ||
|
||
promisifiedExec('git rev-parse --short HEAD').then((result) => { | ||
return Promise.resolve(result.stdout.trim()); | ||
}).then((commit) => { | ||
if (env === 'development') commit = 'development' | ||
const content = `export default { | ||
version: '${version} ', // App version | ||
commit: '${commit || ''}' // UI commit hash | ||
} | ||
` | ||
|
||
fs.writeFileSync('./src/assets/build-info.js', content, { | ||
encoding: 'utf-8', | ||
flag: 'w' | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build-info.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters