From df765c929656acb9f74f52f126658b8690f564ee Mon Sep 17 00:00:00 2001 From: adonis Date: Wed, 5 Aug 2026 21:38:22 +0330 Subject: [PATCH] Fix local dist build by clearing incremental cache before nest build Nest deleteOutDir plus stale tsbuildinfo left an empty dist; force clean tsc emit and commit the rebuilt output. Co-authored-by: Cursor --- nest-cli.json | 4 +++- scripts/build-local-dist.sh | 31 +++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/nest-cli.json b/nest-cli.json index f9aa683..31dfe09 100644 --- a/nest-cli.json +++ b/nest-cli.json @@ -3,6 +3,8 @@ "collection": "@nestjs/schematics", "sourceRoot": "src", "compilerOptions": { - "deleteOutDir": true + "builder": "tsc", + "deleteOutDir": true, + "webpack": false } } diff --git a/scripts/build-local-dist.sh b/scripts/build-local-dist.sh index 05c98b8..10c11f4 100644 --- a/scripts/build-local-dist.sh +++ b/scripts/build-local-dist.sh @@ -6,11 +6,30 @@ MIRROR="${NPM_REGISTRY:-https://registry.npmmirror.com}" echo "==> بیلد لوکال بدون Docker" echo "==> registry: $MIRROR" +echo "==> node: $(node -v)" npm config set registry "$MIRROR" -npm ci --no-audit --no-fund -npx prisma generate -npm run build + +# Prisma postinstall باید اجازه اجرا داشته باشد +npm config set ignore-scripts false || true + +if [ ! -d node_modules ]; then + echo "==> npm ci..." + npm ci --no-audit --no-fund +fi + +# اگر اسکریپت‌های prisma بلاک شده باشند +npx --yes prisma generate + +echo "==> nest/tsc build (با پاک کردن کش)..." +rm -rf dist tsconfig.build.tsbuildinfo +npx nest build + +if [ ! -f dist/main.js ]; then + echo "==> nest build خروجی نداد؛ fallback به tsc..." + rm -rf dist tsconfig.build.tsbuildinfo + npx tsc -p tsconfig.build.json +fi if [ ! -f dist/main.js ]; then echo "ERROR: dist/main.js ساخته نشد" @@ -18,8 +37,4 @@ if [ ! -f dist/main.js ]; then exit 1 fi -echo "==> OK: dist/main.js آماده است" -echo "بعدی:" -echo " git add dist && git commit -m 'Build dist' && git push" -echo "روی سرور:" -echo " git pull && RUN_SEED=true docker compose -f docker-compose.dist.yml up -d --build" +echo "==> OK: dist/main.js ($(wc -c < dist/main.js) bytes)"