mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-09 20:23:06 +08:00
feat: close #2190 improve app auto updater
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import tauriConfig from "../../src-tauri/tauri.conf.json";
|
||||
|
||||
export const getBuildConfig = () => {
|
||||
if (typeof process === "undefined") {
|
||||
throw Error(
|
||||
@@ -5,23 +7,37 @@ export const getBuildConfig = () => {
|
||||
);
|
||||
}
|
||||
|
||||
const COMMIT_ID: string = (() => {
|
||||
const buildMode = process.env.BUILD_MODE ?? "standalone";
|
||||
const isApp = !!process.env.BUILD_APP;
|
||||
const version = tauriConfig.package.version;
|
||||
|
||||
const commitInfo = (() => {
|
||||
try {
|
||||
const childProcess = require("child_process");
|
||||
return childProcess
|
||||
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 "unknown";
|
||||
return {
|
||||
commitDate: "unknown",
|
||||
commitHash: "unknown",
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
return {
|
||||
commitId: COMMIT_ID,
|
||||
buildMode: process.env.BUILD_MODE ?? "standalone",
|
||||
isApp: !!process.env.BUILD_APP,
|
||||
version,
|
||||
...commitInfo,
|
||||
buildMode,
|
||||
isApp,
|
||||
};
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user