@alwatr/env 5.5.30 → 6.0.1

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/dist/main.js ADDED
@@ -0,0 +1,5 @@
1
+ /* 📦 @alwatr/env v6.0.1 */
2
+ import{platformInfo as k}from"@alwatr/platform-info";function x(j){let h=process.env[j.name];if(h==="")h=void 0;if(k.development===!0)h??=j.developmentValue??j.defaultValue;else h??=j.defaultValue;if(h===void 0)throw Error(`Environment variable "${j.name}" is required.`);return h}export{x as getEnv};
3
+
4
+ //# debugId=6DE50F270AB4F9B164756E2164756E21
5
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/main.ts"],
4
+ "sourcesContent": [
5
+ "import {platformInfo} from '@alwatr/platform-info';\n\n/**\n * Parameters for retrieving an environment variable value.\n */\nexport type GetEnvOption = {\n /**\n * The name of the environment variable.\n */\n name: string;\n\n /**\n * The default value to use if the environment variable is not set.\n * If not provided, the environment variable is required and an error will be thrown if it is not set.\n * Except in development mode, where the development value will be used instead if provided.\n */\n defaultValue?: string;\n\n /**\n * The value to use in a development environment.\n * It will be overwrite the default value in development mode and completely ignored in production mode.\n */\n developmentValue?: string;\n};\n\nexport function getEnv(option: GetEnvOption): string {\n let value = process.env[option.name];\n if (value === '') value = undefined; // empty string is considered as undefined in environment variables\n\n if (platformInfo.development === true) {\n value ??= option.developmentValue ?? option.defaultValue;\n }\n else {\n value ??= option.defaultValue;\n }\n\n if (value === undefined) {\n throw new Error(`Environment variable \"${option.name}\" is required.`);\n }\n\n return value;\n}\n"
6
+ ],
7
+ "mappings": ";AAAA,uBAAQ,8BAyBD,SAAS,CAAM,CAAC,EAA8B,CACnD,IAAI,EAAQ,QAAQ,IAAI,EAAO,MAC/B,GAAI,IAAU,GAAI,EAAQ,OAE1B,GAAI,EAAa,cAAgB,GAC/B,IAAU,EAAO,kBAAoB,EAAO,aAG5C,SAAU,EAAO,aAGnB,GAAI,IAAU,OACZ,MAAU,MAAM,yBAAyB,EAAO,oBAAoB,EAGtE,OAAO",
8
+ "debugId": "6DE50F270AB4F9B164756E2164756E21",
9
+ "names": []
10
+ }
package/package.json CHANGED
@@ -1,34 +1,61 @@
1
1
  {
2
2
  "name": "@alwatr/env",
3
+ "version": "6.0.1",
3
4
  "description": "A tiny and tree-shakable TypeScript library to get environment variables with type-safe and fallback value for development and production.",
4
- "version": "5.5.30",
5
+ "license": "MPL-2.0",
5
6
  "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
7
+ "type": "module",
8
+ "repository": {
9
+ "directory": "packages/env",
10
+ "type": "git",
11
+ "url": "https://github.com/Alwatr/nanolib"
12
+ },
13
+ "homepage": "https://github.com/Alwatr/nanolib/tree/next/packages/env#readme",
6
14
  "bugs": "https://github.com/Alwatr/nanolib/issues",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/main.d.ts",
18
+ "default": "./dist/main.js"
19
+ }
20
+ },
21
+ "sideEffects": false,
7
22
  "dependencies": {
8
- "@alwatr/platform-info": "5.5.29"
23
+ "@alwatr/platform-info": "6.0.1"
9
24
  },
