Skip to content

novincode/cfman

Repository files navigation

🌩️ cfman

A beautiful CLI tool to manage multiple Cloudflare accounts and deploy Workers/Pages with ease

NPM version License Package Provenance

✨ Features

  • 🔐 Secure Token Management - Store multiple Cloudflare API tokens safely
  • 🚀 One-Command Deployment - Deploy Workers or Pages to any account with a single command
  • 🎨 Beautiful CLI - Colorful, intuitive interface with helpful prompts and emojis
  • 🔄 Complete Wrangler Integration - Full overlay on top of Wrangler with account management
  • 📄 Pages Support - Deploy Next.js and other static sites to Cloudflare Pages
  • Smart Fallback - Automatically uses npx wrangler if global installation is not found
  • 🛡️ Type-Safe - Built with TypeScript for reliability
  • Fast & Lightweight - Single bundled executable

🚀 Quick Start

Installation

# Global installation (recommended)
npm install -g cfman

# Or use with npx (no installation needed)
npx cfman --help

Setup Your First Account

# Add your first Cloudflare account
cfman token add --name production --token your_cf_token_here

# Check status with beautiful output
cfman status

# Use any Wrangler command with account management
cfman wrangler --account production whoami

📚 Usage

Token Management

# Add a new account token with guided prompts
cfman token add --name staging --token cf_abc123...

# List all configured accounts (tokens never shown)
cfman token list

# Remove an account with confirmation
cfman token remove staging

# Show config file locations and security info
cfman token info

Universal Wrangler Commands

# Run ANY Wrangler command with account management
cfman wrangler --account myaccount whoami
cfman wrangler --account myaccount pages project list
cfman wrangler --account myaccount d1 list
cfman wrangler --account myaccount kv namespace list

# Examples for Pages
cfman wrangler --account myaccount pages deploy out
cfman wrangler --account myaccount pages deployment list

# Examples for Workers
cfman wrangler --account myaccount deploy
cfman wrangler --account myaccount tail my-worker
cfman wrangler --account myaccount secret put SECRET_KEY

# Works without global Wrangler installation (uses npx automatically)
cfman wrangler --account myaccount whoami

Status & Setup

# Check current configuration with beautiful interface
cfman status

# Interactive setup wizard for new users
cfman setup

🔧 Configuration

Token Storage

Tokens are securely stored in your system's config directory:

  • macOS/Linux: ~/.config/cfman/tokens.json
  • Windows: %APPDATA%/cfman/tokens.json

File permissions are set to 600 (owner read/write only) for security.

Wrangler Integration

cfman is a complete overlay on top of Wrangler supporting:

  1. Universal Commands - Run ANY Wrangler command with cfman wrangler --account name <command>
  2. Smart Fallback - Uses npx wrangler automatically if global Wrangler is not installed
  3. Fallback Support - Uses wrangler auth login when no tokens are configured
  4. Beautiful Interface - Enhanced with colors, emojis, and helpful prompts

Wrangler Installation:

  • Recommended: npm install -g wrangler (faster execution)
  • Automatic: cfman automatically uses npx wrangler as fallback
  • No Setup Required: Works out of the box with Node.js installed

🎯 Why cfman?

Before cfman:

# Switch between accounts manually
export CLOUDFLARE_API_TOKEN=cf_token_for_client_a
wrangler deploy --env production

export CLOUDFLARE_API_TOKEN=cf_token_for_client_b  
wrangler pages deploy out

With cfman (Universal Overlay):

# Clean, simple, safe - Works with ANY Wrangler command
cfman wrangler --account client-a deploy --env production
cfman wrangler --account client-b pages deploy out
cfman wrangler --account client-a d1 create my-database
cfman wrangler --account client-b kv namespace create my-kv

# Beautiful interface with helpful guidance
cfman status  # See what's configured
cfman setup   # Interactive setup wizard

🛠️ Development

Prerequisites

  • Node.js 18+
  • pnpm (recommended) or npm

Setup

# Clone the repository
git clone https://github.com/novincode/cfman.git
cd cfman

# Install dependencies
pnpm install

# Build the project
pnpm build

# Test locally
./dist/index.js --help

Build & Release

# Build for production
pnpm build

# Run in development mode with auto-reload
pnpm dev

# Publish to npm
npm publish

🔒 Security

  • 🛡️ Package Provenance: Published with cryptographic verification linking npm package to GitHub source code
  • 🔐 Secure Token Storage: API tokens stored locally with secure file permissions (600)
  • 👁️ Privacy: Tokens are never logged, printed, or transmitted
  • 🔒 OS-Level Encryption: Each account's token is isolated and encrypted at rest by the OS
  • ✅ Supply Chain Security: Verifiable build process through GitHub Actions and npm attestations
  • Compatible with existing Wrangler authentication methods

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

MIT © Shayan Moradi

🙏 Acknowledgments

  • Built on top of Wrangler - the official Cloudflare Workers CLI
  • Inspired by the need for better multi-account management in modern development workflows

⭐ Star on GitHub📦 View on NPM🐛 Report Bug💬 Discussions