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
@@ -0,0 +1,10 @@
1
+ [OPT-IMP-1]
2
+ context='''The Plugin(${arg[0]}) cannot be found in the ${arg[1]} path.'''
3
+ aid='''Please ensure that the ${arg[0]} plugin is installed in the ${arg[2]} directory or
4
+ Try providing the exact path to the ${arg[0]} plugin directory relative to the project root directory.'''
5
+ link=''
6
+
7
+ [OPT-IMP-2]
8
+ context='''The Plugin directory(${arg[0]}) cannot be found in the ${arg[1]} path.'''
9
+ aid='''Please ensure that you have provided the correct path to the Plugin directory.'''
10
+ link=''
package/lib/apig-utils.js CHANGED
@@ -40,7 +40,7 @@ const option_1 = require("./util_modules/option");
40
40
  const project_1 = require("./util_modules/project");
41
41
  exports.apigUtils = {
42
42
  validate: () => __awaiter(void 0, void 0, void 0, function* () {
43
- const ruleFile = project_1.resolveProjectPath(config_1.apigConfig.rules());
43
+ const ruleFile = (0, project_1.resolveProjectPath)(config_1.apigConfig.rules());
44
44
  const ruleArr = (yield fs_1.ASYNC.readJSONFile(ruleFile, {
45
45
  checkpath: true,
46
46
  throws: true
@@ -48,7 +48,7 @@ exports.apigUtils = {
48
48
  throw new error_1.default('Unable to read ' + ruleFile + ' file.', {
49
49
  exit: 1,
50
50
  errorId: 'APIG-UTILS-1',
51
- arg: [ansi_colors_1.bold(ruleFile), ansi_colors_1.italic.red(err)],
51
+ arg: [(0, ansi_colors_1.bold)(ruleFile), ansi_colors_1.italic.red(err)],
52
52
  original: err
53
53
  });
54
54
  }));
@@ -56,7 +56,7 @@ exports.apigUtils = {
56
56
  throw new error_1.default(ruleFile + ' file not found' + constants_1.FILENAME.config, {
57
57
  exit: 1,
58
58
  errorId: 'APIG-UTILS-2',
59
- arg: [ansi_colors_1.bold.red(ruleFile), ansi_colors_1.bold(constants_1.FILENAME.config)]
59
+ arg: [ansi_colors_1.bold.red(ruleFile), (0, ansi_colors_1.bold)(constants_1.FILENAME.config)]
60
60
  });
61
61
  }
62
62
  let localRuleArr = [];
@@ -72,7 +72,7 @@ exports.apigUtils = {
72
72
  }
73
73
  }
74
74
  catch (e) {
75
- logger_1.debug(error_1.default.getErrorInstance(e).message);
75
+ (0, logger_1.debug)(error_1.default.getErrorInstance(e).message);
76
76
  }
77
77
  let redirectIdx = -1;
78
78
  const namesArr = [];
@@ -98,14 +98,14 @@ exports.apigUtils = {
98
98
  throw new error_1.default('source_endpoint missing for rule ' + rule.name, {
99
99
  exit: 1,
100
100
  errorId: 'APIG-UTILS-5',
101
- arg: [ansi_colors_1.bold.red(rule.name), ansi_colors_1.bold('source_endpoint')]
101
+ arg: [ansi_colors_1.bold.red(rule.name), (0, ansi_colors_1.bold)('source_endpoint')]
102
102
  });
103
103
  }
104
104
  if (rule.method === undefined || rule.method === null) {
105
105
  throw new error_1.default('method missing for rule ' + rule.name, {
106
106
  exit: 1,
107
107
  errorId: 'APIG-UTILS-5',
108
- arg: [ansi_colors_1.bold.red(rule.name), ansi_colors_1.bold('method')]
108
+ arg: [ansi_colors_1.bold.red(rule.name), (0, ansi_colors_1.bold)('method')]
109
109
  });
110
110
  }
111
111
  if (sourceUrlByConfig[rule.source_endpoint] !== undefined &&
@@ -115,10 +115,10 @@ exports.apigUtils = {
115
115
  exit: 1,
116
116
  errorId: 'APIG-UTILS-6',
117
117
  arg: [
118
- ansi_colors_1.bold(rule.name),
119
- ansi_colors_1.bold('source_endpoint'),
118
+ (0, ansi_colors_1.bold)(rule.name),
119
+ (0, ansi_colors_1.bold)('source_endpoint'),
120
120
  ansi_colors_1.italic.red(rule.source_endpoint),
121
- ansi_colors_1.bold(duplicateRuleName)
121
+ (0, ansi_colors_1.bold)(duplicateRuleName)
122
122
  ]
123
123
  });
124
124
  }
@@ -130,7 +130,7 @@ exports.apigUtils = {
130
130
  const homepage = runtime_store_1.default.get('context.client.homepage');
131
131
  const clientValidity = runtime_store_1.default.get('context.client.valid', false);
132
132
  if (!clientValidity || (redirectPath === undefined && homepage === undefined)) {
133
- throw new error_1.default('Login Redirect rule cannot be verified since client package is not valid', { exit: 1, errorId: 'APIG-UTILS-7', arg: [ansi_colors_1.bold(rule.name)] });
133
+ throw new error_1.default('Login Redirect rule cannot be verified since client package is not valid', { exit: 1, errorId: 'APIG-UTILS-7', arg: [(0, ansi_colors_1.bold)(rule.name)] });
134
134
  }
135
135
  else if (!redirectPath) {
136
136
  redirectPath = '/app/' + homepage;
@@ -138,11 +138,11 @@ exports.apigUtils = {
138
138
  redirectIdx = index;
139
139
  runtime_store_1.default.set('context.client.login_redirect', rule.source_endpoint);
140
140
  if (rule.target_endpoint && rule.target_endpoint !== redirectPath) {
141
- logger_1.debug('Login redirect - target_endpoint is modified to match the local client');
141
+ (0, logger_1.debug)('Login redirect - target_endpoint is modified to match the local client');
142
142
  }
143
143
  rule.target_endpoint = redirectPath;
144
144
  if (rule.method && rule.method !== 'GET') {
145
- logger_1.debug('Login redirect - method is modified to match the local client');
145
+ (0, logger_1.debug)('Login redirect - method is modified to match the local client');
146
146
  }
147
147
  rule.method = 'GET';
148
148
  rule.system = true;
@@ -156,7 +156,7 @@ exports.apigUtils = {
156
156
  throw new error_1.default('client target cannot have authentication, for rule name : ' + rule.name, {
157
157
  exit: 1,
158
158
  errorId: 'APIG-UTILS-8',
159
- arg: [ansi_colors_1.bold(rule.name), ansi_colors_1.italic.red('"authentication"')]
159
+ arg: [(0, ansi_colors_1.bold)(rule.name), ansi_colors_1.italic.red('"authentication"')]
160
160
  });
161
161
  }
162
162
  }
@@ -207,10 +207,10 @@ exports.apigUtils = {
207
207
  });
208
208
  err.errorId = 'APIG-UTILS-9';
209
209
  err.arg = [
210
- ansi_colors_1.bold('source_endpoint'),
211
- ansi_colors_1.bold(rule.name),
212
- ansi_colors_1.italic(source_endpoint.replace(part, ansi_colors_1.red(part))),
213
- ansi_colors_1.bold('Error: ') + ansi_colors_1.italic.red(util_1.inspect(regexError))
210
+ (0, ansi_colors_1.bold)('source_endpoint'),
211
+ (0, ansi_colors_1.bold)(rule.name),
212
+ (0, ansi_colors_1.italic)(source_endpoint.replace(part, (0, ansi_colors_1.red)(part))),
213
+ (0, ansi_colors_1.bold)('Error: ') + ansi_colors_1.italic.red((0, util_1.inspect)(regexError))
214
214
  ];
215
215
  throw err;
216
216
  }
@@ -222,10 +222,10 @@ exports.apigUtils = {
222
222
  exit: 1,
223
223
  errorId: 'APIG-UTILS-10',
224
224
  arg: [
225
- ansi_colors_1.bold('source_endpoint'),
226
- ansi_colors_1.bold(rule.name),
227
- ansi_colors_1.italic(source_endpoint.replace(part, ansi_colors_1.red(part))),
228
- ansi_colors_1.bold('Error: ') +
225
+ (0, ansi_colors_1.bold)('source_endpoint'),
226
+ (0, ansi_colors_1.bold)(rule.name),
227
+ (0, ansi_colors_1.italic)(source_endpoint.replace(part, (0, ansi_colors_1.red)(part))),
228
+ (0, ansi_colors_1.bold)('Error: ') +
229
229
  ansi_colors_1.italic.red('Regular Expression(s) in the source_endpoint should not contain ^ or $ symbols')
230
230
  ]
231
231
  });
@@ -238,10 +238,10 @@ exports.apigUtils = {
238
238
  exit: 1,
239
239
  errorId: 'APIG-UTILS-10',
240
240
  arg: [
241
- ansi_colors_1.bold('source_endpoint'),
242
- ansi_colors_1.bold(rule.name),
243
- ansi_colors_1.italic(source_endpoint.replace(part, ansi_colors_1.red(part))),
244
- ansi_colors_1.bold('Error: ') +
241
+ (0, ansi_colors_1.bold)('source_endpoint'),
242
+ (0, ansi_colors_1.bold)(rule.name),
243
+ (0, ansi_colors_1.italic)(source_endpoint.replace(part, (0, ansi_colors_1.red)(part))),
244
+ (0, ansi_colors_1.bold)('Error: ') +
245
245
  ansi_colors_1.italic.red('Regular Expression(s) in the source_endpoint with the wildcard character(.*)' +
246
246
  ' is only allowed to be present at the last section of the endpoint')
247
247
  ]
@@ -269,7 +269,7 @@ exports.apigUtils = {
269
269
  otherProps.name, {
270
270
  exit: 1,
271
271
  errorId: 'APIG-UTILS-11',
272
- arg: [ansi_colors_1.bold(otherProps.name), ansi_colors_1.bold('target_endpoint')]
272
+ arg: [(0, ansi_colors_1.bold)(otherProps.name), (0, ansi_colors_1.bold)('target_endpoint')]
273
273
  });
274
274
  case 'basicio':
275
275
  if (otherProps.target_id === undefined) {
@@ -277,7 +277,7 @@ exports.apigUtils = {
277
277
  otherProps.name, {
278
278
  exit: 1,
279
279
  errorId: 'APIG-UTILS-11',
280
- arg: [ansi_colors_1.bold(otherProps.name), ansi_colors_1.bold('target_id')]
280
+ arg: [(0, ansi_colors_1.bold)(otherProps.name), (0, ansi_colors_1.bold)('target_id')]
281
281
  });
282
282
  }
283
283
  const generatedUrl = fn_utils_1.fnUtils.common.generateUrlForTarget({
@@ -301,9 +301,9 @@ exports.apigUtils = {
301
301
  exit: 1,
302
302
  errorId: 'APIG-UTILS-12',
303
303
  arg: [
304
- ansi_colors_1.bold(otherProps.name),
305
- ansi_colors_1.bold('target_endpoint'),
306
- ansi_colors_1.bold('target')
304
+ (0, ansi_colors_1.bold)(otherProps.name),
305
+ (0, ansi_colors_1.bold)('target_endpoint'),
306
+ (0, ansi_colors_1.bold)('target')
307
307
  ]
308
308
  });
309
309
  }
@@ -311,10 +311,10 @@ exports.apigUtils = {
311
311
  exit: 1,
312
312
  errorId: 'APIG-UTILS-13',
313
313
  arg: [
314
- ansi_colors_1.bold('target'),
314
+ (0, ansi_colors_1.bold)('target'),
315
315
  ansi_colors_1.italic.red(otherProps.target),
316
- ansi_colors_1.bold(otherProps.name),
317
- ansi_colors_1.bold(['* client', '* advancedio', '* basicio'].join('\n'))
316
+ (0, ansi_colors_1.bold)(otherProps.name),
317
+ (0, ansi_colors_1.bold)(['* client', '* advancedio', '* basicio'].join('\n'))
318
318
  ]
319
319
  });
320
320
  }
