zcatalyst-cli 1.11.1 → 1.13.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 (188) hide show
  1. package/docs/optional-import.toml +10 -0
  2. package/lib/apig-utils.js +39 -39
  3. package/lib/archiver.js +13 -9
  4. package/lib/authentication/index.js +22 -18
  5. package/lib/authentication/login.js +37 -39
  6. package/lib/bin/catalyst.js +15 -15
  7. package/lib/cli_table/src/cell.js +26 -26
  8. package/lib/cli_table/src/layout-manager.js +44 -45
  9. package/lib/cli_table/src/table.js +9 -9
  10. package/lib/cli_table/src/utils.js +35 -36
  11. package/lib/client-utils.js +18 -18
  12. package/lib/client.js +1 -1
  13. package/lib/command_needs/auth.js +7 -7
  14. package/lib/command_needs/rc.js +24 -24
  15. package/lib/commands/apig/disable.js +5 -5
  16. package/lib/commands/apig/enable.js +5 -5
  17. package/lib/commands/apig/status.js +9 -9
  18. package/lib/commands/client/delete.js +19 -19
  19. package/lib/commands/client/setup.js +8 -4
  20. package/lib/commands/deploy.js +18 -14
  21. package/lib/commands/ds/export.js +11 -11
  22. package/lib/commands/ds/import.js +12 -12
  23. package/lib/commands/ds/status.js +15 -15
  24. package/lib/commands/event/generate/index.js +21 -17
  25. package/lib/commands/event/generate/integ.js +7 -3
  26. package/lib/commands/functions/add.js +8 -4
  27. package/lib/commands/functions/config.js +5 -5
  28. package/lib/commands/functions/delete.js +22 -22
  29. package/lib/commands/functions/setup.js +8 -4
  30. package/lib/commands/functions/shell.js +12 -5
  31. package/lib/commands/help.js +4 -4
  32. package/lib/commands/iac/export.js +8 -8
  33. package/lib/commands/iac/import.js +29 -21
  34. package/lib/commands/iac/pack.js +15 -11
  35. package/lib/commands/iac/status.js +6 -2
  36. package/lib/commands/index.js +5 -1
  37. package/lib/commands/init.js +14 -10
  38. package/lib/commands/login.js +5 -1
  39. package/lib/commands/logout.js +5 -1
  40. package/lib/commands/project/list.js +14 -10
  41. package/lib/commands/project/reset.js +5 -5
  42. package/lib/commands/project/use.js +9 -9
  43. package/lib/commands/pull.js +18 -14
  44. package/lib/commands/run.js +13 -9
  45. package/lib/commands/serve.js +5 -1
  46. package/lib/commands/token/generate.js +6 -2
  47. package/lib/commands/token/list.js +7 -3
  48. package/lib/commands/token/revoke.js +6 -2
  49. package/lib/commands/whoami.js +3 -3
  50. package/lib/dc.js +2 -2
  51. package/lib/deploy/features/apig.js +6 -6
  52. package/lib/deploy/features/client.js +1 -1
  53. package/lib/deploy/features/functions/index.js +9 -9
  54. package/lib/deploy/features/index.js +5 -1
  55. package/lib/deploy/index.js +2 -2
  56. package/lib/endpoints/index.js +17 -13
  57. package/lib/endpoints/lib/apig.js +5 -5
  58. package/lib/endpoints/lib/applogic.js +4 -4
  59. package/lib/endpoints/lib/cache.js +3 -3
  60. package/lib/endpoints/lib/catalyst-details.js +1 -1
  61. package/lib/endpoints/lib/client.js +5 -5
  62. package/lib/endpoints/lib/datastore.js +2 -2
  63. package/lib/endpoints/lib/ds-bulk.js +5 -5
  64. package/lib/endpoints/lib/env.js +1 -1
  65. package/lib/endpoints/lib/event-bus.js +1 -1
  66. package/lib/endpoints/lib/filestore.js +2 -2
  67. package/lib/endpoints/lib/functions.js +4 -4
  68. package/lib/endpoints/lib/iac.js +10 -10
  69. package/lib/endpoints/lib/project.js +20 -5
  70. package/lib/endpoints/lib/queue.js +3 -3
  71. package/lib/endpoints/lib/sdk.js +1 -1
  72. package/lib/endpoints/lib/zcql.js +1 -1
  73. package/lib/error.js +11 -9
  74. package/lib/errorOut.js +2 -2
  75. package/lib/event_generate/cache.js +5 -5
  76. package/lib/event_generate/custom.js +2 -2
  77. package/lib/event_generate/datastore.js +5 -5
  78. package/lib/event_generate/filestore.js +5 -5
  79. package/lib/event_generate/integration/cliq.js +3 -3
  80. package/lib/event_generate/user.js +1 -1
  81. package/lib/event_generate/webapp.js +5 -5
  82. package/lib/execute-script.js +19 -15
  83. package/lib/express_middlewares/authenticator.js +32 -5
  84. package/lib/express_middlewares/logger.js +2 -2
  85. package/lib/express_middlewares/unknownReqProxy.js +1 -1
  86. package/lib/fn-utils/index.js +5 -1
  87. package/lib/fn-utils/lib/common.js +44 -44
  88. package/lib/fn-utils/lib/integ.js +9 -9
  89. package/lib/fn-utils/lib/java.js +48 -46
  90. package/lib/fn-utils/lib/node.js +8 -8
  91. package/lib/fn-watcher.js +9 -11
  92. package/lib/iac/status/bundle.js +5 -5
  93. package/lib/iac/status/deploy.js +4 -4
  94. package/lib/index.js +2 -2
  95. package/lib/init/dependencies/npm-install.js +8 -1
  96. package/lib/init/dependencies/package-json.js +6 -6
  97. package/lib/init/features/client/index.js +5 -1
  98. package/lib/init/features/client/initializers/angular.js +29 -27
  99. package/lib/init/features/client/initializers/basic.js +10 -6
  100. package/lib/init/features/client/initializers/lyte.js +12 -13
  101. package/lib/init/features/client/initializers/react.js +23 -18
  102. package/lib/init/features/functions/index.js +23 -14
  103. package/lib/init/features/functions/languages/java.js +10 -10
  104. package/lib/init/features/functions/languages/node.js +9 -9
  105. package/lib/init/features/index.js +12 -8
  106. package/lib/init/features/project.js +20 -20
  107. package/lib/init/index.js +2 -2
  108. package/lib/init/util/client.js +12 -7
  109. package/lib/init/util/functions.js +1 -1
  110. package/lib/init/util/project.js +4 -4
  111. package/lib/internal/api.js +19 -19
  112. package/lib/internal/command.js +20 -16
  113. package/lib/internal/config.js +5 -5
  114. package/lib/internal/credential.js +10 -10
  115. package/lib/internal/crypt.js +5 -5
  116. package/lib/internal/rc.js +5 -5
  117. package/lib/migration/global/1.6.2.js +3 -3
  118. package/lib/migration/index.js +22 -18
  119. package/lib/option-filter.js +34 -30
  120. package/lib/optional-import.js +30 -11
  121. package/lib/plugin-loader.js +28 -13
  122. package/lib/port-resolver.js +4 -4
  123. package/lib/progress.js +2 -2
  124. package/lib/prompt/index.js +6 -2
  125. package/lib/prompt/types/file-path.js +1 -1
  126. package/lib/pull/features/apig.js +9 -9
  127. package/lib/pull/features/client.js +7 -7
  128. package/lib/pull/features/functions/index.js +15 -15
  129. package/lib/pull/features/index.js +5 -1
  130. package/lib/pull/index.js +4 -4
  131. package/lib/repl-server.js +2 -2
  132. package/lib/serve/features/apig.js +1 -1
  133. package/lib/serve/features/index.js +8 -4
  134. package/lib/serve/index.js +15 -11
  135. package/lib/serve/server/index.js +34 -27
  136. package/lib/serve/server/lib/java/JavaaioServer.java +5 -3
  137. package/lib/serve/server/lib/java/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
  138. package/lib/serve/server/lib/java/lib/catalyst-java-runtime-1.0.0.jar +0 -0
  139. package/lib/serve/server/lib/java/lib/zip4j-2.5.0.jar +0 -0
  140. package/lib/serve/server/lib/master.js +33 -36
  141. package/lib/serve/server/lib/node.js +7 -3
  142. package/lib/serve/server/lib/web_client/index.js +3 -3
  143. package/lib/serve/server/lib/web_client/server.js +33 -30
  144. package/lib/shell/dependencies/http-functions.js +38 -33
  145. package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +14 -3
  146. package/lib/shell/dependencies/invoker/bio/node.js +5 -2
  147. package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +7 -2
  148. package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +7 -2
  149. package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +7 -2
  150. package/lib/shell/dependencies/invoker/integ/node.js +8 -4
  151. package/lib/shell/dependencies/local-function.js +44 -40
  152. package/lib/shell/index.js +16 -12
  153. package/lib/shell/prepare/index.js +2 -2
  154. package/lib/shell/prepare/languages/index.js +5 -1
  155. package/lib/shell/prepare/languages/java.js +1 -1
  156. package/lib/throbber/index.js +17 -17
  157. package/lib/throbber/utils.js +9 -9
  158. package/lib/track.js +7 -7
  159. package/lib/util_modules/config/index.js +5 -1
  160. package/lib/util_modules/config/lib/client.js +18 -21
  161. package/lib/util_modules/constants/lib/auth.js +6 -6
  162. package/lib/util_modules/constants/lib/cliq-handlers.js +2 -2
  163. package/lib/util_modules/constants/lib/template.js +21 -21
  164. package/lib/util_modules/constants/lib/urls.js +20 -12
  165. package/lib/util_modules/context-help.js +15 -15
  166. package/lib/util_modules/fs/index.js +5 -1
  167. package/lib/util_modules/fs/lib/async.js +4 -4
  168. package/lib/util_modules/fs/utils.js +1 -1
  169. package/lib/util_modules/global-space.js +0 -97
  170. package/lib/util_modules/logger.js +2 -2
  171. package/lib/util_modules/parser/toml.js +1 -1
  172. package/lib/util_modules/project.js +6 -6
  173. package/lib/util_modules/server.js +53 -0
  174. package/lib/util_modules/shell.js +4 -4
  175. package/lib/winston.js +5 -5
  176. package/package.json +40 -40
  177. package/scripts/postInstall.js +7 -6
  178. package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +23 -5
  179. package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +23 -8
  180. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -3
  181. package/templates/init/functions/node/integ/cliq/package.json +2 -1
  182. package/templates/init/functions/node/integ/cliq/sample.js +3 -1
  183. package/docs/.DS_Store +0 -0
  184. package/lib/serve/server/lib/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  185. package/templates/.DS_Store +0 -0
  186. package/templates/init/.DS_Store +0 -0
  187. package/templates/init/client/.DS_Store +0 -0
  188. package/templates/init/client/react/.DS_Store +0 -0