10
25
  "devDependencies": {
11
- "@alwatr/nano-build": "6.4.2",
12
- "@alwatr/prettier-config": "6.0.2",
13
- "@alwatr/tsconfig-base": "6.0.4",
14
- "@alwatr/type-helper": "7.0.2",
26
+ "@alwatr/nano-build": "7.0.1",
27
+ "@alwatr/prettier-config": "7.0.1",
28
+ "@alwatr/tsconfig-base": "8.0.0",
29
+ "@alwatr/type-helper": "8.0.1",
15
30
  "@types/node": "^24.12.0",
16
31
  "typescript": "^5.9.3"
17
32
  },
18
- "exports": {
19
- ".": {
20
- "types": "./dist/main.d.ts",
21
- "import": "./dist/main.mjs",
22
- "require": "./dist/main.cjs"
23
- }
33
+ "scripts": {
34
+ "b": "bun run build",
35
+ "build": "bun run build:ts && bun run build:es",
36
+ "build:es": "nano-build --preset=module src/main.ts",
37
+ "build:ts": "tsc --build",
38
+ "c": "bun run clean",
39
+ "cb": "bun run clean && bun run build",
40
+ "clean": "rm -rfv dist *.tsbuildinfo",
41
+ "d": "bun run build:es && bun",
42
+ "t": "bun run test",
43
+ "test": "bun test",
44
+ "w": "bun run watch",
45
+ "watch": "bun run watch:ts & bun run watch:es",
46
+ "watch:es": "bun run build:es --watch",
47
+ "watch:ts": "bun run build:ts --watch --preserveWatchOutput"
24
48
  },
25
49
  "files": [
26
- "**/*.{js,mjs,cjs,map,d.ts,html,md,LEGAL.txt}",
50
+ "**/*.{js,mjs,cjs,ts,map,d.ts,html,LEGAL.txt}",
51
+ "README.md",
27
52
  "LICENSE",
28
53
  "!demo/**/*",
29
54
  "!**/*.test.js"
30
55
  ],
31
- "homepage": "https://github.com/Alwatr/nanolib/tree/next/packages/env#readme",
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
32
59
  "keywords": [
33
60
  "alwatr",
34
61
  "browser",
@@ -46,36 +73,6 @@
46
73
  "utility",
47
74
  "utils"
48
75
  ],
49
- "license": "MPL-2.0",
50
- "main": "./dist/main.cjs",
51
- "module": "./dist/main.mjs",
52
76
  "prettier": "@alwatr/prettier-config",
53
- "publishConfig": {
54
- "access": "public"
55
- },
56
- "repository": {
57
- "type": "git",
58
- "url": "https://github.com/Alwatr/nanolib",
59
- "directory": "packages/env"
60
- },
61
- "scripts": {
62
- "b": "bun run build",
63
- "build": "bun run build:ts && bun run build:es",
64
- "build:es": "nano-build --preset=module",
65
- "build:ts": "tsc --build",
66
- "c": "bun run clean",
67
- "cb": "bun run clean && bun run build",
68
- "clean": "rm -rfv dist *.tsbuildinfo",
69
- "d": "bun run build:es && bun --enable-source-maps --trace-warnings",
70
- "t": "bun run test",
71
- "test": "bun test",
72
- "w": "bun run watch",
73
- "watch": "bun run watch:ts & bun run watch:es",
74
- "watch:es": "bun run build:es --watch",
75
- "watch:ts": "bun run build:ts --watch --preserveWatchOutput"
76
- },
77
- "sideEffects": false,
78
- "type": "module",
79
- "types": "./dist/main.d.ts",
80
- "gitHead": "def1decf8f496f4b0d3d3ab952c346c689c30160"
77
+ "gitHead": "f843742e94d6ebed3921d57b624d9deb35c2c102"
81
78
  }