@@ -328,9 +328,9 @@ exports.apigUtils = {
328
328
  exit: 1,
329
329
  errorId: 'APIG-UTILS-14',
330
330
  arg: [
331
- ansi_colors_1.bold('target_endpoint'),
331
+ (0, ansi_colors_1.bold)('target_endpoint'),
332
332
  ansi_colors_1.italic.red(otherProps.target_endpoint),
333
- ansi_colors_1.bold(otherProps.name)
333
+ (0, ansi_colors_1.bold)(otherProps.name)
334
334
  ]
335
335
  });
336
336
  }
@@ -347,18 +347,18 @@ exports.apigUtils = {
347
347
  return localConfig;
348
348
  },
349
349
  executeHook: ({ prefix, command }) => {
350
- if (option_1.getOptionValue('ignoreScripts', false)) {
351
- logger_1.debug(`skipping ${prefix + command} hook`);
350
+ if ((0, option_1.getOptionValue)('ignoreScripts', false)) {
351
+ (0, logger_1.debug)(`skipping ${prefix + command} hook`);
352
352
  return;
353
353
  }
354
354
  const exeCommand = config_1.apigConfig.script(prefix + command, null);
355
355
  if (exeCommand === null) {
356
356
  return;
357
357
  }
358
- execute_script_1.default('apig:' + prefix + command);
358
+ (0, execute_script_1.default)('apig:' + prefix + command);
359
359
  },
360
360
  pack: () => __awaiter(void 0, void 0, void 0, function* () {
361
- const file = project_1.resolveProjectPath(config_1.apigConfig.rules());
361
+ const file = (0, project_1.resolveProjectPath)(config_1.apigConfig.rules());
362
362
  return fs_1.SYNC.getReadStream(file);
363
363
  })
364
364
  };
