Skip to content

fix(cloudflare): relocate wrangler.jsonc into apps/registry/#107

Merged
amondnet merged 1 commit into
mainfrom
fix/cloudflare-pages-wrangler-relocate
May 28, 2026
Merged

fix(cloudflare): relocate wrangler.jsonc into apps/registry/#107
amondnet merged 1 commit into
mainfrom
fix/cloudflare-pages-wrangler-relocate

Conversation

@amondnet

@amondnet amondnet commented May 28, 2026

Copy link
Copy Markdown
Contributor

What

  • Move wrangler.jsonc from the repo root into apps/registry/wrangler.jsonc
  • Adjust pages_build_output_dir: apps/registry/distdist (now resolved under the new Root directory)
  • Adjust $schema path: apps/registry/node_modules/wrangler/config-schema.jsonnode_modules/wrangler/config-schema.json
  • Drop --config ../../wrangler.jsonc from apps/registry's preview:cf script (same-folder auto-detection)
  • Comment block in the new file documents the required Cloudflare Pages project settings

Why

The previous ask-docs Cloudflare Pages build failed with Error: Output directory "apps/registry/dist" not found. because Pages auto-detected the root wrangler.jsonc (registry-scoped) while the build command targeted apps/docs. With each project's wrangler file living next to its own project, the cross-project leak disappears.

⚠️ Required Cloudflare Pages dashboard changes (paired with this PR)

This PR will not unblock the deploy on its own. After merge, update both Pages projects:

ask-registry

  • Root directory: /apps/registry

  • Build command (one of):

    • cd ../.. && bun install && bun run build -- --filter=@pleaseai/ask-registry
    • cd ../.. && bun install && turbo run build --filter=@pleaseai/ask-registry

    (turbo's dependsOn: ["^build"] ensures @pleaseai/ask-schema builds first — required because the registry imports its dist/ exports via workspace:*.)

  • Build output directory: dist

ask-docs

  • Root directory: /apps/docs (uses the existing apps/docs/wrangler.jsonc)

  • Build command: cd ../.. && bun install && bun run --cwd apps/docs build

    (Still routes through the repo-root bun install so the hoisted node_modules, root postinstall h3 cleanup, and docs-please patch all apply.)

Verification plan

  1. Open this PR; both Pages projects build a Preview deployment for the branch.
  2. Confirm both preview URLs render correctly before promoting to production.
  3. If either preview fails, do not merge — revert the dashboard settings, since this PR + dashboard changes are a single logical unit.

Why option 2 over option 1 (kept ask-docs Root = repo root)

Option 1 (only changing ask-docs Root directory) would have fixed the immediate failure with no code changes, but it left the asymmetry — registry config at repo root, docs config inside its app folder. Option 2 makes both projects symmetric (each has its own apps/<name>/wrangler.jsonc) at the cost of also moving the registry's Cloudflare Pages Root, which requires a non-trivial Build command change to preserve the schema workspace dep build order. The trade-off was discussed and option 2 was chosen for the cleaner long-term shape.


Summary by cubic

Moved the Cloudflare Pages wrangler.jsonc into apps/registry/ and updated paths to stop ask-docs from picking up registry config. This fixes the “output directory not found” error and simplifies local wrangler preview.

  • Migration
    • ask-registry: Root=apps/registry; Build=cd ../.. && bun install && bun run build -- --filter=@pleaseai/ask-registry; Output=dist
    • ask-docs: Root=apps/docs; Build=cd ../.. && bun install && bun run --cwd apps/docs build

Written for commit 034d87d. Summary will update on new commits.

The ask-docs Cloudflare Pages build was failing with:
  Error: Output directory "apps/registry/dist" not found.

Root cause: Pages auto-discovers wrangler config from the Root directory.
Because ask-docs pointed its Root at the repo root, it picked up the
registry-specific wrangler.jsonc (pages_build_output_dir: apps/registry/dist)
and looked for output the docs build never produces.

Fix: move wrangler.jsonc from the repo root into apps/registry/ so each
Pages project has its own wrangler config next to its own source. Adjust
pages_build_output_dir from apps/registry/dist to dist (now relative to
apps/registry/) and the $schema path accordingly. Drop --config ../../wrangler.jsonc
from the preview:cf script since wrangler auto-detects the config in the same folder.

Requires paired Cloudflare Pages dashboard changes (see PR body):
- ask-registry: Root directory /  -> apps/registry, build output dist
- ask-docs: Root directory / -> apps/docs
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. status:in-progress Currently being worked on type:chore Maintenance, build, dependencies labels May 28, 2026
@amondnet amondnet self-assigned this May 28, 2026
@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Architecture diagram
sequenceDiagram
    participant Git as GitHub / Git
    participant Pages as Cloudflare Pages
    participant Registry as apps/registry
    participant Docs as apps/docs
    participant Turbo as Turborepo
    participant Schema as @pleaseai/ask-schema

    Note over Git,Schema: Deploy Flow after PR

    Git->>Pages: Push / Merge to branch
    Pages->>Pages: Trigger both Pages projects

    par ask-registry deploy
        Pages->>Registry: NEW: Root directory = apps/registry
        Pages->>Registry: NEW: Build command = cd ../.. && bun install && bun run build -- --filter=@pleaseai/ask-registry
        Registry->>Turbo: CHANGED: Resolve wrangler.jsonc from apps/registry/
        Turbo->>Schema: Build dependency (^build)
        Schema-->>Turbo: dist/ outputs
        Turbo->>Registry: Build Nuxt app
        Registry->>Registry: Output to apps/registry/dist/
        Pages->>Registry: NEW: Read output from dist/ (relative to Root)
        Pages-->>Git: Preview deployment URL
    and ask-docs deploy
        Pages->>Docs: NEW: Root directory = apps/docs
        Pages->>Docs: NEW: Build command = cd ../.. && bun install && bun run --cwd apps/docs build
        Docs->>Docs: CHANGED: No longer picks up wrangler.jsonc from repo root
        Docs->>Docs: Build docs app
        Pages->>Docs: Read output from dist/ (relative to Root)
        Pages-->>Git: Preview deployment URL
    end

    Note over Pages: Both projects now have isolated wrangler.jsonc configs

    alt Any preview fails
        Pages-->>Git: Block merge
        Note over Git: Do not merge - revert dashboard settings
    else Both previews succeed
        Git->>Pages: Promote to production
    end
Loading

Auto-approved: This PR relocates the wrangler.jsonc configuration into the apps/registry directory and adjusts relative paths to fix a Cloudflare Pages build conflict, with no changes to business logic, data, or security.

Re-trigger cubic

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying ask with  Cloudflare Pages  Cloudflare Pages

Latest commit: 034d87d
Status: ✅  Deploy successful!
Preview URL: https://ca89258c.ask-6im.pages.dev
Branch Preview URL: https://fix-cloudflare-pages-wrangle.ask-6im.pages.dev

View logs

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying ask-registry with  Cloudflare Pages  Cloudflare Pages

Latest commit: 034d87d
Status: ✅  Deploy successful!
Preview URL: https://8badaee9.ask-registry.pages.dev
Branch Preview URL: https://fix-cloudflare-pages-wrangle.ask-registry.pages.dev

View logs

@amondnet amondnet merged commit 929b74f into main May 28, 2026
6 checks passed
@amondnet amondnet deleted the fix/cloudflare-pages-wrangler-relocate branch May 28, 2026 13:54
@github-actions github-actions Bot mentioned this pull request May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files. status:in-progress Currently being worked on type:chore Maintenance, build, dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant