๐Ÿ“ฆ Installation Guide

Complete installation instructions for all platforms and environments

Table of Contents

System Requirements

Minimum Requirements

Installation Methods

# Install Bun if not already installed
curl -fsSL https://bun.sh/install | bash

# Clone the repository
git clone https://github.com/brendadeeznuts1111/cf-api.git
cd cf-api

# Install dependencies
bun install

# Set up environment
cp .env.example .env
# Edit .env with your Cloudflare credentials

# Verify installation
bun run cf --version

Method 2: Using npm

# Install globally from npm
npm install -g @cloudflare/cf-cli

# Verify installation
cf --version

Method 3: Using Docker ๐Ÿณ

# Pull the Docker image
docker pull ghcr.io/brendadeeznuts1111/cf-api:latest

# Run with Docker
docker run -it --rm \
  -v ~/.cf-cli:/root/.cf-cli \
  -e CLOUDFLARE_API_TOKEN=your_token \
  ghcr.io/brendadeeznuts1111/cf-api:latest

Method 4: From Source

# Clone the repository
git clone https://github.com/brendadeeznuts1111/cf-api.git
cd cf-api

# Install Bun
curl -fsSL https://bun.sh/install | bash

# Install dependencies
bun install

# Build from source
bun build src/cli.ts --compile --outfile dist/cf-cli

# Install globally
sudo mv dist/cf-cli /usr/local/bin/cf
sudo chmod +x /usr/local/bin/cf

# Verify
cf --version

Method 5: Using Homebrew (macOS)

# Add tap
brew tap brendadeeznuts1111/cf-cli

# Install
brew install cf-cli

# Verify
cf --version

Platform-Specific Instructions

macOS ๐ŸŽ

Using Homebrew

brew tap brendadeeznuts1111/cf-cli
brew install cf-cli

Manual Installation

# Download the binary
curl -L https://github.com/brendadeeznuts1111/cf-api/releases/latest/download/cf-api-darwin-arm64 -o cf
chmod +x cf
sudo mv cf /usr/local/bin/

# Add to PATH if needed
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Linux ๐Ÿง

Ubuntu/Debian

# Install Bun
curl -fsSL https://bun.sh/install | bash

# Install from source
git clone https://github.com/brendadeeznuts1111/cf-api.git
cd cf-api
bun install
sudo ln -s $(pwd)/src/cli.ts /usr/local/bin/cf

RHEL/CentOS/Fedora

# Install dependencies
sudo dnf install git nodejs

# Install Bun
curl -fsSL https://bun.sh/install | bash

# Clone and install
git clone https://github.com/brendadeeznuts1111/cf-api.git
cd cf-api
bun install

Arch Linux

# Install from AUR
yay -S cf-cli

# Or manually
git clone https://github.com/brendadeeznuts1111/cf-api.git
cd cf-api
bun install

Windows ๐ŸชŸ

Using PowerShell

# Install Bun
powershell -c "irm bun.sh/install.ps1 | iex"

# Clone repository
git clone https://github.com/brendadeeznuts1111/cf-api.git
cd cf-api

# Install dependencies
bun install

# Create batch file for global access
echo @echo off > cf.bat
echo bun run "%~dp0\src\cli.ts" %* >> cf.bat
move cf.bat C:\Windows\System32\

Using WSL2

# Install WSL2 if not already installed
wsl --install

# Inside WSL2, follow Linux instructions
curl -fsSL https://bun.sh/install | bash
git clone https://github.com/brendadeeznuts1111/cf-api.git
cd cf-api
bun install

Configuration

Step 1: Get Cloudflare API Token

  1. Log in to Cloudflare Dashboard
  2. Go to My Profile โ†’ API Tokens
  3. Click Create Token
  4. Use template: Edit zone DNS or create custom token with required permissions:
    • Zone:Read
    • Zone:Edit
    • DNS:Read
    • DNS:Edit
    • Workers Scripts:Read
    • Workers Scripts:Edit
    • Workers KV Storage:Read
    • Workers KV Storage:Edit

Step 2: Set Environment Variables

Create .env file:

