zcatalyst-cli 1.15.0-beta.5 → 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.
- package/docs/serve/server/index.toml +5 -0
- package/docs/serve/server/lib/appsail/index.toml +4 -0
- 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 +317 -123
- package/lib/serve/server/lib/appsail/index.js +28 -10
- 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 +11 -17
- 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
|
}
|
|
@@ -101,148 +117,326 @@ class Server {
|
|
|
101
117
|
});
|
|
102
118
|
}
|
|
103
119
|
startServer(details, masterPort) {
|
|
104
|
-
var _a, _b;
|
|
120
|
+
var _a, _b, _c;
|
|
105
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
122
|
if (details.target === undefined) {
|
|
107
|
-
return;
|
|
123
|
+
return details;
|
|
108
124
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
case 'client': {
|
|
116
|
-
currentProcess = yield (0, index_js_4.default)(details, masterPort);
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
case 'functions':
|
|
120
|
-
case 'server': {
|
|
121
|
-
if ((_a = details.target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java.value)) {
|
|
122
|
-
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;
|
|
123
131
|
}
|
|
124
|
-
|
|
125
|
-
currentProcess = yield (0,
|
|
132
|
+
case 'client': {
|
|
133
|
+
currentProcess = yield (0, index_js_4.default)(details, masterPort);
|
|
134
|
+
break;
|
|
126
135
|
}
|
|
127
|
-
|
|
128
|
-
|
|
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 });
|
|
129
151
|
}
|
|
130
|
-
break;
|
|
131
152
|
}
|
|
132
|
-
|
|
133
|
-
|
|
153
|
+
details.process = currentProcess;
|
|
154
|
+
const stdout = currentProcess.stdout;
|
|
155
|
+
if (stdout) {
|
|
156
|
+
stdout.on('data', (chunk) => {
|
|
157
|
+
process.stdout.write(chunk.toString());
|
|
158
|
+
});
|
|
134
159
|
}
|
|
160
|
+
const stderr = currentProcess.stderr;
|
|
161
|
+
if (stderr) {
|
|
162
|
+
stderr.on('data', (chunk) => {
|
|
163
|
+
process.stderr.write(chunk.toString());
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return new Promise((res) => setTimeout(() => res(details), 100));
|
|
135
167
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
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;
|
|
148
186
|
}
|
|
149
|
-
return new Promise((res) => setTimeout(res, 100));
|
|
150
187
|
});
|
|
151
188
|
}
|
|
152
189
|
start() {
|
|
153
190
|
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;
|
|
191
|
+
const logUrls = {
|
|
192
|
+
functions: {
|
|
193
|
+
bio: { targs: [], nameMaxLength: 0 },
|
|
194
|
+
aio: { targs: [], nameMaxLength: 0 },
|
|
195
|
+
browserlogic: { targs: [], nameMaxLength: 0 }
|
|
196
|
+
},
|
|
197
|
+
appsail: { targs: [], nameMaxLength: 0 },
|
|
198
|
+
client: {}
|
|
199
|
+
};
|
|
200
|
+
this._addBasicFnDetails(logUrls.functions.bio);
|
|
201
|
+
const masterTargets = ['functions', 'client', 'server'].reduce((_masterTargets, targ) => {
|
|
202
|
+
if (this.targetsMap[targ]) {
|
|
203
|
+
_masterTargets.targets[targ] = this.targetsMap[targ];
|
|
204
|
+
_masterTargets.length += this.targetsMap[targ].length;
|
|
177
205
|
}
|
|
178
|
-
return
|
|
206
|
+
return _masterTargets;
|
|
207
|
+
}, {
|
|
208
|
+
targets: {},
|
|
209
|
+
length: 0
|
|
179
210
|
});
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
211
|
+
const serveTargets = Object.values(masterTargets.targets);
|
|
212
|
+
const serveTargetsArr = serveTargets.flat();
|
|
213
|
+
const masterPort = runtime_store_1.default.get(`context.port.http.master`, -1);
|
|
214
|
+
let startPromise = Promise.resolve();
|
|
215
|
+
if (masterTargets.length > 0) {
|
|
216
|
+
if (masterPort === -1) {
|
|
217
|
+
throw new error_1.default('master port cannot be undefined', { exit: 2 });
|
|
184
218
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (
|
|
196
|
-
'send' in targetDetails.process) {
|
|
197
|
-
targetDetails.process.send('start');
|
|
219
|
+
yield Promise.all(serveTargets.map((targetDetails) => Promise.all(targetDetails.map((details) => {
|
|
220
|
+
var _a, _b;
|
|
221
|
+
const _details = details;
|
|
222
|
+
if (((_a = _details.target) === null || _a === void 0 ? void 0 : _a.type) === 'bio' &&
|
|
223
|
+
!((_b = _details.target.stack) === null || _b === void 0 ? void 0 : _b.includes('python'))) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
return this.startServer(_details, masterPort).then((t) => {
|
|
227
|
+
var _a, _b, _c, _d;
|
|
228
|
+
const serverDetails = t;
|
|
229
|
+
if (!((_a = serverDetails.target) === null || _a === void 0 ? void 0 : _a.valid)) {
|
|
198
230
|
return;
|
|
199
231
|
}
|
|
200
|
-
(
|
|
232
|
+
if (serverDetails.type === 'client') {
|
|
233
|
+
logUrls.client = serverDetails;
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
const _details = serverDetails;
|
|
237
|
+
const targType = (_b = _details.target) === null || _b === void 0 ? void 0 : _b.type;
|
|
238
|
+
logUrls.functions[targType].targs.push(_details);
|
|
239
|
+
logUrls.functions[targType].nameMaxLength =
|
|
240
|
+
((_c = _details.target) === null || _c === void 0 ? void 0 : _c.name) &&
|
|
241
|
+
_details.target.name.length >
|
|
242
|
+
logUrls.functions[targType].nameMaxLength
|
|
243
|
+
? (_d = _details.target) === null || _d === void 0 ? void 0 : _d.name.length
|
|
244
|
+
: logUrls.functions[targType].nameMaxLength;
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}))));
|
|
248
|
+
if (serveTargetsArr.length === 0) {
|
|
249
|
+
throw new error_1.default('Trying to start master server before other server', {
|
|
250
|
+
exit: 2
|
|
201
251
|
});
|
|
202
|
-
|
|
252
|
+
}
|
|
253
|
+
this.masterServer =
|
|
254
|
+
masterTargets.length > 0
|
|
255
|
+
? yield (0, master_1.default)(masterPort, masterTargets.targets)
|
|
256
|
+
: undefined;
|
|
257
|
+
startPromise = new Promise((res) => {
|
|
258
|
+
this.masterServer
|
|
259
|
+
? this.masterServer.on('listening', () => {
|
|
260
|
+
serveTargetsArr.forEach((targetDetails) => {
|
|
261
|
+
var _a;
|
|
262
|
+
if (targetDetails.process &&
|
|
263
|
+
'send' in targetDetails.process) {
|
|
264
|
+
targetDetails.process.send('start');
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
(_a = targetDetails.process) === null || _a === void 0 ? void 0 : _a.emit('start');
|
|
268
|
+
});
|
|
269
|
+
res();
|
|
270
|
+
})
|
|
271
|
+
: res();
|
|
272
|
+
});
|
|
273
|
+
this.targetsMap.server.every((t) => {
|
|
274
|
+
var _a;
|
|
275
|
+
if (t.debugPort !== -1 &&
|
|
276
|
+
((_a = t.target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python.value))) {
|
|
277
|
+
const table = (0, cli_table_1.getCustomColourTable)(ansi_colors_1.yellow);
|
|
278
|
+
table.push(['As of now, local debugging for python is not supported']);
|
|
279
|
+
(0, logger_1.info)(table.toString());
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
return false;
|
|
203
283
|
});
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
wait() {
|
|
208
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
-
const masterPort = runtime_store_1.default.get(`context.port.http.master`, -1);
|
|
210
|
-
if (!this.masterServer) {
|
|
211
|
-
(0, logger_1.debug)('Master server is not started yet.');
|
|
212
|
-
throw new error_1.default('Server cannot be put to wait state.', { exit: 2 });
|
|
213
284
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
var _a, _b;
|
|
217
|
-
const
|
|
218
|
-
if (!target ||
|
|
285
|
+
if (this.targetsMap.appSail.length > 0) {
|
|
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)) {
|
|
219
290
|
return;
|
|
220
291
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
292
|
+
logUrls.appsail.targs.push(targSail);
|
|
293
|
+
logUrls.appsail.nameMaxLength =
|
|
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
|
|
297
|
+
: logUrls.appsail.nameMaxLength;
|
|
298
|
+
})));
|
|
299
|
+
}
|
|
300
|
+
let loggedEntries = 0;
|
|
301
|
+
Object.entries(logUrls).forEach(([targType, logTarg]) => {
|
|
302
|
+
var _a;
|
|
303
|
+
switch (targType) {
|
|
304
|
+
case 'functions': {
|
|
305
|
+
Object.entries(logTarg).forEach((x) => {
|
|
306
|
+
const [_targType, _logTarg] = x;
|
|
307
|
+
if (_logTarg.targs.length === 0) {
|
|
308
|
+
return;
|
|
232
309
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
310
|
+
loggedEntries++;
|
|
311
|
+
switch (_targType) {
|
|
312
|
+
case 'bio': {
|
|
313
|
+
(0, logger_1.info)();
|
|
314
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)(' >>>>>>>>>>>>>> BasicIO <<<<<<<<<<<<<< '));
|
|
315
|
+
_logTarg.targs.forEach((t) => {
|
|
316
|
+
var _a;
|
|
317
|
+
const target = t;
|
|
318
|
+
if (!((_a = target.target) === null || _a === void 0 ? void 0 : _a.url)) {
|
|
319
|
+
throw new error_1.default('Target URL not found', {
|
|
320
|
+
exit: 2
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
bioLogUrl(target, masterPort, _logTarg.nameMaxLength);
|
|
324
|
+
});
|
|
325
|
+
(0, logger_1.info)();
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
case 'aio': {
|
|
329
|
+
(0, logger_1.info)();
|
|
330
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)(' >>>>>>>>>>>>> AdvancedIO <<<<<<<<<<<< '));
|
|
331
|
+
_logTarg.targs.forEach((t) => {
|
|
332
|
+
var _a;
|
|
333
|
+
const _target = t;
|
|
334
|
+
if (!((_a = _target.target) === null || _a === void 0 ? void 0 : _a.url)) {
|
|
335
|
+
throw new error_1.default('Target URL not found', {
|
|
336
|
+
exit: 2
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
aioLogUrl(_target, masterPort, _logTarg.nameMaxLength);
|
|
340
|
+
});
|
|
341
|
+
(0, logger_1.info)();
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
case 'browserlogic': {
|
|
345
|
+
(0, logger_1.info)();
|
|
346
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)(' >>>>>>>>>>>> BrowserLogic <<<<<<<<<<< '));
|
|
347
|
+
_logTarg.targs.forEach((t) => {
|
|
348
|
+
var _a;
|
|
349
|
+
const target = t;
|
|
350
|
+
if (!((_a = target.target) === null || _a === void 0 ? void 0 : _a.url)) {
|
|
351
|
+
throw new error_1.default('Target URL not found', {
|
|
352
|
+
exit: 2
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
bioLogUrl(target, masterPort, _logTarg.nameMaxLength);
|
|
356
|
+
});
|
|
357
|
+
(0, logger_1.info)();
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
case 'appsail': {
|
|
365
|
+
const _logTarg = logTarg;
|
|
366
|
+
if (_logTarg.targs.length === 0) {
|
|
367
|
+
return;
|
|
238
368
|
}
|
|
239
|
-
|
|
369
|
+
loggedEntries++;
|
|
370
|
+
(0, logger_1.info)();
|
|
371
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)(' >>>>>>>>>>>>>> AppSail <<<<<<<<<<<<<< '));
|
|
372
|
+
_logTarg.targs.forEach((t) => {
|
|
240
373
|
var _a;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
374
|
+
const targetSail = t.target;
|
|
375
|
+
const targName = ((_a = targetSail.appSail) === null || _a === void 0 ? void 0 : _a.name) + '';
|
|
376
|
+
(0, logger_1.labeled)(targName +
|
|
377
|
+
' '.repeat((_logTarg.nameMaxLength || targName.length) - targName.length), `http://localhost:${targetSail.port.proxy}`).MESSAGE();
|
|
378
|
+
});
|
|
379
|
+
(0, logger_1.info)();
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
case 'client': {
|
|
383
|
+
if (Object.keys(logTarg).length === 0) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
loggedEntries++;
|
|
387
|
+
(0, logger_1.info)();
|
|
388
|
+
const targApp = logTarg;
|
|
389
|
+
const appUrl = 'http://localhost:' + masterPort;
|
|
390
|
+
const label = `client[${(_a = targApp.target) === null || _a === void 0 ? void 0 : _a.name}]`;
|
|
391
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)(' >>>>>>>>>>>>> Web Client <<<<<<<<<<<<'));
|
|
392
|
+
(0, logger_1.labeled)(label, `${appUrl}/app/`).MESSAGE();
|
|
393
|
+
(0, logger_1.info)();
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
245
397
|
});
|
|
398
|
+
return loggedEntries > 0
|
|
399
|
+
? startPromise
|
|
400
|
+
: Promise.reject(new error_1.default('No Resources served', { exit: 1, errorId: 'SERVE-IDX-2' }));
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
wait() {
|
|
404
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
405
|
+
if (this.masterServer) {
|
|
406
|
+
const masterPort = runtime_store_1.default.get(`context.port.http.master`, -1);
|
|
407
|
+
Object.values(this.targetsMap).forEach((details) => {
|
|
408
|
+
details.forEach((targetdetails) => {
|
|
409
|
+
var _a, _b;
|
|
410
|
+
const target = targetdetails.target;
|
|
411
|
+
if (!target || !targetdetails.process) {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
(_a = target.watcher) === null || _a === void 0 ? void 0 : _a.on('preparing', () => __awaiter(this, void 0, void 0, function* () {
|
|
415
|
+
yield this.kill(targetdetails.process);
|
|
416
|
+
}));
|
|
417
|
+
(_b = target.watcher) === null || _b === void 0 ? void 0 : _b.on('compiled', () => __awaiter(this, void 0, void 0, function* () {
|
|
418
|
+
yield this.restart(targetdetails);
|
|
419
|
+
if (target.type === constants_1.FN_TYPE.basic) {
|
|
420
|
+
(0, logger_1.labeled)(`functions[${target.name}]`, 'ready!').MESSAGE();
|
|
421
|
+
if (!target.url) {
|
|
422
|
+
throw new error_1.default('Target URL not found while restarting server', {
|
|
423
|
+
exit: 2
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
bioLogUrl(targetdetails, masterPort);
|
|
427
|
+
}
|
|
428
|
+
else if (target.type === constants_1.FN_TYPE.advanced) {
|
|
429
|
+
(0, logger_1.labeled)(`AdvancedIO[${target.name}]`, 'ready!').MESSAGE();
|
|
430
|
+
aioLogUrl(targetdetails, masterPort);
|
|
431
|
+
}
|
|
432
|
+
setTimeout(() => {
|
|
433
|
+
var _a;
|
|
434
|
+
(_a = target.watcher) === null || _a === void 0 ? void 0 : _a.emit('next');
|
|
435
|
+
}, 1000);
|
|
436
|
+
}));
|
|
437
|
+
}, this);
|
|
438
|
+
});
|
|
439
|
+
}
|
|
246
440
|
return new Promise((res) => {
|
|
247
441
|
['SIGINT', 'SIGTERM'].forEach((sig) => process.on(sig, res));
|
|
248
442
|
});
|
|
@@ -23,6 +23,8 @@ 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"));
|
|
27
|
+
const ansi_colors_1 = require("ansi-colors");
|
|
26
28
|
function executeHook(script, name, moduleSource) {
|
|
27
29
|
if ((0, option_1.getOptionValue)('ignoreScripts', false)) {
|
|
28
30
|
(0, logger_1.debug)(`skipping ${name} hook`);
|
|
@@ -42,21 +44,29 @@ const startAppSail = (port, opts) => {
|
|
|
42
44
|
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
45
|
}).RAW();
|
|
44
46
|
};
|
|
45
|
-
exports.default = (
|
|
47
|
+
exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
48
|
var _a, _b, _c;
|
|
47
49
|
let child;
|
|
48
|
-
|
|
50
|
+
const targetSail = serverDetails.target;
|
|
51
|
+
if (!targetSail || !targetSail.appSail) {
|
|
49
52
|
throw new error_1.default('AppSail details not found');
|
|
50
53
|
}
|
|
51
54
|
if ((_a = targetSail.appSail.scripts) === null || _a === void 0 ? void 0 : _a.preserve) {
|
|
52
55
|
executeHook(targetSail.appSail.scripts.preserve, `AppSail [PRESERVE] [${(_b = targetSail.appSail) === null || _b === void 0 ? void 0 : _b.name}]`, targetSail.appSail.source);
|
|
53
56
|
}
|
|
54
|
-
|
|
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))
|
|
55
65
|
? (0, path_1.dirname)(targetSail.appSail.buildPath)
|
|
56
66
|
: targetSail.appSail.buildPath;
|
|
57
67
|
switch (true) {
|
|
58
68
|
case targetSail.appSail.stack.startsWith('node'): {
|
|
59
|
-
child = startAppSail(targetSail.port, {
|
|
69
|
+
child = startAppSail(targetSail.port.appsail, {
|
|
60
70
|
type: 'nodejs',
|
|
61
71
|
target,
|
|
62
72
|
command: targetSail.appSail.command,
|
|
@@ -66,7 +76,7 @@ exports.default = (targetSail, masterPort) => __awaiter(void 0, void 0, void 0,
|
|
|
66
76
|
break;
|
|
67
77
|
}
|
|
68
78
|
case targetSail.appSail.stack.startsWith('python'): {
|
|
69
|
-
child = startAppSail(targetSail.port, {
|
|
79
|
+
child = startAppSail(targetSail.port.appsail, {
|
|
70
80
|
type: 'python',
|
|
71
81
|
target,
|
|
72
82
|
command: targetSail.appSail.command,
|
|
@@ -96,8 +106,8 @@ exports.default = (targetSail, masterPort) => __awaiter(void 0, void 0, void 0,
|
|
|
96
106
|
throw err;
|
|
97
107
|
}
|
|
98
108
|
}
|
|
99
|
-
const jettyCommand = `java -jar ${(0, path_1.join)(jettyPath
|
|
100
|
-
child = startAppSail(targetSail.port, {
|
|
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}`;
|
|
110
|
+
child = startAppSail(targetSail.port.appsail, {
|
|
101
111
|
target,
|
|
102
112
|
type: 'war',
|
|
103
113
|
command: jettyCommand,
|
|
@@ -106,7 +116,7 @@ exports.default = (targetSail, masterPort) => __awaiter(void 0, void 0, void 0,
|
|
|
106
116
|
});
|
|
107
117
|
break;
|
|
108
118
|
}
|
|
109
|
-
child = startAppSail(targetSail.port, {
|
|
119
|
+
child = startAppSail(targetSail.port.appsail, {
|
|
110
120
|
target,
|
|
111
121
|
command: targetSail.appSail.command,
|
|
112
122
|
type: 'javase',
|
|
@@ -119,8 +129,16 @@ exports.default = (targetSail, masterPort) => __awaiter(void 0, void 0, void 0,
|
|
|
119
129
|
throw new error_1.default('Invalid AppSail stack');
|
|
120
130
|
}
|
|
121
131
|
}
|
|
122
|
-
(0,
|
|
123
|
-
|
|
132
|
+
const masterServe = yield (0, master_1.default)(targetSail.port.proxy, {
|
|
133
|
+
appSail: [serverDetails]
|
|
134
|
+
});
|
|
135
|
+
child.once('exit', () => {
|
|
136
|
+
masterServe.close((err) => {
|
|
137
|
+
if (err) {
|
|
138
|
+
(0, logger_1.debug)('Error stopping the AppSail proxy server: ', err);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
124
142
|
if ((_c = targetSail.appSail.scripts) === null || _c === void 0 ? void 0 : _c.postserve) {
|
|
125
143
|
child.once('exit', () => {
|
|
126
144
|
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();
|