@achs/env 4.0.0 → 4.1.1

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.
Files changed (54) hide show
  1. package/arguments.d.ts +25 -25
  2. package/arguments.js +125 -125
  3. package/commands/env.command.d.ts +7 -7
  4. package/commands/env.command.js +78 -78
  5. package/commands/export.command.d.ts +7 -7
  6. package/commands/export.command.js +53 -53
  7. package/commands/index.d.ts +5 -5
  8. package/commands/index.js +13 -13
  9. package/commands/pull.command.d.ts +6 -6
  10. package/commands/pull.command.js +38 -38
  11. package/commands/push.command.d.ts +6 -6
  12. package/commands/push.command.js +37 -37
  13. package/commands/schema.command.d.ts +3 -3
  14. package/commands/schema.command.js +18 -18
  15. package/exec.d.ts +2 -2
  16. package/exec.js +145 -146
  17. package/exec.js.map +1 -1
  18. package/index.d.ts +3 -3
  19. package/index.js +19 -19
  20. package/interfaces/index.d.ts +1 -1
  21. package/interfaces/index.js +17 -17
  22. package/interfaces/loader.interface.d.ts +20 -20
  23. package/interfaces/loader.interface.js +2 -2
  24. package/main.d.ts +2 -2
  25. package/main.js +5 -5
  26. package/package.json +12 -13
  27. package/providers/app-settings.provider.d.ts +7 -7
  28. package/providers/app-settings.provider.d.ts.map +1 -1
  29. package/providers/app-settings.provider.js +51 -47
  30. package/providers/app-settings.provider.js.map +1 -1
  31. package/providers/azure-key-vault.provider.d.ts +19 -19
  32. package/providers/azure-key-vault.provider.js +148 -148
  33. package/providers/index.d.ts +6 -6
  34. package/providers/index.js +29 -29
  35. package/providers/local.provider.d.ts +7 -7
  36. package/providers/local.provider.js +41 -41
  37. package/providers/package-json.provider.d.ts +7 -7
  38. package/providers/package-json.provider.js +29 -29
  39. package/tsconfig.build.tsbuildinfo +1 -1
  40. package/utils/command.util.d.ts +12 -12
  41. package/utils/command.util.js +134 -135
  42. package/utils/command.util.js.map +1 -1
  43. package/utils/index.d.ts +6 -6
  44. package/utils/index.js +22 -22
  45. package/utils/interpolate.util.d.ts +3 -3
  46. package/utils/interpolate.util.js +32 -32
  47. package/utils/json.util.d.ts +4 -4
  48. package/utils/json.util.js +47 -47
  49. package/utils/logger.d.ts +2 -2
  50. package/utils/logger.js +17 -17
  51. package/utils/normalize.util.d.ts +2 -2
  52. package/utils/normalize.util.js +60 -60
  53. package/utils/schema.util.d.ts +10 -10
  54. package/utils/schema.util.js +99 -99
@@ -1,18 +1,18 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./loader.interface"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./loader.interface"), exports);
18
18
  //# sourceMappingURL=index.js.map
@@ -1,21 +1,21 @@
1
- import { Arguments, Argv } from 'yargs';
2
- export type EnvResult = Record<string, unknown> | Record<string, unknown>[] | Promise<Record<string, unknown>> | Promise<Record<string, unknown>[]>;
3
- export interface EnvProviderResult {
4
- key: string;
5
- config?: Record<string, unknown>;
6
- value: Record<string, any> | Record<string, any>[];
7
- }
8
- export interface EnvProvider<A, C extends Record<string, any> | undefined = undefined> {
9
- key: string;
10
- builder?: (builder: Argv<unknown>) => void;
11
- load: (argv: Arguments<A>, config?: C) => EnvResult | never;
12
- pull?: (argv: Arguments<A>, config?: C) => void;
13
- push?: (argv: Arguments<A>, config?: C) => void;
14
- }
15
- export interface EnvProviderConfig {
16
- path: string;
17
- type: 'integrated' | 'module' | 'script';
18
- handler: EnvProvider<any, any>;
19
- config?: Record<string, unknown>;
20
- }
1
+ import { Arguments, Argv } from 'yargs';
2
+ export type EnvResult = Record<string, unknown> | Record<string, unknown>[] | Promise<Record<string, unknown>> | Promise<Record<string, unknown>[]>;
3
+ export interface EnvProviderResult {
4
+ key: string;
5
+ config?: Record<string, unknown>;
6
+ value: Record<string, any> | Record<string, any>[];
7
+ }
8
+ export interface EnvProvider<A, C extends Record<string, any> | undefined = undefined> {
9
+ key: string;
10
+ builder?: (builder: Argv<unknown>) => void;
11
+ load: (argv: Arguments<A>, config?: C) => EnvResult | never;
12
+ pull?: (argv: Arguments<A>, config?: C) => void;
13
+ push?: (argv: Arguments<A>, config?: C) => void;
14
+ }
15
+ export interface EnvProviderConfig {
16
+ path: string;
17
+ type: 'integrated' | 'module' | 'script';
18
+ handler: EnvProvider<any, any>;
19
+ config?: Record<string, unknown>;
20
+ }
21
21
  //# sourceMappingURL=loader.interface.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=loader.interface.js.map
