zcatalyst-cli 1.15.0-beta.6 → 1.15.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.
@@ -22,3 +22,10 @@ link = 'https://www.zoho.com/catalyst/help/cli-init.html#Options'
22
22
  context = '''The project which is currently active doesn't seems to be present in Catalyst remote console.'''
23
23
  aid = '''Use the ${arg[0]} command in order to change the existing active project.'''
24
24
  link = 'https://www.zoho.com/catalyst/help/cli-projects.html#Use'
25
+
26
+ [RC-6]
27
+ context = '''The Catalyst portal initialized in the current project directory is not accessible with the currently logged in user.\n
28
+ ${arg[0]} ${arg[1]}
29
+ ${arg[2]} ${arg[3]}'''
30
+ aid = '''Please ensure you've logged-in with the correct user credentials.'''
31
+ link = ''
@@ -25,13 +25,13 @@ link = ''
25
25
 
26
26
  [OPT-FILTER-6]
27
27
  context = '''The input for the ${arg[0]} option is in an invalid format: ${arg[1]}'''
28
- aid = '''Please use only these valid formats to specify the targets: \n${arg[2]}\n${arg[3]}'''
28
+ aid = '''Please use only these valid formats to specify the targets: \n${arg[2]}\n${arg[3]}\n${arg[4]}'''
29
29
  link = ''
30
30
 
31
31
  [OPT-FILTER-7]
32
32
  context = '''The input of the ${arg[0]} option for target ${arg[1]} is in an invalid format: ${arg[2]}'''
