episodely-envcheck 0.1.0__tar.gz
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.
- episodely_envcheck-0.1.0/LICENSE +9 -0
- episodely_envcheck-0.1.0/PKG-INFO +76 -0
- episodely_envcheck-0.1.0/README.md +60 -0
- episodely_envcheck-0.1.0/envcheck.py +158 -0
- episodely_envcheck-0.1.0/episodely_envcheck.egg-info/PKG-INFO +76 -0
- episodely_envcheck-0.1.0/episodely_envcheck.egg-info/SOURCES.txt +9 -0
- episodely_envcheck-0.1.0/episodely_envcheck.egg-info/dependency_links.txt +1 -0
- episodely_envcheck-0.1.0/episodely_envcheck.egg-info/entry_points.txt +2 -0
- episodely_envcheck-0.1.0/episodely_envcheck.egg-info/top_level.txt +1 -0
- episodely_envcheck-0.1.0/pyproject.toml +27 -0
- episodely_envcheck-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 episodely
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: episodely-envcheck
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lint .env files and compare them with .env.example. Values are never printed.
|
|
5
|
+
Author: episodely
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/episodely/envcheck
|
|
8
|
+
Project-URL: Issues, https://github.com/episodely/envcheck/issues
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# envcheck
|
|
18
|
+
|
|
19
|
+
Lint a `.env` file and diff it against `.env.example`. Catches the mistakes that break a deploy or quietly leak: duplicate keys, keys missing from the example, keys set locally that nobody documented, unquoted values with spaces, broken quotes, stray whitespace and empty values.
|
|
20
|
+
|
|
21
|
+
Values are **never printed**. The output names keys and line numbers only, so it is safe to paste into a bug report or CI log. Pure Python, no dependencies, runs offline.
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
$ python envcheck.py .env --example .env.example
|
|
25
|
+
- [error] missing-key REDIS_URL: Set in the example (line 3) but missing here; startup usually needs it.
|
|
26
|
+
2 [error] duplicate-key DATABASE_URL: Key is also set on line 1; the last one wins.
|
|
27
|
+
3 [warn] unquoted-spaces APP_NAME: Unquoted value contains spaces; quote it or the value gets cut short.
|
|
28
|
+
4 [info] undocumented-key DEBUG_MODE: Not in the example; add it there so new setups know about it.
|
|
29
|
+
2 error(s), 1 warning(s), 1 note(s).
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
pip install episodely-envcheck
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Or copy `envcheck.py` into your project, it has no dependencies.
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
python envcheck.py .env # lint one file
|
|
44
|
+
python envcheck.py .env --example .env.example # also compare keys
|
|
45
|
+
cat .env | python envcheck.py # read stdin
|
|
46
|
+
python envcheck.py .env --example .env.example --json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Exit code is 1 when there is at least one `error`, so it fits CI. Warnings and notes alone exit 0. `--json` gives `{ok, counts, issues}` for tooling.
|
|
50
|
+
|
|
51
|
+
## Checks
|
|
52
|
+
|
|
53
|
+
| Code | Level | Meaning |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| `duplicate-key` | error | the same key is set twice; the last one silently wins |
|
|
56
|
+
| `missing-key` | error | the example file sets it, this file does not |
|
|
57
|
+
| `not-assignment` | error | a line that is not `KEY=VALUE` (usually a value with spaces or `#`) |
|
|
58
|
+
| `empty-key` | error | a line with `=` but no key |
|
|
59
|
+
| `odd-key` | warn | key characters some parsers reject |
|
|
60
|
+
| `unbalanced-quote` | warn | value starts or ends with a quote but not both |
|
|
61
|
+
| `unquoted-spaces` | warn | unquoted value contains spaces |
|
|
62
|
+
| `inline-hash` | info | unquoted value contains `#`; parsers disagree |
|
|
63
|
+
| `trailing-whitespace` | info | value ends in spaces or tabs, which some parsers keep |
|
|
64
|
+
| `empty-value` | info | key is set to an empty string |
|
|
65
|
+
| `escaped-quote` | info | quoted value contains its own quote character |
|
|
66
|
+
| `undocumented-key` | info | set here but not in the example |
|
|
67
|
+
|
|
68
|
+
`export KEY=VALUE` is accepted, `#` comment lines and blank lines are skipped, and a UTF-8 BOM or CRLF line endings are handled. A missing file, a directory or non-UTF-8 input exits 2 with one line on stderr, never a traceback.
|
|
69
|
+
|
|
70
|
+
## Test
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
python -m pytest
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
MIT licensed.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# envcheck
|
|
2
|
+
|
|
3
|
+
Lint a `.env` file and diff it against `.env.example`. Catches the mistakes that break a deploy or quietly leak: duplicate keys, keys missing from the example, keys set locally that nobody documented, unquoted values with spaces, broken quotes, stray whitespace and empty values.
|
|
4
|
+
|
|
5
|
+
Values are **never printed**. The output names keys and line numbers only, so it is safe to paste into a bug report or CI log. Pure Python, no dependencies, runs offline.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
$ python envcheck.py .env --example .env.example
|
|
9
|
+
- [error] missing-key REDIS_URL: Set in the example (line 3) but missing here; startup usually needs it.
|
|
10
|
+
2 [error] duplicate-key DATABASE_URL: Key is also set on line 1; the last one wins.
|
|
11
|
+
3 [warn] unquoted-spaces APP_NAME: Unquoted value contains spaces; quote it or the value gets cut short.
|
|
12
|
+
4 [info] undocumented-key DEBUG_MODE: Not in the example; add it there so new setups know about it.
|
|
13
|
+
2 error(s), 1 warning(s), 1 note(s).
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
pip install episodely-envcheck
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or copy `envcheck.py` into your project, it has no dependencies.
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
python envcheck.py .env # lint one file
|
|
28
|
+
python envcheck.py .env --example .env.example # also compare keys
|
|
29
|
+
cat .env | python envcheck.py # read stdin
|
|
30
|
+
python envcheck.py .env --example .env.example --json
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Exit code is 1 when there is at least one `error`, so it fits CI. Warnings and notes alone exit 0. `--json` gives `{ok, counts, issues}` for tooling.
|
|
34
|
+
|
|
35
|
+
## Checks
|
|
36
|
+
|
|
37
|
+
| Code | Level | Meaning |
|
|
38
|
+
|---|---|---|
|
|
39
|
+
| `duplicate-key` | error | the same key is set twice; the last one silently wins |
|
|
40
|
+
| `missing-key` | error | the example file sets it, this file does not |
|
|
41
|
+
| `not-assignment` | error | a line that is not `KEY=VALUE` (usually a value with spaces or `#`) |
|
|
42
|
+
| `empty-key` | error | a line with `=` but no key |
|
|
43
|
+
| `odd-key` | warn | key characters some parsers reject |
|
|
44
|
+
| `unbalanced-quote` | warn | value starts or ends with a quote but not both |
|
|
45
|
+
| `unquoted-spaces` | warn | unquoted value contains spaces |
|
|
46
|
+
| `inline-hash` | info | unquoted value contains `#`; parsers disagree |
|
|
47
|
+
| `trailing-whitespace` | info | value ends in spaces or tabs, which some parsers keep |
|
|
48
|
+
| `empty-value` | info | key is set to an empty string |
|
|
49
|
+
| `escaped-quote` | info | quoted value contains its own quote character |
|
|
50
|
+
| `undocumented-key` | info | set here but not in the example |
|
|
51
|
+
|
|
52
|
+
`export KEY=VALUE` is accepted, `#` comment lines and blank lines are skipped, and a UTF-8 BOM or CRLF line endings are handled. A missing file, a directory or non-UTF-8 input exits 2 with one line on stderr, never a traceback.
|
|
53
|
+
|
|
54
|
+
## Test
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
python -m pytest
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
MIT licensed.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"""Lint .env files and compare them with .env.example.
|
|
2
|
+
|
|
3
|
+
Values are never printed, so the output is safe to paste into a bug report.
|
|
4
|
+
"""
|
|
5
|
+
import re, sys, argparse, json
|
|
6
|
+
|
|
7
|
+
KEY_RE = re.compile(r"^[A-Za-z_][A-Za-z0-9_.\-]*$")
|
|
8
|
+
ASSIGN = re.compile(r"^([^=]*?)\s*=\s*(.*)$")
|
|
9
|
+
QUOTES = "\"'"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _issues_for_value(key, val):
|
|
13
|
+
"""Problems with one value. Returns (level, code, message) tuples; never echoes val."""
|
|
14
|
+
out = []
|
|
15
|
+
if val == "":
|
|
16
|
+
return [("info", "empty-value", "Key is set to an empty string.")]
|
|
17
|
+
if val != val.rstrip():
|
|
18
|
+
out.append(("info", "trailing-whitespace", "Value has trailing whitespace; many parsers keep it."))
|
|
19
|
+
starts, ends = val[0] in QUOTES, val[-1] in QUOTES
|
|
20
|
+
if starts and ends and len(val) >= 2:
|
|
21
|
+
inner = val[1:-1]
|
|
22
|
+
if val[0] in inner:
|
|
23
|
+
out.append(("info", "escaped-quote", "Quoted value contains its own quote character; check the escaping."))
|
|
24
|
+
return out
|
|
25
|
+
if starts != ends:
|
|
26
|
+
out.append(("warn", "unbalanced-quote", "Value starts or ends with a quote character but not both."))
|
|
27
|
+
return out
|
|
28
|
+
body = val.strip()
|
|
29
|
+
if re.search(r"\s", body):
|
|
30
|
+
out.append(("warn", "unquoted-spaces", "Unquoted value contains spaces; quote it or the value gets cut short."))
|
|
31
|
+
if "#" in body:
|
|
32
|
+
out.append(("info", "inline-hash", "Unquoted value contains '#': some parsers keep it, some treat it as a comment."))
|
|
33
|
+
return out
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def parse(text):
|
|
37
|
+
"""Parse .env text into ordered (line_no, key) entries plus syntax issues."""
|
|
38
|
+
entries, issues = [], []
|
|
39
|
+
for no, raw in enumerate(text.splitlines(), 1):
|
|
40
|
+
line = raw.strip()
|
|
41
|
+
if not line or line.startswith("#"):
|
|
42
|
+
continue
|
|
43
|
+
# keep trailing whitespace on the value: parsers disagree about it, and it is invisible
|
|
44
|
+
body = raw.lstrip()
|
|
45
|
+
if body.startswith("export "):
|
|
46
|
+
body = body[7:].lstrip()
|
|
47
|
+
m = ASSIGN.match(body)
|
|
48
|
+
if not m:
|
|
49
|
+
issues.append((no, "error", "not-assignment", "", "Line is not KEY=VALUE; quote values that contain spaces or #."))
|
|
50
|
+
continue
|
|
51
|
+
key = m.group(1).strip()
|
|
52
|
+
val = m.group(2)
|
|
53
|
+
if not key:
|
|
54
|
+
issues.append((no, "error", "empty-key", "", "Line has no key before '='."))
|
|
55
|
+
continue
|
|
56
|
+
if not KEY_RE.match(key):
|
|
57
|
+
issues.append((no, "warn", "odd-key", key, "Key has characters some parsers reject; use letters, digits, _ . -"))
|
|
58
|
+
entries.append((no, key))
|
|
59
|
+
for level, code, message in _issues_for_value(key, val):
|
|
60
|
+
issues.append((no, level, code, key, message))
|
|
61
|
+
return entries, issues
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def lint(text, example_text=None):
|
|
65
|
+
"""Lint one .env body, optionally against an example file. Returns a sorted issue list."""
|
|
66
|
+
if not isinstance(text, str):
|
|
67
|
+
raise TypeError("text must be a string")
|
|
68
|
+
if example_text is not None and not isinstance(example_text, str):
|
|
69
|
+
raise TypeError("example_text must be a string")
|
|
70
|
+
text = text.lstrip("\ufeff").replace("\r\n", "\n").replace("\r", "\n")
|
|
71
|
+
entries, issues = parse(text)
|
|
72
|
+
first = {}
|
|
73
|
+
for no, key in entries:
|
|
74
|
+
if key in first:
|
|
75
|
+
issues.append((no, "error", "duplicate-key", key, f"Key is also set on line {first[key]}; the last one wins."))
|
|
76
|
+
else:
|
|
77
|
+
first[key] = no
|
|
78
|
+
if example_text is not None:
|
|
79
|
+
example_text = example_text.lstrip("\ufeff").replace("\r\n", "\n").replace("\r", "\n")
|
|
80
|
+
ex_entries, _ = parse(example_text)
|
|
81
|
+
ex_line, ex_keys = {}, []
|
|
82
|
+
for no, key in ex_entries:
|
|
83
|
+
if key not in ex_line:
|
|
84
|
+
ex_line[key] = no
|
|
85
|
+
ex_keys.append(key)
|
|
86
|
+
for key in ex_keys:
|
|
87
|
+
if key not in first:
|
|
88
|
+
issues.append((0, "error", "missing-key", key, f"Set in the example (line {ex_line[key]}) but missing here; startup usually needs it."))
|
|
89
|
+
for key in first:
|
|
90
|
+
if key not in ex_line:
|
|
91
|
+
issues.append((first[key], "info", "undocumented-key", key, "Not in the example; add it there so new setups know about it."))
|
|
92
|
+
issues.sort(key=lambda i: (i[0], i[1] != "error", i[2], i[3]))
|
|
93
|
+
return issues
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def read_input(path):
|
|
97
|
+
"""Read a file (or stdin) as UTF-8 text, or raise ValueError with a printable message."""
|
|
98
|
+
if path is None:
|
|
99
|
+
stream = getattr(sys.stdin, "buffer", None)
|
|
100
|
+
if stream is None: # already a text stream (tests, some runners)
|
|
101
|
+
return sys.stdin.read()
|
|
102
|
+
data, label = stream.read(), "stdin"
|
|
103
|
+
else:
|
|
104
|
+
label = path
|
|
105
|
+
try:
|
|
106
|
+
with open(path, "rb") as fh:
|
|
107
|
+
data = fh.read()
|
|
108
|
+
except FileNotFoundError:
|
|
109
|
+
raise ValueError(f"no such file: {path}")
|
|
110
|
+
except IsADirectoryError:
|
|
111
|
+
raise ValueError(f"is a directory: {path}")
|
|
112
|
+
except PermissionError:
|
|
113
|
+
raise ValueError(f"permission denied: {path}")
|
|
114
|
+
except OSError as exc:
|
|
115
|
+
raise ValueError(f"could not read {path}: {exc.strerror or exc}")
|
|
116
|
+
try:
|
|
117
|
+
return data.decode("utf-8-sig")
|
|
118
|
+
except UnicodeDecodeError as exc:
|
|
119
|
+
raise ValueError(f"{label} is not valid UTF-8 (byte {exc.start}); convert it to UTF-8 first")
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def main(argv=None):
|
|
123
|
+
ap = argparse.ArgumentParser(prog="envcheck", description="Lint a .env file, optionally against .env.example. Values are never printed.")
|
|
124
|
+
ap.add_argument("file", nargs="?", help="the .env file (default: stdin)")
|
|
125
|
+
ap.add_argument("--example", metavar="PATH", help="compare against this example file")
|
|
126
|
+
ap.add_argument("--json", action="store_true")
|
|
127
|
+
a = ap.parse_args(argv)
|
|
128
|
+
try:
|
|
129
|
+
text = read_input(a.file)
|
|
130
|
+
example = read_input(a.example) if a.example else None
|
|
131
|
+
except ValueError as exc:
|
|
132
|
+
print(f"envcheck: {exc}", file=sys.stderr)
|
|
133
|
+
return 2
|
|
134
|
+
issues = lint(text, example)
|
|
135
|
+
counts = {lv: sum(1 for i in issues if i[1] == lv) for lv in ("error", "warn", "info")}
|
|
136
|
+
try:
|
|
137
|
+
if a.json:
|
|
138
|
+
print(json.dumps({
|
|
139
|
+
"ok": counts["error"] == 0,
|
|
140
|
+
"counts": counts,
|
|
141
|
+
"issues": [dict(line=n, level=lv, code=c, key=k, message=m) for n, lv, c, k, m in issues],
|
|
142
|
+
}, indent=2))
|
|
143
|
+
else:
|
|
144
|
+
for n, lv, c, k, m in issues:
|
|
145
|
+
where = f"{n:>4}" if n else " -"
|
|
146
|
+
print(f"{where} [{lv}] {c}{' ' + k if k else ''}: {m}")
|
|
147
|
+
print(f"{counts['error']} error(s), {counts['warn']} warning(s), {counts['info']} note(s).")
|
|
148
|
+
except BrokenPipeError:
|
|
149
|
+
try:
|
|
150
|
+
sys.stdout.close()
|
|
151
|
+
except BrokenPipeError:
|
|
152
|
+
pass
|
|
153
|
+
return 0
|
|
154
|
+
return 1 if counts["error"] else 0
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
if __name__ == "__main__":
|
|
158
|
+
sys.exit(main())
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: episodely-envcheck
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lint .env files and compare them with .env.example. Values are never printed.
|
|
5
|
+
Author: episodely
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/episodely/envcheck
|
|
8
|
+
Project-URL: Issues, https://github.com/episodely/envcheck/issues
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# envcheck
|
|
18
|
+
|
|
19
|
+
Lint a `.env` file and diff it against `.env.example`. Catches the mistakes that break a deploy or quietly leak: duplicate keys, keys missing from the example, keys set locally that nobody documented, unquoted values with spaces, broken quotes, stray whitespace and empty values.
|
|
20
|
+
|
|
21
|
+
Values are **never printed**. The output names keys and line numbers only, so it is safe to paste into a bug report or CI log. Pure Python, no dependencies, runs offline.
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
$ python envcheck.py .env --example .env.example
|
|
25
|
+
- [error] missing-key REDIS_URL: Set in the example (line 3) but missing here; startup usually needs it.
|
|
26
|
+
2 [error] duplicate-key DATABASE_URL: Key is also set on line 1; the last one wins.
|
|
27
|
+
3 [warn] unquoted-spaces APP_NAME: Unquoted value contains spaces; quote it or the value gets cut short.
|
|
28
|
+
4 [info] undocumented-key DEBUG_MODE: Not in the example; add it there so new setups know about it.
|
|
29
|
+
2 error(s), 1 warning(s), 1 note(s).
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
pip install episodely-envcheck
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Or copy `envcheck.py` into your project, it has no dependencies.
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
python envcheck.py .env # lint one file
|
|
44
|
+
python envcheck.py .env --example .env.example # also compare keys
|
|
45
|
+
cat .env | python envcheck.py # read stdin
|
|
46
|
+
python envcheck.py .env --example .env.example --json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Exit code is 1 when there is at least one `error`, so it fits CI. Warnings and notes alone exit 0. `--json` gives `{ok, counts, issues}` for tooling.
|
|
50
|
+
|
|
51
|
+
## Checks
|
|
52
|
+
|
|
53
|
+
| Code | Level | Meaning |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| `duplicate-key` | error | the same key is set twice; the last one silently wins |
|
|
56
|
+
| `missing-key` | error | the example file sets it, this file does not |
|
|
57
|
+
| `not-assignment` | error | a line that is not `KEY=VALUE` (usually a value with spaces or `#`) |
|
|
58
|
+
| `empty-key` | error | a line with `=` but no key |
|
|
59
|
+
| `odd-key` | warn | key characters some parsers reject |
|
|
60
|
+
| `unbalanced-quote` | warn | value starts or ends with a quote but not both |
|
|
61
|
+
| `unquoted-spaces` | warn | unquoted value contains spaces |
|
|
62
|
+
| `inline-hash` | info | unquoted value contains `#`; parsers disagree |
|
|
63
|
+
| `trailing-whitespace` | info | value ends in spaces or tabs, which some parsers keep |
|
|
64
|
+
| `empty-value` | info | key is set to an empty string |
|
|
65
|
+
| `escaped-quote` | info | quoted value contains its own quote character |
|
|
66
|
+
| `undocumented-key` | info | set here but not in the example |
|
|
67
|
+
|
|
68
|
+
`export KEY=VALUE` is accepted, `#` comment lines and blank lines are skipped, and a UTF-8 BOM or CRLF line endings are handled. A missing file, a directory or non-UTF-8 input exits 2 with one line on stderr, never a traceback.
|
|
69
|
+
|
|
70
|
+
## Test
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
python -m pytest
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
MIT licensed.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
envcheck.py
|
|
4
|
+
pyproject.toml
|
|
5
|
+
episodely_envcheck.egg-info/PKG-INFO
|
|
6
|
+
episodely_envcheck.egg-info/SOURCES.txt
|
|
7
|
+
episodely_envcheck.egg-info/dependency_links.txt
|
|
8
|
+
episodely_envcheck.egg-info/entry_points.txt
|
|
9
|
+
episodely_envcheck.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
envcheck
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "episodely-envcheck"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Lint .env files and compare them with .env.example. Values are never printed."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
authors = [{ name = "episodely" }]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"License :: OSI Approved :: MIT License",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.urls]
|
|
20
|
+
Homepage = "https://github.com/episodely/envcheck"
|
|
21
|
+
Issues = "https://github.com/episodely/envcheck/issues"
|
|
22
|
+
|
|
23
|
+
[project.scripts]
|
|
24
|
+
envcheck = "envcheck:main"
|
|
25
|
+
|
|
26
|
+
[tool.setuptools]
|
|
27
|
+
py-modules = ["envcheck"]
|