diff --git a/.github/workflows/deploy-functions.yml b/.github/workflows/deploy-functions.yml index 437dd34..f4095c0 100644 --- a/.github/workflows/deploy-functions.yml +++ b/.github/workflows/deploy-functions.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - # Checkout repository code + # Checkout repository source code - name: Checkout uses: actions/checkout@v4 @@ -24,32 +24,38 @@ jobs: node-version: "22" cache: "npm" - # Install dependencies for the whole monorepo (npm workspaces) + # Install all monorepo dependencies (npm workspaces) - name: Install dependencies run: npm ci - # Build ONLY the functions workspace (tsc output to functions/dist) + # Build the internal workspace package first. + # This ensures that TypeScript can resolve @embalse-info/db + # and that declaration files (.d.ts) exist before building functions. + - name: Build db package (types) + run: npm run -w @embalse-info/db build + + # Build ONLY the functions workspace (TypeScript -> dist/) + # This runs clean + type-check + build - name: Build functions workspace run: npm run -w functions ci - # Prepare a deploy folder that contains: - # - host.json at the root - # - dist/ at the root - # - a package.json that references the internal db package via "file:" - # - the internal package code under ./packages/db + # Prepare a clean deployment folder that Azure expects. + # Azure Functions requires host.json at the root. + # We also copy compiled dist output and the internal db package. - name: Prepare deploy folder run: | rm -rf deploy mkdir -p deploy/packages - # Copy runtime files expected by Azure Functions + # Copy required runtime files cp functions/host.json deploy/host.json cp -R functions/dist deploy/dist - # Copy the internal workspace package so it can be installed with "file:" + # Copy the internal workspace package so it can be installed via "file:" cp -R packages/db deploy/packages/db - # Generate a deploy-specific package.json + # Generate a deploy-specific package.json. + # We inject a file-based dependency so Azure can install the internal package. node -e " const fs = require('fs'); const pkg = JSON.parse(fs.readFileSync('functions/package.json','utf8')); @@ -60,11 +66,12 @@ jobs: fs.writeFileSync('deploy/package.json', JSON.stringify(pkg, null, 2)); " - # Generate a deploy-specific package-lock.json by installing in deploy/ + # Install only production dependencies inside deploy/ + # This creates deploy/node_modules ready for Azure runtime cd deploy - npm install --omit=dev + npm install --omit=dev --ignore-scripts - # Deploy the deploy/ folder (it is now a complete Functions app root) + # Deploy the prepared folder to Azure Functions - name: Deploy to Azure Functions uses: Azure/functions-action@v1 with: diff --git a/packages/db/package.json b/packages/db/package.json index 5cd70a0..89fb9a9 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -14,7 +14,7 @@ "scripts": { "postinstall": "node setup.js", "build": "run-p clean type-check build:db", - "build:db": "tsc", + "build:db": "tsc -p tsconfig.json", "clean": "rimraf dist", "prestart:db": "docker compose down --remove-orphans", "start:db": "docker compose up -d", diff --git a/packages/db/tsconfig.json b/packages/db/tsconfig.json index acdda31..1e97891 100644 --- a/packages/db/tsconfig.json +++ b/packages/db/tsconfig.json @@ -9,6 +9,7 @@ "isolatedModules": true, "esModuleInterop": true, "declaration": true, + "declarationMap": false, "strict": false }, "include": ["src/**/*"],