zenvx 0.2.0 → 0.2.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.
Files changed (52) hide show
  1. package/README.md +55 -17
  2. package/dist/adapters/next.cjs +151 -0
  3. package/dist/adapters/next.d.cts +6 -0
  4. package/dist/adapters/next.d.ts +6 -0
  5. package/dist/adapters/next.js +32 -0
  6. package/dist/adapters/node.cjs +135 -0
  7. package/dist/adapters/node.d.cts +5 -0
  8. package/dist/adapters/node.d.ts +5 -0
  9. package/dist/adapters/node.js +17 -0
  10. package/dist/adapters/vite.cjs +135 -0
  11. package/dist/adapters/vite.d.cts +5 -0
  12. package/dist/adapters/vite.d.ts +5 -0
  13. package/dist/adapters/vite.js +16 -0
  14. package/dist/chunk-3HCQKBTL.js +29 -0
  15. package/dist/chunk-DX3SLVGQ.js +18 -0
  16. package/dist/chunk-E7OYVDFC.js +67 -0
  17. package/dist/chunk-ELPQSMQJ.js +24 -0
  18. package/dist/chunk-KGVPNFG3.js +43 -0
  19. package/dist/chunk-R2XSSP2M.js +24 -0
  20. package/dist/core/define-env.cjs +125 -0
  21. package/dist/core/define-env.d.cts +6 -0
  22. package/dist/core/define-env.d.ts +6 -0
  23. package/dist/core/define-env.js +9 -0
  24. package/dist/core/generate-example.cjs +71 -0
  25. package/dist/core/generate-example.d.cts +5 -0
  26. package/dist/core/generate-example.d.ts +5 -0
  27. package/dist/core/generate-example.js +6 -0
  28. package/dist/core/parser.cjs +53 -0
  29. package/dist/core/parser.d.cts +6 -0
  30. package/dist/core/parser.d.ts +6 -0
  31. package/dist/core/parser.js +6 -0
  32. package/dist/core/proxy.cjs +42 -0
  33. package/dist/core/proxy.d.cts +3 -0
  34. package/dist/core/proxy.d.ts +3 -0
  35. package/dist/core/proxy.js +6 -0
  36. package/dist/core/tx.cjs +91 -0
  37. package/dist/core/tx.d.cts +42 -0
  38. package/dist/core/tx.d.ts +42 -0
  39. package/dist/core/tx.js +6 -0
  40. package/dist/core/types.cjs +18 -0
  41. package/dist/core/types.d.cts +8 -0
  42. package/dist/core/types.d.ts +8 -0
  43. package/dist/core/types.js +0 -0
  44. package/dist/index.cjs +4 -24
  45. package/dist/index.d.cts +4 -51
  46. package/dist/index.d.ts +4 -51
  47. package/dist/index.js +8 -176
  48. package/dist/types/vite-env.d.cjs +1 -0
  49. package/dist/types/vite-env.d.d.cts +2 -0
  50. package/dist/types/vite-env.d.d.ts +2 -0
  51. package/dist/types/vite-env.d.js +0 -0
  52. package/package.json +18 -6
