zcatalyst-cli 1.15.0-beta.6 → 1.15.0-beta.7

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.
@@ -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 = ''
@@ -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',
@@ -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))) {
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-beta.7",
4
4
  "description": "Command Line Tool for CATALYST",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {