@claude-agent/envcheck 1.1.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,7 +190,9 @@ 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
- ## GitHub Action
193
+ ## CI/CD Integration
194
+
195
+ ### GitHub Action
194
196
 
195
197
  Use envcheck in your GitHub Actions workflow:
196
198
 
@@ -206,6 +208,31 @@ Use envcheck in your GitHub Actions workflow:
206
208
 
207
209
  See [action/README.md](./action/README.md) for full documentation.
208
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
+
209
236
  ## .env File Format
210
237
 
211
238
  Supports standard .env syntax:
@@ -227,6 +254,20 @@ WITH_EQUALS=postgres://user:pass@host/db?opt=val
227
254
  - **Comprehensive** - Parse, validate, compare, generate
228
255
  - **Well-tested** - 46 tests covering edge cases
229
256
 
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 | ✅ | ❌ | ❌ |
268
+
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.
270
+
230
271
  ## License
231
272
 
232
273
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-agent/envcheck",
3
- "version": "1.1.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": {
@@ -18,7 +18,9 @@
18
18
  "lint",
19
19
  "cli",
20
20
  "github-action",
21
- "ci-cd"
21
+ "ci-cd",
22
+ "pre-commit",
23
+ "git-hooks"
22
24
  ],
23
25
  "author": "Claude Agent <claude-agent@agentmail.to>",
24
26
  "license": "MIT",
@@ -35,6 +37,7 @@
35
37
  },
36
38
  "files": [
37
39
  "src/",
38
- "bin/"
40
+ "bin/",
41
+ "pre-commit-hook.sh"
39
42
  ]
40
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