@pitininja/envious 1.0.7 → 1.1.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 +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -15
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/index.ts +1 -1
- package/tsconfig.json +3 -2
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
require("dotenv/config");
|
|
8
|
-
const os_1 = __importDefault(require("os"));
|
|
9
|
-
const value_1 = require("@sinclair/typebox/value");
|
|
10
|
-
const envious = (schema) => {
|
|
11
|
-
const parsed = value_1.Value.Convert(schema, process.env);
|
|
12
|
-
const errors = [...value_1.Value.Errors(schema, parsed)];
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import Os from 'os';
|
|
3
|
+
import { Value } from '@sinclair/typebox/value';
|
|
4
|
+
export const envious = (schema) => {
|
|
5
|
+
const parsed = Value.Convert(schema, process.env);
|
|
6
|
+
const errors = [...Value.Errors(schema, parsed)];
|
|
13
7
|
if (errors.length) {
|
|
14
8
|
const computedErrorMessages = {};
|
|
15
9
|
errors.forEach(({ path, message }) => {
|
|
@@ -23,12 +17,11 @@ const envious = (schema) => {
|
|
|
23
17
|
'Invalid environment variables',
|
|
24
18
|
...Object.entries(computedErrorMessages).map(([varName, messages]) => ` ${varName} : ${messages.join(', ')}`)
|
|
25
19
|
];
|
|
26
|
-
throw new Error(errorTextParts.join(
|
|
20
|
+
throw new Error(errorTextParts.join(Os.EOL));
|
|
27
21
|
}
|
|
28
|
-
return
|
|
22
|
+
return Value.Cast({
|
|
29
23
|
...schema,
|
|
30
24
|
additionalProperties: false
|
|
31
25
|
}, parsed);
|
|
32
26
|
};
|
|
33
|
-
exports.envious = envious;
|
|
34
27
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAoB,MAAS,EAAa,EAAE;IAC/D,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAChB,MAAM,qBAAqB,GAA6B,EAAE,CAAC;QAC3D,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;YACjC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC3C,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,EAAE,CAAC;gBACrC,qBAAqB,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;YAC3C,CAAC;YACD,qBAAqB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;QACH,MAAM,cAAc,GAAa;YAC7B,+BAA+B;YAC/B,GAAG,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,GAAG,CACxC,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,KAAK,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACnE;SACJ,CAAC;QACF,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CACb;QACI,GAAG,MAAM;QACT,oBAAoB,EAAE,KAAK;KAC9B,EACD,MAAM,CACT,CAAC;AACN,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pitininja/envious",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "AGPL-3.0-or-later",
|
|
5
5
|
"homepage": "https://github.com/pitininja/envious",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/pitininja/envious"
|
|
9
9
|
},
|
|
10
|
+
"type": "module",
|
|
10
11
|
"scripts": {
|
|
11
12
|
"prepare": "[ -d '.husky' ] && husky || true",
|
|
12
|
-
"build": "tsc --build --clean tsconfig.json && tsc --
|
|
13
|
+
"build": "tsc --build --clean tsconfig.json && tsc --project tsconfig.json",
|
|
13
14
|
"lint": "npx eslint . --ext=.js,.ts --max-warnings=0 && npx prettier --check . && npx tsc --noEmit",
|
|
14
15
|
"format": "npx eslint . --fix --ext=.js,.ts --max-warnings=0 && npx prettier --write . && npx tsc --noEmit"
|
|
15
16
|
},
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'dotenv/config';
|
|
2
2
|
import Os from 'os';
|
|
3
|
-
import { Static, TSchema } from '@sinclair/typebox';
|
|
3
|
+
import { type Static, type TSchema } from '@sinclair/typebox';
|
|
4
4
|
import { Value } from '@sinclair/typebox/value';
|
|
5
5
|
|
|
6
6
|
export const envious = <T extends TSchema>(schema: T): Static<T> => {
|
package/tsconfig.json
CHANGED