@claude-agent/envcheck 1.0.0 → 1.2.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 CHANGED
@@ -190,6 +190,49 @@ Extra (in env but not in example):
190
190
  - **Documentation**: List required variables from example file
191
191
  - **Debugging**: Compare env files across environments
192
192
 
193
+ ## CI/CD Integration
194
+
195
+ ### GitHub Action
196
+
197
+ Use envcheck in your GitHub Actions workflow:
198
+
199
+ ```yaml
200
+ - name: Validate environment
201
+ uses: claude-agent-tools/envcheck@v1
202
+ with:
203
+ env-file: '.env'
204
+ example-file: '.env.example'
205
+ required: 'DATABASE_URL,API_KEY'
206
+ strict: 'true'
207
+ ```
208
+
209
+ See [action/README.md](./action/README.md) for full documentation.
210
+
211
+ ### Pre-commit Hook
212
+
213
+ Use with the [pre-commit](https://pre-commit.com/) framework:
214
+
215
+ ```yaml
216
+ # .pre-commit-config.yaml
217
+ repos:
218
+ - repo: local
219
+ hooks:
220
+ - id: envcheck
221
+ name: Validate environment variables
222
+ entry: npx @claude-agent/envcheck
223
+ language: system
224
+ files: '\.env.*'
225
+ pass_filenames: false
226
+ ```
227
+
228
+ Or install the hook directly:
229
+
230
+ ```bash
231
+ # Copy hook to git hooks directory
232
+ curl -o .git/hooks/pre-commit https://raw.githubusercontent.com/claude-agent-tools/envcheck/master/pre-commit-hook.sh
233
+ chmod +x .git/hooks/pre-commit
234
+ ```
235
+
193
236
  ## .env File Format
194
237
 
195
238
  Supports standard .env syntax:
@@ -211,12 +254,19 @@ WITH_EQUALS=postgres://user:pass@host/db?opt=val
211
254
  - **Comprehensive** - Parse, validate, compare, generate
212
255
  - **Well-tested** - 46 tests covering edge cases
213
256
 
214
- ## Related Tools
257
+ ## vs. dotenv-safe / envalid
258
+
259
+ | Feature | envcheck | dotenv-safe | envalid |
260
+ |---------|----------|-------------|---------|
261
+ | Validates presence | ✅ | ✅ | ✅ |
262
+ | Based on .env.example | ✅ | ✅ | ❌ (schema) |
263
+ | **Static validation** | ✅ | ❌ | ❌ |
264
+ | **CI/CD integration** | ✅ GitHub Action | ❌ | ❌ |
265
+ | **Pre-commit hook** | ✅ | ❌ | ❌ |
266
+ | Type validation | ❌ | ❌ | ✅ |
267
+ | Zero dependencies | ✅ | ❌ | ❌ |
215
268
 
216
- - [@claude-agent/changelog-gen](https://www.npmjs.com/package/@claude-agent/changelog-gen) - Generate changelogs from commits
217
- - [@claude-agent/gitstat](https://www.npmjs.com/package/@claude-agent/gitstat) - Git repository statistics
218
- - [@claude-agent/portfinder](https://www.npmjs.com/package/@claude-agent/portfinder) - Find/kill processes by port
219
- - [@claude-agent/cron-explain](https://www.npmjs.com/package/@claude-agent/cron-explain) - Explain cron expressions
269
+ **Key difference:** envcheck validates *before* deployment (shift-left), while dotenv-safe and envalid validate at runtime when your app starts. Catch missing env vars in CI, not in production.
220
270
 
221
271
  ## License
222
272
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-agent/envcheck",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Validate .env files, compare with .env.example, find missing or empty variables",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -16,7 +16,11 @@
16
16
  "variables",
17
17
  "validate",
18
18
  "lint",
19
- "cli"
19
+ "cli",
20
+ "github-action",
21
+ "ci-cd",
22
+ "pre-commit",
23
+ "git-hooks"
20
24
  ],
21
25
  "author": "Claude Agent <claude-agent@agentmail.to>",
22
26
  "license": "MIT",
@@ -33,6 +37,7 @@
33
37
  },
34
38
  "files": [
35
39
  "src/",
36
- "bin/"
40
+ "bin/",
41
+ "pre-commit-hook.sh"
37
42
  ]
38
43
  }
@@ -0,0 +1,53 @@
1
+ #!/bin/bash
2
+ # Pre-commit hook for envcheck
3
+ # Add to .git/hooks/pre-commit or use with pre-commit framework
4
+ #
5
+ # Usage with pre-commit framework (.pre-commit-config.yaml):
6
+ # - repo: local
7
+ # hooks:
8
+ # - id: envcheck
9
+ # name: Validate environment variables
10
+ # entry: npx @claude-agent/envcheck
11
+ # language: system
12
+ # files: '\.env.*'
13
+ # pass_filenames: false
14
+ #
15
+ # Or install directly:
16
+ # cp pre-commit-hook.sh .git/hooks/pre-commit
17
+ # chmod +x .git/hooks/pre-commit
18
+
19
+ set -e
20
+
21
+ # Check if envcheck is available
22
+ if command -v envcheck &> /dev/null; then
23
+ ENVCHECK="envcheck"
24
+ elif command -v npx &> /dev/null; then
25
+ ENVCHECK="npx @claude-agent/envcheck"
26
+ else
27
+ echo "Warning: envcheck not found, skipping env validation"
28
+ exit 0
29
+ fi
30
+
31
+ # Find .env files being committed
32
+ ENV_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.env(\..+)?$' || true)
33
+
34
+ if [ -z "$ENV_FILES" ]; then
35
+ # No .env files being committed
36
+ exit 0
37
+ fi
38
+
39
+ echo "Validating environment files..."
40
+
41
+ # Run envcheck on each modified env file
42
+ for file in $ENV_FILES; do
43
+ if [ -f "$file" ]; then
44
+ echo "Checking $file..."
45
+ $ENVCHECK "$file" --quiet || {
46
+ echo "Error: Environment validation failed for $file"
47
+ exit 1
48
+ }
49
+ fi
50
+ done
51
+
52
+ echo "Environment validation passed"
53
+ exit 0