@kasoa/env 0.0.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 ADDED
@@ -0,0 +1 @@
1
+ # `@kasoa/env`
@@ -0,0 +1,3 @@
1
+ import type { StandardSchemaV1 } from "@standard-schema/spec";
2
+ export declare function defineEnv<TSchema extends StandardSchemaV1>(schema: TSchema): (env: unknown) => StandardSchemaV1.InferOutput<TSchema>;
3
+ //# sourceMappingURL=define-env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-env.d.ts","sourceRoot":"","sources":["../src/define-env.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,wBAAgB,SAAS,CAAC,OAAO,SAAS,gBAAgB,EACzD,MAAM,EAAE,OAAO,GACb,CAAC,GAAG,EAAE,OAAO,KAAK,gBAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,CA2BzD"}
@@ -0,0 +1,22 @@
1
+ import { styleText } from "node:util";
2
+ export function defineEnv(schema) {
3
+ return (env) => {
4
+ const result = schema["~standard"].validate(env);
5
+ if (result instanceof Promise) {
6
+ throw new TypeError("Schema validation must be synchronous");
7
+ }
8
+ if (result.issues) {
9
+ const issues = result.issues.flatMap((issue) => (issue.path ?? []).map((item) => {
10
+ const key = typeof item === "object" ? item.key : item;
11
+ const message = issue.message;
12
+ return `${String(key)}: ${message}`;
13
+ }));
14
+ const error = [
15
+ `${styleText("red", "Invalid environment variables")}`,
16
+ ...issues,
17
+ ].join("\n");
18
+ throw new Error(error);
19
+ }
20
+ return result.value;
21
+ };
22
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./define-env.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./define-env.js";
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@kasoa/env",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "license": "MIT",
7
+ "description": "Manage environment variables, simply",
8
+ "keywords": [
9
+ "kasoa",
10
+ "env",
11
+ "environment",
12
+ "variables",
13
+ "valibot",
14
+ "zod",
15
+ "arktype"
16
+ ],
17
+ "author": {
18
+ "name": "Emmanuel Chucks",
19
+ "url": "https://emmanuelchucks.com"
20
+ },
21
+ "homepage": "https://github.com/emmanuelchucks/kasoa/tree/main/packages/package-env",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/emmanuelchucks/kasoa.git",
25
+ "directory": "packages/package-env"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/emmanuelchucks/kasoa/issues"
29
+ },
30
+ "main": "dist/index.js",
31
+ "types": "dist/index.d.ts",
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "exports": {
36
+ ".": "./dist/index.js"
37
+ },
38
+ "devDependencies": {
39
+ "@standard-schema/spec": "1.0.0-beta.4",
40
+ "@types/node": "^22.10.4",
41
+ "arktype": "2.0.0-rc.30",
42
+ "typescript": "^5.7.2",
43
+ "valibot": "^1.0.0-beta.9",
44
+ "zod": "^3.24.1",
45
+ "@kasoa/config-biome": "0.0.0",
46
+ "@kasoa/config-typescript": "0.0.0"
47
+ },
48
+ "scripts": {
49
+ "dev": "tsc --watch",
50
+ "build": "tsc",
51
+ "test": "node --test --experimental-strip-types tests/*.test.ts",
52
+ "check": "biome check --write",
53
+ "format": "biome format --write",
54
+ "check-types": "tsc --noEmit",
55
+ "clean": "rm -rf dist"
56
+ }
57
+ }