feat(local-env): deploy-cf subcommand for iframe blueprint apps#3179
Merged
feat(local-env): deploy-cf subcommand for iframe blueprint apps#3179
Conversation
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.
✅ Deploy Preview for tangle-dapp ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for tangle-leaderboard ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for tangle-cloud ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…from environment values' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
deploy-cf [<slug>...]toscripts/local-env/blueprint-ui-catalog.mjs. For every blueprint whose metadata declaresexternalApp.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
BLUEPRINTSregistry (12 entries already enumerated) and the existing per-repometadata/blueprint-metadata.jsonconvention used byprepare/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):arena/ui/app/frontend/webwith a build script)_headers(CSP/Permissions-Policy/HSTS/XFO/etc.) and_redirects(SPA fallback)wrangler pages deploy— creates the project if missing*.pages.dev(handles CF's auto-suffix surprise — e.g.agent-sandbox-5xi.pages.devwhen 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
blueprintUi.externalApp.url = "https://<slug>.blueprint.tangle.tools/"andmode: 'iframe'in the blueprint repo'smetadata/blueprint-metadata.jsonnode 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 (afterpnpm installwas needed in arena/), restores live URL ✓deploy-cf agent-sandbox: idempotent re-deploy, both subdomains return HTTP 200 with full security header stack ✓Run