envx-cli 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +349 -83
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +171 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/copy.d.ts.map +1 -1
- package/dist/commands/copy.js +8 -7
- package/dist/commands/copy.js.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +3 -2
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/decrypt.d.ts.map +1 -1
- package/dist/commands/decrypt.js +21 -5
- package/dist/commands/decrypt.js.map +1 -1
- package/dist/commands/encrypt.d.ts +4 -0
- package/dist/commands/encrypt.d.ts.map +1 -1
- package/dist/commands/encrypt.js +26 -5
- package/dist/commands/encrypt.js.map +1 -1
- package/dist/commands/interactive.d.ts.map +1 -1
- package/dist/commands/interactive.js +3 -2
- package/dist/commands/interactive.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +66 -16
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.d.ts +17 -0
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +7 -1
- package/dist/schemas/index.js.map +1 -1
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/file.d.ts +7 -2
- package/dist/utils/file.d.ts.map +1 -1
- package/dist/utils/file.js +51 -3
- package/dist/utils/file.js.map +1 -1
- package/dist/utils/interactive.d.ts +1 -1
- package/dist/utils/interactive.d.ts.map +1 -1
- package/dist/utils/interactive.js +7 -2
- package/dist/utils/interactive.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,19 +5,74 @@ Environment file encryption and management tool for secure development workflows
|
|
|
5
5
|
[](https://badge.fury.io/js/envx-cli)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
- [Overview](#overview)
|
|
11
|
+
- [Features](#features)
|
|
12
|
+
- [Prerequisites](#prerequisites)
|
|
13
|
+
- [Installation](#installation)
|
|
14
|
+
- [Quick Start](#quick-start)
|
|
15
|
+
- [Commands](#commands)
|
|
16
|
+
- [envx init](#envx-init)
|
|
17
|
+
- [envx create](#envx-create)
|
|
18
|
+
- [envx encrypt](#envx-encrypt)
|
|
19
|
+
- [envx decrypt](#envx-decrypt)
|
|
20
|
+
- [envx interactive](#envx-interactive)
|
|
21
|
+
- [envx list](#envx-list)
|
|
22
|
+
- [envx copy](#envx-copy)
|
|
23
|
+
- [envx status](#envx-status)
|
|
24
|
+
- [envx config](#envx-config)
|
|
25
|
+
- [Configuration](#configuration)
|
|
26
|
+
- [.envrc File](#envrc-file)
|
|
27
|
+
- [.envxrc File (Project Config)](#envxrc-file-project-config)
|
|
28
|
+
- [Secret Variable Naming](#secret-variable-naming)
|
|
29
|
+
- [Environment Filtering](#environment-filtering)
|
|
30
|
+
- [File Structure](#file-structure)
|
|
31
|
+
- [Workflow Examples](#workflow-examples)
|
|
32
|
+
- [Basic Workflow](#basic-workflow)
|
|
33
|
+
- [Deployment Workflow](#deployment-workflow)
|
|
34
|
+
- [Team Workflow](#team-workflow)
|
|
35
|
+
- [Multi-Service Management](#multi-service-management)
|
|
36
|
+
- [Batch Operations](#batch-operations)
|
|
37
|
+
- [Copy to .env Workflow](#copy-to-env-workflow)
|
|
38
|
+
- [Dry Run Workflow](#dry-run-workflow)
|
|
39
|
+
- [Security Best Practices](#security-best-practices)
|
|
40
|
+
- [Integration with Direnv](#integration-with-direnv)
|
|
41
|
+
- [Troubleshooting](#troubleshooting)
|
|
42
|
+
- [API Reference](#api-reference)
|
|
43
|
+
- [Environment Variables](#environment-variables)
|
|
44
|
+
- [Exit Codes](#exit-codes)
|
|
45
|
+
- [Testing](#testing)
|
|
46
|
+
- [Running Tests](#running-tests)
|
|
47
|
+
- [Testing Philosophy](#testing-philosophy)
|
|
48
|
+
- [Test Coverage](#test-coverage)
|
|
49
|
+
- [Test Structure](#test-structure)
|
|
50
|
+
- [Development](#development)
|
|
51
|
+
- [Building from Source](#building-from-source)
|
|
52
|
+
- [Architecture](#architecture)
|
|
53
|
+
- [Development Workflow](#development-workflow)
|
|
54
|
+
- [Contributing](#contributing)
|
|
55
|
+
- [Changelog](#changelog)
|
|
56
|
+
- [License](#license)
|
|
57
|
+
- [Support](#support)
|
|
58
|
+
|
|
8
59
|
## Overview
|
|
9
60
|
|
|
10
61
|
EnvX is a command-line tool that helps you securely manage environment files across different stages (development, staging, production) using GPG encryption. It provides a simple workflow for encrypting sensitive environment variables while maintaining ease of use for development teams.
|
|
11
62
|
|
|
12
63
|
## Features
|
|
13
64
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
65
|
+
- **GPG-based encryption** for maximum security
|
|
66
|
+
- **Stage-based management** (development, staging, production, etc.)
|
|
67
|
+
- **Interactive setup** with guided configuration
|
|
68
|
+
- **Batch operations** on multiple files and directories
|
|
69
|
+
- **Secret management** with `.envrc` integration
|
|
70
|
+
- **Project configuration** via `.envxrc` for per-project ignore patterns and environment tracking
|
|
71
|
+
- **Environment filtering** to auto-ignore non-secret files (example, sample, template)
|
|
72
|
+
- **Dry run mode** to preview operations without making changes
|
|
73
|
+
- **Config management** CLI for managing project settings without editing JSON
|
|
74
|
+
- **Beautiful CLI** with colored output and progress indicators
|
|
75
|
+
- **Best practices** enforcement and security recommendations
|
|
21
76
|
|
|
22
77
|
## Prerequisites
|
|
23
78
|
|
|
@@ -121,6 +176,21 @@ Initialize EnvX in a new project with guided setup.
|
|
|
121
176
|
envx init
|
|
122
177
|
```
|
|
123
178
|
|
|
179
|
+
The init wizard will:
|
|
180
|
+
|
|
181
|
+
1. Verify GPG is available
|
|
182
|
+
2. Discover existing environment files, auto-ignoring non-secret files (example, sample, template)
|
|
183
|
+
3. Let you select which environments to manage via checkbox prompt
|
|
184
|
+
4. Offer to add non-selected environments to the ignore list in `.envxrc`
|
|
185
|
+
5. Save your selected environments to `.envxrc`
|
|
186
|
+
6. Update `.gitignore` with recommended patterns
|
|
187
|
+
7. Optionally start interactive secret setup
|
|
188
|
+
8. Optionally encrypt your environment files immediately after setup
|
|
189
|
+
|
|
190
|
+
**Options:**
|
|
191
|
+
|
|
192
|
+
- `-c, --cwd <path>` - Working directory
|
|
193
|
+
|
|
124
194
|
### `envx create`
|
|
125
195
|
|
|
126
196
|
Create new environment files.
|
|
@@ -158,6 +228,9 @@ envx encrypt -e production
|
|
|
158
228
|
# Encrypt all environments at once
|
|
159
229
|
envx encrypt --all
|
|
160
230
|
|
|
231
|
+
# Preview what would be encrypted (no changes made)
|
|
232
|
+
envx encrypt -e production --dry-run
|
|
233
|
+
|
|
161
234
|
# Use custom secret from .envrc
|
|
162
235
|
envx encrypt -e production -s CUSTOM_SECRET
|
|
163
236
|
|
|
@@ -167,8 +240,8 @@ envx encrypt -e staging -i
|
|
|
167
240
|
# Encrypt all with specific passphrase
|
|
168
241
|
envx encrypt --all -p "your-passphrase"
|
|
169
242
|
|
|
170
|
-
#
|
|
171
|
-
envx encrypt -e
|
|
243
|
+
# Overwrite existing encrypted files
|
|
244
|
+
envx encrypt -e production --overwrite
|
|
172
245
|
```
|
|
173
246
|
|
|
174
247
|
**Options:**
|
|
@@ -178,6 +251,8 @@ envx encrypt -e development -p "your-passphrase"
|
|
|
178
251
|
- `-p, --passphrase <pass>` - Encryption passphrase
|
|
179
252
|
- `-s, --secret <secret>` - Secret variable name from .envrc
|
|
180
253
|
- `-i, --interactive` - Interactive file selection (disabled with --all)
|
|
254
|
+
- `--overwrite` - Overwrite existing encrypted files
|
|
255
|
+
- `--dry-run` - Show what would happen without making changes
|
|
181
256
|
- `-c, --cwd <path>` - Working directory
|
|
182
257
|
|
|
183
258
|
### `envx decrypt`
|
|
@@ -191,6 +266,9 @@ envx decrypt -e production
|
|
|
191
266
|
# Decrypt all environments at once
|
|
192
267
|
envx decrypt --all
|
|
193
268
|
|
|
269
|
+
# Preview what would be decrypted (no changes made)
|
|
270
|
+
envx decrypt -e production --dry-run
|
|
271
|
+
|
|
194
272
|
# Overwrite existing files without confirmation
|
|
195
273
|
envx decrypt -e development --overwrite
|
|
196
274
|
|
|
@@ -209,6 +287,7 @@ envx decrypt -e staging -i
|
|
|
209
287
|
- `-s, --secret <secret>` - Secret variable name from .envrc
|
|
210
288
|
- `-i, --interactive` - Interactive file selection (disabled with --all)
|
|
211
289
|
- `--overwrite` - Overwrite existing files without confirmation
|
|
290
|
+
- `--dry-run` - Show what would happen without making changes
|
|
212
291
|
- `-c, --cwd <path>` - Working directory
|
|
213
292
|
|
|
214
293
|
### `envx interactive`
|
|
@@ -234,7 +313,7 @@ envx interactive --generate
|
|
|
234
313
|
|
|
235
314
|
### `envx list`
|
|
236
315
|
|
|
237
|
-
List all environment files and their status.
|
|
316
|
+
List all environment files and their status. Automatically filters out non-secret environments (example, sample, template) based on your [ignore patterns](#environment-filtering).
|
|
238
317
|
|
|
239
318
|
```bash
|
|
240
319
|
# List all environment files
|
|
@@ -296,7 +375,7 @@ envx copy -e production --all --overwrite
|
|
|
296
375
|
|
|
297
376
|
### `envx status`
|
|
298
377
|
|
|
299
|
-
Show project encryption status and recommendations.
|
|
378
|
+
Show project encryption status and recommendations. Automatically filters out non-secret environments based on your [ignore patterns](#environment-filtering).
|
|
300
379
|
|
|
301
380
|
```bash
|
|
302
381
|
envx status
|
|
@@ -306,6 +385,158 @@ envx status
|
|
|
306
385
|
|
|
307
386
|
- `-c, --cwd <path>` - Working directory
|
|
308
387
|
|
|
388
|
+
### `envx config`
|
|
389
|
+
|
|
390
|
+
Manage project configuration stored in `.envxrc` without editing JSON manually.
|
|
391
|
+
|
|
392
|
+
#### `envx config show`
|
|
393
|
+
|
|
394
|
+
Display the current `.envxrc` configuration, showing both custom settings and defaults.
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
envx config show
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
#### `envx config ignore list`
|
|
401
|
+
|
|
402
|
+
List all current ignore patterns (from `.envxrc` or defaults).
|
|
403
|
+
|
|
404
|
+
```bash
|
|
405
|
+
envx config ignore list
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
#### `envx config ignore add <pattern>`
|
|
409
|
+
|
|
410
|
+
Add a pattern to the ignore list. Environments matching this pattern will be excluded from operations like `--all`, `list`, and `status`.
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
# Ignore the "test" environment
|
|
414
|
+
envx config ignore add test
|
|
415
|
+
|
|
416
|
+
# Ignore a custom environment name
|
|
417
|
+
envx config ignore add local-dev
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
#### `envx config ignore remove <pattern>`
|
|
421
|
+
|
|
422
|
+
Remove a pattern from the ignore list.
|
|
423
|
+
|
|
424
|
+
```bash
|
|
425
|
+
envx config ignore remove test
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
#### `envx config reset`
|
|
429
|
+
|
|
430
|
+
Reset the configuration to defaults, removing all custom ignore patterns.
|
|
431
|
+
|
|
432
|
+
```bash
|
|
433
|
+
envx config reset
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
## Configuration
|
|
437
|
+
|
|
438
|
+
### `.envrc` File
|
|
439
|
+
|
|
440
|
+
EnvX uses `.envrc` files to store encryption secrets. The format follows the direnv convention:
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
# Environment secrets generated by envx
|
|
444
|
+
export DEVELOPMENT_SECRET="your-development-secret"
|
|
445
|
+
export STAGING_SECRET="your-staging-secret"
|
|
446
|
+
export PRODUCTION_SECRET="your-production-secret"
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### `.envxrc` File (Project Config)
|
|
450
|
+
|
|
451
|
+
EnvX supports a `.envxrc` JSON file in your project root for per-project configuration. This file is automatically managed by `envx init` and `envx config` commands.
|
|
452
|
+
|
|
453
|
+
```json
|
|
454
|
+
{
|
|
455
|
+
"ignore": ["example", "sample", "template", "local-dev"],
|
|
456
|
+
"environments": ["development", "staging", "production"]
|
|
457
|
+
}
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
**Fields:**
|
|
461
|
+
|
|
462
|
+
| Field | Type | Description |
|
|
463
|
+
| -------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
464
|
+
| `ignore` | `string[]` | Patterns to exclude from environment discovery. Environments whose names match any pattern (case-insensitive) are filtered from `--all`, `list`, and `status` operations. Defaults to `["example", "sample", "template"]` if not set. |
|
|
465
|
+
| `environments` | `string[]` | List of managed environments. Set during `envx init` based on your selection. |
|
|
466
|
+
|
|
467
|
+
You can manage this file through the CLI:
|
|
468
|
+
|
|
469
|
+
```bash
|
|
470
|
+
# View current config
|
|
471
|
+
envx config show
|
|
472
|
+
|
|
473
|
+
# Add a custom ignore pattern
|
|
474
|
+
envx config ignore add test
|
|
475
|
+
|
|
476
|
+
# Remove a pattern
|
|
477
|
+
envx config ignore remove sample
|
|
478
|
+
|
|
479
|
+
# Reset to defaults
|
|
480
|
+
envx config reset
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
Or edit `.envxrc` directly as JSON.
|
|
484
|
+
|
|
485
|
+
### Secret Variable Naming
|
|
486
|
+
|
|
487
|
+
EnvX follows the convention: `<STAGE>_SECRET`
|
|
488
|
+
|
|
489
|
+
Examples:
|
|
490
|
+
|
|
491
|
+
- `DEVELOPMENT_SECRET`
|
|
492
|
+
- `STAGING_SECRET`
|
|
493
|
+
- `PRODUCTION_SECRET`
|
|
494
|
+
- `LOCAL_SECRET`
|
|
495
|
+
|
|
496
|
+
### Environment Filtering
|
|
497
|
+
|
|
498
|
+
EnvX automatically filters non-secret environment files from discovery operations. By default, files matching `example`, `sample`, or `template` are excluded.
|
|
499
|
+
|
|
500
|
+
This filtering applies to:
|
|
501
|
+
|
|
502
|
+
- `envx encrypt --all` / `envx decrypt --all` (batch operations)
|
|
503
|
+
- `envx list` (environment listing)
|
|
504
|
+
- `envx status` (project status)
|
|
505
|
+
- `envx init` (environment discovery)
|
|
506
|
+
|
|
507
|
+
**How it works:**
|
|
508
|
+
|
|
509
|
+
1. If `.envxrc` exists with an `ignore` field, those patterns are used
|
|
510
|
+
2. If no `.envxrc` exists or `ignore` is not set, the defaults are used: `["example", "sample", "template"]`
|
|
511
|
+
3. Pattern matching is case-insensitive (`.env.Example` matches pattern `example`)
|
|
512
|
+
|
|
513
|
+
**Customizing filters:**
|
|
514
|
+
|
|
515
|
+
```bash
|
|
516
|
+
# Add a custom pattern
|
|
517
|
+
envx config ignore add test
|
|
518
|
+
|
|
519
|
+
# Remove a default pattern (to include it in operations)
|
|
520
|
+
envx config ignore remove template
|
|
521
|
+
|
|
522
|
+
# See current patterns
|
|
523
|
+
envx config ignore list
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
**Bypass filtering:** Pass an explicit empty ignore list programmatically via `findAllEnvironments(cwd, [])` to include all environments.
|
|
527
|
+
|
|
528
|
+
### File Structure
|
|
529
|
+
|
|
530
|
+
```
|
|
531
|
+
your-project/
|
|
532
|
+
├── .env.development # Unencrypted (local only)
|
|
533
|
+
├── .env.staging.gpg # Encrypted (committed)
|
|
534
|
+
├── .env.production.gpg # Encrypted (committed)
|
|
535
|
+
├── .envrc # Secrets (local only)
|
|
536
|
+
├── .envxrc # Project config (local only)
|
|
537
|
+
└── .gitignore # Excludes .env.* but allows *.gpg
|
|
538
|
+
```
|
|
539
|
+
|
|
309
540
|
## Workflow Examples
|
|
310
541
|
|
|
311
542
|
### Basic Workflow
|
|
@@ -458,11 +689,12 @@ envx decrypt --all --overwrite
|
|
|
458
689
|
|
|
459
690
|
**Benefits of using `--all`:**
|
|
460
691
|
|
|
461
|
-
-
|
|
462
|
-
-
|
|
463
|
-
-
|
|
464
|
-
-
|
|
465
|
-
-
|
|
692
|
+
- **Efficiency**: Process multiple environments in one command
|
|
693
|
+
- **Consistency**: Same passphrase/secret handling across all environments
|
|
694
|
+
- **Automation**: Perfect for CI/CD pipelines and scripts
|
|
695
|
+
- **Safety**: Each environment is processed independently - failures in one don't stop others
|
|
696
|
+
- **Reporting**: Comprehensive summary showing results for each environment
|
|
697
|
+
- **Filtering**: Automatically skips non-secret environments (example, sample, template)
|
|
466
698
|
|
|
467
699
|
**Key Features of `--all` Flag:**
|
|
468
700
|
|
|
@@ -490,67 +722,56 @@ envx copy -e production --overwrite
|
|
|
490
722
|
|
|
491
723
|
**Use cases for `envx copy`:**
|
|
492
724
|
|
|
493
|
-
-
|
|
494
|
-
-
|
|
495
|
-
-
|
|
496
|
-
-
|
|
497
|
-
-
|
|
498
|
-
-
|
|
499
|
-
-
|
|
725
|
+
- **Deployment**: Copy environment configuration to `.env` for application use
|
|
726
|
+
- **Environment Switching**: Quickly switch between different configurations
|
|
727
|
+
- **Local Development**: Use production/staging config locally for debugging
|
|
728
|
+
- **Docker/Containers**: Set up environment in containerized deployments
|
|
729
|
+
- **CI/CD**: Activate specific environments during pipeline stages
|
|
730
|
+
- **Multi-Service**: Manage environment files across multiple services from project root
|
|
731
|
+
- **Batch Operations**: Copy same environment to all services with one command
|
|
500
732
|
|
|
501
|
-
|
|
733
|
+
### Dry Run Workflow
|
|
502
734
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
EnvX uses `.envrc` files to store encryption secrets. The format follows the direnv convention:
|
|
735
|
+
Preview encrypt/decrypt operations before executing them:
|
|
506
736
|
|
|
507
737
|
```bash
|
|
508
|
-
#
|
|
509
|
-
|
|
510
|
-
export STAGING_SECRET="your-staging-secret"
|
|
511
|
-
export PRODUCTION_SECRET="your-production-secret"
|
|
512
|
-
```
|
|
738
|
+
# See what files would be encrypted
|
|
739
|
+
envx encrypt -e production --dry-run
|
|
513
740
|
|
|
514
|
-
|
|
741
|
+
# Preview batch encryption
|
|
742
|
+
envx encrypt --all -p "your-passphrase" --dry-run
|
|
515
743
|
|
|
516
|
-
|
|
744
|
+
# Preview decryption
|
|
745
|
+
envx decrypt -e production --dry-run
|
|
746
|
+
```
|
|
517
747
|
|
|
518
|
-
|
|
748
|
+
Dry run mode shows:
|
|
519
749
|
|
|
520
|
-
-
|
|
521
|
-
-
|
|
522
|
-
-
|
|
523
|
-
- `LOCAL_SECRET`
|
|
750
|
+
- Which files would be processed
|
|
751
|
+
- The passphrase source (provided, `.envrc`, or interactive)
|
|
752
|
+
- Total file count
|
|
524
753
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
```
|
|
528
|
-
your-project/
|
|
529
|
-
├── .env.development # Unencrypted (local only)
|
|
530
|
-
├── .env.staging.gpg # Encrypted (committed)
|
|
531
|
-
├── .env.production.gpg # Encrypted (committed)
|
|
532
|
-
├── .envrc # Secrets (local only)
|
|
533
|
-
└── .gitignore # Excludes .env.* but allows *.gpg
|
|
534
|
-
```
|
|
754
|
+
No files are created, modified, or deleted during a dry run.
|
|
535
755
|
|
|
536
756
|
## Security Best Practices
|
|
537
757
|
|
|
538
|
-
###
|
|
758
|
+
### Do's
|
|
539
759
|
|
|
540
|
-
-
|
|
541
|
-
-
|
|
542
|
-
-
|
|
543
|
-
-
|
|
544
|
-
-
|
|
545
|
-
-
|
|
760
|
+
- Always encrypt production and staging environment files
|
|
761
|
+
- Commit encrypted `.gpg` files to version control
|
|
762
|
+
- Add `.envrc` and `.envxrc` to your `.gitignore`
|
|
763
|
+
- Use strong, unique secrets for each environment
|
|
764
|
+
- Regularly rotate encryption secrets
|
|
765
|
+
- Use `envx status` to check your security posture
|
|
766
|
+
- Use `--dry-run` to preview operations before executing
|
|
546
767
|
|
|
547
|
-
###
|
|
768
|
+
### Don'ts
|
|
548
769
|
|
|
549
|
-
-
|
|
550
|
-
-
|
|
551
|
-
-
|
|
552
|
-
-
|
|
553
|
-
-
|
|
770
|
+
- Never commit unencrypted `.env.*` files (except templates)
|
|
771
|
+
- Don't commit `.envrc` or `.envxrc` files to version control
|
|
772
|
+
- Don't use weak or predictable passphrases
|
|
773
|
+
- Don't share secrets through insecure channels
|
|
774
|
+
- Don't leave decrypted files in production environments
|
|
554
775
|
|
|
555
776
|
### Recommended `.gitignore`
|
|
556
777
|
|
|
@@ -561,8 +782,9 @@ your-project/
|
|
|
561
782
|
!.env.template
|
|
562
783
|
!*.gpg
|
|
563
784
|
|
|
564
|
-
# EnvX secrets
|
|
785
|
+
# EnvX secrets and config
|
|
565
786
|
.envrc
|
|
787
|
+
.envxrc
|
|
566
788
|
```
|
|
567
789
|
|
|
568
790
|
## Integration with Direnv
|
|
@@ -655,15 +877,18 @@ EnvX respects the following environment variables:
|
|
|
655
877
|
|
|
656
878
|
### Exit Codes
|
|
657
879
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
880
|
+
| Code | Constant | Description |
|
|
881
|
+
| ---- | ---------------- | -------------------------------- |
|
|
882
|
+
| `0` | `SUCCESS` | Operation completed successfully |
|
|
883
|
+
| `1` | `GENERAL_ERROR` | General error |
|
|
884
|
+
| `2` | `INVALID_ARGS` | Invalid arguments provided |
|
|
885
|
+
| `3` | `FILE_ERROR` | File operation failed |
|
|
886
|
+
| `4` | `GPG_ERROR` | GPG operation failed |
|
|
887
|
+
| `5` | `USER_CANCELLED` | Operation cancelled by user |
|
|
663
888
|
|
|
664
889
|
## Testing
|
|
665
890
|
|
|
666
|
-
EnvX includes a
|
|
891
|
+
EnvX includes a comprehensive test suite covering core functionality, configuration management, and real-world CLI usage scenarios.
|
|
667
892
|
|
|
668
893
|
### Running Tests
|
|
669
894
|
|
|
@@ -688,26 +913,32 @@ npm run test:watch
|
|
|
688
913
|
|
|
689
914
|
The test suite prioritizes **essential functionality** over comprehensive coverage:
|
|
690
915
|
|
|
691
|
-
-
|
|
692
|
-
-
|
|
693
|
-
-
|
|
694
|
-
-
|
|
695
|
-
- ❌ **Complex mocking** - Simplified approach focusing on actual behavior
|
|
916
|
+
- **Core business logic** - Command validation, file utilities, path manipulation
|
|
917
|
+
- **Configuration management** - `.envxrc` read/write/merge, ignore patterns, defaults
|
|
918
|
+
- **Real CLI scenarios** - Actual command execution in various environments
|
|
919
|
+
- **Critical workflows** - User-facing functionality that must work reliably
|
|
696
920
|
|
|
697
921
|
### Test Coverage
|
|
698
922
|
|
|
699
|
-
**Current Status**:
|
|
923
|
+
**Current Status**: 181 tests passing across 7 test suites
|
|
700
924
|
|
|
701
|
-
- **Core Tests**:
|
|
925
|
+
- **Core Tests**: 165 tests covering essential functionality
|
|
702
926
|
- Schema validation: 25 tests (command input validation)
|
|
703
|
-
- File utilities: 39 tests (path manipulation, secret generation)
|
|
927
|
+
- File utilities: 39 tests (path manipulation, secret generation, gitignore)
|
|
704
928
|
- Command logic: 25 tests (workflow patterns and decision logic)
|
|
705
929
|
- All-flag functionality: 15 tests (batch operations, error handling)
|
|
930
|
+
- EnvxrcConfig infrastructure: 23 tests (read/write/merge, ignore patterns, filtering)
|
|
931
|
+
- Config command: 7 tests (show, add, remove, reset operations)
|
|
932
|
+
- Copy command: 31 tests (single/multi-directory, encrypted/unencrypted)
|
|
706
933
|
|
|
707
934
|
- **Integration Tests**: 16 tests covering real CLI usage
|
|
708
935
|
- Help/version commands
|
|
709
936
|
- Create command functionality
|
|
710
|
-
-
|
|
937
|
+
- Init command validation
|
|
938
|
+
- Config subcommand (show, ignore, reset)
|
|
939
|
+
- Dry run flag (encrypt/decrypt)
|
|
940
|
+
- Copy `--all` flag
|
|
941
|
+
- Environment filtering (list, status)
|
|
711
942
|
- Error handling scenarios
|
|
712
943
|
- Environment validation
|
|
713
944
|
|
|
@@ -717,9 +948,11 @@ The test suite prioritizes **essential functionality** over comprehensive covera
|
|
|
717
948
|
__tests__/
|
|
718
949
|
├── core/ # Essential functionality tests
|
|
719
950
|
│ ├── schemas.test.ts # Input validation for all commands
|
|
720
|
-
│ ├── file.test.ts # File utilities
|
|
951
|
+
│ ├── file.test.ts # File utilities, path manipulation, gitignore
|
|
721
952
|
│ ├── commands.test.ts # Command workflow logic patterns
|
|
722
|
-
│
|
|
953
|
+
│ ├── all-flag.test.ts # Batch operations and --all flag functionality
|
|
954
|
+
│ ├── envxrc.test.ts # .envxrc config read/write/merge/filtering
|
|
955
|
+
│ └── config.test.ts # Config command operations
|
|
723
956
|
└── integration/ # End-to-end CLI tests
|
|
724
957
|
└── cli.test.ts # Real CLI execution scenarios
|
|
725
958
|
```
|
|
@@ -738,6 +971,36 @@ npm run build
|
|
|
738
971
|
npm link
|
|
739
972
|
```
|
|
740
973
|
|
|
974
|
+
### Architecture
|
|
975
|
+
|
|
976
|
+
```
|
|
977
|
+
src/
|
|
978
|
+
├── index.ts # Entry point, CLI framework, inline commands
|
|
979
|
+
├── commands/ # Command implementations
|
|
980
|
+
│ ├── config.ts # envx config subcommand
|
|
981
|
+
│ ├── copy.ts # envx copy
|
|
982
|
+
│ ├── create.ts # envx create
|
|
983
|
+
│ ├── decrypt.ts # envx decrypt
|
|
984
|
+
│ ├── encrypt.ts # envx encrypt
|
|
985
|
+
│ └── interactive.ts # envx interactive
|
|
986
|
+
├── schemas/
|
|
987
|
+
│ └── index.ts # Zod validation schemas
|
|
988
|
+
├── types/
|
|
989
|
+
│ └── index.ts # TypeScript interfaces and enums
|
|
990
|
+
└── utils/
|
|
991
|
+
├── exec.ts # GPG operations, CLI output (ExecUtils, CliUtils)
|
|
992
|
+
├── file.ts # File discovery, .envrc/.envxrc, gitignore (FileUtils)
|
|
993
|
+
└── interactive.ts # User prompts via inquirer (InteractiveUtils)
|
|
994
|
+
```
|
|
995
|
+
|
|
996
|
+
**Key patterns:**
|
|
997
|
+
|
|
998
|
+
- Each command file exports `createXxxCommand()` (Commander command) and `executeXxx()` (core logic)
|
|
999
|
+
- All utility classes use static methods, no instances
|
|
1000
|
+
- Zod schemas validate all command inputs; `--all` dynamically alters schema requirements
|
|
1001
|
+
- Configuration resolution: `--passphrase` flag > `.envrc` file > interactive prompt
|
|
1002
|
+
- Working directory: `--cwd` flag > `process.cwd()`
|
|
1003
|
+
|
|
741
1004
|
### Development Workflow
|
|
742
1005
|
|
|
743
1006
|
```bash
|
|
@@ -749,6 +1012,9 @@ npm run test:watch
|
|
|
749
1012
|
|
|
750
1013
|
# Build and test
|
|
751
1014
|
npm run build && npm test
|
|
1015
|
+
|
|
1016
|
+
# Lint and format
|
|
1017
|
+
npm run lint:fix && npm run format
|
|
752
1018
|
```
|
|
753
1019
|
|
|
754
1020
|
### Contributing
|
|
@@ -778,9 +1044,9 @@ MIT © [rahulretnan](https://github.com/rahulretnan)
|
|
|
778
1044
|
|
|
779
1045
|
## Support
|
|
780
1046
|
|
|
781
|
-
-
|
|
782
|
-
-
|
|
783
|
-
-
|
|
1047
|
+
- [Issues](https://github.com/rahulretnan/envx-cli/issues)
|
|
1048
|
+
- [Discussions](https://github.com/rahulretnan/envx-cli/discussions)
|
|
1049
|
+
- Email: hi@rahulretnan.me
|
|
784
1050
|
|
|
785
1051
|
---
|
|
786
1052
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,mBAAmB,QAAO,OAmFtC,CAAC"}
|