()
| 2 | import { DEFAULT_INPUT_TEMPLATE } from "../constant"; |
| 3 | |
| 4 | export const getBuildConfig = () => { |
| 5 | if (typeof process === "undefined") { |
| 6 | throw Error( |
| 7 | "[Server Config] you are importing a nodejs-only module outside of nodejs", |
| 8 | ); |
| 9 | } |
| 10 | |
| 11 | const buildMode = process.env.BUILD_MODE ?? "standalone"; |
| 12 | const isApp = !!process.env.BUILD_APP; |
| 13 | const version = "v" + tauriConfig.package.version; |
| 14 | |
| 15 | const commitInfo = (() => { |
| 16 | try { |
| 17 | const childProcess = require("child_process"); |
| 18 | const commitDate: string = childProcess |
| 19 | .execSync('git log -1 --format="%at000" --date=unix') |
| 20 | .toString() |
| 21 | .trim(); |
| 22 | const commitHash: string = childProcess |
| 23 | .execSync('git log --pretty=format:"%H" -n 1') |
| 24 | .toString() |
| 25 | .trim(); |
| 26 | |
| 27 | return { commitDate, commitHash }; |
| 28 | } catch (e) { |
| 29 | console.error("[Build Config] No git or not from git repo."); |
| 30 | return { |
| 31 | commitDate: "unknown", |
| 32 | commitHash: "unknown", |
| 33 | }; |
| 34 | } |
| 35 | })(); |
| 36 | |
| 37 | return { |
| 38 | version, |
| 39 | ...commitInfo, |
| 40 | buildMode, |
| 41 | isApp, |
| 42 | template: process.env.DEFAULT_INPUT_TEMPLATE ?? DEFAULT_INPUT_TEMPLATE, |
| 43 | }; |
| 44 | }; |
| 45 | |
| 46 | export type BuildConfig = ReturnType<typeof getBuildConfig>; |
no test coverage detected