@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 CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  > Environment variable parsing using Dotenv & Typebox
4
4
 
5
+ ## Warning ⚠️
6
+
7
+ From v2 this library is shipped in ESM. If your project is setup in CJS you must use v1.
8
+
5
9
  ## Install
6
10
 
7
11
  ```shell
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import 'dotenv/config';
2
- import { Static, TSchema } from '@sinclair/typebox';
2
+ import { type Static, type TSchema } from '@sinclair/typebox';
3
3
  export declare const envious: <T extends TSchema>(schema: T) => Static<T>;
package/dist/index.js CHANGED
@@ -1,15 +1,9 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.envious = void 0;
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(os_1.default.EOL));
20
+ throw new Error(errorTextParts.join(Os.EOL));
27
21
  }
28
- return value_1.Value.Cast({
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":";;;;;;AAAA,yBAAuB;AACvB,4CAAoB;AAEpB,mDAAgD;AAEzC,MAAM,OAAO,GAAG,CAAoB,MAAS,EAAa,EAAE;IAC/D,MAAM,MAAM,GAAG,aAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,CAAC,GAAG,aAAK,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,YAAE,C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,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.7",
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 --module commonjs",
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
@@ -6,8 +6,9 @@
6
6
  },
7
7
  "compilerOptions": {
8
8
  "outDir": "dist",
9
- "target": "esnext",
10
- "moduleResolution": "node",
9
+ "target": "ESNext",
10
+ "module": "NodeNext",
11
+ "moduleResolution": "NodeNext",
11
12
  "declaration": true,
12
13
  "sourceMap": true,
13
14
  "strict": true,