env-latest 1.0.0 → 1.0.2
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 +67 -0
- package/package.json +10 -2
- package/.env +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# env-latest
|
|
2
|
+
|
|
3
|
+
A dead-simple, blazing-fast CLI tool to ensure your local `.env` file is always in sync with `.env.example`. Stop fighting with "missing environment variable" crashes in production!
|
|
4
|
+
|
|
5
|
+
## Why use this?
|
|
6
|
+
When working on backend/cloud projects, team members often add new variables to `.env.example`. If other developers (or your CI/CD pipeline) forget to update their local `.env` files, the application crashes silently.
|
|
7
|
+
|
|
8
|
+
`env-latest` checks if every key inside `.env.example` exists in your `.env`. If something is missing, it will boldly yell out the exact missing keys and fail the process with `Exit Code 1` — perfect for Husky Pre-commit hooks!
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Run it instantly using `npx` (No installation needed!):
|
|
15
|
+
```bash
|
|
16
|
+
npx env-latest
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or install it globally:
|
|
20
|
+
```bash
|
|
21
|
+
npm install -g env-latest
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or add it to your project's `devDependencies`:
|
|
25
|
+
```bash
|
|
26
|
+
npm install --save-dev env-latest
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Usage / Example
|
|
32
|
+
|
|
33
|
+
Simply run the command in the root of any project that contains `.env` and `.env.example` files:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
env-latest
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Case 1: All Sync (Success)
|
|
40
|
+
```text
|
|
41
|
+
[env-latest] All environment variables are synced!
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Case 2: Missing Variables (Error)
|
|
45
|
+
```text
|
|
46
|
+
[env-latest] Error: Missing environment variables in your .env file:
|
|
47
|
+
- AWS_SECRET_KEY
|
|
48
|
+
- DB_PASSWORD
|
|
49
|
+
|
|
50
|
+
Please add these to your .env file so the application can run properly.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Adding to Husky / Pre-commit Hooks (Recommended)
|
|
56
|
+
You can prevent developers from committing code if their `.env` is outdated! Just add `env-latest` to your `package.json` scripts:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"scripts": {
|
|
61
|
+
"precommit": "env-latest && lint-staged"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
*Created with ❤️ to save developers from debugging `.env` nightmares.*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "env-latest",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -12,7 +12,15 @@
|
|
|
12
12
|
"bin": {
|
|
13
13
|
"env-latest": "./index.js"
|
|
14
14
|
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/gaweki/env-latest.git"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/gaweki/env-latest/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/gaweki/env-latest#readme",
|
|
15
23
|
"dependencies": {
|
|
16
24
|
"dotenv": "^17.3.1"
|
|
17
25
|
}
|
|
18
|
-
}
|
|
26
|
+
}
|
package/.env
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
DB_HOST=127.0.0.1
|