zcatalyst-cli 1.7.1 → 1.9.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 (179) hide show
  1. package/README.md +31 -10
  2. package/docs/apig-utils.toml +69 -0
  3. package/docs/authentication/index.toml +15 -0
  4. package/docs/authentication/login.toml +14 -0
  5. package/docs/client-utils.toml +24 -0
  6. package/docs/command_needs/auth.toml +4 -0
  7. package/docs/command_needs/rc.toml +24 -0
  8. package/docs/commands/apig/disable.toml +4 -0
  9. package/docs/commands/apig/enable.toml +4 -0
  10. package/docs/commands/apig/status.toml +4 -0
  11. package/docs/commands/client/delete.toml +34 -0
  12. package/docs/commands/ds/export.toml +4 -0
  13. package/docs/commands/ds/import.toml +15 -0
  14. package/docs/commands/ds/status.toml +9 -0
  15. package/docs/commands/event/generate/index.toml +29 -0
  16. package/docs/commands/event/generate/integ.toml +4 -0
  17. package/docs/commands/functions/config.toml +11 -0
  18. package/docs/commands/functions/delete.toml +29 -0
  19. package/docs/commands/project/use.toml +9 -0
  20. package/docs/dc.toml +4 -0
  21. package/docs/deploy/features/apig.toml +4 -0
  22. package/docs/deploy/features/functions/index.toml +4 -0
  23. package/docs/event_generate/cache.toml +4 -0
  24. package/docs/event_generate/custom.toml +4 -0
  25. package/docs/event_generate/datastore.toml +4 -0
  26. package/docs/event_generate/filestore.toml +4 -0
  27. package/docs/event_generate/integration/cliq.toml +9 -0
  28. package/docs/execute-script.toml +19 -0
  29. package/docs/fn-utils/lib/common.toml +25 -0
  30. package/docs/fn-utils/lib/java.toml +34 -0
  31. package/docs/fn-utils/lib/node.toml +4 -0
  32. package/docs/init/index.toml +4 -0
  33. package/docs/internal/command.toml +4 -0
  34. package/docs/internal/config.toml +9 -0
  35. package/docs/internal/credential.toml +14 -0
  36. package/docs/option-filter.toml +45 -0
  37. package/docs/port-resolver.toml +9 -0
  38. package/docs/pull/index.toml +4 -0
  39. package/docs/serve/index.toml +4 -0
  40. package/docs/shell/index.toml +4 -0
  41. package/docs/util_modules/project.toml +9 -0
  42. package/lib/apig-utils.js +133 -43
  43. package/lib/archiver.js +4 -2
  44. package/lib/authentication/index.js +44 -9
  45. package/lib/authentication/login.js +51 -8
  46. package/lib/bin/catalyst.js +14 -7
  47. package/lib/client-utils.js +47 -14
  48. package/lib/client.js +1 -1
  49. package/lib/command_needs/auth.js +5 -3
  50. package/lib/command_needs/rc.js +35 -13
  51. package/lib/commands/apig/disable.js +8 -3
  52. package/lib/commands/apig/enable.js +8 -3
  53. package/lib/commands/apig/status.js +29 -9
  54. package/lib/commands/client/delete.js +65 -26
  55. package/lib/commands/client/setup.js +2 -2
  56. package/lib/commands/deploy.js +2 -2
  57. package/lib/commands/ds/export.js +16 -8
  58. package/lib/commands/ds/import.js +20 -14
  59. package/lib/commands/ds/status.js +22 -11
  60. package/lib/commands/event/generate/index.js +62 -12
  61. package/lib/commands/event/generate/integ.js +7 -3
  62. package/lib/commands/functions/add.js +2 -2
  63. package/lib/commands/functions/config.js +11 -3
  64. package/lib/commands/functions/delete.js +36 -13
  65. package/lib/commands/functions/setup.js +2 -2
  66. package/lib/commands/functions/shell.js +2 -2
  67. package/lib/commands/help.js +1 -1
  68. package/lib/commands/index.js +2 -3
  69. package/lib/commands/init.js +4 -4
  70. package/lib/commands/login.js +2 -2
  71. package/lib/commands/logout.js +2 -2
  72. package/lib/commands/project/list.js +2 -2
  73. package/lib/commands/project/reset.js +1 -1
  74. package/lib/commands/project/use.js +18 -2
  75. package/lib/commands/pull.js +5 -5
  76. package/lib/commands/run.js +2 -2
  77. package/lib/commands/serve.js +7 -6
  78. package/lib/commands/token/generate.js +2 -2
  79. package/lib/commands/token/list.js +2 -2
  80. package/lib/commands/token/revoke.js +2 -2
  81. package/lib/commands/whoami.js +1 -1
  82. package/lib/dc.js +11 -1
  83. package/lib/deploy/features/apig.js +33 -33
  84. package/lib/deploy/features/client.js +12 -19
  85. package/lib/deploy/features/functions/index.js +14 -4
  86. package/lib/deploy/features/index.js +1 -1
  87. package/lib/deploy/index.js +2 -9
  88. package/lib/endpoints/index.js +5 -2
  89. package/lib/endpoints/lib/apig.js +15 -5
  90. package/lib/endpoints/lib/applogic.js +12 -4
  91. package/lib/endpoints/lib/cache.js +9 -3
  92. package/lib/endpoints/lib/catalyst-details.js +37 -0
  93. package/lib/endpoints/lib/client.js +15 -5
  94. package/lib/endpoints/lib/datastore.js +6 -2
  95. package/lib/endpoints/lib/ds-bulk.js +15 -5
  96. package/lib/endpoints/lib/env.js +3 -1
  97. package/lib/endpoints/lib/event-bus.js +3 -1
  98. package/lib/endpoints/lib/filestore.js +6 -2
  99. package/lib/endpoints/lib/functions.js +12 -4
  100. package/lib/endpoints/lib/project.js +9 -3
  101. package/lib/endpoints/lib/queue.js +9 -3
  102. package/lib/endpoints/lib/sdk.js +3 -1
  103. package/lib/endpoints/lib/zcql.js +3 -1
  104. package/lib/error.js +18 -0
  105. package/lib/errorOut.js +10 -7
  106. package/lib/event_generate/cache.js +9 -1
  107. package/lib/event_generate/custom.js +6 -1
  108. package/lib/event_generate/datastore.js +12 -2
  109. package/lib/event_generate/filestore.js +9 -1
  110. package/lib/event_generate/integration/cliq.js +10 -2
  111. package/lib/execute-script.js +35 -6
  112. package/lib/express_middlewares/unknownReqProxy.js +18 -7
  113. package/lib/fn-utils/index.js +1 -1
  114. package/lib/fn-utils/lib/common.js +95 -17
  115. package/lib/fn-utils/lib/integ.js +4 -3
  116. package/lib/fn-utils/lib/java.js +49 -13
  117. package/lib/fn-utils/lib/node.js +15 -6
  118. package/lib/fn-watcher.js +67 -0
  119. package/lib/index.js +13 -12
  120. package/lib/init/dependencies/package-json.js +3 -1
  121. package/lib/init/features/functions/index.js +41 -29
  122. package/lib/init/features/functions/languages/java.js +5 -4
  123. package/lib/init/features/functions/languages/node.js +6 -5
  124. package/lib/init/features/index.js +8 -4
  125. package/lib/init/index.js +10 -3
  126. package/lib/internal/api.js +9 -9
  127. package/lib/internal/command.js +19 -14
  128. package/lib/internal/config.js +15 -15
  129. package/lib/internal/credential.js +33 -7
  130. package/lib/internal/rc.js +18 -10
  131. package/lib/migration/global/1.4.0.js +4 -2
  132. package/lib/migration/global/1.6.2.js +4 -2
  133. package/lib/migration/index.js +1 -1
  134. package/lib/option-filter.js +79 -22
  135. package/lib/optional-import.js +1 -1
  136. package/lib/plugin-loader.js +1 -1
  137. package/lib/port-resolver.js +23 -3
  138. package/lib/prompt.js +1 -1
  139. package/lib/pull/features/functions/index.js +7 -7
  140. package/lib/pull/features/index.js +1 -1
  141. package/lib/pull/index.js +10 -3
  142. package/lib/repl-server.js +9 -5
  143. package/lib/serve/features/index.js +11 -2
  144. package/lib/serve/index.js +19 -9
  145. package/lib/serve/server/index.js +137 -60
  146. package/lib/serve/server/lib/client.js +1 -1
  147. package/lib/serve/server/lib/master.js +16 -3
  148. package/lib/serve/server/lib/node.js +1 -1
  149. package/lib/shell/dependencies/http-functions.js +120 -90
  150. package/lib/shell/dependencies/invoker/integ/node.js +1 -1
  151. package/lib/shell/dependencies/local-function.js +86 -119
  152. package/lib/shell/index.js +10 -10
  153. package/lib/shell/prepare/index.js +1 -4
  154. package/lib/shell/prepare/languages/index.js +15 -4
  155. package/lib/track.js +4 -1
  156. package/lib/util_modules/config/index.js +1 -1
  157. package/lib/util_modules/config/lib/apig.js +3 -3
  158. package/lib/util_modules/config/lib/client.js +3 -3
  159. package/lib/util_modules/config/lib/functions.js +5 -5
  160. package/lib/util_modules/constants/index.js +22 -20
  161. package/lib/util_modules/constants/lib/regex.js +3 -2
  162. package/lib/util_modules/constants/lib/runtime.js +9 -0
  163. package/lib/util_modules/contextHelp.js +63 -123
  164. package/lib/util_modules/fs/index.js +1 -1
  165. package/lib/util_modules/fs/lib/async.js +19 -2
  166. package/lib/util_modules/fs/lib/sync.js +13 -1
  167. package/lib/util_modules/logger.js +12 -20
  168. package/lib/util_modules/option.js +1 -13
  169. package/lib/util_modules/project.js +75 -26
  170. package/lib/util_modules/shell.js +8 -2
  171. package/package.json +45 -45
  172. package/scripts/postInstall.js +31 -0
  173. package/lib/cjson.js +0 -20
  174. package/lib/log-error.js +0 -18
  175. package/lib/util_modules/big-json.js +0 -16
  176. package/lib/util_modules/constants/lib/stack.js +0 -6
  177. package/templates/init/functions/.DS_Store +0 -0
  178. package/templates/init/functions/node/.DS_Store +0 -0
  179. package/templates/init/functions/node/integ/.DS_Store +0 -0
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -33,7 +33,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  const command_1 = __importDefault(require("../internal/command"));
35
35
  exports.default = new command_1.default('logout')
