kourou 0.24.2 → 0.25.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.
Files changed (132) hide show
  1. package/README.md +98 -12
  2. package/lib/commands/api-key/check.d.ts +3 -3
  3. package/lib/commands/api-key/check.js +5 -7
  4. package/lib/commands/api-key/create.d.ts +3 -3
  5. package/lib/commands/api-key/create.js +8 -10
  6. package/lib/commands/api-key/delete.d.ts +3 -3
  7. package/lib/commands/api-key/delete.js +4 -6
  8. package/lib/commands/api-key/search.d.ts +3 -3
  9. package/lib/commands/api-key/search.js +5 -7
  10. package/lib/commands/app/debug-proxy.d.ts +3 -3
  11. package/lib/commands/app/debug-proxy.js +57 -55
  12. package/lib/commands/app/doctor.d.ts +24 -0
  13. package/lib/commands/app/doctor.js +201 -0
  14. package/lib/commands/app/scaffold.d.ts +2 -2
  15. package/lib/commands/app/scaffold.js +20 -15
  16. package/lib/commands/app/start-services.d.ts +1 -1
  17. package/lib/commands/app/start-services.js +26 -26
  18. package/lib/commands/collection/create.d.ts +3 -3
  19. package/lib/commands/collection/create.js +9 -6
  20. package/lib/commands/collection/export.d.ts +5 -5
  21. package/lib/commands/collection/export.js +25 -26
  22. package/lib/commands/collection/import.d.ts +5 -5
  23. package/lib/commands/collection/import.js +17 -17
  24. package/lib/commands/collection/migrate.d.ts +27 -0
  25. package/lib/commands/collection/migrate.js +43 -0
  26. package/lib/commands/config/diff.d.ts +1 -1
  27. package/lib/commands/config/diff.js +27 -21
  28. package/lib/commands/document/search.d.ts +3 -3
  29. package/lib/commands/document/search.js +20 -20
  30. package/lib/commands/es/aliases/cat.d.ts +12 -0
  31. package/lib/commands/es/aliases/cat.js +36 -0
  32. package/lib/commands/es/indices/cat.d.ts +2 -2
  33. package/lib/commands/es/indices/cat.js +8 -8
  34. package/lib/commands/es/indices/get.d.ts +2 -2
  35. package/lib/commands/es/indices/get.js +7 -7
  36. package/lib/commands/es/indices/insert.d.ts +2 -2
  37. package/lib/commands/es/indices/insert.js +9 -9
  38. package/lib/commands/es/migrate.d.ts +10 -8
  39. package/lib/commands/es/migrate.js +86 -82
  40. package/lib/commands/es/snapshot/create-repository.d.ts +2 -2
  41. package/lib/commands/es/snapshot/create-repository.js +16 -12
  42. package/lib/commands/es/snapshot/create.d.ts +2 -2
  43. package/lib/commands/es/snapshot/create.js +7 -7
  44. package/lib/commands/es/snapshot/list.d.ts +2 -2
  45. package/lib/commands/es/snapshot/list.js +12 -8
  46. package/lib/commands/file/decrypt.d.ts +4 -4
  47. package/lib/commands/file/decrypt.js +21 -21
  48. package/lib/commands/file/encrypt.d.ts +4 -4
  49. package/lib/commands/file/encrypt.js +20 -22
  50. package/lib/commands/file/test.d.ts +3 -3
  51. package/lib/commands/file/test.js +13 -13
  52. package/lib/commands/import.d.ts +5 -5
  53. package/lib/commands/import.js +39 -28
  54. package/lib/commands/index/export.d.ts +5 -4
  55. package/lib/commands/index/export.js +21 -19
  56. package/lib/commands/index/import.d.ts +5 -5
  57. package/lib/commands/index/import.js +21 -19
  58. package/lib/commands/instance/kill.d.ts +2 -2
  59. package/lib/commands/instance/kill.js +34 -34
  60. package/lib/commands/instance/list.d.ts +1 -1
  61. package/lib/commands/instance/list.js +33 -30
  62. package/lib/commands/instance/logs.d.ts +2 -2
  63. package/lib/commands/instance/logs.js +26 -22
  64. package/lib/commands/instance/spawn.d.ts +2 -2
  65. package/lib/commands/instance/spawn.js +46 -40
  66. package/lib/commands/paas/deploy.d.ts +2 -2
  67. package/lib/commands/paas/deploy.js +33 -21
  68. package/lib/commands/paas/init.d.ts +1 -1
  69. package/lib/commands/paas/init.js +10 -6
  70. package/lib/commands/paas/login.d.ts +3 -3
  71. package/lib/commands/paas/login.js +30 -19
  72. package/lib/commands/paas/logs.d.ts +27 -0
  73. package/lib/commands/paas/logs.js +137 -18
  74. package/lib/commands/profile/export.d.ts +3 -3
  75. package/lib/commands/profile/export.js +12 -12
  76. package/lib/commands/profile/import.d.ts +3 -3
  77. package/lib/commands/profile/import.js +6 -8
  78. package/lib/commands/realtime/subscribe.d.ts +3 -3
  79. package/lib/commands/realtime/subscribe.js +25 -25
  80. package/lib/commands/redis/list-keys.d.ts +3 -3
  81. package/lib/commands/redis/list-keys.js +15 -11
  82. package/lib/commands/role/export.d.ts +3 -3
  83. package/lib/commands/role/export.js +11 -11
  84. package/lib/commands/role/import.d.ts +4 -4
  85. package/lib/commands/role/import.js +10 -12
  86. package/lib/commands/sdk/execute.d.ts +5 -5
  87. package/lib/commands/sdk/execute.js +23 -19
  88. package/lib/commands/sdk/query.d.ts +5 -4
  89. package/lib/commands/sdk/query.js +30 -24
  90. package/lib/commands/user/export-mappings.d.ts +3 -3
  91. package/lib/commands/user/export-mappings.js +11 -11
  92. package/lib/commands/user/export.d.ts +6 -6
  93. package/lib/commands/user/export.js +34 -33
  94. package/lib/commands/user/import-mappings.d.ts +3 -3
  95. package/lib/commands/user/import-mappings.js +7 -7
  96. package/lib/commands/user/import.d.ts +3 -3
  97. package/lib/commands/user/import.js +6 -8
  98. package/lib/commands/vault/add.d.ts +3 -3
  99. package/lib/commands/vault/add.js +27 -19
  100. package/lib/commands/vault/decrypt.d.ts +4 -4
  101. package/lib/commands/vault/decrypt.js +24 -20
  102. package/lib/commands/vault/encrypt.d.ts +4 -4
  103. package/lib/commands/vault/encrypt.js +24 -20
  104. package/lib/commands/vault/show.d.ts +3 -3
  105. package/lib/commands/vault/show.js +24 -20
  106. package/lib/commands/vault/test.d.ts +3 -3
  107. package/lib/commands/vault/test.js +16 -12
  108. package/lib/common.d.ts +3 -3
  109. package/lib/common.js +28 -29
  110. package/lib/hooks/command_not_found/api-action.d.ts +2 -2
  111. package/lib/hooks/command_not_found/api-action.js +20 -22
  112. package/lib/index.d.ts +1 -1
  113. package/lib/support/PaasKommand.d.ts +2 -2
  114. package/lib/support/PaasKommand.js +9 -9
  115. package/lib/support/dump-collection.js +50 -41
  116. package/lib/support/editor.js +12 -10
  117. package/lib/support/execute.d.ts +6 -1
  118. package/lib/support/execute.js +9 -8
  119. package/lib/support/kuzzle.d.ts +12 -4
  120. package/lib/support/kuzzle.js +65 -31
  121. package/lib/support/migrate/providers/elasticsearch.d.ts +16 -0
  122. package/lib/support/migrate/providers/elasticsearch.js +74 -0
  123. package/lib/support/migrate/providers/file.d.ts +15 -0
  124. package/lib/support/migrate/providers/file.js +74 -0
  125. package/lib/support/migrate/providers/index.d.ts +12 -0
  126. package/lib/support/migrate/providers/index.js +16 -0
  127. package/lib/support/migrate/types.d.ts +8 -0
  128. package/lib/support/migrate/types.js +2 -0
  129. package/lib/support/restore-collection.d.ts +2 -1
  130. package/lib/support/restore-collection.js +37 -26
  131. package/lib/support/restore-securities.js +22 -19
  132. package/package.json +16 -15
