299 lines
4.5 KiB
Markdown
299 lines
4.5 KiB
Markdown
# AEVS - Environment Variables Sync
|
|
|
|
A CLI tool for syncing `.env` files between machines using S3-compatible storage.
|
|
|
|
## Features
|
|
|
|
- 🔄 Sync `.env` files across multiple development machines
|
|
- ☁️ Works with S3-compatible storage (AWS S3, MinIO, Cloudflare R2, DigitalOcean Spaces)
|
|
- 🔒 Secure storage with proper permissions (files stored with 0600)
|
|
- 📦 Automatic tar.gz compression
|
|
- ⚡ Fast and efficient
|
|
- 🎯 Simple workflow
|
|
|
|
## Installation
|
|
|
|
### From Source
|
|
|
|
```bash
|
|
git clone https://github.com/user/aevs.git
|
|
cd aevs
|
|
make build
|
|
make install
|
|
```
|
|
|
|
Or using Go:
|
|
|
|
```bash
|
|
go install github.com/user/aevs/cmd/aevs@latest
|
|
```
|
|
|
|
## Quick Start
|
|
|
|
### 1. Configure Storage (one-time setup per machine)
|
|
|
|
```bash
|
|
aevs config
|
|
```
|
|
|
|
You'll be prompted for:
|
|
- Storage type (s3)
|
|
- S3 endpoint
|
|
- AWS region
|
|
- Bucket name
|
|
- Access key ID
|
|
- Secret access key
|
|
|
|
### 2. Initialize a Project
|
|
|
|
```bash
|
|
cd your-project
|
|
aevs init
|
|
```
|
|
|
|
This will:
|
|
- Scan for `.env` files in your project
|
|
- Create `aevs.yaml` configuration
|
|
- List all found env files
|
|
|
|
### 3. Push Files to Storage
|
|
|
|
```bash
|
|
aevs push
|
|
```
|
|
|
|
### 4. Pull Files on Another Machine
|
|
|
|
```bash
|
|
# First, configure storage on the new machine
|
|
aevs config
|
|
|
|
# Then pull your project
|
|
aevs pull my-project
|
|
|
|
# Or if you already have aevs.yaml:
|
|
aevs pull
|
|
```
|
|
|
|
## Commands
|
|
|
|
### `aevs config`
|
|
|
|
Configure S3-compatible storage credentials.
|
|
|
|
```bash
|
|
aevs config
|
|
```
|
|
|
|
Configuration is stored in `~/.config/aevs/config.yaml` with secure permissions (0600).
|
|
|
|
### `aevs init [project-name]`
|
|
|
|
Initialize project in current directory.
|
|
|
|
```bash
|
|
# Auto-detect project name from directory
|
|
aevs init
|
|
|
|
# Specify project name
|
|
aevs init my-project
|
|
|
|
# Overwrite existing config
|
|
aevs init --force
|
|
```
|
|
|
|
Creates `aevs.yaml` with list of found `.env` files.
|
|
|
|
### `aevs push`
|
|
|
|
Upload `.env` files to storage.
|
|
|
|
```bash
|
|
# Push current project
|
|
aevs push
|
|
|
|
# Dry run (see what would be uploaded)
|
|
aevs push --dry-run
|
|
|
|
# Use custom config path
|
|
aevs push --config path/to/aevs.yaml
|
|
```
|
|
|
|
### `aevs pull [project-name]`
|
|
|
|
Download `.env` files from storage.
|
|
|
|
```bash
|
|
# Pull using local aevs.yaml
|
|
aevs pull
|
|
|
|
# Pull specific project
|
|
aevs pull my-project
|
|
|
|
# Overwrite all files without confirmation
|
|
aevs pull --force
|
|
|
|
# Dry run
|
|
aevs pull --dry-run
|
|
```
|
|
|
|
Conflict resolution:
|
|
- `o` - overwrite this file
|
|
- `s` - skip this file
|
|
- `d` - show diff
|
|
- `O` - overwrite all files
|
|
- `S` - skip all files
|
|
|
|
### `aevs list`
|
|
|
|
List all projects in storage.
|
|
|
|
```bash
|
|
# Table output
|
|
aevs list
|
|
|
|
# JSON output
|
|
aevs list --json
|
|
```
|
|
|
|
### `aevs status`
|
|
|
|
Show sync status of current project.
|
|
|
|
```bash
|
|
aevs status
|
|
```
|
|
|
|
Shows:
|
|
- Files up to date
|
|
- Files modified locally
|
|
- Files modified remotely
|
|
- Missing files
|
|
- New files
|
|
|
|
## Configuration
|
|
|
|
### Global Config (`~/.config/aevs/config.yaml`)
|
|
|
|
```yaml
|
|
storage:
|
|
type: s3
|
|
endpoint: https://s3.amazonaws.com
|
|
region: us-east-1
|
|
bucket: my-envs-bucket
|
|
access_key: AKIA...
|
|
secret_key: ****
|
|
```
|
|
|
|
### Project Config (`aevs.yaml`)
|
|
|
|
```yaml
|
|
project: my-project
|
|
files:
|
|
- .env
|
|
- .env.production
|
|
- .env.development
|
|
- docker/.env
|
|
```
|
|
|
|
## File Scanning
|
|
|
|
### Included Patterns
|
|
|
|
- `.env` - exact match
|
|
- `.env.*` - e.g., `.env.production`, `.env.local`
|
|
- `*.env` - e.g., `docker.env`, `app.env`
|
|
|
|
### Excluded Directories
|
|
|
|
- `node_modules/`, `.git/`, `vendor/`
|
|
- `venv/`, `.venv/`, `__pycache__/`
|
|
- `.idea/`, `.vscode/`
|
|
- `dist/`, `build/`
|
|
|
|
### Excluded Files
|
|
|
|
- `.env.example`
|
|
- `.env.sample`
|
|
- `.env.template`
|
|
|
|
## Storage Providers
|
|
|
|
### AWS S3
|
|
|
|
```bash
|
|
aevs config
|
|
# Endpoint: https://s3.amazonaws.com
|
|
# Region: us-east-1 (or your preferred region)
|
|
```
|
|
|
|
### MinIO
|
|
|
|
```bash
|
|
aevs config
|
|
# Endpoint: https://minio.yourdomain.com:9000
|
|
# Region: (leave empty or use default)
|
|
```
|
|
|
|
### Cloudflare R2
|
|
|
|
```bash
|
|
aevs config
|
|
# Endpoint: https://[account-id].r2.cloudflarestorage.com
|
|
# Region: auto
|
|
```
|
|
|
|
### DigitalOcean Spaces
|
|
|
|
```bash
|
|
aevs config
|
|
# Endpoint: https://[region].digitaloceanspaces.com
|
|
# Region: [region] (e.g., nyc3)
|
|
```
|
|
|
|
## Security
|
|
|
|
- Configuration files are stored with `0600` permissions (owner read/write only)
|
|
- `.env` files are never committed to version control
|
|
- All data is transmitted over HTTPS
|
|
- Consider enabling S3 versioning for backup/recovery
|
|
|
|
## Error Handling
|
|
|
|
Exit codes:
|
|
- `0` - Success
|
|
- `1` - General error
|
|
- `2` - Configuration error
|
|
- `3` - File system error
|
|
- `4` - Storage error
|
|
- `5` - Network error
|
|
- `130` - Interrupted (Ctrl+C)
|
|
|
|
## Development
|
|
|
|
### Build
|
|
|
|
```bash
|
|
make build
|
|
```
|
|
|
|
### Run Tests
|
|
|
|
```bash
|
|
make test
|
|
```
|
|
|
|
### Clean
|
|
|
|
```bash
|
|
make clean
|
|
```
|
|
|
|
## License
|
|
|
|
MIT
|
|
|
|
## Contributing
|
|
|
|
Contributions are welcome! Please feel free to submit a Pull Request.
|