@nitra/check-env 4.0.0 → 4.1.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/README.md CHANGED
@@ -8,7 +8,7 @@ and that you did not leave dangerous development overrides in production.
8
8
  ## Installation
9
9
 
10
10
  ```bash
11
- yarn add @nitra/check-env
11
+ bun add @nitra/check-env
12
12
  ```
13
13
 
14
14
  ## Usage
@@ -31,6 +31,17 @@ If some required environment variable are not set, it will tell you and throw
31
31
  an error at the end:
32
32
  !["CLI output"](output.png)
33
33
 
34
+ ## SKIP_CHECK_ENV
35
+
36
+ If the `SKIP_CHECK_ENV` environment variable is set, the library will skip required variable checks and will not throw. This can be useful for local development or specific CI scenarios.
37
+
38
+ ```bash
39
+ SKIP_CHECK_ENV=1 bun node app.js
40
+ ```
41
+
42
+ - With `SKIP_CHECK_ENV` enabled, you'll see a warning in logs: `SKIP_CHECK_ENV is set, skipping environment variable check`.
43
+ - The exported `env` will behave like plain `process.env` (no proxy checks for prior validation).
44
+
34
45
  ## License
35
46
 
36
47
  [MIT](https://github.com/47ng/check-env/blob/master/LICENSE) - Made with ❤️ by [François Best](https://francoisbest.com)
package/package.json CHANGED
@@ -1,37 +1,37 @@
1
1
  {
2
2
  "name": "@nitra/check-env",
3
- "version": "4.0.0",
3
+ "version": "4.1.1",
4
4
  "description": "Check that the critical environment variables are set",
5
- "type": "module",
6
- "main": "./src/index.js",
7
- "types": "./types/index.d.ts",
8
- "exports": {
9
- ".": "./src/index.js"
10
- },
11
- "repository": {
12
- "type": "git",
13
- "url": "git+https://github.com/nitra/checkenv.git"
5
+ "keywords": [
6
+ "check-env",
7
+ "env",
8
+ "nitra"
9
+ ],
10
+ "bugs": {
11
+ "url": "https://github.com/nitra/check-env/issues"
14
12
  },
13
+ "license": "MIT",
15
14
  "author": {
16
15
  "name": "François Best",
17
16
  "email": "contact@francoisbest.com",
18
17
  "url": "https://francoisbest.com"
19
18
  },
20
- "license": "MIT",
21
- "bugs": {
22
- "url": "https://github.com/nitra/checkenv/issues"
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/nitra/check-env.git"
23
22
  },
24
- "keywords": [
25
- "env",
26
- "check-env",
27
- "nitra"
28
- ],
29
- "prettier": "@nitra/prettier-config",
30
23
  "files": [
31
24
  "src",
32
25
  "types"
33
26
  ],
27
+ "type": "module",
28
+ "main": "./src/index.js",
29
+ "types": "./types/index.d.ts",
30
+ "exports": {
31
+ ".": "./src/index.js"
32
+ },
34
33
  "dependencies": {
35
- "@nitra/pino": "^2.3.0"
36
- }
34
+ "@nitra/pino": "^2.12.0"
35
+ },
36
+ "prettier": "@nitra/prettier-config"
37
37
  }
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import process from 'node:process'
2
- import log from '@nitra/pino'
1
+ import { log } from '@nitra/pino'
2
+ import { env as pEnv } from 'node:process'
3
3
 
4
- const testEnv = name => !process.env[name]
4
+ const testEnv = name => !pEnv[name]
5
5
 
6
6
  const displayMissing = name => {
7
7
  log.error(`❌ Missing required environment variable ${name}`)
@@ -24,9 +24,15 @@ const checked = new Set()
24
24
  /**
25
25
  * Перевірка наявності змінних середовища
26
26
  * @function
27
- * @param {Array.<string>} required
27
+ * @param {Array.<string>} required - список обов'язкових змінних середовища
28
28
  */
29
29
  export const checkEnv = required => {
30
+ // Якщо змінна SKIP_CHECK_ENV встановлена, то пропускаємо перевірку
31
+ if (pEnv.SKIP_CHECK_ENV) {
32
+ log.warn('SKIP_CHECK_ENV is set, skipping environment variable check')
33
+ return
34
+ }
35
+
30
36
  const missingReq = []
31
37
 
32
38
  for (const name of required) {
@@ -52,11 +58,11 @@ export default checkEnv
52
58
 
53
59
  const envProxyHandler = {
54
60
  /**
55
- * Set colour of object
56
- * @param target
57
- * @param prop
58
- * @param _
59
- * @returns {string}
61
+ * Проксі-доступ до значень змінних середовища
62
+ * @param {object} target - об'єкт із змінними середовища
63
+ * @param {string} prop - назва змінної середовища
64
+ * @param {unknown} _ - не використовується
65
+ * @returns {string} - значення змінної середовища
60
66
  */
61
67
  get(target, prop, _) {
62
68
  // Якщо зі списку перевірених то повертаємо значення
@@ -70,6 +76,6 @@ const envProxyHandler = {
70
76
  }
71
77
 
72
78
  /**
73
- * @type {Object.<string, string>}
79
+ * @type {Record<string, string>}
74
80
  */
75
- export const env = new Proxy(process.env, envProxyHandler)
81
+ export const env = pEnv.SKIP_CHECK_ENV ? pEnv : new Proxy(pEnv, envProxyHandler) // Якщо змінна SKIP_CHECK_ENV встановлена, то пропускаємо перевірку
package/types/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * MissingEnvironmentVariableError
3
3
  *
4
4
  * @class
5
- * @extends Error
5
+ * @augments Error
6
6
  */
7
7
  export class MissingEnvironmentVariableError extends Error {
8
8
  constructor(envs: any);