package/src/main.ts ADDED
@@ -0,0 +1,42 @@
1
+ import {platformInfo} from '@alwatr/platform-info';
2
+
3
+ /**
4
+ * Parameters for retrieving an environment variable value.
5
+ */
6
+ export type GetEnvOption = {
7
+ /**
8
+ * The name of the environment variable.
9
+ */
10
+ name: string;
11
+
12
+ /**
13
+ * The default value to use if the environment variable is not set.
14
+ * If not provided, the environment variable is required and an error will be thrown if it is not set.
15
+ * Except in development mode, where the development value will be used instead if provided.
16
+ */
17
+ defaultValue?: string;
18
+
19
+ /**
20
+ * The value to use in a development environment.
21
+ * It will be overwrite the default value in development mode and completely ignored in production mode.
22
+ */
23
+ developmentValue?: string;
24
+ };
25
+
26
+ export function getEnv(option: GetEnvOption): string {
27
+ let value = process.env[option.name];
28
+ if (value === '') value = undefined; // empty string is considered as undefined in environment variables
29
+
30
+ if (platformInfo.development === true) {
31
+ value ??= option.developmentValue ?? option.defaultValue;
32
+ }
33
+ else {
34
+ value ??= option.defaultValue;
35
+ }
36
+
37
+ if (value === undefined) {
38
+ throw new Error(`Environment variable "${option.name}" is required.`);
39
+ }
40
+
41
+ return value;
42
+ }
package/CHANGELOG.md DELETED
@@ -1,276 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [5.5.30](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.29...@alwatr/env@5.5.30) (2026-03-18)
7
-
8
- **Note:** Version bump only for package @alwatr/env
9
-
10
- ## [5.5.29](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.28...@alwatr/env@5.5.29) (2026-03-16)
11
-
12
- ### 🔨 Code Refactoring
13
-
14
- * migrate build scripts from yarn to bun across multiple packages ([d90e962](https://github.com/Alwatr/nanolib/commit/d90e962f15e5c951e191d5f02341279b6472abc3))
15
-
16
- ### 🔗 Dependencies update
17
-
18
- * bump the npm-dependencies group with 10 updates ([c48d9ba](https://github.com/Alwatr/nanolib/commit/c48d9baa1cd7c2dc144b3e01e0fda60bf87c074c))
19
-
20
- ## [5.5.28](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.27...@alwatr/env@5.5.28) (2026-02-18)
21
-
22
- ### 🔗 Dependencies update
23
-
24
- * update @types/node to version 24.10.13 across multiple packages ([4c6d2a3](https://github.com/Alwatr/nanolib/commit/4c6d2a37ab26b1c86812b2aa38b2eca4ee097cb6))
25
-
26
- ## [5.5.27](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.26...@alwatr/env@5.5.27) (2025-12-23)
27
-
28
- ### 🔗 Dependencies update
29
-
30
- * upgrade @types/node to version 24.10.4 and update related dependencies ([acf04df](https://github.com/Alwatr/nanolib/commit/acf04df71647f5a401ef5e6bbfffcc478e4326d2))
31
-
32
- ## [5.5.26](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.25...@alwatr/env@5.5.26) (2025-12-13)
33
-
34
- ### 🔗 Dependencies update
35
-
36
- * update `@types/node` and `[@lerna-lite](https://github.com/lerna-lite)` dependencies. ([8daa8fd](https://github.com/Alwatr/nanolib/commit/8daa8fd023d5414c9f95feb4319353c6ea34be31))
37
-
38
- ## [5.5.25](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.24...@alwatr/env@5.5.25) (2025-12-10)
39
-
40
- ### 🔗 Dependencies update
41
-
42
- * Upgrade lerna-lite, prettier, types/node, and yarn dependencies. ([42a7fca](https://github.com/Alwatr/nanolib/commit/42a7fca15430aca2ac1eaa19496c2a2ebfc8c470))
43
-
44
- ## [5.5.24](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.23...@alwatr/env@5.5.24) (2025-11-18)
45
-
46
- ### 🔨 Code Refactoring
47
-
48
- * remove unnecessary type declarations from tsconfig.json files ([89bcc7d](https://github.com/Alwatr/nanolib/commit/89bcc7db839807110b80f8ba34414ea9734d9c75))
49
-
50
- ## [5.5.23](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.22...@alwatr/env@5.5.23) (2025-11-15)
51
-
52
- ### 🔗 Dependencies update
53
-
54
- * bump the npm-dependencies group with 2 updates ([a80b84d](https://github.com/Alwatr/nanolib/commit/a80b84dada6c09b5e5621e7487c8ec13fff3c23a))
55
-
56
- ## [5.5.22](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.21...@alwatr/env@5.5.22) (2025-11-15)
57
-
58
- **Note:** Version bump only for package @alwatr/env
59
-
60
- ## [5.5.21](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.20...@alwatr/env@5.5.21) (2025-11-04)
61
-
62
- ### 🔗 Dependencies update
63
-
64
- * bump the npm-dependencies group across 1 directory with 9 updates ([fdf29d5](https://github.com/Alwatr/nanolib/commit/fdf29d5aa89983cb06f79d42650a364521f5c4b9))
65
- * update @types/node from ^22.18.12 to ^24.10.0 across multiple packages ([1169a86](https://github.com/Alwatr/nanolib/commit/1169a86001da2abfbe99a7da33c8e92183f553f6))
66
-
67
- ## [5.5.20](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.19...@alwatr/env@5.5.20) (2025-10-06)
68
-
69
- ### 🔗 Dependencies update
70
-
71
- * bump the npm-dependencies group with 4 updates ([9825815](https://github.com/Alwatr/nanolib/commit/982581552bbb4b97dca52af5e93a80937f0c3109))
72
-
73
- ## [5.5.19](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.18...@alwatr/env@5.5.19) (2025-09-27)
74
-
75
- ### 🧹 Miscellaneous Chores
76
-
77
- * exclude test files from package distribution ([86f4f2f](https://github.com/Alwatr/nanolib/commit/86f4f2f5985845c5cf3a3a9398de7b2f98ce53e7))
78
-
79
- ## [5.5.18](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.17...@alwatr/env@5.5.18) (2025-09-22)
80
-
81
- **Note:** Version bump only for package @alwatr/env
82
-
83
- ## [5.5.17](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.16...@alwatr/env@5.5.17) (2025-09-22)
84
-
85
- **Note:** Version bump only for package @alwatr/env
86
-
87
- ## [5.5.16](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.15...@alwatr/env@5.5.16) (2025-09-21)
88
-
89
- **Note:** Version bump only for package @alwatr/env
90
-
91
- ## [5.5.15](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.14...@alwatr/env@5.5.15) (2025-09-20)
92
-
93
- ### 🐛 Bug Fixes
94
-
95
- * add sideEffects property to package.json files for better tree-shaking ([c7b9e74](https://github.com/Alwatr/nanolib/commit/c7b9e74e1920c8e35b438742de61883ca62da58c))
96
- * add sideEffects property to package.json files for better tree-shaking ([e8402c4](https://github.com/Alwatr/nanolib/commit/e8402c481a14a1f807a37aaa862a936713d26176))
97
-
98
- ### 🧹 Miscellaneous Chores
99
-
100
- * remove duplicate sideEffects property from multiple package.json files ([b123f86](https://github.com/Alwatr/nanolib/commit/b123f86be81481de2314aae9bb2eeb629743d24c))
101
-
102
- ## [5.5.14](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.13...@alwatr/env@5.5.14) (2025-09-19)
103
-
104
- **Note:** Version bump only for package @alwatr/env
105
-
106
- ## [5.5.13](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.12...@alwatr/env@5.5.13) (2025-09-15)
107
-
108
- **Note:** Version bump only for package @alwatr/env
109
-
110
- ## [5.5.12](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.11...@alwatr/env@5.5.12) (2025-09-13)
111
-
112
- ### 🔗 Dependencies update
113
-
114
- * update @types/node version to ^22.18.3 in multiple package.json files ([13db6fc](https://github.com/Alwatr/nanolib/commit/13db6fc176bc6cdcefedc50d77ac550bd5052c9a))
115
-
116
- ## [5.5.11](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.10...@alwatr/env@5.5.11) (2025-09-13)
117
-
118
- ### 🧹 Miscellaneous Chores
119
-
120
- * remove package-tracer dependency and related code from fetch package ([96fe4e9](https://github.com/Alwatr/nanolib/commit/96fe4e9552a205f218ceed187c55e4e904a07089))
121
-
122
- ## [5.5.10](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.9...@alwatr/env@5.5.10) (2025-09-09)
123
-
124
- ### 🧹 Miscellaneous Chores
125
-
126
- * remove trailing newlines from contributing sections in README files ([e8ab1bc](https://github.com/Alwatr/nanolib/commit/e8ab1bc43e0addea5ccd4c897c2cec597cb9e15f))
127
-
128
- ## [5.5.9](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.8...@alwatr/env@5.5.9) (2025-09-06)
129
-
130
- **Note:** Version bump only for package @alwatr/env
131
-
132
- ## [5.5.8](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.7...@alwatr/env@5.5.8) (2025-09-05)
133
-
134
- ### 🔗 Dependencies update
135
-
136
- * update jest to version 30.1.3 and @types/node to version 22.18.1 ([754212b](https://github.com/Alwatr/nanolib/commit/754212b1523cfc4cfe26c9e9f6d634aa8311e0b7))
137
-
138
- ## [5.5.7](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.6...@alwatr/env@5.5.7) (2025-09-01)
139
-
140
- ### 🔗 Dependencies update
141
-
142
- * update lerna-lite dependencies to version 4.7.3 and jest to 30.1.2 ([95d7870](https://github.com/Alwatr/nanolib/commit/95d7870ec7ad1e6ed2688bafddcabf46857f6981))
143
-
144
- ## [5.5.6](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.5...@alwatr/env@5.5.6) (2025-08-23)
145
-
146
- **Note:** Version bump only for package @alwatr/env
147
-
148
- ## [5.5.5](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.3...@alwatr/env@5.5.5) (2025-08-23)
149
-
150
- ### 🐛 Bug Fixes
151
-
152
- * update license from AGPL-3.0-only to MPL-2.0 ([d20968e](https://github.com/Alwatr/nanolib/commit/d20968e60cc89b1dcdf9b96507178da6ed562f55))
153
- * update package versions in multiple package.json files ([7638b1c](https://github.com/Alwatr/nanolib/commit/7638b1cafee2b4e0f97db7a89ac9fba6384b9b10))
154
-
155
- ### 🔨 Code Refactoring
156
-
157
- * Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. ([db6a4f7](https://github.com/Alwatr/nanolib/commit/db6a4f76deec2d1d8039978144e4bc51b6f1a0e3))
158
-
159
- ### 🧹 Miscellaneous Chores
160
-
161
- * reformat all package.json files ([ceda45d](https://github.com/Alwatr/nanolib/commit/ceda45de186667790474f729cb4b161a5148ce19))
162
-
163
- ### 🔗 Dependencies update
164
-
165
- * revert @types/node version to ^22.17.2 (LTS) ([49f8101](https://github.com/Alwatr/nanolib/commit/49f8101eac5c41aa7684112f4308254dbfab9787))
166
- * update TypeScript and Jest versions across all packages to improve compatibility and performance ([31baf36](https://github.com/Alwatr/nanolib/commit/31baf366101e92e27db66a21c849fb101f19be47))
167
-
168
- ## [5.5.4](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.3...@alwatr/env@5.5.4) (2025-08-23)
169
-
170
- ### Code Refactoring
171
-
172
- * Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. ([db6a4f7](https://github.com/Alwatr/nanolib/commit/db6a4f76deec2d1d8039978144e4bc51b6f1a0e3)) by @alimd
173
-
174
- ## <small>5.5.3 (2025-04-15)</small>
175
-
176
- **Note:** Version bump only for package @alwatr/env
177
-
178
- ## [5.5.2](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.1...@alwatr/env@5.5.2) (2025-04-01)
179
-
180
- ### Dependencies update
181
-
182
- * bump the development-dependencies group across 1 directory with 2 updates ([c1320b4](https://github.com/Alwatr/nanolib/commit/c1320b447a492c5e720e25ad71e9df81eeea3670)) by @dependabot[bot]
183
-
184
- ## [5.5.1](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.5.0...@alwatr/env@5.5.1) (2025-03-18)
185
-
186
- ### Dependencies update
187
-
188
- * bump the development-dependencies group with 9 updates ([7290aa3](https://github.com/Alwatr/nanolib/commit/7290aa3b52ce66ca237d2a12d28a7687b113f83d)) by @dependabot[bot]
189
-
190
- ## [5.5.0](https://github.com/Alwatr/nanolib/compare/@alwatr/env@5.4.0...@alwatr/env@5.5.0) (2025-03-06)
191
-
192
- ### Miscellaneous Chores
193
-
194
- * update username casing in changelog entries ([9722ac9](https://github.com/Alwatr/nanolib/commit/9722ac9a078438a4e8ebfa5826ea70e0e3a52ca6)) by @
195
-
196
- ### Dependencies update
197
-
198
- * bump the development-dependencies group across 1 directory with 11 updates ([720c395](https://github.com/Alwatr/nanolib/commit/720c3954da55c929fe8fb16957121f4c51fb7f0c)) by @dependabot[bot]
199
-
200
- ## [5.4.0](https://github.com/Alwatr/nanolib/compare/@alwatr/env@1.0.1...@alwatr/env@5.4.0) (2025-02-18)
201
-
202
- ### Dependencies update
203
-
204
- * bump @types/node from ^22.13.0 to ^22.13.4 and prettier from 3.4.2 to 3.5.1; update eslint-import-resolver-typescript to 3.8.2 ([b9a8399](https://github.com/Alwatr/nanolib/commit/b9a8399add39509e90bfdc589fb5e2321718029d)) by @
205
-
206
- ## 5.3.0 (2025-02-03)
207
-
208
- ### Miscellaneous Chores
209
-
210
- * edit README ([3860b3d](https://github.com/Alwatr/nanolib/commit/3860b3df48ab82dc479d5236c2e8579df614aabf)) by @
211
-
212
- ### Dependencies update
213
-
214
- * bump the development-dependencies group across 1 directory with 11 updates ([cb79d07](https://github.com/Alwatr/nanolib/commit/cb79d072a57c79e1c01abff1a293d6757bb65350)) by @
215
- * update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages ([ddab05b](https://github.com/Alwatr/nanolib/commit/ddab05b5d767c30191f36a065e4bc88744e8e3fe)) by @
216
-
217
- ## 5.0.0 (2024-11-02)
218
-
219
- ### ⚠ BREAKING CHANGES
220
-
221
- * To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.
222
-
223
- ### Code Refactoring
224
-
225
- * use the same version as @alwatr/nanolib ([60eb860](https://github.com/Alwatr/nanolib/commit/60eb860a0e33dfffe2d1d95e63ce54c60876be06)) by @
226
-
227
- ## [5.3.0](https://github.com/Alwatr/nanolib/compare/v5.2.1...v5.3.0) (2025-02-03)
228
-
229
- ### Miscellaneous Chores
230
-
231
- * edit README ([3860b3d](https://github.com/Alwatr/nanolib/commit/3860b3df48ab82dc479d5236c2e8579df614aabf)) by @ArmanAsadian
232
-
233
- ### Dependencies update
234
-
235
- * bump the development-dependencies group across 1 directory with 11 updates ([cb79d07](https://github.com/Alwatr/nanolib/commit/cb79d072a57c79e1c01abff1a293d6757bb65350)) by @dependabot[bot]
236
- * update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages ([ddab05b](https://github.com/Alwatr/nanolib/commit/ddab05b5d767c30191f36a065e4bc88744e8e3fe)) by @alimd
237
-
238
- ## 5.0.0 (2024-11-02)
239
-
240
- ### ⚠ BREAKING CHANGES
241
-
242
- * To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.
243
-
244
- ### Bug Fixes
245
-
246
- * **env:** package.json path ([fff643d](https://github.com/Alwatr/nanolib/commit/fff643d949340e84509502e62b2587d03a47e034)) by @
247
-
248
- ### Code Refactoring
249
-
250
- * **env:** rename package and function ([6d72576](https://github.com/Alwatr/nanolib/commit/6d72576576964ba4bf3bdc5767e14d9293f941c9)) by @
251
- * use the same version as @alwatr/nanolib ([60eb860](https://github.com/Alwatr/nanolib/commit/60eb860a0e33dfffe2d1d95e63ce54c60876be06)) by @
252
-
253
- ### Dependencies update
254
-
255
- * bump the development-dependencies group across 1 directory with 2 updates ([2dfda9e](https://github.com/Alwatr/nanolib/commit/2dfda9ec38a595f1fd961490d1a2fbf060f20a66)) by @
256
- * update ([4434ba6](https://github.com/Alwatr/nanolib/commit/4434ba67c3f576bb1a0c307fbdb263c43cd9733a)) by @
257
-
258
- ## [1.0.1](https://github.com/Alwatr/nanolib/compare/@alwatr/env@1.0.0...@alwatr/env@1.0.1) (2024-11-02)
259
-
260
- ### Dependencies update
261
-
262
- * update ([4434ba6](https://github.com/Alwatr/nanolib/commit/4434ba67c3f576bb1a0c307fbdb263c43cd9733a)) by @alimd
263
-
264
- ## 1.0.0 (2024-10-25)
265
-
266
- ### Bug Fixes
267
-
268
- * **env:** package.json path ([fff643d](https://github.com/Alwatr/nanolib/commit/fff643d949340e84509502e62b2587d03a47e034)) by @alimd
269
-
270
- ### Code Refactoring
271
-
272
- * **env:** rename package and function ([6d72576](https://github.com/Alwatr/nanolib/commit/6d72576576964ba4bf3bdc5767e14d9293f941c9)) by @alimd
273
-
274
- ### Dependencies update
275
-
276
- * bump the development-dependencies group across 1 directory with 2 updates ([2dfda9e](https://github.com/Alwatr/nanolib/commit/2dfda9ec38a595f1fd961490d1a2fbf060f20a66)) by @dependabot[bot]
package/dist/main.cjs DELETED
@@ -1,3 +0,0 @@
1
- /** 📦 @alwatr/env v5.5.30 */
2
- "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var main_exports={};__export(main_exports,{getEnv:()=>getEnv});module.exports=__toCommonJS(main_exports);var import_platform_info=require("@alwatr/platform-info");function getEnv(option){let value=process.env[option.name];if(value==="")value=void 0;if(import_platform_info.platformInfo.development===true){value??=option.developmentValue??option.defaultValue}else{value??=option.defaultValue}if(value===void 0){throw new Error(`Environment variable "${option.name}" is required.`)}return value}0&&(module.exports={getEnv});
3
- //# sourceMappingURL=main.cjs.map
package/dist/main.cjs.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/main.ts"],
4
- "sourcesContent": ["import {platformInfo} from '@alwatr/platform-info';\n\n/**\n * Parameters for retrieving an environment variable value.\n */\nexport type GetEnvOption = {\n /**\n * The name of the environment variable.\n */\n name: string;\n\n /**\n * The default value to use if the environment variable is not set.\n * If not provided, the environment variable is required and an error will be thrown if it is not set.\n * Except in development mode, where the development value will be used instead if provided.\n */\n defaultValue?: string;\n\n /**\n * The value to use in a development environment.\n * It will be overwrite the default value in development mode and completely ignored in production mode.\n */\n developmentValue?: string;\n};\n\nexport function getEnv(option: GetEnvOption): string {\n let value = process.env[option.name];\n if (value === '') value = undefined; // empty string is considered as undefined in environment variables\n\n if (platformInfo.development === true) {\n value ??= option.developmentValue ?? option.defaultValue;\n }\n else {\n value ??= option.defaultValue;\n }\n\n if (value === undefined) {\n throw new Error(`Environment variable \"${option.name}\" is required.`);\n }\n\n return value;\n}\n"],
5
- "mappings": ";qqBAAA,kIAA2B,iCAyBpB,SAAS,OAAO,OAA8B,CACnD,IAAI,MAAQ,QAAQ,IAAI,OAAO,IAAI,EACnC,GAAI,QAAU,GAAI,MAAQ,OAE1B,GAAI,kCAAa,cAAgB,KAAM,CACrC,QAAU,OAAO,kBAAoB,OAAO,YAC9C,KACK,CACH,QAAU,OAAO,YACnB,CAEA,GAAI,QAAU,OAAW,CACvB,MAAM,IAAI,MAAM,yBAAyB,OAAO,IAAI,gBAAgB,CACtE,CAEA,OAAO,KACT",
6
- "names": []
7
- }
package/dist/main.mjs DELETED
@@ -1,3 +0,0 @@
1
- /** 📦 @alwatr/env v5.5.30 */
2
- import{platformInfo}from"@alwatr/platform-info";function getEnv(option){let value=process.env[option.name];if(value==="")value=void 0;if(platformInfo.development===true){value??=option.developmentValue??option.defaultValue}else{value??=option.defaultValue}if(value===void 0){throw new Error(`Environment variable "${option.name}" is required.`)}return value}export{getEnv};
3
- //# sourceMappingURL=main.mjs.map
package/dist/main.mjs.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/main.ts"],
4
- "sourcesContent": ["import {platformInfo} from '@alwatr/platform-info';\n\n/**\n * Parameters for retrieving an environment variable value.\n */\nexport type GetEnvOption = {\n /**\n * The name of the environment variable.\n */\n name: string;\n\n /**\n * The default value to use if the environment variable is not set.\n * If not provided, the environment variable is required and an error will be thrown if it is not set.\n * Except in development mode, where the development value will be used instead if provided.\n */\n defaultValue?: string;\n\n /**\n * The value to use in a development environment.\n * It will be overwrite the default value in development mode and completely ignored in production mode.\n */\n developmentValue?: string;\n};\n\nexport function getEnv(option: GetEnvOption): string {\n let value = process.env[option.name];\n if (value === '') value = undefined; // empty string is considered as undefined in environment variables\n\n if (platformInfo.development === true) {\n value ??= option.developmentValue ?? option.defaultValue;\n }\n else {\n value ??= option.defaultValue;\n }\n\n if (value === undefined) {\n throw new Error(`Environment variable \"${option.name}\" is required.`);\n }\n\n return value;\n}\n"],
5
- "mappings": ";AAAA,OAAQ,iBAAmB,wBAyBpB,SAAS,OAAO,OAA8B,CACnD,IAAI,MAAQ,QAAQ,IAAI,OAAO,IAAI,EACnC,GAAI,QAAU,GAAI,MAAQ,OAE1B,GAAI,aAAa,cAAgB,KAAM,CACrC,QAAU,OAAO,kBAAoB,OAAO,YAC9C,KACK,CACH,QAAU,OAAO,YACnB,CAEA,GAAI,QAAU,OAAW,CACvB,MAAM,IAAI,MAAM,yBAAyB,OAAO,IAAI,gBAAgB,CACtE,CAEA,OAAO,KACT",
6
- "names": []
7
- }