diff --git a/scripts/build.ts b/scripts/build.ts index afd7b66..2d3f28d 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -55,7 +55,7 @@ export default async function build(dev = Dev, log = true) { __BUILD_BRANCH__: JSON.stringify( (await $`git rev-parse --abbrev-ref HEAD`.text()).trim(), ), - __BUILD_ENV__: JSON.stringify(dev ? 'development' : 'production'), + __DEV__: String(dev), // See types.d.ts for what these flags do __BUILD_FLAG_DEBUG_MODULE_LOOKUPS__: String(dev), diff --git a/src/constants.ts b/src/constants.ts index ffeed69..dd6571f 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,2 +1,3 @@ export const GitHubOrganizationURL = 'https://github.com/revenge-mod' export const DiscordServerURL = 'https://discord.com/invite/ddcQf3s2Uq' +export const BuildEnvironment = __DEV__ ? 'development' : 'production' diff --git a/src/plugins/init/settings/definitions/RevengeVersionSetting.tsx b/src/plugins/init/settings/definitions/RevengeVersionSetting.tsx index 640e429..82ce0ce 100644 --- a/src/plugins/init/settings/definitions/RevengeVersionSetting.tsx +++ b/src/plugins/init/settings/definitions/RevengeVersionSetting.tsx @@ -1,4 +1,5 @@ import TableRowAssetIcon from '@revenge-mod/components/TableRowAssetIcon' +import { BuildEnvironment } from '~/constants' import RevengeIcon from '~assets/RevengeIcon' import { Setting } from '../constants' import type { SettingsItem } from '@revenge-mod/discord/modules/settings' @@ -8,7 +9,7 @@ const RevengeVersionSetting: SettingsItem = { IconComponent: () => , title: () => 'Revenge', useDescription: () => - `${__BUILD_VERSION__}-${__BUILD_COMMIT__}-${__BUILD_BRANCH__} (${__BUILD_ENV__})`, + `${__BUILD_VERSION__}-${__BUILD_COMMIT__}-${__BUILD_BRANCH__} (${BuildEnvironment})`, type: 'static', } diff --git a/src/preinit.ts b/src/preinit.ts index de4b337..a28729f 100644 --- a/src/preinit.ts +++ b/src/preinit.ts @@ -6,6 +6,7 @@ import { onModuleInitialized, } from '@revenge-mod/modules/metro/subscriptions' import { getErrorStack } from '@revenge-mod/utils/errors' +import { BuildEnvironment } from './constants' const IndexModuleId = 0 @@ -14,7 +15,7 @@ onModuleFirstRequired(IndexModuleId, function onIndexRequired() { if (__BUILD_FLAG_LOG_PROMISE_REJECTIONS__) require('./patches/log-promise-rejections') - if (__BUILD_ENV__ === 'development') + if (__DEV__) nativeLoggingHook(`\u001b[31m--- PREINIT STAGE ---\u001b[0m`, 1) // Initialize preinit libraries @@ -29,7 +30,7 @@ onModuleFirstRequired(IndexModuleId, function onIndexRequired() { onModuleInitialized(IndexModuleId, function onIndexInitialized() { try { - if (__BUILD_ENV__ === 'development') + if (__DEV__) nativeLoggingHook( `\u001b[31m--- INIT STAGE ---\u001b[0m`, 1, @@ -63,7 +64,7 @@ function onError(e: unknown) { const Device = DeviceModule.getConstants() alert( - `Failed to load Revenge (${__BUILD_VERSION__}-${__BUILD_COMMIT__}-${__BUILD_BRANCH__} (${__BUILD_ENV__}))\n` + + `Failed to load Revenge (${__BUILD_VERSION__}-${__BUILD_COMMIT__}-${__BUILD_BRANCH__} (${BuildEnvironment}))\n` + `Discord: ${Client.Version} (${Client.Build})\n` + `Device: ${Device.deviceManufacturer} ${Device.deviceModel}\n\n` + getErrorStack(e), diff --git a/types.d.ts b/types.d.ts index 198baeb..7fd8eb7 100644 --- a/types.d.ts +++ b/types.d.ts @@ -1,7 +1,7 @@ // Type definitions for things in this codebase ONLY! declare global { - const __BUILD_ENV__: 'development' | 'production' + const __DEV__: boolean const __BUILD_COMMIT__: string const __BUILD_BRANCH__: string const __BUILD_VERSION__: string