package/main.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ #!/usr/bin/env node
2
+ export {};
3
3
  //# sourceMappingURL=main.d.ts.map
package/main.js CHANGED
@@ -1,6 +1,6 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const exec_1 = require("./exec");
5
- (0, exec_1.exec)(process.argv.slice(2));
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const exec_1 = require("./exec");
5
+ (0, exec_1.exec)(process.argv.slice(2));
6
6
  //# sourceMappingURL=main.js.map
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
- "version": "4.0.0",
2
+ "version": "4.1.1",
3
3
  "project": "common",
4
4
  "name": "@achs/env",
5
5
  "title": "Environment Variables CLI Tool",
6
6
  "description": "Extensible environment variables handler for NodeJS apps",
7
7
  "author": "Alvear Candia, Cristopher Alejandro <caalvearc@achs.cl>",
8
- "repository": "https://achsdev.visualstudio.com/Proyectos%20Activos/_git/ACHS.Lib.Env",
9
8
  "private": false,
10
9
  "keywords": [
11
10
  "env",
@@ -27,30 +26,30 @@
27
26
  "yargs-parser": "^21.1.1"
28
27
  },
29
28
  "devDependencies": {
30
- "@types/jest": "^29.4.0",
29
+ "@types/jest": "^29.5.1",
31
30
  "@types/merge-deep": "^3.0.0",
32
- "@types/node": "^18.14.6",
31
+ "@types/node": "^18.15.13",
33
32
  "@types/npmcli__ci-detect": "^2.0.0",
34
33
  "@types/to-json-schema": "^0.2.1",
35
- "@types/yargs": "^17.0.22",
34
+ "@types/yargs": "^17.0.24",
36
35
  "@types/yargs-parser": "^21.0.0",
37
- "@typescript-eslint/eslint-plugin": "^5.54.1",
38
- "@typescript-eslint/parser": "^5.54.1",
36
+ "@typescript-eslint/eslint-plugin": "^5.59.0",
37
+ "@typescript-eslint/parser": "^5.59.0",
39
38
  "copyfiles": "^2.4.1",
40
39
  "del-cli": "^5.0.0",
41
- "eslint": "^8.35.0",
42
- "eslint-config-prettier": "^8.7.0",
40
+ "eslint": "^8.38.0",
41
+ "eslint-config-prettier": "^8.8.0",
43
42
  "eslint-plugin-eslint-comments": "^3.2.0",
44
43
  "eslint-plugin-jest": "^27.2.1",
45
44
  "eslint-plugin-jest-formatting": "^3.1.0",
46
45
  "eslint-plugin-prettier": "^4.2.1",
47
46
  "eslint-plugin-promise": "^6.1.1",
48
- "eslint-plugin-sonarjs": "^0.18.0",
47
+ "eslint-plugin-sonarjs": "^0.19.0",
49
48
  "eslint-plugin-unicorn": "^46.0.0",
50
49
  "jest": "^29.5.0",
51
- "prettier": "^2.8.4",
52
- "ts-jest": "^29.0.5",
53
- "typescript": "^4.9.5"
50
+ "prettier": "^2.8.7",
51
+ "ts-jest": "^29.1.0",
52
+ "typescript": "^5.0.4"
54
53
  },