package/lib/archiver.js CHANGED
@@ -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];
@@ -47,7 +51,7 @@ class Archiver {
47
51
  throw new error_1.default('Unable to parse zip content, content should be either a string or buffer', { exit: 2 });
48
52
  }
49
53
  this.content = content;
50
- this.jszip = jszip_1.loadAsync(content, { createFolders });
54
+ this.jszip = (0, jszip_1.loadAsync)(content, { createFolders });
51
55
  return this;
52
56
  }
53
57
  _writeFolder(folder, to, recursive = false, ignoreInitial = false) {
@@ -60,13 +64,13 @@ class Archiver {
60
64
  while (files.length > 0) {
61
65
  const limit = files.length < Archiver.maxWriteLimit ? files.length : Archiver.maxWriteLimit;
62
66
  yield Promise.all(files.splice(0, limit).map((file) => __awaiter(this, void 0, void 0, function* () {
63
- const filePath = path_1.join(to, path_1.dirname(ignoreInitial ? file.name.substr(file.name.indexOf('/') + 1) : file.name));
67
+ const filePath = (0, path_1.join)(to, (0, path_1.dirname)(ignoreInitial ? file.name.substr(file.name.indexOf('/') + 1) : file.name));
64
68
  yield fs_1.ASYNC.ensureDir(filePath);
65
69
  if (file.name.endsWith('.zip') && recursive) {
66
70
  const zipContent = yield file.async('nodebuffer');
67
71
  return new Archiver()
68
72
  .load(zipContent)
69
- .extract(path_1.join(filePath, path_1.basename(file.name).replace('.zip', '')), '/', {
73
+ .extract((0, path_1.join)(filePath, (0, path_1.basename)(file.name).replace('.zip', '')), '/', {
70
74
  recursive,
71
75
  ignoreInitial
72
76
  })
@@ -80,9 +84,9 @@ class Archiver {
80
84
  _writeFile(file, to) {
81
85
  return __awaiter(this, void 0, void 0, function* () {
82
86
  return new Promise((resolve) => {
83
- const fileName = path_1.basename(file.name);
87
+ const fileName = (0, path_1.basename)(file.name);
84
88
  file.nodeStream()
85
- .pipe(fs_1.SYNC.getWriteStream(path_1.join(to, fileName)))
89
+ .pipe(fs_1.SYNC.getWriteStream((0, path_1.join)(to, fileName)))
86
90
  .on('close', resolve);
87
91
  });
88
92
  });
@@ -220,10 +224,10 @@ class Archiver {
220
224
  }
221
225
  });
222
226
  if (pth.endsWith('.zip')) {
223
- pth = path_1.join(path_1.dirname(pth), this.name + '.zip');
227
+ pth = (0, path_1.join)((0, path_1.dirname)(pth), this.name + '.zip');
224
228
  }
225
- if (path_1.parse(pth).ext === '') {
226
- pth = path_1.join(pth, this.name + '.zip');
229
+ if ((0, path_1.parse)(pth).ext === '') {
230
+ pth = (0, path_1.join)(pth, this.name + '.zip');
227
231
  }
228
232
  yield fs_1.ASYNC.writeFile(pth, content);
229
233
  })
@@ -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];
@@ -48,7 +52,7 @@ const login_1 = __importDefault(require("./login"));
48
52
  const revoke_1 = __importDefault(require("./revoke"));
49
53
  function create() {
50
54
  return __awaiter(this, void 0, void 0, function* () {
51
- if (option_1.getOptionValue('current', false)) {
55
+ if ((0, option_1.getOptionValue)('current', false)) {
52
56
  return runtime_store_1.default.get('credential.cliToken');
53
57
  }
54
58
  const result = yield new login_1.default(false, false).init();
@@ -58,12 +62,12 @@ function create() {
58
62
  }
59
63
  exports.create = create;
60
64
  function list() {
61
- const tokens = config_store_1.default.get(`${dc_1.getActiveDC()}.tokens`, null);
65
+ const tokens = config_store_1.default.get(`${(0, dc_1.getActiveDC)()}.tokens`, null);
62
66
  if (tokens === null || Object.keys(tokens).length === 0) {
63
67
  throw new error_1.default('No tokens found', {
64
68
  exit: 0,
65
69
  errorId: 'IDX-1',
66
- arg: [ansi_colors_1.bold('catalyst token:generate')]
70
+ arg: [(0, ansi_colors_1.bold)('catalyst token:generate')]
67
71
  });
68
72
  }
69
73
  const tableData = [];
@@ -74,7 +78,7 @@ function list() {
74
78
  tableData.push([
75
79
  tokenId,
76
80
  cred.cliToken,
77
- cred.createdTime ? moment_1.default(cred.createdTime).format('YYYY-MM-DD HH:mm:ss') : 'N/A'
81
+ cred.createdTime ? (0, moment_1.default)(cred.createdTime).format('YYYY-MM-DD HH:mm:ss') : 'N/A'
78
82
  ]);
79
83
  }
80
84
  }
@@ -83,7 +87,7 @@ function list() {
83
87
  exports.list = list;
84
88
  function revoke(id) {
85
89
  return __awaiter(this, void 0, void 0, function* () {
86
- const tokens = config_store_1.default.get(`${dc_1.getActiveDC()}.tokens`, {});
90
+ const tokens = config_store_1.default.get(`${(0, dc_1.getActiveDC)()}.tokens`, {});
87
91
  const tokenKey = Object.keys(tokens).find((key) => key === id);
88
92
  if (tokenKey === undefined) {
89
93
  const allTokenKeys = Object.keys(tokens);
@@ -93,7 +97,7 @@ function revoke(id) {
93
97
  arg: [
94
98
  id,
95
99
  allTokenKeys.length > 0 ? '* ' + allTokenKeys.join('\n* ') : 'None',
96
- ansi_colors_1.bold('catalyst token:list')
100
+ (0, ansi_colors_1.bold)('catalyst token:list')
97
101
  ]
98
102
  });
99
103
  }
@@ -104,11 +108,11 @@ function revoke(id) {
104
108
  exports.revoke = revoke;
105
109
  function login() {
106
110
  return __awaiter(this, void 0, void 0, function* () {
107
- let activeDC = dc_1.getActiveDC();
111
+ let activeDC = (0, dc_1.getActiveDC)();
108
112
  const user = config_store_1.default.get(`${activeDC}.user`);
109
113
  const token = config_store_1.default.get(`${activeDC}.credential`);
110
- if (user && token && !option_1.getOptionValue('force', false)) {
111
- logger_1.message('No need to login. Already logged as: ' + ansi_colors_1.default.cyan.bold(user.Email));
114
+ if (user && token && !(0, option_1.getOptionValue)('force', false)) {
115
+ (0, logger_1.message)('No need to login. Already logged as: ' + ansi_colors_1.default.cyan.bold(user.Email));
112
116
  return;
113
117
  }
114
118
  const ans = yield prompt_1.default.ask(prompt_1.default.question('collectUsage', 'Allow Catalyst to collect CLI error reporting information?', {
@@ -122,33 +126,33 @@ function login() {
122
126
  value: dcObj.value
123
127
  });
124
128
  }),
125
- when: () => !option_1.getGlobalOptionValue('dc') &&
129
+ when: () => !(0, option_1.getGlobalOptionValue)('dc') &&
126
130
  !!Object.values(constants_1.DC_TYPE).find((dc) => dc.value === activeDC)
127
131
  }));
128
132
  if (ans.dc !== undefined && ans.dc !== activeDC) {
129
- dc_1.updateActiveDC(ans.dc);
133
+ (0, dc_1.updateActiveDC)(ans.dc);
130
134
  activeDC = ans.dc;
131
135
  }
132
- const localhost = option_1.getOptionValue('localhost', true);
136
+ const localhost = (0, option_1.getOptionValue)('localhost', true);
133
137
  const result = yield new login_1.default(localhost).init();
134
138
  activeDC = result.dc;
135
139
  config_store_1.default.set('usage', ans.collectUsage);
136
140
  config_store_1.default.set(`${activeDC}.user`, result.user);
137
141
  config_store_1.default.set(`${activeDC}.scopes`, result.scopes);
138
142
  credential_1.default.init(result.token).persistMinimal('credential');
139
- logger_1.success('Success! Logged in as : ' + ansi_colors_1.default.cyan.bold(result.user.Email));
143
+ (0, logger_1.success)('Success! Logged in as : ' + ansi_colors_1.default.cyan.bold(result.user.Email));
140
144
  });
141
145
  }
142
146
  exports.login = login;
143
147
  function logout() {
144
148
  return __awaiter(this, void 0, void 0, function* () {
145
- const activeDC = dc_1.getActiveDC();
149
+ const activeDC = (0, dc_1.getActiveDC)();
146
150
  const tokenObj = config_store_1.default.get(`${activeDC}.credential`, null);
147
151
  if (tokenObj === null) {
148
152
  throw new error_1.default('Not logged in', {
149
153
  exit: 0,
150
154
  errorId: 'IDX-3',
151
- arg: [ansi_colors_1.bold('catalyst login')]
155
+ arg: [(0, ansi_colors_1.bold)('catalyst login')]
152
156
  });
153
157
  }
154
158
  const user = config_store_1.default.get(`${activeDC}.user`, null);
@@ -158,12 +162,12 @@ function logout() {
158
162
  ansi_colors_1.default.cyan.bold(user.Email) +
159
163
  ' , are you sure?', { type: 'confirm', defaultAns: true }));
160
164
  if (!ans.consent) {
161
- logger_1.message('Aborting logout process...');
165
+ (0, logger_1.message)('Aborting logout process...');
162
166
  return;
163
167
  }
164
168
  const credential = credential_1.default.init(tokenObj, false);
165
169
  yield new revoke_1.default(credential, 'credential').init();
166
- logger_1.success('SuccessFully Logged out, we hope to see you soon. (^-^)ノ');
170
+ (0, logger_1.success)('SuccessFully Logged out, we hope to see you soon. (^-^)ノ');
167
171
  });
168
172
  }
169
173
  exports.logout = logout;
@@ -13,7 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const ansi_colors_1 = require("ansi-colors");
16
- const http_1 = __importDefault(require("http"));
16
+ const http_1 = require("http");
17
+ const server_js_1 = require("../util_modules/server.js");
17
18
  const open_1 = __importDefault(require("open"));
18
19
  const path_1 = require("path");
19
20
  const portfinder_1 = require("portfinder");
@@ -32,7 +33,7 @@ const option_1 = require("../util_modules/option");
32
33
  class Login {
33
34
  constructor(localhost = true, user = true) {
34
35
  this.localhost = localhost;
35
- this.portPromise = portfinder_1.getPortPromise({
36
+ this.portPromise = (0, portfinder_1.getPortPromise)({
36
37
  startPort: 9005,
37
38
  port: 9005,
38
39
  stopPort: 9009
@@ -91,7 +92,7 @@ class Login {
91
92
  });
92
93
  if (!js_1.JS.hasIn(authCodeResponse, 'body.access_token') ||
93
94
  !js_1.JS.hasIn(authCodeResponse, 'body.refresh_token')) {
94
- logger_1.debug('Token Fetch Error: \n' +
95
+ (0, logger_1.debug)('Token Fetch Error: \n' +
95
96
  ' Status: ' +
96
97
  authCodeResponse.status +
97
98
  ', Body: ' +
@@ -131,14 +132,14 @@ class Login {
131
132
  });
132
133
  if (!js_1.JS.hasIn(deviceCodeResponse, 'body.access_token') ||
133
134
  !js_1.JS.hasIn(deviceCodeResponse, 'body.refresh_token')) {
134
- logger_1.debug('Token Fetch Error: \n' +
135
+ (0, logger_1.debug)('Token Fetch Error: \n' +
135
136
  ' Status: ' +
136
137
  deviceCodeResponse.status +
137
138
  ', Body: ' +
138
139
  JSON.stringify(deviceCodeResponse.body));
139
- logger_1.debug('> polling <');
140
+ (0, logger_1.debug)('> polling <');
140
141
  if (++retryCount > 30) {
141
- if (option_1.getCurrentCommand() === 'login') {
142
+ if ((0, option_1.getCurrentCommand)() === 'login') {
142
143
  throw new error_1.default('Unable to get refresh_token from code', {
143
144
  exit: 0,
144
145
  errorId: 'LOGIN-1'
@@ -148,7 +149,7 @@ class Login {
148
149
  throw new error_1.default('Unable to get refresh_token from code', {
149
150
  exit: 1,
150
151
  errorId: 'LOGIN-2',
151
- arg: [ansi_colors_1.bold('catalyst token:generate')]
152
+ arg: [(0, ansi_colors_1.bold)('catalyst token:generate')]
152
153
  });
153
154
  }
154
155
  }
@@ -163,7 +164,7 @@ class Login {
163
164
  }
164
165
  _respondWithFile(req, res, statusCode, filename) {
165
166
  return __awaiter(this, void 0, void 0, function* () {
166
- const content = yield fs_1.ASYNC.readFile(path_1.join(__dirname, filename));
167
+ const content = yield fs_1.ASYNC.readFile((0, path_1.join)(__dirname, filename));
167
168
  res.setHeader('Content-Type', 'text/html');
168
169
  if (content !== undefined) {
169
170
  res.setHeader('Content-Length', content.length);
@@ -191,7 +192,7 @@ class Login {
191
192
  });
192
193
  });
193
194
  if (!js_1.JS.hasIn(userInfoResponse, 'body.Email') && !js_1.JS.hasIn(userInfoResponse, 'body.ZUID')) {
194
- logger_1.debug('User Details Fetch Error:\n' +
195
+ (0, logger_1.debug)('User Details Fetch Error:\n' +
195
196
  ' Status: ' +
196
197
  userInfoResponse.response.statusCode +
197
198
  ', Body: ' +
@@ -204,7 +205,7 @@ class Login {
204
205
  _loginWithoutLocalhost(err) {
205
206
  return __awaiter(this, void 0, void 0, function* () {
206
207
  if (err) {
207
- logger_1.debug('Error while login with server : ' + err.message);
208
+ (0, logger_1.debug)('Error while login with server : ' + err.message);
208
209
  }
209
210
  this.salt = 'm';
210
211
  const throbber = throbber_1.default.getInstance();
@@ -229,7 +230,7 @@ class Login {
229
230
  });
230
231
  if (!js_1.JS.hasIn(deviceCodeResponse, 'body.user_code') ||
231
232
  !js_1.JS.hasIn(deviceCodeResponse, 'body.device_code')) {
232
- logger_1.debug('Token Fetch Error: \n' +
233
+ (0, logger_1.debug)('Token Fetch Error: \n' +
233
234
  ' Status: ' +
234
235
  deviceCodeResponse.status +
235
236
  ', Body: ' +
@@ -239,12 +240,12 @@ class Login {
239
240
  errorId: 'LOGIN-3'
240
241
  });
241
242
  }
242
- logger_1.info();
243
- logger_1.info('Visit this URL on any device: \n');
244
- logger_1.info(ansi_colors_1.bold.underline(js_1.JS.get(deviceCodeResponse, 'body.verification_url')));
245
- logger_1.info();
246
- logger_1.info('Enter the device verification code: ' +
247
- ansi_colors_1.bold(js_1.JS.get(deviceCodeResponse, 'body.user_code')) +
243
+ (0, logger_1.info)();
244
+ (0, logger_1.info)('Visit this URL on any device: \n');
245
+ (0, logger_1.info)(ansi_colors_1.bold.underline(js_1.JS.get(deviceCodeResponse, 'body.verification_url')));
246
+ (0, logger_1.info)();
247
+ (0, logger_1.info)('Enter the device verification code: ' +
248
+ (0, ansi_colors_1.bold)(js_1.JS.get(deviceCodeResponse, 'body.user_code')) +
248
249
  ' and click verify to continue.');
249
250
  const deviceCode = js_1.JS.get(deviceCodeResponse, 'body.device_code');
250
251
  yield js_1.JS.sleep(10000);
@@ -260,7 +261,7 @@ class Login {
260
261
  user: userDetails,
261
262
  token: result,
262
263
  scopes: js_1.JS.values(constants_1.SCOPE),
263
- dc: dc_1.getActiveDC()
264
+ dc: (0, dc_1.getActiveDC)()
264
265
  };
265
266
  }
266
267
  catch (e) {
@@ -273,17 +274,15 @@ class Login {
273
274
  return __awaiter(this, void 0, void 0, function* () {
274
275
  return new Promise((resolve, reject) => {
275
276
  var _a;
276
- const dcRef = (_a = dc_1.getActiveDCType()) === null || _a === void 0 ? void 0 : _a.ref;
277
+ const dcRef = (_a = (0, dc_1.getActiveDCType)()) === null || _a === void 0 ? void 0 : _a.ref;
277
278
  const callbackUrl = this._getCallbackUrl(port);
278
279
  const authUrl = this._getLoginUrl(callbackUrl);
279
280
  let reqCount = 0;
280
- const server = http_1.default.createServer((req, res) => __awaiter(this, void 0, void 0, function* () {
281
+ const server = (0, http_1.createServer)((req, res) => __awaiter(this, void 0, void 0, function* () {
281
282
  try {
282
283
  let processReq = true;
283
- if (reqCount + 1 > 1 ||
284
- req.url === '/favicon.ico' ||
285
- req.url === undefined) {
286
- logger_1.debug('unknown request received : ' + req.url);
284
+ if (reqCount + 1 > 1 || req.url === '/favicon.ico' || req.url === undefined) {
285
+ (0, logger_1.debug)('unknown request received : ' + req.url);
287
286
  processReq = false;
288
287
  res.writeHead(404);
289
288
  res.end();
@@ -299,57 +298,56 @@ class Login {
299
298
  if (dcRef !== undefined &&
300
299
  typeof location === 'string' &&
301
300
  location !== dcRef) {
302
- logger_1.warning('Your credentials does not match the DC opted!!!');
301
+ (0, logger_1.warning)('Your credentials does not match the DC opted!!!');
303
302
  const ans = yield prompt_1.default.ask(prompt_1.default.question('DC', `Do you wish to continue with login by making ${location.toUpperCase()} DC as active ?`, {
304
303
  type: 'confirm',
305
304
  defaultAns: true
306
305
  }));
307
306
  if (!ans.DC) {
308
- server.close();
307
+ yield destroyer.destroy(true).catch((err) => (0, logger_1.debug)(err));
309
308
  reject(new error_1.default('Aborted by user.\n', {
310
309
  exit: 1
311
310
  }));
312
311
  return;
313
312
  }
314
- dc_1.updateActiveDC(constants_1.DC_TYPE[location].value);
313
+ (0, dc_1.updateActiveDC)(constants_1.DC_TYPE[location].value);
315
314
  }
316
315
  const result = yield this._getTokenFromAuthorizationCode(code, callbackUrl);
317
316
  js_1.JS.set(result, 'token', this.salt + '_' + result.refresh_token);
318
317
  credential_1.default.oneTimeToken = result.access_token;
319
318
  const userDetails = yield this._getUserDetails();
320
- server.close();
319
+ yield destroyer.destroy(true).catch((err) => (0, logger_1.debug)(err));
320
+ yield new Promise((res) => setTimeout(res, 2000));
321
321
  resolve({
322
322
  user: userDetails,
323
323
  token: result,
324
324
  scopes: js_1.JS.values(constants_1.SCOPE),
325
- dc: dc_1.getActiveDC()
325
+ dc: (0, dc_1.getActiveDC)()
326
326
  });
327
327
  }
328
328
  else if (processReq) {
329
329
  yield this._respondWithFile(req, res, 400, '../../templates/loginFailure.html');
330
- server.close();
330
+ yield destroyer.destroy(true).catch((err) => (0, logger_1.debug)(err));
331
331
  reject(new error_1.default("Credentials doesn't seem to be valid.\n", {
332
332
  exit: 1
333
333
  }));
334
334
  }
335
335
  }
336
336
  catch (e) {
337
- server.close();
337
+ yield destroyer.destroy(true).catch((err) => (0, logger_1.debug)(err));
338
338
  reject(new error_1.default('Server crashed with error.\n', {
339
339
  exit: 2,
340
340
  original: error_1.default.getErrorInstance(e)
341
341
  }));
342
342
  }
343
343
  }));
344
- server.on('connection', (socket) => {
345
- socket.unref();
346
- });
344
+ const destroyer = new server_js_1.ConnectionDestroyer(server);
347
345
  server.listen(port, () => {
348
- logger_1.info();
349
- logger_1.info('Visit this URL on this device to log in:');
350
- logger_1.info(ansi_colors_1.bold.underline(authUrl));
351
- logger_1.info();
352
- open_1.default(authUrl).catch();
346
+ (0, logger_1.info)();
347
+ (0, logger_1.info)('Visit this URL on this device to log in:');
348
+ (0, logger_1.info)(ansi_colors_1.bold.underline(authUrl));
349
+ (0, logger_1.info)();
350
+ (0, open_1.default)(authUrl).catch();
353
351
  });
354
352
  server.on('error', () => {
355
353
  this._loginWithoutLocalhost().then(resolve, reject);