@achs/env 3.0.0 → 3.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/.eslintignore +3 -0
- package/.eslintrc.json +329 -0
- package/.vscode/extensions.json +18 -0
- package/.vscode/launch.json +30 -0
- package/.vscode/settings.json +29 -0
- package/CHANGELOG.md +4 -0
- package/jest.config.json +28 -0
- package/package.json +16 -16
- package/{arguments.js → src/arguments.ts} +32 -8
- package/src/commands/env.command.ts +139 -0
- package/src/commands/export.command.ts +88 -0
- package/{commands/index.d.ts → src/commands/index.ts} +0 -1
- package/src/commands/pull.command.ts +52 -0
- package/src/commands/push.command.ts +48 -0
- package/src/commands/schema.command.ts +31 -0
- package/src/exec.ts +221 -0
- package/{index.d.ts → src/index.ts} +0 -1
- package/{interfaces/index.d.ts → src/interfaces/index.ts} +0 -1
- package/src/interfaces/loader.interface.ts +66 -0
- package/src/main.ts +6 -0
- package/src/providers/app-settings.provider.ts +67 -0
- package/src/providers/azure-key-vault.provider.ts +277 -0
- package/src/providers/index.ts +29 -0
- package/src/providers/local.provider.ts +44 -0
- package/src/providers/package-json.provider.ts +39 -0
- package/src/utils/command.util.ts +223 -0
- package/{utils/index.d.ts → src/utils/index.ts} +0 -1
- package/src/utils/interpolate.util.ts +65 -0
- package/src/utils/json.util.ts +116 -0
- package/{utils/logger.js → src/utils/logger.ts} +6 -6
- package/src/utils/normalize.util.ts +142 -0
- package/src/utils/schema.util.ts +191 -0
- package/tests/env/appsettings.json +32 -0
- package/tests/env/dev.env.json +12 -0
- package/tests/env/dev.local.env.json +9 -0
- package/tests/env/env.schema.json +225 -0
- package/tests/env/keys.json +7 -0
- package/tests/env/settings/schema.json +239 -0
- package/tests/env/settings/settings.json +22 -0
- package/tests/env.int.test.ts +42 -0
- package/tests/exec.ts +19 -0
- package/tests/export.int.test.ts +9 -0
- package/tests/pull-push.int.test.ts +15 -0
- package/tests/run.js +32 -0
- package/tests/schema.int.test.ts +9 -0
- package/tests/setup.ts +13 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +37 -0
- package/arguments.d.ts +0 -25
- package/arguments.d.ts.map +0 -1
- package/arguments.js.map +0 -1
- package/commands/env.command.d.ts +0 -8
- package/commands/env.command.d.ts.map +0 -1
- package/commands/env.command.js +0 -85
- package/commands/env.command.js.map +0 -1
- package/commands/export.command.d.ts +0 -8
- package/commands/export.command.d.ts.map +0 -1
- package/commands/export.command.js +0 -54
- package/commands/export.command.js.map +0 -1
- package/commands/index.d.ts.map +0 -1
- package/commands/index.js +0 -14
- package/commands/index.js.map +0 -1
- package/commands/pull.command.d.ts +0 -7
- package/commands/pull.command.d.ts.map +0 -1
- package/commands/pull.command.js +0 -39
- package/commands/pull.command.js.map +0 -1
- package/commands/push.command.d.ts +0 -7
- package/commands/push.command.d.ts.map +0 -1
- package/commands/push.command.js +0 -38
- package/commands/push.command.js.map +0 -1
- package/commands/schema.command.d.ts +0 -4
- package/commands/schema.command.d.ts.map +0 -1
- package/commands/schema.command.js +0 -18
- package/commands/schema.command.js.map +0 -1
- package/exec.d.ts +0 -3
- package/exec.d.ts.map +0 -1
- package/exec.js +0 -142
- package/exec.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/index.js +0 -20
- package/index.js.map +0 -1
- package/interfaces/index.d.ts.map +0 -1
- package/interfaces/index.js +0 -18
- package/interfaces/index.js.map +0 -1
- package/interfaces/loader.interface.d.ts +0 -21
- package/interfaces/loader.interface.d.ts.map +0 -1
- package/interfaces/loader.interface.js +0 -3
- package/interfaces/loader.interface.js.map +0 -1
- package/main.d.ts +0 -3
- package/main.d.ts.map +0 -1
- package/main.js +0 -6
- package/main.js.map +0 -1
- package/providers/app-settings.provider.d.ts +0 -8
- package/providers/app-settings.provider.d.ts.map +0 -1
- package/providers/app-settings.provider.js +0 -50
- package/providers/app-settings.provider.js.map +0 -1
- package/providers/azure-key-vault.provider.d.ts +0 -20
- package/providers/azure-key-vault.provider.d.ts.map +0 -1
- package/providers/azure-key-vault.provider.js +0 -143
- package/providers/azure-key-vault.provider.js.map +0 -1
- package/providers/index.d.ts +0 -7
- package/providers/index.d.ts.map +0 -1
- package/providers/index.js +0 -30
- package/providers/index.js.map +0 -1
- package/providers/local.provider.d.ts +0 -8
- package/providers/local.provider.d.ts.map +0 -1
- package/providers/local.provider.js +0 -31
- package/providers/local.provider.js.map +0 -1
- package/providers/package-json.provider.d.ts +0 -8
- package/providers/package-json.provider.d.ts.map +0 -1
- package/providers/package-json.provider.js +0 -29
- package/providers/package-json.provider.js.map +0 -1
- package/tsconfig.build.tsbuildinfo +0 -1
- package/utils/command.util.d.ts +0 -13
- package/utils/command.util.d.ts.map +0 -1
- package/utils/command.util.js +0 -134
- package/utils/command.util.js.map +0 -1
- package/utils/index.d.ts.map +0 -1
- package/utils/index.js +0 -23
- package/utils/index.js.map +0 -1
- package/utils/interpolate.util.d.ts +0 -4
- package/utils/interpolate.util.d.ts.map +0 -1
- package/utils/interpolate.util.js +0 -33
- package/utils/interpolate.util.js.map +0 -1
- package/utils/json.util.d.ts +0 -5
- package/utils/json.util.d.ts.map +0 -1
- package/utils/json.util.js +0 -48
- package/utils/json.util.js.map +0 -1
- package/utils/logger.d.ts +0 -3
- package/utils/logger.d.ts.map +0 -1
- package/utils/logger.js.map +0 -1
- package/utils/normalize.util.d.ts +0 -3
- package/utils/normalize.util.d.ts.map +0 -1
- package/utils/normalize.util.js +0 -61
- package/utils/normalize.util.js.map +0 -1
- package/utils/schema.util.d.ts +0 -11
- package/utils/schema.util.d.ts.map +0 -1
- package/utils/schema.util.js +0 -100
- package/utils/schema.util.js.map +0 -1
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
{
|
|
2
|
+
"package-json": {
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"ENV": {
|
|
6
|
+
"type": [
|
|
7
|
+
"string"
|
|
8
|
+
],
|
|
9
|
+
"nullable": true
|
|
10
|
+
},
|
|
11
|
+
"VERSION": {
|
|
12
|
+
"type": [
|
|
13
|
+
"string"
|
|
14
|
+
],
|
|
15
|
+
"nullable": true
|
|
16
|
+
},
|
|
17
|
+
"PROJECT": {
|
|
18
|
+
"type": [
|
|
19
|
+
"string"
|
|
20
|
+
],
|
|
21
|
+
"nullable": true
|
|
22
|
+
},
|
|
23
|
+
"NAME": {
|
|
24
|
+
"type": [
|
|
25
|
+
"string"
|
|
26
|
+
],
|
|
27
|
+
"nullable": true
|
|
28
|
+
},
|
|
29
|
+
"TITLE": {
|
|
30
|
+
"type": [
|
|
31
|
+
"string"
|
|
32
|
+
],
|
|
33
|
+
"nullable": true
|
|
34
|
+
},
|
|
35
|
+
"DESCRIPTION": {
|
|
36
|
+
"type": [
|
|
37
|
+
"string"
|
|
38
|
+
],
|
|
39
|
+
"nullable": true
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"app-settings": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"properties": {
|
|
46
|
+
"VAR1": {
|
|
47
|
+
"type": [
|
|
48
|
+
"string"
|
|
49
|
+
],
|
|
50
|
+
"nullable": true
|
|
51
|
+
},
|
|
52
|
+
"C1": {
|
|
53
|
+
"type": [
|
|
54
|
+
"string"
|
|
55
|
+
],
|
|
56
|
+
"nullable": true
|
|
57
|
+
},
|
|
58
|
+
"C2": {
|
|
59
|
+
"type": [
|
|
60
|
+
"string"
|
|
61
|
+
],
|
|
62
|
+
"nullable": true
|
|
63
|
+
},
|
|
64
|
+
"C3": {
|
|
65
|
+
"type": [
|
|
66
|
+
"integer"
|
|
67
|
+
],
|
|
68
|
+
"nullable": true
|
|
69
|
+
},
|
|
70
|
+
"GROUP1": {
|
|
71
|
+
"type": [
|
|
72
|
+
"object"
|
|
73
|
+
],
|
|
74
|
+
"properties": {
|
|
75
|
+
"VAR1": {
|
|
76
|
+
"type": [
|
|
77
|
+
"null"
|
|
78
|
+
],
|
|
79
|
+
"nullable": true
|
|
80
|
+
},
|
|
81
|
+
"VAR2": {
|
|
82
|
+
"type": [
|
|
83
|
+
"string"
|
|
84
|
+
],
|
|
85
|
+
"nullable": true
|
|
86
|
+
},
|
|
87
|
+
"VAR3": {
|
|
88
|
+
"type": [
|
|
89
|
+
"boolean"
|
|
90
|
+
],
|
|
91
|
+
"nullable": true
|
|
92
|
+
},
|
|
93
|
+
"GROUP2": {
|
|
94
|
+
"type": [
|
|
95
|
+
"object"
|
|
96
|
+
],
|
|
97
|
+
"properties": {
|
|
98
|
+
"VAR1": {
|
|
99
|
+
"type": [
|
|
100
|
+
"string"
|
|
101
|
+
],
|
|
102
|
+
"nullable": true
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"nullable": true
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"nullable": true
|
|
109
|
+
},
|
|
110
|
+
"C4": {
|
|
111
|
+
"type": [
|
|
112
|
+
"string"
|
|
113
|
+
],
|
|
114
|
+
"format": "utc-millisec",
|
|
115
|
+
"nullable": true
|
|
116
|
+
},
|
|
117
|
+
"NODE_ENV": {
|
|
118
|
+
"type": [
|
|
119
|
+
"string"
|
|
120
|
+
],
|
|
121
|
+
"nullable": true
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"azure-key-vault": {
|
|
126
|
+
"type": "object",
|
|
127
|
+
"properties": {
|
|
128
|
+
"VAR1": {
|
|
129
|
+
"type": [
|
|
130
|
+
"boolean"
|
|
131
|
+
],
|
|
132
|
+
"nullable": true
|
|
133
|
+
},
|
|
134
|
+
"VAR2": {
|
|
135
|
+
"type": [
|
|
136
|
+
"boolean"
|
|
137
|
+
],
|
|
138
|
+
"nullable": true
|
|
139
|
+
},
|
|
140
|
+
"VAR3": {
|
|
141
|
+
"type": [
|
|
142
|
+
"integer"
|
|
143
|
+
],
|
|
144
|
+
"nullable": true
|
|
145
|
+
},
|
|
146
|
+
"VAR4": {
|
|
147
|
+
"type": [
|
|
148
|
+
"string"
|
|
149
|
+
],
|
|
150
|
+
"nullable": true
|
|
151
|
+
},
|
|
152
|
+
"ARR1": {
|
|
153
|
+
"type": [
|
|
154
|
+
"array"
|
|
155
|
+
],
|
|
156
|
+
"nullable": true
|
|
157
|
+
},
|
|
158
|
+
"GROUP2": {
|
|
159
|
+
"type": [
|
|
160
|
+
"object"
|
|
161
|
+
],
|
|
162
|
+
"properties": {
|
|
163
|
+
"VAR1": {
|
|
164
|
+
"type": [
|
|
165
|
+
"string"
|
|
166
|
+
],
|
|
167
|
+
"nullable": true
|
|
168
|
+
},
|
|
169
|
+
"VAR2": {
|
|
170
|
+
"type": [
|
|
171
|
+
"string"
|
|
172
|
+
],
|
|
173
|
+
"nullable": true
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"nullable": true
|
|
177
|
+
},
|
|
178
|
+
"$SECRET": {
|
|
179
|
+
"type": [
|
|
180
|
+
"string"
|
|
181
|
+
],
|
|
182
|
+
"nullable": true
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"local": {
|
|
187
|
+
"type": "object",
|
|
188
|
+
"properties": {
|
|
189
|
+
"VAR4": {
|
|
190
|
+
"type": [
|
|
191
|
+
"string"
|
|
192
|
+
],
|
|
193
|
+
"nullable": true
|
|
194
|
+
},
|
|
195
|
+
"GROUP1": {
|
|
196
|
+
"type": [
|
|
197
|
+
"object"
|
|
198
|
+
],
|
|
199
|
+
"properties": {
|
|
200
|
+
"VAR1": {
|
|
201
|
+
"type": [
|
|
202
|
+
"null"
|
|
203
|
+
],
|
|
204
|
+
"nullable": true
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
"nullable": true
|
|
208
|
+
},
|
|
209
|
+
"GROUP2": {
|
|
210
|
+
"type": [
|
|
211
|
+
"object"
|
|
212
|
+
],
|
|
213
|
+
"properties": {
|
|
214
|
+
"VAR2": {
|
|
215
|
+
"type": [
|
|
216
|
+
"string"
|
|
217
|
+
],
|
|
218
|
+
"nullable": true
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
"nullable": true
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
{
|
|
2
|
+
"package-json": {
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"ENV": {
|
|
6
|
+
"type": [
|
|
7
|
+
"string"
|
|
8
|
+
],
|
|
9
|
+
"nullable": true
|
|
10
|
+
},
|
|
11
|
+
"VERSION": {
|
|
12
|
+
"type": [
|
|
13
|
+
"string"
|
|
14
|
+
],
|
|
15
|
+
"nullable": true
|
|
16
|
+
},
|
|
17
|
+
"PROJECT": {
|
|
18
|
+
"type": [
|
|
19
|
+
"string"
|
|
20
|
+
],
|
|
21
|
+
"nullable": true
|
|
22
|
+
},
|
|
23
|
+
"NAME": {
|
|
24
|
+
"type": [
|
|
25
|
+
"string"
|
|
26
|
+
],
|
|
27
|
+
"nullable": true
|
|
28
|
+
},
|
|
29
|
+
"TITLE": {
|
|
30
|
+
"type": [
|
|
31
|
+
"string"
|
|
32
|
+
],
|
|
33
|
+
"nullable": true
|
|
34
|
+
},
|
|
35
|
+
"DESCRIPTION": {
|
|
36
|
+
"type": [
|
|
37
|
+
"string"
|
|
38
|
+
],
|
|
39
|
+
"nullable": true
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"app-settings": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"properties": {
|
|
46
|
+
"VAR1": {
|
|
47
|
+
"type": [
|
|
48
|
+
"string"
|
|
49
|
+
],
|
|
50
|
+
"nullable": true
|
|
51
|
+
},
|
|
52
|
+
"C1": {
|
|
53
|
+
"type": [
|
|
54
|
+
"string"
|
|
55
|
+
],
|
|
56
|
+
"nullable": true
|
|
57
|
+
},
|
|
58
|
+
"C2": {
|
|
59
|
+
"type": [
|
|
60
|
+
"string"
|
|
61
|
+
],
|
|
62
|
+
"nullable": true
|
|
63
|
+
},
|
|
64
|
+
"C3": {
|
|
65
|
+
"type": [
|
|
66
|
+
"integer"
|
|
67
|
+
],
|
|
68
|
+
"nullable": true
|
|
69
|
+
},
|
|
70
|
+
"GROUP1": {
|
|
71
|
+
"type": [
|
|
72
|
+
"object"
|
|
73
|
+
],
|
|
74
|
+
"properties": {
|
|
75
|
+
"VAR1": {
|
|
76
|
+
"type": [
|
|
77
|
+
"null"
|
|
78
|
+
],
|
|
79
|
+
"nullable": true
|
|
80
|
+
},
|
|
81
|
+
"VAR2": {
|
|
82
|
+
"type": [
|
|
83
|
+
"string"
|
|
84
|
+
],
|
|
85
|
+
"nullable": true
|
|
86
|
+
},
|
|
87
|
+
"VAR3": {
|
|
88
|
+
"type": [
|
|
89
|
+
"boolean"
|
|
90
|
+
],
|
|
91
|
+
"nullable": true
|
|
92
|
+
},
|
|
93
|
+
"GROUP2": {
|
|
94
|
+
"type": [
|
|
95
|
+
"object"
|
|
96
|
+
],
|
|
97
|
+
"properties": {
|
|
98
|
+
"VAR1": {
|
|
99
|
+
"type": [
|
|
100
|
+
"string"
|
|
101
|
+
],
|
|
102
|
+
"nullable": true
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"nullable": true
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"nullable": true
|
|
109
|
+
},
|
|
110
|
+
"C4": {
|
|
111
|
+
"type": [
|
|
112
|
+
"string"
|
|
113
|
+
],
|
|
114
|
+
"format": "utc-millisec",
|
|
115
|
+
"nullable": true
|
|
116
|
+
},
|
|
117
|
+
"NODE_ENV": {
|
|
118
|
+
"type": [
|
|
119
|
+
"string"
|
|
120
|
+
],
|
|
121
|
+
"nullable": true
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"azure-key-vault": {
|
|
126
|
+
"type": "object",
|
|
127
|
+
"properties": {
|
|
128
|
+
"VAR1": {
|
|
129
|
+
"type": [
|
|
130
|
+
"boolean"
|
|
131
|
+
],
|
|
132
|
+
"nullable": true
|
|
133
|
+
},
|
|
134
|
+
"VAR2": {
|
|
135
|
+
"type": [
|
|
136
|
+
"boolean"
|
|
137
|
+
],
|
|
138
|
+
"nullable": true
|
|
139
|
+
},
|
|
140
|
+
"VAR3": {
|
|
141
|
+
"type": [
|
|
142
|
+
"integer"
|
|
143
|
+
],
|
|
144
|
+
"nullable": true
|
|
145
|
+
},
|
|
146
|
+
"VAR4": {
|
|
147
|
+
"type": [
|
|
148
|
+
"string"
|
|
149
|
+
],
|
|
150
|
+
"nullable": true
|
|
151
|
+
},
|
|
152
|
+
"ARR1": {
|
|
153
|
+
"type": [
|
|
154
|
+
"array"
|
|
155
|
+
],
|
|
156
|
+
"nullable": true
|
|
157
|
+
},
|
|
158
|
+
"GROUP2": {
|
|
159
|
+
"type": [
|
|
160
|
+
"object"
|
|
161
|
+
],
|
|
162
|
+
"properties": {
|
|
163
|
+
"VAR1": {
|
|
164
|
+
"type": [
|
|
165
|
+
"string"
|
|
166
|
+
],
|
|
167
|
+
"nullable": true
|
|
168
|
+
},
|
|
169
|
+
"VAR2": {
|
|
170
|
+
"type": [
|
|
171
|
+
"string"
|
|
172
|
+
],
|
|
173
|
+
"nullable": true
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"nullable": true
|
|
177
|
+
},
|
|
178
|
+
"$SECRET": {
|
|
179
|
+
"type": [
|
|
180
|
+
"string"
|
|
181
|
+
],
|
|
182
|
+
"nullable": true
|
|
183
|
+
},
|
|
184
|
+
"GROUP1": {
|
|
185
|
+
"type": [
|
|
186
|
+
"object"
|
|
187
|
+
],
|
|
188
|
+
"properties": {
|
|
189
|
+
"VAR1": {
|
|
190
|
+
"type": [
|
|
191
|
+
"null"
|
|
192
|
+
],
|
|
193
|
+
"nullable": true
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
"nullable": true
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
"local": {
|
|
201
|
+
"type": "object",
|
|
202
|
+
"properties": {
|
|
203
|
+
"VAR4": {
|
|
204
|
+
"type": [
|
|
205
|
+
"string"
|
|
206
|
+
],
|
|
207
|
+
"nullable": true
|
|
208
|
+
},
|
|
209
|
+
"GROUP1": {
|
|
210
|
+
"type": [
|
|
211
|
+
"object"
|
|
212
|
+
],
|
|
213
|
+
"properties": {
|
|
214
|
+
"VAR1": {
|
|
215
|
+
"type": [
|
|
216
|
+
"null"
|
|
217
|
+
],
|
|
218
|
+
"nullable": true
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
"nullable": true
|
|
222
|
+
},
|
|
223
|
+
"GROUP2": {
|
|
224
|
+
"type": [
|
|
225
|
+
"object"
|
|
226
|
+
],
|
|
227
|
+
"properties": {
|
|
228
|
+
"VAR2": {
|
|
229
|
+
"type": [
|
|
230
|
+
"string"
|
|
231
|
+
],
|
|
232
|
+
"nullable": true
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
"nullable": true
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"logMaskValuesOfKeys": ["SECRET"],
|
|
3
|
+
"providers": [
|
|
4
|
+
{
|
|
5
|
+
"path": "package-json"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"path": "app-settings"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"path": "azure-key-vault",
|
|
12
|
+
"config": {
|
|
13
|
+
"dev": {
|
|
14
|
+
"vaultUrl": "https://azure.vault.net"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"path": "local"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { execEnv, execDebugEnv } from './exec';
|
|
2
|
+
|
|
3
|
+
const subcmd = ': node tests/run.js';
|
|
4
|
+
|
|
5
|
+
describe('env command', () => {
|
|
6
|
+
test('show helps', () => {
|
|
7
|
+
const response = execEnv('--help');
|
|
8
|
+
|
|
9
|
+
expect(response).toMatch(/usage: env/i);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('load env into run.js', () => {
|
|
13
|
+
const response = execEnv('-e dev', '--m debug', subcmd);
|
|
14
|
+
|
|
15
|
+
expect(response).not.toMatch(/error/i);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('load env without modes into run.js', () => {
|
|
19
|
+
const response = execEnv('-e dev', ': node tests/run.js');
|
|
20
|
+
|
|
21
|
+
expect(response).not.toMatch(/error/i);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('load env with two modes into run.js', () => {
|
|
25
|
+
const response = execEnv('-e dev', '--m debug build', subcmd);
|
|
26
|
+
|
|
27
|
+
expect(response).not.toMatch(/error/i);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('load env with options after subcmd', () => {
|
|
31
|
+
const response = execEnv('-e dev', subcmd, ': -m debug');
|
|
32
|
+
|
|
33
|
+
expect(response).not.toMatch(/error/i);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('logger must not show SECRET variable value', () => {
|
|
37
|
+
const response = execDebugEnv('-e dev', subcmd);
|
|
38
|
+
|
|
39
|
+
expect(response).not.toMatch(/error/i);
|
|
40
|
+
expect(response).not.toMatch(/any secret/i);
|
|
41
|
+
});
|
|
42
|
+
});
|
package/tests/exec.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
|
|
3
|
+
const CMD = 'node dist/main.js';
|
|
4
|
+
|
|
5
|
+
const BASE_ARGS = ['--root tests/env', '--mock'];
|
|
6
|
+
|
|
7
|
+
export const execEnv = (...args: string[]): string | undefined => {
|
|
8
|
+
return execSync(
|
|
9
|
+
`${CMD} ${[...BASE_ARGS, '--log error', ...args].join(' ')}`
|
|
10
|
+
)?.toString();
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const execDebugEnv = (...args: string[]): string | undefined => {
|
|
14
|
+
return execSync(
|
|
15
|
+
`${CMD} ${[...BASE_ARGS, '--log debug', ...args].join(' ')}`
|
|
16
|
+
)?.toString();
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { execSync as exec } from 'child_process';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { execEnv } from './exec';
|
|
2
|
+
|
|
3
|
+
describe('pull & push commands', () => {
|
|
4
|
+
test('pull', () => {
|
|
5
|
+
const response = execEnv('pull', '-e dev');
|
|
6
|
+
|
|
7
|
+
expect(response).not.toMatch(/error/i);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('push', () => {
|
|
11
|
+
const response = execEnv('push', '-e dev');
|
|
12
|
+
|
|
13
|
+
expect(response).not.toMatch(/error/i);
|
|
14
|
+
});
|
|
15
|
+
});
|
package/tests/run.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function validateEnv(...vars) {
|
|
2
|
+
for(const key of vars) {
|
|
3
|
+
if(!process.env[key])
|
|
4
|
+
{
|
|
5
|
+
throw new Error(`${key} dont loaded`);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
validateEnv(
|
|
11
|
+
'NODE_ENV',
|
|
12
|
+
'ENV',
|
|
13
|
+
'VERSION',
|
|
14
|
+
'PROJECT',
|
|
15
|
+
'NAME',
|
|
16
|
+
'TITLE',
|
|
17
|
+
'DESCRIPTION',
|
|
18
|
+
'VAR1',
|
|
19
|
+
'C1',
|
|
20
|
+
'C2',
|
|
21
|
+
'C3',
|
|
22
|
+
'C4',
|
|
23
|
+
'GROUP1__VAR2',
|
|
24
|
+
'GROUP1__VAR3',
|
|
25
|
+
'GROUP1__GROUP2__VAR1',
|
|
26
|
+
'VAR2',
|
|
27
|
+
'VAR3',
|
|
28
|
+
'VAR4',
|
|
29
|
+
'ARR1',
|
|
30
|
+
'GROUP2__VAR1',
|
|
31
|
+
'GROUP2__VAR2'
|
|
32
|
+
);
|
package/tests/setup.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { exec, execEnv } from './exec';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Builds app and regenerates schema.
|
|
5
|
+
*/
|
|
6
|
+
function setup(): void {
|
|
7
|
+
// builds application
|
|
8
|
+
exec('npm run build');
|
|
9
|
+
// generates schema from environment variables
|
|
10
|
+
execEnv('schema', '-e dev', '-m debug');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default setup;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": "src",
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
|
|
6
|
+
"target": "es2018",
|
|
7
|
+
"module": "commonjs",
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
|
|
11
|
+
"allowJs": false,
|
|
12
|
+
"checkJs": false,
|
|
13
|
+
|
|
14
|
+
"experimentalDecorators": true,
|
|
15
|
+
"emitDecoratorMetadata": true,
|
|
16
|
+
|
|
17
|
+
"incremental": true,
|
|
18
|
+
"sourceMap": true,
|
|
19
|
+
"declaration": true,
|
|
20
|
+
"declarationMap": true,
|
|
21
|
+
"removeComments": true,
|
|
22
|
+
|
|
23
|
+
"isolatedModules": true,
|
|
24
|
+
"esModuleInterop": true,
|
|
25
|
+
"importHelpers": false,
|
|
26
|
+
"skipLibCheck": false,
|
|
27
|
+
"downlevelIteration": false,
|
|
28
|
+
|
|
29
|
+
"strict": true,
|
|
30
|
+
"strictPropertyInitialization": false,
|
|
31
|
+
"noFallthroughCasesInSwitch": false,
|
|
32
|
+
"noUnusedLocals": false,
|
|
33
|
+
"noUnusedParameters": false,
|
|
34
|
+
"exactOptionalPropertyTypes": false
|
|
35
|
+
},
|
|
36
|
+
"include": ["src/**/*", "tests/**/*", "**/*.spec.ts", "**/*.test.ts"]
|
|
37
|
+
}
|