55
54
  "main": "index.js",
56
55
  "types": "index.d.ts",
@@ -1,8 +1,8 @@
1
- import { CommandArguments } from '../arguments';
2
- import { EnvProvider } from '../interfaces';
3
- interface AppSettingsCommandArguments extends CommandArguments {
4
- envFile: string;
5
- }
6
- export declare const AppSettingsProvider: EnvProvider<AppSettingsCommandArguments>;
7
- export {};
1
+ import { CommandArguments } from '../arguments';
2
+ import { EnvProvider } from '../interfaces';
3
+ interface AppSettingsCommandArguments extends CommandArguments {
4
+ envFile: string;
5
+ }
6
+ export declare const AppSettingsProvider: EnvProvider<AppSettingsCommandArguments>;
7
+ export {};
8
8
  //# sourceMappingURL=app-settings.provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-settings.provider.d.ts","sourceRoot":"","sources":["../../src/providers/app-settings.provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAS5C,UAAU,2BAA4B,SAAQ,gBAAgB;IAC7D,OAAO,EAAE,MAAM,CAAC;CAChB;AAKD,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,2BAA2B,CAmDxE,CAAC"}
1
+ {"version":3,"file":"app-settings.provider.d.ts","sourceRoot":"","sources":["../../src/providers/app-settings.provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAS5C,UAAU,2BAA4B,SAAQ,gBAAgB;IAC7D,OAAO,EAAE,MAAM,CAAC;CAChB;AAKD,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,2BAA2B,CAyDxE,CAAC"}
@@ -1,48 +1,52 @@
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.AppSettingsProvider = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const utils_1 = require("../utils");
9
- const KEY = 'app-settings';
10
- const logger = utils_1.logger.getChildLogger({
11
- prefix: [chalk_1.default.bold.blue(`[${KEY}]`)]
12
- });
13
- exports.AppSettingsProvider = {
14
- key: KEY,
15
- builder: (builder) => {
16
- builder.options({
17
- envFile: {
18
- group: KEY,
19
- alias: 'ef',
20
- type: 'string',
21
- default: '[[root]]/appsettings.json',
22
- describe: 'Environment variables file path (non secrets)'
23
- }
24
- });
25
- },
26
- load: async ({ env, root, modes = [], envFile, ci }) => {
27
- var _a;
28
- const [appsettings = {}, wasFound] = await (0, utils_1.readJson)(envFile);
29
- if (!wasFound)
30
- logger.warn(`${chalk_1.default.blue(envFile)} not found`);
31
- const composite = appsettings['|DEFAULT|'] ||
32
- appsettings['|ENV|'] ||
33
- appsettings['|MODE|'];
34
- const unitary = await Promise.all([
35
- (0, utils_1.readJson)(`${root}/appsettings.${env}.json`).then(([settings]) => settings),
36
- (0, utils_1.readJson)(`${root}/appsettings.${env}.local.json`).then(([settings]) => (ci ? {} : settings)),
37
- ...modes.map((mode) => (0, utils_1.readJson)(`${root}/appsettings.${mode}.json`).then(([settings]) => settings))
38
- ]);
39
- return [
40
- composite ? {} : appsettings,
41
- appsettings['|DEFAULT|'],
42
- (_a = appsettings['|ENV|']) === null || _a === void 0 ? void 0 : _a[env],
43
- ...modes.map((mode) => { var _a; return (_a = appsettings['|MODE|']) === null || _a === void 0 ? void 0 : _a[mode]; }),
44
- ...unitary
45
- ];
46
- }
47
- };
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.AppSettingsProvider = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const utils_1 = require("../utils");
9
+ const KEY = 'app-settings';
10
+ const logger = utils_1.logger.getChildLogger({
11
+ prefix: [chalk_1.default.bold.blue(`[${KEY}]`)]
12
+ });
13
+ exports.AppSettingsProvider = {
14
+ key: KEY,
15
+ builder: (builder) => {
16
+ builder.options({
17
+ envFile: {
18
+ group: KEY,
19
+ alias: 'ef',
20
+ type: 'string',
21
+ default: '[[root]]/appsettings.json',
22
+ describe: 'Environment variables file path (non secrets)'
23
+ }
24
+ });
25
+ },
26
+ load: async ({ env, root, modes = [], envFile, ci }) => {
27
+ var _a, _b;
28
+ const [appsettings = {}, wasFound] = await (0, utils_1.readJson)(envFile);
29
+ if (!wasFound)
30
+ logger.warn(`${chalk_1.default.blue(envFile)} not found`);
31
+ const composite = appsettings['|DEFAULT|'] ||
32
+ appsettings['|ENV|'] ||
33
+ appsettings['|MODE|'] ||
34
+ appsettings['|LOCAL|'];
35
+ const unitary = await Promise.all([
36
+ (0, utils_1.readJson)(`${root}/appsettings.${env}.json`).then(([settings]) => settings),
37
+ (0, utils_1.readJson)(`${root}/appsettings.${env}.local.json`).then(([settings]) => (ci ? {} : settings)),
38
+ ...modes.map((mode) => (0, utils_1.readJson)(`${root}/appsettings.${mode}.json`).then(([settings]) => settings))
39
+ ]);
40
+ if (ci)
41
+ appsettings['|LOCAL|'] = null;
42
+ return [
43
+ composite ? {} : appsettings,
44
+ appsettings['|DEFAULT|'],
45
+ (_a = appsettings['|ENV|']) === null || _a === void 0 ? void 0 : _a[env],
46
+ ...modes.map((mode) => { var _a; return (_a = appsettings['|MODE|']) === null || _a === void 0 ? void 0 : _a[mode]; }),
47
+ (_b = appsettings['|LOCAL|']) === null || _b === void 0 ? void 0 : _b[env],
48
+ ...unitary
49
+ ];
50
+ }
51
+ };
48
52
  //# sourceMappingURL=app-settings.provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-settings.provider.js","sourceRoot":"","sources":["../../src/providers/app-settings.provider.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,oCAA4D;AAE5D,MAAM,GAAG,GAAG,cAAc,CAAC;AAE3B,MAAM,MAAM,GAAG,cAAY,CAAC,cAAc,CAAC;IAC1C,MAAM,EAAE,CAAC,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;CACrC,CAAC,CAAC;AASU,QAAA,mBAAmB,GAA6C;IAC5E,GAAG,EAAE,GAAG;IAER,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE;QACpB,OAAO,CAAC,OAAO,CAAC;YACf,OAAO,EAAE;gBACR,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,IAAI;gBACX,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,2BAA2B;gBACpC,QAAQ,EAAE,+CAA+C;aACzD;SACD,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE;;QACtD,MAAM,CAAC,WAAW,GAAG,EAAE,EAAE,QAAQ,CAAC,GAAG,MAAM,IAAA,gBAAQ,EAAC,OAAO,CAAC,CAAC;QAE7D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AE,EAAE,CAAC,QAAQ,CACxB;YACD,IAAA,gBAAQ,EAAC,GAAG,IAAI,gBAAgB,GAAG,aAAa,CAAC,CAAC,IAAI,CACrD,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CACpC;YACD,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACrB,IAAA,gBAAQ,EAAC,GAAG,IAAI,gBAAgB,IAAI,OAAO,CAAC,CAAC,IAAI,CAChD,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,CACxB,CACD;SACD,CAAC,CAAC;QAGH,IAAI,EAAE;YAAE,WAAW,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;QAEtC,OAAO;YACN,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW;YAE5B,WAAW,CAAC,WAAW,CAAC;YAExB,MAAA,WAAW,CAAC,OAAO,CAAC,0CAAG,GAAG,CAAC;YAE3B,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,WAAC,OAAA,MAAA,WAAW,CAAC,QAAQ,CAAC,0CAAG,IAAI,CAAC,CAAA,EAAA,CAAC;YAErD,MAAA,WAAW,CAAC,SAAS,CAAC,0CAAG,GAAG,CAAC;YAE7B,GAAG,OAAO;SACV,CAAC;IACH,CAAC;CACD,CAAC"}
@@ -1,20 +1,20 @@
1
- import { CommandArguments } from '../arguments';
2
- import { EnvProvider } from '../interfaces';
3
- import { PullCommandArguments } from 'commands/pull.command';
4
- interface AzureKeyVaultCommandArguments extends CommandArguments {
5
- secretsFile: string;
6
- keysFile?: string[];
7
- vaultUrl: string;
8
- spn: string;
9
- password: string;
10
- tenant: string;
11
- mock: boolean;
12
- }
13
- interface AzureKeyVaultCommandConfig {
14
- [key: string]: {
15
- vaultUrl: string;
16
- };
17
- }
18
- export declare const AzureKeyVaultProvider: EnvProvider<AzureKeyVaultCommandArguments & PullCommandArguments, AzureKeyVaultCommandConfig>;
19
- export {};
1
+ import { CommandArguments } from '../arguments';
2
+ import { EnvProvider } from '../interfaces';
3
+ import { PullCommandArguments } from 'commands/pull.command';
4
+ interface AzureKeyVaultCommandArguments extends CommandArguments {
5
+ secretsFile: string;
6
+ keysFile?: string[];
7
+ vaultUrl: string;
8
+ spn: string;
9
+ password: string;
10
+ tenant: string;
11
+ mock: boolean;
12
+ }
13
+ interface AzureKeyVaultCommandConfig {
14
+ [key: string]: {
15
+ vaultUrl: string;
16
+ };
17
+ }
18
+ export declare const AzureKeyVaultProvider: EnvProvider<AzureKeyVaultCommandArguments & PullCommandArguments, AzureKeyVaultCommandConfig>;
19
+ export {};
20
20
  //# sourceMappingURL=azure-key-vault.provider.d.ts.map
@@ -1,149 +1,149 @@
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.AzureKeyVaultProvider = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const azure_key_vault_1 = require("@achs/azure-key-vault");
9
- const utils_1 = require("../utils");
10
- const fs_1 = require("fs");
11
- const KEY = 'azure-key-vault';
12
- const logger = utils_1.logger.getChildLogger({
13
- prefix: [chalk_1.default.bold.blue(`[${KEY}]`)]
14
- });
15
- exports.AzureKeyVaultProvider = {
16
- key: KEY,
17
- builder: (builder) => {
18
- builder.options({
19
- secretsFile: {
20
- group: KEY,
21
- type: 'string',
22
- default: '[[root]]/[[env]].env.json',
23
- describe: 'Secret variables file path'
24
- },
25
- keysFile: {
26
- group: KEY,
27
- alias: ['k', 'keys'],
28
- type: 'array',
29
- default: ['[[root]]/keys.json', '../keys.json'],
30
- describe: 'Azure Key Vault keys file path'
31
- },
32
- vaultUrl: {
33
- group: KEY,
34
- alias: 'url',
35
- type: 'string',
36
- describe: 'Azure Key Vault URL'
37
- },
38
- spn: {
39
- group: KEY,
40
- alias: ['clientId', 'id'],
41
- type: 'string',
42
- describe: 'SPN Client ID'
43
- },
44
- password: {
45
- group: KEY,
46
- alias: ['p', 'pass', 'clientSecret'],
47
- type: 'string',
48
- describe: 'SPN Client Secret Password'
49
- },
50
- tenant: {
51
- group: KEY,
52
- alias: 't',
53
- type: 'string',
54
- describe: 'Azure Tenant ID'
55
- },
56
- mock: {
57
- group: KEY,
58
- type: 'boolean',
59
- default: false,
60
- describe: 'Mocks Azure Key Vault client'
61
- }
62
- });
63
- },
64
- push: async (argv, config) => {
65
- var _a;
66
- const [secrets, secretsWasFound] = await (0, utils_1.readJson)(argv.secretsFile);
67
- if (!secretsWasFound) {
68
- logger.error(`${chalk_1.default.blue(argv.secretFile)} not found`);
69
- process.exit(1);
70
- }
71
- logger.silly('local secrets loaded:', secrets);
72
- const akv = await loadAzureKeyVaultClient(argv, (_a = config === null || config === void 0 ? void 0 : config[argv.env]) === null || _a === void 0 ? void 0 : _a.vaultUrl);
73
- logger.info('pushing variables to store');
74
- const results = await akv.setAll(secrets);
75
- logger.silly('secrets pushed:', results);
76
- const schema = await (0, utils_1.generateSchemaFrom)([{ key: KEY, value: secrets }], argv);
77
- logger.silly('schema for akv updated:', schema);
78
- },
79
- pull: async (argv, config) => {
80
- var _a, _b;
81
- const schema = (_a = argv.schema) === null || _a === void 0 ? void 0 : _a[KEY];
82
- if (!schema) {
83
- logger.error('no schema found');
84
- logger.info(`generating empty ${chalk_1.default.bold.underline.yellowBright(argv.secretsFile)} file (you can retry command)`);
85
- await (0, utils_1.writeJson)(argv.secretsFile, {}, false, true);
86
- process.exit(1);
87
- }
88
- const jsonTemplate = (0, utils_1.schemaToJson)(schema);
89
- const akv = await loadAzureKeyVaultClient(argv, (_b = config === null || config === void 0 ? void 0 : config[argv.env]) === null || _b === void 0 ? void 0 : _b.vaultUrl);
90
- logger.info('pulling variables from store');
91
- const secrets = await akv.getFor(jsonTemplate, true);
92
- logger.silly('remote secrets loaded:', secrets);
93
- await (0, utils_1.writeJson)(argv.secretsFile, secrets, argv.overwrite, true);
94
- },
95
- load: async (argv, config) => {
96
- const { secretsFile, env } = argv;
97
- if (!env) {
98
- logger.silly('no env, so skipping provider');
99
- return [];
100
- }
101
- if (!(0, fs_1.existsSync)(secretsFile)) {
102
- logger.warn('secrets file not found, pulling from store');
103
- await exports.AzureKeyVaultProvider.pull(argv, config);
104
- }
105
- const [secrets] = await (0, utils_1.readJson)(secretsFile);
106
- return [secrets];
107
- }
108
- };
109
- function keysAreValid(keys) {
110
- return keys && keys.clientId && keys.clientSecret && keys.tenantId;
111
- }
112
- async function loadKeysFile(env, paths) {
113
- var _a, _b;
114
- logger.debug(`searching keys at ${chalk_1.default.yellow(paths.join(','))}`);
115
- const readers = await Promise.all(paths.map((path) => (0, utils_1.readJson)(path)));
116
- const [keys, wasFound] = (_a = readers.find(([keys, wasFound]) => wasFound && keysAreValid(keys[env]))) !== null && _a !== void 0 ? _a : [null, false];
117
- return (_b = keys === null || keys === void 0 ? void 0 : keys[env]) !== null && _b !== void 0 ? _b : {};
118
- }
119
- async function loadAzureKeyVaultClient({ env, vaultUrl, spn, password, tenant, projectInfo, keysFile, mock }, configVaultUrl) {
120
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
121
- let url = (_b = (_a = process.env.AZURE_VAULT_URL) !== null && _a !== void 0 ? _a : vaultUrl) !== null && _b !== void 0 ? _b : configVaultUrl;
122
- const config = {
123
- project: (_c = process.env.AZURE_PROJECT) !== null && _c !== void 0 ? _c : projectInfo.project,
124
- group: (_d = process.env.AZURE_GROUP) !== null && _d !== void 0 ? _d : projectInfo.name,
125
- env
126
- };
127
- if (!config.project) {
128
- logger.error(`no project info from ${chalk_1.default.blue('package.json')} found`);
129
- process.exit(1);
130
- }
131
- const credentials = {
132
- clientId: (_e = process.env.AZURE_CLIENT_ID) !== null && _e !== void 0 ? _e : spn,
133
- clientSecret: (_f = process.env.AZURE_CLIENT_SECRET) !== null && _f !== void 0 ? _f : password,
134
- tenantId: (_g = process.env.AZURE_TENANT_ID) !== null && _g !== void 0 ? _g : tenant
135
- };
136
- if (keysFile && keysFile.length > 0 && !keysAreValid(credentials)) {
137
- const keys = await loadKeysFile(env, keysFile);
138
- url !== null && url !== void 0 ? url : (url = keys.vaultUrl);
139
- (_h = credentials.clientId) !== null && _h !== void 0 ? _h : (credentials.clientId = keys.clientId);
140
- (_j = credentials.clientSecret) !== null && _j !== void 0 ? _j : (credentials.clientSecret = keys.clientSecret);
141
- (_k = credentials.tenantId) !== null && _k !== void 0 ? _k : (credentials.tenantId = keys.tenantId);
142
- }
143
- logger.debug(`credentials loaded for project ${chalk_1.default.bold.underline.yellowBright(config.project)} and group ${chalk_1.default.bold.underline.yellowBright(config.group)}`);
144
- logger.debug(`connected to ${chalk_1.default.bold.underline.greenBright(url)}`);
145
- return mock
146
- ? (0, azure_key_vault_1.createAzureKeyVaultMock)(config)
147
- : new azure_key_vault_1.AzureKeyVault(url, config, credentials);
148
- }
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.AzureKeyVaultProvider = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const azure_key_vault_1 = require("@achs/azure-key-vault");
9
+ const utils_1 = require("../utils");
10
+ const fs_1 = require("fs");
11
+ const KEY = 'azure-key-vault';
12
+ const logger = utils_1.logger.getChildLogger({
13
+ prefix: [chalk_1.default.bold.blue(`[${KEY}]`)]
14
+ });
15
+ exports.AzureKeyVaultProvider = {
16
+ key: KEY,
17
+ builder: (builder) => {
18
+ builder.options({
19
+ secretsFile: {
20
+ group: KEY,
21
+ type: 'string',
22
+ default: '[[root]]/[[env]].env.json',
23
+ describe: 'Secret variables file path'
24
+ },
25
+ keysFile: {
26
+ group: KEY,
27
+ alias: ['k', 'keys'],
28
+ type: 'array',
29
+ default: ['[[root]]/keys.json', '../keys.json'],
30
+ describe: 'Azure Key Vault keys file path'
31
+ },
32
+ vaultUrl: {
33
+ group: KEY,
34
+ alias: 'url',
35
+ type: 'string',
36
+ describe: 'Azure Key Vault URL'
37
+ },
38
+ spn: {
39
+ group: KEY,
40
+ alias: ['clientId', 'id'],
41
+ type: 'string',
42
+ describe: 'SPN Client ID'
43
+ },
44
+ password: {
45
+ group: KEY,
46
+ alias: ['p', 'pass', 'clientSecret'],
47
+ type: 'string',
48
+ describe: 'SPN Client Secret Password'
49
+ },
50
+ tenant: {
51
+ group: KEY,
52
+ alias: 't',
53
+ type: 'string',
54
+ describe: 'Azure Tenant ID'
55
+ },
56
+ mock: {
57
+ group: KEY,
58
+ type: 'boolean',
59
+ default: false,
60
+ describe: 'Mocks Azure Key Vault client'
61
+ }
62
+ });
63
+ },
64
+ push: async (argv, config) => {
65
+ var _a;
66
+ const [secrets, secretsWasFound] = await (0, utils_1.readJson)(argv.secretsFile);
67
+ if (!secretsWasFound) {
68
+ logger.error(`${chalk_1.default.blue(argv.secretFile)} not found`);
69
+ process.exit(1);
70
+ }
71
+ logger.silly('local secrets loaded:', secrets);
72
+ const akv = await loadAzureKeyVaultClient(argv, (_a = config === null || config === void 0 ? void 0 : config[argv.env]) === null || _a === void 0 ? void 0 : _a.vaultUrl);
73
+ logger.info('pushing variables to store');
74
+ const results = await akv.setAll(secrets);
75
+ logger.silly('secrets pushed:', results);
76
+ const schema = await (0, utils_1.generateSchemaFrom)([{ key: KEY, value: secrets }], argv);
77
+ logger.silly('schema for akv updated:', schema);
78
+ },
79
+ pull: async (argv, config) => {
80
+ var _a, _b;
81
+ const schema = (_a = argv.schema) === null || _a === void 0 ? void 0 : _a[KEY];
82
+ if (!schema) {
83
+ logger.error('no schema found');
84
+ logger.info(`generating empty ${chalk_1.default.bold.underline.yellowBright(argv.secretsFile)} file (you can retry command)`);
85
+ await (0, utils_1.writeJson)(argv.secretsFile, {}, false, true);
86
+ process.exit(1);
87
+ }
88
+ const jsonTemplate = (0, utils_1.schemaToJson)(schema);
89
+ const akv = await loadAzureKeyVaultClient(argv, (_b = config === null || config === void 0 ? void 0 : config[argv.env]) === null || _b === void 0 ? void 0 : _b.vaultUrl);
90
+ logger.info('pulling variables from store');
91
+ const secrets = await akv.getFor(jsonTemplate, true);
92
+ logger.silly('remote secrets loaded:', secrets);
93
+ await (0, utils_1.writeJson)(argv.secretsFile, secrets, argv.overwrite, true);
94
+ },
95
+ load: async (argv, config) => {
96
+ const { secretsFile, env } = argv;
97
+ if (!env) {
98
+ logger.silly('no env, so skipping provider');
99
+ return [];
100
+ }
101
+ if (!(0, fs_1.existsSync)(secretsFile)) {
102
+ logger.warn('secrets file not found, pulling from store');
103
+ await exports.AzureKeyVaultProvider.pull(argv, config);
104
+ }
105
+ const [secrets] = await (0, utils_1.readJson)(secretsFile);
106
+ return [secrets];
107
+ }
108
+ };
109
+ function keysAreValid(keys) {
110
+ return keys && keys.clientId && keys.clientSecret && keys.tenantId;
111
+ }
112
+ async function loadKeysFile(env, paths) {
113
+ var _a, _b;
114
+ logger.debug(`searching keys at ${chalk_1.default.yellow(paths.join(','))}`);
115
+ const readers = await Promise.all(paths.map((path) => (0, utils_1.readJson)(path)));
116
+ const [keys, wasFound] = (_a = readers.find(([keys, wasFound]) => wasFound && keysAreValid(keys[env]))) !== null && _a !== void 0 ? _a : [null, false];
117
+ return (_b = keys === null || keys === void 0 ? void 0 : keys[env]) !== null && _b !== void 0 ? _b : {};
118
+ }
119
+ async function loadAzureKeyVaultClient({ env, vaultUrl, spn, password, tenant, projectInfo, keysFile, mock }, configVaultUrl) {
120
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
121
+ let url = (_b = (_a = process.env.AZURE_VAULT_URL) !== null && _a !== void 0 ? _a : vaultUrl) !== null && _b !== void 0 ? _b : configVaultUrl;
122
+ const config = {
123
+ project: (_c = process.env.AZURE_PROJECT) !== null && _c !== void 0 ? _c : projectInfo.project,
124
+ group: (_d = process.env.AZURE_GROUP) !== null && _d !== void 0 ? _d : projectInfo.name,
125
+ env
126
+ };
127
+ if (!config.project) {
128
+ logger.error(`no project info from ${chalk_1.default.blue('package.json')} found`);
129
+ process.exit(1);
130
+ }
131
+ const credentials = {
132
+ clientId: (_e = process.env.AZURE_CLIENT_ID) !== null && _e !== void 0 ? _e : spn,
133
+ clientSecret: (_f = process.env.AZURE_CLIENT_SECRET) !== null && _f !== void 0 ? _f : password,
134
+ tenantId: (_g = process.env.AZURE_TENANT_ID) !== null && _g !== void 0 ? _g : tenant
135
+ };
136
+ if (keysFile && keysFile.length > 0 && !keysAreValid(credentials)) {
137
+ const keys = await loadKeysFile(env, keysFile);
138
+ url !== null && url !== void 0 ? url : (url = keys.vaultUrl);
139
+ (_h = credentials.clientId) !== null && _h !== void 0 ? _h : (credentials.clientId = keys.clientId);
140
+ (_j = credentials.clientSecret) !== null && _j !== void 0 ? _j : (credentials.clientSecret = keys.clientSecret);
141
+ (_k = credentials.tenantId) !== null && _k !== void 0 ? _k : (credentials.tenantId = keys.tenantId);
142
+ }
143
+ logger.debug(`credentials loaded for project ${chalk_1.default.bold.underline.yellowBright(config.project)} and group ${chalk_1.default.bold.underline.yellowBright(config.group)}`);
144
+ logger.debug(`connected to ${chalk_1.default.bold.underline.greenBright(url)}`);
145
+ return mock
146
+ ? (0, azure_key_vault_1.createAzureKeyVaultMock)(config)
147
+ : new azure_key_vault_1.AzureKeyVault(url, config, credentials);
148
+ }
149
149
  //# sourceMappingURL=azure-key-vault.provider.js.map