chore: fix more build issues

BREAKING CHANGE: In `@revanced/discord-bot`, its environment variable
                 `DATABASE_URL` has been renamed to `DATABASE_PATH`
                 and the `file:` prefix is no longer needed
This commit is contained in:
Palm
2024-07-08 17:18:39 +00:00
committed by GitHub
parent 9b6ba56d99
commit 77fefb9bef
12 changed files with 29 additions and 27 deletions

View File

@@ -25,8 +25,6 @@ The distribution files will be placed inside the `dist` directory. Inside will i
- The default configuration for the API
- Compiled source files of the API
You'll need to also copy the `node_modules` directory dereferenced if you want to run the distribution files somewhere else.
## ✈️ Deploying
To deploy the API, you'll need to:
@@ -43,7 +41,8 @@ To deploy the API, you'll need to:
3. Replace the default configuration *(optional)*
4. Configure environment variables
As seen in [`.env.example`](../.env.example). You can also optionally use a `.env` file which **Bun will automatically load**.
As seen in [`.env.example`](../.env.example). You can also optionally use a `.env` file which **Bun will automatically load**.
It is recommended to set `NODE_ENV` to `production` when deploying production builds.
5. Finally, you can run the API using these commands

View File

@@ -1,2 +1,2 @@
DISCORD_TOKEN="YOUR-TOKEN-HERE"
DATABASE_URL=file:./db.sqlite3
DATABASE_PATH=./db.sqlite3

View File

@@ -61,10 +61,10 @@ You can set environment variables in your shell or use a `.env` file which **Bun
The Discord bot token.
#### `DATABASE_URL`
#### `DATABASE_PATH`
The database URL, since we're using SQLite, we'll be using the `file` protocol.
Example values are: `file:./revanced.db`, `file:./db.sqlite`, `file:./discord_bot.sqlite`
The database path.
Example values are: `./revanced.db`, `db.sqlite3`, `../some/path/discord_bot.sqlite`
## ⏭️ What's next

View File

@@ -4,6 +4,6 @@ export default defineConfig({
dialect: 'sqlite',
schema: './src/database/schemas.ts',
dbCredentials: {
url: process.env['DATABASE_URL'],
url: `file:./${process.env['DATABASE_PATH']}`,
},
})

View File

@@ -10,7 +10,7 @@
"start": "bun run scripts/generate-indexes.ts && bun run src/index.ts",
"dev": "bun run scripts/generate-indexes.ts && bun --watch src/index.ts",
"build:config": "bun build config.ts --outdir=dist",
"build": "bun prepare && bun build:config && bun build src/index.ts -e ./config.js --target=bun --outdir=dist/src && DATABASE_URL=dist/db.sqlite3 drizzle-kit push",
"build": "bun prepare && bun build:config && bun build src/index.ts -e ./config.js --target=bun --outdir=dist/src && DATABASE_PATH=dist/db.sqlite3 drizzle-kit push",
"watch": "bun dev",
"prepare": "bun run scripts/generate-indexes.ts"
},

View File

@@ -1,16 +1,16 @@
// AUTO-GENERATED BY A SCRIPT, DON'T TOUCH
import './index'
import './fun/reply'
import './fun/coinflip'
import './development/eval'
import './development/stop'
import './development/exception-test'
import './fun/reply'
import './moderation/unban'
import './moderation/purge'
import './moderation/cure'
import './moderation/role-preset'
import './moderation/mute'
import './moderation/unmute'
import './moderation/unban'
import './moderation/slowmode'
import './moderation/mute'
import './moderation/ban'
import './moderation/role-preset'
import './moderation/slowmode'
import './development/stop'
import './development/exception-test'
import './development/eval'

View File

@@ -29,7 +29,7 @@ export const api = {
disconnectCount: 0,
}
const db = new Database(process.env['DATABASE_URL'])
const db = new Database(process.env['DATABASE_PATH'])
export const database = drizzle(db, {
schema: schemas,
@@ -61,5 +61,8 @@ export const discord = {
],
},
}),
commands: Object.fromEntries(Object.values<Command>(commands).map((cmd) => [cmd.data.name, cmd])) as Record<string, Command>,
commands: Object.fromEntries(Object.values<Command>(commands).map(cmd => [cmd.data.name, cmd])) as Record<
string,
Command
>,
} as const

View File

@@ -1,5 +1,5 @@
// AUTO-GENERATED BY A SCRIPT, DON'T TOUCH
import './ready'
import './disconnect'
import './index'
import './disconnect'

View File

@@ -4,7 +4,7 @@ import './ready'
import './cureRequired'
import './index'
import './messageCreate/messageScanRequired'
import './messageReactionAdd/correctResponse'
import './interactionCreate/chatCommand'
import './interactionCreate/correctResponse'
import './guildMemberAdd/applyRolePresets'
import './interactionCreate/correctResponse'
import './interactionCreate/chatCommand'
import './messageReactionAdd/correctResponse'

View File

@@ -4,7 +4,7 @@ import { getMissingEnvironmentVariables } from '@revanced/bot-shared'
import './events/register'
// Check if token exists
const missingEnvs = getMissingEnvironmentVariables(['DISCORD_TOKEN', 'DATABASE_URL'])
const missingEnvs = getMissingEnvironmentVariables(['DISCORD_TOKEN', 'DATABASE_PATH'])
if (missingEnvs.length) {
for (const env of missingEnvs) logger.fatal(`${env} is not defined in environment variables`)
process.exit(1)

BIN
bun.lockb Normal file → Executable file

Binary file not shown.

View File

@@ -8,8 +8,8 @@
"author": "Palm <contact@palmdevs.me> (https://palmdevs.me)",
"workspaces": ["packages/*", "apis/*", "bots/*"],
"scripts": {
"build": "turbo run build",
"build:packages": "turbo run build --filter=\"./packages/*\"",
"build:all": "turbo run build",
"build:packages": "turbo build --filter=\"./packages/*\"",
"watch": "turbo run watch",
"flint": "biome check --write .",
"flint:check": "biome check .",
@@ -27,7 +27,7 @@
"Palm <contact@palmdevs.me> (https://palmdevs.me)",
"ReVanced <nosupport@revanced.app> (https://revanced.app)"
],
"packageManager": "pnpm@9.4.0",
"packageManager": "bun@1.1.18",
"devDependencies": {
"@biomejs/biome": "^1.8.2",
"@commitlint/cli": "^19.3.0",