@@ -27,7 +27,7 @@ const runtime_1 = __importDefault(require("../../../../util_modules/constants/li
27
27
  const functions_1 = require("../../../util/functions");
28
28
  exports.default = (stack) => () => __awaiter(void 0, void 0, void 0, function* () {
29
29
  const fnType = runtime_store_1.default.get('context.functions.type');
30
- const fnDirPath = path_1.join(runtime_store_1.default.get('context.functions.dir_path'));
30
+ const fnDirPath = (0, path_1.join)(runtime_store_1.default.get('context.functions.dir_path'));
31
31
  yield fs_1.ASYNC.ensureDir(fnDirPath);
32
32
  const functionAns = yield prompt_1.default.ask(prompt_1.default.question('name', 'What will be the name of the java function? This will also be the folder name. ', {
33
33
  defaultAns: 'sample',
@@ -47,18 +47,18 @@ exports.default = (stack) => () => __awaiter(void 0, void 0, void 0, function* (
47
47
  return 'Invalid class name';
48
48
  }
49
49
  }));
50
- const targetPath = path_1.join(fnDirPath, functionAns.name);
50
+ const targetPath = (0, path_1.join)(fnDirPath, functionAns.name);
51
51
  const dirExists = yield fs_1.ASYNC.dirExists(targetPath);
52
52
  const overwriteAns = dirExists
53
53
  ? yield prompt_1.default.ask(prompt_1.default.question('overwrite', 'Directory ' +
54
- ansi_colors_1.underline(functionAns.name) +
54
+ (0, ansi_colors_1.underline)(functionAns.name) +
55
55
  ' already exists inside functions directory. Overwrite ?', {
56
56
  type: 'confirm',
57
57
  defaultAns: false
58
58
  }))
59
59
  : { overwrite: true };
60
60
  if (!overwriteAns.overwrite) {
61
- logger_1.warning('Skipping functions java setup...');
61
+ (0, logger_1.warning)('Skipping functions java setup...');
62
62
  return;
63
63
  }
64
64
  yield fs_1.ASYNC.deleteDir(targetPath).catch();
@@ -67,7 +67,7 @@ exports.default = (stack) => () => __awaiter(void 0, void 0, void 0, function* (
67
67
  ? js_1.JS.get(constants_1.TEMPLATE.functions.java[fnType], service)
68
68
  : constants_1.TEMPLATE.functions.java[fnType];
69
69
  if (fnType === constants_1.FN_TYPE.integration) {
70
- yield integ_1.copyIntegHandlers(templatePath, targetPath, runtime_1.default.language.java);
70
+ yield (0, integ_1.copyIntegHandlers)(templatePath, targetPath, runtime_1.default.language.java);
71
71
  }
72
72
  else {
73
73
  yield fs_1.ASYNC.copyDir(templatePath, targetPath);
@@ -79,12 +79,12 @@ exports.default = (stack) => () => __awaiter(void 0, void 0, void 0, function* (
79
79
  type: fnType,
80
80
  integ_config
81
81
  });
82
- yield fs_1.ASYNC.rename(path_1.join(fnDirPath, functionAns.name, constants_1.FILENAME.functions.java_main), () => functionAns.class + '.java');
83
- yield common_1.getSDK(fnType, path_1.join(fnDirPath, functionAns.name, constants_1.FOLDERNAME.java_fn_lib), 'java', {
82
+ yield fs_1.ASYNC.rename((0, path_1.join)(fnDirPath, functionAns.name, constants_1.FILENAME.functions.java_main), () => functionAns.class + '.java');
83
+ yield (0, common_1.getSDK)(fnType, (0, path_1.join)(fnDirPath, functionAns.name, constants_1.FOLDERNAME.java_fn_lib), 'java', {
84
84
  service
85
85
  });
86
- const userFnClassPath = path_1.join(fnDirPath, functionAns.name, constants_1.FILENAME.functions.java_classpath);
87
- const userFnLibPath = path_1.join(fnDirPath, functionAns.name, constants_1.FOLDERNAME.java_fn_lib);
86
+ const userFnClassPath = (0, path_1.join)(fnDirPath, functionAns.name, constants_1.FILENAME.functions.java_classpath);
87
+ const userFnLibPath = (0, path_1.join)(fnDirPath, functionAns.name, constants_1.FOLDERNAME.java_fn_lib);
88
88
  yield fn_utils_1.fnUtils.java.rewriteClasspath(userFnClassPath, userFnLibPath);
89
- return functions_1.fillFunctionsInitPayload(targetPath, functionAns.name, stack, fnType);
89
+ return (0, functions_1.fillFunctionsInitPayload)(targetPath, functionAns.name, stack, fnType);
90
90
  });
@@ -34,29 +34,29 @@ exports.default = (stack) => () => __awaiter(void 0, void 0, void 0, function* (
34
34
  : constants_1.TEMPLATE.functions.node[fnType];
35
35
  const functionsDirPath = runtime_store_1.default.get('context.functions.dir_path');
36
36
  yield fs_1.ASYNC.ensureDir(functionsDirPath);
37
- const finalJson = yield package_json_1.default(templatePath, ['name', 'main', 'author']);
38
- const targetPath = path_1.join(functionsDirPath, finalJson.name);
37
+ const finalJson = yield (0, package_json_1.default)(templatePath, ['name', 'main', 'author']);
38
+ const targetPath = (0, path_1.join)(functionsDirPath, finalJson.name);
39
39
  const dirExists = yield fs_1.ASYNC.dirExists(targetPath);
40
40
  const overwriteAns = dirExists
41
41
  ? yield prompt_1.default.ask(prompt_1.default.question('overwrite', 'Directory ' +
42
- ansi_colors_1.underline(finalJson.name) +
42
+ (0, ansi_colors_1.underline)(finalJson.name) +
43
43
  ' already exists inside functions directory. Overwrite ?', {
44
44
  type: 'confirm',
45
45
  defaultAns: false
46
46
  }))
47
47
  : { overwrite: true };
48
48
  if (!overwriteAns.overwrite) {
49
- logger_1.warning('Skipping functions node setup...');
49
+ (0, logger_1.warning)('Skipping functions node setup...');
50
50
  return;
51
51
  }
52
52
  yield fs_1.ASYNC.deleteDir(targetPath).catch();
53
53
  if (fnType === constants_1.FN_TYPE.integration) {
54
- yield integ_1.copyIntegHandlers(templatePath, targetPath, runtime_1.default.language.nodejs);
54
+ yield (0, integ_1.copyIntegHandlers)(templatePath, targetPath, runtime_1.default.language.nodejs);
55
55
  }
56
56
  else {
57
57
  yield fs_1.ASYNC.copyDir(templatePath, targetPath);
58
58
  }
59
- yield fs_1.ASYNC.rename(path_1.join(targetPath, constants_1.FILENAME.functions.node_main), () => finalJson.main);
59
+ yield fs_1.ASYNC.rename((0, path_1.join)(targetPath, constants_1.FILENAME.functions.node_main), () => finalJson.main);
60
60
  const placeholderArr = [];
61
61
  const replaceArr = [];
62
62
  Object.keys(constants_1.PLACEHOLDER.functions.node_package).forEach((key) => {
@@ -71,7 +71,7 @@ exports.default = (stack) => () => __awaiter(void 0, void 0, void 0, function* (
71
71
  integ_config
72
72
  });
73
73
  fnType === constants_1.FN_TYPE.integration
74
- ? yield npm_install_1.default(targetPath, true)
75
- : yield npm_install_1.default(targetPath);
76
- return functions_1.fillFunctionsInitPayload(targetPath, finalJson.name, stack, fnType);
74
+ ? yield (0, npm_install_1.default)(targetPath, true)
75
+ : yield (0, npm_install_1.default)(targetPath);
76
+ return (0, functions_1.fillFunctionsInitPayload)(targetPath, finalJson.name, stack, fnType);
77
77
  });
@@ -1,7 +1,11 @@
1
1
  'use strict';
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -51,7 +55,7 @@ function upsertEnvArr(envArr, idx = 0) {
51
55
  }
52
56
  const currentEnvObj = envArr[idx];
53
57
  const isDefault = currentEnvObj.env_name === constants_1.DEFAULT.env_name;
54
- yield project_1.upsertEnv(currentEnvObj.project_details.id + '', currentEnvObj, {
58
+ yield (0, project_1.upsertEnv)(currentEnvObj.project_details.id + '', currentEnvObj, {
55
59
  base: isDefault,
56
60
  active: isDefault
57
61
  });
@@ -75,8 +79,8 @@ function setFnConfig(featureName, add) {
75
79
  const config = runtime_store_1.default.get('config');
76
80
  featureContextArr.forEach((context) => {
77
81
  var _a, _b;
78
- const targetSourceDir = featureName === 'functions' ? path_1.dirname(context.source) : context.source;
79
- const targetSource = path_1.relative(project_1.getProjectRoot(), targetSourceDir);
82
+ const targetSourceDir = featureName === 'functions' ? (0, path_1.dirname)(context.source) : context.source;
83
+ const targetSource = (0, path_1.relative)((0, project_1.getProjectRoot)(), targetSourceDir);
80
84
  switch (featureName) {
81
85
  case 'functions':
82
86
  if (!add) {
@@ -92,7 +96,7 @@ function setFnConfig(featureName, add) {
92
96
  ? js_1.JS.uniq(ignoreArr.concat(['.output']))
93
97
  : ignoreArr);
94
98
  if (config.get(featureName + '.source') !== targetSource) {
95
- logger_1.warning(featureName + ' source has been modified');
99
+ (0, logger_1.warning)(featureName + ' source has been modified');
96
100
  config.set(featureName + '.source', targetSource);
97
101
  }
98
102
  break;
@@ -135,15 +139,15 @@ function project() {
135
139
  if (!projectPayload) {
136
140
  return;
137
141
  }
138
- yield project_1.upsertProject(projectPayload, {
142
+ yield (0, project_1.upsertProject)(projectPayload, {
139
143
  base: true,
140
144
  active: true
141
145
  });
142
146
  yield upsertEnvArr(runtime_store_1.default.get('payload.env', null));
143
147
  if (runtime_store_1.default.get('payload.project.new', false)) {
144
- logger_1.message('New Project has been successfully created and associated with this directory.');
148
+ (0, logger_1.message)('New Project has been successfully created and associated with this directory.');
145
149
  }
146
- logger_1.message(ansi_colors_1.bold(constants_1.FILENAME.rc) + ' file has be successfully created with project details.');
150
+ (0, logger_1.message)((0, ansi_colors_1.bold)(constants_1.FILENAME.rc) + ' file has be successfully created with project details.');
147
151
  const isImport = runtime_store_1.default.get('payload.project.import', false);
148
152
  if (isImport) {
149
153
  setFnConfig('functions', true);
@@ -22,7 +22,7 @@ const constants_1 = require("../../util_modules/constants");
22
22
  const js_1 = require("../../util_modules/js");
23
23
  const logger_1 = require("../../util_modules/logger");
24
24
  const option_1 = require("../../util_modules/option");
25
- const yaml_1 = __importDefault(require("yaml"));
25
+ const yaml_1 = require("yaml");
26
26
  const project_1 = require("../../util_modules/project");
27
27
  const path_1 = require("path");
28
28
  const functions_1 = require("../util/functions");
@@ -33,13 +33,13 @@ const fn_utils_1 = require("../../fn-utils");
33
33
  const client_utils_1 = require("../../client-utils");
34
34
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
35
35
  var _a, _b;
36
- const projectAPI = yield endpoints_1.projectAPI();
37
- const defaultRCProjectName = project_1.getDefaultProjectName(null);
38
- const defaultRCProjectId = project_1.getDefaultProjectId(null);
36
+ const projectAPI = yield (0, endpoints_1.projectAPI)();
37
+ const defaultRCProjectName = (0, project_1.getDefaultProjectName)(null);
38
+ const defaultRCProjectId = (0, project_1.getDefaultProjectId)(null);
39
39
  if (defaultRCProjectName !== null &&
40
40
  defaultRCProjectId !== null &&
41
- !option_1.getOptionValue('force', false)) {
42
- logger_1.message(constants_1.FILENAME.rc + ' already has ' + ansi_colors_1.bold(defaultRCProjectName) + ' as a default project.');
41
+ !(0, option_1.getOptionValue)('force', false)) {
42
+ (0, logger_1.message)(constants_1.FILENAME.rc + ' already has ' + (0, ansi_colors_1.bold)(defaultRCProjectName) + ' as a default project.');
43
43
  try {
44
44
  yield projectAPI.getProject(defaultRCProjectId);
45
45
  throw new error_1.default('Skipping project setup, since project directory contains a default project. To overwrite use --force option');
@@ -48,17 +48,17 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
48
48
  if (js_1.JS.get(err, 'context.response.statusCode') !== 404) {
49
49
  throw err;
50
50
  }
51
- logger_1.warning('cleaning up ' +
51
+ (0, logger_1.warning)('cleaning up ' +
52
52
  constants_1.FILENAME.rc +
53
53
  ' since the current default project for this folder is not found in remote');
54
- yield project_1.removeProject(defaultRCProjectId + '');
54
+ yield (0, project_1.removeProject)(defaultRCProjectId + '');
55
55
  }
56
56
  }
57
- logger_1.message('Setting up a new default project for this folder\n');
57
+ (0, logger_1.message)('Setting up a new default project for this folder\n');
58
58
  const allProjects = (yield projectAPI.getAllProjects());
59
59
  if (allProjects.length === 0) {
60
60
  throw new error_1.default('Visit ' +
61
- ansi_colors_1.underline(constants_1.ORIGIN.console) +
61
+ (0, ansi_colors_1.underline)(constants_1.ORIGIN.console) +
62
62
  ' for creation of your first project before you continue.', { exit: 1 });
63
63
  }
64
64
  const projectChoices = [
@@ -83,21 +83,21 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
83
83
  }));
84
84
  let selectedProject = projectAns.project;
85
85
  if (typeof selectedProject !== 'number') {
86
- return project_2.fillProjectPayload(selectedProject);
86
+ return (0, project_2.fillProjectPayload)(selectedProject);
87
87
  }
88
88
  if (selectedProject === 0) {
89
89
  const projectNameAns = yield prompt_1.default.ask(prompt_1.default.question('projectName', 'Provide a name for your new project:', {
90
90
  validate: (ans) => (ans.match(constants_1.REGEX.project.name) ? true : 'Invalid project name')
91
91
  }));
92
92
  selectedProject = yield projectAPI.createProject(projectNameAns.projectName);
93
- return project_2.fillProjectPayload(selectedProject, true);
93
+ return (0, project_2.fillProjectPayload)(selectedProject, true);
94
94
  }
95
- const [zipArchive, template, importRes] = yield import_1.iacImport();
95
+ const [zipArchive, template, importRes] = yield (0, import_1.iacImport)();
96
96
  yield zipArchive
97
97
  .extract(runtime_store_1.default.get('cwd'), '/', { recursive: true, ignoreInitial: false })
98
98
  .finalize();
99
99
  const parsedJSON = js_1.JS.parseJSON(template);
100
- const templateJson = parsedJSON ? parsedJSON : yaml_1.default.parse(template);
100
+ const templateJson = parsedJSON ? parsedJSON : (0, yaml_1.parse)(template);
101
101
  const functions = ((_a = templateJson.components) === null || _a === void 0 ? void 0 : _a.Functions) || [];
102
102
  const client = ((_b = templateJson.components) === null || _b === void 0 ? void 0 : _b.WebClient) || [];
103
103
  yield Promise.all(functions.map(({ properties }) => __awaiter(void 0, void 0, void 0, function* () {
@@ -110,26 +110,26 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
110
110
  ? fn_utils_1.fnUtils.java
111
111
  : null;
112
112
  if (fnUtil === null) {
113
- logger_1.warning(`skipping setup of function(${refinedTargets[0].name}) since provided stack ${stack} is not supported.`);
113
+ (0, logger_1.warning)(`skipping setup of function(${refinedTargets[0].name}) since provided stack ${stack} is not supported.`);
114
114
  return;
115
115
  }
116
116
  yield fnUtil.validate(refinedTargets, 0);
117
117
  if (!refinedTargets[0].valid) {
118
- logger_1.debug('Invalid target : ' +
118
+ (0, logger_1.debug)('Invalid target : ' +
119
119
  refinedTargets[0].name +
120
120
  ' reason : ' +
121
121
  refinedTargets[0].failure_reason);
122
- logger_1.warning(`skipping setup of function(${refinedTargets[0].name}) since the package is invalid. \nContact catalyst support with debug log.`);
122
+ (0, logger_1.warning)(`skipping setup of function(${refinedTargets[0].name}) since the package is invalid. \nContact catalyst support with debug log.`);
123
123
  return;
124
124
  }
125
- functions_1.fillFunctionsInitPayload(source, properties.name, properties.stack, properties.type);
125
+ (0, functions_1.fillFunctionsInitPayload)(source, properties.name, properties.stack, properties.type);
126
126
  })));
127
127
  if (client.length > 0) {
128
128
  const { properties } = client[0];
129
129
  const source = properties.code.path.replace('/', path_1.sep).replace('.zip', '');
130
130
  yield client_utils_1.clientUtils.validate(source);
131
- client_1.fillClientInitPayload(source, properties.app_name);
131
+ (0, client_1.fillClientInitPayload)(source, properties.app_name);
132
132
  }
133
133
  const projectDetails = yield projectAPI.getProject(importRes.project_details.id);
134
- return project_2.fillProjectPayload(projectDetails, true, true);
134
+ return (0, project_2.fillProjectPayload)(projectDetails, true, true);
135
135
  });
package/lib/init/index.js CHANGED
@@ -31,14 +31,14 @@ function init() {
31
31
  errorId: 'INIT-IDX-1',
32
32
  arg: [
33
33
  ansi_colors_1.bold.red(feature),
34
- ansi_colors_1.bold(Object.keys(features_1.default)
34
+ (0, ansi_colors_1.bold)(Object.keys(features_1.default)
35
35
  .map((feat) => '* ' + feat)
36
36
  .join('\n'))
37
37
  ]
38
38
  });
39
39
  }
40
40
  const MODULE = features_1.default[feature];
41
- logger_1.info(ansi_colors_1.bold('\n' + ansi_colors_1.white('===> ') + js_1.JS.capitalize(feature) + ' Setup'));
41
+ (0, logger_1.info)((0, ansi_colors_1.bold)('\n' + (0, ansi_colors_1.white)('===> ') + js_1.JS.capitalize(feature) + ' Setup'));
42
42
  yield MODULE();
43
43
  runtime_store_1.default.set('payload.features', runtime_store_1.default.get('payload.features', []).concat(feature));
44
44
  return init();
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -31,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
31
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
32
36
  };
33
37
  Object.defineProperty(exports, "__esModule", { value: true });
34
- exports.addDevDep = exports.clientNamePrompt = exports.directoryOverridePrompt = exports.fillClientInitPayload = void 0;
38
+ exports.addDependency = exports.clientNamePrompt = exports.directoryOverridePrompt = exports.fillClientInitPayload = void 0;
35
39
  const ansi_colors_1 = require("ansi-colors");
36
40
  const runtime_store_js_1 = __importDefault(require("../../runtime-store.js"));
37
41
  const error_js_1 = __importDefault(require("../../error.js"));
@@ -49,7 +53,7 @@ function directoryOverridePrompt(dir) {
49
53
  return __awaiter(this, void 0, void 0, function* () {
50
54
  const foldeExists = yield ASYNC.dirExists(dir);
51
55
  if (foldeExists) {
52
- const overwriteAns = yield index_js_1.default.ask(index_js_1.default.question('overwrite', 'Directory ' + ansi_colors_1.underline(dir) + ' already exists. Overwrite ?', {
56
+ const overwriteAns = yield index_js_1.default.ask(index_js_1.default.question('overwrite', 'Directory ' + (0, ansi_colors_1.underline)(dir) + ' already exists. Overwrite ?', {
53
57
  type: 'confirm',
54
58
  defaultAns: false
55
59
  }));
@@ -77,20 +81,21 @@ function clientNamePrompt(question, defaultAns) {
77
81
  });
78
82
  }
79
83
  exports.clientNamePrompt = clientNamePrompt;
80
- function addDevDep(filePath, dep, depPath = []) {
84
+ function addDependency(filePath, dep, { dev = false, depPath = [] } = {}) {
81
85
  return __awaiter(this, void 0, void 0, function* () {
82
86
  try {
83
87
  const packageJson = yield ASYNC.readJSONFile(filePath);
84
88
  if (packageJson) {
85
- depPath.push('devDependencies');
89
+ depPath.push(dev ? 'devDependencies' : 'dependencies');
90
+ js_js_1.JS.assign(dep, js_js_1.JS.get(packageJson, depPath));
86
91
  js_js_1.JS.set(packageJson, depPath, dep);
87
92
  yield ASYNC.writeJSONFile(filePath, packageJson);
88
93
  }
89
94
  }
90
95
  catch (e) {
91
96
  const err = error_js_1.default.getErrorInstance(e, { skipHelp: true });
92
- logger_js_1.debug(`unable to write to ${filePath}: ${err.message}`);
97
+ (0, logger_js_1.debug)(`unable to write to ${filePath}: ${err.message}`);
93
98
  }
94
99
  });
95
100
  }
96
- exports.addDevDep = addDevDep;
101
+ exports.addDependency = addDependency;
@@ -15,6 +15,6 @@ const fillFunctionsInitPayload = (source, name, stack, type) => {
15
15
  type
16
16
  });
17
17
  runtime_store_1.default.set('payload.functions.targets', existingFns);
18
- runtime_store_1.default.set('payload.functions.source', path_1.dirname(source));
18
+ runtime_store_1.default.set('payload.functions.source', (0, path_1.dirname)(source));
19
19
  };
20
20
  exports.fillFunctionsInitPayload = fillFunctionsInitPayload;
@@ -20,15 +20,15 @@ const constants_1 = require("../../util_modules/constants");
20
20
  const project_1 = require("../../util_modules/project");
21
21
  const fillProjectPayload = (selectedProject, isNew = false, isImport = false) => __awaiter(void 0, void 0, void 0, function* () {
22
22
  runtime_store_1.default.set('payload.project', selectedProject);
23
- runtime_store_1.default.set('project', project_1.transformProject(selectedProject));
24
- const envAPI = yield endpoints_1.envAPI();
25
- const envArr = (yield envAPI.getEnvs(project_1.getProjectId()));
23
+ runtime_store_1.default.set('project', (0, project_1.transformProject)(selectedProject));
24
+ const envAPI = yield (0, endpoints_1.envAPI)();
25
+ const envArr = (yield envAPI.getEnvs((0, project_1.getProjectId)()));
26
26
  const envObj = envArr.find((env) => env.env_name === constants_1.DEFAULT.env_name);
27
27
  if (envObj === undefined) {
28
28
  throw new error_1.default('There is no development environment found for this project. Kindly contact support.', { exit: 2 });
29
29
  }
30
30
  runtime_store_1.default.set('payload.env', envArr);
31
- runtime_store_1.default.set('project.env', project_1.transformEnv(envObj));
31
+ runtime_store_1.default.set('project.env', (0, project_1.transformEnv)(envObj));
32
32
  runtime_store_1.default.set('payload.project.new', isNew);
33
33
  runtime_store_1.default.set('payload.project.import', isImport);
34
34
  });
@@ -1,7 +1,11 @@
1
1
  'use strict';
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -40,18 +44,14 @@ const constants_1 = require("../util_modules/constants");
40
44
  const js_1 = require("../util_modules/js");
41
45
  const logger_1 = require("../util_modules/logger");
42
46
  class API {
43
- constructor({ authNeeded = true, resolveOnError = false, maxRetry = 3, env = constants_1.DEFAULT.env_name, log = {} } = {}) {
47
+ constructor({ authNeeded = true, resolveOnError = false, maxRetry = 3, env = constants_1.DEFAULT.env_name, log = {}, headers = {} } = {}) {
44
48
  this.requestOpts = {
45
49
  url: constants_1.ORIGIN.admin,
46
50
  method: 'GET',
47
51
  json: true,
48
- headers: {
49
- Accept: 'application/vnd.catalyst.v2+json',
50
- 'User-Agent': runtime_store_1.default.get('context.cli.package.name') +
52
+ headers: Object.assign(Object.assign({}, headers), { Accept: 'application/vnd.catalyst.v2+json', 'User-Agent': runtime_store_1.default.get('context.cli.package.name') +
51
53
  '/' +
52
- runtime_store_1.default.get('context.cli.package.version'),
53
- 'X-CATALYST-Environment': env
54
- }
54
+ runtime_store_1.default.get('context.cli.package.version'), 'X-CATALYST-Environment': env })
55
55
  };
56
56
  this.authNeeded = authNeeded;
57
57
  this.resolveOnHTTPError = resolveOnError;
@@ -72,7 +72,7 @@ class API {
72
72
  ? '\nRequest Form: ' + JSON.stringify(this.requestOpts.form)
73
73
  : '';
74
74
  body = this.logOpts.skipReqBody === true ? '\n<request body omitted>' : body;
75
- logger_1.debug('>>>> HTTP REQUEST : ' +
75
+ (0, logger_1.debug)('>>>> HTTP REQUEST : ' +
76
76
  this.requestOpts.method +
77
77
  ' ' +
78
78
  this.requestOpts.url +
@@ -82,15 +82,15 @@ class API {
82
82
  '\n');
83
83
  }
84
84
  _logResp(resp) {
85
- logger_1.debug('<<<< HTTP RESPONSE : ' +
85
+ (0, logger_1.debug)('<<<< HTTP RESPONSE : ' +
86
86
  resp.statusCode +
87
87
  '\n' +
88
88
  'Response Headers: ' +
89
89
  JSON.stringify(resp.headers) +
90
90
  '\n');
91
91
  if (!js_1.JS.isUndefined(resp.timings)) {
92
- logger_1.debug('TOTAL TIME TAKEN : ' + Number(resp.timings.end.toFixed(3)) + ' ms\n');
93
- logger_1.debug('REQUEST PHASES : ' + resp.timingPhases);
92
+ (0, logger_1.debug)('TOTAL TIME TAKEN : ' + Number(resp.timings.end.toFixed(3)) + ' ms\n');
93
+ (0, logger_1.debug)('REQUEST PHASES : ' + resp.timingPhases);
94
94
  }
95
95
  if (this.logOpts.progress !== undefined) {
96
96
  js_1.JS.set(this.logOpts, 'progress.total', resp.headers['content-length']);
@@ -117,13 +117,13 @@ class API {
117
117
  }
118
118
  catch (e) {
119
119
  const err = error_1.default.getErrorInstance(e);
120
- logger_1.debug('API Parsing Error: ' + err.message);
120
+ (0, logger_1.debug)('API Parsing Error: ' + err.message);
121
121
  }
122
122
  }
123
123
  if (resp.statusCode >= 400 && !this.logOpts.skipRespBody) {
124
- logger_1.debug('Response Body : ' + JSON.stringify(resp.body) + '\n');
124
+ (0, logger_1.debug)('Response Body : ' + JSON.stringify(resp.body) + '\n');
125
125
  if (!this.resolveOnHTTPError) {
126
- throw errorResponse_1.default(resp, body);
126
+ throw (0, errorResponse_1.default)(resp, body);
127
127
  }
128
128
  }
129
129
  return {
@@ -142,8 +142,8 @@ class API {
142
142
  exit: 2
143
143
  });
144
144
  }
145
- logger_1.debug('API Error while firing request : ' + err.message + '\n');
146
- logger_1.debug('>>>> RETRYING\n');
145
+ (0, logger_1.debug)('API Error while firing request : ' + err.message + '\n');
146
+ (0, logger_1.debug)('>>>> RETRYING\n');
147
147
  return this._request(true);
148
148
  });
149
149
  }
@@ -155,13 +155,13 @@ class API {
155
155
  return new Promise((resolve, reject) => {
156
156
  const responseBuffer = [];
157
157
  let isJSONResponse = false;
158
- request_1.default(this.requestOpts, (err) => __awaiter(this, void 0, void 0, function* () {
158
+ (0, request_1.default)(this.requestOpts, (err) => __awaiter(this, void 0, void 0, function* () {
159
159
  if (err) {
160
160
  switch (err.code) {
161
161
  case 'ETIMEDOUT':
162
162
  case 'ENOTFOUND':
163
163
  case 'ESOCKETTIMEDOUT':
164
- logger_1.warning(err.code +
164
+ (0, logger_1.warning)(err.code +
165
165
  ' has occured while communicating remote server. Kindly be patient while the cli retries this request.');
166
166
  try {
167
167
  resolve(yield this._retry(err));
@@ -1,7 +1,11 @@
1
1
  'use strict';
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -103,7 +107,7 @@ class Command {
103
107
  }
104
108
  if (this.helpText !== null) {
105
109
  cmd.on('--help', () => {
106
- logger_1.info(this.helpText);
110
+ (0, logger_1.info)(this.helpText);
107
111
  });
108
112
  }
109
113
  cmd.allowUnknownOption(this.allowUnknownOptions);
@@ -118,24 +122,24 @@ class Command {
118
122
  const argCount = cmd._args.length;
119
123
  if (programArgs.slice(-1)[0].args.length > argCount &&
120
124
  !this.allowUnknownOptions) {
121
- return errorOut_1.default(new error_1.default('Too many arguments', {
125
+ return (0, errorOut_1.default)(new error_1.default('Too many arguments', {
122
126
  exit: 1,
123
127
  errorId: 'CMD-1',
124
- arg: [ansi_colors_1.bold(cmd.name()), ansi_colors_1.bold('catalyst help ' + cmd.name())]
128
+ arg: [(0, ansi_colors_1.bold)(cmd.name()), (0, ansi_colors_1.bold)('catalyst help ' + cmd.name())]
125
129
  }));
126
130
  }
127
131
  try {
128
132
  yield runner.apply(this, programArgs);
129
133
  const duration = Date.now() - start;
130
- errorOut_1.default();
131
- yield track_1.default(this.cmdName, 'success', duration);
134
+ (0, errorOut_1.default)();
135
+ yield (0, track_1.default)(this.cmdName, 'success', duration);
132
136
  }
133
137
  catch (err) {
134
138
  const duration = Date.now() - start;
135
139
  const errorEvent = err.exit === 1 ? 'Error (User)' : 'Error (Unexpected)';
136
- const preppedMessage = strip_ansi_1.default(err.message || '');
137
- errorOut_1.default(err);
138
- yield track_1.default(errorEvent, preppedMessage, duration);
140
+ const preppedMessage = (0, strip_ansi_1.default)(err.message || '');
141
+ (0, errorOut_1.default)(err);
142
+ yield (0, track_1.default)(errorEvent, preppedMessage, duration);
139
143
  }
140
144
  }));
141
145
  return cmd;
@@ -149,16 +153,16 @@ class Command {
149
153
  return;
150
154
  }
151
155
  if (js_1.JS.indexOf(this.optIgnores, opts) > -1) {
152
- logger_1.warning('Cannot use option ' +
153
- ansi_colors_1.bold(opts) +
156
+ (0, logger_1.warning)('Cannot use option ' +
157
+ (0, ansi_colors_1.bold)(opts) +
154
158
  ' along with ' +
155
- ansi_colors_1.bold(this.command) +
159
+ (0, ansi_colors_1.bold)(this.command) +
156
160
  ' command. Hence ignored.');
157
161
  return;
158
162
  }
159
- option_1.setGlobalOption(opts, optsValue);
163
+ (0, option_1.setGlobalOption)(opts, optsValue);
160
164
  });
161
- runtime_store_1.default.set('project.root', project_1.getProjectRoot());
165
+ runtime_store_1.default.set('project.root', (0, project_1.getProjectRoot)());
162
166
  runtime_store_1.default.set('cwd', process.cwd());
163
167
  }
164
168
  runner() {
@@ -173,10 +177,10 @@ class Command {
173
177
  runtime_store_1.default.set('opts', Object.assign({ _name: command.name(), unknownOpts }, opts));
174
178
  this._prepare(command);
175
179
  try {
176
- yield migration_1.default(runtime_store_1.default.get('context.cli.package.version'));
180
+ yield (0, migration_1.default)(runtime_store_1.default.get('context.cli.package.version'));
177
181
  }
178
182
  catch (e) {
179
- logger_1.debug(e);
183
+ (0, logger_1.debug)(e);
180
184
  }
181
185
  yield Promise.all(js_1.JS.map(this.beforeRunners, (before) => __awaiter(this, void 0, void 0, function* () {
182
186
  const beforeModule = (yield Promise.resolve().then(() => __importStar(require('../command_needs/' + before.fn)))).default;
@@ -57,9 +57,9 @@ class Config {
57
57
  }
58
58
  static load(canIgnore) {
59
59
  return __awaiter(this, void 0, void 0, function* () {
60
- const pd = project_1.getProjectRoot();
60
+ const pd = (0, project_1.getProjectRoot)();
61
61
  try {
62
- const configPath = path_1.join(pd, constants_1.FILENAME.config);
62
+ const configPath = (0, path_1.join)(pd, constants_1.FILENAME.config);
63
63
  const data = yield fs_1.ASYNC.readJSONFile(configPath, { checkpath: true });
64
64
  if (data !== undefined) {
65
65
  const config = new Config(configPath, data);
@@ -74,16 +74,16 @@ class Config {
74
74
  fileName: __filename
75
75
  });
76
76
  err.errorId = 'CONFIG-1';
77
- err.arg = [ansi_colors_1.bold(constants_1.FILENAME.config), err.message];
77
+ err.arg = [(0, ansi_colors_1.bold)(constants_1.FILENAME.config), err.message];
78
78
  throw err;
79
79
  }
80
80
  if (canIgnore) {
81
- return new Config(path_1.join(pd, constants_1.FILENAME.config));
81
+ return new Config((0, path_1.join)(pd, constants_1.FILENAME.config));
82
82
  }
83
83
  throw new error_1.default('Not in a Catalyst app directory', {
84
84
  exit: 1,
85
85
  errorId: 'CONFIG-2',
86
- arg: [ansi_colors_1.bold(constants_1.FILENAME.config), ansi_colors_1.bold('catalyst init'), pd]
86
+ arg: [(0, ansi_colors_1.bold)(constants_1.FILENAME.config), (0, ansi_colors_1.bold)('catalyst init'), pd]
87
87
  });
88
88
  });
89
89
  }