36
- .description('Log the CLI out of your Zoho Catalyst account')
36
+ .description('Log the CLI out of your Catalyst account')
37
37
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
38
38
  const auth = yield Promise.resolve().then(() => __importStar(require('../authentication')));
39
39
  return auth.logout();
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -38,7 +38,7 @@ const constants_1 = require("../../util_modules/constants");
38
38
  const logger_1 = require("../../util_modules/logger");
39
39
  const project_1 = require("../../util_modules/project");
40
40
  exports.default = new command_1.default('project:list')
41
- .description('List the Catalyst projects you have access to')
41
+ .description('List all the Catalyst projects you have access to')
42
42
  .needs('auth', [constants_1.SCOPE.projects])
43
43
  .needs('config', { optional: true, resolveOnNotFound: true })
44
44
  .needs('rc', { optional: true })
@@ -17,7 +17,7 @@ const constants_1 = require("../../util_modules/constants");
17
17
  const logger_1 = require("../../util_modules/logger");
18
18
  const project_1 = require("../../util_modules/project");
19
19
  exports.default = new command_1.default('project:reset')
20
- .description('Clear an active selection of project and reset to base project')
20
+ .description('Clear an active project selection and reset to the base project')
21
21
  .needs('auth', [constants_1.SCOPE.projects])
