@jutaru-dev/envsonar 0.1.0 → 0.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
@@ -1,176 +1,188 @@
1
- # envsonar
2
-
3
- [![ci](https://github.com/jutaru-dev/envsonar/actions/workflows/ci.yml/badge.svg)](https://github.com/jutaru-dev/envsonar/actions/workflows/ci.yml)
4
- [![npm](https://img.shields.io/npm/v/@jutaru-dev/envsonar?color=2f74ff)](https://www.npmjs.com/package/@jutaru-dev/envsonar)
5
- ![dependencies](https://img.shields.io/badge/dependencies-0-2f74ff)
6
- ![node](https://img.shields.io/badge/node-%E2%89%A520-2f74ff)
7
- ![license](https://img.shields.io/badge/license-MIT-2f74ff)
8
-
9
- **Catches the env vars your code reads but `.env.example` forgot — and knows which ones your framework reads for you.**
10
-
11
- <p align="center">
12
- <img src="https://raw.githubusercontent.com/jutaru-dev/envsonar/main/assets/demo.svg" alt="envsonar on a monorepo: two keys missing from .env.example, one documented key nobody reads" width="100%">
13
- </p>
14
-
15
- Checking `.env.example` against the code isn't a new idea, and the simple version is easy: grep for `process.env.X` and `os.getenv("X")`. The trouble is that real projects mostly don't read config that way. ASP.NET Core turns `config["Jwt:Key"]` into `Jwt__Key`. pydantic-settings derives names from class fields. A zod schema parses `process.env` in one place. The postgres image reads `POSTGRES_PASSWORD` and the OpenAI SDK reads `OPENAI_API_KEY` without a single line of your code naming them.
16
-
17
- A grep-only check misses the first group and calls the second one "unused". After a week of false alarms people switch it off. envsonar is built around that problem: it understands how each stack reads configuration, so what it reports is worth fixing.
18
-
19
- ## What that means on a real project
20
-
21
- The demo above is [`examples/demo`](https://github.com/jutaru-dev/envsonar/tree/main/examples/demo): a Next.js app, an ASP.NET Core API, a Python worker and a compose file sharing one `.env.example`.
22
-
23
- | | a scan that only finds direct reads | envsonar |
24
- | --- | --- | --- |
25
- | missing from `.env.example` | `STRIPE_SECRET_KEY`, `REDIS_URL` | `STRIPE_SECRET_KEY`, `WORKER_QUEUE_URL` |
26
- | documented but "unused" | 8 keys, 7 of them wrong | `LEGACY_FLAG` |
27
- | why | can't see the zod schema, .NET config, pydantic fields, the SDKs or the postgres image | reads all of them; `REDIS_URL` has a fallback in code, so it's a note, not an error |
28
-
29
- Before release it was also run on two private production projects, an ASP.NET Core + Next.js + compose app and a Python bot: zero false alarms between code and `.env.example`, and two real undocumented keys found.
30
-
31
- ## Quick start
32
-
33
- ```sh
34
- npx @jutaru-dev/envsonar # check the current project
35
- npx @jutaru-dev/envsonar --fix # add what's missing to .env.example (creates it if needed)
36
- npx @jutaru-dev/envsonar --list # every variable the code reads, and where
37
- ```
38
-
39
- Node.js 20 or newer. No install step and no config needed. `--fix` writes each key with an empty value and a comment saying where it's read:
40
-
41
- ```sh
42
- # added by envsonar
43
- # read in apps/web/src/app/api/checkout/route.ts:3
44
- STRIPE_SECRET_KEY=
45
- ```
46
-
47
- ## What it checks
48
-
49
- | | | |
50
- | --- | --- | --- |
51
- | ✗ | `undocumented` | read in code, not in `.env.example` |
52
- | ✗ | `missing` | in `.env.example`, not set in `.env` and the code needs it (only when `.env` exists) |
53
- | ! | `unused` | in `.env.example`, but nothing reads it: not your code, not a framework, SDK or image |
54
- | ! | `defaulted` | read with a fallback (`?? "x"`, `getenv("X", 1)`, `${X:-1}`), not in `.env.example`; hidden unless `--optional` |
55
- | ! | `empty` · `extra` · `duplicate` | in `.env`: empty value, key not documented, key defined twice |
56
- | ✗ | `syntax` | a line in either file that isn't `KEY=VALUE` |
57
-
58
- Errors fail the run; `--strict` makes warnings fail too. Reports contain key names, files and line numbers only. **Values are never printed**, so the output is safe in public CI logs.
59
-
60
- ## What it understands
61
-
62
- | Stack | Reads it picks up |
63
- | --- | --- |
64
- | **JS / TS** | `process.env.X`, `process.env["X"]`, `import.meta.env.X`, `Bun.env`, `Deno.env.get`, `const { X, Y = 1 } = process.env`, `const env = process.env; env.X` |
65
- | **env schemas** | zod objects passed to `parse(process.env)`, `@t3-oss/env` `createEnv`, envalid `cleanEnv`; `.default()` / `.optional()` count as fallbacks |
66
- | **SvelteKit · Vite** | `import { X } from "$env/static/private"`, `$env/dynamic`, `%VITE_X%` in `index.html` |
67
- | **ASP.NET Core** | `config["Jwt:Key"]` → `Jwt__Key`, `GetValue<T>()`, `GetConnectionString("Db")` → `ConnectionStrings__Db`, `GetSection("Smtp")` binds `Smtp__*`; keys with a value in `appsettings*.json` don't need a `.env` entry; names match case-insensitively, as .NET does |
68
- | **Python** | `os.getenv`, `os.environ[...]`, `.get` / `.setdefault`, aliases such as `env = dict(os.environ)`; **pydantic-settings** fields with `env_prefix` and `alias` |
69
- | **Go** | `os.Getenv`, `os.LookupEnv`, struct tags `env:"X"` (caarlos0/env) and `envconfig:"X"` |
70
- | **PHP / Laravel** | `env("X", default)`, `getenv`, `$_ENV`; framework keys Laravel reads from its own config |
71
- | **Ruby · Rust** | `ENV["X"]`, `ENV.fetch`; `env::var`, `dotenvy::var`, `env!`, `option_env!` |
72
- | **Prisma** | `env("DATABASE_URL")` in `schema.prisma` and `prisma.config.ts` |
73
- | **Docker Compose** | `${X}`, `${X:-default}`, `${X:?error}`, nested `${A:-${B}}`, `$X`; `environment:` entries supply the app with values |
74
-
75
- ### Variables nobody's code names
76
-
77
- Some variables are read by a dependency or a container, not by you. envsonar finds the dependency in `package.json`, `pyproject.toml` / `requirements*.txt`, `composer.json`, `*.csproj` or the compose `image:`, and stops calling its variables unused. The run header says what it found: `also read by: Next.js, OpenAI SDK, postgres image`.
78
-
79
- Covered now: Next.js, Nuxt, Auth.js, Prisma, OpenAI, Anthropic, Google AI, AWS, Google Cloud / Firebase, Sentry, libpq (`PG*`), Vercel Postgres / KV / Blob, Upstash, dotenvx, Django, Laravel, ASP.NET Core, Docker Compose, and the postgres, mysql, mariadb, mongo, redis, rabbitmq, minio, pgadmin, keycloak, clickhouse, elasticsearch, mssql, grafana, mailpit and n8n images. The whole list is one readable file, [`src/profiles.js`](https://github.com/jutaru-dev/envsonar/blob/main/src/profiles.js); adding a stack is a three-line PR.
80
-
81
- ### What it doesn't guess
82
-
83
- - **Dynamic reads** such as `process.env[name]` or `os.getenv(key)` can't be resolved statically. envsonar lists them with their locations (`1 dynamic read can't be checked: src/config.ts:12`) instead of silently skipping them.
84
- - It reads source with patterns, not a full parser per language. A read hidden behind your own wrapper (`getConfig("X")`) isn't seen. Add the key to `.env.example`, or skip it with `--ignore-key`.
85
- - Kubernetes manifests, Terraform and CI workflow files aren't scanned yet.
86
-
87
- ## In CI
88
-
89
- ```yaml
90
- # .github/workflows/env.yml
91
- name: env
92
- on: [pull_request]
93
- jobs:
94
- envsonar:
95
- runs-on: ubuntu-latest
96
- steps:
97
- - uses: actions/checkout@v4
98
- - uses: actions/setup-node@v4
99
- with:
100
- node-version: 22
101
- - run: npx @jutaru-dev/envsonar
102
- ```
103
-
104
- On GitHub Actions the findings also become annotations on the lines that caused them: the `STRIPE_SECRET_KEY` error shows up right on `route.ts:3` in the pull request diff. Elsewhere use `--format github` to force it, or `--json` for your own tooling.
105
-
106
- `.env` is usually not in CI, so only the code ↔ `.env.example` checks run there. To check a committed env file too, pass it: `--env .env.ci`.
107
-
108
- ## Options
109
-
110
- | | |
111
- | --- | --- |
112
- | `envsonar [dir]` | project to check (default: current directory); for a monorepo, run it per app: `envsonar apps/api` |
113
- | `--fix` | add undocumented keys to `.env.example`, creating the file if needed |
114
- | `--optional` | also report (and `--fix`) keys that have a fallback in code |
115
- | `--list` | print every variable the code reads, bound config sections and dynamic reads |
116
- | `--example <path>` | default `.env.example` |
117
- | `--env <path>` | default `.env`; checked only if it exists, unless you pass this flag |
118
- | `--no-code` | don't scan source, only compare `.env` with `.env.example` |
119
- | `--ignore <dir>` | skip a directory (repeatable). `node_modules`, build output, virtualenvs, worktrees and plain dirs from `.gitignore` are skipped already |
120
- | `--ignore-key <KEY>` | skip a key; `PREFIX_*` works (repeatable). OS and CI variables (`PATH`, `CI`, `GITHUB_*`, …) are skipped already |
121
- | `--strict` | warnings fail the run too |
122
- | `--json` | machine-readable report |
123
- | `--format <pretty\|github>` | `github` prints workflow annotations (automatic on GitHub Actions) |
124
- | `--no-color` | also respects `NO_COLOR` |
125
-
126
- The same settings can live in `.envsonarrc.json` or under `"envsonar"` in `package.json`:
127
-
128
- ```json
129
- {
130
- "envsonar": {
131
- "example": "config/.env.example",
132
- "ignore": ["legacy"],
133
- "ignoreKeys": ["INTERNAL_*"],
134
- "optional": true
135
- }
136
- }
137
- ```
138
-
139
- **Exit codes:** `0` clean · `1` errors found · `2` bad usage, unreadable file, or no `.env.example` (run `--fix` to create one).
140
-
141
- ## From code
142
-
143
- ```js
144
- import { scanProject, parseEnv, check } from "@jutaru-dev/envsonar";
145
- import { readFileSync } from "node:fs";
146
-
147
- const scan = scanProject(".");
148
- const findings = check({
149
- example: parseEnv(readFileSync(".env.example", "utf8")),
150
- exampleFile: ".env.example",
151
- scan,
152
- });
153
- ```
154
-
155
- `findings` is an array of `{ severity, code, key, file, line, message }`. `scan.usages` maps every key to the places it's read.
156
-
157
- ## Alternatives
158
-
159
- There are plenty of tools around `.env` files; pick the one that matches the job.
160
-
161
- - [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter): style and syntax of `.env` files themselves.
162
- - [envalid](https://github.com/af/envalid), [@t3-oss/env](https://github.com/t3-oss/t3-env): validate variables at runtime. envsonar reads their schemas, so the two work together.
163
- - [dotenvx](https://github.com/dotenvx/dotenvx): encrypted `.env` files.
164
- - [envsleuth](https://pypi.org/project/envsleuth), [dotenv-scan](https://dev.to/flyingsquirrel0419/i-got-tired-of-deploying-broken-configs-so-i-built-dotenv-scan-47lb), [env-check](https://github.com/SemTiOne/env-check): also compare code with `.env.example`. envsleuth has SARIF output.
165
-
166
- envsonar's focus is a mixed-stack repository and few false alarms: framework-specific config reads, implicit consumers, and defaults told apart from required keys.
167
-
168
- ## Development
169
-
170
- ```sh
171
- node --test # the whole suite, no install needed
172
- ```
173
-
174
- ## License
175
-
176
- MIT © Jutaru
1
+ # envsonar
2
+
3
+ [![ci](https://github.com/jutaru-dev/envsonar/actions/workflows/ci.yml/badge.svg)](https://github.com/jutaru-dev/envsonar/actions/workflows/ci.yml)
4
+ [![npm](https://img.shields.io/npm/v/@jutaru-dev/envsonar?color=2f74ff)](https://www.npmjs.com/package/@jutaru-dev/envsonar)
5
+ ![dependencies](https://img.shields.io/badge/dependencies-0-2f74ff)
6
+ ![node](https://img.shields.io/badge/node-%E2%89%A520-2f74ff)
7
+ ![license](https://img.shields.io/badge/license-MIT-2f74ff)
8
+
9
+ **Catches the env vars your code reads but `.env.example` forgot — and knows which ones your framework reads for you.**
10
+
11
+ <p align="center">
12
+ <img src="https://raw.githubusercontent.com/jutaru-dev/envsonar/main/assets/demo.svg" alt="envsonar on a monorepo: two keys missing from .env.example, one documented key nobody reads" width="100%">
13
+ </p>
14
+
15
+ Checking `.env.example` against the code isn't a new idea, and the simple version is easy: grep for `process.env.X` and `os.getenv("X")`. The trouble is that real projects mostly don't read config that way. ASP.NET Core turns `config["Jwt:Key"]` into `Jwt__Key`. pydantic-settings derives names from class fields. A zod schema parses `process.env` in one place. The postgres image reads `POSTGRES_PASSWORD` and the OpenAI SDK reads `OPENAI_API_KEY` without a single line of your code naming them.
16
+
17
+ A grep-only check misses the first group and calls the second one "unused". After a week of false alarms people switch it off. envsonar is built around that problem: it understands how each stack reads configuration, so what it reports is worth fixing.
18
+
19
+ ## What that means on a real project
20
+
21
+ The demo above is [`examples/demo`](https://github.com/jutaru-dev/envsonar/tree/main/examples/demo): a Next.js app, an ASP.NET Core API, a Python worker and a compose file sharing one `.env.example`.
22
+
23
+ | | a scan that only finds direct reads | envsonar |
24
+ | --- | --- | --- |
25
+ | missing from `.env.example` | `STRIPE_SECRET_KEY`, `REDIS_URL` | `STRIPE_SECRET_KEY`, `WORKER_QUEUE_URL` |
26
+ | documented but "unused" | 8 keys, 7 of them wrong | `LEGACY_FLAG` |
27
+ | why | can't see the zod schema, .NET config, pydantic fields, the SDKs or the postgres image | reads all of them; `REDIS_URL` has a fallback in code, so it's a note, not an error |
28
+
29
+ Before release it was also run on two private production projects, an ASP.NET Core + Next.js + compose app and a Python bot: zero false alarms between code and `.env.example`, and two real undocumented keys found.
30
+
31
+ ## Quick start
32
+
33
+ ```sh
34
+ npx @jutaru-dev/envsonar # check the current project
35
+ npx @jutaru-dev/envsonar --fix # add what's missing to .env.example (creates it if needed)
36
+ npx @jutaru-dev/envsonar --list # every variable the code reads, and where
37
+ ```
38
+
39
+ Node.js 20 or newer. No install step and no config needed. `--fix` writes each key with an empty value and a comment saying where it's read:
40
+
41
+ ```sh
42
+ # added by envsonar
43
+ # read in apps/web/src/app/api/checkout/route.ts:3
44
+ STRIPE_SECRET_KEY=
45
+ ```
46
+
47
+ ## What it checks
48
+
49
+ | | | |
50
+ | --- | --- | --- |
51
+ | ✗ | `undocumented` | read in code, not in `.env.example` |
52
+ | ✗ | `missing` | in `.env.example`, not set in `.env` and the code needs it (only when `.env` exists) |
53
+ | ! | `unused` | in `.env.example`, but nothing reads it: not your code, not a framework, SDK or image |
54
+ | ! | `defaulted` | read with a fallback (`?? "x"`, `getenv("X", 1)`, `${X:-1}`), not in `.env.example`; hidden unless `--optional` |
55
+ | ! | `empty` · `extra` · `duplicate` | in `.env`: empty value, key not documented, key defined twice |
56
+ | ✗ | `syntax` | a line in either file that isn't `KEY=VALUE` |
57
+
58
+ Errors fail the run; `--strict` makes warnings fail too. Reports contain key names, files and line numbers only. **Values are never printed**, so the output is safe in public CI logs.
59
+
60
+ ## What it understands
61
+
62
+ | Stack | Reads it picks up |
63
+ | --- | --- |
64
+ | **JS / TS** | `process.env.X`, `process.env["X"]`, `import.meta.env.X`, `Bun.env`, `Deno.env.get`, `const { X, Y = 1 } = process.env`, `const env = process.env; env.X` |
65
+ | **env schemas** | zod objects passed to `parse(process.env)`, `@t3-oss/env` `createEnv`, envalid `cleanEnv`, also when a formatter wraps them over several lines; `.default()` / `.optional()` count as fallbacks, `runtimeEnv` doesn't override them |
66
+ | **SvelteKit · Vite** | `import { X } from "$env/static/private"`, `$env/dynamic`, `%VITE_X%` in `index.html` |
67
+ | **ASP.NET Core** | `config["Jwt:Key"]` → `Jwt__Key`, `GetValue<T>()`, `GetConnectionString("Db")` → `ConnectionStrings__Db`; options classes bound with `Configure<JwtOptions>(GetSection("Jwt"))`, `GetSection("Jwt").Get<T>()` or `BindConfiguration("Jwt")` → one key per property, required unless it has a real default; keys with a value in `appsettings.json` don't need a `.env` entry (`appsettings.Development.json` doesn't count, production won't have it); names match case-insensitively, as .NET does |
68
+ | **Python** | `os.getenv`, `os.environ[...]`, `.get` / `.setdefault`, aliases such as `env = dict(os.environ)`; **pydantic-settings** fields with `env_prefix` and `alias` |
69
+ | **Go** | `os.Getenv`, `os.LookupEnv`, struct tags `env:"X"` (caarlos0/env) and `envconfig:"X"` |
70
+ | **PHP / Laravel** | `env("X", default)`, `getenv`, `$_ENV`; framework keys Laravel reads from its own config |
71
+ | **Ruby · Rust** | `ENV["X"]`, `ENV.fetch`; `env::var`, `dotenvy::var`, `env!`, `option_env!` |
72
+ | **Prisma** | `env("DATABASE_URL")` in `schema.prisma` and `prisma.config.ts` |
73
+ | **Docker Compose** | `${X}`, `${X:-default}`, `${X:?error}`, nested `${A:-${B}}`, `$X`; `environment:` entries supply the app with values |
74
+
75
+ ### Variables nobody's code names
76
+
77
+ Some variables are read by a dependency or a container, not by you. envsonar finds the dependency in `package.json`, `pyproject.toml` / `requirements*.txt`, `composer.json`, `*.csproj` or the compose `image:`, and stops calling its variables unused. The run header says what it found: `also read by: Next.js, OpenAI SDK, postgres image`.
78
+
79
+ Covered now: Next.js, Nuxt, Auth.js, Prisma, OpenAI, Anthropic, Google AI, AWS, Google Cloud / Firebase, Sentry, libpq (`PG*`), Vercel Postgres / KV / Blob, Upstash, dotenvx, Django, Laravel, ASP.NET Core, Docker Compose, and the postgres, mysql, mariadb, mongo, redis, rabbitmq, minio, pgadmin, keycloak, clickhouse, elasticsearch, mssql, grafana, mailpit and n8n images. The whole list is one readable file, [`src/profiles.js`](https://github.com/jutaru-dev/envsonar/blob/main/src/profiles.js); adding a stack is a three-line PR.
80
+
81
+ ### What it doesn't guess
82
+
83
+ - **Dynamic reads** such as `process.env[name]` or `os.getenv(key)` can't be resolved statically. envsonar lists them with their locations (`1 dynamic read can't be checked: src/config.ts:12`) instead of silently skipping them.
84
+ - Comments and docstrings are skipped, and so are writes such as `process.env.X = "1"` in a setup file. Tests (`test/`, `__tests__/`, `*.test.ts`, `test_*.py`, `*_test.go`, `*.Tests` projects) aren't scanned: they set and mock variables the app itself doesn't need. `--include-tests` scans them too.
85
+ - It reads source with patterns, not a full parser per language. A read hidden behind your own wrapper (`getConfig("X")`) isn't seen. Add the key to `.env.example`, or skip it with `--ignore-key`.
86
+ - Kubernetes manifests, Terraform and CI workflow files aren't scanned yet.
87
+
88
+ ## In CI
89
+
90
+ As a GitHub Action, no Node setup or install step needed:
91
+
92
+ ```yaml
93
+ # .github/workflows/env.yml
94
+ name: env
95
+ on: [pull_request]
96
+ jobs:
97
+ envsonar:
98
+ runs-on: ubuntu-latest
99
+ steps:
100
+ - uses: actions/checkout@v7
101
+ - uses: jutaru-dev/envsonar@v0
102
+ # with:
103
+ # path: apps/api # project directory, default "."
104
+ # args: --strict # any CLI flags
105
+ ```
106
+
107
+ The action runs the check once and exposes `errors` and `warnings` counts as step outputs. Any other CI, or a pinned npm version:
108
+
109
+ ```yaml
110
+ - run: npx @jutaru-dev/envsonar@0.2.0
111
+ ```
112
+
113
+ On GitHub Actions the findings also become annotations on the lines that caused them: the `STRIPE_SECRET_KEY` error shows up right on `route.ts:3` in the pull request diff. Elsewhere use `--format github` to force it, or `--json` for your own tooling.
114
+
115
+ `.env` is usually not in CI, so only the code ↔ `.env.example` checks run there. To check a committed env file too, pass it: `--env .env.ci`.
116
+
117
+ ## Options
118
+
119
+ | | |
120
+ | --- | --- |
121
+ | `envsonar [dir]` | project to check (default: current directory); for a monorepo, run it per app: `envsonar apps/api` |
122
+ | `--fix` | add undocumented keys to `.env.example`, creating the file if needed |
123
+ | `--optional` | also report (and `--fix`) keys that have a fallback in code |
124
+ | `--list` | print every variable the code reads, bound config sections and dynamic reads |
125
+ | `--example <path>` | default `.env.example` |
126
+ | `--env <path>` | default `.env`; checked only if it exists, unless you pass this flag |
127
+ | `--no-code` | don't scan source, only compare `.env` with `.env.example` |
128
+ | `--ignore <dir>` | skip a directory (repeatable). `node_modules`, build output (`bin`/`obj` next to a `.csproj`), virtualenvs, worktrees and plain dirs from `.gitignore` are skipped already |
129
+ | `--include-tests` | also scan test files and directories |
130
+ | `--ignore-key <KEY>` | skip a key; `PREFIX_*` works (repeatable). OS and CI variables (`PATH`, `CI`, `GITHUB_*`, …) are skipped already |
131
+ | `--strict` | warnings fail the run too |
132
+ | `--json` | machine-readable report |
133
+ | `--format <pretty\|github>` | `github` prints workflow annotations (automatic on GitHub Actions) |
134
+ | `--no-color` | also respects `NO_COLOR` |
135
+
136
+ The same settings can live in `.envsonarrc.json` or under `"envsonar"` in `package.json`:
137
+
138
+ ```json
139
+ {
140
+ "envsonar": {
141
+ "example": "config/.env.example",
142
+ "ignore": ["legacy"],
143
+ "ignoreKeys": ["INTERNAL_*"],
144
+ "includeTests": false,
145
+ "optional": true
146
+ }
147
+ }
148
+ ```
149
+
150
+ **Exit codes:** `0` clean · `1` errors found · `2` bad usage, unreadable file, or no `.env.example` (run `--fix` to create one).
151
+
152
+ ## From code
153
+
154
+ ```js
155
+ import { scanProject, parseEnv, check } from "@jutaru-dev/envsonar";
156
+ import { readFileSync } from "node:fs";
157
+
158
+ const scan = scanProject(".");
159
+ const findings = check({
160
+ example: parseEnv(readFileSync(".env.example", "utf8")),
161
+ exampleFile: ".env.example",
162
+ scan,
163
+ });
164
+ ```
165
+
166
+ `findings` is an array of `{ severity, code, key, file, line, message }`. `scan.usages` maps every key to the places it's read. Type declarations ship with the package.
167
+
168
+ ## Alternatives
169
+
170
+ There are plenty of tools around `.env` files; pick the one that matches the job.
171
+
172
+ - [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter): style and syntax of `.env` files themselves.
173
+ - [envalid](https://github.com/af/envalid), [@t3-oss/env](https://github.com/t3-oss/t3-env): validate variables at runtime. envsonar reads their schemas, so the two work together.
174
+ - [dotenvx](https://github.com/dotenvx/dotenvx): encrypted `.env` files.
175
+ - [envsleuth](https://pypi.org/project/envsleuth), [dotenv-scan](https://dev.to/flyingsquirrel0419/i-got-tired-of-deploying-broken-configs-so-i-built-dotenv-scan-47lb), [env-check](https://github.com/SemTiOne/env-check): also compare code with `.env.example`. envsleuth has SARIF output.
176
+
177
+ envsonar's focus is a mixed-stack repository and few false alarms: framework-specific config reads, implicit consumers, and defaults told apart from required keys.
178
+
179
+ ## Development
180
+
181
+ ```sh
182
+ node --test # the whole suite, no install needed
183
+ npm install && npm run typecheck # types; npm pack / publish build types/ first
184
+ ```
185
+
186
+ ## License
187
+
188
+ MIT © Jutaru
package/bin/envsonar.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  // @ts-check
3
+ import { appendFileSync } from "node:fs";
3
4
  import { run } from "../src/cli.js";
4
5
 
5
6
  process.exitCode = run(process.argv.slice(2), {
@@ -8,4 +9,5 @@ process.exitCode = run(process.argv.slice(2), {
8
9
  cwd: process.cwd(),
9
10
  color: Boolean(process.stdout.isTTY) && !("NO_COLOR" in process.env),
10
11
  githubActions: process.env.GITHUB_ACTIONS === "true",
12
+ githubOutput: process.env.GITHUB_OUTPUT ? (s) => appendFileSync(String(process.env.GITHUB_OUTPUT), s + "\n") : undefined,
11
13
  });
package/package.json CHANGED
@@ -1,46 +1,57 @@
1
- {
2
- "name": "@jutaru-dev/envsonar",
3
- "version": "0.1.0",
4
- "description": "Catches env vars your code reads but .env.example forgot — and knows which ones .NET config, pydantic, Prisma, compose and SDKs read for you. Zero dependencies, never prints a value.",
5
- "type": "module",
6
- "bin": {
7
- "envsonar": "bin/envsonar.js"
8
- },
9
- "exports": {
10
- ".": "./src/index.js"
11
- },
12
- "files": [
13
- "bin",
14
- "src"
15
- ],
16
- "engines": {
17
- "node": ">=20"
18
- },
19
- "scripts": {
20
- "test": "node --test",
21
- "typecheck": "tsc -p jsconfig.json"
22
- },
23
- "keywords": [
24
- "dotenv",
25
- "env",
26
- "env-example",
27
- "environment-variables",
28
- "lint",
29
- "ci",
30
- "github-actions",
31
- "monorepo",
32
- "aspnetcore",
33
- "pydantic-settings",
34
- "prisma",
35
- "docker-compose",
36
- "laravel"
37
- ],
38
- "author": "Jutaru (https://github.com/jutaru-dev)",
39
- "license": "MIT",
40
- "repository": {
41
- "type": "git",
42
- "url": "git+https://github.com/jutaru-dev/envsonar.git"
43
- },
44
- "bugs": "https://github.com/jutaru-dev/envsonar/issues",
45
- "homepage": "https://github.com/jutaru-dev/envsonar#readme"
46
- }
1
+ {
2
+ "name": "@jutaru-dev/envsonar",
3
+ "version": "0.2.0",
4
+ "description": "Catches env vars your code reads but .env.example forgot — and knows which ones .NET config, pydantic, Prisma, compose and SDKs read for you. Zero dependencies, never prints a value.",
5
+ "type": "module",
6
+ "bin": {
7
+ "envsonar": "bin/envsonar.js"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "types": "./types/index.d.ts",
12
+ "default": "./src/index.js"
13
+ }
14
+ },
15
+ "types": "./types/index.d.ts",
16
+ "files": [
17
+ "bin",
18
+ "src",
19
+ "types"
20
+ ],
21
+ "engines": {
22
+ "node": ">=20"
23
+ },
24
+ "scripts": {
25
+ "test": "node --test",
26
+ "typecheck": "tsc -p jsconfig.json",
27
+ "build:types": "tsc -p tsconfig.types.json",
28
+ "prepack": "npm run build:types"
29
+ },
30
+ "keywords": [
31
+ "dotenv",
32
+ "env",
33
+ "env-example",
34
+ "environment-variables",
35
+ "lint",
36
+ "ci",
37
+ "github-actions",
38
+ "monorepo",
39
+ "aspnetcore",
40
+ "pydantic-settings",
41
+ "prisma",
42
+ "docker-compose",
43
+ "laravel"
44
+ ],
45
+ "author": "Jutaru (https://github.com/jutaru-dev)",
46
+ "license": "MIT",
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/jutaru-dev/envsonar.git"
50
+ },
51
+ "bugs": "https://github.com/jutaru-dev/envsonar/issues",
52
+ "homepage": "https://github.com/jutaru-dev/envsonar#readme",
53
+ "devDependencies": {
54
+ "@types/node": "^22.0.0",
55
+ "typescript": "5.9.3"
56
+ }
57
+ }