{"_id":"@ahmed-226m/config-guard","name":"@ahmed-226m/config-guard","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@ahmed-226m/config-guard","version":"0.1.0","description":"Validate, migrate, and secure your configuration files","type":"module","main":"dist/index.js","bin":{"config-guard":"dist/index.js"},"scripts":{"dev":"tsx cmd/index.ts","build":"tsup && chmod +x dist/index.js","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage","lint":"eslint . --ext .ts","type-check":"tsc --noEmit","validate":"npm run type-check && npm run lint && npm run test","prepublishOnly":"npm run validate && npm run build"},"keywords":["config","validation","migration","security","yaml","json","toml","env"],"author":{"name":"Ahmed Mahmoud","email":"ahmedmhmouad41@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/ahmed-226/config-guard.git"},"homepage":"https://github.com/ahmed-226/config-guard#readme","publishConfig":{"access":"public"},"dependencies":{"chalk":"^5.3.0","commander":"^11.1.0","dotenv":"^17.4.2"},"devDependencies":{"@types/js-yaml":"^4.0.9","@types/node":"^20.19.39","@typescript-eslint/eslint-plugin":"^6.17.0","@typescript-eslint/parser":"^6.17.0","@vitest/coverage-v8":"^1.1.0","eslint":"^8.56.0","tsup":"^8.0.1","tsx":"^4.7.0","typescript":"^5.3.3","vitest":"^1.1.0"},"optionalDependencies":{"@iarna/toml":"^2.2.5","js-yaml":"^4.1.1"},"_id":"@ahmed-226m/config-guard@0.1.0","gitHead":"266c36e4caac02461fb4d5806673d12eb116fd17","bugs":{"url":"https://github.com/ahmed-226/config-guard/issues"},"_nodeVersion":"20.20.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-tAO6IGUaSFFAGoRp+nqxI+zQwvf5DLWX+zs2OGPEMdrXEBaKn3oAcsbkQR5fOesFc5C0KFVjQwuOO6zoYnb95g==","shasum":"9516eb5a018195d16f784c5f432ce519b81a3bb4","tarball":"https://registry.npmjs.org/@ahmed-226m/config-guard/-/config-guard-0.1.0.tgz","fileCount":3,"unpackedSize":238137,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICYjkQ3l41v3wO4T3BhE1OoZangL84aEAYBLMrCj0nJwAiB7Vx0A9zE+Q9x+lPkg1GjIZvT0UtKsTjC1yAEp6358DA=="}]},"_npmUser":{"name":"ahmed-226m","email":"ahmedmhmoud428@gmail.com"},"directories":{},"maintainers":[{"name":"ahmed-226m","email":"ahmedmhmoud428@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/config-guard_0.1.0_1777401259407_0.7701277171438434"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-28T18:34:19.241Z","0.1.0":"2026-04-28T18:34:19.537Z","modified":"2026-04-28T18:34:19.757Z"},"maintainers":[{"name":"ahmed-226m","email":"ahmedmhmoud428@gmail.com"}],"description":"Validate, migrate, and secure your configuration files","homepage":"https://github.com/ahmed-226/config-guard#readme","keywords":["config","validation","migration","security","yaml","json","toml","env"],"repository":{"type":"git","url":"git+https://github.com/ahmed-226/config-guard.git"},"author":{"name":"Ahmed Mahmoud","email":"ahmedmhmouad41@gmail.com"},"bugs":{"url":"https://github.com/ahmed-226/config-guard/issues"},"license":"MIT","readme":"# config-guard\n\nA CLI tool for validating, migrating, and scanning configuration files for secrets. Built with TypeScript, featuring Clean Architecture and comprehensive test coverage.\n\n![Tests Passing](https://img.shields.io/badge/tests-50%2F50%20passing-brightgreen)\n![TypeScript](https://img.shields.io/badge/language-TypeScript-blue)\n![Node.js](https://img.shields.io/badge/runtime-Node.js-green)\n\n---\n\n## Quick Start\n\n### Installation\n\n```bash\nnpm install\nnpm run build\n```\n\n### Basic Usage\n\n```bash\n# Validate a configuration file\nnpx tsx cmd/index.ts validate config.json\nnpx tsx cmd/index.ts validate config.yaml --json\n\n# Migrate configuration between versions\nnpx tsx cmd/index.ts migrate config-v1.yaml --from v1 --to v2 --dry-run\nnpx tsx cmd/index.ts migrate config-v1.yaml --from v1 --to v2 --output config-v2.yaml\n\n# Scan for secrets\nnpx tsx cmd/index.ts scan-secrets config.env\n```\n\n### Supported Formats\n\n- **JSON** — Fully supported with strict parsing\n- **YAML** — Fully supported via `js-yaml`\n- **TOML** — Fully supported via `@iarna/toml`\n- **.env** — Supported via custom parser (values are strings; type coercion is manual)\n\n---\n\n## Features\n\n### ✅ Validate Configuration Files\n\nValidates configuration files against a schema with the following rule types:\n\n- **Required**: Field must be present\n- **Type**: Field must match expected type (string, number, boolean, array, object)\n- **Enum**: Field must be one of allowed values\n- **Range**: Number must be within min/max bounds\n- **Pattern**: String must match regex pattern\n\n#### Example Validation\n\n```bash\n# Returns exit code 0 (success)\nnpx tsx cmd/index.ts validate testdata/json/valid_full.json\n\n# Returns exit code 1 (failure) with error details\nnpx tsx cmd/index.ts validate testdata/json/missing_required.json\n```\n\n**JSON Output** (for CI/CD integration):\n\n```bash\nnpx tsx cmd/index.ts validate config.json --json\n```\n\nOutput:\n```json\n{\n  \"isValid\": true,\n  \"errors\": [],\n  \"warnings\": []\n}\n```\n\n### ✅ Migrate Configurations\n\nDefine versioned migration paths to safely transform configuration files between versions.\n\n```bash\n# Dry-run: see what would change\nnpx tsx cmd/index.ts migrate config-v1.yaml --from v1 --to v2 --dry-run\n\n# Apply migration to new file\nnpx tsx cmd/index.ts migrate config-v1.yaml --from v1 --to v2 --output config-v2.yaml\n\n# Apply migration in-place (overwrites original)\nnpx tsx cmd/index.ts migrate config-v1.yaml --from v1 --to v2\n```\n\n**Supported Transformations**:\n- `rename`: Rename a field (e.g., `app_name` → `application_name`)\n- `addDefault`: Add a field with a default value if missing\n- `deprecate`: Remove deprecated fields\n- `custom`: Apply custom transformation function\n\n### ✅ Detect Secrets\n\nScan configuration files for common secrets using regex patterns.\n\n```bash\nnpx tsx cmd/index.ts scan-secrets config.env\n```\n\n**Detects**:\n- AWS Access Keys (pattern: `AKIA[0-9A-Z]{16}`)\n- GitHub Personal Access Tokens (pattern: `ghp_[a-zA-Z0-9_]{36,}`)\n- Password fields (pattern: `password\\s*[:=]\\s*['\"]?([^'\"]+)['\"]?`)\n\n**Output**:\n- Line numbers and column positions\n- Redacted secret values (`Ak**...**LE` format)\n- Severity levels (high, medium, low)\n\n---\n## Limitations & Future Enhancements\n\n### Current Limitations\n\n1. **Schema is hardcoded** in the validate command\n   - Future: Load from `--schema <file>` JSON/YAML schema definitions\n\n2. **Migration paths are hardcoded** in the migrate command\n   - Future: Load from `migrations/` directory with proper versioning\n\n3. **Secret patterns are hardcoded**\n   - Future: Load from configurable pattern library or external file\n\n4. **No watch mode**\n   - Future: Add `--watch` flag to re-validate on file change\n\n---\n\n## Commands Reference\n\n```bash\n# Validation\nnpx tsx cmd/index.ts validate <file> [--format auto-detect|json|yaml|toml|env] [--json]\n\n# Migration\nnpx tsx cmd/index.ts migrate <file> --from <version> --to <version> [--output <file>] [--dry-run] [--json]\n\n# Secret Scanning\nnpx tsx cmd/index.ts scan-secrets <file> [--json]\n\n# Help\nnpx tsx cmd/index.ts --help\nnpx tsx cmd/index.ts validate --help\n\n# Version\nnpx tsx cmd/index.ts --version\n```\n\n---\n\n## Example: Full Workflow\n\n```bash\n# 1. Validate a configuration file\nnpx tsx cmd/index.ts validate config-v1.yaml\n# Output: ✓ Configuration is valid\n\n# 2. Scan for secrets before committing\nnpx tsx cmd/index.ts scan-secrets .env\n# Output: ✓ No secrets found\n\n# 3. Prepare for v2 migration with dry-run\nnpx tsx cmd/index.ts migrate config-v1.yaml --from v1 --to v2 --dry-run\n# Output: ✓ Successfully migrated from v1 to v2\n#         (Dry-run: No changes were written to disk)\n\n# 4. Apply migration to new file\nnpx tsx cmd/index.ts migrate config-v1.yaml --from v1 --to v2 --output config-v2.yaml\n# Output: ✓ Successfully migrated from v1 to v2\n#         ✓ Written to: config-v2.yaml\n\n# 5. Validate new config\nnpx tsx cmd/index.ts validate config-v2.yaml\n# Output: ✓ Configuration is valid\n\n# 6. Get JSON output for CI/CD\nnpx tsx cmd/index.ts validate config-v2.yaml --json\n# Output: {\"isValid\": true, \"errors\": [], \"warnings\": []}\n```\n\n\n\n---\n\n## Architecture Diagram\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                     CLI Entry Point (cmd/)                  │\n│         (validate, migrate, scan-secrets commands)          │\n└────────────────────────┬────────────────────────────────────┘\n                         │\n                         ▼\n┌─────────────────────────────────────────────────────────────┐\n│              Application Layer (use cases)                  │\n│   (ValidateUseCase, MigrateUseCase, ScanSecretsUseCase)     │\n└────────────────────────┬────────────────────────────────────┘\n                         │\n        ┌────────────────┼────────────────┐\n        │                │                │\n        ▼                ▼                ▼\n┌──────────────┐  ┌──────────────┐  ┌──────────────┐\n│  Domain      │  │  Parsers     │  │  Validators  │\n│  (pure       │  │  (adapters)  │  │  (strategy)  │\n│  business    │  │              │  │              │\n│  logic)      │  │  JSON/YAML/  │  │  Required/   │\n│              │  │  TOML/ENV    │  │  Type/Enum/  │\n│  ConfigSchema│  │              │  │  Range/      │\n│  Validation  │  │              │  │  Pattern     │\n│  Result      │  │              │  │              │\n│  MigrationObj│  │              │  │              │\n└──────────────┘  └──────────────┘  └──────────────┘\n        ▲                │                │\n        │                │                │\n        └────────────────┴────────────────┘\n                         │\n                         ▼\n        ┌────────────────────────────────┐\n        │  Infrastructure Layer (I/O)    │\n        │  - File Reading/Writing        │\n        │  - Regex Secret Scanning       │\n        └────────────────────────────────┘\n                         │\n                         ▼\n        ┌────────────────────────────────┐\n        │  Presentation Layer            │\n        │  (Output Formatters)           │\n        │  - Text & JSON formatting      │\n        └────────────────────────────────┘\n```\n\n---\n\n## License\n\nMIT","readmeFilename":"README.md","_rev":"1-c21475730684f4a9454b4e71da064e50"}