# Required
CLOUDFLARE_API_TOKEN=your_api_token_here
CLOUDFLARE_ACCOUNT_ID=your_account_id_here

# Optional
CLOUDFLARE_ZONE_ID=your_zone_id_here
CF_CLI_LOG_LEVEL=info
CF_CLI_OUTPUT_FORMAT=json

Or use environment variables:

export CLOUDFLARE_API_TOKEN="your_token"
export CLOUDFLARE_ACCOUNT_ID="your_account_id"

Step 3: Verify Configuration

# Test authentication
cf auth test

# Scan resources
cf scan

# Generate report
cf report

Verification

Basic Verification

# Check version
cf --version

# Show help
cf --help

# Test authentication
cf auth test

Complete Verification

# Run diagnostic
cf doctor

# Expected output:
# โœ… Bun runtime: 1.1.4
# โœ… CLI version: 1.0.0
# โœ… Configuration: Found
# โœ… Authentication: Valid
# โœ… API connectivity: OK
# โœ… Permissions: Sufficient

Troubleshooting

Common Issues

Permission Denied

# Fix permissions
chmod +x /usr/local/bin/cf

# Or use sudo
sudo bun run cf scan

Command Not Found

# Add to PATH
echo 'export PATH="$HOME/.bun/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

API Token Invalid

# Verify token
curl -X GET "https://api.cloudflare.com/client/v4/user/tokens/verify" \
  -H "Authorization: Bearer YOUR_TOKEN"

SSL Certificate Issues

# Disable SSL verification (not recommended for production)
export NODE_TLS_REJECT_UNAUTHORIZED=0

Debug Mode

# Enable debug logging
export DEBUG=cf:*
export CF_CLI_LOG_LEVEL=debug

# Run with verbose output
cf scan --verbose

Updating

Update to Latest Version

Using Bun

cd cf-api
git pull origin master
bun install
bun update

Using npm

npm update -g @cloudflare/cf-cli

Using Docker

docker pull ghcr.io/brendadeeznuts1111/cf-api:latest

Check for Updates

# Check current version
cf --version

# Check latest version
cf update --check

# Auto-update
cf update --auto

Uninstallation

Remove CLI

Installed with Bun

# Remove global link
rm /usr/local/bin/cf

# Remove project directory
rm -rf ~/cf-api

Installed with npm

npm uninstall -g @cloudflare/cf-cli

Installed with Homebrew

brew uninstall cf-cli
brew untap brendadeeznuts1111/cf-cli

Clean Configuration

# Remove configuration files
rm -rf ~/.cf-cli
rm -rf ~/.config/cf-cli

# Remove environment variables
unset CLOUDFLARE_API_TOKEN
unset CLOUDFLARE_ACCOUNT_ID

Advanced Installation

Custom Installation Directory

# Install to custom location
PREFIX=/opt/cf-cli
mkdir -p $PREFIX
git clone https://github.com/brendadeeznuts1111/cf-api.git $PREFIX
cd $PREFIX
bun install

# Create symlink
ln -s $PREFIX/src/cli.ts /usr/local/bin/cf

Build for Different Platforms

# Build for all platforms
bun build src/cli.ts --compile --target=bun-linux-x64 --outfile dist/cf-linux-x64
bun build src/cli.ts --compile --target=bun-darwin-x64 --outfile dist/cf-darwin-x64
bun build src/cli.ts --compile --target=bun-darwin-arm64 --outfile dist/cf-darwin-arm64
bun build src/cli.ts --compile --target=bun-windows-x64 --outfile dist/cf-windows-x64.exe

Enterprise Installation

# Clone to shared location
sudo git clone https://github.com/brendadeeznuts1111/cf-api.git /opt/cf-cli
cd /opt/cf-cli

# Install dependencies
sudo bun install --production

# Create system-wide command
sudo ln -s /opt/cf-cli/src/cli.ts /usr/local/bin/cf

# Set permissions
sudo chmod 755 /usr/local/bin/cf
sudo chown -R root:root /opt/cf-cli

Next Steps

Getting Help


Last Updated: December 2024
Version: 1.0.0