This commit is contained in:
2025-08-11 21:17:26 +02:00
parent ba81ce67c7
commit e8d8b449ce
3 changed files with 18 additions and 18 deletions

View File

@@ -21,17 +21,11 @@ const files = [
eventFiles.map(f => `src/events/${f}`) eventFiles.map(f => `src/events/${f}`)
].flat() ].flat()
const banner = [
"const bun__build = true",
process.env.DOCKER === "1" ? "const bun__docker = true" : null
].filter(v => typeof v === "string").join("\n")
await Bun.build({ await Bun.build({
entrypoints: ["src/index.ts", ...files], entrypoints: ["src/index.ts", ...files],
outdir: "dist", outdir: "dist",
target: "bun", target: "bun",
splitting: true, splitting: true,
minify: true,
sourcemap: process.env.NODE_ENV === "dev" ? "external" : undefined, sourcemap: process.env.NODE_ENV === "dev" ? "external" : undefined,
naming: { naming: {
entry: "[dir]/[name].[ext]", entry: "[dir]/[name].[ext]",
@@ -39,5 +33,5 @@ await Bun.build({
asset: "asset/[name]-[hash].[ext]" asset: "asset/[name]-[hash].[ext]"
}, },
root: "src", root: "src",
banner banner: process.env.DOCKER === "1" ? "process.env.BUN__DOCKER = 'true'" : undefined
}) })

8
src/enviroment.d.ts vendored
View File

@@ -3,8 +3,7 @@ declare global {
interface ProcessEnv { interface ProcessEnv {
NODE_ENV?: "dev" | "prod" NODE_ENV?: "dev" | "prod"
TYPESCRIPT?: "true" TYPESCRIPT?: "true"
BUILD?: "true" BUN__DOCKER?: "true"
DOCKER?: "1"
} }
} }
} }
@@ -16,9 +15,4 @@ declare global {
} }
} }
declare global {
const bun__build: boolean | undefined
const bun__docker: boolean | undefined
}
export {} export {}

View File

@@ -1,4 +1,5 @@
import { RedisClient } from "bun" import { RedisClient } from "bun"
import { LoadEventsOptions } from "~/typings"
import { ExtendedClient as Client } from "~/utils/Client" import { ExtendedClient as Client } from "~/utils/Client"
import env from "./Env" import env from "./Env"
import loadAllEvents from "./Events/loadevents" import loadAllEvents from "./Events/loadevents"
@@ -7,12 +8,9 @@ import { log } from "./Logger"
const client = new Client() const client = new Client()
const redis = new RedisClient(env.prod.REDISURI) const redis = new RedisClient(env.prod.REDISURI)
const ft = bun__build !== true ? "ts" : "js"
const dir = bun__docker !== true ? bun__build !== true ? "src" : "dist" : ""
class Illegitimate { class Illegitimate {
async start() { async start() {
await loadAllEvents(client, { ft, dir }) await loadAllEvents(client, this.getOpts())
await client.start() await client.start()
await this.databases() await this.databases()
this.loadMethods() this.loadMethods()
@@ -28,6 +26,20 @@ class Illegitimate {
}) })
} }
private getOpts(): LoadEventsOptions {
if (process.env.BUN__DOCKER === "true") {
return {
ft: "js",
dir: ""
}
} else {
return {
ft: "ts",
dir: "src"
}
}
}
private loadMethods() { private loadMethods() {
String.prototype.removeIndents = function(this: string) { String.prototype.removeIndents = function(this: string) {
return this.replace(/^ */gm, "") return this.replace(/^ */gm, "")