@@ -0,0 +1,42 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const tx: {
4
+ /**
5
+ * STRICT STRING:
6
+ * Rejects purely numeric strings (e.g. "12345").
7
+ * Good for API Keys.
8
+ */
9
+ string: (message?: string) => z.ZodString;
10
+ /**
11
+ * SMART NUMBER:
12
+ * Automatically converts "3000" -> 3000.
13
+ * Fails if the value is not a valid number (e.g. "abc").
14
+ */
15
+ number: (message?: string) => z.ZodCoercedNumber<unknown>;
16
+ /**
17
+ * PORT VALIDATOR:
18
+ * Coerces to number and ensures it is between 1 and 65535.
19
+ */
20
+ port: (message?: string) => z.ZodCoercedNumber<unknown>;
21
+ /**
22
+ * SMART BOOLEAN:
23
+ * Handles "true", "TRUE", "1" -> true
24
+ * Handles "false", "FALSE", "0" -> false
25
+ * Throws error on anything else.
26
+ */
27
+ bool: (message?: string) => z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>, z.ZodTransform<boolean, string | boolean>>;
28
+ /**
29
+ * URL:
30
+ * Strict URL checking.
31
+ */
32
+ url: (message?: string) => z.ZodURL;
33
+ email: (message?: string) => z.ZodEmail;
34
+ positiveNumber: (message?: string) => z.ZodCoercedNumber<unknown>;
35
+ nonEmptyString: (message?: string) => z.ZodString;
36
+ semver: (message?: string) => z.ZodString;
37
+ path: (message?: string) => z.ZodString;
38
+ enum: <T extends readonly [string, ...string[]]>(values: T, message?: string) => z.ZodEnum<{ [k_1 in T[number]]: k_1; } extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never>;
39
+ json: <T = unknown>(message?: string) => z.ZodPipe<z.ZodString, z.ZodTransform<Awaited<T>, string>>;
40
+ };
41
+
42
+ export { tx };
@@ -0,0 +1,42 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const tx: {
4
+ /**
5
+ * STRICT STRING:
6
+ * Rejects purely numeric strings (e.g. "12345").
7
+ * Good for API Keys.
8
+ */
9
+ string: (message?: string) => z.ZodString;
10
+ /**
11
+ * SMART NUMBER:
12
+ * Automatically converts "3000" -> 3000.
13
+ * Fails if the value is not a valid number (e.g. "abc").
14
+ */
15
+ number: (message?: string) => z.ZodCoercedNumber<unknown>;
16
+ /**
17
+ * PORT VALIDATOR:
18
+ * Coerces to number and ensures it is between 1 and 65535.
19
+ */
20
+ port: (message?: string) => z.ZodCoercedNumber<unknown>;
21
+ /**
22
+ * SMART BOOLEAN:
23
+ * Handles "true", "TRUE", "1" -> true
24
+ * Handles "false", "FALSE", "0" -> false
25
+ * Throws error on anything else.
26
+ */
27
+ bool: (message?: string) => z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>, z.ZodTransform<boolean, string | boolean>>;
28
+ /**
29
+ * URL:
30
+ * Strict URL checking.
31
+ */
32
+ url: (message?: string) => z.ZodURL;
33
+ email: (message?: string) => z.ZodEmail;
34
+ positiveNumber: (message?: string) => z.ZodCoercedNumber<unknown>;
35
+ nonEmptyString: (message?: string) => z.ZodString;
36
+ semver: (message?: string) => z.ZodString;
37
+ path: (message?: string) => z.ZodString;
38
+ enum: <T extends readonly [string, ...string[]]>(values: T, message?: string) => z.ZodEnum<{ [k_1 in T[number]]: k_1; } extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never>;
39
+ json: <T = unknown>(message?: string) => z.ZodPipe<z.ZodString, z.ZodTransform<Awaited<T>, string>>;
40
+ };
41
+
42
+ export { tx };
@@ -0,0 +1,6 @@
1
+ import {
2
+ tx
3
+ } from "../chunk-E7OYVDFC.js";
4
+ export {
5
+ tx
6
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/core/types.ts
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,8 @@
1
+ type ValidationMode = "runtime" | "build";
2
+ interface DefineEnvOptions {
3
+ path?: string;
4
+ mode?: ValidationMode;
5
+ generateExample?: boolean;
6
+ }
7
+
8
+ export type { DefineEnvOptions, ValidationMode };
@@ -0,0 +1,8 @@
1
+ type ValidationMode = "runtime" | "build";
2
+ interface DefineEnvOptions {
3
+ path?: string;
4
+ mode?: ValidationMode;
5
+ generateExample?: boolean;
6
+ }
7
+
8
+ export type { DefineEnvOptions, ValidationMode };
File without changes
package/dist/index.cjs CHANGED
@@ -102,23 +102,6 @@ var tx = {
102
102
  // src/core/define-env.ts
103
103
  var import_zod4 = require("zod");
104
104
 
105
- // src/loaders/dotenv.ts
106
- var import_dotenv = __toESM(require("dotenv"), 1);
107
- var import_fs = __toESM(require("fs"), 1);
108
- function loadDotEnv(path = ".env") {
109
- if (!import_fs.default.existsSync(path)) {
110
- throw new Error(
111
- `[envx] .env file not found at path "${path}"
112
- Tip: Set { dotenv: false } if you manage environment variables yourself.`
113
- );
114
- }
115
- const result = import_dotenv.default.config({ path });
116
- if (result.error) {
117
- throw result.error;
118
- }
119
- return result.parsed ?? {};
120
- }
121
-
122
105
  // src/core/parser.ts
123
106
  var import_zod2 = require("zod");
124
107
  function parseEnv(schema, source, mode = "runtime") {
@@ -162,7 +145,7 @@ function createTypedProxy(obj) {
162
145
 
163
146
  // src/core/generate-example.ts
164
147
  var import_zod3 = require("zod");
165
- var import_fs2 = __toESM(require("fs"), 1);
148
+ var import_fs = __toESM(require("fs"), 1);
166
149
  function getZodTypeName(schema) {
167
150
  let type = "unknown";
168
151
  if (schema instanceof import_zod3.ZodString) type = "string";
@@ -190,17 +173,14 @@ function generateExample(schema, path = ".env.example") {
190
173
  return `${key}=${placeholder ?? ""} # ${othertype ?? type}`;
191
174
  });
192
175
  const content = [...header, ...lines].join("\n") + "\n";
193
- import_fs2.default.writeFileSync(path, content);
194
- console.log(content);
176
+ import_fs.default.writeFileSync(path, content);
195
177
  console.log(`\u2705 .env.example generated at ${path}`);
196
178
  }
197
179
 
198
180
  // src/core/define-env.ts
199
- function defineEnv(shape, options) {
200
- const fileEnv = loadDotEnv(options?.path);
201
- const merged = { ...fileEnv, ...process.env };
181
+ function defineEnv(shape, source, options) {
202
182
  const schema = import_zod4.z.object(shape);
203
- const parsed = parseEnv(schema, merged, options?.mode ?? "runtime");
183
+ const parsed = parseEnv(schema, source, options?.mode ?? "runtime");
204
184
  if (options?.generateExample) {
205
185
  generateExample(schema);
206
186
  }
package/dist/index.d.cts CHANGED
@@ -1,51 +1,4 @@
1
- import { z } from 'zod';
2
-
3
- declare const tx: {
4
- /**
5
- * STRICT STRING:
6
- * Rejects purely numeric strings (e.g. "12345").
7
- * Good for API Keys.
8
- */
9
- string: (message?: string) => z.ZodString;
10
- /**
11
- * SMART NUMBER:
12
- * Automatically converts "3000" -> 3000.
13
- * Fails if the value is not a valid number (e.g. "abc").
14
- */
15
- number: (message?: string) => z.ZodCoercedNumber<unknown>;
16
- /**
17
- * PORT VALIDATOR:
18
- * Coerces to number and ensures it is between 1 and 65535.
19
- */
20
- port: (message?: string) => z.ZodCoercedNumber<unknown>;
21
- /**
22
- * SMART BOOLEAN:
23
- * Handles "true", "TRUE", "1" -> true
24
- * Handles "false", "FALSE", "0" -> false
25
- * Throws error on anything else.
26
- */
27
- bool: (message?: string) => z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>, z.ZodTransform<boolean, string | boolean>>;
28
- /**
29
- * URL:
30
- * Strict URL checking.
31
- */
32
- url: (message?: string) => z.ZodURL;
33
- email: (message?: string) => z.ZodEmail;
34
- positiveNumber: (message?: string) => z.ZodCoercedNumber<unknown>;
35
- nonEmptyString: (message?: string) => z.ZodString;
36
- semver: (message?: string) => z.ZodString;
37
- path: (message?: string) => z.ZodString;
38
- enum: <T extends readonly [string, ...string[]]>(values: T, message?: string) => z.ZodEnum<{ [k_1 in T[number]]: k_1; } extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never>;
39
- json: <T = unknown>(message?: string) => z.ZodPipe<z.ZodString, z.ZodTransform<Awaited<T>, string>>;
40
- };
41
-
42
- type ValidationMode = "runtime" | "build";
43
- interface DefineEnvOptions {
44
- path?: string;
45
- mode?: ValidationMode;
46
- generateExample?: boolean;
47
- }
48
-
49
- declare function defineEnv<T extends z.ZodRawShape>(shape: T, options?: DefineEnvOptions): { [K in keyof T]: z.core.output<T[K]>; };
50
-
51
- export { type DefineEnvOptions, defineEnv, tx };
1
+ export { tx } from './core/tx.cjs';
2
+ export { defineEnv } from './core/define-env.cjs';
3
+ export { DefineEnvOptions } from './core/types.cjs';
4
+ import 'zod';
package/dist/index.d.ts CHANGED
@@ -1,51 +1,4 @@
1
- import { z } from 'zod';
2
-
3
- declare const tx: {
4
- /**
5
- * STRICT STRING:
6
- * Rejects purely numeric strings (e.g. "12345").
7
- * Good for API Keys.
8
- */
9
- string: (message?: string) => z.ZodString;
10
- /**
11
- * SMART NUMBER:
12
- * Automatically converts "3000" -> 3000.
13
- * Fails if the value is not a valid number (e.g. "abc").
14
- */
15
- number: (message?: string) => z.ZodCoercedNumber<unknown>;
16
- /**
17
- * PORT VALIDATOR:
18
- * Coerces to number and ensures it is between 1 and 65535.
19
- */
20
- port: (message?: string) => z.ZodCoercedNumber<unknown>;
21
- /**
22
- * SMART BOOLEAN:
23
- * Handles "true", "TRUE", "1" -> true
24
- * Handles "false", "FALSE", "0" -> false
25
- * Throws error on anything else.
26
- */
27
- bool: (message?: string) => z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>, z.ZodTransform<boolean, string | boolean>>;
28
- /**
29
- * URL:
30
- * Strict URL checking.
31
- */
32
- url: (message?: string) => z.ZodURL;
33
- email: (message?: string) => z.ZodEmail;
34
- positiveNumber: (message?: string) => z.ZodCoercedNumber<unknown>;
35
- nonEmptyString: (message?: string) => z.ZodString;
36
- semver: (message?: string) => z.ZodString;
37
- path: (message?: string) => z.ZodString;
38
- enum: <T extends readonly [string, ...string[]]>(values: T, message?: string) => z.ZodEnum<{ [k_1 in T[number]]: k_1; } extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never>;
39
- json: <T = unknown>(message?: string) => z.ZodPipe<z.ZodString, z.ZodTransform<Awaited<T>, string>>;
40
- };
41
-
42
- type ValidationMode = "runtime" | "build";
43
- interface DefineEnvOptions {
44
- path?: string;
45
- mode?: ValidationMode;
46
- generateExample?: boolean;
47
- }
48
-
49
- declare function defineEnv<T extends z.ZodRawShape>(shape: T, options?: DefineEnvOptions): { [K in keyof T]: z.core.output<T[K]>; };
50
-
51
- export { type DefineEnvOptions, defineEnv, tx };
1
+ export { tx } from './core/tx.js';
2
+ export { defineEnv } from './core/define-env.js';
3
+ export { DefineEnvOptions } from './core/types.js';
4
+ import 'zod';
package/dist/index.js CHANGED
@@ -1,180 +1,12 @@
1
- // src/core/tx.ts
2
- import { z } from "zod";
3
- var SEMVER_REGEX = /^\d+\.\d+\.\d+(-[0-9A-Za-z-.]+)?$/;
4
- var tx = {
5
- /**
6
- * STRICT STRING:
7
- * Rejects purely numeric strings (e.g. "12345").
8
- * Good for API Keys.
9
- */
10
- string: (message = "Value should be text, but looks like a number.") => z.string().trim().regex(/^(?!\d+$).+$/, { error: message }).describe("Non-numeric string"),
11
- /**
12
- * SMART NUMBER:
13
- * Automatically converts "3000" -> 3000.
14
- * Fails if the value is not a valid number (e.g. "abc").
15
- */
16
- number: (message = "Must be a number") => z.coerce.number({ error: message }).finite().describe("Numeric value"),
17
- /**
18
- * PORT VALIDATOR:
19
- * Coerces to number and ensures it is between 1 and 65535.
20
- */
21
- port: (message = "Must be a valid port (1\u201365535)") => z.coerce.number({ error: message }).int().min(1).max(65535).describe("TCP/UDP port number (1\u201365535)"),
22
- /**
23
- * SMART BOOLEAN:
24
- * Handles "true", "TRUE", "1" -> true
25
- * Handles "false", "FALSE", "0" -> false
26
- * Throws error on anything else.
27
- */
28
- bool: (message) => {
29
- return z.union([z.string(), z.boolean()]).transform((val, ctx) => {
30
- if (typeof val === "boolean") return val;
31
- const v = val.toLowerCase();
32
- if (v === "true" || v === "1") return true;
33
- if (v === "false" || v === "0") return false;
34
- ctx.addIssue({
35
- code: z.ZodIssueCode.custom,
36
- message: message || 'Must be a boolean ("true"/"false"/"1"/"0")'
37
- });
38
- return z.NEVER;
39
- });
40
- },
41
- /**
42
- * URL:
43
- * Strict URL checking.
44
- */
45
- url: (message = "Must be a valid URL (e.g. https://...)") => z.url({ error: message }).describe("A valid URL including protocol"),
46
- email: (message = "Must be a valid email address") => z.email({ error: message }).describe("A valid email address"),
47
- positiveNumber: (message = "Must be > 0") => z.coerce.number().gt(0, { error: message }).describe("A positive number"),
48
- nonEmptyString: (message = "Cannot be empty") => z.string().trim().min(1, { error: message }).describe("A non-empty string"),
49
- semver: (message = "Must be valid semver") => z.string().regex(SEMVER_REGEX, { error: message }).describe("Semantic version (x.y.z)"),
50
- path: (message = "Must be a valid path") => z.string().trim().min(1, { error: message }).describe("Filesystem path"),
51
- enum: (values, message = `Must be one of: ${values.join(", ")}`) => z.enum(values, { error: message }).describe(`One of: ${values.join(", ")}`),
52
- json: (message = "Must be valid JSON") => z.string().transform((val, ctx) => {
53
- try {
54
- return JSON.parse(val);
55
- } catch {
56
- ctx.addIssue({
57
- code: "custom",
58
- error: message
59
- });
60
- return z.NEVER;
61
- }
62
- }).describe("JSON-encoded value")
63
- };
64
-
65
- // src/core/define-env.ts
66
- import { z as z3 } from "zod";
67
-
68
- // src/loaders/dotenv.ts
69
- import dotenv from "dotenv";
70
- import fs from "fs";
71
- function loadDotEnv(path = ".env") {
72
- if (!fs.existsSync(path)) {
73
- throw new Error(
74
- `[envx] .env file not found at path "${path}"
75
- Tip: Set { dotenv: false } if you manage environment variables yourself.`
76
- );
77
- }
78
- const result = dotenv.config({ path });
79
- if (result.error) {
80
- throw result.error;
81
- }
82
- return result.parsed ?? {};
83
- }
84
-
85
- // src/core/parser.ts
86
- import "zod";
87
- function parseEnv(schema, source, mode = "runtime") {
88
- const result = schema.safeParse(source);
89
- if (!result.success) {
90
- const issues = result.error.issues.map((i) => `\u274C ${i.path.join(".")}: ${i.message}`).join("\n");
91
- const header = mode === "build" ? [
92
- "\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510",
93
- "\u2502 \u274C INVALID ENVIRONMENT VARIABLES DETECTED \u2502",
94
- "\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"
95
- ] : [
96
- "\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510",
97
- "\u2502 \u26A0 WARNING INVALID ENVIRONMENT VARIABLES \u26A0 \u2502",
98
- "\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"
99
- ];
100
- const box = ["", ...header, issues, ""].join("\n");
101
- if (mode === "build") {
102
- throw new Error(box);
103
- } else {
104
- console.warn(box);
105
- process.exit(1);
106
- }
107
- }
108
- return result.success ? result.data : {};
109
- }
110
-
111
- // src/core/proxy.ts
112
- function createTypedProxy(obj) {
113
- return new Proxy(obj, {
114
- get(target, prop) {
115
- if (!(prop in target)) {
116
- console.error(
117
- `\u274C Tried to access undefined environment variable "${prop}"`
118
- );
119
- process.exit(1);
120
- }
121
- return target[prop];
122
- }
123
- });
124
- }
125
-
126
- // src/core/generate-example.ts
127
1
  import {
128
- ZodDefault,
129
- ZodOptional,
130
- ZodString,
131
- ZodNumber,
132
- ZodBoolean
133
- } from "zod";
134
- import fs2 from "fs";
135
- function getZodTypeName(schema) {
136
- let type = "unknown";
137
- if (schema instanceof ZodString) type = "string";
138
- else if (schema instanceof ZodNumber) type = "number";
139
- else if (schema instanceof ZodBoolean) type = "boolean";
140
- return type;
141
- }
142
- function generateExample(schema, path = ".env.example") {
143
- const header = [
144
- "# Example environment variables",
145
- "# Copy this file to .env and fill in the values",
146
- ""
147
- ];
148
- const lines = Object.entries(schema.shape).map(([key, zodSchema]) => {
149
- let placeholder = "";
150
- let othertype = null;
151
- let actualSchema = zodSchema;
152
- if (zodSchema instanceof ZodOptional) actualSchema = zodSchema.unwrap();
153
- if (zodSchema instanceof ZodDefault) {
154
- actualSchema = zodSchema.def.innerType;
155
- placeholder = zodSchema.def.defaultValue ?? "";
156
- othertype = typeof zodSchema.def.defaultValue;
157
- }
158
- const type = getZodTypeName(actualSchema);
159
- return `${key}=${placeholder ?? ""} # ${othertype ?? type}`;
160
- });
161
- const content = [...header, ...lines].join("\n") + "\n";
162
- fs2.writeFileSync(path, content);
163
- console.log(content);
164
- console.log(`\u2705 .env.example generated at ${path}`);
165
- }
166
-
167
- // src/core/define-env.ts
168
- function defineEnv(shape, options) {
169
- const fileEnv = loadDotEnv(options?.path);
170
- const merged = { ...fileEnv, ...process.env };
171
- const schema = z3.object(shape);
172
- const parsed = parseEnv(schema, merged, options?.mode ?? "runtime");
173
- if (options?.generateExample) {
174
- generateExample(schema);
175
- }
176
- return createTypedProxy(parsed);
177
- }
2
+ tx
3
+ } from "./chunk-E7OYVDFC.js";
4
+ import {
5
+ defineEnv
6
+ } from "./chunk-ELPQSMQJ.js";
7
+ import "./chunk-KGVPNFG3.js";
8
+ import "./chunk-3HCQKBTL.js";
9
+ import "./chunk-DX3SLVGQ.js";
178
10
  export {
179
11
  defineEnv,
180
12
  tx
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zenvx",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -30,13 +30,28 @@
30
30
  "import": "./dist/index.js",
31
31
  "require": "./dist/index.cjs",
32
32
  "types": "./dist/index.d.ts"
33
+ },
34
+ "./node": {
35
+ "import": "./dist/adapters/node.js",
36
+ "require": "./dist/adapters/node.cjs",
37
+ "types": "./dist/adapters/node.d.ts"
38
+ },
39
+ "./vite": {
40
+ "import": "./dist/adapters/vite.js",
41
+ "require": "./dist/adapters/vite.cjs",
42
+ "types": "./dist/adapters/vite.d.ts"
43
+ },
44
+ "./next": {
45
+ "import": "./dist/adapters/next.js",
46
+ "require": "./dist/adapters/next.cjs",
47
+ "types": "./dist/adapters/next.d.ts"
33
48
  }
34
49
  },
35
50
  "files": [
36
51
  "dist"
37
52
  ],
38
53
  "scripts": {
39
- "build": "tsup src/index.ts --format esm,cjs --dts --external zod,dotenv",
54
+ "build": "tsup src --format esm,cjs --dts --external zod,dotenv",
40
55
  "dev": "tsup src/index.ts --watch --external zod,dotenv",
41
56
  "lint": "eslint .",
42
57
  "lint:fix": "eslint . --fix",
@@ -47,16 +62,13 @@
47
62
  "peerDependencies": {
48
63
  "zod": "^4.3.5"
49
64
  },
50
- "dependencies": {
51
- "dotenv": "^16.4.7"
52
- },
53
65
  "peerDependenciesMeta": {
54
66
  "zod": {
55
67
  "optional": true
56
68
  }
57
69
  },
58
70
  "devDependencies": {
59
- "@types/node": "^25.0.9",
71
+ "@types/node": "^25.1.0",
60
72
  "@typescript-eslint/eslint-plugin": "^8.53.1",
61
73
  "@typescript-eslint/parser": "^8.53.1",
62
74
  "dotenv": "^17.2.3",