22
22
  .needs('config', { optional: true, resolveOnNotFound: true })
23
23
  .needs('rc')
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const ansi_colors_1 = require("ansi-colors");
15
16
  const endpoints_1 = require("../../endpoints");
16
17
  const error_1 = __importDefault(require("../../error"));
17
18
  const command_1 = __importDefault(require("../../internal/command"));
@@ -34,7 +35,17 @@ exports.default = new command_1.default('project:use [name_or_project_id]')
34
35
  });
35
36
  logger_1.success('Successfully made project active');
36
37
  });
37
- const allProjects = (yield (yield endpoints_1.projectAPI()).getAllProjects());
38
+ const allProjects = (yield (yield endpoints_1.projectAPI()).getAllProjects().catch(() => {
39
+ throw new error_1.default('Unable to get projects', {
40
+ exit: 2
41
+ });
42
+ }));
43
+ if (allProjects.length === 0) {
44
+ throw new error_1.default('No projects found', {
45
+ exit: 0,
46
+ errorId: 'PROJ-USE-1'
47
+ });
48
+ }
38
49
  if (allProjects.length === 1) {
39
50
  logger_1.message('only one project found in remote, ignoring user input and making it as active');
40
51
  return makeActive(allProjects[0]);
@@ -46,7 +57,12 @@ exports.default = new command_1.default('project:use [name_or_project_id]')
46
57
  : transformedProjects.find((proj) => proj.name === newActive);
47
58
  if (optedProject === undefined) {
48
59
  throw new error_1.default('provided project does not match any project in remote', {
49
- exit: 0
60
+ exit: 1,
61
+ errorId: 'PROJ-USE-2',
62
+ arg: [
63
+ ansi_colors_1.bold(newActive),
64
+ ansi_colors_1.bold(allProjects.map((project) => '* ' + project.project_name).join('\n'))
65
+ ]
50
66
  });
51
67
  }
52
68
  return makeActive(optedProject);
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -32,7 +32,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
32
32
  };
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  const ansi_colors_1 = require("ansi-colors");
35
- const error_1 = __importDefault(require("../error"));
36
35
  const features_1 = require("../init/features");
