@e-n-v/env 0.0.5 → 0.0.7

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 (72) hide show
  1. package/dist/{BooleanMap-DmFnCA-O.d.ts → BooleanMap-B7MeMkJC.d.ts} +1 -1
  2. package/dist/{BooleanMap-B2eIP3tZ.d.cts → BooleanMap-D93UJnv5.d.cts} +1 -1
  3. package/dist/{EnvModel-D8rt0EJ6.d.ts → EnvModel-BiT0OiDZ.d.ts} +2 -2
  4. package/dist/{EnvModel-CrGclUpJ.d.cts → EnvModel-I0fWZZ_n.d.cts} +2 -2
  5. package/dist/{StringEnvVarSchema-B8MT7htU.d.ts → StringEnvVarSchema-BwSGgmeG.d.ts} +5 -3
  6. package/dist/{StringEnvVarSchema-BF6C0nyT.d.cts → StringEnvVarSchema-DnsZTIS0.d.cts} +5 -3
  7. package/dist/cli.cjs +3 -3
  8. package/dist/cli.js +3 -3
  9. package/dist/core.cjs +1 -1
  10. package/dist/core.d.cts +4 -4
  11. package/dist/core.d.ts +4 -4
  12. package/dist/core.js +1 -1
  13. package/dist/{index-D8pslhp4.d.cts → index-ClKndmJv.d.ts} +27 -3
  14. package/dist/{index-Dq_0aeAL.d.ts → index-UQm0jdkG.d.cts} +27 -3
  15. package/dist/{root.cjs → index.cjs} +10 -10
  16. package/dist/index.d.cts +21 -0
  17. package/dist/index.d.ts +21 -0
  18. package/dist/index.js +21 -0
  19. package/dist/{model-Dic8IJsf.d.ts → model-BNDYMM9l.d.ts} +1 -1
  20. package/dist/{model-ft0WhSSS.d.cts → model-CJMnbGuS.d.cts} +1 -1
  21. package/dist/model.cjs +2 -2
  22. package/dist/model.d.cts +4 -4
  23. package/dist/model.d.ts +4 -4
  24. package/dist/model.js +2 -2
  25. package/dist/{parse-BT1QSa5e.d.cts → parse-5fpTbjTr.d.cts} +1 -1
  26. package/dist/{parse-DwtLpVhC.d.ts → parse-awxwtQ1N.d.ts} +1 -1
  27. package/dist/parse.cjs +3 -3
  28. package/dist/parse.d.cts +6 -6
  29. package/dist/parse.d.ts +6 -6
  30. package/dist/parse.js +3 -3
  31. package/dist/{prompt-yKdccbtZ.d.ts → prompt-DG8haZjn.d.ts} +1 -1
  32. package/dist/{prompt-C5WudV9x.d.cts → prompt-lmZdPaBh.d.cts} +1 -1
  33. package/dist/prompt.cjs +3 -3
  34. package/dist/prompt.d.cts +4 -4
  35. package/dist/prompt.d.ts +4 -4
  36. package/dist/prompt.js +3 -3
  37. package/dist/{redis-EcC7TX3K.cjs → redis-Cazgs3_J.cjs} +96 -20
  38. package/dist/{redis-CJOpRPjc.js → redis-DXhlNtvD.js} +67 -21
  39. package/dist/{schema-jN4EtvEP.d.ts → schema-CHypJTDK.d.ts} +1 -1
  40. package/dist/{schema-DH4GiW9A.d.cts → schema-DdDa3Qjy.d.cts} +1 -1
  41. package/dist/schemas/zod.cjs +118 -67
  42. package/dist/schemas/zod.d.cts +112 -80
  43. package/dist/schemas/zod.d.ts +112 -80
  44. package/dist/schemas/zod.js +55 -26
  45. package/dist/schemas.cjs +25 -3
  46. package/dist/schemas.d.cts +3 -3
  47. package/dist/schemas.d.ts +3 -3
  48. package/dist/schemas.js +4 -4
  49. package/dist/{src-CLTURaoo.js → src-B5Qu-M-r.js} +10 -2
  50. package/dist/{src-BBwjK5SK.js → src-BrNrE0hX.js} +3 -4
  51. package/dist/{src-Cjo2XA4n.cjs → src-CdqOYilA.cjs} +3 -4
  52. package/dist/{src-Dtv7TlJx.js → src-DI-VW4dW.js} +29 -10
  53. package/dist/{src-CVdUqK3q.js → src-DQaQ28lz.js} +4 -1
  54. package/dist/{src-DZmpNGrQ.cjs → src-DVdOONrX.cjs} +326 -84
  55. package/dist/{src-meUnCASg.cjs → src-DywfI0fM.cjs} +10 -2
  56. package/dist/{src-XjL5cyPG.cjs → src-PHSSk-t3.cjs} +4 -1
  57. package/dist/{src-DWYoqPX1.cjs → src-dO72HN6e.cjs} +31 -10
  58. package/dist/{src-B7FG1rak.js → src-vBXlFkSP.js} +130 -20
  59. package/dist/{validate-CyxrRacF.d.ts → validate-8HbVniNt.d.cts} +3 -2
  60. package/dist/{validate-BxA3a-ns.d.cts → validate-CE8hQ5JG.d.ts} +3 -2
  61. package/dist/{vars-CYOaskkK.cjs → vars-BHXXBiY1.cjs} +1 -1
  62. package/dist/{vars-BNVI6k89.d.ts → vars-DF9DoAF4.d.ts} +2 -2
  63. package/dist/{vars-DOW0LiiN.js → vars-FOuH_HuL.js} +1 -1
  64. package/dist/{vars-CptZRPX5.d.cts → vars-KUgv2rti.d.cts} +2 -2
  65. package/dist/vars.cjs +27 -5
  66. package/dist/vars.d.cts +7 -7
  67. package/dist/vars.d.ts +7 -7
  68. package/dist/vars.js +6 -6
  69. package/package.json +7 -7
  70. package/dist/root.d.cts +0 -21
  71. package/dist/root.d.ts +0 -21
  72. package/dist/root.js +0 -21
