From 9850b21e2b2fa7fa3d10cd961459519e241ccce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sun, 21 Jul 2024 20:41:40 -0500 Subject: [PATCH] fix: inlclude node files --- package.json | 2 +- prisma/schema.prisma | 3 +-- scripts/build.ts | 61 -------------------------------------------- 3 files changed, 2 insertions(+), 64 deletions(-) delete mode 100644 scripts/build.ts diff --git a/package.json b/package.json index 70317bc7f..313299104 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "scripts": { "build:assets": "bun scripts/buildAssets/index.ts", "build:averages": "bun scripts/averages", - "build:bot": "rm -rf dist/bot && bun build src/index.ts src/workers/bot.ts src/workers/render.ts --outdir dist/bot --target=bun --splitting --sourcemap=inline && cp -R src/lang dist/bot/lang && prisma generate && cp prisma/schema.prisma dist/bot/schema.prisma", + "build:bot": "rm -rf dist/bot && mkdir -p dist/bot/node_modules/prisma && bun build src/index.ts src/workers/bot.ts src/workers/render.ts --outdir dist/bot --target=bun --splitting --sourcemap=inline && cp -R src/lang dist/bot/lang && prisma generate && cp prisma/schema.prisma dist/bot/schema.prisma && cp -R node_modules/prisma/*.node dist/bot/node_modules/prisma", "build:website": "bun build:sitemap && next build", "build:sitemap": "bun scripts/sitemap.ts", "build:docs": "vitepress build docs", diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 3b20b2367..e648508ac 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,6 +1,5 @@ generator client { - provider = "prisma-client-js" - binaryTargets = ["native", "debian-openssl-1.1.x"] + provider = "prisma-client-js" } datasource db { diff --git a/scripts/build.ts b/scripts/build.ts deleted file mode 100644 index 3cbfbea53..000000000 --- a/scripts/build.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { exec } from 'child_process'; -import { build } from 'esbuild'; -import { cp, readdir } from 'fs/promises'; -import { argv } from 'process'; -import { promisify } from 'util'; - -const execPromise = promisify(exec); -const isProduction = argv.includes('--production'); - -await readdir('src/workers').then((workers) => { - const files = [ - 'bot', - 'index', - - ...workers.map((file) => `workers/${file.replace('.ts', '')}`), - ]; - - build({ - entryPoints: files.map((file) => `src/${file}.ts`), - outdir: 'dist/bot', - - platform: 'node', - tsconfig: 'tsconfig.esbuild.json', - loader: { - '.node': 'copy', - '.ttf': 'file', - }, - format: 'cjs', - jsx: 'transform', - outExtension: { - '.js': '.cjs', - }, - - external: ['sharp'], - bundle: true, - sourcemap: true, - minifyIdentifiers: false, // causes goofy errors - minifySyntax: true, - minifyWhitespace: true, - - logLevel: 'info', - }); -}); - -// copy schema.prisma -await cp('prisma/schema.prisma', 'dist/bot/schema.prisma'); -await readdir('node_modules/prisma').then((files) => - files - .filter((file) => file.endsWith('.node')) - .map((file) => cp(`node_modules/prisma/${file}`, `dist/bot/${file}`)), -); - -if (isProduction) { - // install fixed sharp - console.log('Installing fixed sharp...'); - await execPromise('yarn init -y && yarn add sharp@0.33.1 --ignore-engines', { - cwd: 'dist/bot', - }); -} - -console.log('Generated:', await readdir('dist/bot'));