37
36
  const command_1 = __importDefault(require("../internal/command"));
38
37
  const prompt_1 = __importDefault(require("../prompt"));
@@ -43,7 +42,7 @@ const fs_1 = require("../util_modules/fs");
43
42
  const js_1 = require("../util_modules/js");
44
43
  const logger_1 = require("../util_modules/logger");
45
44
  exports.default = new command_1.default('pull [feature]')
46
- .description('Pull an existing project from Catalyst')
45
+ .description('Pull resources of your project from the remote console to the local directory')
47
46
  .needs('auth', [constants_1.SCOPE.functions, constants_1.SCOPE.webapp])
48
47
  .needs('config', { optional: true })
49
48
  .needs('rc')
@@ -79,7 +78,8 @@ exports.default = new command_1.default('pull [feature]')
79
78
  }))
80
79
  : { confirmation: true };
81
80
  if (!ans.confirmation) {
82
- throw new error_1.default('Aborted by user.', { exit: 1 });
81
+ logger_1.message('Aborted by user.');
82
+ return;
83
83
  }
84
84
  let featureAns = { features: [feature] };
85
85
  if (feature === undefined) {
@@ -88,7 +88,7 @@ exports.default = new command_1.default('pull [feature]')
88
88
  value: 'functions',
89
89
  short: 'Functions'
90
90
  }),
