zod-envkit 1.3.4 → 1.4.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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [1.4.0](https://github.com/nxtxe/zod-envkit/compare/v1.3.5...v1.4.0) (2026-05-19)
2
+
3
+
4
+ ### Features
5
+
6
+ * **cli:** add --production flag scaffold for check command ([01f3a02](https://github.com/nxtxe/zod-envkit/commit/01f3a02cfba0b991e3403968848818d73e570e0b))
7
+
8
+ ## [1.3.5](https://github.com/nxtxe/zod-envkit/compare/v1.3.4...v1.3.5) (2026-05-04)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **cli:** harden 1.3.5 stability checks and release hygiene ([74381b9](https://github.com/nxtxe/zod-envkit/commit/74381b97785a469bf5465d8839702f206acb4c2e))
14
+
1
15
  ## [1.3.4](https://github.com/nxtxe/zod-envkit/compare/v1.3.3...v1.3.4) (2026-04-20)
2
16
 
3
17
 
@@ -196,7 +196,7 @@ var SECRET_PATTERNS = [
196
196
  (k) => k.includes("SESSION"),
197
197
  (k) => k.includes("CREDENTIAL"),
198
198
  (k) => k.includes("CREDS"),
199
- (k) => k.includes("DATABASE_URL") || k === "DB_URL",
199
+ (k) => k.includes("DATABASE_URL") || k === "DB_URL" || k === "POSTGRES_URL" || k === "MYSQL_URL" || k === "DATABASE",
200
200
  (k) => k.includes("CONNECTION_STRING")
201
201
  ];
202
202
  function isSecretKey(key) {
@@ -46,7 +46,10 @@ var messages = {
46
46
  INVALID_FORMAT: "Invalid docs format",
47
47
  INVALID_MASK_MODE: "Invalid mask mode",
48
48
  INVALID_SORT: "Invalid sort mode",
49
+ INVALID_SCHEMA_MODE: "Invalid schema mode",
49
50
  INIT_INPUT_EMPTY: "Input env file is empty or not found:",
51
+ META_EMPTY_TIP_LINE_1: "Add at least one KEY=value line to .env.example,",
52
+ META_EMPTY_TIP_LINE_2: "or create env.meta.json and run: npx zod-envkit generate -c env.meta.json",
50
53
  SCHEMA_LOAD_FAILED: "Failed to load schema file:",
51
54
  SCHEMA_NOT_OBJECT: "Schema file must export a Zod object (z.object(...)).",
52
55
  SCHEMA_VARS_NOT_IN_META: "Schema variables not listed in env.meta.json:",
@@ -70,7 +73,10 @@ var messages = {
70
73
  INVALID_FORMAT: "\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\u0446\u0438\u0438",
71
74
  INVALID_MASK_MODE: "\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0440\u0435\u0436\u0438\u043C \u043C\u0430\u0441\u043A\u0438\u0440\u043E\u0432\u043A\u0438",
72
75
  INVALID_SORT: "\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0440\u0435\u0436\u0438\u043C \u0441\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u043A\u0438",
76
+ INVALID_SCHEMA_MODE: "\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0440\u0435\u0436\u0438\u043C schema",
73
77
  INIT_INPUT_EMPTY: "\u0424\u0430\u0439\u043B \u043E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u044F \u043F\u0443\u0441\u0442 \u0438\u043B\u0438 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D:",
78
+ META_EMPTY_TIP_LINE_1: "\u0414\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u0432 .env.example \u0445\u043E\u0442\u044F \u0431\u044B \u043E\u0434\u043D\u0443 \u0441\u0442\u0440\u043E\u043A\u0443 KEY=value,",
79
+ META_EMPTY_TIP_LINE_2: "\u0438\u043B\u0438 \u0441\u043E\u0437\u0434\u0430\u0439\u0442\u0435 env.meta.json \u0438 \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435: npx zod-envkit generate -c env.meta.json",
74
80
  SCHEMA_LOAD_FAILED: "\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u0430\u0439\u043B \u0441\u0445\u0435\u043C\u044B:",
75
81
  SCHEMA_NOT_OBJECT: "\u0424\u0430\u0439\u043B \u0441\u0445\u0435\u043C\u044B \u0434\u043E\u043B\u0436\u0435\u043D \u044D\u043A\u0441\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C Zod object (z.object(...)).",
76
82
  SCHEMA_VARS_NOT_IN_META: "\u041F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u044B\u0435 \u0441\u0445\u0435\u043C\u044B \u043E\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044E\u0442 \u0432 env.meta.json:",
@@ -183,8 +189,8 @@ function loadMeta(lang, configFile) {
183
189
  `- ${examplePath}`,
184
190
  "",
185
191
  t(lang, "META_TIP"),
186
- " Add at least one KEY=value line to .env.example,",
187
- " or create env.meta.json and run: npx zod-envkit generate -c env.meta.json"
192
+ ` ${t(lang, "META_EMPTY_TIP_LINE_1")}`,
193
+ ` ${t(lang, "META_EMPTY_TIP_LINE_2")}`
188
194
  ]);
189
195
  }
190
196
  console.warn(`\u26A0\uFE0F ${t(lang, "META_FALLBACK_EXAMPLE")}`);
@@ -470,7 +476,7 @@ var SECRET_PATTERNS = [
470
476
  (k) => k.includes("SESSION"),
471
477
  (k) => k.includes("CREDENTIAL"),
472
478
  (k) => k.includes("CREDS"),
473
- (k) => k.includes("DATABASE_URL") || k === "DB_URL",
479
+ (k) => k.includes("DATABASE_URL") || k === "DB_URL" || k === "POSTGRES_URL" || k === "MYSQL_URL" || k === "DATABASE",
474
480
  (k) => k.includes("CONNECTION_STRING")
475
481
  ];
476
482
  function isSecretKey(key) {
@@ -630,6 +636,9 @@ async function loadSchemaFile(filePath, lang) {
630
636
  // src/cli/commands/check.ts
631
637
  function registerCheck(program2, getLang2) {
632
638
  program2.command("check").description("Exit with code 1 if env is invalid (loads dotenv)").option("-c, --config <file>", "Path to env meta json", "env.meta.json").option("--dotenv <list>", "Comma-separated dotenv files (default: .env)", ".env").option("--strict", "Fail if unknown env vars are present (dotenv-only)").option(
639
+ "--production",
640
+ "Production guard: stricter deploy/CI checks (unknown dotenv keys, empty required, placeholders)"
641
+ ).option(
633
642
  "--schema <file>",
634
643
  "Path to JS file exporting Zod object; run schema\u2194meta consistency check"
635
644
  ).option(
@@ -638,6 +647,8 @@ function registerCheck(program2, getLang2) {
638
647
  "strict"
639
648
  ).action(async (opts) => {
640
649
  const lang = getLang2();
650
+ const production = Boolean(opts.production);
651
+ void production;
641
652
  const loaded = loadDotEnv(opts.dotenv);
642
653
  const { meta } = loadMeta(lang, opts.config);
643
654
  const sections = [];
@@ -661,7 +672,7 @@ function registerCheck(program2, getLang2) {
661
672
  if (opts.schema) {
662
673
  const schemaMode = String(opts.schemaMode ?? "strict").toLowerCase();
663
674
  if (schemaMode !== "warn" && schemaMode !== "strict") {
664
- fail(lang, "INVALID_FORMAT", ["--schema-mode must be warn or strict"]);
675
+ fail(lang, "INVALID_SCHEMA_MODE", ["- warn | strict"]);
665
676
  }
666
677
  const { keys: schemaKeys } = await loadSchemaFile(opts.schema, lang);
667
678
  const metaKeys = new Set(Object.keys(meta));
@@ -672,7 +683,7 @@ function registerCheck(program2, getLang2) {
672
683
  const lines = [];
673
684
  if (inSchemaNotMeta.length) {
674
685
  lines.push(`\u274C ${t(lang, "SCHEMA_VARS_NOT_IN_META")}`);
675
- inSchemaNotMeta.forEach((k) => lines.push(`- ${k}`));
686
+ inSchemaNotMeta.sort((a, b) => a.localeCompare(b)).forEach((k) => lines.push(`- ${k}`));
676
687
  lines.push(` ${t(lang, "SCHEMA_HINT_ADD_TO_META")}`);
677
688
  lines.push("");
678
689
  }
package/dist/cli/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  getMissingEnv,
6
6
  getUnknownEnv,
7
7
  isSecretKey
8
- } from "../chunk-J4V5ODI6.js";
8
+ } from "../chunk-WWWQDMV5.js";
9
9
 
10
10
  // src/cli/index.ts
11
11
  import { Command } from "commander";
@@ -30,7 +30,10 @@ var messages = {
30
30
  INVALID_FORMAT: "Invalid docs format",
31
31
  INVALID_MASK_MODE: "Invalid mask mode",
32
32
  INVALID_SORT: "Invalid sort mode",
33
+ INVALID_SCHEMA_MODE: "Invalid schema mode",
33
34
  INIT_INPUT_EMPTY: "Input env file is empty or not found:",
35
+ META_EMPTY_TIP_LINE_1: "Add at least one KEY=value line to .env.example,",
36
+ META_EMPTY_TIP_LINE_2: "or create env.meta.json and run: npx zod-envkit generate -c env.meta.json",
34
37
  SCHEMA_LOAD_FAILED: "Failed to load schema file:",
35
38
  SCHEMA_NOT_OBJECT: "Schema file must export a Zod object (z.object(...)).",
36
39
  SCHEMA_VARS_NOT_IN_META: "Schema variables not listed in env.meta.json:",
@@ -54,7 +57,10 @@ var messages = {
54
57
  INVALID_FORMAT: "\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430\u0446\u0438\u0438",
55
58
  INVALID_MASK_MODE: "\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0440\u0435\u0436\u0438\u043C \u043C\u0430\u0441\u043A\u0438\u0440\u043E\u0432\u043A\u0438",
56
59
  INVALID_SORT: "\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0440\u0435\u0436\u0438\u043C \u0441\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u043A\u0438",
60
+ INVALID_SCHEMA_MODE: "\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0440\u0435\u0436\u0438\u043C schema",
57
61
  INIT_INPUT_EMPTY: "\u0424\u0430\u0439\u043B \u043E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u044F \u043F\u0443\u0441\u0442 \u0438\u043B\u0438 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D:",
62
+ META_EMPTY_TIP_LINE_1: "\u0414\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u0432 .env.example \u0445\u043E\u0442\u044F \u0431\u044B \u043E\u0434\u043D\u0443 \u0441\u0442\u0440\u043E\u043A\u0443 KEY=value,",
63
+ META_EMPTY_TIP_LINE_2: "\u0438\u043B\u0438 \u0441\u043E\u0437\u0434\u0430\u0439\u0442\u0435 env.meta.json \u0438 \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435: npx zod-envkit generate -c env.meta.json",
58
64
  SCHEMA_LOAD_FAILED: "\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u0430\u0439\u043B \u0441\u0445\u0435\u043C\u044B:",
59
65
  SCHEMA_NOT_OBJECT: "\u0424\u0430\u0439\u043B \u0441\u0445\u0435\u043C\u044B \u0434\u043E\u043B\u0436\u0435\u043D \u044D\u043A\u0441\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C Zod object (z.object(...)).",
60
66
  SCHEMA_VARS_NOT_IN_META: "\u041F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u044B\u0435 \u0441\u0445\u0435\u043C\u044B \u043E\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044E\u0442 \u0432 env.meta.json:",
@@ -167,8 +173,8 @@ function loadMeta(lang, configFile) {
167
173
  `- ${examplePath}`,
168
174
  "",
169
175
  t(lang, "META_TIP"),
170
- " Add at least one KEY=value line to .env.example,",
171
- " or create env.meta.json and run: npx zod-envkit generate -c env.meta.json"
176
+ ` ${t(lang, "META_EMPTY_TIP_LINE_1")}`,
177
+ ` ${t(lang, "META_EMPTY_TIP_LINE_2")}`
172
178
  ]);
173
179
  }
174
180
  console.warn(`\u26A0\uFE0F ${t(lang, "META_FALLBACK_EXAMPLE")}`);
@@ -409,6 +415,9 @@ async function loadSchemaFile(filePath, lang) {
409
415
  // src/cli/commands/check.ts
410
416
  function registerCheck(program2, getLang2) {
411
417
  program2.command("check").description("Exit with code 1 if env is invalid (loads dotenv)").option("-c, --config <file>", "Path to env meta json", "env.meta.json").option("--dotenv <list>", "Comma-separated dotenv files (default: .env)", ".env").option("--strict", "Fail if unknown env vars are present (dotenv-only)").option(
418
+ "--production",
419
+ "Production guard: stricter deploy/CI checks (unknown dotenv keys, empty required, placeholders)"
420
+ ).option(
412
421
  "--schema <file>",
413
422
  "Path to JS file exporting Zod object; run schema\u2194meta consistency check"
414
423
  ).option(
@@ -417,6 +426,8 @@ function registerCheck(program2, getLang2) {
417
426
  "strict"
418
427
  ).action(async (opts) => {
419
428
  const lang = getLang2();
429
+ const production = Boolean(opts.production);
430
+ void production;
420
431
  const loaded = loadDotEnv(opts.dotenv);
421
432
  const { meta } = loadMeta(lang, opts.config);
422
433
  const sections = [];
@@ -440,7 +451,7 @@ function registerCheck(program2, getLang2) {
440
451
  if (opts.schema) {
441
452
  const schemaMode = String(opts.schemaMode ?? "strict").toLowerCase();
442
453
  if (schemaMode !== "warn" && schemaMode !== "strict") {
443
- fail(lang, "INVALID_FORMAT", ["--schema-mode must be warn or strict"]);
454
+ fail(lang, "INVALID_SCHEMA_MODE", ["- warn | strict"]);
444
455
  }
445
456
  const { keys: schemaKeys } = await loadSchemaFile(opts.schema, lang);
446
457
  const metaKeys = new Set(Object.keys(meta));
@@ -451,7 +462,7 @@ function registerCheck(program2, getLang2) {
451
462
  const lines = [];
452
463
  if (inSchemaNotMeta.length) {
453
464
  lines.push(`\u274C ${t(lang, "SCHEMA_VARS_NOT_IN_META")}`);
454
- inSchemaNotMeta.forEach((k) => lines.push(`- ${k}`));
465
+ inSchemaNotMeta.sort((a, b) => a.localeCompare(b)).forEach((k) => lines.push(`- ${k}`));
455
466
  lines.push(` ${t(lang, "SCHEMA_HINT_ADD_TO_META")}`);
456
467
  lines.push("");
457
468
  }
package/dist/index.cjs CHANGED
@@ -231,7 +231,7 @@ var SECRET_PATTERNS = [
231
231
  (k) => k.includes("SESSION"),
232
232
  (k) => k.includes("CREDENTIAL"),
233
233
  (k) => k.includes("CREDS"),
234
- (k) => k.includes("DATABASE_URL") || k === "DB_URL",
234
+ (k) => k.includes("DATABASE_URL") || k === "DB_URL" || k === "POSTGRES_URL" || k === "MYSQL_URL" || k === "DATABASE",
235
235
  (k) => k.includes("CONNECTION_STRING")
236
236
  ];
237
237
  function isSecretKey(key) {
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  getUnknownEnv,
7
7
  isSecretKey,
8
8
  sortMetaEntries
9
- } from "./chunk-J4V5ODI6.js";
9
+ } from "./chunk-WWWQDMV5.js";
10
10
 
11
11
  // src/index.ts
12
12
  function loadEnv(schema, opts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod-envkit",
3
- "version": "1.3.4",
3
+ "version": "1.4.0",
4
4
  "description": "Validate environment variables with Zod and generate .env.example",
5
5
  "license": "MIT",
6
6
  "author": "",
@@ -49,8 +49,9 @@
49
49
  "test:preprod:robust": "pnpm build && PREPROD_ITER=30 vitest run tests/test/preprod/30-robustness",
50
50
  "test:before-release": "pnpm build && pnpm test:preprod && pnpm test:preprod:robust",
51
51
  "ci:smoke": "pnpm build && node dist/cli/index.js --help",
52
+ "ci:release-hygiene": "node scripts/validate-release-state.cjs",
52
53
  "ci:docs": "pnpm docs:build",
53
- "ci:all": "pnpm ci:smoke && pnpm test && pnpm ci:docs",
54
+ "ci:all": "pnpm ci:smoke && pnpm test && pnpm ci:release-hygiene && pnpm ci:docs",
54
55
  "prepublishOnly": "pnpm build && pnpm test",
55
56
  "docs:api": "typedoc --tsconfig tsconfig.docs.json --entryPoints src/index.ts",
56
57
  "docs:build": "pnpm docs:api && node scripts/copy-changelog-to-docs.cjs && vitepress build docs",