CLI tool for syncing encrypted .env files across teams using dotenvx
Project description
dotenvx-plaintext-sync
CLI tool for syncing encrypted .env files across teams using dotenvx.
Why dotenvx-plaintext-sync?
dotenvx is a great tool for encrypting .env files. It's designed to run apps with encrypted env files directly (dotenvx run), but sometimes you need plaintext .env files:
- Your framework reads
.envdirectly - You want to keep existing workflows
- You need to inspect values during debugging
The problem with plaintext workflows
When decrypting .env files manually, operational risks emerge:
- Path mistakes - Typing paths manually every time leads to errors
- OS differences - Path separators and behaviors vary across systems
- Multi-environment chaos - Managing dev/staging/production separately is tedious
- Accidental commits - Easy to forget gitignore and leak secrets
How dotenvx-plaintext-sync helps
| Problem | Solution |
|---|---|
| Path mistakes | Config file manages all paths centrally |
| OS differences | Consistent interface across platforms |
| Multi-environment | Just specify env name: dxps encrypt development |
| Accidental commits | Auto-configures gitignore, validates env paths are protected |
| Overwriting team values | Append-only encryption preserves existing keys |
| Losing local changes | Non-destructive decrypt outputs to latest/, not your working file |
| Over-sharing keys | Separate key files per environment |
Prerequisites
- Python 3.11+
- dotenvx:
# npm
npm install -g @dotenvx/dotenvx
# brew
brew install dotenvx/brew/dotenvx
# curl
curl -sfS https://dotenvx.sh | sh
Installation
pip install dotenvx-plaintext-sync
Quick Start
# 1. Initialize in your project
cd your-project
dxps init
# 2. Create your plaintext env file
echo "API_KEY=secret123" > envs/.env.development
# 3. Encrypt it
dxps encrypt development
# → Creates enc/.env.development.enc and envs/keys/development.keys
# 4. Share envs/keys/development.keys with your team securely
# 5. Commit the encrypted file
git add enc/.env.development.enc
git commit -m "Add encrypted development env"
Directory Structure
After dxps init:
your-project/
├── dxps.json # Configuration
├── enc/ # Encrypted files (commit these)
│ └── .env.development.enc
├── envs/ # Local files (gitignored)
│ ├── .env.development # Plaintext source
│ ├── .env.staging
│ ├── .env.production
│ ├── keys/ # Key files
│ │ └── development.keys
│ └── latest/ # Decrypted output
│ └── .env.development
└── .gitignore # Updated automatically
Usage
Encrypt
Add or update keys in your plaintext file, then encrypt:
dxps encrypt development
- First run: generates key file and
.enc - Subsequent runs: adds new keys to existing
.enc(doesn't overwrite existing values)
Update existing values
To update values that already exist in the encrypted file:
dxps encrypt development --update
This will:
- Compare your plaintext file with the encrypted file
- Show a diff of changes (new keys and updated values)
- Ask for confirmation before applying
=== Changes to be applied ===
[NEW]
+ NEW_API_KEY
[UPDATE]
~ DATABASE_URL
~ SECRET_KEY
Apply these changes? [y/N]:
Decrypt
Decrypt to latest/ directory (safe, doesn't overwrite your working file):
dxps decrypt development
# → Output: envs/latest/.env.development
Pull
Decrypt and apply directly to your working file in one step:
dxps pull development
# → Decrypts and copies to envs/.env.development
Configuration
Edit dxps.json:
{
"env_dir": "envs",
"envs": {
"development": "envs/.env.development",
"staging": "envs/.env.staging",
"production": "envs/.env.production"
},
"enc_dir": "enc",
"work_dir": "tmp/dxps"
}
Or use pyproject.toml:
[tool.dxps]
env_dir = "envs"
enc_dir = "enc"
[tool.dxps.envs]
development = "envs/.env.development"
staging = "envs/.env.staging"
production = "envs/.env.production"
Custom paths example
{
"env_dir": "config/env",
"envs": {
"dev": "config/env/.env.dev",
"prod": "config/env/.env.prod"
}
}
Note: All env paths must be under env_dir. This is enforced to ensure gitignore protection.
Design Principles
- Safe by default -
encryptonly adds new keys, use--updateto modify existing values - Non-destructive -
decryptoutputs tolatest/, usepullto apply to working file - Validated - Checks that all values are encrypted, env paths are protected
- Confirmed - Updates require explicit
y/Nconfirmation
License
MIT
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dotenvx_plaintext_sync-0.1.0.tar.gz.
File metadata
- Download URL: dotenvx_plaintext_sync-0.1.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7fab17fe1530738adce2ff7cd4fd58c00f00f53c2292008d505561e04b16eef
|
|
| MD5 |
1578da9cd8b93e73b431e5e5fea199f2
|
|
| BLAKE2b-256 |
4946e0e13853c4293888cd82222e552c4462d7ee7c16b63f4831c093294438cb
|
File details
Details for the file dotenvx_plaintext_sync-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dotenvx_plaintext_sync-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a74e563fdba120ce54151fa74bf3eaadbf51cc57b21caa939a145a504cba52c8
|
|
| MD5 |
d67069ea033579a9b2fc30e864a403f8
|
|
| BLAKE2b-256 |
a179667b10b82e47d25ba351e54c8edc78ee051330ba8cdbb24220312c251e78
|