91
- prompt_1.default.choice('Client: Choose from list of versions perviously deployed', {
91
+ prompt_1.default.choice('Client: Choose from list of versions previously deployed', {
92
92
  value: 'client',
93
93
  short: 'Client'
94
94
  }),
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -38,7 +38,7 @@ const constants_1 = require("../util_modules/constants");
38
38
  const logger_1 = require("../util_modules/logger");
39
39
  exports.default = new command_1.default('run-script [command]')
40
40
  .alias('run')
41
- .description('run a particular command script')
41
+ .description('Run a particular command script defined in catalyst.json')
42
42
  .needs('auth')
43
43
  .needs('config')
44
44
  .needs('rc', { optional: true, resolveOnNotFound: true })
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -34,13 +34,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
34
34
  const command_1 = __importDefault(require("../internal/command"));
35
35
  const constants_1 = require("../util_modules/constants");
36
36
  exports.default = new command_1.default('serve')
37
- .description('Serve your code for local testing without affecting the production')
37
+ .description('Serve Basic I/O and Advanced I/O functions, and the client, to test them locally')
38
38
  .option('--http <port>', 'start the server at specified port ')
39
- .option('--debug <type:port>', 'the functions are invoked from local environment enabling debugging options on provided or default ports ' +
40
- '(e.g. "advancedio:8000,basicio:8080")' +
41
- `(default: advancedio:<name>:${constants_1.DEFAULT.serve_port.debug.advancedio},basicio:${constants_1.DEFAULT.serve_port.debug.basicio})`)
42
- .option('--bind <port>', 'the port on which functions are running in http mode using functions:shell')
39
+ .option('--debug <type:port>', 'the functions are invoked from local environment enabling debugging options on provided ports ' +
40
+ `(example: advancedio:<name>:${constants_1.DEFAULT.serve_port.debug.advancedio},basicio:${constants_1.DEFAULT.serve_port.debug.basicio})`)
41
+ .option('--proxy <url>', 'proxy url to proxy any unknown request to the given url ' +
42
+ '(e.g. "http://localhost:8080")')
43
43
  .option('--only <targets>', 'only serve specified, comma-separated targets (e.g. "client,functions:f1")')
44
+ .option('--watch', 'watch for file and directory changes and enable hot reload')
44
45
  .option('--except <targets>', 'serve all targets except specified (e.g. "client")')
45
46
  .option('--ignore-scripts', 'ignore the pre and post lifescycle scripts')
46
47
  .needs('auth', [constants_1.SCOPE.functions, constants_1.SCOPE.functions_execution, constants_1.SCOPE.webapp])
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -34,7 +34,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
34
34
  const command_1 = __importDefault(require("../../internal/command"));
35
35
  const logger_1 = require("../../util_modules/logger");
36
36
  exports.default = new command_1.default('token:generate')
37
- .description('Create a CLI token in order to use in CI systems')
37
+ .description('Generate a token to authenticate accessing the CLI from a remote system')
38
38
  .option('--current', 'prints out the existing token used by this CLI')
39
39
  .needs('auth')
40
40
  .ignore(['token'])
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -35,7 +35,7 @@ const ansi_colors_1 = require("ansi-colors");
35
35
  const command_1 = __importDefault(require("../../internal/command"));
36
36
  const logger_1 = require("../../util_modules/logger");
37
37
  exports.default = new command_1.default('token:list')
38
- .description('List all the available tokens created from this cli')
38
+ .description('List all the available tokens generated in this CLI')
39
39
  .ignore(['token'])
40
40
  .needs('auth')
41
41
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -34,7 +34,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
34
34
  const command_1 = __importDefault(require("../../internal/command"));
35
35
  const logger_1 = require("../../util_modules/logger");
36
36
  exports.default = new command_1.default('token:revoke <id>')
37
- .description('Revoke the token created from this CLI')
37
+ .description('Revoke a token generated in this CLI')
38
38
  .needs('auth')
39
39
  .ignore(['token'])
40
40
  .action((input) => __awaiter(void 0, void 0, void 0, function* () {
@@ -18,7 +18,7 @@ const dc_1 = require("../dc");
18
18
  const command_1 = __importDefault(require("../internal/command"));
19
19
  const logger_1 = require("../util_modules/logger");
20
20
  exports.default = new command_1.default('whoami')
21
- .description('prints out the current logged in user email id')
21
+ .description('Print the email address of the user currently logged in')
22
22
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
23
23
  const activeDC = dc_1.getActiveDC();
24
24
  const user = config_store_1.default.get(`${activeDC}.user`);
package/lib/dc.js CHANGED
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.updateActiveDC = exports.getActiveDCType = exports.getActiveDC = void 0;
7
+ const ansi_colors_1 = require("ansi-colors");
7
8
  const config_store_1 = __importDefault(require("./config-store"));
8
9
  const error_1 = __importDefault(require("./error"));
9
10
  const constants_1 = require("./util_modules/constants");
@@ -23,7 +24,16 @@ function getActiveDC() {
23
24
  }
24
25
  if (typeof dcOption === 'string') {
25
26
  if (!Object.keys(constants_1.DC_TYPE).includes(dcOption)) {
26
- throw new error_1.default('Provide DC in global option is not valid. Use "us" | "eu" | "in" as values.', { exit: 1 });
27
+ throw new error_1.default('Provide DC in global option is not valid: ' + dcOption, {
28
+ exit: 1,
29
+ errorId: 'DC-1',
30
+ arg: [
31
+ ansi_colors_1.bold.red(dcOption),
32
+ ansi_colors_1.bold(Object.keys(constants_1.DC_TYPE)
33
+ .map((dc) => '* ' + dc)
34
+ .join('\n'))
35
+ ]
36
+ });
27
37
  }
28
38
  return constants_1.DC_TYPE[dcOption].value;
29
39
  }
@@ -12,47 +12,47 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const ansi_colors_1 = require("ansi-colors");
15
16
  const apig_utils_1 = require("../../apig-utils");
16
17
  const endpoints_1 = require("../../endpoints");
18
+ const error_1 = __importDefault(require("../../error"));
17
19
  const runtime_store_1 = __importDefault(require("../../runtime-store"));
18
20
  const config_1 = require("../../util_modules/config");
19
21
  const constants_1 = require("../../util_modules/constants");
20
22
  const logger_1 = require("../../util_modules/logger");
21
23
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
22
- try {
23
- const api = yield endpoints_1.apigAPI();
24
- const response = (yield api.getAPIGStatus());
25
- if (response.scheduled) {
26
- logger_1.labeled('apig', 'Skipping deploy since previous schedule is not over yet.').ERROR();
27
- logger_1.labeled('apig', 'You can deploy apig separately using "--only apig" option next time.').MESSAGE();
28
- return;
29
- }
30
- if (config_1.apigConfig.enabled(null) === null) {
31
- logger_1.labeled('apig', 'Skipping deploy, since unable to detect the status of API Gateway from ' +
32
- constants_1.FILENAME.config).ERROR();
33
- return;
34
- }
35
- if (!config_1.apigConfig.enabled()) {
36
- if (response.status) {
37
- yield api.updateAPIGStatus(false);
38
- logger_1.labeled('apig', 'Disabled successfully').SUCCESS();
39
- }
40
- logger_1.labeled('apig', 'Skipping deploy since API Gateway is not enabled locally in ' + constants_1.FILENAME.config).ERROR();
41
- return;
42
- }
43
- if (config_1.apigConfig.enabled() && !response.status) {
44
- yield api.updateAPIGStatus(true);
45
- logger_1.labeled('apig', 'Enabled successfully').SUCCESS();
24
+ const api = yield endpoints_1.apigAPI();
25
+ const response = (yield api.getAPIGStatus());
26
+ if (response.scheduled) {
27
+ logger_1.labeled('apig', 'Skipping deploy since previous schedule is not over yet.').ERROR();
28
+ logger_1.labeled('apig', 'You can deploy apig separately using "--only apig" option next time.').MESSAGE();
29
+ return;
30
+ }
31
+ if (config_1.apigConfig.enabled(null) === null) {
32
+ throw new error_1.default('Skipping deploy, since unable to detect the status of API Gateway from ' +
33
+ constants_1.FILENAME.config, {
34
+ exit: 2
35
+ });
36
+ }
37
+ if (!config_1.apigConfig.enabled()) {
38
+ if (response.status) {
39
+ yield api.updateAPIGStatus(false);
40
+ logger_1.labeled('apig', 'Disabled successfully').SUCCESS();
46
41
  }
47
- apig_utils_1.apigUtils.executeHook({ prefix: 'pre', command: 'deploy' });
48
- yield apig_utils_1.apigUtils.validate();
49
- const readStream = yield apig_utils_1.apigUtils.pack();
50
- yield api.deploy(readStream);
51
- runtime_store_1.default.set('payload.apig.deploy', true);
52
- apig_utils_1.apigUtils.executeHook({ prefix: 'post', command: 'deploy' });
42
+ throw new error_1.default('APIG not enabled locally', {
43
+ errorId: 'APIG-1',
44
+ arg: [ansi_colors_1.bold('catalyst apig:enable')],
45
+ exit: 0
46
+ });
53
47
  }
54
- catch (err) {
55
- logger_1.labeled('apig', err.message || err).WARN();
56
- return;
48
+ if (config_1.apigConfig.enabled() && !response.status) {
49
+ yield api.updateAPIGStatus(true);
50
+ logger_1.labeled('apig', 'Enabled successfully').SUCCESS();
57
51
  }
52
+ apig_utils_1.apigUtils.executeHook({ prefix: 'pre', command: 'deploy' });
53
+ yield apig_utils_1.apigUtils.validate();
54
+ const readStream = yield apig_utils_1.apigUtils.pack();
55
+ yield api.deploy(readStream);
56
+ runtime_store_1.default.set('payload.apig.deploy', true);
57
+ apig_utils_1.apigUtils.executeHook({ prefix: 'post', command: 'deploy' });
58
58
  });
@@ -16,24 +16,17 @@ const client_utils_1 = require("../../client-utils");
16
16
  const endpoints_1 = require("../../endpoints");
17
17
  const runtime_store_1 = __importDefault(require("../../runtime-store"));
18
18
  const constants_1 = require("../../util_modules/constants");
19
- const logger_1 = require("../../util_modules/logger");
20
19
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
21
- try {
22
- client_utils_1.clientUtils.executeHook({ prefix: 'pre', command: 'deploy' });
23
- yield client_utils_1.clientUtils.validate();
24
- const readStream = yield client_utils_1.clientUtils.pack();
25
- const resp = (yield (yield endpoints_1.clientAPI()).deploy(readStream));
26
- runtime_store_1.default.set('payload.client.url', 'https://' +
27
- resp.url_prefix +
28
- '.' +
29
- constants_1.ORIGIN.app.replace('https://', '') +
30
- '/app/' +
31
- runtime_store_1.default.get('context.client.homepage'));
32
- runtime_store_1.default.set('payload.client.deploy', true);
33
- client_utils_1.clientUtils.executeHook({ prefix: 'post', command: 'deploy' });
34
- }
35
- catch (err) {
36
- logger_1.labeled('client', err.message || err).WARN();
37
- return;
38
- }
20
+ client_utils_1.clientUtils.executeHook({ prefix: 'pre', command: 'deploy' });
21
+ yield client_utils_1.clientUtils.validate();
22
+ const readStream = yield client_utils_1.clientUtils.pack();
23
+ const resp = (yield (yield endpoints_1.clientAPI()).deploy(readStream));
24
+ runtime_store_1.default.set('payload.client.url', 'https://' +
25
+ resp.url_prefix +
26
+ '.' +
27
+ constants_1.ORIGIN.app.replace('https://', '') +
28
+ '/app/' +
29
+ runtime_store_1.default.get('context.client.homepage'));
30
+ runtime_store_1.default.set('payload.client.deploy', true);
31
+ client_utils_1.clientUtils.executeHook({ prefix: 'post', command: 'deploy' });
39
32
  });
@@ -12,24 +12,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const ansi_colors_1 = require("ansi-colors");
15
16
  const endpoints_1 = require("../../../endpoints");
16
17
  const error_1 = __importDefault(require("../../../error"));
17
18
  const fn_utils_1 = require("../../../fn-utils");
18
19
  const runtime_store_1 = __importDefault(require("../../../runtime-store"));
19
20
  const constants_1 = require("../../../util_modules/constants");
21
+ const runtime_1 = __importDefault(require("../../../util_modules/constants/lib/runtime"));
20
22
  const logger_1 = require("../../../util_modules/logger");
23
+ const option_1 = require("../../../util_modules/option");
21
24
  const languages_1 = require("./languages");
22
25
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
23
26
  fn_utils_1.fnUtils.common.executeHook({ prefix: 'pre', command: 'deploy' });
24
27
  const targets = yield fn_utils_1.fnUtils.common.validate();
25
28
  if (targets.length === 0) {
26
- throw new error_1.default('No functions are ready to be deployed', { exit: 1 });
29
+ const only = option_1.getOptionValue('only', false);
30
+ const except = option_1.getOptionValue('except', false);
31
+ const option = only ? 'only' : except ? 'except' : 'none';
32
+ throw new error_1.default('No functions are ready to be deployed', {
33
+ exit: 1,
34
+ errorId: 'IDX-1',
35
+ arg: [ansi_colors_1.bold(option)]
36
+ });
27
37
  }
28
38
  const refinedTargets = yield fn_utils_1.fnUtils.common.refineTargets(targets);
29
39
  runtime_store_1.default.set('context.functions.targets', refinedTargets);
30
40
  const packedTargets = yield Promise.all([
31
- languages_1.node(refinedTargets.filter((target) => target.stack === constants_1.STACK.node10 && target.valid)),
32
- languages_1.java(refinedTargets.filter((target) => target.stack === constants_1.STACK.java8 && target.valid))
41
+ languages_1.node(refinedTargets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.nodejs)) && target.valid; })),
42
+ languages_1.java(refinedTargets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java)) && target.valid; }))
33
43
  ]);
34
44
  const combinedTarget = [...(packedTargets[0] || []), ...(packedTargets[1] || [])];
35
45
  const batchSize = 1;
@@ -69,7 +79,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
69
79
  }
70
80
  const allTargets = refinedTargets.filter((target) => {
71
81
  if (!target.valid) {
72
- logger_1.warning('skipping deploy of target ' + target.source + ' since ' + target.failure_reason);
82
+ logger_1.warning('skipping deploy of target [' + target.name + '] since ' + target.failure_reason);
73
83
  }
74
84
  return target.valid;
75
85
  });
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -12,8 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const ansi_colors_1 = require("ansi-colors");
16
- const error_1 = __importDefault(require("../error"));
17
15
  const runtime_store_1 = __importDefault(require("../runtime-store"));
18
16
  const logger_1 = require("../util_modules/logger");
19
17
  const features_1 = __importDefault(require("./features"));
@@ -27,20 +25,15 @@ function deploy() {
27
25
  if (currentTarget === undefined) {
28
26
  return deploy();
29
27
  }
30
- if (!Object.keys(features_1.default).includes(currentTarget)) {
31
- throw new error_1.default(ansi_colors_1.bold(currentTarget) +
32
- ' is not a valid feature. Must be one of ' +
33
- Object.keys(features_1.default).join(','), { exit: 1 });
34
- }
35
28
  const featureModule = features_1.default[currentTarget];
36
29
  runtime_store_1.default.set('context.current.target', currentTarget);
37
30
  try {
38
- yield featureModule();
39
31
  runtime_store_1.default.set('payload.targets', runtime_store_1.default.get('payload.targets', []).concat(currentTarget));
32
+ yield featureModule();
40
33
  }
41
34
  catch (error) {
35
+ logger_1.debug(`${currentTarget} deploy unsuccessful, reason : ${error.stack}`);
42
36
  logger_1.labeled(currentTarget, error.message).WARN();
43
- logger_1.debug(error.stack);
44
37
  }
45
38
  return deploy();
46
39
  });
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -128,8 +128,11 @@ function eventBusAPI({ auth = true, projectId = project_1.getProjectId(), env =
128
128
  });
