123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import tauriConfig from "../../src-tauri/tauri.conf.json";
- 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 = "v" + tauriConfig.package.version;
- 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",
- };
- }
- })();
- const {
- OAUTH_AUTHORIZE_ENDPOINT,
- OAUTH_CLIENT_ID,
- OAUTH_REDIRECT_URI,
- OAUTH_CLIENT_SECRET,
- OAUTH_USERINFO,
- BASE_PATH,
- } = process.env;
- let authorizeUrl = "";
- if (OAUTH_AUTHORIZE_ENDPOINT && OAUTH_CLIENT_ID && OAUTH_REDIRECT_URI) {
- authorizeUrl = `${OAUTH_AUTHORIZE_ENDPOINT}?client_id=${OAUTH_CLIENT_ID}&response_type=token&scope=userinfo&redirect_uri=${encodeURIComponent(
- OAUTH_REDIRECT_URI,
- )}`;
- }
- return {
- version,
- ...commitInfo,
- buildMode,
- isApp,
- authorizeUrl,
- baseApi: BASE_PATH,
- };
- };
- export type BuildConfig = ReturnType<typeof getBuildConfig>;
|