arkenv 0.6.0 → 0.7.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
@@ -12,7 +12,7 @@
12
12
  <a href="https://nodejs.org/en"><img alt="Node.js" src="https://img.shields.io/badge/Node.js-339933?style=flat&logo=node.js&logoColor=white"></a>
13
13
  <a href="https://bun.com/"><img alt="Bun" src="https://img.shields.io/badge/Bun-14151a?logo=bun&logoColor=fbf0df"></a>
14
14
  <a href="https://vite.dev/"><img alt="Vite" src="https://custom-icon-badges.demolab.com/badge/Vite-2e2742?logo=vite2&logoColor=dfdfd6"></a>
15
- <a href="https://github.com/yamcodes/arkenv"><img alt="GitHub Repo stars" src="https://custom-icon-badges.demolab.com/github/stars/yamcodes/arkenv?logo=star&logoColor=373737&label=Star%20us!"></a>
15
+ <a href="https://github.com/yamcodes/arkenv"><img alt="GitHub Repo stars" src="https://custom-icon-badges.demolab.com/github/stars/yamcodes/arkenv?logo=star&logoColor=373737&label=Star%20us!&"></a>
16
16
  </p>
17
17
 
18
18
  ## Requirements
@@ -84,7 +84,7 @@ You can find more examples in the [examples](https://github.com/yamcodes/arkenv/
84
84
  - 🔒 **Typesafe**: Full TypeScript support with inferred types
85
85
  - 🚀 **Runtime validation**: Catch missing or invalid environment variables early
86
86
  - 💪 **Powered by ArkType**: Leverage ArkType's powerful type system
87
- - 🪶 **Lightweight**: Only a single dependency ([see size](https://bundlephobia.com/package/arkenv))
87
+ - 🪶 **Lightweight**: Zero dependencies, [tiny bundle size](https://bundlephobia.com/package/arkenv)
88
88
  - ⚡ **Fast**: Optimized for performance with minimal overhead
89
89
 
90
90
  ## Documentation
package/dist/index.cjs CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,21 +15,13 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/index.ts
31
21
  var index_exports = {};
32
22
  __export(index_exports, {
33
23
  createEnv: () => createEnv,
34
- default: () => createEnv,
24
+ default: () => index_default,
35
25
  type: () => type4
36
26
  });
37
27
  module.exports = __toCommonJS(index_exports);
@@ -40,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
40
30
  var import_arktype3 = require("arktype");
41
31
 
42
32
  // src/errors.ts
43
- var import_chalk = __toESM(require("chalk"), 1);
33
+ var import_node_util = require("util");
44
34
 
45
35
  // src/utils.ts
46
36
  var indent = (str, amt = 2, { dontDetectNewlines = false } = {}) => {
@@ -57,13 +47,13 @@ var formatErrors = (errors) => Object.entries(errors.byPath).map(([path, error])
57
47
  const valueMatch = messageWithoutPath.match(/\(was "([^"]+)"\)/);
58
48
  const formattedMessage = valueMatch ? messageWithoutPath.replace(
59
49
  `(was "${valueMatch[1]}")`,
60
- `(was ${import_chalk.default.cyan(`"${valueMatch[1]}"`)})`
50
+ `(was ${(0, import_node_util.styleText)("cyan", `"${valueMatch[1]}"`)})`
61
51
  ) : messageWithoutPath;
62
- return `${import_chalk.default.yellow(path)}${formattedMessage}`;
52
+ return `${(0, import_node_util.styleText)("yellow", path)}${formattedMessage}`;
63
53
  }).join("\n");
64
54
  var ArkEnvError = class extends Error {
65
55
  constructor(errors, message = "Errors found while validating environment variables") {
66
- super(`${import_chalk.default.red(message)}
56
+ super(`${(0, import_node_util.styleText)("red", message)}
67
57
  ${indent(formatErrors(errors))}
68
58
  `);
69
59
  this.name = "ArkEnvError";
@@ -110,6 +100,10 @@ function createEnv(def, env = process.env) {
110
100
 
111
101
  // src/type.ts
112
102
  var type4 = $.type;
103
+
104
+ // src/index.ts
105
+ var arkenv = createEnv;
106
+ var index_default = arkenv;
113
107
  // Annotate the CommonJS export names for ESM import in node:
114
108
  0 && (module.exports = {
115
109
  createEnv,
package/dist/index.d.cts CHANGED
@@ -80,7 +80,7 @@ declare const $: arktype.Scope<{
80
80
  }>;
81
81
 
82
82
  type RuntimeEnvironment = Record<string, string | undefined>;
83
- type EnvSchema<def, $ = {}> = type$1.validate<def, $>;
83
+ type EnvSchema<def> = type$1.validate<def, (typeof $)["t"]>;
84
84
  /**
85
85
  * Create an environment variables object from a schema and an environment
86
86
  * @param def - The environment variable schema
@@ -88,8 +88,7 @@ type EnvSchema<def, $ = {}> = type$1.validate<def, $>;
88
88
  * @returns The validated environment variable schema
89
89
  * @throws An error if the environment variables are invalid. See {@link ArkEnvError}
90
90
  */
91
- declare function createEnv<const T extends Record<string, string | undefined>>(def: EnvSchema<T, (typeof $)["t"]>, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>>;
92
- declare function createEnv<const T extends Record<string, string | undefined>>(def: EnvSchema<T>, env?: RuntimeEnvironment): distill.Out<type$1.infer<T>>;
91
+ declare function createEnv<const T extends Record<string, string | undefined>>(def: EnvSchema<T>, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>>;
93
92
 
94
93
  declare const type: arktype_internal_type_ts.TypeParser<{
95
94
  string: arktype.Submodule<{
@@ -163,4 +162,6 @@ declare const type: arktype_internal_type_ts.TypeParser<{
163
162
  }>;
164
163
  }>;
165
164
 
166
- export { type EnvSchema, createEnv, createEnv as default, type };
165
+ declare const arkenv: typeof createEnv;
166
+
167
+ export { type EnvSchema, createEnv, arkenv as default, type };
package/dist/index.d.ts CHANGED
@@ -80,7 +80,7 @@ declare const $: arktype.Scope<{
80
80
  }>;
81
81
 
82
82
  type RuntimeEnvironment = Record<string, string | undefined>;
83
- type EnvSchema<def, $ = {}> = type$1.validate<def, $>;
83
+ type EnvSchema<def> = type$1.validate<def, (typeof $)["t"]>;
84
84
  /**
85
85
  * Create an environment variables object from a schema and an environment
86
86
  * @param def - The environment variable schema
@@ -88,8 +88,7 @@ type EnvSchema<def, $ = {}> = type$1.validate<def, $>;
88
88
  * @returns The validated environment variable schema
89
89
  * @throws An error if the environment variables are invalid. See {@link ArkEnvError}
90
90
  */
91
- declare function createEnv<const T extends Record<string, string | undefined>>(def: EnvSchema<T, (typeof $)["t"]>, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>>;
92
- declare function createEnv<const T extends Record<string, string | undefined>>(def: EnvSchema<T>, env?: RuntimeEnvironment): distill.Out<type$1.infer<T>>;
91
+ declare function createEnv<const T extends Record<string, string | undefined>>(def: EnvSchema<T>, env?: RuntimeEnvironment): distill.Out<type$1.infer<T, (typeof $)["t"]>>;
93
92
 
94
93
  declare const type: arktype_internal_type_ts.TypeParser<{
95
94
  string: arktype.Submodule<{
@@ -163,4 +162,6 @@ declare const type: arktype_internal_type_ts.TypeParser<{
163
162
  }>;
164
163
  }>;
165
164
 
166
- export { type EnvSchema, createEnv, createEnv as default, type };
165
+ declare const arkenv: typeof createEnv;
166
+
167
+ export { type EnvSchema, createEnv, arkenv as default, type };
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { type as type3 } from "arktype";
3
3
 
4
4
  // src/errors.ts
5
- import chalk from "chalk";
5
+ import { styleText } from "util";
6
6
 
7
7
  // src/utils.ts
8
8
  var indent = (str, amt = 2, { dontDetectNewlines = false } = {}) => {
@@ -19,13 +19,13 @@ var formatErrors = (errors) => Object.entries(errors.byPath).map(([path, error])
19
19
  const valueMatch = messageWithoutPath.match(/\(was "([^"]+)"\)/);
20
20
  const formattedMessage = valueMatch ? messageWithoutPath.replace(
21
21
  `(was "${valueMatch[1]}")`,
22
- `(was ${chalk.cyan(`"${valueMatch[1]}"`)})`
22
+ `(was ${styleText("cyan", `"${valueMatch[1]}"`)})`
23
23
  ) : messageWithoutPath;
24
- return `${chalk.yellow(path)}${formattedMessage}`;
24
+ return `${styleText("yellow", path)}${formattedMessage}`;
25
25
  }).join("\n");
26
26
  var ArkEnvError = class extends Error {
27
27
  constructor(errors, message = "Errors found while validating environment variables") {
28
- super(`${chalk.red(message)}
28
+ super(`${styleText("red", message)}
29
29
  ${indent(formatErrors(errors))}
30
30
  `);
31
31
  this.name = "ArkEnvError";
@@ -72,8 +72,12 @@ function createEnv(def, env = process.env) {
72
72
 
73
73
  // src/type.ts
74
74
  var type4 = $.type;
75
+
76
+ // src/index.ts
77
+ var arkenv = createEnv;
78
+ var index_default = arkenv;
75
79
  export {
76
80
  createEnv,
77
- createEnv as default,
81
+ index_default as default,
78
82
  type4 as type
79
83
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arkenv",
3
3
  "type": "module",
4
- "version": "0.6.0",
4
+ "version": "0.7.0",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -39,9 +39,6 @@
39
39
  "peerDependencies": {
40
40
  "arktype": "^2.1.22"
41
41
  },
42
- "dependencies": {
43
- "chalk": "^5.6.2"
44
- },
45
42
  "scripts": {
46
43
  "build": "rimraf dist && tsup",
47
44
  "test:once": "pnpm test",