129
129
  }
130
130
  exports.eventBusAPI = eventBusAPI;
131
- function logAPI({ auth = true, projectId = project_1.getProjectId(), env = project_1.getEnvName() } = {}) {
131
+ function logAPI({ auth = true, projectId = project_1.getProjectId(-1), env = project_1.getEnvName() } = {}) {
132
132
  return __awaiter(this, void 0, void 0, function* () {
133
+ if (projectId === -1) {
134
+ return;
135
+ }
133
136
  const log = (yield Promise.resolve().then(() => __importStar(require('./lib/log')))).default;
134
137
  return new log(projectId, { authNeeded: auth, env });
135
138
  });
@@ -33,7 +33,9 @@ class Apig {
33
33
  return res.body.data;
34
34
  }
35
35
  logger_1.debug('get all apis response from server : ' + res.body);
36
- throw new error_1.default('Server Error: Unexpected Response from server.', { exit: 2 });
36
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
37
+ exit: 2
38
+ });
37
39
  });
38
40
  }
39
41
  deploy(sourceStream) {
@@ -48,7 +50,9 @@ class Apig {
48
50
  return res.body.data;
49
51
  }
50
52
  logger_1.debug('deploy APIG response from server : ' + res.body);
51
- throw new error_1.default('Server Error: Unexpected Response from server.', { exit: 2 });
53
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
54
+ exit: 2
55
+ });
52
56
  });
