add bun:build to database

This commit is contained in:
Einhornimmond 2025-05-03 07:28:09 +02:00 committed by einhornimmond
parent e5abb9e226
commit 0484ce037e
2 changed files with 37 additions and 8 deletions

26
database/bun.build.ts Normal file
View File

@ -0,0 +1,26 @@
import fs from 'node:fs'
import { latestDbVersion } from './src/config/detectLastDBVersion'
await Bun.build({
entrypoints: ['entity/index.ts'],
bundle: true,
target: 'bun',
packages: 'external',
outdir: './build',
plugins: [
{
// hardcode last db version string into index.ts, before parsing
name: 'replace-latest-db-version-import',
setup(build) {
build.onLoad({ filter: /index\.ts$/ }, async (args) => {
let source = await fs.promises.readFile(args.path, 'utf8')
source = source.replace(
/import\s*\{\s*latestDbVersion\s*\}\s*from\s*['"][^'"]+['"]/,
`const latestDbVersion = "${latestDbVersion}";`,
)
return { contents: source, loader: 'ts' }
})
},
},
],
})

View File

@ -15,26 +15,29 @@
"license": "Apache-2.0",
"private": false,
"scripts": {
"build": "bun ./esbuild.config.ts",
"build": "tsx ./esbuild.config.ts",
"build:bun": "bun ./bun.build.ts",
"typecheck": "tsc --noEmit",
"up": "cross-env TZ=UTC bun src/index.ts up",
"down": "cross-env TZ=UTC bun src/index.ts down",
"reset": "cross-env TZ=UTC bun src/index.ts reset",
"clear": "cross-env TZ=UTC bun src/index.ts clear",
"up": "cross-env TZ=UTC tsx src/index.ts up",
"down": "cross-env TZ=UTC tsx src/index.ts down",
"reset": "cross-env TZ=UTC tsx src/index.ts reset",
"clear": "cross-env TZ=UTC tsx src/index.ts clear",
"lint": "biome check --error-on-warnings .",
"lint:fix": "biome check --error-on-warnings . --write",
"up:backend_test": "cross-env TZ=UTC DB_DATABASE=gradido_test_backend bun src/index.ts up",
"up:federation_test": "cross-env TZ=UTC DB_DATABASE=gradido_test_federation bun src/index.ts up",
"up:dht_test": "cross-env TZ=UTC DB_DATABASE=gradido_test_dht bun src/index.ts up"
"up:backend_test": "cross-env TZ=UTC DB_DATABASE=gradido_test_backend tsx src/index.ts up",
"up:federation_test": "cross-env TZ=UTC DB_DATABASE=gradido_test_federation tsx src/index.ts up",
"up:dht_test": "cross-env TZ=UTC DB_DATABASE=gradido_test_dht tsx src/index.ts up"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@types/bun": "^1.2.11",
"@types/faker": "^5.5.9",
"@types/geojson": "^7946.0.13",
"@types/node": "^17.0.21",
"bun": "^1.2.11",
"esbuild": "^0.25.2",
"prettier": "^2.8.7",
"tsx": "^4.19.4",
"typescript": "^4.9.5"
},
"dependencies": {