| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import { DEFAULT_INPUT_TEMPLATE } from "../constant";
- export const getBuildConfig = () => {
- if (typeof process === "undefined") {
- throw Error(
- "[Server Config] you are importing a nodejs-only module outside of nodejs",
- );
- }
- const buildMode = process.env.BUILD_MODE ?? "standalone";
- const isApp = !!process.env.BUILD_APP;
- const version = "v2.16.1"; // Fixed version for web-only build
- const commitInfo = (() => {
- try {
- const childProcess = require("child_process");
- const commitDate: string = childProcess
- .execSync('git log -1 --format="%at000" --date=unix')
- .toString()
- .trim();
- const commitHash: string = childProcess
- .execSync('git log --pretty=format:"%H" -n 1')
- .toString()
- .trim();
- return { commitDate, commitHash };
- } catch (e) {
- console.error("[Build Config] No git or not from git repo.");
- return {
- commitDate: "unknown",
- commitHash: "unknown",
- };
- }
- })();
- return {
- version,
- ...commitInfo,
- buildMode,
- isApp,
- template: process.env.DEFAULT_INPUT_TEMPLATE ?? DEFAULT_INPUT_TEMPLATE,
- };
- };
- export type BuildConfig = ReturnType<typeof getBuildConfig>;
|