|
44 | 44 | - [Comparison](#comparison) |
45 | 45 | - [Command Reference](#command-reference) |
46 | 46 | - [Options](#options) |
| 47 | +- [Multi-Environment Support](#multi-environment-support) |
47 | 48 | - [CI/CD Integration](#cicd-integration) |
48 | 49 | - [Contributing](#contributing) |
49 | 50 | - [License](#license) |
@@ -289,12 +290,34 @@ envrepair check |
289 | 290 |
|
290 | 291 | Runs validation without interactive prompts, outputs differences in JSON, and exits with status 1 if variables are missing. Designed for CI/CD scripting. |
291 | 292 |
|
| 293 | +### init |
| 294 | + |
| 295 | +```bash |
| 296 | +envrepair init |
| 297 | +``` |
| 298 | + |
| 299 | +Bootstraps a `.env.example` template by parsing an active `.env` file, preserving all spacing, comments, and structure while stripping the values of all variables. |
| 300 | + |
292 | 301 | ## Options |
293 | 302 |
|
294 | | -- `-e, --env <path>`: Path to the active env file (defaults to `.env`). |
| 303 | +- `-e, --env <path>`: Path to the active env file. |
295 | 304 | - `-x, --example <path>`: Path to the template example file (defaults to `.env.example`). |
| 305 | +- `-m, --mode <name>`: Specifies environment mode (e.g. `development`, `production`). Resolves cascading files matching the mode. |
296 | 306 | - `-h, --help`: Displays help information. |
297 | 307 |
|
| 308 | +## Multi-Environment Support |
| 309 | + |
| 310 | +`envrepair` automatically supports multi-environment configurations using priority-based cascading resolution, mirroring standard frameworks (such as Next.js and Vite). |
| 311 | + |
| 312 | +When you run `envrepair` without file path overrides, it scans and merges variables from existing active files in the following priority order (from lowest to highest): |
| 313 | + |
| 314 | +1. `.env` (lowest priority) |
| 315 | +2. `.env.${mode}` (if `--mode` is specified) |
| 316 | +3. `.env.local` (local overrides; skipped if `--mode test` is used) |
| 317 | +4. `.env.${mode}.local` (highest priority; if `--mode` is specified) |
| 318 | + |
| 319 | +Any missing variables identified will be appended to the highest priority existing override file on disk (defaulting to `.env` or `.env.${mode}`). |
| 320 | + |
298 | 321 | ## CI/CD Integration |
299 | 322 |
|
300 | 323 | In headless environments, `envrepair` skips prompts and exits with status 1 if variables are missing: |
|
0 commit comments