@achs/env 4.11.0 → 5.0.0-alpha.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/CHANGELOG.md +31 -0
- package/README.md +98 -110
- package/arguments.d.ts +14 -14
- package/arguments.d.ts.map +1 -1
- package/arguments.js +135 -131
- package/arguments.js.map +1 -1
- package/commands/env.command.d.ts +8 -2
- package/commands/env.command.d.ts.map +1 -1
- package/commands/env.command.js +55 -82
- package/commands/env.command.js.map +1 -1
- package/commands/export.command.d.ts +8 -2
- package/commands/export.command.d.ts.map +1 -1
- package/commands/export.command.js +53 -62
- package/commands/export.command.js.map +1 -1
- package/commands/index.d.ts +5 -5
- package/commands/index.d.ts.map +1 -1
- package/commands/index.js +5 -14
- package/commands/pull.command.d.ts +6 -1
- package/commands/pull.command.d.ts.map +1 -1
- package/commands/pull.command.js +20 -37
- package/commands/pull.command.js.map +1 -1
- package/commands/push.command.d.ts +6 -1
- package/commands/push.command.d.ts.map +1 -1
- package/commands/push.command.js +20 -36
- package/commands/push.command.js.map +1 -1
- package/commands/schema.command.d.ts +6 -1
- package/commands/schema.command.d.ts.map +1 -1
- package/commands/schema.command.js +16 -17
- package/commands/schema.command.js.map +1 -1
- package/exec.d.ts +7 -1
- package/exec.d.ts.map +1 -1
- package/exec.js +84 -158
- package/exec.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.d.ts.map +1 -1
- package/index.js +3 -20
- package/interfaces/index.d.ts +1 -1
- package/interfaces/index.d.ts.map +1 -1
- package/interfaces/loader.interface.d.ts +29 -3
- package/interfaces/loader.interface.d.ts.map +1 -1
- package/main.d.ts +0 -1
- package/main.js +7 -26
- package/main.js.map +1 -1
- package/package.json +56 -35
- package/providers/app-settings.provider.d.ts +5 -2
- package/providers/app-settings.provider.d.ts.map +1 -1
- package/providers/app-settings.provider.js +36 -49
- package/providers/app-settings.provider.js.map +1 -1
- package/providers/azure-key-vault.provider.d.ts +12 -7
- package/providers/azure-key-vault.provider.d.ts.map +1 -1
- package/providers/azure-key-vault.provider.js +138 -158
- package/providers/azure-key-vault.provider.js.map +1 -1
- package/providers/index.d.ts +2 -2
- package/providers/index.d.ts.map +1 -1
- package/providers/index.js +18 -28
- package/providers/index.js.map +1 -1
- package/providers/local.provider.d.ts +5 -2
- package/providers/local.provider.d.ts.map +1 -1
- package/providers/local.provider.js +27 -40
- package/providers/local.provider.js.map +1 -1
- package/providers/package-json.provider.d.ts +5 -2
- package/providers/package-json.provider.d.ts.map +1 -1
- package/providers/package-json.provider.js +26 -28
- package/providers/package-json.provider.js.map +1 -1
- package/utils/argv.util.d.ts +10 -0
- package/utils/argv.util.d.ts.map +1 -0
- package/utils/argv.util.js +24 -0
- package/utils/argv.util.js.map +1 -0
- package/utils/command.util.d.ts +70 -3
- package/utils/command.util.d.ts.map +1 -1
- package/utils/command.util.js +60 -140
- package/utils/command.util.js.map +1 -1
- package/utils/index.d.ts +7 -6
- package/utils/index.d.ts.map +1 -1
- package/utils/index.js +8 -23
- package/utils/interpolate.util.d.ts +29 -1
- package/utils/interpolate.util.d.ts.map +1 -1
- package/utils/interpolate.util.js +12 -30
- package/utils/interpolate.util.js.map +1 -1
- package/utils/json.util.d.ts +41 -3
- package/utils/json.util.d.ts.map +1 -1
- package/utils/json.util.js +24 -42
- package/utils/json.util.js.map +1 -1
- package/utils/logger.d.ts +21 -2
- package/utils/logger.d.ts.map +1 -1
- package/utils/logger.js +31 -17
- package/utils/logger.js.map +1 -1
- package/utils/normalize.util.d.ts +24 -2
- package/utils/normalize.util.d.ts.map +1 -1
- package/utils/normalize.util.js +35 -56
- package/utils/normalize.util.js.map +1 -1
- package/utils/schema.util.d.ts +59 -0
- package/utils/schema.util.d.ts.map +1 -1
- package/utils/schema.util.js +62 -97
- package/utils/schema.util.js.map +1 -1
- package/commands/index.js.map +0 -1
- package/index.js.map +0 -1
- package/interfaces/index.js +0 -18
- package/interfaces/index.js.map +0 -1
- package/interfaces/loader.interface.js +0 -3
- package/interfaces/loader.interface.js.map +0 -1
- package/tsconfig.build.tsbuildinfo +0 -1
- package/utils/index.js.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## 5.0.0
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
- **ESM migration**: the package is now pure ESM (`"type": "module"`). CommonJS `require()` is no longer supported. Consumers must use ESM `import` syntax, and custom providers must be ESM modules with a `default` export.
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
- **tslog**: upgraded from v3 to v4 with updated logger API (`minLevel`, `maskValuesOfKeys`, `maskValuesRegEx`).
|
|
14
|
+
- **yargs**: upgraded to v18.
|
|
15
|
+
- **TypeScript**: upgraded to v6.
|
|
16
|
+
- **ajv**: upgraded to v8.20 with `ajv-formats` for format validators.
|
|
17
|
+
- **picocolors**: replaces `chalk` for lightweight terminal color output.
|
|
18
|
+
|
|
19
|
+
### Build & Testing
|
|
20
|
+
|
|
21
|
+
- **Vite**: adopted as the build tool replacing the previous tsc-based pipeline.
|
|
22
|
+
- **Vitest**: replaces Jest for unit and integration testing, with native ESM support.
|
|
23
|
+
- **100% unit coverage**: all source files covered (464 statements, 303 branches, 84 functions, 428 lines).
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
- **Child process exit-code propagation**: `env` command now correctly forwards non-zero exit codes from spawned subprocesses.
|
|
28
|
+
- **AKV `secretsFile` log typo**: corrected log message in Azure Key Vault provider.
|
|
29
|
+
- **AKV DNS check redesign**: DNS reachability check now uses `dns.Resolver` with public resolvers instead of a failing secret probe.
|
|
30
|
+
- **`normalize` leading-`$` strip**: keys starting with `$` are now correctly stripped to their base name (shared/global key convention).
|
|
31
|
+
- **Accurate flatten/normalize types**: improved TypeScript type accuracy for `flatAndValidateResults` and related utilities.
|
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
/>
|
|
26
26
|
|
|
27
27
|
<img
|
|
28
|
-
src="https://img.shields.io/badge/nodejs
|
|
28
|
+
src="https://img.shields.io/badge/nodejs->=20.0.0-darkgreen?style=flat-square"
|
|
29
29
|
alt="nodejs engine"
|
|
30
30
|
/>
|
|
31
31
|
|
|
@@ -49,16 +49,16 @@ Eases NodeJS <b>environment variable handling</b>, like [env-cmd](https://www.np
|
|
|
49
49
|
|
|
50
50
|
## 📌 **Requirements**
|
|
51
51
|
|
|
52
|
-
First, [download](https://nodejs.org/) and install **NodeJS**. Version `
|
|
52
|
+
First, [download](https://nodejs.org/) and install **NodeJS**. Version `20` or higher is required.
|
|
53
53
|
|
|
54
54
|
Validate installed versions of node and npm with:
|
|
55
55
|
|
|
56
56
|
```bash
|
|
57
57
|
> node -v
|
|
58
|
-
|
|
58
|
+
v20.0.0
|
|
59
59
|
|
|
60
60
|
> npm -v
|
|
61
|
-
|
|
61
|
+
10.0.0
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
You can initialize a new npm project using:
|
|
@@ -69,13 +69,29 @@ You can initialize a new npm project using:
|
|
|
69
69
|
|
|
70
70
|
<p align="right">(<a href="#top">back to top</a>)</p>
|
|
71
71
|
|
|
72
|
+
<!-- ESM NOTE -->
|
|
73
|
+
|
|
74
|
+
## 📦 **ESM only**
|
|
75
|
+
|
|
76
|
+
Starting from v5, this package is **ESM-only** (`"type": "module"`). Consumers must use ESM `import` syntax. Custom providers must also be ESM modules that export their provider object as the `default` export.
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
// ✅ ESM import
|
|
80
|
+
import { MyProvider } from '@achs/env';
|
|
81
|
+
|
|
82
|
+
// ❌ CommonJS require is not supported
|
|
83
|
+
// const { MyProvider } = require('@achs/env');
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
<p align="right">(<a href="#top">back to top</a>)</p>
|
|
87
|
+
|
|
72
88
|
<!-- QUICK START -->
|
|
73
89
|
|
|
74
90
|
## ⚡️ **Quick start**
|
|
75
91
|
|
|
76
|
-
> 🔔 Make sure that you have [NodeJS
|
|
92
|
+
> 🔔 Make sure that you have [NodeJS 20+](https://nodejs.org/) installed on your computer.
|
|
77
93
|
|
|
78
|
-
-
|
|
94
|
+
- Installs the package:
|
|
79
95
|
|
|
80
96
|
```bash
|
|
81
97
|
> npm install @achs/env
|
|
@@ -86,7 +102,7 @@ You can initialize a new npm project using:
|
|
|
86
102
|
> _
|
|
87
103
|
```
|
|
88
104
|
|
|
89
|
-
-
|
|
105
|
+
- Executes binary directly:
|
|
90
106
|
|
|
91
107
|
```bash
|
|
92
108
|
> node_modules/.bin/env --help
|
|
@@ -114,7 +130,7 @@ You can initialize a new npm project using:
|
|
|
114
130
|
> _
|
|
115
131
|
```
|
|
116
132
|
|
|
117
|
-
-
|
|
133
|
+
- Or add desired commands in your **npm script** in `package.json`:
|
|
118
134
|
|
|
119
135
|
```javascript
|
|
120
136
|
{
|
|
@@ -138,7 +154,7 @@ You can initialize a new npm project using:
|
|
|
138
154
|
}
|
|
139
155
|
```
|
|
140
156
|
|
|
141
|
-
-
|
|
157
|
+
- Execs your command:
|
|
142
158
|
|
|
143
159
|
**file**: _dist/main.js_
|
|
144
160
|
|
|
@@ -200,9 +216,8 @@ console.log(`My environment loaded is: ${process.env.ENV}`);
|
|
|
200
216
|
│ ├── exec.ts # initialization logic (load config, commands, etc.)
|
|
201
217
|
│ └── main.ts
|
|
202
218
|
├── tests/ # integration tests
|
|
203
|
-
├── .
|
|
204
|
-
├──
|
|
205
|
-
├── tsconfig.build.json
|
|
219
|
+
├── eslint.config.js
|
|
220
|
+
├── vite.config.ts # build (lib) + vitest (unit & integration)
|
|
206
221
|
└── tsconfig.json
|
|
207
222
|
```
|
|
208
223
|
|
|
@@ -224,45 +239,45 @@ _`[[root]]/config-file.[[env]].json`_ will be _`config/config-file.dev.json`_.
|
|
|
224
239
|
|
|
225
240
|
### Global options
|
|
226
241
|
|
|
227
|
-
| Option
|
|
242
|
+
| Option | Description | Type | Default | Required? |
|
|
228
243
|
| ---------------------------------- | ----------------------------------------------- | ---------- | ------- | --------- |
|
|
229
|
-
| `--help`
|
|
230
|
-
| `--e, --env`
|
|
231
|
-
| `-m, --modes`
|
|
232
|
-
| `--nd, --nestingDelimiter`
|
|
233
|
-
| `--arrDesc, --arrayDescomposition` | Whether serialize or break down arrays
|
|
234
|
-
| `-x, --expand`
|
|
235
|
-
| `-ci`
|
|
244
|
+
| `--help` | Shows help | `boolean` | | No |
|
|
245
|
+
| `--e, --env` | Environment for load | `string` | | Yes |
|
|
246
|
+
| `-m, --modes` | Execution modes | `string[]` | `[]` | No |
|
|
247
|
+
| `--nd, --nestingDelimiter` | Nesting level delimiter for flatten | `string` | `__` | No |
|
|
248
|
+
| `--arrDesc, --arrayDescomposition` | Whether serialize or break down arrays | `boolean` | `false` | No |
|
|
249
|
+
| `-x, --expand` | Interpolates environment variables using itself | `boolean` | `false` | No |
|
|
250
|
+
| `-ci` | Continuous Integration mode | `boolean` | `false` | No |
|
|
236
251
|
|
|
237
252
|
</br>
|
|
238
253
|
|
|
239
254
|
### Workspace options
|
|
240
255
|
|
|
241
|
-
| Option
|
|
256
|
+
| Option | Description | Type | Default | Required? |
|
|
242
257
|
| ------------------ | --------------------------------- | -------- | --------------------------------- | --------- |
|
|
243
|
-
| `--root`
|
|
244
|
-
| `-c, --configFile` | Config JSON file path
|
|
245
|
-
| `-s, --schemaFile` | Environment Schema JSON file path | `string` | `[[root]]/settings/schema.json` | No
|
|
258
|
+
| `--root` | Default environment folder path | `string` | `env` | No |
|
|
259
|
+
| `-c, --configFile` | Config JSON file path | `string` | `[[root]]/settings/settings.json` | No |
|
|
260
|
+
| `-s, --schemaFile` | Environment Schema JSON file path | `string` | `[[root]]/settings/schema.json` | No |
|
|
246
261
|
|
|
247
262
|
### JSON Schema options
|
|
248
263
|
|
|
249
|
-
| Option
|
|
264
|
+
| Option | Description | Type | Default | Required? |
|
|
250
265
|
| ---------------------- | ---------------------------------------------------------- | ----------------- | ------- | --------- |
|
|
251
|
-
| `-r, --resolve`
|
|
252
|
-
| `--null, --nullable` | Whether variables are nullable by default
|
|
253
|
-
| `--df, --detectFormat` | Whether format of strings variables are included in schema | `boolean`
|
|
266
|
+
| `-r, --resolve` | Whether merges new schema or override | `merge, override` | `merge` | No |
|
|
267
|
+
| `--null, --nullable` | Whether variables are nullable by default | `boolean` | `true` | No |
|
|
268
|
+
| `--df, --detectFormat` | Whether format of strings variables are included in schema | `boolean` | `false` | No |
|
|
254
269
|
|
|
255
270
|
### Logger options
|
|
256
271
|
|
|
257
|
-
| Option
|
|
272
|
+
| Option | Description | Type | Default | Required? |
|
|
258
273
|
| ------------------- | ----------- | ---------------------------------------- | ------- | --------- |
|
|
259
|
-
| `--log, --logLevel` | Log level | `silly, trace, debug, info, warn, error` | `info` | No
|
|
274
|
+
| `--log, --logLevel` | Log level | `silly, trace, debug, info, warn, error` | `info` | No |
|
|
260
275
|
|
|
261
276
|
<div align="center">
|
|
262
277
|
<span style="font-size:20px;font-weight:bold" align="center">Commands</span>
|
|
263
278
|
</div>
|
|
264
279
|
|
|
265
|
-
-
|
|
280
|
+
- ## **`env`**
|
|
266
281
|
|
|
267
282
|
Inject your environment variables into `process.env` and executes a command.
|
|
268
283
|
|
|
@@ -284,7 +299,7 @@ Examples:
|
|
|
284
299
|
> env -e prod -m build optimize : npm build
|
|
285
300
|
```
|
|
286
301
|
|
|
287
|
-
-
|
|
302
|
+
- ## **`pull`**
|
|
288
303
|
|
|
289
304
|
Pulls environment variables from providers stores.
|
|
290
305
|
|
|
@@ -292,9 +307,9 @@ Pulls environment variables from providers stores.
|
|
|
292
307
|
env pull -e [env] [options..]
|
|
293
308
|
```
|
|
294
309
|
|
|
295
|
-
| Option
|
|
310
|
+
| Option | Description | Type | Default | Required? |
|
|
296
311
|
| ----------------- | ------------------------- | --------- | ------- | --------- |
|
|
297
|
-
| `-o, --overwrite` | Overwrite local variables | `boolean` | `false` | No
|
|
312
|
+
| `-o, --overwrite` | Overwrite local variables | `boolean` | `false` | No |
|
|
298
313
|
|
|
299
314
|
Examples:
|
|
300
315
|
|
|
@@ -302,7 +317,7 @@ Examples:
|
|
|
302
317
|
> env pull -e dev
|
|
303
318
|
```
|
|
304
319
|
|
|
305
|
-
-
|
|
320
|
+
- ## **`push`**
|
|
306
321
|
|
|
307
322
|
Pushes environment variables to providers stores.
|
|
308
323
|
|
|
@@ -310,9 +325,9 @@ Pushes environment variables to providers stores.
|
|
|
310
325
|
env push -e [env] [options..]
|
|
311
326
|
```
|
|
312
327
|
|
|
313
|
-
| Option
|
|
328
|
+
| Option | Description | Type | Default | Required? |
|
|
314
329
|
| ------------- | ------------------------------------ | --------- | ------- | --------- |
|
|
315
|
-
| `-f, --force` | Force push for secrets (replace all) | `boolean` | `false` | No
|
|
330
|
+
| `-f, --force` | Force push for secrets (replace all) | `boolean` | `false` | No |
|
|
316
331
|
|
|
317
332
|
Examples:
|
|
318
333
|
|
|
@@ -320,7 +335,7 @@ Examples:
|
|
|
320
335
|
> env push -e dev
|
|
321
336
|
```
|
|
322
337
|
|
|
323
|
-
-
|
|
338
|
+
- ## **`schema`**
|
|
324
339
|
|
|
325
340
|
Generates validation schema from providers output variables.
|
|
326
341
|
|
|
@@ -334,7 +349,7 @@ Examples:
|
|
|
334
349
|
> env schema -e dev -m build
|
|
335
350
|
```
|
|
336
351
|
|
|
337
|
-
-
|
|
352
|
+
- ## **`export`**
|
|
338
353
|
|
|
339
354
|
Export unified environment variables to a file from providers.
|
|
340
355
|
|
|
@@ -342,10 +357,10 @@ Export unified environment variables to a file from providers.
|
|
|
342
357
|
env export -e [env] -m [modes] [options..]
|
|
343
358
|
```
|
|
344
359
|
|
|
345
|
-
| Option
|
|
360
|
+
| Option | Description | Type | Default | Required? |
|
|
346
361
|
| --------------- | ---------------------------------- | -------- | -------- | --------- |
|
|
347
|
-
| `-u, -p, --uri` | Uri for export file with variables | `string` | `.env` | No
|
|
348
|
-
| `-f, --format` | Format for export variables
|
|
362
|
+
| `-u, -p, --uri` | Uri for export file with variables | `string` | `.env` | No |
|
|
363
|
+
| `-f, --format` | Format for export variables | `string` | `dotenv` | No |
|
|
349
364
|
|
|
350
365
|
Examples:
|
|
351
366
|
|
|
@@ -362,7 +377,7 @@ Examples:
|
|
|
362
377
|
Main feature of this library is using providers for get and set environment variables.
|
|
363
378
|
So, you can define your own provider, but lib came with 3 integrated providers:
|
|
364
379
|
|
|
365
|
-
-
|
|
380
|
+
- ## **`package-json`**
|
|
366
381
|
|
|
367
382
|
Load some info from your project `package.json`.
|
|
368
383
|
|
|
@@ -378,9 +393,9 @@ Info read is:
|
|
|
378
393
|
}
|
|
379
394
|
```
|
|
380
395
|
|
|
381
|
-
| Option
|
|
396
|
+
| Option | Description | Type | Default | Required? |
|
|
382
397
|
| ------------------- | --------------------------- | -------- | ------- | --------- |
|
|
383
|
-
| `--vp, --varPrefix` | Prefix for loaded variables | `string` | `""`
|
|
398
|
+
| `--vp, --varPrefix` | Prefix for loaded variables | `string` | `""` | No |
|
|
384
399
|
|
|
385
400
|
Examples:
|
|
386
401
|
|
|
@@ -390,7 +405,7 @@ Examples:
|
|
|
390
405
|
|
|
391
406
|
</br>
|
|
392
407
|
|
|
393
|
-
-
|
|
408
|
+
- ## **`app-settings`**
|
|
394
409
|
|
|
395
410
|
Non secrets loader for `appsettings.json`.
|
|
396
411
|
|
|
@@ -441,55 +456,26 @@ In example:
|
|
|
441
456
|
}
|
|
442
457
|
```
|
|
443
458
|
|
|
444
|
-
| Option
|
|
445
|
-
|
|
|
446
|
-
| `--ef, --envFile`
|
|
447
|
-
| `--sp, --sectionPrefix` | Prefix for env and modes in env file | `string` | `::` | No |
|
|
448
|
-
|
|
449
|
-
</br>
|
|
450
|
-
|
|
451
|
-
- ## **`package-json`**
|
|
452
|
-
|
|
453
|
-
Load some info from your project `package.json`.
|
|
454
|
-
|
|
455
|
-
Info read is:
|
|
456
|
-
|
|
457
|
-
```json
|
|
458
|
-
{
|
|
459
|
-
"version": "1.0.0",
|
|
460
|
-
"project": "project-name",
|
|
461
|
-
"name": "@package-name",
|
|
462
|
-
"title": "app-name",
|
|
463
|
-
"description": "any description"
|
|
464
|
-
}
|
|
465
|
-
```
|
|
466
|
-
|
|
467
|
-
| Option | Description | Type | Default | Required? |
|
|
468
|
-
| ------------------- | --------------------------- | -------- | ------- | --------- |
|
|
469
|
-
| `--vp, --varPrefix` | Prefix for loaded variables | `string` | `""` | No |
|
|
470
|
-
|
|
471
|
-
Examples:
|
|
472
|
-
|
|
473
|
-
```bash
|
|
474
|
-
> env -e dev -m build : react-script build : --vp REACT_APP_
|
|
475
|
-
```
|
|
459
|
+
| Option | Description | Type | Default | Required? |
|
|
460
|
+
| ----------------- | ------------------------------- | -------- | --------------------------- | --------- |
|
|
461
|
+
| `--ef, --envFile` | Environment variables file path | `string` | `[[root]]/appsettings.json` | No |
|
|
476
462
|
|
|
477
|
-
-
|
|
463
|
+
- ## **`azure-key-vault`**
|
|
478
464
|
|
|
479
465
|
Azure Key Vault provider, allows to load secrets from vault store to `env/secrets/[[env]].env.json` per environment.
|
|
480
466
|
Also, handles `env/secrets/[[env]].local.env.json` for load local variables with precedence over base.
|
|
481
467
|
|
|
482
|
-
| Option
|
|
468
|
+
| Option | Description | Type | Default | Required? |
|
|
483
469
|
| --------------------------------------- | ---------------------------------------------- | ---------- | ----------------------------------------- | --------- |
|
|
484
|
-
| `--secretFolder`
|
|
485
|
-
| `--secretFile`
|
|
486
|
-
| `--localSecretFile`
|
|
487
|
-
| `-k, --keys, --keysFile`
|
|
488
|
-
| `--url, --vaultUrl`
|
|
489
|
-
| `--spn, --clientId, --id`
|
|
490
|
-
| `-p --password, --pass, --clientSecret` | SPN Client Secret Password
|
|
491
|
-
| `-t, --tenant`
|
|
492
|
-
| `--mock`
|
|
470
|
+
| `--secretFolder` | Secret variables folder path | `string` | `[[root]]/secrets` | No |
|
|
471
|
+
| `--secretFile` | Secret variables file path | `string` | `[[secretFolder]]/[[env]].env.json` | No |
|
|
472
|
+
| `--localSecretFile` | Local secret variables file path | `string` | `[[secretFolder]]/[[env]].local.env.json` | No |
|
|
473
|
+
| `-k, --keys, --keysFile` | Azure Key Vault SPN credentials files paths | `string[]` | `['../keys.json', '[[root]]/keys.json']` | No |
|
|
474
|
+
| `--url, --vaultUrl` | Azure Key Vault server URL | `string` | | Yes |
|
|
475
|
+
| `--spn, --clientId, --id` | SPN Client ID | `string` | | Yes |
|
|
476
|
+
| `-p --password, --pass, --clientSecret` | SPN Client Secret Password | `string` | | Yes |
|
|
477
|
+
| `-t, --tenant` | Azure Tenant ID | `string` | | Yes |
|
|
478
|
+
| `--mock` | Mocks Azure Key Vault client (testing purpose) | `string` | `false` | No |
|
|
493
479
|
|
|
494
480
|
<p align="right">(<a href="#top">back to top</a>)</p>
|
|
495
481
|
|
|
@@ -499,8 +485,8 @@ Also, handles `env/secrets/[[env]].local.env.json` for load local variables with
|
|
|
499
485
|
|
|
500
486
|
You can create your custom providers, in two ways:
|
|
501
487
|
|
|
502
|
-
-
|
|
503
|
-
-
|
|
488
|
+
- **Local Script**: you must create a JavaScript file (.js), exporting by default your "provider" following standard interface exported by this lib.
|
|
489
|
+
- **NPM Package**: you must create your custom NPM library and export by default your "provider" using standard interface exported by this lib.
|
|
504
490
|
|
|
505
491
|
How to load your provider is shown in Config Section.
|
|
506
492
|
|
|
@@ -632,8 +618,8 @@ Allows you to store your secrets in Azure Key Vault.
|
|
|
632
618
|
|
|
633
619
|
For load desired environment, add you npm script like **`env -e <env> -m <mode1[ mode2]> : <your-command>`**.
|
|
634
620
|
|
|
635
|
-
-
|
|
636
|
-
-
|
|
621
|
+
- **mode**: (build|debug|test) execution mode base variables.
|
|
622
|
+
- **env**: (dev|qa|stg|prod) environment variables.
|
|
637
623
|
|
|
638
624
|
_In example: `env -e dev -m debug : npm start`_
|
|
639
625
|
|
|
@@ -643,12 +629,12 @@ _In example: `env -e dev -m debug : npm start`_
|
|
|
643
629
|
|
|
644
630
|
Your `env/secrets` folder will contain files below:
|
|
645
631
|
|
|
646
|
-
-
|
|
647
|
-
-
|
|
648
|
-
-
|
|
649
|
-
-
|
|
650
|
-
-
|
|
651
|
-
-
|
|
632
|
+
- **dev.env.json**: development environment.
|
|
633
|
+
- **dev.local.env.json**: local development environment (takes precedence).
|
|
634
|
+
- **qa.env.json**: quality assurance environment.
|
|
635
|
+
- **qa.local.env.json**: local qa environment (takes precedence).
|
|
636
|
+
- **prod.env.json**: production environment.
|
|
637
|
+
- **prod.local.env.json**: local production environment (takes precedence).
|
|
652
638
|
|
|
653
639
|
_This folder should contains environment variables files for system environments._
|
|
654
640
|
|
|
@@ -694,8 +680,8 @@ _This file allows to load environment files locally first run time._
|
|
|
694
680
|
You can use two command scripts for refresh your local env files
|
|
695
681
|
or publish/updates env files in the azure key vault from your local files.
|
|
696
682
|
|
|
697
|
-
-
|
|
698
|
-
-
|
|
683
|
+
- **Pulls Secrets File**: `env pull -e <env> [-o]`. (-o forces to replace your local file).
|
|
684
|
+
- **Pushes/Publishes Secrets File**: `env push -e <env>`.
|
|
699
685
|
|
|
700
686
|
#### 3.1. Environment Variables for Credentials
|
|
701
687
|
|
|
@@ -778,8 +764,8 @@ const mySharedNestedVar2 = process.env.GROUP1__SHARED;
|
|
|
778
764
|
|
|
779
765
|
### From lowest to highest.
|
|
780
766
|
|
|
781
|
-
-
|
|
782
|
-
-
|
|
767
|
+
- `(dev|qa|prod).env.json`
|
|
768
|
+
- `(dev|qa|prod).local.env.json` (takes precedence over previous)
|
|
783
769
|
|
|
784
770
|
<p align="right">(<a href="#top">back to top</a>)</p>
|
|
785
771
|
|
|
@@ -789,7 +775,7 @@ const mySharedNestedVar2 = process.env.GROUP1__SHARED;
|
|
|
789
775
|
|
|
790
776
|
Project uses ESLint, for code formatting and code styling normalizing.
|
|
791
777
|
|
|
792
|
-
-
|
|
778
|
+
- **eslint**: linter integrated with TypeScript.
|
|
793
779
|
|
|
794
780
|
For correct interpretation of linters, is recommended to use [Visual Studio Code](https://code.visualstudio.com/) as IDE and install the plugins in .vscode folder at 'extensions.json', as well as use the config provided in 'settings.json'
|
|
795
781
|
|
|
@@ -807,12 +793,14 @@ For last changes see [CHANGELOG.md](CHANGELOG.md) file for details.
|
|
|
807
793
|
|
|
808
794
|
## 🛠️ Built with
|
|
809
795
|
|
|
810
|
-
-
|
|
811
|
-
-
|
|
812
|
-
-
|
|
813
|
-
-
|
|
814
|
-
-
|
|
815
|
-
-
|
|
796
|
+
- [yargs](http://yargs.js.org/)
|
|
797
|
+
- [tslog v4](https://tslog.js.org/#/)
|
|
798
|
+
- [subslate](https://github.com/josh-hemphill/subslate)
|
|
799
|
+
- [merge-deep](https://github.com/jonschlinkert/merge-deep)
|
|
800
|
+
- [ajv](https://ajv.js.org/)
|
|
801
|
+
- [to-json-schema](https://www.npmjs.com/package/to-json-schema)
|
|
802
|
+
- [Vite](https://vitejs.dev/) (build)
|
|
803
|
+
- [Vitest](https://vitest.dev/) (testing)
|
|
816
804
|
|
|
817
805
|
<p align="right">(<a href="#top">back to top</a>)</p>
|
|
818
806
|
|
package/arguments.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { JSONSchemaType } from 'ajv';
|
|
2
2
|
import { Arguments, Options } from 'yargs';
|
|
3
|
-
import { EnvProviderConfig } from './interfaces';
|
|
3
|
+
import { EnvProviderConfig } from './interfaces/index.js';
|
|
4
4
|
export interface CommandArguments extends Arguments {
|
|
5
|
+
arrayDescomposition: boolean;
|
|
6
|
+
ci: boolean;
|
|
7
|
+
configFile: string;
|
|
8
|
+
detectFormat: boolean;
|
|
5
9
|
env: string;
|
|
6
|
-
|
|
10
|
+
expand: boolean;
|
|
11
|
+
nestingDelimiter: string;
|
|
12
|
+
nullable: boolean;
|
|
13
|
+
packageJson: string;
|
|
7
14
|
projectInfo: Record<string, string>;
|
|
8
|
-
schema?: Record<string, JSONSchemaType<object>>;
|
|
9
15
|
providers: EnvProviderConfig[];
|
|
10
|
-
|
|
11
|
-
nestingDelimiter: string;
|
|
12
|
-
arrayDescomposition: boolean;
|
|
13
|
-
expand: boolean;
|
|
16
|
+
resolve: 'merge' | 'override';
|
|
14
17
|
root: string;
|
|
15
|
-
configFile: string;
|
|
16
18
|
schemaFile: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
nullable: boolean;
|
|
20
|
-
detectFormat: boolean;
|
|
21
|
-
logLevel?: 'silly' | 'trace' | 'debug' | 'info' | 'warn' | 'error';
|
|
19
|
+
exportIgnoreKeys?: string[];
|
|
20
|
+
logLevel?: 'debug' | 'error' | 'info' | 'silly' | 'trace' | 'warn';
|
|
22
21
|
logMaskAnyRegEx?: string[];
|
|
23
22
|
logMaskValuesOfKeys?: string[];
|
|
24
|
-
|
|
23
|
+
modes?: string[];
|
|
24
|
+
schema?: Record<string, JSONSchemaType<object>>;
|
|
25
25
|
}
|
|
26
26
|
export declare const args: Record<keyof CommandArguments, Options>;
|
|
27
27
|
//# sourceMappingURL=arguments.d.ts.map
|
package/arguments.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arguments.d.ts","sourceRoot":"","sources":["../src/arguments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"arguments.d.ts","sourceRoot":"","sources":["../src/arguments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAS/D,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IAClD,mBAAmB,EAAE,OAAO,CAAC;IAC7B,EAAE,EAAE,OAAO,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAC/B,OAAO,EAAE,OAAO,GAAG,UAAU,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;IACnE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;CAChD;AAGD,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,gBAAgB,EAAE,OAAO,CAuHxD,CAAC"}
|