You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update contributing guidelines, enhance CLI commands with new env options, and improve error handling in doctor/check commands. Bump package versions to 0.1.2 and add dotenv dependency.
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,15 @@ pnpm test
24
24
3. Add or update tests when behavior or public API changes.
25
25
4. Ensure `pnpm build` and `pnpm test` pass locally.
26
26
27
+
### Pre-release check (maintainers)
28
+
29
+
Before pushing a release or opening the version PR:
30
+
31
+
1.`pnpm install`
32
+
2.`pnpm build` (or `pnpm run build` from repo root)
33
+
3.`pnpm test`
34
+
4. From `packages/cli`, run `pnpm pack` and confirm `package/package.json` in the tarball lists a real semver for `@envra/core` (not `workspace:*`).
35
+
27
36
## Publishing (maintainers)
28
37
29
38
We use [Changesets](https://github.com/changesets/changesets) for versioning and npm releases of `@envra/*`.
@@ -82,6 +91,37 @@ pnpm exec changeset publish
82
91
83
92
Prefer the GitHub Action so versions and git tags stay aligned with changelogs.
84
93
94
+
### Troubleshooting local `changeset publish`
95
+
96
+
**`warn Received 404` for `npm info "@envra/..."`**
97
+
98
+
Often normal: Changesets checks whether the **new** version (e.g. `0.1.1`) is already on the registry; until it is published, that can return 404. Your previous release (e.g. `0.1.0`) can still be live — verify with:
99
+
100
+
```bash
101
+
npm view @envra/core version
102
+
```
103
+
104
+
**`packages failed to publish` with no npm error**
105
+
106
+
Changesets does not always print npm’s stderr. Run one package to see the real code:
107
+
108
+
```bash
109
+
pnpm build
110
+
pnpm --filter @envra/core publish --access public --no-git-checks
111
+
```
112
+
113
+
**`npm error code EOTP` (most common after 0.1.0 works)**
114
+
115
+
Your npm account uses **2FA for publishing**. Non-interactive `changeset publish` cannot prompt for an OTP.
116
+
117
+
-**Quick:** publish with a fresh code from your authenticator:
118
+
`pnpm --filter @envra/core publish --access public --no-git-checks --otp=123456`
119
+
(repeat for other packages in order: core → cli, next, eslint-plugin — or use an Automation token below and run `pnpm exec changeset publish` once.)
120
+
-**Better for repeated CLI publishes:** create an [**Automation**](https://docs.npmjs.com/creating-and-viewing-access-tokens#creating-granular-access-tokens-on-the-website) granular access token (publish-capable, no OTP), then `npm login` or set in user `.npmrc`:
Copy file name to clipboardExpand all lines: README.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,9 +93,17 @@ pnpm envra doctor -c ./env.config.ts
93
93
94
94
Loads TypeScript configs via **jiti** (no separate compile step for the config file). Your app should depend on `@envra/core`; add `@envra/cli` as a dev dependency.
95
95
96
+
Export `defineEnv` as `default` / `env`, or export field builders as `schema`, `environmentFields`, `envraSchema`, or `envFields`.
97
+
98
+
**`check` / `doctor`** merge env in this order: start from `process.env`, then each `--env-file` (repeatable), then optional `--env-dir` loads `<dir>/.env` and `<dir>/.env.<node-env>`. Use `--env-preset nest` to default `--env-dir` to `env` (common Nest layout). `--node-env` overrides the segment for `.env.<name>` (default: `NODE_ENV` or `development`). **`--profile`** is the **schema** profile (requiredIn / onlyIn), not the file name.
99
+
100
+
**`doctor --undeclared`**: `ignore-system` (default, skips noisy OS/npm/editor keys), `all`, or `loaded-only` (only keys that came from loaded files).
101
+
102
+
**`--json`** on `check` / `doctor` prints machine-readable output for CI.
103
+
96
104
| Command | Use case |
97
105
| --------- | --------------------------------- |
98
-
|`check`| CI / preflight — validate `process.env`|
Copy file name to clipboardExpand all lines: packages/cli/README.md
+20-2Lines changed: 20 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# @envra/cli
2
2
3
-
Command-line tools for [envra](https://github.com/hasansmadix/envra): validate `process.env`, generate `.env.example` and `ENVIRONMENT.md`, and run hygiene checks (`doctor`).
3
+
Command-line tools for [envra](https://github.com/hasansmadix/envra): validate env, generate `.env.example` and `ENVIRONMENT.md`, and run hygiene checks (`doctor`).
Export `defineEnv(...)` as `default` or `env`, or export `envraSchema` / `schema` as field builders so the CLI can read the schema.
24
+
Export `defineEnv(...)` as `default` or `env`, or export field builders as `envraSchema`, `schema`, `environmentFields`, or `envFields`.
25
+
26
+
## `check` and `doctor` — env loading
27
+
28
+
-**`--env-file <path>`** — repeatable; each file is parsed with [dotenv](https://github.com/motdotla/dotenv) and merged (later overrides earlier). Starts from `process.env`.
29
+
-**`--env-dir <dir>`** — after `--env-file`, loads `<dir>/.env` then `<dir>/.env.<node-env>` if they exist.
30
+
-**`--node-env <name>`** — segment for `.env.<name>` (default: `NODE_ENV` or `development`).
31
+
-**`--env-preset nest`** — sets default `--env-dir` to `env` (matches many Nest `ConfigModule` layouts).
32
+
33
+
`--profile` / `-p` is the **schema** profile for envra rules (`requiredIn` / `onlyIn`), not the env file name.
34
+
35
+
## `doctor`
36
+
37
+
-**`--undeclared <policy>`** — `ignore-system` (default), `all`, or `loaded-only` (only warn on extra keys that appeared in loaded files).
38
+
-**`--json`** — print structured JSON for CI.
39
+
40
+
## Windows
41
+
42
+
If `envra` fails when run via `node` on Windows, call the entry file directly, e.g. `node node_modules/@envra/cli/dist/cli.js check -c ./env.config.ts`.
'Could not find env schema. Export defineEnv() result as default or named `env`, or export `envraSchema` / `schema` as field builders.',
28
+
'Could not find env schema. Export defineEnv() result as default or named `env`, or export field builders as `envraSchema` / `schema` / `environmentFields` / `envFields`.',
0 commit comments