From 410780c3608d7e6227d07b2212c580628907fc4d Mon Sep 17 00:00:00 2001 From: Torgny Bjers Date: Thu, 25 Jun 2026 18:12:17 -0400 Subject: [PATCH] fix: track wrangler.jsonc in git and suppress Hono auto-detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wrangler.jsonc was gitignored (leftover from when only wrangler pages deploy was used in CI, which took CLI flags instead). Now that CI runs wrangler deploy, the config must be in the repo — without it, wrangler falls back to framework auto-detection and fails on Hono 4.105. Also adds build.command to wrangler.jsonc pointing at the dashboard SvelteKit build, which suppresses wrangler 4.105 auto-detection (Hono is the Worker router, not a front-end framework). The separate "Build dashboard" CI step is removed since wrangler now invokes the build itself; dashboard npm ci still runs first so deps are in place. Co-Authored-By: Claude Sonnet 4.6 --- .dev.vars.example | 3 ++ .github/workflows/deploy-dashboard.yml | 5 +--- .gitignore | 2 -- wrangler.jsonc | 38 ++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 wrangler.jsonc diff --git a/.dev.vars.example b/.dev.vars.example index c5c71e4..91f580e 100644 --- a/.dev.vars.example +++ b/.dev.vars.example @@ -8,6 +8,9 @@ # -in private-key.pem -out private-key-pkcs8.pem # Then paste the full PEM (including headers) as the value, with literal \n for newlines. +# D1 database ID — find in Cloudflare dashboard under Workers & Pages > D1 +CLOUDFLARE_D1_DATABASE_ID= + GITHUB_APP_ID= GITHUB_APP_CLIENT_ID= GITHUB_APP_PRIVATE_KEY= diff --git a/.github/workflows/deploy-dashboard.yml b/.github/workflows/deploy-dashboard.yml index 402c7e9..2f41a43 100644 --- a/.github/workflows/deploy-dashboard.yml +++ b/.github/workflows/deploy-dashboard.yml @@ -45,13 +45,10 @@ jobs: working-directory: dashboard run: npm ci - - name: Build dashboard - working-directory: dashboard - run: npm run build - - name: Deploy Worker + assets if: github.ref == 'refs/heads/main' run: npx wrangler deploy env: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_D1_DATABASE_ID: ${{ secrets.CLOUDFLARE_D1_DATABASE_ID }} diff --git a/.gitignore b/.gitignore index f1a6907..4c24017 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,5 @@ node_modules/ /dist/ .*.vars !.*.vars.example -wrangler.jsonc -!dashboard/wrangler.jsonc *.local *.pem diff --git a/wrangler.jsonc b/wrangler.jsonc new file mode 100644 index 0000000..7430fae --- /dev/null +++ b/wrangler.jsonc @@ -0,0 +1,38 @@ +{ + "$schema": "node_modules/wrangler/config-schema.json", + "name": "coverage-tracker", + "main": "src/index.ts", + "compatibility_date": "2026-06-25", + "compatibility_flags": ["nodejs_compat"], + "assets": { + "directory": "./dashboard/build", + "binding": "ASSETS", + "not_found_handling": "single-page-application", + "run_worker_first": ["/api/*"] + }, + // Explicit build command suppresses wrangler's Hono framework auto-detection. + // Hono here is the Worker router, not a front-end framework; the SvelteKit SPA + // is built separately. Dashboard node_modules must already be installed before + // wrangler deploy runs (handled by CI's "Install dashboard dependencies" step). + "build": { + "command": "npm --prefix dashboard run build" + }, + "observability": { "enabled": true }, + "triggers": { "crons": ["30 6 * * *"] }, + "d1_databases": [ + { + "binding": "DB", + "database_name": "coverage", + "database_id": "$CLOUDFLARE_D1_DATABASE_ID", + "migrations_dir": "migrations" + } + ] + // Secrets (set with `wrangler secret put `): + // GITHUB_APP_ID + // GITHUB_APP_CLIENT_ID + // GITHUB_APP_PRIVATE_KEY — PKCS#8 PEM, see .dev.vars.example + // GITHUB_WEBHOOK_SECRET + // CF_ACCESS_AUD — Access application AUD tag + // CF_ACCESS_TEAM_DOMAIN — e.g. myteam.cloudflareaccess.com + // DEV_BYPASS_SECRET — local dev only, never set in production +}