@@ -3,11 +3,13 @@ var EnvVarSchemaBase = class {
3
3
  required;
4
4
  default;
5
5
  description;
6
+ link;
6
7
  process;
7
8
  constructor(input) {
8
9
  this.required = input?.required ?? true;
9
10
  this.default = input?.default;
10
11
  this.description = input?.description;
12
+ this.link = input?.link;
11
13
  this.process = input.process;
12
14
  }
13
15
  };
@@ -67,7 +69,12 @@ function string$1(...checks) {
67
69
  */
68
70
  function number$1(...checks) {
69
71
  return (input) => {
70
- if (typeof input !== "string") throw new Error("Value must be a string");
72
+ if (typeof input === "number") {
73
+ if (isNaN(input)) throw new Error("Value is NaN");
74
+ if (checks.length > 0) return validate(input, checks);
75
+ return input;
76
+ }
77
+ if (typeof input !== "string") throw new Error("Value must be a string or number");
71
78
  const trimmed = input.trim();
72
79
  if (trimmed === "") return;
73
80
  const parsed = parseFloat(trimmed);
@@ -105,7 +112,8 @@ function boolean$1() {
105
112
  const trueValues = new Set(TRUE_STRINGS);
106
113
  const falseValues = new Set(FALSE_STRINGS);
107
114
  return (input) => {
108
- if (typeof input !== "string") throw new Error("Value must be a string");
115
+ if (typeof input === "boolean") return input;
116
+ if (typeof input !== "string") throw new Error("Value must be a string or boolean");
109
117
  const trimmed = input.trim().toLowerCase();
110
118
  if (trimmed === "") return;
111
119
  if (trueValues.has(trimmed)) return true;
@@ -1,5 +1,5 @@
1
- import { r as resolvePreprocessor } from "./src-CLTURaoo.js";
2
- import { i as resolveSchemas, n as EnvModel } from "./src-CVdUqK3q.js";
1
+ import { r as resolvePreprocessor } from "./src-B5Qu-M-r.js";
2
+ import { i as resolveSchemas, n as EnvModel } from "./src-DQaQ28lz.js";
3
3
 
4
4
  //#region ../parse/src/errors/EnvParseError.ts
5
5
  /**
@@ -92,9 +92,8 @@ function parse(source, modelOrOptions) {
92
92
  }
93
93
  const preprocessor = resolvePreprocessor(schema$1.type, preprocessConfig);
94
94
  const preprocessedValue = preprocessor ? preprocessor(rawValue) : rawValue;
95
- const stringValue = typeof preprocessedValue === "string" ? preprocessedValue : String(preprocessedValue);
96
95
  try {
97
- const processedValue = schema$1.process(stringValue);
96
+ const processedValue = schema$1.process(preprocessedValue);
98
97
  if (processedValue === void 0) if (schema$1.default !== void 0) result[key] = schema$1.default;
99
98
  else if (schema$1.required) {
100
99
  issues.push({
@@ -1,5 +1,5 @@
1
- const require_src = require('./src-meUnCASg.cjs');
2
- const require_src$1 = require('./src-XjL5cyPG.cjs');
1
+ const require_src = require('./src-DywfI0fM.cjs');
2
+ const require_src$1 = require('./src-PHSSk-t3.cjs');
3
3
 
4
4
  //#region ../parse/src/errors/EnvParseError.ts
5
5
  /**
@@ -92,9 +92,8 @@ function parse(source, modelOrOptions) {
92
92
  }
93
93
  const preprocessor = require_src.resolvePreprocessor(schema$1.type, preprocessConfig);
94
94
  const preprocessedValue = preprocessor ? preprocessor(rawValue) : rawValue;
95
- const stringValue = typeof preprocessedValue === "string" ? preprocessedValue : String(preprocessedValue);
96
95
  try {
97
- const processedValue = schema$1.process(stringValue);
96
+ const processedValue = schema$1.process(preprocessedValue);
98
97
  if (processedValue === void 0) if (schema$1.default !== void 0) result[key] = schema$1.default;
99
98
  else if (schema$1.required) {
100
99
  issues.push({
@@ -1,12 +1,14 @@
1
1
  import { t as __export } from "./chunk-Bp6m_JJh.js";
2
2
  import { t as resolveChannel } from "./resolveChannel-v9BDsw-M.js";
3
- import { i as preprocessors, r as resolvePreprocessor } from "./src-CLTURaoo.js";
4
- import { i as resolveSchemas, n as EnvModel } from "./src-CVdUqK3q.js";
3
+ import { i as preprocessors, r as resolvePreprocessor } from "./src-B5Qu-M-r.js";
4
+ import { i as resolveSchemas, n as EnvModel } from "./src-DQaQ28lz.js";
5
5
  import { dirname, relative, resolve } from "node:path";
6
6
  import { fileURLToPath, pathToFileURL } from "node:url";
7
+ import { platform } from "node:os";
7
8
  import { stdin, stdout } from "node:process";
8
9
  import { Prompt, isCancel } from "@clack/core";
9
10
  import color from "picocolors";
11
+ import { exec } from "node:child_process";
10
12
  import { clearLine, cursorTo, moveCursor } from "node:readline";
11
13
 
12
14
  //#region ../prompt/src/options/defaults.ts
@@ -186,12 +188,14 @@ var Toolbar = class {
186
188
  _isOpen = false;
187
189
  cursor = 0;
188
190
  previous;
191
+ link;
189
192
  theme;
190
193
  actions;
191
194
  secret;
192
195
  constructor(config) {
193
196
  this.previous = config.previous;
194
197
  this.secret = config.secret;
198
+ this.link = config.link;
195
199
  this.theme = config.theme;
196
200
  this.actions = config.actions;
197
201
  }
@@ -288,6 +292,11 @@ var Toolbar = class {
288
292
  label: this.secret === "shown" ? "Hide" : "Show",
289
293
  action: this.actions.toggleSecret
290
294
  });
295
+ if (this.link) options.push({
296
+ key: "openLink",
297
+ label: "Open link",
298
+ action: this.actions.openLink
299
+ });
291
300
  return options;
292
301
  }
293
302
  };
@@ -512,14 +521,14 @@ function processValue(envKey, value, schema, preprocess) {
512
521
  if (typeof preprocess === "function") return preprocess;
513
522
  return resolvePreprocessor(schema.type);
514
523
  })();
515
- const processedValue = activePreprocessor ? activePreprocessor(value) : value;
516
- let stringValue;
517
- if (typeof processedValue === "boolean") stringValue = String(processedValue);
518
- else if (typeof processedValue === "number") stringValue = String(processedValue);
519
- else if (typeof processedValue === "string") stringValue = processedValue;
520
- else stringValue = value;
524
+ let processedValue = value;
525
+ if (activePreprocessor) try {
526
+ processedValue = activePreprocessor(value);
527
+ } catch {
528
+ processedValue = value;
529
+ }
521
530
  return {
522
- value: schema.process(stringValue),
531
+ value: schema.process(processedValue),
523
532
  rawValue: value,
524
533
  isValid: true
525
534
  };
@@ -608,11 +617,13 @@ var EnvPrompt = class extends ThemedPrompt {
608
617
  this.toolbar = new Toolbar({
609
618
  previous: this.index > 0,
610
619
  secret: hasSecret ? this.mode.isSecretRevealed() ? "shown" : "hidden" : false,
620
+ link: this.schema.link,
611
621
  theme: this.theme,
612
622
  actions: {
613
623
  toggleSecret: () => this.handleToggleSecret(),
614
624
  skip: () => this.handleSkip(),
615
- previous: () => this.handlePrevious()
625
+ previous: () => this.handlePrevious(),
626
+ openLink: () => this.handleOpenLink()
616
627
  }
617
628
  });
618
629
  this.on("finalize", () => {
@@ -752,6 +763,14 @@ var EnvPrompt = class extends ThemedPrompt {
752
763
  this.value = void 0;
753
764
  this.state = "submit";
754
765
  }
766
+ handleOpenLink() {
767
+ const link = this.schema.link;
768
+ if (!link) return;
769
+ this.mode.suppressValidation();
770
+ exec(platform() === "win32" ? `start "" "${link}"` : platform() === "darwin" ? `open "${link}"` : `xdg-open "${link}"`, (error) => {
771
+ if (error) console.error(`Failed to open link: ${link}`);
772
+ });
773
+ }
755
774
  consumeSkipValidation() {
756
775
  if (this.mode.state.shouldSkipValidation) {
757
776
  this.mode.restoreValidation();
@@ -1,4 +1,4 @@
1
- import { a as isEnvVarSchema, c as EnumEnvVarSchema, l as BooleanEnvVarSchema, o as StringEnvVarSchema, s as NumberEnvVarSchema } from "./src-CLTURaoo.js";
1
+ import { a as isEnvVarSchema, c as EnumEnvVarSchema, l as BooleanEnvVarSchema, o as StringEnvVarSchema, s as NumberEnvVarSchema } from "./src-B5Qu-M-r.js";
2
2
  import { Qr as safeParse, jn as stringbool, kn as string, n as number } from "./coerce-DNIuYAx4.js";
3
3
 
4
4
  //#region ../converters/src/converters/zod/ZodV3Converter.ts
@@ -119,6 +119,7 @@ function peelV3Schema(schema) {
119
119
  */
120
120
  function createV3ProcessFunction(schema, type) {
121
121
  return (value) => {
122
+ if (typeof value !== "string") throw new Error("Value must be a string");
122
123
  try {
123
124
  let processSchema = schema;
124
125
  if (type === "number") processSchema = number();
@@ -331,6 +332,7 @@ function peelV4Schema(schema) {
331
332
  */
332
333
  function createV4ProcessFunction(schema, type, originalSchema) {
333
334
  return (value) => {
335
+ if (typeof value !== "string") throw new Error("Value must be a string");
334
336
  try {
335
337
  let processSchema = schema;
336
338
  const def = getV4Def(schema);
@@ -500,6 +502,7 @@ function resolveJoiEnvVarType(schema) {
500
502
  */
501
503
  function createJoiProcessFunction(schema, type) {
502
504
  return (value) => {
505
+ if (typeof value !== "string") throw new Error("Value must be a string");
503
506
  try {
504
507
  let processValue = value;
505
508
  if (type === "number") {