@theholocron/env-utils 1.0.1 → 1.0.6

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,43 @@
1
+ # `@theholocron/env-utils`
2
+
3
+ Runtime environment detection and typed env-var parsing.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @theholocron/env-utils
9
+ pnpm add -D dotenv # peer dependency, optional
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ### Environment detection
15
+
16
+ ```typescript
17
+ import { environment, ENVIRONMENTS } from "@theholocron/env-utils";
18
+
19
+ environment.get(); // "prod" | "qa" | "dev" | "local"
20
+ environment.normalize("production"); // "prod"
21
+ environment.isDeployed(); // true when qa or prod
22
+
23
+ // reads ENVIRONMENT → ENV → NODE_ENV in priority order
24
+ ```
25
+
26
+ ### Env-var parsing
27
+
28
+ ```typescript
29
+ import { createEnvParser } from "@theholocron/env-utils";
30
+
31
+ const { get, map, deprecate } = createEnvParser({ appName: "my-app" });
32
+
33
+ deprecate("database_url", "db__primary__url");
34
+
35
+ export const config = map((get) => ({
36
+ port: get("port") ?? 3000,
37
+ db: { url: get("db.primary.url") ?? get("database_url") },
38
+ }));
39
+ ```
40
+
41
+ ## Documentation
42
+
43
+ Check out [The Holocron Archive](https://docs.theholocron.dev/projects/utils/) for more information.
package/dist/index.d.mts CHANGED
@@ -1,24 +1,4 @@
1
1
  import "dotenv/config";
2
- //#region src/environment.d.ts
3
- declare const ENVIRONMENTS: readonly ["local", "dev", "qa", "prod"];
4
- declare const DEFAULT_ENVIRONMENT: Environment;
5
- declare const DEPLOYED_ENVIRONMENTS: Set<"local" | "dev" | "qa" | "prod">;
6
- /**
7
- * Normalize a string into a canonical Environment.
8
- * Returns undefined if the value is not recognized.
9
- */
10
- declare function normalizeEnvironment(value: string): Environment | undefined;
11
- /**
12
- * Resolve the current environment from input or process.env.
13
- */
14
- declare function getEnvironment(): Environment;
15
- declare const environment: {
16
- get: typeof getEnvironment;
17
- normalize: typeof normalizeEnvironment;
18
- isDeployed: () => boolean;
19
- };
20
- type Environment = (typeof ENVIRONMENTS)[number];
21
- //#endregion
22
2
  //#region src/types.d.ts
23
3
  type Primitive = string | number | boolean;
24
4
  type EnvObject = {
@@ -129,6 +109,26 @@ interface EnvParser<T extends EnvObject = EnvObject> {
129
109
  */
130
110
  declare function createEnvParser<T extends EnvObject = EnvObject>(options: EnvParserOptions): EnvParser<T>;
131
111
  //#endregion
112
+ //#region src/environment.d.ts
113
+ declare const ENVIRONMENTS: readonly ["local", "dev", "qa", "prod"];
114
+ declare const DEFAULT_ENVIRONMENT: Environment;
115
+ declare const DEPLOYED_ENVIRONMENTS: Set<"local" | "dev" | "qa" | "prod">;
116
+ /**
117
+ * Normalize a string into a canonical Environment.
118
+ * Returns undefined if the value is not recognized.
119
+ */
120
+ declare function normalizeEnvironment(value: string): Environment | undefined;
121
+ /**
122
+ * Resolve the current environment from input or process.env.
123
+ */
124
+ declare function getEnvironment(): Environment;
125
+ declare const environment: {
126
+ get: typeof getEnvironment;
127
+ normalize: typeof normalizeEnvironment;
128
+ isDeployed: () => boolean;
129
+ };
130
+ type Environment = (typeof ENVIRONMENTS)[number];
131
+ //#endregion
132
132
  //#region src/loader.d.ts
133
133
  /**
134
134
  * Default loader — calls dotenv/config so the .env file is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/env-utils",
3
- "version": "1.0.1",
3
+ "version": "1.0.6",
4
4
  "description": "Runtime environment detection and typed env-var parsing.",
5
5
  "homepage": "https://github.com/theholocron/utils/tree/main/packages/env#readme",
6
6
  "bugs": "https://github.com/theholocron/utils/issues",
@@ -22,13 +22,13 @@
22
22
  "README.md"
23
23
  ],
24
24
  "devDependencies": {
25
- "@theholocron/tsdown-config": "^7.5.0",
26
- "@theholocron/vitest-config": "^7.5.0",
25
+ "@theholocron/tsdown-config": "^7.6.1",
26
+ "@theholocron/vitest-config": "^7.6.1",
27
27
  "@tsconfig/node-lts": "^24.0.0",
28
- "@types/node": "^26.1.1",
28
+ "@types/node": "^26.1.2",
29
29
  "@vitest/coverage-v8": "^4.1.10",
30
- "dotenv": "^16.5.0",
31
- "tsdown": "^0.22.13",
30
+ "dotenv": "^17.4.2",
31
+ "tsdown": "^0.22.14",
32
32
  "vitest": "^4.1.10"
33
33
  },
34
34
  "peerDependencies": {