@@ -2,24 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const command_1 = require("@oclif/command");
5
- const fs_1 = tslib_1.__importDefault(require("fs"));
5
+ const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
6
6
  const common_1 = require("../../common");
7
7
  const kuzzle_1 = require("../../support/kuzzle");
8
8
  const restore_securities_1 = require("../../support/restore-securities");
9
9
  class UserImport extends common_1.Kommand {
10
10
  async runSafe() {
11
11
  this.logInfo(`Importing users from ${this.args.path} ...`);
12
- const dump = JSON.parse(fs_1.default.readFileSync(this.args.path, 'utf-8'));
12
+ const dump = JSON.parse(fs_1.default.readFileSync(this.args.path, "utf-8"));
13
13
  const count = await (0, restore_securities_1.restoreUsers)(this, dump);
14
14
  this.logOk(`${count} users restored`);
15
15
  }
16
16
  }
17
17
  exports.default = UserImport;
18
- UserImport.description = 'Imports users';
18
+ UserImport.description = "Imports users";
19
19
  UserImport.flags = Object.assign(Object.assign({ help: command_1.flags.help({}) }, kuzzle_1.kuzzleFlags), { protocol: command_1.flags.string({
20
- description: 'Kuzzle protocol (http or websocket)',
21
- default: 'ws',
20
+ description: "Kuzzle protocol (http or websocket)",
21
+ default: "ws",
22
22
  }) });
