Skip to content

feat(local-env): deploy-cf subcommand for iframe blueprint apps#3179

Merged
drewstone merged 2 commits intodevelopfrom
feat/blueprint-cf-deploy
May 7, 2026
Merged

feat(local-env): deploy-cf subcommand for iframe blueprint apps#3179
drewstone merged 2 commits intodevelopfrom
feat/blueprint-cf-deploy

Conversation

@drewstone
Copy link
Copy Markdown
Contributor

Adds deploy-cf [<slug>...] to scripts/local-env/blueprint-ui-catalog.mjs. For every blueprint whose metadata declares externalApp.mode === 'iframe' on *.blueprint.tangle.{tools,sh}, builds and ships its UI to Cloudflare Pages with the iframe-safe header stack.

Why this lives here

Reuses the existing BLUEPRINTS registry (12 entries already enumerated) and the existing per-repo metadata/blueprint-metadata.json convention used by prepare / seed / serve. No new registry. No new directory. One subcommand on the file that already knows about every blueprint.

How it works

For each blueprint that opts in via externalApp.mode = 'iframe' (currently 2 of 12):

  1. Discover UI subdir by convention (arena/ui/app/frontend/web with a build script)
  2. Run the build
  3. Drop _headers (CSP/Permissions-Policy/HSTS/XFO/etc.) and _redirects (SPA fallback)
  4. wrangler pages deploy — creates the project if missing
  5. Attach custom domain
  6. Upsert CNAME pointing at the project's actual canonical *.pages.dev (handles CF's auto-suffix surprise — e.g. agent-sandbox-5xi.pages.dev when the unsuffixed slug is taken)

Idempotent. Re-running on a fully-deployed app is a clean no-op except for the new build artifacts.

Adding the next blueprint

  1. Set blueprintUi.externalApp.url = "https://<slug>.blueprint.tangle.tools/" and mode: 'iframe' in the blueprint repo's metadata/blueprint-metadata.json
  2. node scripts/local-env/blueprint-ui-catalog.mjs deploy-cf <slug>

That's it. No new config in the dapp.

Why Pages and not Workers (today)

The account API token in use is Pages+DNS scoped. Workers Custom Domain attach requires Workers Scripts:Edit + Workers Routes:Edit, which it lacks. The deploy function (deployBlueprintApp) is the single swap point when the token is upgraded — see comment block at the top of the new section. Strategically Workers is the better target; tactically Pages is what we can ship today.

Verified

  • deploy-cf trading-arena: builds + deploys (after pnpm install was needed in arena/), restores live URL ✓
  • deploy-cf agent-sandbox: idempotent re-deploy, both subdomains return HTTP 200 with full security header stack ✓

Run

CLOUDFLARE_API_TOKEN=… CLOUDFLARE_ACCOUNT_ID=… CLOUDFLARE_ZONE_ID=… \\
  node scripts/local-env/blueprint-ui-catalog.mjs deploy-cf [<slug>...]

Adds 'deploy-cf [<slug>...]' to blueprint-ui-catalog.mjs. For every
blueprint whose metadata declares externalApp.mode === 'iframe' on
*.blueprint.tangle.{tools,sh}, builds the UI and ships it to a
Cloudflare Pages project with the iframe-safe header stack —
idempotent, atomic per app, reads the canonical CF subdomain back
to upsert CNAME (handles the *-{slug}.pages.dev suffix surprise).

Targets Pages because the current account API token lacks the
Workers Scripts:Edit / Routes:Edit scopes needed to attach
Workers Custom Domains. Migration path to Workers + Static Assets
documented inline; deployBlueprintApp is the single function to
swap when the token is upgraded.

Conventions (no per-blueprint config needed):
  - UI subdir: first of arena|ui|app|frontend|web with package.json
    declaring a build|cloud:build script
  - Dist path: first of build/client|dist|build that has index.html
  - Hostname: read directly from metadata's externalApp.url

Reuses the same BLUEPRINTS registry + per-repo
metadata/blueprint-metadata.json convention as 'prepare' / 'seed'.

Run with:
  CLOUDFLARE_API_TOKEN=... CLOUDFLARE_ACCOUNT_ID=... CLOUDFLARE_ZONE_ID=... \
  node scripts/local-env/blueprint-ui-catalog.mjs deploy-cf [<slug>...]

Verified end-to-end on trading-arena and agent-sandbox: both serve
HTTP 200 with the full security header stack at the expected URL.
@drewstone drewstone requested a review from AtelyPham as a code owner May 7, 2026 08:09
@netlify
Copy link
Copy Markdown

netlify Bot commented May 7, 2026

Deploy Preview for tangle-dapp ready!

Name Link
🔨 Latest commit 99b4861
🔍 Latest deploy log https://app.netlify.com/projects/tangle-dapp/deploys/69fc4fb1dc62ed0007fb57d6
😎 Deploy Preview https://deploy-preview-3179--tangle-dapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 7, 2026

Deploy Preview for tangle-leaderboard ready!

Name Link
🔨 Latest commit 99b4861
🔍 Latest deploy log https://app.netlify.com/projects/tangle-leaderboard/deploys/69fc4fb24e28e800088468aa
😎 Deploy Preview https://deploy-preview-3179--tangle-leaderboard.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 7, 2026

Deploy Preview for tangle-cloud ready!

Name Link
🔨 Latest commit 99b4861
🔍 Latest deploy log https://app.netlify.com/projects/tangle-cloud/deploys/69fc4fb1b4bbae0008e59e8e
😎 Deploy Preview https://deploy-preview-3179--tangle-cloud.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread scripts/local-env/blueprint-ui-catalog.mjs Fixed
…from environment values'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@drewstone drewstone merged commit 7352173 into develop May 7, 2026
16 of 19 checks passed
@drewstone drewstone deleted the feat/blueprint-cf-deploy branch May 7, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants