@elementor/env 0.3.3 → 0.3.4
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/CHANGELOG.md +6 -0
- package/package.json +10 -3
- package/src/__tests__/index.test.ts +0 -104
- package/typedoc.config.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.3.4](https://github.com/elementor/elementor-packages/compare/@elementor/env@0.3.3...@elementor/env@0.3.4) (2024-08-05)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- publish only necessary files to npm ([#226](https://github.com/elementor/elementor-packages/issues/226)) ([d808e2f](https://github.com/elementor/elementor-packages/commit/d808e2f60eb7ca2d7b8560d0b79c0e62c2f969a8))
|
|
11
|
+
|
|
6
12
|
## [0.3.3](https://github.com/elementor/elementor-packages/compare/@elementor/env@0.3.2...@elementor/env@0.3.3) (2024-07-16)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @elementor/env
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/env",
|
|
3
3
|
"description": "Manage runtime environment variables in a type-safe way",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.4",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "https://github.com/elementor/elementor-packages.git",
|
|
22
|
+
"url": "git+https://github.com/elementor/elementor-packages.git",
|
|
23
23
|
"directory": "packages/libs/env"
|
|
24
24
|
},
|
|
25
25
|
"bugs": {
|
|
@@ -28,9 +28,16 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
+
"files": [
|
|
32
|
+
"README.md",
|
|
33
|
+
"CHANGELOG.md",
|
|
34
|
+
"/dist",
|
|
35
|
+
"/src",
|
|
36
|
+
"!**/__tests__"
|
|
37
|
+
],
|
|
31
38
|
"scripts": {
|
|
32
39
|
"build": "tsup --config=../../tsup.build.ts",
|
|
33
40
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
34
41
|
},
|
|
35
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "f4ca33da0842a29d83736d0a173633085edddaee"
|
|
36
43
|
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { initEnv, InvalidEnvError, parseEnv, __resetEnv } from '../index';
|
|
2
|
-
|
|
3
|
-
describe( '@elementor/env', () => {
|
|
4
|
-
it( 'should warn for non existing env key', () => {
|
|
5
|
-
// Arrange.
|
|
6
|
-
__resetEnv();
|
|
7
|
-
|
|
8
|
-
// Act.
|
|
9
|
-
const { env } = parseEnv( 'unknown-key' );
|
|
10
|
-
|
|
11
|
-
// Assert.
|
|
12
|
-
expect( env ).toEqual( {} );
|
|
13
|
-
expect( console ).toHaveWarned();
|
|
14
|
-
} );
|
|
15
|
-
|
|
16
|
-
it( 'should warn when the returned value is not an object', () => {
|
|
17
|
-
// Arrange.
|
|
18
|
-
initEnv( {
|
|
19
|
-
key: 'not-an-object' as unknown as object, // Emulate runtime error.
|
|
20
|
-
} );
|
|
21
|
-
|
|
22
|
-
// Act.
|
|
23
|
-
const { env } = parseEnv( 'key' );
|
|
24
|
-
|
|
25
|
-
// Assert.
|
|
26
|
-
expect( env ).toEqual( {} );
|
|
27
|
-
expect( console ).toHaveWarned();
|
|
28
|
-
} );
|
|
29
|
-
|
|
30
|
-
it( 'should validate the env data when passing a parsing function', () => {
|
|
31
|
-
// Arrange
|
|
32
|
-
initEnv( {
|
|
33
|
-
validEnv: {
|
|
34
|
-
test: 'value',
|
|
35
|
-
},
|
|
36
|
-
invalidEnv: {
|
|
37
|
-
test: 'value',
|
|
38
|
-
},
|
|
39
|
-
} );
|
|
40
|
-
|
|
41
|
-
// Act.
|
|
42
|
-
const { env: validEnv } = parseEnv( 'validEnv', ( envData ) => {
|
|
43
|
-
return envData as {
|
|
44
|
-
test: string;
|
|
45
|
-
};
|
|
46
|
-
} );
|
|
47
|
-
|
|
48
|
-
const { env: invalidEnv } = parseEnv( 'invalidEnv', () => {
|
|
49
|
-
throw new InvalidEnvError( 'error' );
|
|
50
|
-
} );
|
|
51
|
-
|
|
52
|
-
// Assert.
|
|
53
|
-
expect( validEnv ).toEqual( { test: 'value' } );
|
|
54
|
-
expect( invalidEnv ).toEqual( {} );
|
|
55
|
-
expect( console ).toHaveWarnedWith( 'invalidEnv - error' );
|
|
56
|
-
} );
|
|
57
|
-
|
|
58
|
-
it( 'should support a standalone validation', () => {
|
|
59
|
-
// Arrange
|
|
60
|
-
initEnv( {} );
|
|
61
|
-
|
|
62
|
-
// Act.
|
|
63
|
-
const { validateEnv } = parseEnv( 'unknown-key' );
|
|
64
|
-
|
|
65
|
-
validateEnv();
|
|
66
|
-
|
|
67
|
-
// Assert.
|
|
68
|
-
expect( console ).toHaveWarned();
|
|
69
|
-
} );
|
|
70
|
-
|
|
71
|
-
it( 'should support iterating over the env properties', () => {
|
|
72
|
-
// Arrange
|
|
73
|
-
initEnv( {
|
|
74
|
-
key: {
|
|
75
|
-
test: 'value',
|
|
76
|
-
},
|
|
77
|
-
} );
|
|
78
|
-
|
|
79
|
-
// Act.
|
|
80
|
-
const { env } = parseEnv( 'key' );
|
|
81
|
-
|
|
82
|
-
// Assert.
|
|
83
|
-
expect( Object.keys( env ) ).toEqual( [ 'test' ] );
|
|
84
|
-
} );
|
|
85
|
-
|
|
86
|
-
it( 'should throw any non-env errors from the parsing function', () => {
|
|
87
|
-
// Arrange
|
|
88
|
-
initEnv( {
|
|
89
|
-
key: {
|
|
90
|
-
test: 'value',
|
|
91
|
-
},
|
|
92
|
-
} );
|
|
93
|
-
|
|
94
|
-
// Act.
|
|
95
|
-
const { validateEnv } = parseEnv( 'key', () => {
|
|
96
|
-
throw new Error( 'custom-error' );
|
|
97
|
-
} );
|
|
98
|
-
|
|
99
|
-
// Assert.
|
|
100
|
-
expect( () => {
|
|
101
|
-
validateEnv();
|
|
102
|
-
} ).toThrowError( 'custom-error' );
|
|
103
|
-
} );
|
|
104
|
-
} );
|