Commit 94a1119
feat(cli): implement config management CLI commands (Phase 4)
Add comprehensive config management commands with 7 subcommands for
viewing, editing, validating, backing up, and migrating configurations.
New Commands:
- envg config get <key>: Get config value with dot notation support
* Examples: envg config get package.name, envg config get environments.default
* Returns formatted JSON for objects, plain values for primitives
- envg config set <key> <value>: Set config value with dot notation
* Auto-migrates v1→v2 before setting values
* Updates metadata timestamps automatically
* Type-safe value conversion (boolean, number, array, string)
- envg config list: Display complete configuration as JSON
* Works with both v1 and v2 configs
* Pretty-printed output
- envg config validate: Validate current configuration
* Checks all required fields
* Validates environment consistency (default must be in allowed list)
* Provides detailed error messages for v2 configs
- envg config backup: Create timestamped backup
* Default path: .envguard/config.backup.{timestamp}.json
* Custom path via --output flag
- envg config restore <file>: Restore from backup
* Auto-creates backup of current config before restoring
* Validates backup file format
* Supports both v1 and v2 backups
- envg config migrate: Migrate v1→v2 manually
* Auto-detects current version
* Creates backup before migration
* Skips if already v2
Implementation Details:
- packages/cli/src/commands/config.action.ts: Core implementation (430 lines)
* configGetAction: Nested object access with dot notation
* configSetAction: Type-aware value setting with auto-migration
* configListAction: Pretty JSON display
* configValidateAction: Comprehensive validation with detailed errors
* configBackupAction: Timestamped backup creation
* configRestoreAction: Safe restore with auto-backup
* configMigrateAction: v1→v2 migration workflow
* Helper functions: getNestedValue(), setNestedValue()
- packages/cli/src/cli.ts: Command registration
* Registered config command with 7 subcommands
* Commander.js subcommand pattern
* Consistent --verbose flag support
- packages/cli/src/commands/index.ts: Export config actions
Features:
- Dot notation for nested config access (e.g., "package.name", "environments.allowed")
- Auto-migration from v1→v2 when setting values
- Metadata tracking (lastModified, modifiedBy)
- Safe restore with automatic backup creation
- Type-safe value conversion (string→boolean/number/array)
- Comprehensive validation with actionable error messages
- Timestamped backups for audit trails
CLI Help Output:
$ envg config --help
Usage: envg config [options] [command]
Manage EnvGuard configuration
Commands:
get [options] <key> Get a config value (supports dot notation)
set [options] <key> <value> Set a config value (supports dot notation)
list [options] List all config values
validate [options] Validate current config
backup [options] Backup current config
restore [options] <file> Restore config from backup
migrate [options] Migrate config from v1 to v2
All Tests Passing:
- @envguard/core: 58 tests
- @envguard/node: 88 tests
- @envguard/cli: 12 tests
- Build: Clean for all packages
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent d44c8d0 commit 94a1119
3 files changed
+541
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
6 | 13 | | |
7 | 14 | | |
8 | 15 | | |
| |||
242 | 249 | | |
243 | 250 | | |
244 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
245 | 315 | | |
246 | 316 | | |
247 | 317 | | |
| |||
0 commit comments