EnvSync CLI π»
The command line interface for EnvSync Cloud - seamlessly sync your environment configurations from your terminal.
Built with Go and the urfave/cli framework β‘
Fast, reliable, and developer-friendly CLI for environment synchronization.
β¨ What is EnvSync?
EnvSync keeps your .env files, configuration secrets, and environment variables perfectly synchronized across development, staging, and production environments.
Key Benefits:
- π Secure - End-to-end encryption for sensitive data
- β‘ Fast - Real-time synchronization across environments
- π Web-first - Built for modern web development workflows
- π§ Developer-friendly - Simple CLI commands for terminal lovers
π οΈ Tech Stack
- Go - High-performance systems language
- urfave/cli - Feature-rich CLI framework
- Uber Zap - Structured logging
- Auth0 - Authentication and authorization
π Installation
Install from Release
curl -L https://github.com/EnvSync-Cloud/envsync-cli/releases/latest/download/envsync-linux-amd64 -o envsync
chmod +x envsync
sudo mv envsync /usr/local/bin/
Install from Source
git clone https://github.com/EnvSync-Cloud/envsync-cli.git
cd envsync-cli
make build
sudo mv bin/envsync /usr/local/bin/
Verify Installation
envsync --help
π Usage
Authentication Commands
# Login to EnvSync Cloud
envsync login
# Check current user
envsync whoami
# Logout from EnvSync Cloud
envsync logout
Project Initialization
# Generate a new configuration file
envsync init --app "my-app" --env-type "development"
envsync init -a "my-app" -e "production"
Environment Synchronization
# Push local environment variables to remote
envsync push
# Pull environment variables from remote
envsync pull
Application Management
# Create a new application
envsync app create
# List all applications
envsync app list
# Delete an application
envsync app delete --id "app-id"
envsync app delete -i "app-id"
Environment Type Management
# List all environment types for a specific app
envsync env-type list --app-id "app-id"
envsync env-type list -a "app-id"
# View details of a specific environment type
envsync env-type view --id "env-type-id"
envsync env-type view -i "env-type-id"
Configuration Management
# Set a configuration value
envsync config set
# Get a configuration value
envsync config get
Run Commands with Environment
# Execute commands with synced environment variables
envsync run --command "npm start"
envsync run -c "python app.py"
envsync run -c "go run main.go"
# Run with redacted output (for testing)
envsync run -c "npm start" --redact "secret-value"
envsync run -c "npm start" -r "secret-value"
Global Options
# Output in JSON format
envsync --json app list
envsync -j whoami
# Show help
envsync --help
envsync -h
π Command Reference
NAME:
envsync - sync environment variables between local and remote environments
USAGE:
envsync [global options] [command [command options]]
COMMANDS:
init Generate a new configuration file
run Run with project command
app Interact with your apps.
env-type Manage environment types.
config Manage configuration settings.
help, h Shows a list of commands or help for one command
AUTH:
login Login to Envsync Cloud
whoami Display current user information
logout Logout from Envsync Cloud
SYNC:
push Push environment variables to remote environment
pull Pull environment variables from remote environment
GLOBAL OPTIONS:
--json, -j Output in JSON format (default: false)
--help, -h show help
π§ Configuration
Project Configuration (envsyncrc.toml)
EnvSync CLI uses a TOML configuration file (envsyncrc.toml) in your project root to store project-specific settings:
app_id = "your-app-id"
env_type_id = "your-env-type-id"
This file is automatically generated when you run envsync init and is used by the sync service to identify your project and environment configuration.
Authentication Methods
EnvSync CLI supports multiple authentication methods with the following priority:
- API Key (Recommended for CI/CD) - Set the
API_KEY environment variable
- JWT Token - Obtained through
envsync login and stored in user config
Using API Key in CI/CD Environments
For automated environments like CI/CD pipelines, use the API_KEY environment variable:
# Set API key as environment variable
export API_KEY="your-api-key-here"
# Now run envsync commands
envsync pull
envsync run -c "npm test"
This method is preferred for CI/CD because:
- No interactive login required
- More secure for automated environments
- Easier to manage in CI/CD secret management systems
π Quick Start Workflow
1. Login to EnvSync Cloud
envsync login
2. Initialize Your Project
envsync init --app "my-project" --env-type "development"
3. Push Your Local Environment
envsync push
4. Pull Environment to Another Machine
envsync pull
5. Run Your Application
envsync run --command "npm start"
π Project Structure
envsync-cli/
βββ cmd/
β βββ cli/
β βββ main.go # CLI entry point with urfave/cli setup
βββ internal/
β βββ actions/ # Command implementations
β β βββ run.go # Run command with env injection
β βββ constants/ # Application constants
β βββ config/ # Configuration management
β βββ domain/ # Domain models
β βββ services/ # Business logic and services
β β βββ sync.go # Sync service with TOML config reading
β βββ repository/ # Data access and API client setup
β β βββ repository.go # HTTP client with API key support
β βββ mappers/ # Data transformation and mapping
β βββ logger/ # Logging utilities
βββ bin/ # Compiled binaries
βββ Makefile # Development and build automation
βββ docs/ # Documentation
π¨ Development
Prerequisites
- Go 1.21 or higher
- Make (for using Makefile commands)
Development Commands
The project uses a Makefile for development automation:
# Clone the repository
git clone https://github.com/EnvSync-Cloud/envsync-cli.git
cd envsync-cli
# Build the binary
make build
# Install the binary to /usr/local/bin
make install
# Run in development mode
make dev
# Watch for changes and rebuild automatically
make watch
# Update dependencies
make update
# Format code and tidy modules
make tidy
# Run linter
make lint
# Show all available commands
make help
Custom Backend URL
You can build the CLI with a custom backend URL:
make build BACKEND_URL=https://your-custom-api.com/api
Run Development Version
./bin/envsync --help
π EnvSync Ecosystem
π€ Contributing
We're building the future of environment management!
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
Development Guidelines
- Follow Go best practices and conventions
- Add tests for new functionality
- Update documentation for new commands
- Ensure cross-platform compatibility
- Use the Makefile for consistent development workflows
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Useful Links
Making environment configuration simple, secure, and synchronized π
Built with β€οΈ by the EnvSync team