zcatalyst-cli 1.15.0-beta.5 → 1.15.0-beta.6
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.
- package/lib/archiver.js +8 -3
- package/lib/client-utils.js +5 -1
- package/lib/commands/iac/pack.js +9 -8
- package/lib/deploy/features/appsail/index.js +15 -5
- package/lib/deploy/features/client.js +1 -1
- package/lib/deploy/features/functions/index.js +7 -4
- package/lib/endpoints/lib/applogic.js +14 -2
- package/lib/endpoints/lib/appsail.js +11 -2
- package/lib/endpoints/lib/client.js +11 -2
- package/lib/endpoints/lib/functions.js +14 -2
- package/lib/express_middlewares/logger.js +6 -2
- package/lib/fn-utils/lib/common.js +78 -48
- package/lib/fn-utils/lib/java.js +10 -10
- package/lib/fn-utils/lib/python.js +1 -1
- package/lib/init/features/appsail/index.js +2 -2
- package/lib/internal/api.js +33 -8
- package/lib/option-filter.js +4 -4
- package/lib/port-resolver.js +24 -11
- package/lib/progress.js +3 -2
- package/lib/prompt/types/file-path.js +3 -1
- package/lib/serve/features/appsail.js +14 -3
- package/lib/serve/features/index.js +1 -1
- package/lib/serve/index.js +7 -2
- package/lib/serve/server/index.js +252 -92
- package/lib/serve/server/lib/appsail/index.js +19 -9
- package/lib/serve/server/lib/appsail/start.js +4 -15
- package/lib/serve/server/lib/master.js +10 -10
- package/lib/serve/server/lib/web_client/index.js +5 -5
- package/lib/shell/dependencies/http-functions.js +11 -15
- package/lib/shell/prepare/languages/java.js +9 -4
- package/lib/util_modules/constants/lib/default.js +4 -1
- package/lib/util_modules/constants/lib/scopes.js +1 -0
- package/lib/util_modules/fs/lib/async.js +10 -9
- package/lib/util_modules/fs/lib/sync.js +5 -1
- package/package.json +1 -1
- package/templates/init/functions/java/integ/convokraft/FallbackHandler.java +1 -0
- package/templates/init/functions/node/integ/convokraft/fallback.js +1 -0
- package/templates/init/functions/python/integ/convokraft/fallback_handler.py +2 -1
- package/templates/init/functions/node/.DS_Store +0 -0
- package/templates/init/functions/node/integ/.DS_Store +0 -0
- package/templates/init/functions/node/integ/convokraft/.DS_Store +0 -0
|
@@ -26,13 +26,23 @@ const index_js_4 = __importDefault(require("./lib/web_client/index.js"));
|
|
|
26
26
|
const index_js_5 = __importDefault(require("./lib/appsail/index.js"));
|
|
27
27
|
const cli_table_1 = require("../../cli_table");
|
|
28
28
|
const ansi_colors_1 = require("ansi-colors");
|
|
29
|
-
const bioLogUrl = (
|
|
30
|
-
|
|
29
|
+
const bioLogUrl = (details, masterPort, addSpaces) => {
|
|
30
|
+
var _a, _b, _c, _d;
|
|
31
|
+
const labelMap = {
|
|
32
|
+
bio: 'BasicIO',
|
|
33
|
+
browserlogic: 'Browser Logic'
|
|
34
|
+
};
|
|
35
|
+
const label = addSpaces
|
|
36
|
+
? ((_a = details.target) === null || _a === void 0 ? void 0 : _a.name) + ''
|
|
37
|
+
: `${labelMap[(_b = details.target) === null || _b === void 0 ? void 0 : _b.type]}[${(_c = details.target) === null || _c === void 0 ? void 0 : _c.name}]`;
|
|
38
|
+
(0, logger_1.labeled)(label + ' '.repeat((addSpaces || label.length) - label.length), 'http://localhost:' +
|
|
39
|
+
(masterPort === -1 ? details.httpPort : masterPort) +
|
|
40
|
+
new URL(((_d = details.target) === null || _d === void 0 ? void 0 : _d.url) || '').pathname).MESSAGE();
|
|
31
41
|
};
|
|
32
|
-
const aioLogUrl = (details, masterPort) => {
|
|
33
|
-
var _a, _b;
|
|
34
|
-
|
|
35
|
-
(0, logger_1.
|
|
42
|
+
const aioLogUrl = (details, masterPort, addSpaces) => {
|
|
43
|
+
var _a, _b, _c;
|
|
44
|
+
const label = addSpaces ? ((_a = details.target) === null || _a === void 0 ? void 0 : _a.name) + '' : `AdvancedIO[${(_b = details.target) === null || _b === void 0 ? void 0 : _b.name}]`;
|
|
45
|
+
(0, logger_1.labeled)(label + ' '.repeat((addSpaces || label.length) - label.length), `http://localhost:${masterPort}/server/${(_c = details.target) === null || _c === void 0 ? void 0 : _c.name}/`).MESSAGE();
|
|
36
46
|
};
|
|
37
47
|
class Server {
|
|
38
48
|
constructor() {
|
|
@@ -43,7 +53,7 @@ class Server {
|
|
|
43
53
|
appSail: []
|
|
44
54
|
};
|
|
45
55
|
}
|
|
46
|
-
_addBasicFnDetails() {
|
|
56
|
+
_addBasicFnDetails(bioUrlLogs) {
|
|
47
57
|
const fnTargets = runtime_store_1.default.get('context.functions.targets', []);
|
|
48
58
|
if (fnTargets.length === 0) {
|
|
49
59
|
(0, logger_1.debug)('No basic functions to add');
|
|
@@ -60,12 +70,18 @@ class Server {
|
|
|
60
70
|
})
|
|
61
71
|
.map((t) => js_1.JS.omit(t, ['zip_stream', 'localFn']))
|
|
62
72
|
.forEach((t) => {
|
|
63
|
-
|
|
73
|
+
const target = {
|
|
64
74
|
type: 'functions',
|
|
65
75
|
httpPort,
|
|
66
76
|
debugPort,
|
|
67
77
|
target: t
|
|
68
|
-
}
|
|
78
|
+
};
|
|
79
|
+
this.targetsMap.functions.push(target);
|
|
80
|
+
bioUrlLogs.targs.push(target);
|
|
81
|
+
bioUrlLogs.nameMaxLength =
|
|
82
|
+
t.name.length > bioUrlLogs.nameMaxLength
|
|
83
|
+
? t.name.length
|
|
84
|
+
: bioUrlLogs.nameMaxLength;
|
|
69
85
|
});
|
|
70
86
|
}
|
|
71
87
|
}
|
|
@@ -104,12 +120,12 @@ class Server {
|
|
|
104
120
|
var _a, _b;
|
|
105
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
122
|
if (details.target === undefined) {
|
|
107
|
-
return;
|
|
123
|
+
return details;
|
|
108
124
|
}
|
|
109
125
|
let currentProcess;
|
|
110
126
|
switch (details.type) {
|
|
111
127
|
case 'appsail': {
|
|
112
|
-
currentProcess = yield (0, index_js_5.default)(details
|
|
128
|
+
currentProcess = yield (0, index_js_5.default)(details);
|
|
113
129
|
break;
|
|
114
130
|
}
|
|
115
131
|
case 'client': {
|
|
@@ -146,103 +162,247 @@ class Server {
|
|
|
146
162
|
process.stderr.write(chunk.toString());
|
|
147
163
|
});
|
|
148
164
|
}
|
|
149
|
-
return new Promise((res) => setTimeout(res, 100));
|
|
165
|
+
return new Promise((res) => setTimeout(() => res(details), 100));
|
|
150
166
|
});
|
|
151
167
|
}
|
|
152
168
|
start() {
|
|
153
169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
this.masterServer = server;
|
|
169
|
-
this.targetsMap.server.every((t) => {
|
|
170
|
-
var _a;
|
|
171
|
-
if (t.debugPort !== -1 &&
|
|
172
|
-
((_a = t.target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python.value))) {
|
|
173
|
-
const table = (0, cli_table_1.getCustomColourTable)(ansi_colors_1.yellow);
|
|
174
|
-
table.push(['As of now, local debugging for python is not supported']);
|
|
175
|
-
(0, logger_1.info)(table.toString());
|
|
176
|
-
return true;
|
|
170
|
+
const logUrls = {
|
|
171
|
+
functions: {
|
|
172
|
+
bio: { targs: [], nameMaxLength: 0 },
|
|
173
|
+
aio: { targs: [], nameMaxLength: 0 },
|
|
174
|
+
browserlogic: { targs: [], nameMaxLength: 0 }
|
|
175
|
+
},
|
|
176
|
+
appsail: { targs: [], nameMaxLength: 0 },
|
|
177
|
+
client: {}
|
|
178
|
+
};
|
|
179
|
+
this._addBasicFnDetails(logUrls.functions.bio);
|
|
180
|
+
const masterTargets = ['functions', 'client', 'server'].reduce((_masterTargets, targ) => {
|
|
181
|
+
if (this.targetsMap[targ]) {
|
|
182
|
+
_masterTargets.targets[targ] = this.targetsMap[targ];
|
|
183
|
+
_masterTargets.length += this.targetsMap[targ].length;
|
|
177
184
|
}
|
|
178
|
-
return
|
|
185
|
+
return _masterTargets;
|
|
186
|
+
}, {
|
|
187
|
+
targets: {},
|
|
188
|
+
length: 0
|
|
179
189
|
});
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
190
|
+
const serveTargets = Object.values(masterTargets.targets);
|
|
191
|
+
const serveTargetsArr = serveTargets.flat();
|
|
192
|
+
const masterPort = runtime_store_1.default.get(`context.port.http.master`, -1);
|
|
193
|
+
let startPromise = Promise.resolve();
|
|
194
|
+
if (masterTargets.length > 0) {
|
|
195
|
+
if (masterPort === -1) {
|
|
196
|
+
throw new error_1.default('master port cannot be undefined', { exit: 2 });
|
|
184
197
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
targetDetails.process.send('start');
|
|
198
|
-
return;
|
|
198
|
+
yield Promise.all(serveTargets.map((targetDetails) => Promise.all(targetDetails.map((details) => {
|
|
199
|
+
var _a, _b;
|
|
200
|
+
const _details = details;
|
|
201
|
+
if (((_a = _details.target) === null || _a === void 0 ? void 0 : _a.type) === 'bio' &&
|
|
202
|
+
!((_b = _details.target.stack) === null || _b === void 0 ? void 0 : _b.includes('python'))) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
return this.startServer(_details, masterPort).then((t) => {
|
|
206
|
+
var _a, _b, _c;
|
|
207
|
+
const serverDetails = t;
|
|
208
|
+
if (serverDetails.type === 'client') {
|
|
209
|
+
logUrls.client = serverDetails;
|
|
199
210
|
}
|
|
200
|
-
|
|
211
|
+
else {
|
|
212
|
+
const _details = serverDetails;
|
|
213
|
+
const targType = (_a = _details.target) === null || _a === void 0 ? void 0 : _a.type;
|
|
214
|
+
logUrls.functions[targType].targs.push(_details);
|
|
215
|
+
logUrls.functions[targType].nameMaxLength =
|
|
216
|
+
((_b = _details.target) === null || _b === void 0 ? void 0 : _b.name) &&
|
|
217
|
+
_details.target.name.length >
|
|
218
|
+
logUrls.functions[targType].nameMaxLength
|
|
219
|
+
? (_c = _details.target) === null || _c === void 0 ? void 0 : _c.name.length
|
|
220
|
+
: logUrls.functions[targType].nameMaxLength;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}))));
|
|
224
|
+
if (serveTargetsArr.length === 0) {
|
|
225
|
+
throw new error_1.default('Trying to start master server before other server', {
|
|
226
|
+
exit: 2
|
|
201
227
|
});
|
|
202
|
-
|
|
228
|
+
}
|
|
229
|
+
this.masterServer =
|
|
230
|
+
masterTargets.length > 0
|
|
231
|
+
? yield (0, master_1.default)(masterPort, masterTargets.targets)
|
|
232
|
+
: undefined;
|
|
233
|
+
startPromise = new Promise((res) => {
|
|
234
|
+
this.masterServer
|
|
235
|
+
? this.masterServer.on('listening', () => {
|
|
236
|
+
serveTargetsArr.forEach((targetDetails) => {
|
|
237
|
+
var _a;
|
|
238
|
+
if (targetDetails.process &&
|
|
239
|
+
'send' in targetDetails.process) {
|
|
240
|
+
targetDetails.process.send('start');
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
(_a = targetDetails.process) === null || _a === void 0 ? void 0 : _a.emit('start');
|
|
244
|
+
});
|
|
245
|
+
res();
|
|
246
|
+
})
|
|
247
|
+
: res();
|
|
203
248
|
});
|
|
249
|
+
this.targetsMap.server.every((t) => {
|
|
250
|
+
var _a;
|
|
251
|
+
if (t.debugPort !== -1 &&
|
|
252
|
+
((_a = t.target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python.value))) {
|
|
253
|
+
const table = (0, cli_table_1.getCustomColourTable)(ansi_colors_1.yellow);
|
|
254
|
+
table.push(['As of now, local debugging for python is not supported']);
|
|
255
|
+
(0, logger_1.info)(table.toString());
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
return false;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
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;
|
|
264
|
+
logUrls.appsail.targs.push(targSail);
|
|
265
|
+
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
|
|
269
|
+
: logUrls.appsail.nameMaxLength;
|
|
270
|
+
})));
|
|
271
|
+
}
|
|
272
|
+
Object.entries(logUrls).forEach(([targType, logTarg]) => {
|
|
273
|
+
var _a;
|
|
274
|
+
switch (targType) {
|
|
275
|
+
case 'functions': {
|
|
276
|
+
Object.entries(logTarg).forEach((x) => {
|
|
277
|
+
const [_targType, _logTarg] = x;
|
|
278
|
+
if (_logTarg.targs.length === 0) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
switch (_targType) {
|
|
282
|
+
case 'bio': {
|
|
283
|
+
(0, logger_1.info)();
|
|
284
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)(' >>>>>>>>>>>>>> BasicIO <<<<<<<<<<<<<< '));
|
|
285
|
+
_logTarg.targs.forEach((t) => {
|
|
286
|
+
var _a;
|
|
287
|
+
const target = t;
|
|
288
|
+
if (!((_a = target.target) === null || _a === void 0 ? void 0 : _a.url)) {
|
|
289
|
+
throw new error_1.default('Target URL not found', {
|
|
290
|
+
exit: 2
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
bioLogUrl(target, masterPort, _logTarg.nameMaxLength);
|
|
294
|
+
});
|
|
295
|
+
(0, logger_1.info)();
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
case 'aio': {
|
|
299
|
+
(0, logger_1.info)();
|
|
300
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)(' >>>>>>>>>>>>> AdvancedIO <<<<<<<<<<<< '));
|
|
301
|
+
_logTarg.targs.forEach((t) => {
|
|
302
|
+
var _a;
|
|
303
|
+
const _target = t;
|
|
304
|
+
if (!((_a = _target.target) === null || _a === void 0 ? void 0 : _a.url)) {
|
|
305
|
+
throw new error_1.default('Target URL not found', {
|
|
306
|
+
exit: 2
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
aioLogUrl(_target, masterPort, _logTarg.nameMaxLength);
|
|
310
|
+
});
|
|
311
|
+
(0, logger_1.info)();
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
case 'browserlogic': {
|
|
315
|
+
(0, logger_1.info)();
|
|
316
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)(' >>>>>>>>>>>> BrowserLogic <<<<<<<<<<< '));
|
|
317
|
+
_logTarg.targs.forEach((t) => {
|
|
318
|
+
var _a;
|
|
319
|
+
const target = t;
|
|
320
|
+
if (!((_a = target.target) === null || _a === void 0 ? void 0 : _a.url)) {
|
|
321
|
+
throw new error_1.default('Target URL not found', {
|
|
322
|
+
exit: 2
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
bioLogUrl(target, masterPort, _logTarg.nameMaxLength);
|
|
326
|
+
});
|
|
327
|
+
(0, logger_1.info)();
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
case 'appsail': {
|
|
335
|
+
const _logTarg = logTarg;
|
|
336
|
+
if (_logTarg.targs.length === 0) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
(0, logger_1.info)();
|
|
340
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)(' >>>>>>>>>>>>>> AppSail <<<<<<<<<<<<<< '));
|
|
341
|
+
_logTarg.targs.forEach((t) => {
|
|
342
|
+
var _a;
|
|
343
|
+
const targetSail = t.target;
|
|
344
|
+
const targName = ((_a = targetSail.appSail) === null || _a === void 0 ? void 0 : _a.name) + '';
|
|
345
|
+
(0, logger_1.labeled)(targName +
|
|
346
|
+
' '.repeat((_logTarg.nameMaxLength || targName.length) - targName.length), `http://localhost:${targetSail.port.proxy}`).MESSAGE();
|
|
347
|
+
});
|
|
348
|
+
(0, logger_1.info)();
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
case 'client': {
|
|
352
|
+
if (Object.keys(logTarg).length === 0) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
(0, logger_1.info)();
|
|
356
|
+
const targApp = logTarg;
|
|
357
|
+
const appUrl = 'http://localhost:' + masterPort;
|
|
358
|
+
const label = `client[${(_a = targApp.target) === null || _a === void 0 ? void 0 : _a.name}]`;
|
|
359
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)(' >>>>>>>>>>>>> Web Client <<<<<<<<<<<<'));
|
|
360
|
+
(0, logger_1.labeled)(label, `${appUrl}/app/`).MESSAGE();
|
|
361
|
+
(0, logger_1.info)();
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
204
365
|
});
|
|
366
|
+
return startPromise;
|
|
205
367
|
});
|
|
206
368
|
}
|
|
207
369
|
wait() {
|
|
208
370
|
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const target = targetdetails.target;
|
|
218
|
-
if (!target || !targetdetails.process) {
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
(_a = target.watcher) === null || _a === void 0 ? void 0 : _a.on('preparing', () => __awaiter(this, void 0, void 0, function* () {
|
|
222
|
-
yield this.kill(targetdetails.process);
|
|
223
|
-
}));
|
|
224
|
-
(_b = target.watcher) === null || _b === void 0 ? void 0 : _b.on('compiled', () => __awaiter(this, void 0, void 0, function* () {
|
|
225
|
-
yield this.restart(targetdetails);
|
|
226
|
-
if (target.type === constants_1.FN_TYPE.basic) {
|
|
227
|
-
(0, logger_1.labeled)(`functions[${target.name}]`, 'ready!').MESSAGE();
|
|
228
|
-
if (!target.url) {
|
|
229
|
-
throw new error_1.default('Target URL not found while restarting server', {
|
|
230
|
-
exit: 2
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
bioLogUrl(target.name, new URL(target.url).pathname, targetdetails.httpPort, masterPort);
|
|
234
|
-
}
|
|
235
|
-
else if (target.type === constants_1.FN_TYPE.advanced) {
|
|
236
|
-
(0, logger_1.labeled)(`server[${target.name}]`, 'ready!').MESSAGE();
|
|
237
|
-
aioLogUrl(targetdetails, masterPort);
|
|
371
|
+
if (this.masterServer) {
|
|
372
|
+
const masterPort = runtime_store_1.default.get(`context.port.http.master`, -1);
|
|
373
|
+
Object.values(this.targetsMap).forEach((details) => {
|
|
374
|
+
details.forEach((targetdetails) => {
|
|
375
|
+
var _a, _b;
|
|
376
|
+
const target = targetdetails.target;
|
|
377
|
+
if (!target || !targetdetails.process) {
|
|
378
|
+
return;
|
|
238
379
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
380
|
+
(_a = target.watcher) === null || _a === void 0 ? void 0 : _a.on('preparing', () => __awaiter(this, void 0, void 0, function* () {
|
|
381
|
+
yield this.kill(targetdetails.process);
|
|
382
|
+
}));
|
|
383
|
+
(_b = target.watcher) === null || _b === void 0 ? void 0 : _b.on('compiled', () => __awaiter(this, void 0, void 0, function* () {
|
|
384
|
+
yield this.restart(targetdetails);
|
|
385
|
+
if (target.type === constants_1.FN_TYPE.basic) {
|
|
386
|
+
(0, logger_1.labeled)(`functions[${target.name}]`, 'ready!').MESSAGE();
|
|
387
|
+
if (!target.url) {
|
|
388
|
+
throw new error_1.default('Target URL not found while restarting server', {
|
|
389
|
+
exit: 2
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
bioLogUrl(targetdetails, masterPort);
|
|
393
|
+
}
|
|
394
|
+
else if (target.type === constants_1.FN_TYPE.advanced) {
|
|
395
|
+
(0, logger_1.labeled)(`AdvancedIO[${target.name}]`, 'ready!').MESSAGE();
|
|
396
|
+
aioLogUrl(targetdetails, masterPort);
|
|
397
|
+
}
|
|
398
|
+
setTimeout(() => {
|
|
399
|
+
var _a;
|
|
400
|
+
(_a = target.watcher) === null || _a === void 0 ? void 0 : _a.emit('next');
|
|
401
|
+
}, 1000);
|
|
402
|
+
}));
|
|
403
|
+
}, this);
|
|
404
|
+
});
|
|
405
|
+
}
|
|
246
406
|
return new Promise((res) => {
|
|
247
407
|
['SIGINT', 'SIGTERM'].forEach((sig) => process.on(sig, res));
|
|
248
408
|
});
|
|
@@ -23,6 +23,7 @@ const endpoints_1 = require("../../../../endpoints");
|
|
|
23
23
|
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
|
+
const master_1 = __importDefault(require("../master"));
|
|
26
27
|
function executeHook(script, name, moduleSource) {
|
|
27
28
|
if ((0, option_1.getOptionValue)('ignoreScripts', false)) {
|
|
28
29
|
(0, logger_1.debug)(`skipping ${name} hook`);
|
|
@@ -42,10 +43,11 @@ const startAppSail = (port, opts) => {
|
|
|
42
43
|
env: Object.assign({ X_ZOHO_CATALYST_LISTEN_PORT: port + '', X_ZOHO_CATALYST_RUNTIME_MEMORY: opts.memory + '', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, (opts.env || {}))
|
|
43
44
|
}).RAW();
|
|
44
45
|
};
|
|
45
|
-
exports.default = (
|
|
46
|
+
exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
47
|
var _a, _b, _c;
|
|
47
48
|
let child;
|
|
48
|
-
|
|
49
|
+
const targetSail = serverDetails.target;
|
|
50
|
+
if (!targetSail || !targetSail.appSail) {
|
|
49
51
|
throw new error_1.default('AppSail details not found');
|
|
50
52
|
}
|
|
51
53
|
if ((_a = targetSail.appSail.scripts) === null || _a === void 0 ? void 0 : _a.preserve) {
|
|
@@ -56,7 +58,7 @@ exports.default = (targetSail, masterPort) => __awaiter(void 0, void 0, void 0,
|
|
|
56
58
|
: targetSail.appSail.buildPath;
|
|
57
59
|
switch (true) {
|
|
58
60
|
case targetSail.appSail.stack.startsWith('node'): {
|
|
59
|
-
child = startAppSail(targetSail.port, {
|
|
61
|
+
child = startAppSail(targetSail.port.appsail, {
|
|
60
62
|
type: 'nodejs',
|
|
61
63
|
target,
|
|
62
64
|
command: targetSail.appSail.command,
|
|
@@ -66,7 +68,7 @@ exports.default = (targetSail, masterPort) => __awaiter(void 0, void 0, void 0,
|
|
|
66
68
|
break;
|
|
67
69
|
}
|
|
68
70
|
case targetSail.appSail.stack.startsWith('python'): {
|
|
69
|
-
child = startAppSail(targetSail.port, {
|
|
71
|
+
child = startAppSail(targetSail.port.appsail, {
|
|
70
72
|
type: 'python',
|
|
71
73
|
target,
|
|
72
74
|
command: targetSail.appSail.command,
|
|
@@ -96,8 +98,8 @@ exports.default = (targetSail, masterPort) => __awaiter(void 0, void 0, void 0,
|
|
|
96
98
|
throw err;
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
|
-
const jettyCommand = `java -jar ${(0, path_1.join)(jettyPath.replace(/ /g, '\\ '), 'start.jar')} -Djetty.deploy.monitoredPath=${(0, project_1.resolveProjectPath)(
|
|
100
|
-
child = startAppSail(targetSail.port, {
|
|
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}`;
|
|
102
|
+
child = startAppSail(targetSail.port.appsail, {
|
|
101
103
|
target,
|
|
102
104
|
type: 'war',
|
|
103
105
|
command: jettyCommand,
|
|
@@ -106,7 +108,7 @@ exports.default = (targetSail, masterPort) => __awaiter(void 0, void 0, void 0,
|
|
|
106
108
|
});
|
|
107
109
|
break;
|
|
108
110
|
}
|
|
109
|
-
child = startAppSail(targetSail.port, {
|
|
111
|
+
child = startAppSail(targetSail.port.appsail, {
|
|
110
112
|
target,
|
|
111
113
|
command: targetSail.appSail.command,
|
|
112
114
|
type: 'javase',
|
|
@@ -119,8 +121,16 @@ exports.default = (targetSail, masterPort) => __awaiter(void 0, void 0, void 0,
|
|
|
119
121
|
throw new error_1.default('Invalid AppSail stack');
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
|
-
(0,
|
|
123
|
-
|
|
124
|
+
const masterServe = yield (0, master_1.default)(targetSail.port.proxy, {
|
|
125
|
+
appSail: [serverDetails]
|
|
126
|
+
});
|
|
127
|
+
child.once('exit', () => {
|
|
128
|
+
masterServe.close((err) => {
|
|
129
|
+
if (err) {
|
|
130
|
+
(0, logger_1.debug)('Error stopping the AppSail proxy server: ', err);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
124
134
|
if ((_c = targetSail.appSail.scripts) === null || _c === void 0 ? void 0 : _c.postserve) {
|
|
125
135
|
child.once('exit', () => {
|
|
126
136
|
var _a, _b, _c, _d;
|
|
@@ -7,7 +7,6 @@ const JAVASE = 'javase';
|
|
|
7
7
|
const NODEJS = 'nodejs';
|
|
8
8
|
const PYTHON = 'python';
|
|
9
9
|
|
|
10
|
-
// const WAR_DEFAULT = "";
|
|
11
10
|
const JAVASE_DEFAULT = 'java Main';
|
|
12
11
|
const NODEJS_DEFAULT = 'node main.js';
|
|
13
12
|
const PYTHON_DEFAULT = 'python main.py';
|
|
@@ -33,28 +32,18 @@ function parseCmdArg() {
|
|
|
33
32
|
return args;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
function getWarCommand(command) {
|
|
37
|
-
if (process.env.JAVA_OPTS) {
|
|
38
|
-
command += ` ${process.env.JAVA_OPTS}`;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const DRYRUN_OUTPUT = EXEC_SYNC(command.toString(), {
|
|
42
|
-
stdio: 'pipe',
|
|
43
|
-
cwd: process.env.JETTY_BASE
|
|
44
|
-
}).toString();
|
|
45
|
-
return `java ${DRYRUN_OUTPUT}`;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
35
|
function main() {
|
|
49
36
|
const CMD_ARGS = parseCmdArg();
|
|
50
37
|
|
|
51
38
|
let command = '';
|
|
39
|
+
let cwd = process.cwd();
|
|
52
40
|
switch (CMD_ARGS.rtType) {
|
|
53
41
|
case WAR:
|
|
54
42
|
if (!CMD_ARGS.command) {
|
|
55
43
|
throw new Error(`command not found`);
|
|
56
44
|
}
|
|
57
|
-
command =
|
|
45
|
+
command = CMD_ARGS.command;
|
|
46
|
+
cwd = process.env.JETTY_BASE;
|
|
58
47
|
break;
|
|
59
48
|
case JAVASE:
|
|
60
49
|
command = CMD_ARGS.command || JAVASE_DEFAULT;
|
|
@@ -69,7 +58,7 @@ function main() {
|
|
|
69
58
|
throw new Error(`invalid runtime type: ${CMD_ARGS.rtType}`);
|
|
70
59
|
}
|
|
71
60
|
|
|
72
|
-
EXEC_SYNC(command.toString(), { stdio: 'inherit' });
|
|
61
|
+
EXEC_SYNC(command.toString(), { stdio: 'inherit', cwd });
|
|
73
62
|
}
|
|
74
63
|
|
|
75
64
|
main();
|
|
@@ -92,6 +92,7 @@ const proxyResponseHandler = (systemRoutes) => (proxyRes, req, res) => {
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
function spinUpMaster(listenPort, otherServerDetails) {
|
|
95
|
+
var _a;
|
|
95
96
|
return __awaiter(this, void 0, void 0, function* () {
|
|
96
97
|
const projectDetails = {
|
|
97
98
|
id: (0, project_2.getProjectId)(),
|
|
@@ -104,7 +105,7 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
104
105
|
const customProxyUrl = (0, option_1.getOptionValue)('proxy');
|
|
105
106
|
const app = (0, express_1.default)();
|
|
106
107
|
let systemRoutes;
|
|
107
|
-
app.use(logger_1.default);
|
|
108
|
+
app.use((0, logger_1.default)((_a = otherServerDetails.appSail) === null || _a === void 0 ? void 0 : _a.at(0)));
|
|
108
109
|
app.use(cookie_parser_1.default);
|
|
109
110
|
app.use((0, project_1.default)(projectDetails));
|
|
110
111
|
app.use(authenticator_1.default);
|
|
@@ -153,9 +154,10 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
153
154
|
.on('close', () => (0, logger_2.debug)('proxy closed'));
|
|
154
155
|
const proxyDestroyer = new server_js_1.ConnectionDestroyer(proxy);
|
|
155
156
|
Object.keys(otherServerDetails).forEach((targ) => {
|
|
157
|
+
var _a, _b, _c, _d;
|
|
156
158
|
switch (targ) {
|
|
157
159
|
case 'client': {
|
|
158
|
-
otherServerDetails.client.forEach((clientDetails) => {
|
|
160
|
+
(_a = otherServerDetails.client) === null || _a === void 0 ? void 0 : _a.forEach((clientDetails) => {
|
|
159
161
|
const appTarget = `http://127.0.0.1:${clientDetails.httpPort}/app/`;
|
|
160
162
|
app.use('/app', (req, res) => {
|
|
161
163
|
const target = clientDetails.target;
|
|
@@ -193,7 +195,7 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
193
195
|
break;
|
|
194
196
|
}
|
|
195
197
|
case 'server': {
|
|
196
|
-
otherServerDetails.server.forEach((serverDetail) => {
|
|
198
|
+
(_b = otherServerDetails.server) === null || _b === void 0 ? void 0 : _b.forEach((serverDetail) => {
|
|
197
199
|
var _a;
|
|
198
200
|
app.use('/server/' + ((_a = serverDetail.target) === null || _a === void 0 ? void 0 : _a.name), (req, res) => {
|
|
199
201
|
proxy.web(req, res, {
|
|
@@ -204,7 +206,7 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
204
206
|
break;
|
|
205
207
|
}
|
|
206
208
|
case 'functions': {
|
|
207
|
-
otherServerDetails.functions.forEach((fnDetails) => {
|
|
209
|
+
(_c = otherServerDetails.functions) === null || _c === void 0 ? void 0 : _c.forEach((fnDetails) => {
|
|
208
210
|
const fnTarget = fnDetails.target;
|
|
209
211
|
app.use(`/server/${fnTarget.name}`, (req, res) => {
|
|
210
212
|
proxy.web(req, res, {
|
|
@@ -244,12 +246,11 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
244
246
|
break;
|
|
245
247
|
}
|
|
246
248
|
case 'appSail': {
|
|
247
|
-
otherServerDetails.appSail.forEach((appSailDetails) => {
|
|
248
|
-
|
|
249
|
-
app.use('/appsail/' +
|
|
250
|
-
((_a = appSailDetails.target.appSail) === null || _a === void 0 ? void 0 : _a.name), (req, res) => {
|
|
249
|
+
(_d = otherServerDetails.appSail) === null || _d === void 0 ? void 0 : _d.forEach((appSailDetails) => {
|
|
250
|
+
app.use('/', (req, res) => {
|
|
251
251
|
proxy.web(req, res, {
|
|
252
|
-
target: `http://127.0.0.1:${appSailDetails.target.port
|
|
252
|
+
target: `http://127.0.0.1:${appSailDetails.target.port
|
|
253
|
+
.appsail}`,
|
|
253
254
|
ws: true
|
|
254
255
|
});
|
|
255
256
|
});
|
|
@@ -274,7 +275,6 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
274
275
|
expressServer.maxConnections = 100;
|
|
275
276
|
process.on('SIGINT', () => expressDestroyer.destroy(false));
|
|
276
277
|
expressServer.on('close', () => __awaiter(this, void 0, void 0, function* () {
|
|
277
|
-
(0, logger_2.info)('Shutting down server');
|
|
278
278
|
yield proxyDestroyer.destroy().catch((err) => (0, logger_2.debug)(err));
|
|
279
279
|
}));
|
|
280
280
|
expressServer.on('upgrade', (...upgradeParam) => {
|
|
@@ -48,7 +48,9 @@ exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, fun
|
|
|
48
48
|
];
|
|
49
49
|
throw err;
|
|
50
50
|
});
|
|
51
|
+
(0, logger_1.info)();
|
|
51
52
|
(0, logger_1.labeled)(`Client[${target.name}]`, `Plugin : "${runtime_store_1.default.get(`context.client.plugins.start${target.source ? '.' + target.source : ''}`)}" is used for ${details.type} serve`).MESSAGE();
|
|
53
|
+
(0, logger_1.info)();
|
|
52
54
|
return event;
|
|
53
55
|
}
|
|
54
56
|
const clientListener = yield (0, server_js_1.default)(details.httpPort, target.source, {
|
|
@@ -57,11 +59,9 @@ exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, fun
|
|
|
57
59
|
notFoundPage: target.notFoundPage
|
|
58
60
|
});
|
|
59
61
|
clientListener.addListener('start', () => {
|
|
60
|
-
var _a
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
(0, logger_1.labeled)(label, `URL : ${appUrl}/app/`).MESSAGE();
|
|
64
|
-
((_b = details.target.opts) === null || _b === void 0 ? void 0 : _b.open) && (0, open_1.default)(appUrl).catch();
|
|
62
|
+
var _a;
|
|
63
|
+
return ((_a = details.target.opts) === null || _a === void 0 ? void 0 : _a.open) &&
|
|
64
|
+
(0, open_1.default)('http://localhost:' + masterPort).catch();
|
|
65
65
|
});
|
|
66
66
|
return clientListener;
|
|
67
67
|
});
|