23
- UserImport.args = [
24
- { name: 'path', description: 'Dump file', required: true },
25
- ];
23
+ UserImport.args = [{ name: "path", description: "Dump file", required: true }];
@@ -1,11 +1,11 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../common";
3
3
  export declare class VaultAdd extends Kommand {
4
4
  static initSdk: boolean;
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
- 'vault-key': flags.IOptionFlag<string | undefined>;
8
+ "vault-key": flags.IOptionFlag<string | undefined>;
9
9
  };
10
10
  static args: {
11
11
  name: string;
@@ -2,34 +2,34 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VaultAdd = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const fs_1 = tslib_1.__importDefault(require("fs"));
5
+ const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
6
6
  const command_1 = require("@oclif/command");
7
- const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
8
8
  const kuzzle_vault_1 = require("kuzzle-vault");
9
9
  const common_1 = require("../../common");
10
10
  class VaultAdd extends common_1.Kommand {
11
11
  async runSafe() {
12
- if (lodash_1.default.isEmpty(this.flags['vault-key'])) {
13
- throw new Error('A vault key must be provided');
12
+ if (lodash_1.default.isEmpty(this.flags["vault-key"])) {
13
+ throw new Error("A vault key must be provided");
14
14
  }
15
- if (lodash_1.default.isEmpty(this.args['secrets-file'])) {
16
- throw new Error('A secrets file must be provided');
15
+ if (lodash_1.default.isEmpty(this.args["secrets-file"])) {
16
+ throw new Error("A secrets file must be provided");
17
17
  }
18
- const cryptonomicon = new kuzzle_vault_1.Cryptonomicon(this.flags['vault-key']);
19
- const PARSER = kuzzle_vault_1.Vault.getParser(this.args['secrets-file']);
18
+ const cryptonomicon = new kuzzle_vault_1.Cryptonomicon(this.flags["vault-key"]);
19
+ const PARSER = kuzzle_vault_1.Vault.getParser(this.args["secrets-file"]);
20
20
  let encryptedSecrets = {};
21
- if (fs_1.default.existsSync(this.args['secrets-file'])) {
22
- encryptedSecrets = PARSER.parse(fs_1.default.readFileSync(this.args['secrets-file'], 'utf8'));
21
+ if (fs_1.default.existsSync(this.args["secrets-file"])) {
22
+ encryptedSecrets = PARSER.parse(fs_1.default.readFileSync(this.args["secrets-file"], "utf8"));
23
23
  try {
24
24
  cryptonomicon.decryptObject(encryptedSecrets);
25
25
  }
26
26
  catch (error) {
27
- throw new Error('Trying to add a secret encrypted with a different key');
27
+ throw new Error("Trying to add a secret encrypted with a different key");
28
28
  }
29
29
  }
30
30
  lodash_1.default.set(encryptedSecrets, this.args.key, cryptonomicon.encryptString(this.args.value));
31
- fs_1.default.writeFileSync(this.args['secrets-file'], PARSER.stringify(encryptedSecrets, null, 2));
32
- this.logOk(`Key "${this.args.key}" has been securely added "${this.args['secrets-file']}"`);
31
+ fs_1.default.writeFileSync(this.args["secrets-file"], PARSER.stringify(encryptedSecrets, null, 2));
32
+ this.logOk(`Key "${this.args.key}" has been securely added "${this.args["secrets-file"]}"`);
33
33
  }
34
34
  }
35
35
  exports.VaultAdd = VaultAdd;
@@ -44,16 +44,24 @@ Encrypted secrets are meant to be loaded inside an application with Kuzzle Vault
44
44
  See https://github.com/kuzzleio/kuzzle-vault/ for more information.
45
45
  `;
46
46
  VaultAdd.examples = [
47
- 'kourou vault:add config/secrets.enc.json aws.s3.keyId b61e267676660c314b006b06 --vault-key <vault-key>'
47
+ "kourou vault:add config/secrets.enc.json aws.s3.keyId b61e267676660c314b006b06 --vault-key <vault-key>",
48
48
  ];
49
49
  VaultAdd.flags = {
50
- 'vault-key': command_1.flags.string({
51
- description: 'Kuzzle Vault Key (or KUZZLE_VAULT_KEY)',
50
+ "vault-key": command_1.flags.string({
51
+ description: "Kuzzle Vault Key (or KUZZLE_VAULT_KEY)",
52
52
  default: process.env.KUZZLE_VAULT_KEY,
53
53
  }),
54
54
  };
55
55
  VaultAdd.args = [
56
- { name: 'secrets-file', description: 'Encrypted secrets file', required: true },
57
- { name: 'key', description: 'Path to the key (lodash style)', required: true },
58
- { name: 'value', description: 'Value to encrypt', required: true }
56
+ {
57
+ name: "secrets-file",
58
+ description: "Encrypted secrets file",
59
+ required: true,
60
+ },
61
+ {
62
+ name: "key",
63
+ description: "Path to the key (lodash style)",
64
+ required: true,
65
+ },
66
+ { name: "value", description: "Value to encrypt", required: true },
59
67
  ];
@@ -1,13 +1,13 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../common";
3
3
  export declare class VaultDecrypt extends Kommand {
4
4
  static initSdk: boolean;
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
8
  force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
9
- 'output-file': flags.IOptionFlag<string | undefined>;
10
- 'vault-key': flags.IOptionFlag<string | undefined>;
9
+ "output-file": flags.IOptionFlag<string | undefined>;
10
+ "vault-key": flags.IOptionFlag<string | undefined>;
11
11
  };
12
12
  static args: {
13
13
  name: string;
@@ -2,34 +2,34 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VaultDecrypt = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const fs_1 = tslib_1.__importDefault(require("fs"));
6
- const lodash_1 = tslib_1.__importDefault(require("lodash"));
5
+ const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
6
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
7
7
  const command_1 = require("@oclif/command");
8
8
  const kuzzle_vault_1 = require("kuzzle-vault");
9
9
  const common_1 = require("../../common");
10
10
  class VaultDecrypt extends common_1.Kommand {
11
11
  async runSafe() {
12
- if (lodash_1.default.isEmpty(this.flags['vault-key'])) {
13
- throw new Error('A vault key must be provided');
12
+ if (lodash_1.default.isEmpty(this.flags["vault-key"])) {
13
+ throw new Error("A vault key must be provided");
14
14
  }
15
15
  if (lodash_1.default.isEmpty(this.args.file)) {
16
- throw new Error('A secrets file must be provided');
16
+ throw new Error("A secrets file must be provided");
17
17
  }
18
- let outputFile = `${this.args.file.replace('.enc', '')}`;
19
- if (this.flags['output-file']) {
20
- outputFile = this.flags['output-file'];
18
+ let outputFile = `${this.args.file.replace(".enc", "")}`;
19
+ if (this.flags["output-file"]) {
20
+ outputFile = this.flags["output-file"];
21
21
  }
22
22
  if (fs_1.default.existsSync(outputFile) && !this.flags.force) {
23
23
  throw new Error(`Output file "${outputFile}" already exists. Use -f flag to overwrite it.`);
24
24
  }
25
- const cryptonomicon = new kuzzle_vault_1.Cryptonomicon(this.flags['vault-key']);
25
+ const cryptonomicon = new kuzzle_vault_1.Cryptonomicon(this.flags["vault-key"]);
26
26
  if (!fs_1.default.existsSync(this.args.file)) {
27
27
  throw new Error(`File "${this.args.file}" does not exists`);
28
28
  }
29
29
  const PARSER = kuzzle_vault_1.Vault.getParser(this.args.file);
30
30
  let encryptedSecrets = {};
31
31
  try {
32
- encryptedSecrets = PARSER.parse(fs_1.default.readFileSync(this.args.file, 'utf8'));
32
+ encryptedSecrets = PARSER.parse(fs_1.default.readFileSync(this.args.file, "utf8"));
33
33
  }
34
34
  catch (error) {
35
35
  throw new Error(`Cannot read secrets from file "${this.args.file}": ${error.message}`);
@@ -49,23 +49,27 @@ Decrypted secrets file must NEVER be committed into the repository.
49
49
  See https://github.com/kuzzleio/kuzzle-vault/ for more information.
50
50
  `;
51
51
  VaultDecrypt.examples = [
52
- 'kourou vault:decrypt config/secrets.enc.json --vault-key <vault-key>',
53
- 'kourou vault:decrypt config/secrets.enc.json -o config/secrets.json --vault-key <vault-key>'
52
+ "kourou vault:decrypt config/secrets.enc.json --vault-key <vault-key>",
53
+ "kourou vault:decrypt config/secrets.enc.json -o config/secrets.json --vault-key <vault-key>",
54
54
  ];
55
55
  VaultDecrypt.flags = {
56
56
  force: command_1.flags.boolean({
57
- char: 'f',
58
- description: 'Overwrite the output file if it already exists'
57
+ char: "f",
58
+ description: "Overwrite the output file if it already exists",
59
59
  }),
60
- 'output-file': command_1.flags.string({
61
- char: 'o',
62
- description: 'Output file (default: remove ".enc")'
60
+ "output-file": command_1.flags.string({
61
+ char: "o",
62
+ description: 'Output file (default: remove ".enc")',
63
63
  }),
64
- 'vault-key': command_1.flags.string({
65
- description: 'Kuzzle Vault Key (or KUZZLE_VAULT_KEY)',
64
+ "vault-key": command_1.flags.string({
65
+ description: "Kuzzle Vault Key (or KUZZLE_VAULT_KEY)",
66
66
  default: process.env.KUZZLE_VAULT_KEY,
67
67
  }),
68
68
  };
69
69
  VaultDecrypt.args = [
70
- { name: 'file', description: 'File containing encrypted secrets', required: true }
70
+ {
71
+ name: "file",
72
+ description: "File containing encrypted secrets",
73
+ required: true,
74
+ },
71
75
  ];
@@ -1,13 +1,13 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../common";
3
3
  export declare class VaultEncrypt extends Kommand {
4
4
  static initSdk: boolean;
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
8
  force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
9
- 'output-file': flags.IOptionFlag<string | undefined>;
10
- 'vault-key': flags.IOptionFlag<string | undefined>;
9
+ "output-file": flags.IOptionFlag<string | undefined>;
10
+ "vault-key": flags.IOptionFlag<string | undefined>;
11
11
  };
12
12
  static args: {
13
13
  name: string;
@@ -2,36 +2,36 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VaultEncrypt = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const fs_1 = tslib_1.__importDefault(require("fs"));
6
- const path_1 = tslib_1.__importDefault(require("path"));
7
- const lodash_1 = tslib_1.__importDefault(require("lodash"));
5
+ const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
6
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
7
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
8
8
  const command_1 = require("@oclif/command");
9
9
  const kuzzle_vault_1 = require("kuzzle-vault");
10
10
  const common_1 = require("../../common");
11
11
  class VaultEncrypt extends common_1.Kommand {
12
12
  async runSafe() {
13
- if (lodash_1.default.isEmpty(this.flags['vault-key'])) {
14
- throw new Error('A vault key must be provided');
13
+ if (lodash_1.default.isEmpty(this.flags["vault-key"])) {
14
+ throw new Error("A vault key must be provided");
15
15
  }
16
16
  if (lodash_1.default.isEmpty(this.args.file)) {
17
- throw new Error('A secrets file must be provided');
17
+ throw new Error("A secrets file must be provided");
18
18
  }
19
19
  const { name, ext } = path_1.default.parse(this.args.file);
20
20
  let outputFile = `${name}.enc${ext}`;
21
- if (this.flags['output-file']) {
22
- outputFile = this.flags['output-file'];
21
+ if (this.flags["output-file"]) {
22
+ outputFile = this.flags["output-file"];
23
23
  }
24
24
  if (fs_1.default.existsSync(outputFile) && !this.flags.force) {
25
25
  throw new Error(`Output file "${outputFile}" already exists. Use -f flag to overwrite it.`);
26
26
  }
27
- const cryptonomicon = new kuzzle_vault_1.Cryptonomicon(this.flags['vault-key']);
27
+ const cryptonomicon = new kuzzle_vault_1.Cryptonomicon(this.flags["vault-key"]);
28
28
  if (!fs_1.default.existsSync(this.args.file)) {
29
29
  throw new Error(`File "${this.args.file}" does not exists`);
30
30
  }
31
31
  const PARSER = kuzzle_vault_1.Vault.getParser(this.args.file);
32
32
  let secrets = {};
33
33
  try {
34
- secrets = PARSER.parse(fs_1.default.readFileSync(this.args.file, 'utf8'));
34
+ secrets = PARSER.parse(fs_1.default.readFileSync(this.args.file, "utf8"));
35
35
  }
36
36
  catch (error) {
37
37
  throw new Error(`Cannot read secrets from file "${this.args.file}": ${error.message}`);
@@ -62,23 +62,27 @@ Encrypted secrets are meant to be loaded inside an application with Kuzzle Vault
62
62
  See https://github.com/kuzzleio/kuzzle-vault/ for more information.
63
63
  `;
64
64
  VaultEncrypt.examples = [
65
- 'kourou vault:encrypt config/secrets.json --vault-key <vault-key>',
66
- 'kourou vault:encrypt config/secrets.json -o config/secrets_prod.enc.json --vault-key <vault-key>'
65
+ "kourou vault:encrypt config/secrets.json --vault-key <vault-key>",
66
+ "kourou vault:encrypt config/secrets.json -o config/secrets_prod.enc.json --vault-key <vault-key>",
67
67
  ];
68
68
  VaultEncrypt.flags = {
69
69
  force: command_1.flags.boolean({
70
- char: 'f',
71
- description: 'Overwrite the output file if it already exists'
70
+ char: "f",
71
+ description: "Overwrite the output file if it already exists",
72
72
  }),
73
- 'output-file': command_1.flags.string({
74
- char: 'o',
75
- description: 'Output file (default: <file>.enc.json)'
73
+ "output-file": command_1.flags.string({
74
+ char: "o",
75
+ description: "Output file (default: <file>.enc.json)",
76
76
  }),
77
- 'vault-key': command_1.flags.string({
78
- description: 'Kuzzle Vault Key (or KUZZLE_VAULT_KEY)',
77
+ "vault-key": command_1.flags.string({
78
+ description: "Kuzzle Vault Key (or KUZZLE_VAULT_KEY)",
79
79
  default: process.env.KUZZLE_VAULT_KEY,
80
80
  }),
81
81
  };
82
82
  VaultEncrypt.args = [
83
- { name: 'file', description: 'File containing unencrypted secrets', required: true }
83
+ {
84
+ name: "file",
85
+ description: "File containing unencrypted secrets",
86
+ required: true,
87
+ },
84
88
  ];
@@ -1,11 +1,11 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../common";
3
3
  export declare class VaultShow extends Kommand {
4
4
  static initSdk: boolean;
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
- 'vault-key': flags.IOptionFlag<string | undefined>;
8
+ "vault-key": flags.IOptionFlag<string | undefined>;
9
9
  };
10
10
  static args: ({
11
11
  name: string;
@@ -3,30 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VaultShow = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const command_1 = require("@oclif/command");
6
- const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
- const fs_1 = tslib_1.__importDefault(require("fs"));
8
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
7
+ const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
8
+ const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
9
9
  const kuzzle_vault_1 = require("kuzzle-vault");
10
10
  const common_1 = require("../../common");
11
11
  class VaultShow extends common_1.Kommand {
12
12
  async runSafe() {
13
- if (lodash_1.default.isEmpty(this.flags['vault-key'])) {
14
- throw new Error('A vault key must be provided');
13
+ if (lodash_1.default.isEmpty(this.flags["vault-key"])) {
14
+ throw new Error("A vault key must be provided");
15
15
  }
16
- if (lodash_1.default.isEmpty(this.args['secrets-file'])) {
17
- throw new Error('A secrets file must be provided');
16
+ if (lodash_1.default.isEmpty(this.args["secrets-file"])) {
17
+ throw new Error("A secrets file must be provided");
18
18
  }
19
- const cryptonomicon = new kuzzle_vault_1.Cryptonomicon(this.flags['vault-key']);
20
- if (!fs_1.default.existsSync(this.args['secrets-file'])) {
21
- throw new Error(`File "${this.args['secrets-file']}" does not exists`);
19
+ const cryptonomicon = new kuzzle_vault_1.Cryptonomicon(this.flags["vault-key"]);
20
+ if (!fs_1.default.existsSync(this.args["secrets-file"])) {
21
+ throw new Error(`File "${this.args["secrets-file"]}" does not exists`);
22
22
  }
23
- const PARSER = kuzzle_vault_1.Vault.getParser(this.args['secrets-file']);
23
+ const PARSER = kuzzle_vault_1.Vault.getParser(this.args["secrets-file"]);
24
24
  let encryptedSecrets = {};
25
25
  try {
26
- encryptedSecrets = PARSER.parse(fs_1.default.readFileSync(this.args['secrets-file'], 'utf8'));
26
+ encryptedSecrets = PARSER.parse(fs_1.default.readFileSync(this.args["secrets-file"], "utf8"));
27
27
  }
28
28
  catch (error) {
29
- throw new Error(`Cannot read secrets from file "${this.args['secrets-file']}": ${error.message}`);
29
+ throw new Error(`Cannot read secrets from file "${this.args["secrets-file"]}": ${error.message}`);
30
30
  }
31
31
  if (this.args.key) {
32
32
  const encryptedValue = lodash_1.default.get(encryptedSecrets, this.args.key);
@@ -39,7 +39,7 @@ class VaultShow extends common_1.Kommand {
39
39
  }
40
40
  else {
41
41
  const decryptedSecrets = cryptonomicon.decryptObject(encryptedSecrets);
42
- this.logOk('Secrets file content:');
42
+ this.logOk("Secrets file content:");
43
43
  this.log(chalk_1.default.green(PARSER.stringify(decryptedSecrets, null, 2)));
44
44
  }
45
45
  }
@@ -56,16 +56,20 @@ This method can display either:
56
56
  See https://github.com/kuzzleio/kuzzle-vault/ for more information.
57
57
  `;
58
58
  VaultShow.examples = [
59
- 'kourou vault:show config/secrets.enc.json --vault-key <vault-key>',
60
- 'kourou vault:show config/secrets.enc.json aws.s3.secretKey --vault-key <vault-key>'
59
+ "kourou vault:show config/secrets.enc.json --vault-key <vault-key>",
60
+ "kourou vault:show config/secrets.enc.json aws.s3.secretKey --vault-key <vault-key>",
61
61
  ];
62
62
  VaultShow.flags = {
63
- 'vault-key': command_1.flags.string({
64
- description: 'Kuzzle Vault Key (or KUZZLE_VAULT_KEY)',
63
+ "vault-key": command_1.flags.string({
64
+ description: "Kuzzle Vault Key (or KUZZLE_VAULT_KEY)",
65
65
  default: process.env.KUZZLE_VAULT_KEY,
66
66
  }),
67
67
  };
68
68
  VaultShow.args = [
69
- { name: 'secrets-file', description: 'Encrypted secrets file', required: true },
70
- { name: 'key', description: 'Path to a key (lodash style)' },
69
+ {
70
+ name: "secrets-file",
71
+ description: "Encrypted secrets file",
72
+ required: true,
73
+ },
74
+ { name: "key", description: "Path to a key (lodash style)" },
71
75
  ];
@@ -1,11 +1,11 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../common";
3
3
  export declare class VaultTest extends Kommand {
4
4
  static initSdk: boolean;
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
- 'vault-key': flags.IOptionFlag<string | undefined>;
8
+ "vault-key": flags.IOptionFlag<string | undefined>;
9
9
  };
10
10
  static args: {
11
11
  name: string;
@@ -3,21 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VaultTest = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const command_1 = require("@oclif/command");
6
- const lodash_1 = tslib_1.__importDefault(require("lodash"));
6
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
7
7
  const kuzzle_vault_1 = require("kuzzle-vault");
8
8
  const common_1 = require("../../common");
9
9
  class VaultTest extends common_1.Kommand {
10
10
  async runSafe() {
11
- if (lodash_1.default.isEmpty(this.flags['vault-key'])) {
12
- throw new Error('A vault key must be provided');
11
+ if (lodash_1.default.isEmpty(this.flags["vault-key"])) {
12
+ throw new Error("A vault key must be provided");
13
13
  }
14
- if (lodash_1.default.isEmpty(this.args['secrets-file'])) {
15
- throw new Error('A secrets file must be provided');
14
+ if (lodash_1.default.isEmpty(this.args["secrets-file"])) {
15
+ throw new Error("A secrets file must be provided");
16
16
  }
17
- const vault = new kuzzle_vault_1.Vault(this.flags['vault-key']);
17
+ const vault = new kuzzle_vault_1.Vault(this.flags["vault-key"]);
18
18
  try {
19
- vault.decrypt(this.args['secrets-file']);
20
- this.logOk('Secrets file can be decrypted');
19
+ vault.decrypt(this.args["secrets-file"]);
20
+ this.logOk("Secrets file can be decrypted");
21
21
  }
22
22
  catch (error) {
23
23
  this.logKo(`Secrets file cannot be decrypted: ${error.message}`);
@@ -32,14 +32,18 @@ Tests if an encrypted secrets file can be decrypted.
32
32
  See https://github.com/kuzzleio/kuzzle-vault/ for more information.
33
33
  `;
34
34
  VaultTest.examples = [
35
- 'kourou vault:test config/secrets.enc.json --vault-key <vault-key>'
35
+ "kourou vault:test config/secrets.enc.json --vault-key <vault-key>",
36
36
  ];
37
37
  VaultTest.flags = {
38
- 'vault-key': command_1.flags.string({
39
- description: 'Kuzzle Vault Key (or KUZZLE_VAULT_KEY)',
38
+ "vault-key": command_1.flags.string({
39
+ description: "Kuzzle Vault Key (or KUZZLE_VAULT_KEY)",
40
40
  default: process.env.KUZZLE_VAULT_KEY,
41
41
  }),
42
42
  };
43
43
  VaultTest.args = [
44
- { name: 'secrets-file', description: 'Encrypted secrets file', required: true }
44
+ {
45
+ name: "secrets-file",
46
+ description: "Encrypted secrets file",
47
+ required: true,
48
+ },
45
49
  ];
package/lib/common.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Command } from '@oclif/command';
2
- import { KuzzleSDK } from './support/kuzzle';
3
- import { EditorParams } from './support/editor';
1
+ import { Command } from "@oclif/command";
2
+ import { KuzzleSDK } from "./support/kuzzle";
3
+ import { EditorParams } from "./support/editor";
4
4
  export declare abstract class Kommand extends Command {
5
5
  protected sdk: KuzzleSDK;
6
6
  private exitCode;