@package-broker/cloudflare
v0.10.4
Published
Interactive CLI tool for deploying PACKAGE.broker to Cloudflare Workers
Downloads
56
Readme
@package-broker/cloudflare
CLI tool for deploying PACKAGE.broker to Cloudflare Workers with one command. Supports both interactive and CI/CD modes.
Installation
npm install @package-broker/cloudflare @package-broker/mainUsage
Interactive Mode (Default)
npx package-broker-cloudflare initThe CLI will:
- Prompt for tier selection (free/paid)
- Prompt for worker name
- Generate encryption key
- Create Cloudflare resources (D1, KV, R2, Queue if paid)
- Set encryption key as Cloudflare secret
- Generate
wrangler.tomlwith all IDs populated - Copy migration files
- Optionally deploy the Worker
CI/CD Mode
For non-interactive deployment in GitHub Actions or other CI environments:
npx package-broker-cloudflare deploy --ci --json \
--worker-name my-worker \
--tier free \
--domain app.example.comRequired Environment Variables (CI mode):
CLOUDFLARE_API_TOKEN- Cloudflare API token with required permissionsCLOUDFLARE_ACCOUNT_ID- Your Cloudflare account IDENCRYPTION_KEY- Base64-encoded encryption key
Optional Environment Variables:
WORKER_NAME- Worker name (overrides--worker-nameflag)CLOUDFLARE_TIER-freeorpaid(overrides--tierflag)DOMAIN- Custom domain (overrides--domainflag)SKIP_UI_BUILD- Set totrueto skip UI build stepSKIP_MIGRATIONS- Set totrueto skip migration application
Flags:
--ci- Enable CI mode (non-interactive, no prompts)--json- Output JSON result for machine parsing--worker-name <name>- Worker name--tier <free|paid>- Cloudflare tier--domain <domain>- Custom domain (e.g.,app.example.com)--skip-ui-build- Skip UI build step--skip-migrations- Skip migration application
JSON Output (when using --json):
{
"worker_url": "https://my-worker.workers.dev",
"database_id": "abc123...",
"kv_namespace_id": "def456...",
"r2_bucket_name": "my-worker-artifacts",
"queue_name": "my-worker-queue"
}Features
- Interactive setup: Guided prompts for configuration
- CI/CD mode: Non-interactive deployment with JSON output for automation
- Idempotent: Safe to re-run if resources already exist
- Automatic resource creation: D1, KV, R2, and Queue (paid tier)
- Secret management: Encryption key set as Cloudflare secret (not in wrangler.toml)
- Migration handling: Automatically copies and applies migrations
- Tier-aware: Different configuration for free vs paid tiers
- Wrangler version pinning: Enforces
wrangler@^4.54.0as dependency
Requirements
- Node.js 18+
- Cloudflare account
- Authenticated with
wrangler login(interactive mode) orCLOUDFLARE_API_TOKENenvironment variable (CI mode)
See Also
- Quickstart Guide
- GitHub Template Repository (alternative deployment method)
- GitHub Action (uses this CLI in CI mode)