33
33
  aid = '''Please use only the ${arg[3]} format, to specify your ${arg[1]} targets with the ${arg[0]} option.
34
- example: --debug advancedio:aio_fn:8001'''
34
+ example: --debug ${arg[4]}:fn_name:8001'''
35
35
  link = ''
36
36
 
37
37
  [OPT-FILTER-8]
@@ -2,3 +2,8 @@
2
2
  context = '''Error when serving the ${arg[0]} with the ${arg[1]} plugin.'''
3
3
  aid = '''Please rectify the below error to serve the ${arg[0]}: \n${arg[2]}'''
4
4
  link = ''
5
+
6
+ [SERVE-IDX-2]
7
+ context = '''No components were successfully started for serve'''
8
+ aid = '''Please rectify the errors if any'''
9
+ link = ''
@@ -0,0 +1,4 @@
1
+ [SERVE-APPSAIL-1]
2
+ context = '''The provided build path (${arg[0]}) for the AppSail ${arg[1]} does not exists.'''
3
+ aid = '''Please provide a valid build path'''
4
+ link = ''
@@ -24,6 +24,8 @@ const js_1 = require("../util_modules/js");
24
24
  const logger_1 = require("../util_modules/logger");
25
25
  const option_1 = require("../util_modules/option");
26
26
  const project_2 = require("../util_modules/project");
27
+ const config_store_1 = __importDefault(require("../config-store"));
28
+ const dc_1 = require("../dc");
27
29
  exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck = true } = {}) => __awaiter(void 0, void 0, void 0, function* () {
28
30
  const orgOpt = (0, option_1.getGlobalOptionValue)('org', null);
29
31
  const projectOpt = (0, option_1.getGlobalOptionValue)('project', null);
@@ -191,21 +193,42 @@ exports.default = ({ optional = false, resolveOnNotFound = false, skipOrgCheck =
191
193
  const projectDetails = yield projectApi
192
194
  .getProject(finalProjectObj.id + '')
193
195
  .catch((err) => __awaiter(void 0, void 0, void 0, function* () {
194
- if (js_1.JS.hasIn(err, 'context.response.statusCode') &&
195
- err.context.response.statusCode === 404) {
196
- (0, logger_1.message)('cleaning up ' +
197
- constants_1.FILENAME.rc +
198
- ' since the current active project for this folder is not found in remote');
199
- yield (0, project_2.removeProject)(finalProjectObj.id + '');
200
- if (resolveOnNotFound) {
201
- finalProjectObj = undefined;
202
- return;
196
+ if (js_1.JS.hasIn(err, 'context.response.statusCode')) {
197
+ switch (err.context.response.statusCode) {
198
+ case 404: {
199
+ (0, logger_1.message)('cleaning up ' +
200
+ constants_1.FILENAME.rc +
201
+ ' since the current active project for this folder is not found in remote');
202
+ yield (0, project_2.removeProject)(finalProjectObj.id + '');
203
+ if (resolveOnNotFound) {
204
+ finalProjectObj = undefined;
205
+ return;
206
+ }
207
+ throw new error_1.default('active project not found in remote', {
208
+ exit: 1,
209
+ errorId: 'RC-5',
210
+ arg: [(0, ansi_colors_1.bold)('catalyst project:use')]
211
+ });
212
+ }
213
+ case 403: {
214
+ const activeDC = (0, dc_1.getActiveDC)();
215
+ const user = config_store_1.default.get(`${activeDC}.user`);
216
+ throw new error_1.default('Invalid org identifier: ' + (finalEnvObj === null || finalEnvObj === void 0 ? void 0 : finalEnvObj.id), {
217
+ original: err,
218
+ errorId: 'RC-6',
219
+ arg: [
220
+ (0, ansi_colors_1.bold)('Current logged in user:'),
221
+ ansi_colors_1.cyan.italic.underline(user
222
+ ? user.Email
223
+ ? user.Email
224
+ : `${user.First_Name} ${user.Last_Name}`
225
+ : 'unknown user'),
226
+ (0, ansi_colors_1.bold)('Current Org-id:'),
227
+ (0, ansi_colors_1.red)((finalEnvObj === null || finalEnvObj === void 0 ? void 0 : finalEnvObj.id) || '')
228
+ ]
229
+ });
230
+ }
203
231
  }
204
- throw new error_1.default('active project not found in remote', {
205
- exit: 1,
206
- errorId: 'RC-5',
207
- arg: [(0, ansi_colors_1.bold)('catalyst project:use')]
208
- });
209
232
  }
210
233
  throw err;
211
234
  }));
@@ -56,11 +56,11 @@ exports.default = new command_1.default('functions:shell')
56
56
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
57
57
  const httpOpt = (0, option_1.getOptionValue)('http', false);
58
58
  if (httpOpt && typeof httpOpt !== 'boolean') {
59
- runtime_store_1.default.set('context.port.http.basicio', httpOpt);
59
+ runtime_store_1.default.set('context.port.http.bio', httpOpt);
60
60
  }
61
61
  const debugOpt = (0, option_1.getOptionValue)('debug', false);
62
62
  if (debugOpt && typeof debugOpt !== 'boolean') {
63
- runtime_store_1.default.set('context.port.debug.basicio', debugOpt);
63
+ runtime_store_1.default.set('context.port.debug.bio', debugOpt);
64
64
  }
65
65
  return (yield Promise.resolve().then(() => __importStar(require('../../shell')))).default();
66
66
  }));
@@ -22,9 +22,6 @@ class SDK {
22
22
  }
23
23
  getSdkUrl(fnType, service) {
24
24
  switch (fnType) {
25
- case constants_1.FN_TYPE.browserLogic: {
26
- return `/downloads/sdk/java/catalyst_java_sdk_beta.zip`;
27
- }
28
25
  case constants_1.FN_TYPE.integration: {
29
26
  if (!service) {
30
27
  throw new error_1.default('Invalid integration service');
@@ -32,7 +29,7 @@ class SDK {
32
29
  if (service === constants_1.INTEG.services.cliq) {
33
30
  return `/downloads/sdk/java/${constants_1.INTEG.service_map[service]}/${constants_1.INTEG.java_dependencies[service]}_latest.zip`;
34
31
  }
35
- return '/downloads/sdk/java/catalyst_java_sdk_beta.zip';
32
+ return '/downloads/sdk/java/catalyst_java_sdk_latest.zip';
36
33
  }
37
34
  default: {
38
35
  return '/downloads/sdk/java/catalyst_java_sdk_latest.zip';
@@ -38,6 +38,8 @@ exports.default = (proxyInstance, customProxyUrl) => (req, res) => {
38
38
  changeOrigin: true,
39
39
  ws: true,
40
40
  headers
41
+ }, (err) => {
42
+ (0, logger_1.debug)('Unknown proxy error: ', err);
41
43
  });
42
44
  }
43
45
  };
@@ -380,6 +380,7 @@ exports.findAndReplaceConfigProps = findAndReplaceConfigProps;
380
380
  function resolveAllFnServePort(targets) {
381
381
  return __awaiter(this, void 0, void 0, function* () {
382
382
  let isBioHttp = false;
383
+ let isBioDebug = false;
383
384
  const debugOpts = runtime_store_1.default.get('context.port.debug', false);
384
385
  yield Promise.all(targets.map((target) => __awaiter(this, void 0, void 0, function* () {
385
386
  var _a;
@@ -391,23 +392,35 @@ function resolveAllFnServePort(targets) {
391
392
  ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python.value))) {
392
393
  curTargetType = constants_1.FN_TYPE.advanced;
393
394
  }
394
- if (debugOpts && target.name in (debugOpts[curTargetType] || {})) {
395
- const debugPort = yield port_resolver_1.default.getPort(constants_1.REMOTE_REF.functions.type[curTargetType], 'debug', {
396
- name: target.name,
397
- duplicateCheck: false,
398
- searchSpan: 0
399
- });
400
- runtime_store_1.default.set('context.port.debug.functions.' + target.name, debugPort);
395
+ if (debugOpts) {
396
+ if (!isBioDebug && curTargetType === constants_1.FN_TYPE.basic) {
397
+ isBioDebug = true;
398
+ const debugPort = yield port_resolver_1.default.getPort(curTargetType, 'debug', {
399
+ name: target.name,
400
+ duplicateCheck: true,
401
+ searchSpan: 0
402
+ });
403
+ runtime_store_1.default.set('context.port.debug.' + curTargetType, debugPort);
404
+ }
405
+ else if (typeof debugOpts[curTargetType] === 'object' &&
406
+ target.name in debugOpts[curTargetType]) {
407
+ const debugPort = yield port_resolver_1.default.getPort(curTargetType, 'debug', {
408
+ name: target.name,
409
+ duplicateCheck: false,
410
+ searchSpan: 0
411
+ });
412
+ runtime_store_1.default.set('context.port.debug.functions.' + target.name, debugPort);
413
+ }
401
414
  }
402
415
  if (curTargetType === constants_1.FN_TYPE.basic && isBioHttp) {
403
416
  return;
404
417
  }
405
- const httpPort = yield port_resolver_1.default.getPort(constants_1.REMOTE_REF.functions.type[curTargetType], 'http', {
418
+ const httpPort = yield port_resolver_1.default.getPort(curTargetType, 'http', {
406
419
  name: target.name,
407
420
  duplicateCheck: curTargetType === constants_1.FN_TYPE.advanced || curTargetType === constants_1.FN_TYPE.browserLogic
408
421
  });
409
422
  if (curTargetType === constants_1.FN_TYPE.basic) {
410
- runtime_store_1.default.set('context.port.http.' + constants_1.REMOTE_REF.functions.type.bio, httpPort);
423
+ runtime_store_1.default.set('context.port.http.' + constants_1.FN_TYPE.basic, httpPort);
411
424
  isBioHttp = true;
412
425
  }
413
426
  else {
@@ -415,7 +428,10 @@ function resolveAllFnServePort(targets) {
415
428
  }
416
429
  })));
417
430
  if (debugOpts && 'basicio' in debugOpts) {
418
- const bioDebugPort = yield port_resolver_1.default.getPort(constants_1.REMOTE_REF.functions.type.bio, 'debug', { duplicateCheck: false, searchSpan: 0 });
431
+ const bioDebugPort = yield port_resolver_1.default.getPort('bio', 'debug', {
432
+ duplicateCheck: false,
433
+ searchSpan: 0
434
+ });
419
435
  runtime_store_1.default.set('context.port.debug.basicio', bioDebugPort);
420
436
  }
421
437
  });
@@ -430,11 +446,11 @@ function resolveAllFnPorts(targets) {
430
446
  return resolveAllFnServePort(targets);
431
447
  }
432
448
  case 'functions:shell': {
433
- if (runtime_store_1.default.get('context.port.http.basicio', false)) {
434
- const bioHttpPort = yield port_resolver_1.default.getPort('basicio', 'http', {
449
+ if (runtime_store_1.default.get('context.port.http.' + constants_1.FN_TYPE.basic, false)) {
450
+ const bioHttpPort = yield port_resolver_1.default.getPort('bio', 'http', {
435
451
  duplicateCheck: false
436
452
  });
437
- runtime_store_1.default.set('context.port.http.' + constants_1.REMOTE_REF.functions.type.bio, bioHttpPort);
453
+ runtime_store_1.default.set('context.port.http.' + constants_1.FN_TYPE.basic, bioHttpPort);
438
454
  }
439
455
  break;
440
456
  }
@@ -433,8 +433,12 @@ function cleanUp(files) {
433
433
  }
434
434
  function getTemplatePath(fnType, add) {
435
435
  switch (fnType) {
436
- case constants_1.FN_TYPE.browserLogic:
437
- return constants_1.TEMPLATE.functions.java.browserlogic.selenium;
436
+ case constants_1.FN_TYPE.browserLogic: {
437
+ if (Object.keys(constants_1.TEMPLATE.functions.java.browserlogic).includes('Selenium')) {
438
+ return constants_1.TEMPLATE.functions.java.browserlogic.Selenium;
439
+ }
440
+ throw new error_1.default('Invalid browserlogic type', { exit: 2 });
441
+ }
438
442
  case constants_1.FN_TYPE.integration: {
439
443
  if (!add) {
440
444
  throw new error_1.default('Invalid additional parameter', { exit: 2 });
@@ -44,9 +44,10 @@ const onlyExceptTargets = [
44
44
  ];
45
45
  const portTargets = [
46
46
  { filterName: ['appsail'], target: 'appsail' },
47
- { filterName: ['advancedio', 'aio'], target: 'advancedio' },
48
- { filterName: ['basicio', 'bio'], target: 'basicio' },
49
- { filterName: ['client'], target: 'client' }
47
+ { filterName: ['advancedio', 'aio'], target: 'aio' },
48
+ { filterName: ['basicio', 'bio'], target: 'bio' },
49
+ { filterName: ['client'], target: 'client' },
50
+ { filterName: ['browser_logic', 'browserlogic'], target: 'browserlogic' }
50
51
  ];
51
52
  function enrichOptsData(opt, optValue, validTargets, multiTargetSupport = true) {
52
53
  if (optValue === undefined || typeof optValue === 'boolean') {
@@ -160,7 +161,9 @@ function validatePorts() {
160
161
  (0, ansi_colors_1.bold)('--debug'),
161
162
  ansi_colors_1.italic.red('--debug <target>'),
162
163
  (0, ansi_colors_1.bold)('* basicio: ') + ansi_colors_1.italic.green('--debug <basicio|bio>:<port>'),
163
- (0, ansi_colors_1.bold)('* advancedio: ') + ansi_colors_1.italic.green('--debug <advancedio|aio>:<name>:<port>')
164
+ (0, ansi_colors_1.bold)('* advancedio: ') + ansi_colors_1.italic.green('--debug <advancedio|aio>:<name>:<port>'),
165
+ (0, ansi_colors_1.bold)('* browserlogic: ') +
166
+ ansi_colors_1.italic.green('--debug <browserlogic|browser_logic>:<name>:<port>')
164
167
  ]
165
168
  });
166
169
  }
@@ -173,20 +176,34 @@ function filterPorts() {
173
176
  const validOptResultants = validatePorts();
174
177
  runtime_store_1.default.set(`context.port.http.master`, validOptResultants.port);
175
178
  validOptResultants.debug.forEach((res) => {
176
- if (res.target.target === constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.advanced] && !res.specific) {
177
- throw new error_1.default('Invalid input format for advancedio target', {
179
+ if ((res.target.target === constants_1.FN_TYPE.advanced ||
180
+ res.target.target === constants_1.FN_TYPE.browserLogic) &&
181
+ !res.specific) {
182
+ const targMap = {
183
+ aio: {
184
+ filter: 'advancedio|aio',
185
+ targName: constants_1.REMOTE_REF.functions.type[res.target.target]
186
+ },
187
+ browserlogic: {
188
+ filter: 'browser_logic|browserlogic',
189
+ targName: constants_1.REMOTE_REF.functions.type[res.target.target]
190
+ }
191
+ };
192
+ const targ = targMap[res.target.target];
193
+ throw new error_1.default(`Invalid input format for ${targ} target`, {
178
194
  exit: 1,
179
195
  errorId: 'OPT-FILTER-7',
180
196
  arg: [
181
197
  (0, ansi_colors_1.bold)('--debug'),
182
- (0, ansi_colors_1.bold)('advancedio'),
183
- ansi_colors_1.italic.red('--debug <advancedio|aio>:<name|port>'),
184
- ansi_colors_1.italic.green('--debug <advancedio|aio>:<name>:<port>')
198
+ (0, ansi_colors_1.bold)(targ.targName),
199
+ ansi_colors_1.italic.red(`--debug <${targ.filter}>:<name|port>`),
200
+ ansi_colors_1.italic.green(`--debug <${targ.filter}>:<name>:<port>`),
201
+ targ.targName
185
202
  ]
186
203
  });
187
204
  }
188
- else if (res.target.target === constants_1.REMOTE_REF.functions.type.bio) {
189
- runtime_store_1.default.set(`context.port.debug.${constants_1.REMOTE_REF.functions.type.bio}`, res.filter);
205
+ else if (res.target.target === constants_1.FN_TYPE.basic) {
206
+ runtime_store_1.default.set(`context.port.debug.${constants_1.FN_TYPE.basic}`, res.filter);
190
207
  }
191
208
  else {
192
209
  runtime_store_1.default.set(`context.port.debug.${res.target.target}.${res.filter}`, res.specific);
@@ -24,6 +24,14 @@ const error_1 = __importDefault(require("./error"));
24
24
  const runtime_store_1 = __importDefault(require("./runtime-store"));
25
25
  const constants_1 = require("./util_modules/constants");
26
26
  const logger_1 = require("./util_modules/logger");
27
+ const featureRef = {
28
+ client: 'client',
29
+ aio: 'advancedio',
30
+ bio: 'basicio',
31
+ master: 'master',
32
+ appsail: 'appsail',
33
+ browserlogic: 'browser_logic'
34
+ };
27
35
  class PortResolver {
28
36
  static getFreePort(startPort, searchSpan, dupCheck) {
29
37
  return __awaiter(this, void 0, void 0, function* () {
@@ -62,7 +70,7 @@ class PortResolver {
62
70
  port = constants_1.DEFAULT.serve_port['http']['appsail'][server];
63
71
  }
64
72
  else {
65
- port = constants_1.DEFAULT.serve_port[type][feature];
73
+ port = constants_1.DEFAULT.serve_port[type][featureRef[feature]];
66
74
  }
67
75
  }
68
76
  else {
@@ -58,8 +58,8 @@ class Server {
58
58
  if (fnTargets.length === 0) {
59
59
  (0, logger_1.debug)('No basic functions to add');
60
60
  }
61
- const httpPort = parseInt(runtime_store_1.default.get('context.port.http.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic]), 10);
62
- const debugPort = parseInt(runtime_store_1.default.get('context.port.debug.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic], '-1'), 10);
61
+ const httpPort = parseInt(runtime_store_1.default.get('context.port.http.' + constants_1.FN_TYPE.basic), 10);
62
+ const debugPort = parseInt(runtime_store_1.default.get('context.port.debug.' + constants_1.FN_TYPE.basic, '-1'), 10);
63
63
  if (!isNaN(httpPort)) {
64
64
  fnTargets
65
65
  .filter((t) => {
@@ -117,52 +117,73 @@ class Server {
117
117
  });
118
118
  }
119
119
  startServer(details, masterPort) {
120
- var _a, _b;
120
+ var _a, _b, _c;
121
121
  return __awaiter(this, void 0, void 0, function* () {
122
122
  if (details.target === undefined) {
123
123
  return details;
124
124
  }
125
- let currentProcess;
126
- switch (details.type) {
127
- case 'appsail': {
128
- currentProcess = yield (0, index_js_5.default)(details);
129
- break;
130
- }
131
- case 'client': {
132
- currentProcess = yield (0, index_js_4.default)(details, masterPort);
133
- break;
134
- }
135
- case 'functions':
136
- case 'server': {
137
- if ((_a = details.target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java.value)) {
138
- currentProcess = yield (0, index_js_1.default)(details, masterPort);
125
+ try {
126
+ let currentProcess;
127
+ switch (details.type) {
128
+ case 'appsail': {
129
+ currentProcess = yield (0, index_js_5.default)(details);
130
+ break;
139
131
  }
140
- else if ((_b = details.target.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.node.value)) {
141
- currentProcess = yield (0, index_js_2.default)(details, masterPort);
132
+ case 'client': {
133
+ currentProcess = yield (0, index_js_4.default)(details, masterPort);
134
+ break;
142
135
  }
143
- else {
144
- currentProcess = yield (0, index_js_3.default)(details);
136
+ case 'functions':
137
+ case 'server': {
138
+ if ((_a = details.target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java.value)) {
139
+ currentProcess = yield (0, index_js_1.default)(details, masterPort);
140
+ }
141
+ else if ((_b = details.target.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.node.value)) {
142
+ currentProcess = yield (0, index_js_2.default)(details, masterPort);
143
+ }
144
+ else {
145
+ currentProcess = yield (0, index_js_3.default)(details);
146
+ }
147
+ break;
148
+ }
149
+ default: {
150
+ throw new error_1.default('Invalid feature type', { exit: 2 });
145
151
  }
146
- break;
147
152
  }
148
- default: {
149
- throw new error_1.default('Invalid feature type', { exit: 2 });
153
+ details.process = currentProcess;
154
+ const stdout = currentProcess.stdout;
155
+ if (stdout) {
156
+ stdout.on('data', (chunk) => {
157
+ process.stdout.write(chunk.toString());
158
+ });
159
+ }
160
+ const stderr = currentProcess.stderr;
161
+ if (stderr) {
162
+ stderr.on('data', (chunk) => {
163
+ process.stderr.write(chunk.toString());
164
+ });
150
165
  }
166
+ return new Promise((res) => setTimeout(() => res(details), 100));
151
167
  }
152
- details.process = currentProcess;
153
- const stdout = currentProcess.stdout;
154
- if (stdout) {
155
- stdout.on('data', (chunk) => {
156
- process.stdout.write(chunk.toString());
157
- });
158
- }
159
- const stderr = currentProcess.stderr;
160
- if (stderr) {
161
- stderr.on('data', (chunk) => {
162
- process.stderr.write(chunk.toString());
163
- });
168
+ catch (er) {
169
+ const error = 'Unable to start the server: ' + error_1.default.getErrorInstance(er).message;
170
+ if (details.type === 'appsail') {
171
+ const target = details.target;
172
+ target.validity.valid = false;
173
+ (0, logger_1.labeled)(`AppSail[${(_c = target.appSail) === null || _c === void 0 ? void 0 : _c.name}]`, error).ERROR();
174
+ }
175
+ else if (details.type === 'client') {
176
+ const target = details.target;
177
+ target.valid = false;
178
+ (0, logger_1.labeled)(`WebClient[${details.target}]`, error).ERROR();
179
+ }
180
+ else {
181
+ const target = details.target;
182
+ target.valid = false;
183
+ (0, logger_1.labeled)(`${target.type}[${target.name}]`, error).ERROR();
184
+ }
185
+ return details;
164
186
  }
165
- return new Promise((res) => setTimeout(() => res(details), 100));
166
187
  });
167
188
  }
168
189
  start() {
@@ -203,20 +224,23 @@ class Server {
203
224
  return;
204
225
  }
205
226
  return this.startServer(_details, masterPort).then((t) => {
206
- var _a, _b, _c;
227
+ var _a, _b, _c, _d;
207
228
  const serverDetails = t;
229
+ if (!((_a = serverDetails.target) === null || _a === void 0 ? void 0 : _a.valid)) {
230
+ return;
231
+ }
208
232
  if (serverDetails.type === 'client') {
209
233
  logUrls.client = serverDetails;
210
234
  }
211
235
  else {
212
236
  const _details = serverDetails;
213
- const targType = (_a = _details.target) === null || _a === void 0 ? void 0 : _a.type;
237
+ const targType = (_b = _details.target) === null || _b === void 0 ? void 0 : _b.type;
214
238
  logUrls.functions[targType].targs.push(_details);
215
239
  logUrls.functions[targType].nameMaxLength =
216
- ((_b = _details.target) === null || _b === void 0 ? void 0 : _b.name) &&
240
+ ((_c = _details.target) === null || _c === void 0 ? void 0 : _c.name) &&
217
241
  _details.target.name.length >
218
242
  logUrls.functions[targType].nameMaxLength
219
- ? (_c = _details.target) === null || _c === void 0 ? void 0 : _c.name.length
243
+ ? (_d = _details.target) === null || _d === void 0 ? void 0 : _d.name.length
220
244
  : logUrls.functions[targType].nameMaxLength;
221
245
  }
222
246
  });
@@ -259,16 +283,21 @@ class Server {
259
283
  });
260
284
  }
261
285
  if (this.targetsMap.appSail.length > 0) {
262
- yield Promise.all(this.targetsMap.appSail.map((targSail) => this.startServer(targSail, -1).then(() => {
263
- var _a, _b, _c, _d, _e;
286
+ yield Promise.all(this.targetsMap.appSail.map((targSail) => this.startServer(targSail, -1).then((details) => {
287
+ var _a, _b, _c, _d, _e, _f;
288
+ const serverDetails = details;
289
+ if (!((_a = serverDetails.target) === null || _a === void 0 ? void 0 : _a.validity.valid)) {
290
+ return;
291
+ }
264
292
  logUrls.appsail.targs.push(targSail);
265
293
  logUrls.appsail.nameMaxLength =
266
- ((_b = (_a = targSail.target) === null || _a === void 0 ? void 0 : _a.appSail) === null || _b === void 0 ? void 0 : _b.name) &&
267
- ((_d = (_c = targSail.target) === null || _c === void 0 ? void 0 : _c.appSail) === null || _d === void 0 ? void 0 : _d.name.length) > logUrls.appsail.nameMaxLength
268
- ? (_e = targSail.target) === null || _e === void 0 ? void 0 : _e.appSail.name.length
294
+ ((_c = (_b = targSail.target) === null || _b === void 0 ? void 0 : _b.appSail) === null || _c === void 0 ? void 0 : _c.name) &&
295
+ ((_e = (_d = targSail.target) === null || _d === void 0 ? void 0 : _d.appSail) === null || _e === void 0 ? void 0 : _e.name.length) > logUrls.appsail.nameMaxLength
296
+ ? (_f = targSail.target) === null || _f === void 0 ? void 0 : _f.appSail.name.length
269
297
  : logUrls.appsail.nameMaxLength;
270
298
  })));
271
299
  }
300
+ let loggedEntries = 0;
272
301
  Object.entries(logUrls).forEach(([targType, logTarg]) => {
273
302
  var _a;
274
303
  switch (targType) {
@@ -278,6 +307,7 @@ class Server {
278
307
  if (_logTarg.targs.length === 0) {
279
308
  return;
280
309
  }
310
+ loggedEntries++;
281
311
  switch (_targType) {
282
312
  case 'bio': {
283
313
  (0, logger_1.info)();
@@ -336,6 +366,7 @@ class Server {
336
366
  if (_logTarg.targs.length === 0) {
337
367
  return;
338
368
  }
369
+ loggedEntries++;
339
370
  (0, logger_1.info)();
340
371
  (0, logger_1.info)((0, ansi_colors_1.bold)(' >>>>>>>>>>>>>> AppSail <<<<<<<<<<<<<< '));
341
372
  _logTarg.targs.forEach((t) => {
@@ -352,6 +383,7 @@ class Server {
352
383
  if (Object.keys(logTarg).length === 0) {
353
384
  return;
354
385
  }
386
+ loggedEntries++;
355
387
  (0, logger_1.info)();
356
388
  const targApp = logTarg;
357
389
  const appUrl = 'http://localhost:' + masterPort;
@@ -363,7 +395,9 @@ class Server {
363
395
  }
364
396
  }
365
397
  });
366
- return startPromise;
398
+ return loggedEntries > 0
399
+ ? startPromise
400
+ : Promise.reject(new error_1.default('No Resources served', { exit: 1, errorId: 'SERVE-IDX-2' }));
367
401
  });
368
402
  }
369
403
  wait() {
@@ -24,6 +24,7 @@ const archiver_1 = __importDefault(require("../../../../archiver"));
24
24
  const option_1 = require("../../../../util_modules/option");
25
25
  const execute_script_1 = require("../../../../execute-script");
26
26
  const master_1 = __importDefault(require("../master"));
27
+ const ansi_colors_1 = require("ansi-colors");
27
28
  function executeHook(script, name, moduleSource) {
28
29
  if ((0, option_1.getOptionValue)('ignoreScripts', false)) {
29
30
  (0, logger_1.debug)(`skipping ${name} hook`);
@@ -53,7 +54,14 @@ exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function*
53
54
  if ((_a = targetSail.appSail.scripts) === null || _a === void 0 ? void 0 : _a.preserve) {
54
55
  executeHook(targetSail.appSail.scripts.preserve, `AppSail [PRESERVE] [${(_b = targetSail.appSail) === null || _b === void 0 ? void 0 : _b.name}]`, targetSail.appSail.source);
55
56
  }
56
- const target = (yield fs_1.ASYNC.isFile(targetSail.appSail.buildPath))
57
+ if (!(yield fs_1.ASYNC.isPathExists(targetSail.appSail.buildPath))) {
58
+ throw new error_1.default(`Build path does not exists [${targetSail.appSail.buildPath}]`, {
59
+ exit: 1,
60
+ errorId: 'SERVE-APPSAIL-1',
61
+ arg: [ansi_colors_1.italic.red(targetSail.appSail.buildPath), (0, ansi_colors_1.bold)(targetSail.appSail.name)]
62
+ });
63
+ }
64
+ const target = (yield fs_1.ASYNC.fileExists(targetSail.appSail.buildPath))
57
65
  ? (0, path_1.dirname)(targetSail.appSail.buildPath)
58
66
  : targetSail.appSail.buildPath;
59
67
  switch (true) {
@@ -98,7 +106,7 @@ exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function*
98
106
  throw err;
99
107
  }
100
108
  }
101
- const jettyCommand = `java -jar ${(0, path_1.join)(jettyPath.replace(/ /g, '\\ '), 'start.jar')} -Djetty.deploy.monitoredPath=${(0, project_1.resolveProjectPath)(target)} -Djetty.http.port=${targetSail.port.appsail}`;
109
+ const jettyCommand = `java -jar "${(0, path_1.join)(jettyPath, 'start.jar')}" -Djetty.deploy.monitoredPath="${(0, project_1.resolveProjectPath)(target)}" -Djetty.http.port=${targetSail.port.appsail}`;
102
110
  child = startAppSail(targetSail.port.appsail, {
103
111
  target,
104
112
  type: 'war',
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- import express from 'express';
3
+ import { createServer } from 'http';
4
4
  import { inspect } from 'util';
5
5
  import { pathToFileURL } from 'url';
6
6
 
@@ -8,8 +8,6 @@ const args = process.argv.slice(2);
8
8
  const listenPort = parseInt(args[0], 10);
9
9
  const fnDetails = JSON.parse(args[1]);
10
10
 
11
- const app = express();
12
-
13
11
  const targetName = fnDetails.name;
14
12
  const index = pathToFileURL(fnDetails.index);
15
13
  const type = fnDetails.type;
@@ -69,9 +67,9 @@ const browserLogicHandler = async (req, res) => {
69
67
  }
70
68
  };
71
69
 
72
- app.use('/', type === 'browserlogic' ? browserLogicHandler : aioHandler);
70
+ const server = createServer(type === 'browserlogic' ? browserLogicHandler : aioHandler);
73
71
 
74
- app.listen(listenPort).on('error', (err) => {
72
+ server.listen(listenPort).on('error', (err) => {
75
73
  // eslint-disable-next-line no-console
76
74
  console.error(err);
77
75
  });
@@ -117,6 +117,11 @@ class HttpFunctions {
117
117
  cb(errorString, null);
118
118
  });
119
119
  slave.on('exit', (code) => {
120
+ if (!fs_1.SYNC.fileExists(this.responseFile)) {
121
+ (0, logger_2.debug)(`${this.responseFile} not present`);
122
+ cb(new Error('File does not exists: ' + this.responseFile));
123
+ return;
124
+ }
120
125
  const response = fs_1.SYNC.getReadStream(this.responseFile);
121
126
  const metaFileString = fs_1.SYNC.readFile(this.metaFile);
122
127
  let meta = {};
@@ -138,12 +143,15 @@ class HttpFunctions {
138
143
  }
139
144
  });
140
145
  this.runningSlaves.push(slave);
141
- }, { batchSize: 1, concurrent: 1, maxTimeout: Infinity });
146
+ }, { batchSize: 1, concurrent: 1, maxTimeout: Infinity }).on('task_failed', (targetName, err) => {
147
+ (0, logger_2.debug)('Unable to serve the function: ' + targetName);
148
+ (0, logger_2.debug)(err);
149
+ });
142
150
  }
143
151
  _spinUpServer() {
144
152
  return __awaiter(this, void 0, void 0, function* () {
145
- const debugPort = parseInt(runtime_store_1.default.get('context.port.debug.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic], '-1'), 10);
146
- const httpPort = parseInt(runtime_store_1.default.get('context.port.http.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic]), 10);
153
+ const debugPort = parseInt(runtime_store_1.default.get('context.port.debug.' + constants_1.FN_TYPE.basic, '-1'), 10);
154
+ const httpPort = parseInt(runtime_store_1.default.get('context.port.http.' + constants_1.FN_TYPE.basic), 10);
147
155
  if (this.repl !== undefined) {
148
156
  this.app.use((_req, _res, next) => {
149
157
  (0, shell_1.clearLine)(process.stdout);
@@ -151,7 +159,7 @@ class HttpFunctions {
151
159
  });
152
160
  }
153
161
  if (this.app.locals.primary) {
154
- this.app.use(logger_1.default);
162
+ this.app.use((0, logger_1.default)());
155
163
  this.app.use(cookie_parser_1.default);
156
164
  this.app.use((0, project_1.default)({
157
165
  id: (0, project_2.getProjectId)(),
@@ -91,7 +91,7 @@ class LocalFunction {
91
91
  const projectRoot = runtime_store_1.default.get('project.root');
92
92
  const accessToken = yield credential_1.default.getAccessToken();
93
93
  const slaveOptions = [];
94
- const debugPort = runtime_store_1.default.get('context.port.debug.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic], null);
94
+ const debugPort = runtime_store_1.default.get('context.port.debug.' + constants_1.FN_TYPE.basic, null);
95
95
  yield fs_1.ASYNC.ensureFile(this.responseFile, true);
96
96
  yield fs_1.ASYNC.ensureFile(this.metaFile, true);
97
97
  if ((_a = this.target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.node.value)) {
@@ -78,7 +78,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
78
78
  replServer.setContext(target.name, localFn.call);
79
79
  target.localFn = localFn;
80
80
  })));
81
- if (runtime_store_1.default.get('context.port.http.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic], false)) {
81
+ if (runtime_store_1.default.get('context.port.http.' + constants_1.FN_TYPE.basic, false)) {
82
82
  yield httpServer.start();
83
83
  }
84
84
  yield replServer.wait();
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = Object.freeze({
4
4
  nodejs: {
5
- Puppeteer: { 'puppeteer-core': 'latest', 'zcatalyst-sdk-node': 'beta' },
6
- Playwright: { 'playwright-core': 'latest', 'zcatalyst-sdk-node': 'beta' },
7
- Selenium: { 'selenium-webdriver': 'latest', 'zcatalyst-sdk-node': 'beta' }
5
+ Puppeteer: { 'puppeteer-core': 'latest', 'zcatalyst-sdk-node': 'latest' },
6
+ Playwright: { 'playwright-core': 'latest', 'zcatalyst-sdk-node': 'latest' },
7
+ Selenium: { 'selenium-webdriver': 'latest', 'zcatalyst-sdk-node': 'latest' }
8
8
  },
9
9
  java: {
10
10
  Selenium: [
@@ -35,9 +35,9 @@ exports.default = Object.freeze({
35
35
  [constants_1.INTEG.services.convokraft]: (0, path_1.join)(FUNCTIONS_NODE_ROOT, 'integ', 'convokraft')
36
36
  },
37
37
  [constants_1.FN_TYPE.browserLogic]: {
38
- playwright: (0, path_1.join)(FUNCTIONS_NODE_ROOT, 'browserlogic', 'playwright'),
39
- puppeteer: (0, path_1.join)(FUNCTIONS_NODE_ROOT, 'browserlogic', 'puppeteer'),
40
- selenium: (0, path_1.join)(FUNCTIONS_NODE_ROOT, 'browserlogic', 'selenium')
38
+ Playwright: (0, path_1.join)(FUNCTIONS_NODE_ROOT, 'browserlogic', 'playwright'),
39
+ Puppeteer: (0, path_1.join)(FUNCTIONS_NODE_ROOT, 'browserlogic', 'puppeteer'),
40
+ Selenium: (0, path_1.join)(FUNCTIONS_NODE_ROOT, 'browserlogic', 'selenium')
41
41
  }
42
42
  },
43
43
  java: {
@@ -50,8 +50,8 @@ exports.default = Object.freeze({
50
50
  [constants_1.INTEG.services.convokraft]: (0, path_1.join)(FUNCTIONS_JAVA_ROOT, 'integ', 'convokraft')
51
51
  },
52
52
  [constants_1.FN_TYPE.browserLogic]: {
53
- selenium: (0, path_1.join)(FUNCTIONS_JAVA_ROOT, 'browserlogic', 'selenium'),
54
- playwright: (0, path_1.join)(FUNCTIONS_JAVA_ROOT, 'browserlogic', 'playwright')
53
+ Selenium: (0, path_1.join)(FUNCTIONS_JAVA_ROOT, 'browserlogic', 'selenium'),
54
+ Playwright: (0, path_1.join)(FUNCTIONS_JAVA_ROOT, 'browserlogic', 'playwright')
55
55
  }
56
56
  },
57
57
  python: {
@@ -12,7 +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
- exports.chmod = exports.writeJSONFile = exports.readJSONFile = exports.emptyDir = exports.findAndReplace = exports.rename = exports.copyDir = exports.copyFiles = exports.copyFile = exports.deleteDir = exports.deleteFile = exports.ensureDir = exports.ensureFile = exports.walk = exports.dirList = exports.writeFile = exports.tempFile = exports.readFile = exports.isFile = exports.fileExists = exports.dirExists = exports.isPathExists = void 0;
15
+ exports.chmod = exports.writeJSONFile = exports.readJSONFile = exports.emptyDir = exports.findAndReplace = exports.rename = exports.copyDir = exports.copyFiles = exports.copyFile = exports.deleteDir = exports.deleteFile = exports.ensureDir = exports.ensureFile = exports.walk = exports.dirList = exports.writeFile = exports.tempFile = exports.readFile = exports.fileExists = exports.dirExists = exports.isPathExists = void 0;
16
16
  const fs_extra_1 = __importDefault(require("fs-extra"));
17
17
  const minimatch_1 = __importDefault(require("minimatch"));
18
18
  const os_1 = __importDefault(require("os"));
@@ -39,13 +39,6 @@ function fileExists(pth) {
39
39
  });
40
40
  }
41
41
  exports.fileExists = fileExists;
42
- function isFile(pth) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- const stats = yield fs_extra_1.default.stat((0, utils_js_1.untildify)(pth)).catch(() => false);
45
- return stats && stats.isFile();
46
- });
47
- }
48
- exports.isFile = isFile;
49
42
  function readFile(pth, type) {
50
43
  return __awaiter(this, void 0, void 0, function* () {
51
44
  if (!(yield fileExists(pth))) {
@@ -20,7 +20,7 @@ class ConnectionDestroyer {
20
20
  this.connections = new Set();
21
21
  if (this.server instanceof http_proxy_1.default) {
22
22
  this.server.on('proxyReq', (req) => {
23
- req.on('finish', () => this.connections.delete(req));
23
+ req.on('close', () => this.connections.delete(req));
24
24
  this.connections.add(req);
25
25
  });
26
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcatalyst-cli",
3
- "version": "1.15.0-beta.6",
3
+ "version": "1.15.0",
4
4
  "description": "Command Line Tool for CATALYST",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -70,7 +70,7 @@
70
70
  "@types/inquirer-autocomplete-prompt": "^1.3.4",
71
71
  "@types/jest": "^27.4.1",
72
72
  "@types/lodash": "^4.14.182",
73
- "@types/minimatch": "^3.0.5",
73
+ "@types/minimatch": "^5.1.2",
74
74
  "@types/node": "^17.0.25",
75
75
  "@types/request": "^2.48.8",
76
76
  "@types/semver": "^7.3.9",