chore(scripts/build): replace __BUILD_ENV__ with __DEV__

This commit is contained in:
PalmDevs 2025-07-10 12:39:25 +07:00
parent 705225f05a
commit 82c593e9bb
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA
5 changed files with 9 additions and 6 deletions

View file

@ -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),

View file

@ -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'

View file

@ -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: () => <TableRowAssetIcon id={RevengeIcon} />,
title: () => 'Revenge',
useDescription: () =>
`${__BUILD_VERSION__}-${__BUILD_COMMIT__}-${__BUILD_BRANCH__} (${__BUILD_ENV__})`,
`${__BUILD_VERSION__}-${__BUILD_COMMIT__}-${__BUILD_BRANCH__} (${BuildEnvironment})`,
type: 'static',
}

View file

@ -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),

2
types.d.ts vendored
View file

@ -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