@gudroniy/env-doctor 1.0.0 → 1.0.1
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 +26 -26
- package/README.ru.md +75 -0
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
1
|
# env-doctor
|
|
2
2
|
|
|
3
|
-
CLI
|
|
3
|
+
A CLI that checks your `.env` files for missing variables, type mismatches, and drift between environments (dev / staging / production) — **before** it breaks your deploy.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## The problem
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
A classic failure mode: everything works locally, but one environment variable was never added to production — so the app crashes right after deploy. Or the variable is there, just in the wrong format (`PORT=abc` instead of a number). Usually this gets caught by eyeballing files side by side, if it gets caught at all.
|
|
8
8
|
|
|
9
|
-
`env-doctor`
|
|
9
|
+
`env-doctor` automates that check.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Install
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
npm install -g env-doctor
|
|
14
|
+
npm install -g @gudroniy/env-doctor
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Or without a global install:
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
npx env-doctor check
|
|
20
|
+
npx @gudroniy/env-doctor check
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
##
|
|
23
|
+
## Quick start
|
|
24
24
|
|
|
25
|
-
1.
|
|
25
|
+
1. Generate a schema from your working `.env`:
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
28
|
env-doctor init --file .env
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
This creates `env.schema.json` — a description of the expected variables and their types (inferred automatically).
|
|
32
32
|
|
|
33
|
-
2.
|
|
33
|
+
2. Edit the schema if needed — mark optional variables (`"required": false`), adjust types.
|
|
34
34
|
|
|
35
|
-
3.
|
|
35
|
+
3. Check any other `.env` file against that schema:
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
38
|
env-doctor check .env.production
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
With no arguments, it checks every `.env*` file in the current directory:
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
44
|
env-doctor check
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
##
|
|
47
|
+
## Example output
|
|
48
48
|
|
|
49
49
|
```
|
|
50
50
|
.env.production
|
|
51
|
-
✘
|
|
52
|
-
✘
|
|
53
|
-
✘
|
|
54
|
-
⚠
|
|
51
|
+
✘ Missing required variable "API_KEY"
|
|
52
|
+
✘ Variable "PORT" should be type number, got "not-a-number"
|
|
53
|
+
✘ Missing required variable "STRIPE_WEBHOOK_SECRET"
|
|
54
|
+
⚠ Variable "LEGACY_FLAG" is not defined in the schema
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
Total: 3 errors, 1 warning
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
##
|
|
59
|
+
## Using it in CI
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
The command exits with code `1` if any errors are found — drop it into your pipeline before deploy:
|
|
62
62
|
|
|
63
63
|
```yaml
|
|
64
|
-
- run: npx env-doctor check .env.production --strict
|
|
64
|
+
- run: npx @gudroniy/env-doctor check .env.production --strict
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
`--strict` also treats undeclared variables (e.g. leftover legacy keys) as errors, not just warnings.
|
|
68
68
|
|
|
69
|
-
##
|
|
69
|
+
## Supported types
|
|
70
70
|
|
|
71
71
|
`string`, `number`, `boolean`, `url`, `email`
|
|
72
72
|
|
|
73
|
-
##
|
|
73
|
+
## License
|
|
74
74
|
|
|
75
75
|
MIT
|
package/README.ru.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# env-doctor
|
|
2
|
+
|
|
3
|
+
CLI, который проверяет `.env` файлы на пропущенные переменные, несовпадение типов и расхождения между окружениями (dev / staging / production) — **до** того, как это сломает деплой.
|
|
4
|
+
|
|
5
|
+
## Проблема
|
|
6
|
+
|
|
7
|
+
Классическая ситуация: в `.env` локально всё работает, а на проде забыли добавить одну переменную — и приложение падает после деплоя. Или переменная есть, но записана не в том формате (например, `PORT=abc` вместо числа). Обычно это ловят вручную, глазами, сравнивая файлы.
|
|
8
|
+
|
|
9
|
+
`env-doctor` автоматизирует эту проверку.
|
|
10
|
+
|
|
11
|
+
## Установка
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g env-doctor
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Или без глобальной установки:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx env-doctor check
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Быстрый старт
|
|
24
|
+
|
|
25
|
+
1. Сгенерируй схему на основе рабочего `.env`:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
env-doctor init --file .env
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Это создаст `env.schema.json` — файл с описанием ожидаемых переменных и их типов (определяются автоматически).
|
|
32
|
+
|
|
33
|
+
2. Отредактируй схему при необходимости — пометь необязательные переменные (`"required": false`), поправь типы.
|
|
34
|
+
|
|
35
|
+
3. Проверь любой другой `.env` файл на соответствие схеме:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
env-doctor check .env.production
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Без аргументов проверяются все файлы вида `.env*` в текущей папке:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
env-doctor check
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Пример вывода
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
.env.production
|
|
51
|
+
✘ Переменная "API_KEY" обязательна, но пустая
|
|
52
|
+
✘ Переменная "PORT" должна быть типа number, получено "not-a-number"
|
|
53
|
+
✘ Отсутствует обязательная переменная "STRIPE_WEBHOOK_SECRET"
|
|
54
|
+
⚠ Переменная "LEGACY_FLAG" не описана в схеме
|
|
55
|
+
|
|
56
|
+
Итого: 3 ошибок, 1 предупреждений
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Использование в CI
|
|
60
|
+
|
|
61
|
+
Команда завершается с кодом `1`, если найдены ошибки — удобно добавить проверку в pipeline перед деплоем:
|
|
62
|
+
|
|
63
|
+
```yaml
|
|
64
|
+
- run: npx env-doctor check .env.production --strict
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Флаг `--strict` также считает ошибкой любые переменные, не описанные в схеме (например, забытые старые ключи).
|
|
68
|
+
|
|
69
|
+
## Поддерживаемые типы
|
|
70
|
+
|
|
71
|
+
`string`, `number`, `boolean`, `url`, `email`
|
|
72
|
+
|
|
73
|
+
## Лицензия
|
|
74
|
+
|
|
75
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gudroniy/env-doctor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "CLI, который проверяет .env файлы на пропущенные переменные, несовпадение типов и расхождения между окружениями",
|
|
5
5
|
"bin": {
|
|
6
6
|
"env-doctor": "./bin/env-doctor.js"
|
|
7
7
|
},
|
|
8
8
|
"main": "src/index.js",
|
|
9
9
|
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/VIad1slav/env-doctor.git"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/VIad1slav/env-doctor#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/VIad1slav/env-doctor/issues"
|
|
17
|
+
},
|
|
10
18
|
"files": [
|
|
11
19
|
"bin",
|
|
12
20
|
"src",
|