envcf
v1.1.9
Published
π Beautiful CLI tool to push environment variables to Cloudflare Pages/Workers
Maintainers
Readme
π₯οΈ EnvCF
Beautiful CLI tool to push environment variables to Cloudflare Pages/Workers
EnvCF is a modern, user-friendly CLI tool that makes it super easy to sync your environment variables from .env files to Cloudflare Pages or Workers. No more manual copying and pasting!
β¨ Features
- π Auto-discovery - Automatically finds your
wrangler.tomlorwrangler.jsoncconfiguration - π Multiple file support - Handle
.env,.env.local,.env.production, etc. - π― Environment targeting - Deploy to production or preview environments
- π¨ Beautiful interface - Interactive prompts with colors and emojis
- π Type-safe - Built with TypeScript for reliability
- πββοΈ Dry run mode - Preview changes before applying them
- β‘ Fast & lightweight - Minimal dependencies, maximum performance
- π©οΈ Multi-account support - Seamlessly integrates with cfman for managing multiple Cloudflare accounts
π Installation
Global Installation (Recommended)
npm install -g envcf
# or
pnpm add -g envcf
# or
yarn global add envcfUse without installing
npx envcfπ Usage
Basic Usage
Navigate to your project directory and run:
envcfThe CLI will guide you through:
- π Finding your wrangler config - Automatically detects
wrangler.tomlorwrangler.jsonc - π― Choosing environment - Select between production and preview
- π Selecting env files - Pick which
.envfiles to use - β Confirmation - Review variables before pushing
- π Deployment - Push variables to Cloudflare
Advanced Options
# Dry run - see what would happen without making changes
envcf --dry-run
# Use custom env file
envcf --file .env.custom
# Use custom wrangler config
envcf --config wrangler.custom.toml
# Show help
envcf --helpMulti-Account Management
EnvCF integrates seamlessly with cfman for managing multiple Cloudflare accounts:
# First, set up your accounts with cfman
npx cfman token add --name production --token cf_your_production_token
npx cfman token add --name staging --token cf_your_staging_token
# Then use envcf with specific accounts
envcf --account production # Deploy to production account
envcf --account staging # Deploy to staging account
# You can combine with other options
envcf --account production --dry-run --file .env.prodBenefits of cfman integration:
- π Secure token management - Store multiple API tokens safely
- π One-command deployment - No manual token switching
- π‘οΈ Isolated accounts - Each account's tokens are kept separate
- π― Environment specific - Perfect for agencies or multi-client setups
ποΈ Prerequisites
Wrangler CLI installed and authenticated:
npm install -g wrangler wrangler loginOptional: cfman for multi-account management:
npm install -g cfman cfman token add --name production --token your_tokenProject structure with either:
wrangler.tomlfilewrangler.jsoncfile
Environment files like:
.env.env.local.env.production.env.preview
π Example Workflow
$ envcf
π₯οΈ EnvCF - Environment Variables to Cloudflare
π Looking for wrangler configuration...
β
Found config: wrangler.toml
π¦ Project: my-awesome-app
? Which environment do you want to deploy to?
β― π Production
π§ͺ Preview
π Looking for environment files...
? Which environment files do you want to use?
β― β π .env
β π .env.local
β π All files
π Parsing environment variables...
β
Found 12 environment variables
π Environment variables to be pushed:
β’ DATABASE_URL (from .env)
β’ API_KEY (from .env)
β’ SECRET_TOKEN (from .env.local)
...
? Push these 12 variables to production? Yes
π Pushing to Cloudflare...
π Authenticated with Cloudflare
β
DATABASE_URL
β
API_KEY
β
SECRET_TOKEN
...
π Results:
β
Success: 12
β¨ All environment variables pushed successfully!π§ Configuration
Wrangler Configuration
EnvCF works with standard Wrangler configuration files:
wrangler.toml:
name = "my-app"
compatibility_date = "2023-12-01"
[env.preview]
# Preview environment config
[env.production]
# Production environment configwrangler.jsonc:
{
"name": "my-app",
"compatibility_date": "2023-12-01",
"env": {
"preview": {},
"production": {}
}
}Environment Files
Standard .env file format:
# Database
DATABASE_URL=postgresql://localhost:5432/mydb
DATABASE_POOL_SIZE=10
# API Keys
STRIPE_SECRET_KEY=sk_test_...
SENDGRID_API_KEY=SG....
# Feature Flags
ENABLE_ANALYTICS=true
DEBUG_MODE=falseπ€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
π License
MIT Β© Shayan Moradi
π Acknowledgments
Happy deploying! π
