arkenv 0.4.0 → 0.6.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 +28 -12
- package/dist/index.cjs +7 -9
- package/dist/index.d.cts +77 -13
- package/dist/index.d.ts +77 -13
- package/dist/index.js +5 -14
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
+
<sup><b>We are now featured on <a href="https://arktype.io/docs/ecosystem#arkenv">arktype.io</a>!</b></sup>
|
|
3
|
+
<br />
|
|
2
4
|
<a href="https://arkenv.js.org">
|
|
3
5
|
<img alt="arkenv - Typesafe Environment Variables" src="https://og.tailgraph.com/og?titleFontFamily=JetBrains+Mono&textFontFamily=Inter&title=ArkEnv&titleTailwind=text-[%23e9eef9]%20font-bold%20relative%20decoration-%5Brgb(180,215,255)%5D%20decoration-wavy%20decoration-[5px]%20underline%20underline-offset-[16px]%20text-5xl%20mb-8&text=Typesafe%20environment%20variables%20powered%20by%20ArkType&textTailwind=text-[%238b9dc1]%20text-3xl&bgTailwind=bg-gradient-to-b%20from-[%23061a3a]%20to-black" width="645px">
|
|
4
6
|
</a>
|
|
5
7
|
<br />
|
|
6
8
|
<a href="https://github.com/yamcodes/arkenv/actions/workflows/tests.yml?query=branch%3Amain"><img alt="Tests Status" src="https://github.com/yamcodes/arkenv/actions/workflows/tests.yml/badge.svg?event=push&branch=main"></a>
|
|
7
|
-
<a href="https://
|
|
8
|
-
<a href="https://www.
|
|
9
|
-
<a href="https://
|
|
10
|
-
<a href="https://
|
|
9
|
+
<a href="https://discord.com/channels/957797212103016458/1415373591394127894"><img alt="Chat on Discord" src="https://img.shields.io/discord/957797212103016458?label=Chat&color=5865f4&logo=discord&labelColor=121214"></a>
|
|
10
|
+
<a href="https://www.typescriptlang.org/"><img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-3178C6?style=flat&logo=typescript&logoColor=white"></a>
|
|
11
|
+
<a href="https://arktype.io/"><img alt="Powered By ArkType" src="https://custom-icon-badges.demolab.com/badge/ArkType-0d1526?logo=arktype2&logoColor=e9eef9"></a>
|
|
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
|
+
<a href="https://bun.com/"><img alt="Bun" src="https://img.shields.io/badge/Bun-14151a?logo=bun&logoColor=fbf0df"></a>
|
|
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>
|
|
11
16
|
</p>
|
|
12
17
|
|
|
18
|
+
## Requirements
|
|
19
|
+
|
|
20
|
+
- TypeScript >= 5.1 and [anything else required by ArkType](https://arktype.io/docs/intro/setup#installation)
|
|
21
|
+
- We support Node.js ([example](examples/basic/README.md)), Bun ([example](examples/with-bun/README.md)), and Vite ([example](examples/with-vite-react-ts/README.md))
|
|
22
|
+
|
|
13
23
|
## Installation
|
|
14
24
|
|
|
15
25
|
<details open>
|
|
@@ -46,18 +56,16 @@ bun add arkenv arktype
|
|
|
46
56
|
|
|
47
57
|
## Quickstart
|
|
48
58
|
|
|
49
|
-
> [!TIP]
|
|
50
|
-
> Find more examples in the [examples](https://github.com/yamcodes/arkenv/tree/main/examples) directory.
|
|
51
|
-
|
|
52
59
|
```ts
|
|
53
|
-
import
|
|
60
|
+
import arkenv from 'arkenv';
|
|
54
61
|
|
|
55
|
-
const env =
|
|
62
|
+
const env = arkenv({
|
|
56
63
|
HOST: "string.host", // valid IP address or localhost
|
|
57
64
|
PORT: "number.port", // valid port number (0-65535)
|
|
58
65
|
NODE_ENV: "'development' | 'production' | 'test'",
|
|
59
66
|
});
|
|
60
67
|
|
|
68
|
+
|
|
61
69
|
// Automatically validate and parse process.env
|
|
62
70
|
// TypeScript knows the ✨exact✨ types!
|
|
63
71
|
console.log(env.HOST); // (property) HOST: string
|
|
@@ -65,12 +73,18 @@ console.log(env.PORT); // (property) PORT: number
|
|
|
65
73
|
console.log(env.NODE_ENV); // (property) NODE_ENV: "development" | "production" | "test"
|
|
66
74
|
```
|
|
67
75
|
|
|
76
|
+
You can find more examples in the [examples](https://github.com/yamcodes/arkenv/tree/main/examples) directory.
|
|
77
|
+
|
|
78
|
+
> [!TIP]
|
|
79
|
+
> **VS Code Users:** Get syntax highlighting and inline error summaries for the ArkType ecosystem with the [ArkType VS Code extension](https://marketplace.visualstudio.com/items?itemName=arktypeio.arkdark). For even better TypeScript highlighting, try [ArkThemes](https://marketplace.cursorapi.com/items/?itemName=arktypeio.arkthemes).
|
|
80
|
+
> 
|
|
81
|
+
|
|
68
82
|
## Features
|
|
69
83
|
|
|
70
84
|
- 🔒 **Typesafe**: Full TypeScript support with inferred types
|
|
71
85
|
- 🚀 **Runtime validation**: Catch missing or invalid environment variables early
|
|
72
86
|
- 💪 **Powered by ArkType**: Leverage ArkType's powerful type system
|
|
73
|
-
- 🪶 **Lightweight**: Only a single dependency ([
|
|
87
|
+
- 🪶 **Lightweight**: Only a single dependency ([see size](https://bundlephobia.com/package/arkenv))
|
|
74
88
|
- ⚡ **Fast**: Optimized for performance with minimal overhead
|
|
75
89
|
|
|
76
90
|
## Documentation
|
|
@@ -81,9 +95,11 @@ For detailed documentation and examples, please visit our [documentation site](h
|
|
|
81
95
|
|
|
82
96
|
- [@arkenv/vite-plugin](https://github.com/yamcodes/arkenv/tree/main/packages/vite-plugin): [Vite](https://vite.dev/) plugin to validate environment variables at build time
|
|
83
97
|
|
|
84
|
-
##
|
|
98
|
+
## Supporting ArkEnv
|
|
99
|
+
|
|
100
|
+
If you love ArkEnv, you can support the project by starring it on GitHub!
|
|
85
101
|
|
|
86
|
-
|
|
102
|
+
You are also welcome to directly [contribute to the project's development](https://github.com/yamcodes/arkenv/blob/main/CONTRIBUTING.md).
|
|
87
103
|
|
|
88
104
|
## Thanks / Inspiration
|
|
89
105
|
|
package/dist/index.cjs
CHANGED
|
@@ -31,15 +31,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
createEnv: () => createEnv,
|
|
34
|
-
default: () =>
|
|
34
|
+
default: () => createEnv,
|
|
35
|
+
type: () => type4
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(index_exports);
|
|
37
38
|
|
|
38
39
|
// src/create-env.ts
|
|
39
|
-
var create_env_exports = {};
|
|
40
|
-
__export(create_env_exports, {
|
|
41
|
-
createEnv: () => createEnv
|
|
42
|
-
});
|
|
43
40
|
var import_arktype3 = require("arktype");
|
|
44
41
|
|
|
45
42
|
// src/errors.ts
|
|
@@ -79,7 +76,7 @@ var import_arktype2 = require("arktype");
|
|
|
79
76
|
// src/types.ts
|
|
80
77
|
var import_arktype = require("arktype");
|
|
81
78
|
var port = (0, import_arktype.type)("string", "=>", (data, ctx) => {
|
|
82
|
-
const asNumber = Number.parseInt(data);
|
|
79
|
+
const asNumber = Number.parseInt(data, 10);
|
|
83
80
|
const isInteger = Number.isInteger(asNumber);
|
|
84
81
|
const isBetween = 0 <= asNumber && asNumber <= 65535;
|
|
85
82
|
if (!isInteger || !isBetween) {
|
|
@@ -111,9 +108,10 @@ function createEnv(def, env = process.env) {
|
|
|
111
108
|
return validatedEnv;
|
|
112
109
|
}
|
|
113
110
|
|
|
114
|
-
// src/
|
|
115
|
-
var
|
|
111
|
+
// src/type.ts
|
|
112
|
+
var type4 = $.type;
|
|
116
113
|
// Annotate the CommonJS export names for ESM import in node:
|
|
117
114
|
0 && (module.exports = {
|
|
118
|
-
createEnv
|
|
115
|
+
createEnv,
|
|
116
|
+
type
|
|
119
117
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as arktype from 'arktype';
|
|
2
|
-
import { type, distill } from 'arktype';
|
|
2
|
+
import { type as type$1, distill } from 'arktype';
|
|
3
3
|
import * as arktype_internal_attributes_ts from 'arktype/internal/attributes.ts';
|
|
4
4
|
import * as arktype_internal_keywords_string_ts from 'arktype/internal/keywords/string.ts';
|
|
5
|
+
import * as arktype_internal_type_ts from 'arktype/internal/type.ts';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* The root scope for the ArkEnv library, containing extensions to the ArkType scopes with ArkEnv-specific types like `string.host` and `number.port`.
|
|
@@ -79,7 +80,7 @@ declare const $: arktype.Scope<{
|
|
|
79
80
|
}>;
|
|
80
81
|
|
|
81
82
|
type RuntimeEnvironment = Record<string, string | undefined>;
|
|
82
|
-
type EnvSchema<def, $ = {}> = type.validate<def, $>;
|
|
83
|
+
type EnvSchema<def, $ = {}> = type$1.validate<def, $>;
|
|
83
84
|
/**
|
|
84
85
|
* Create an environment variables object from a schema and an environment
|
|
85
86
|
* @param def - The environment variable schema
|
|
@@ -87,16 +88,79 @@ type EnvSchema<def, $ = {}> = type.validate<def, $>;
|
|
|
87
88
|
* @returns The validated environment variable schema
|
|
88
89
|
* @throws An error if the environment variables are invalid. See {@link ArkEnvError}
|
|
89
90
|
*/
|
|
90
|
-
declare function createEnv<const T extends Record<string, string | undefined>>(def: EnvSchema<T, (typeof $)["t"]>, env?: RuntimeEnvironment): distill.Out<type.infer<T, (typeof $)["t"]>>;
|
|
91
|
-
declare function createEnv<const T extends Record<string, string | undefined>>(def: EnvSchema<T>, env?: RuntimeEnvironment): distill.Out<type.infer<T>>;
|
|
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>>;
|
|
92
93
|
|
|
93
|
-
declare const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
declare const type: arktype_internal_type_ts.TypeParser<{
|
|
95
|
+
string: arktype.Submodule<{
|
|
96
|
+
root: string;
|
|
97
|
+
" arkInferred": string;
|
|
98
|
+
trim: arktype.Submodule<arktype_internal_keywords_string_ts.trim.$ & {
|
|
99
|
+
" arkInferred": (In: string) => arktype_internal_attributes_ts.To<string>;
|
|
100
|
+
}>;
|
|
101
|
+
normalize: arktype.Submodule<arktype_internal_keywords_string_ts.normalize.$ & {
|
|
102
|
+
" arkInferred": (In: string) => arktype_internal_attributes_ts.To<string>;
|
|
103
|
+
}>;
|
|
104
|
+
alpha: string;
|
|
105
|
+
alphanumeric: string;
|
|
106
|
+
hex: string;
|
|
107
|
+
base64: arktype.Submodule<{
|
|
108
|
+
root: string;
|
|
109
|
+
url: string;
|
|
110
|
+
} & {
|
|
111
|
+
" arkInferred": string;
|
|
112
|
+
}>;
|
|
113
|
+
capitalize: arktype.Submodule<arktype_internal_keywords_string_ts.capitalize.$ & {
|
|
114
|
+
" arkInferred": (In: string) => arktype_internal_attributes_ts.To<string>;
|
|
115
|
+
}>;
|
|
116
|
+
creditCard: string;
|
|
117
|
+
date: arktype.Submodule<arktype_internal_keywords_string_ts.stringDate.$ & {
|
|
118
|
+
" arkInferred": string;
|
|
119
|
+
}>;
|
|
120
|
+
digits: string;
|
|
121
|
+
email: string;
|
|
122
|
+
integer: arktype.Submodule<arktype_internal_keywords_string_ts.stringInteger.$ & {
|
|
123
|
+
" arkInferred": string;
|
|
124
|
+
}>;
|
|
125
|
+
ip: arktype.Submodule<arktype_internal_keywords_string_ts.ip.$ & {
|
|
126
|
+
" arkInferred": string;
|
|
127
|
+
}>;
|
|
128
|
+
json: arktype.Submodule<arktype_internal_keywords_string_ts.stringJson.$ & {
|
|
129
|
+
" arkInferred": string;
|
|
130
|
+
}>;
|
|
131
|
+
lower: arktype.Submodule<arktype_internal_keywords_string_ts.lower.$ & {
|
|
132
|
+
" arkInferred": (In: string) => arktype_internal_attributes_ts.To<string>;
|
|
133
|
+
}>;
|
|
134
|
+
numeric: arktype.Submodule<arktype_internal_keywords_string_ts.stringNumeric.$ & {
|
|
135
|
+
" arkInferred": string;
|
|
136
|
+
}>;
|
|
137
|
+
regex: string;
|
|
138
|
+
semver: string;
|
|
139
|
+
upper: arktype.Submodule<{
|
|
140
|
+
root: (In: string) => arktype_internal_attributes_ts.To<string>;
|
|
141
|
+
preformatted: string;
|
|
142
|
+
} & {
|
|
143
|
+
" arkInferred": (In: string) => arktype_internal_attributes_ts.To<string>;
|
|
144
|
+
}>;
|
|
145
|
+
url: arktype.Submodule<arktype_internal_keywords_string_ts.url.$ & {
|
|
146
|
+
" arkInferred": string;
|
|
147
|
+
}>;
|
|
148
|
+
uuid: arktype.Submodule<arktype_internal_keywords_string_ts.uuid.$ & {
|
|
149
|
+
" arkInferred": string;
|
|
150
|
+
}>;
|
|
151
|
+
host: string;
|
|
152
|
+
}>;
|
|
153
|
+
number: arktype.Submodule<{
|
|
154
|
+
NaN: number;
|
|
155
|
+
Infinity: number;
|
|
156
|
+
root: number;
|
|
157
|
+
" arkInferred": number;
|
|
158
|
+
integer: number;
|
|
159
|
+
epoch: number;
|
|
160
|
+
safe: number;
|
|
161
|
+
NegativeInfinity: number;
|
|
162
|
+
port: (In: string) => arktype.Out<number>;
|
|
163
|
+
}>;
|
|
164
|
+
}>;
|
|
101
165
|
|
|
102
|
-
export { type EnvSchema, createEnv,
|
|
166
|
+
export { type EnvSchema, createEnv, createEnv as default, type };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as arktype from 'arktype';
|
|
2
|
-
import { type, distill } from 'arktype';
|
|
2
|
+
import { type as type$1, distill } from 'arktype';
|
|
3
3
|
import * as arktype_internal_attributes_ts from 'arktype/internal/attributes.ts';
|
|
4
4
|
import * as arktype_internal_keywords_string_ts from 'arktype/internal/keywords/string.ts';
|
|
5
|
+
import * as arktype_internal_type_ts from 'arktype/internal/type.ts';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* The root scope for the ArkEnv library, containing extensions to the ArkType scopes with ArkEnv-specific types like `string.host` and `number.port`.
|
|
@@ -79,7 +80,7 @@ declare const $: arktype.Scope<{
|
|
|
79
80
|
}>;
|
|
80
81
|
|
|
81
82
|
type RuntimeEnvironment = Record<string, string | undefined>;
|
|
82
|
-
type EnvSchema<def, $ = {}> = type.validate<def, $>;
|
|
83
|
+
type EnvSchema<def, $ = {}> = type$1.validate<def, $>;
|
|
83
84
|
/**
|
|
84
85
|
* Create an environment variables object from a schema and an environment
|
|
85
86
|
* @param def - The environment variable schema
|
|
@@ -87,16 +88,79 @@ type EnvSchema<def, $ = {}> = type.validate<def, $>;
|
|
|
87
88
|
* @returns The validated environment variable schema
|
|
88
89
|
* @throws An error if the environment variables are invalid. See {@link ArkEnvError}
|
|
89
90
|
*/
|
|
90
|
-
declare function createEnv<const T extends Record<string, string | undefined>>(def: EnvSchema<T, (typeof $)["t"]>, env?: RuntimeEnvironment): distill.Out<type.infer<T, (typeof $)["t"]>>;
|
|
91
|
-
declare function createEnv<const T extends Record<string, string | undefined>>(def: EnvSchema<T>, env?: RuntimeEnvironment): distill.Out<type.infer<T>>;
|
|
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>>;
|
|
92
93
|
|
|
93
|
-
declare const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
declare const type: arktype_internal_type_ts.TypeParser<{
|
|
95
|
+
string: arktype.Submodule<{
|
|
96
|
+
root: string;
|
|
97
|
+
" arkInferred": string;
|
|
98
|
+
trim: arktype.Submodule<arktype_internal_keywords_string_ts.trim.$ & {
|
|
99
|
+
" arkInferred": (In: string) => arktype_internal_attributes_ts.To<string>;
|
|
100
|
+
}>;
|
|
101
|
+
normalize: arktype.Submodule<arktype_internal_keywords_string_ts.normalize.$ & {
|
|
102
|
+
" arkInferred": (In: string) => arktype_internal_attributes_ts.To<string>;
|
|
103
|
+
}>;
|
|
104
|
+
alpha: string;
|
|
105
|
+
alphanumeric: string;
|
|
106
|
+
hex: string;
|
|
107
|
+
base64: arktype.Submodule<{
|
|
108
|
+
root: string;
|
|
109
|
+
url: string;
|
|
110
|
+
} & {
|
|
111
|
+
" arkInferred": string;
|
|
112
|
+
}>;
|
|
113
|
+
capitalize: arktype.Submodule<arktype_internal_keywords_string_ts.capitalize.$ & {
|
|
114
|
+
" arkInferred": (In: string) => arktype_internal_attributes_ts.To<string>;
|
|
115
|
+
}>;
|
|
116
|
+
creditCard: string;
|
|
117
|
+
date: arktype.Submodule<arktype_internal_keywords_string_ts.stringDate.$ & {
|
|
118
|
+
" arkInferred": string;
|
|
119
|
+
}>;
|
|
120
|
+
digits: string;
|
|
121
|
+
email: string;
|
|
122
|
+
integer: arktype.Submodule<arktype_internal_keywords_string_ts.stringInteger.$ & {
|
|
123
|
+
" arkInferred": string;
|
|
124
|
+
}>;
|
|
125
|
+
ip: arktype.Submodule<arktype_internal_keywords_string_ts.ip.$ & {
|
|
126
|
+
" arkInferred": string;
|
|
127
|
+
}>;
|
|
128
|
+
json: arktype.Submodule<arktype_internal_keywords_string_ts.stringJson.$ & {
|
|
129
|
+
" arkInferred": string;
|
|
130
|
+
}>;
|
|
131
|
+
lower: arktype.Submodule<arktype_internal_keywords_string_ts.lower.$ & {
|
|
132
|
+
" arkInferred": (In: string) => arktype_internal_attributes_ts.To<string>;
|
|
133
|
+
}>;
|
|
134
|
+
numeric: arktype.Submodule<arktype_internal_keywords_string_ts.stringNumeric.$ & {
|
|
135
|
+
" arkInferred": string;
|
|
136
|
+
}>;
|
|
137
|
+
regex: string;
|
|
138
|
+
semver: string;
|
|
139
|
+
upper: arktype.Submodule<{
|
|
140
|
+
root: (In: string) => arktype_internal_attributes_ts.To<string>;
|
|
141
|
+
preformatted: string;
|
|
142
|
+
} & {
|
|
143
|
+
" arkInferred": (In: string) => arktype_internal_attributes_ts.To<string>;
|
|
144
|
+
}>;
|
|
145
|
+
url: arktype.Submodule<arktype_internal_keywords_string_ts.url.$ & {
|
|
146
|
+
" arkInferred": string;
|
|
147
|
+
}>;
|
|
148
|
+
uuid: arktype.Submodule<arktype_internal_keywords_string_ts.uuid.$ & {
|
|
149
|
+
" arkInferred": string;
|
|
150
|
+
}>;
|
|
151
|
+
host: string;
|
|
152
|
+
}>;
|
|
153
|
+
number: arktype.Submodule<{
|
|
154
|
+
NaN: number;
|
|
155
|
+
Infinity: number;
|
|
156
|
+
root: number;
|
|
157
|
+
" arkInferred": number;
|
|
158
|
+
integer: number;
|
|
159
|
+
epoch: number;
|
|
160
|
+
safe: number;
|
|
161
|
+
NegativeInfinity: number;
|
|
162
|
+
port: (In: string) => arktype.Out<number>;
|
|
163
|
+
}>;
|
|
164
|
+
}>;
|
|
101
165
|
|
|
102
|
-
export { type EnvSchema, createEnv,
|
|
166
|
+
export { type EnvSchema, createEnv, createEnv as default, type };
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __export = (target, all) => {
|
|
3
|
-
for (var name in all)
|
|
4
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
-
};
|
|
6
|
-
|
|
7
1
|
// src/create-env.ts
|
|
8
|
-
var create_env_exports = {};
|
|
9
|
-
__export(create_env_exports, {
|
|
10
|
-
createEnv: () => createEnv
|
|
11
|
-
});
|
|
12
2
|
import { type as type3 } from "arktype";
|
|
13
3
|
|
|
14
4
|
// src/errors.ts
|
|
@@ -48,7 +38,7 @@ import { scope, type as type2 } from "arktype";
|
|
|
48
38
|
// src/types.ts
|
|
49
39
|
import { type } from "arktype";
|
|
50
40
|
var port = type("string", "=>", (data, ctx) => {
|
|
51
|
-
const asNumber = Number.parseInt(data);
|
|
41
|
+
const asNumber = Number.parseInt(data, 10);
|
|
52
42
|
const isInteger = Number.isInteger(asNumber);
|
|
53
43
|
const isBetween = 0 <= asNumber && asNumber <= 65535;
|
|
54
44
|
if (!isInteger || !isBetween) {
|
|
@@ -80,9 +70,10 @@ function createEnv(def, env = process.env) {
|
|
|
80
70
|
return validatedEnv;
|
|
81
71
|
}
|
|
82
72
|
|
|
83
|
-
// src/
|
|
84
|
-
var
|
|
73
|
+
// src/type.ts
|
|
74
|
+
var type4 = $.type;
|
|
85
75
|
export {
|
|
86
76
|
createEnv,
|
|
87
|
-
|
|
77
|
+
createEnv as default,
|
|
78
|
+
type4 as type
|
|
88
79
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkenv",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"bugs": "https://github.com/yamcodes/arkenv/labels/arkenv",
|
|
32
32
|
"author": "Yam Borodetsky <yam@yam.codes>",
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@ark/schema": "^0.
|
|
35
|
-
"@types/node": "
|
|
34
|
+
"@ark/schema": "^0.49.0",
|
|
35
|
+
"@types/node": "24.3.1",
|
|
36
36
|
"tsup": "^8.5.0",
|
|
37
37
|
"typescript": "^5.9.2"
|
|
38
38
|
},
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"arktype": "^2.1.22"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"chalk": "^5.6.
|
|
43
|
+
"chalk": "^5.6.2"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "rimraf dist && tsup",
|