53
57
  }
54
58
  getAllRules() {
@@ -72,7 +76,9 @@ class Apig {
72
76
  return res.body.data;
73
77
  }
74
78
  logger_1.debug('get all apis response from server : ' + res.body);
75
- throw new error_1.default('Server Error: Unexpected Response from server.', { exit: 2 });
79
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
80
+ exit: 2
81
+ });
76
82
  });
77
83
  }
78
84
  getScheduleReport(prev = false) {
@@ -86,7 +92,9 @@ class Apig {
86
92
  return res.body.data;
87
93
  }
88
94
  logger_1.debug('getScheduleReport response from server : ' + res.body);
89
- throw new error_1.default('Server Error: Unexpected Response from server.', { exit: 2 });
95
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
96
+ exit: 2
97
+ });
90
98
  });
91
99
  }
92
100
  updateAPIGStatus(status) {
@@ -101,7 +109,9 @@ class Apig {
101
109
  return res.body.data;
102
110
  }
103
111
  logger_1.debug('change status of APIG response from server : ' + res.body);
104
- throw new error_1.default('Server Error: Unexpected Response from server.', { exit: 2 });
112
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
113
+ exit: 2
114
+ });
105
115
  });
106
116
  }
107
117
  }
@@ -43,7 +43,9 @@ class Applogic {
43
43
  return res.body.data;
44
44
  }
45
45
  logger_1.debug('save applogic response from server : ' + res.body);
46
- throw new error_1.default('Server Error: Unexpected Response from server.', { exit: 2 });
46
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
47
+ exit: 2
48
+ });
47
49
  });
48
50
  }
49
51
  getAllApplogic() {
@@ -53,7 +55,9 @@ class Applogic {
53
55
  return res.body.data;
54
56
  }
55
57
  logger_1.debug('get applogic response from server : ' + res.body);
56
- throw new error_1.default('Server Error: Unexpected Response from server.', { exit: 2 });
58
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
59
+ exit: 2
60
+ });
57
61
  });
58
62
  }
59
63
  download(name) {
@@ -69,7 +73,9 @@ class Applogic {
69
73
  return res.body;
70
74
  }
71
75
  logger_1.debug('java sdk response from server : ' + res.body);
72
- throw new error_1.default('Server Error: Unexpected Response from server.', { exit: 2 });
76
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
77
+ exit: 2
78
+ });
73
79
  });
74
80
  }
75
81
  delete(id) {
@@ -79,7 +85,9 @@ class Applogic {
79
85
  return res.body.data;
80
86
  }
81
87
  logger_1.debug('delete applogic response from server : ' + res.body);
82
- throw new error_1.default('Server Error: Unexpected Response from server.', { exit: 2 });
88
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
89
+ exit: 2
90
+ });
83
91
  });
84
92
  }
85
93
  }