@adonisjs/env 4.1.4-0 → 4.1.5-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.
|
@@ -1 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
export declare const E_INVALID_ENV_VARIABLES: {
|
|
3
|
+
new (message?: string | undefined, options?: (ErrorOptions & {
|
|
4
|
+
code?: string | undefined;
|
|
5
|
+
status?: number | undefined;
|
|
6
|
+
}) | undefined): {
|
|
7
|
+
help: string;
|
|
8
|
+
name: string;
|
|
9
|
+
code?: string | undefined;
|
|
10
|
+
status: number;
|
|
11
|
+
toString(): string;
|
|
12
|
+
readonly [Symbol.toStringTag]: string;
|
|
13
|
+
message: string;
|
|
14
|
+
stack?: string | undefined;
|
|
15
|
+
cause?: unknown;
|
|
16
|
+
};
|
|
17
|
+
message: string;
|
|
18
|
+
code: string;
|
|
19
|
+
help?: string | undefined;
|
|
20
|
+
status?: number | undefined;
|
|
21
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
22
|
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
23
|
+
stackTraceLimit: number;
|
|
24
|
+
};
|
package/build/src/exceptions.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const E_INVALID_ENV_VARIABLES =
|
|
1
|
+
import { Exception } from '@poppinss/utils';
|
|
2
|
+
export const E_INVALID_ENV_VARIABLES = class EnvValidationException extends Exception {
|
|
3
|
+
static message = 'Validation failed for one or more environment variables';
|
|
4
|
+
static code = 'E_INVALID_ENV_VARIABLES';
|
|
5
|
+
help = '';
|
|
6
|
+
};
|
package/build/src/validator.js
CHANGED
|
@@ -7,19 +7,19 @@ export class EnvValidator {
|
|
|
7
7
|
this.#error = new E_INVALID_ENV_VARIABLES();
|
|
8
8
|
}
|
|
9
9
|
validate(values) {
|
|
10
|
-
const
|
|
10
|
+
const help = [];
|
|
11
11
|
const validated = Object.keys(this.#schema).reduce((result, key) => {
|
|
12
12
|
const value = process.env[key] || values[key];
|
|
13
13
|
try {
|
|
14
14
|
result[key] = this.#schema[key](key, value);
|
|
15
15
|
}
|
|
16
16
|
catch (error) {
|
|
17
|
-
|
|
17
|
+
help.push(`- ${error.message}`);
|
|
18
18
|
}
|
|
19
19
|
return result;
|
|
20
20
|
}, { ...values });
|
|
21
|
-
if (
|
|
22
|
-
this.#error.
|
|
21
|
+
if (help.length) {
|
|
22
|
+
this.#error.help = help.join('\n');
|
|
23
23
|
throw this.#error;
|
|
24
24
|
}
|
|
25
25
|
return validated;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/env",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.5-0",
|
|
4
4
|
"description": "Environment variable manager for Node.js",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"@japa/runner": "^2.2.2",
|
|
42
42
|
"@japa/spec-reporter": "^1.3.2",
|
|
43
43
|
"@poppinss/dev-utils": "^2.0.3",
|
|
44
|
-
"@swc/core": "^1.3.
|
|
44
|
+
"@swc/core": "^1.3.32",
|
|
45
45
|
"@types/fs-extra": "^11.0.1",
|
|
46
46
|
"@types/node": "^18.11.18",
|
|
47
47
|
"c8": "^7.12.0",
|
|
48
48
|
"cross-env": "^7.0.3",
|
|
49
49
|
"del-cli": "^5.0.0",
|
|
50
|
-
"eslint": "^8.
|
|
50
|
+
"eslint": "^8.33.0",
|
|
51
51
|
"eslint-config-prettier": "^8.6.0",
|
|
52
52
|
"eslint-plugin-adonis": "^3.0.3",
|
|
53
53
|
"eslint-plugin-prettier": "^4.2.1",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"np": "^7.6.3",
|
|
58
58
|
"prettier": "^2.8.3",
|
|
59
59
|
"ts-node": "^10.9.1",
|
|
60
|
-
"typescript": "^4.9.
|
|
60
|
+
"typescript": "^4.9.5"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@poppinss/utils": "^6.5.0-0",
|