envsync-cli

module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2025 License: MIT

README ΒΆ

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:

  1. API Key (Recommended for CI/CD) - Set the API_KEY environment variable
  2. 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!

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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.

πŸ’¬ Support & Community


Making environment configuration simple, secure, and synchronized 🌟

Built with ❀️ by the EnvSync team

Directories ΒΆ

Path Synopsis
cmd
cli command
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL