zcatalyst-cli 1.12.1 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/apig-utils.js +39 -39
- package/lib/archiver.js +13 -9
- package/lib/authentication/index.js +22 -18
- package/lib/authentication/login.js +32 -32
- package/lib/bin/catalyst.js +15 -15
- package/lib/cli_table/src/cell.js +26 -26
- package/lib/cli_table/src/layout-manager.js +44 -45
- package/lib/cli_table/src/table.js +9 -9
- package/lib/cli_table/src/utils.js +35 -36
- package/lib/client-utils.js +18 -18
- package/lib/client.js +1 -1
- package/lib/command_needs/auth.js +7 -7
- package/lib/command_needs/rc.js +24 -24
- package/lib/commands/apig/disable.js +5 -5
- package/lib/commands/apig/enable.js +5 -5
- package/lib/commands/apig/status.js +9 -9
- package/lib/commands/client/delete.js +18 -18
- package/lib/commands/client/setup.js +8 -4
- package/lib/commands/deploy.js +18 -14
- package/lib/commands/ds/export.js +11 -11
- package/lib/commands/ds/import.js +12 -12
- package/lib/commands/ds/status.js +10 -10
- package/lib/commands/event/generate/index.js +21 -17
- package/lib/commands/event/generate/integ.js +7 -3
- package/lib/commands/functions/add.js +8 -4
- package/lib/commands/functions/config.js +5 -5
- package/lib/commands/functions/delete.js +20 -20
- package/lib/commands/functions/setup.js +8 -4
- package/lib/commands/functions/shell.js +7 -3
- package/lib/commands/help.js +4 -4
- package/lib/commands/iac/export.js +8 -8
- package/lib/commands/iac/import.js +23 -19
- package/lib/commands/iac/pack.js +15 -11
- package/lib/commands/iac/status.js +6 -2
- package/lib/commands/index.js +5 -1
- package/lib/commands/init.js +14 -10
- package/lib/commands/login.js +5 -1
- package/lib/commands/logout.js +5 -1
- package/lib/commands/project/list.js +14 -10
- package/lib/commands/project/reset.js +5 -5
- package/lib/commands/project/use.js +9 -9
- package/lib/commands/pull.js +18 -14
- package/lib/commands/run.js +13 -9
- package/lib/commands/serve.js +5 -1
- package/lib/commands/token/generate.js +6 -2
- package/lib/commands/token/list.js +7 -3
- package/lib/commands/token/revoke.js +6 -2
- package/lib/commands/whoami.js +3 -3
- package/lib/dc.js +2 -2
- package/lib/deploy/features/apig.js +6 -6
- package/lib/deploy/features/client.js +1 -1
- package/lib/deploy/features/functions/index.js +9 -9
- package/lib/deploy/features/index.js +5 -1
- package/lib/deploy/index.js +2 -2
- package/lib/endpoints/index.js +17 -13
- package/lib/endpoints/lib/apig.js +5 -5
- package/lib/endpoints/lib/applogic.js +4 -4
- package/lib/endpoints/lib/cache.js +3 -3
- package/lib/endpoints/lib/catalyst-details.js +1 -1
- package/lib/endpoints/lib/client.js +5 -5
- package/lib/endpoints/lib/datastore.js +2 -2
- package/lib/endpoints/lib/ds-bulk.js +5 -5
- package/lib/endpoints/lib/env.js +1 -1
- package/lib/endpoints/lib/event-bus.js +1 -1
- package/lib/endpoints/lib/filestore.js +2 -2
- package/lib/endpoints/lib/functions.js +4 -4
- package/lib/endpoints/lib/iac.js +10 -10
- package/lib/endpoints/lib/project.js +20 -5
- package/lib/endpoints/lib/queue.js +3 -3
- package/lib/endpoints/lib/sdk.js +1 -1
- package/lib/endpoints/lib/zcql.js +1 -1
- package/lib/error.js +1 -1
- package/lib/errorOut.js +2 -2
- package/lib/event_generate/cache.js +5 -5
- package/lib/event_generate/custom.js +2 -2
- package/lib/event_generate/datastore.js +5 -5
- package/lib/event_generate/filestore.js +5 -5
- package/lib/event_generate/integration/cliq.js +3 -3
- package/lib/event_generate/user.js +1 -1
- package/lib/event_generate/webapp.js +5 -5
- package/lib/execute-script.js +19 -15
- package/lib/express_middlewares/authenticator.js +32 -5
- package/lib/express_middlewares/logger.js +2 -2
- package/lib/express_middlewares/unknownReqProxy.js +1 -1
- package/lib/fn-utils/index.js +5 -1
- package/lib/fn-utils/lib/common.js +44 -44
- package/lib/fn-utils/lib/integ.js +9 -9
- package/lib/fn-utils/lib/java.js +46 -46
- package/lib/fn-utils/lib/node.js +7 -7
- package/lib/fn-watcher.js +9 -11
- package/lib/iac/status/bundle.js +5 -5
- package/lib/iac/status/deploy.js +4 -4
- package/lib/index.js +2 -2
- package/lib/init/dependencies/npm-install.js +1 -1
- package/lib/init/dependencies/package-json.js +6 -6
- package/lib/init/features/client/index.js +5 -1
- package/lib/init/features/client/initializers/angular.js +16 -12
- package/lib/init/features/client/initializers/basic.js +10 -6
- package/lib/init/features/client/initializers/lyte.js +11 -7
- package/lib/init/features/client/initializers/react.js +13 -9
- package/lib/init/features/functions/index.js +9 -9
- package/lib/init/features/functions/languages/java.js +10 -10
- package/lib/init/features/functions/languages/node.js +9 -9
- package/lib/init/features/index.js +12 -8
- package/lib/init/features/project.js +20 -20
- package/lib/init/index.js +2 -2
- package/lib/init/util/client.js +7 -3
- package/lib/init/util/functions.js +1 -1
- package/lib/init/util/project.js +4 -4
- package/lib/internal/api.js +19 -19
- package/lib/internal/command.js +20 -16
- package/lib/internal/config.js +5 -5
- package/lib/internal/credential.js +10 -10
- package/lib/internal/crypt.js +5 -5
- package/lib/internal/rc.js +5 -5
- package/lib/migration/global/1.6.2.js +3 -3
- package/lib/migration/index.js +22 -18
- package/lib/option-filter.js +34 -30
- package/lib/optional-import.js +12 -8
- package/lib/plugin-loader.js +7 -3
- package/lib/port-resolver.js +4 -4
- package/lib/progress.js +2 -2
- package/lib/prompt/index.js +5 -1
- package/lib/prompt/types/file-path.js +1 -1
- package/lib/pull/features/apig.js +9 -9
- package/lib/pull/features/client.js +7 -7
- package/lib/pull/features/functions/index.js +14 -14
- package/lib/pull/features/index.js +5 -1
- package/lib/pull/index.js +4 -4
- package/lib/repl-server.js +2 -2
- package/lib/serve/features/apig.js +1 -1
- package/lib/serve/features/index.js +8 -4
- package/lib/serve/index.js +15 -11
- package/lib/serve/server/index.js +34 -27
- package/lib/serve/server/lib/java/JavaaioServer.java +2 -1
- package/lib/serve/server/lib/java/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/lib/catalyst-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/lib/zip4j-2.5.0.jar +0 -0
- package/lib/serve/server/lib/master.js +26 -15
- package/lib/serve/server/lib/node.js +7 -3
- package/lib/serve/server/lib/web_client/index.js +3 -3
- package/lib/serve/server/lib/web_client/server.js +17 -17
- package/lib/shell/dependencies/http-functions.js +38 -33
- package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +7 -2
- package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +7 -2
- package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +7 -2
- package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +7 -2
- package/lib/shell/dependencies/invoker/integ/node.js +8 -4
- package/lib/shell/dependencies/local-function.js +44 -40
- package/lib/shell/index.js +12 -12
- package/lib/shell/prepare/index.js +2 -2
- package/lib/shell/prepare/languages/index.js +5 -1
- package/lib/shell/prepare/languages/java.js +1 -1
- package/lib/throbber/index.js +17 -17
- package/lib/throbber/utils.js +9 -9
- package/lib/track.js +7 -7
- package/lib/util_modules/config/index.js +5 -1
- package/lib/util_modules/constants/lib/auth.js +6 -6
- package/lib/util_modules/constants/lib/cliq-handlers.js +2 -2
- package/lib/util_modules/constants/lib/template.js +21 -21
- package/lib/util_modules/constants/lib/urls.js +11 -11
- package/lib/util_modules/context-help.js +15 -15
- package/lib/util_modules/fs/index.js +5 -1
- package/lib/util_modules/fs/lib/async.js +4 -4
- package/lib/util_modules/fs/utils.js +1 -1
- package/lib/util_modules/logger.js +2 -2
- package/lib/util_modules/parser/toml.js +1 -1
- package/lib/util_modules/project.js +6 -6
- package/lib/util_modules/shell.js +4 -4
- package/lib/winston.js +5 -5
- package/package.json +39 -39
- package/scripts/postInstall.js +7 -6
- package/docs/.DS_Store +0 -0
- package/lib/serve/server/lib/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/templates/.DS_Store +0 -0
- package/templates/init/.DS_Store +0 -0
- package/templates/init/client/.DS_Store +0 -0
- package/templates/init/client/react/.DS_Store +0 -0
- package/templates/init/functions/node/integ/cliq/.DS_Store +0 -0
package/lib/pull/index.js
CHANGED
|
@@ -31,17 +31,17 @@ function pull() {
|
|
|
31
31
|
errorId: 'PULL-1',
|
|
32
32
|
arg: [
|
|
33
33
|
ansi_colors_1.bold.red(feature),
|
|
34
|
-
ansi_colors_1.bold(Object.keys(features_1.default)
|
|
34
|
+
(0, ansi_colors_1.bold)(Object.keys(features_1.default)
|
|
35
35
|
.map((feat) => '* ' + feat)
|
|
36
36
|
.join('\n'))
|
|
37
37
|
]
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
const MODULE = features_1.default[feature];
|
|
41
|
-
logger_1.info(ansi_colors_1.bold('\n' + ansi_colors_1.white('===> ') + js_1.JS.capitalize(feature) + ' Setup'));
|
|
41
|
+
(0, logger_1.info)((0, ansi_colors_1.bold)('\n' + (0, ansi_colors_1.white)('===> ') + js_1.JS.capitalize(feature) + ' Setup'));
|
|
42
42
|
yield MODULE().catch((err) => {
|
|
43
|
-
logger_1.info();
|
|
44
|
-
logger_1.warning(`Skipping pull of ${feature}. Since ${err.message}.\nContact Catalyst Support with catalyst-debug.log file.`);
|
|
43
|
+
(0, logger_1.info)();
|
|
44
|
+
(0, logger_1.warning)(`Skipping pull of ${feature}. Since ${err.message}.\nContact Catalyst Support with catalyst-debug.log file.`);
|
|
45
45
|
});
|
|
46
46
|
if (runtime_store_1.default.get('payload.' + feature, false)) {
|
|
47
47
|
runtime_store_1.default.set('payload.features', runtime_store_1.default.get('payload.features', []).concat(feature));
|
package/lib/repl-server.js
CHANGED
|
@@ -9,7 +9,7 @@ const error_1 = __importDefault(require("./error"));
|
|
|
9
9
|
const stdin = process.stdin;
|
|
10
10
|
const ASCII_ETX_CODE = 0x03;
|
|
11
11
|
class Repl {
|
|
12
|
-
constructor({ prompt = '>', writer = (output) => util_1.inspect(output), useColors = true, ignoreUndefined = false } = {}) {
|
|
12
|
+
constructor({ prompt = '>', writer = (output) => (0, util_1.inspect)(output), useColors = true, ignoreUndefined = false } = {}) {
|
|
13
13
|
this.prompt = prompt;
|
|
14
14
|
this.writer = writer;
|
|
15
15
|
this.useColors = useColors;
|
|
@@ -21,7 +21,7 @@ class Repl {
|
|
|
21
21
|
this.pureEmit = stdin.emit;
|
|
22
22
|
}
|
|
23
23
|
start() {
|
|
24
|
-
this.server = repl_1.start({
|
|
24
|
+
this.server = (0, repl_1.start)({
|
|
25
25
|
prompt: this.prompt,
|
|
26
26
|
writer: this.writer,
|
|
27
27
|
useColors: this.useColors,
|
|
@@ -14,7 +14,7 @@ const config_1 = require("../../util_modules/config");
|
|
|
14
14
|
const logger_1 = require("../../util_modules/logger");
|
|
15
15
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
if (!config_1.apigConfig.enabled()) {
|
|
17
|
-
logger_1.info('Skipping API Gateway rules');
|
|
17
|
+
(0, logger_1.info)('Skipping API Gateway rules');
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
apig_utils_1.apigUtils.executeHook({ prefix: 'pre', command: 'serve' });
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -45,9 +49,9 @@ function client() {
|
|
|
45
49
|
}
|
|
46
50
|
catch (e) {
|
|
47
51
|
const err = error_1.default.getErrorInstance(e);
|
|
48
|
-
logger_1.info();
|
|
49
|
-
logger_1.warning('Skipping the serve of Client because of the error: ' + err.message);
|
|
50
|
-
logger_1.info();
|
|
52
|
+
(0, logger_1.info)();
|
|
53
|
+
(0, logger_1.warning)('Skipping the serve of Client because of the error: ' + err.message);
|
|
54
|
+
(0, logger_1.info)();
|
|
51
55
|
return;
|
|
52
56
|
}
|
|
53
57
|
const clientName = runtime_store_1.default.get('context.client.name');
|
package/lib/serve/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -48,19 +52,19 @@ const server_1 = __importDefault(require("./server"));
|
|
|
48
52
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
53
|
const serveTargets = runtime_store_1.default.get('context.targets', []);
|
|
50
54
|
const advancedServer = new server_1.default();
|
|
51
|
-
const basicFnServer = new http_functions_1.default();
|
|
55
|
+
const basicFnServer = new http_functions_1.default({ primary: false });
|
|
52
56
|
try {
|
|
53
57
|
const masterPort = yield port_resolver_1.default.getPort('master', 'http', 'master', false);
|
|
54
58
|
runtime_store_1.default.set('context.port.http.master', masterPort);
|
|
55
59
|
yield Promise.all(serveTargets.map((target) => features[target]()));
|
|
56
60
|
const rawTargets = runtime_store_1.default.get('context.functions.targets', []);
|
|
57
|
-
const watchOpt = option_1.getOptionValue('watch', false);
|
|
61
|
+
const watchOpt = (0, option_1.getOptionValue)('watch', false);
|
|
58
62
|
if (watchOpt) {
|
|
59
|
-
yield Promise.all(rawTargets.map((target) => __awaiter(void 0, void 0, void 0, function* () { return (target.valid ? fn_watcher_1.default(target) : undefined); })));
|
|
63
|
+
yield Promise.all(rawTargets.map((target) => __awaiter(void 0, void 0, void 0, function* () { return (target.valid ? (0, fn_watcher_1.default)(target) : undefined); })));
|
|
60
64
|
}
|
|
61
65
|
const funtionTargets = rawTargets.filter((target) => {
|
|
62
66
|
if (!target.valid) {
|
|
63
|
-
logger_1.warning('skipping serve of function [' +
|
|
67
|
+
(0, logger_1.warning)('skipping serve of function [' +
|
|
64
68
|
target.name +
|
|
65
69
|
'] since ' +
|
|
66
70
|
target.failure_reason);
|
|
@@ -75,7 +79,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
75
79
|
const client = runtime_store_1.default.get('context.client', false);
|
|
76
80
|
if (client && client.valid) {
|
|
77
81
|
client.opts = {
|
|
78
|
-
open: option_1.getOptionValue('open', false),
|
|
82
|
+
open: (0, option_1.getOptionValue)('open', false),
|
|
79
83
|
watch: watchOpt
|
|
80
84
|
};
|
|
81
85
|
advancedServer.add('client', client);
|
|
@@ -85,7 +89,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
91
|
if (serveTargets.includes('functions') && funtionTargets.length === 0) {
|
|
88
|
-
logger_1.labeled('functions', 'No targets are ready to be served in local').WARN();
|
|
92
|
+
(0, logger_1.labeled)('functions', 'No targets are ready to be served in local').WARN();
|
|
89
93
|
serveTargets.splice(serveTargets.indexOf('functions'), 1);
|
|
90
94
|
runtime_store_1.default.set('context.targets', serveTargets);
|
|
91
95
|
}
|
|
@@ -105,7 +109,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
105
109
|
yield advancedServer.start();
|
|
106
110
|
yield advancedServer.wait();
|
|
107
111
|
yield Promise.all([
|
|
108
|
-
fs_1.ASYNC.deleteDir(path_1.join(runtime_store_1.default.get('cwd'), '.build')).catch(),
|
|
112
|
+
fs_1.ASYNC.deleteDir((0, path_1.join)(runtime_store_1.default.get('cwd'), '.build')).catch(),
|
|
109
113
|
advancedServer ? advancedServer.stop() : undefined,
|
|
110
114
|
basicFnServer ? basicFnServer.stop() : undefined
|
|
111
115
|
]);
|
|
@@ -121,12 +125,12 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
121
125
|
command: 'serve'
|
|
122
126
|
});
|
|
123
127
|
}
|
|
124
|
-
logger_1.info();
|
|
125
|
-
logger_1.success('Shutdown complete');
|
|
128
|
+
(0, logger_1.info)();
|
|
129
|
+
(0, logger_1.success)('Shutdown complete');
|
|
126
130
|
}
|
|
127
131
|
catch (e) {
|
|
128
132
|
yield Promise.all([
|
|
129
|
-
fs_1.ASYNC.deleteDir(path_1.join(runtime_store_1.default.get('cwd'), '.build')).catch(),
|
|
133
|
+
fs_1.ASYNC.deleteDir((0, path_1.join)(runtime_store_1.default.get('cwd'), '.build')).catch(),
|
|
130
134
|
advancedServer ? advancedServer.stop() : undefined,
|
|
131
135
|
basicFnServer ? basicFnServer.stop() : undefined
|
|
132
136
|
]);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -62,7 +66,7 @@ class Server {
|
|
|
62
66
|
_addBasicFnDetails() {
|
|
63
67
|
const fnTargets = runtime_store_1.default.get('context.functions.targets', []);
|
|
64
68
|
if (fnTargets.length === 0) {
|
|
65
|
-
logger_1.debug('No basic functions to add');
|
|
69
|
+
(0, logger_1.debug)('No basic functions to add');
|
|
66
70
|
}
|
|
67
71
|
const httpPort = parseInt(runtime_store_1.default.get('context.port.http.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic]), 10);
|
|
68
72
|
const debugPort = parseInt(runtime_store_1.default.get('context.port.debug.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic], '-1'), 10);
|
|
@@ -83,45 +87,47 @@ class Server {
|
|
|
83
87
|
_spinUpJavaServer(details, masterPort) {
|
|
84
88
|
var _a, _b, _c, _d;
|
|
85
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
const javaServer = path_1.join(runtime_store_1.default.get('cwd'), '.build', '.catalyst', 'aioserver', 'JavaaioServer');
|
|
87
|
-
const targetDir = path_1.join(runtime_store_1.default.get('cwd'), '.build', (_a = details.target) === null || _a === void 0 ? void 0 : _a.name);
|
|
90
|
+
const javaServer = (0, path_1.join)(runtime_store_1.default.get('cwd'), '.build', '.catalyst', 'aioserver', 'JavaaioServer');
|
|
91
|
+
const targetDir = (0, path_1.join)(runtime_store_1.default.get('cwd'), '.build', (_a = details.target) === null || _a === void 0 ? void 0 : _a.name);
|
|
88
92
|
const label = `${details.type}[${(_b = details.target) === null || _b === void 0 ? void 0 : _b.name}]`;
|
|
89
|
-
fn_utils_1.fnUtils.java.ensureJavaInvoker(javaServer, path_1.normalize(path_1.join(__dirname, './lib', 'java', 'JavaaioServer.java')));
|
|
90
|
-
const serverFiles = yield fs_1.ASYNC.walk(path_1.dirname(javaServer));
|
|
93
|
+
fn_utils_1.fnUtils.java.ensureJavaInvoker(javaServer, (0, path_1.normalize)((0, path_1.join)(__dirname, './lib', 'java', 'JavaaioServer.java')));
|
|
94
|
+
const serverFiles = yield fs_1.ASYNC.walk((0, path_1.dirname)(javaServer));
|
|
91
95
|
yield Promise.all(serverFiles.map((file) => __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
return fs_1.ASYNC.copyFile(file, path_1.join(targetDir, path_1.relative(path_1.dirname(javaServer), file.replace('lib' + path_1.sep, ''))));
|
|
96
|
+
return fs_1.ASYNC.copyFile(file, (0, path_1.join)(targetDir, (0, path_1.relative)((0, path_1.dirname)(javaServer), file.replace('lib' + path_1.sep, ''))));
|
|
93
97
|
})));
|
|
94
98
|
const opts = [
|
|
95
99
|
'-cp',
|
|
96
|
-
path_1.join(targetDir, '*') + fn_utils_1.fnUtils.java.classPathSep + targetDir + path_1.sep,
|
|
100
|
+
(0, path_1.join)(targetDir, '*') + fn_utils_1.fnUtils.java.classPathSep + targetDir + path_1.sep,
|
|
97
101
|
'-DCATALYST_FUNCTION_TYPE=applogic'
|
|
98
102
|
];
|
|
99
103
|
if (details.debugPort !== -1) {
|
|
100
|
-
logger_1.labeled(label, 'you can attach your debugger at port : ' + details.debugPort).MESSAGE();
|
|
104
|
+
(0, logger_1.labeled)(label, 'you can attach your debugger at port : ' + details.debugPort).MESSAGE();
|
|
101
105
|
opts.push('-Xdebug');
|
|
102
106
|
opts.push('-Xrunjdwp:transport=dt_socket,address=' + details.debugPort + ',server=y,suspend=y');
|
|
103
107
|
}
|
|
104
|
-
opts.push(path_1.basename(javaServer));
|
|
108
|
+
opts.push((0, path_1.basename)(javaServer));
|
|
105
109
|
opts.push(details.httpPort + '');
|
|
106
110
|
const targetSource = (_c = details.target) === null || _c === void 0 ? void 0 : _c.source;
|
|
107
111
|
const configType = details.type === 'server' ? 'functions' : details.type;
|
|
108
|
-
const servePlugin = yield plugin_loader_1.default(configType, 'start', targetSource).catch((err) => logger_1.debug(err));
|
|
112
|
+
const servePlugin = yield (0, plugin_loader_1.default)(configType, 'start', targetSource).catch((err) => (0, logger_1.debug)(err));
|
|
109
113
|
if (typeof servePlugin === 'function') {
|
|
110
114
|
const event = servePlugin(details, masterPort);
|
|
111
|
-
logger_1.labeled(label, `Plugin : "${runtime_store_1.default.get(`context.${configType}.plugins.start${targetSource ? '.' + targetSource : ''}`)}" is used for ${details.type} serve`).MESSAGE();
|
|
115
|
+
(0, logger_1.labeled)(label, `Plugin : "${runtime_store_1.default.get(`context.${configType}.plugins.start${targetSource ? '.' + targetSource : ''}`)}" is used for ${details.type} serve`).MESSAGE();
|
|
112
116
|
return event;
|
|
113
117
|
}
|
|
114
|
-
const child = shell_1.spawn('java', opts, {
|
|
118
|
+
const child = (0, shell_1.spawn)('java', opts, {
|
|
115
119
|
cwd: targetSource,
|
|
116
120
|
stdio: 'pipe',
|
|
117
121
|
env: {
|
|
118
122
|
X_ZOHO_CATALYST_IS_LOCAL: 'true',
|
|
123
|
+
X_ZOHO_CATALYST_FUNCTION_LOADED: 'true',
|
|
124
|
+
X_ZOHO_CATALYST_CODE_LOCATION: targetDir + path_1.sep,
|
|
119
125
|
X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth,
|
|
120
126
|
X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin
|
|
121
127
|
}
|
|
122
128
|
}).RAW();
|
|
123
|
-
logger_1.labeled(label, `URL : http://localhost:${masterPort}/server/${(_d = details.target) === null || _d === void 0 ? void 0 : _d.name}/`).MESSAGE();
|
|
124
|
-
logger_1.info();
|
|
129
|
+
(0, logger_1.labeled)(label, `URL : http://localhost:${masterPort}/server/${(_d = details.target) === null || _d === void 0 ? void 0 : _d.name}/`).MESSAGE();
|
|
130
|
+
(0, logger_1.info)();
|
|
125
131
|
return child;
|
|
126
132
|
});
|
|
127
133
|
}
|
|
@@ -131,17 +137,17 @@ class Server {
|
|
|
131
137
|
const label = `${details.type}[${(_a = details.target) === null || _a === void 0 ? void 0 : _a.name}]`;
|
|
132
138
|
const _d = details.target, { ['watcher']: _ } = _d, serialisableTarget = __rest(_d, ['watcher']);
|
|
133
139
|
const opts = [
|
|
134
|
-
path_1.join(__dirname, 'lib', 'node.js'),
|
|
140
|
+
(0, path_1.join)(__dirname, 'lib', 'node.js'),
|
|
135
141
|
details.httpPort + '',
|
|
136
142
|
JSON.stringify(serialisableTarget)
|
|
137
143
|
];
|
|
138
144
|
if (details.debugPort !== -1) {
|
|
139
|
-
logger_1.labeled(label, 'you can attach your debugger at port : ' + details.debugPort).MESSAGE();
|
|
145
|
+
(0, logger_1.labeled)(label, 'you can attach your debugger at port : ' + details.debugPort).MESSAGE();
|
|
140
146
|
opts.unshift('--inspect=' + details.debugPort);
|
|
141
147
|
}
|
|
142
148
|
const targetSource = (_b = details.target) === null || _b === void 0 ? void 0 : _b.source;
|
|
143
149
|
const configType = details.type === 'server' ? 'functions' : details.type;
|
|
144
|
-
const servePlugin = yield plugin_loader_1.default(configType, 'start', targetSource).catch((err) => logger_1.debug(err));
|
|
150
|
+
const servePlugin = yield (0, plugin_loader_1.default)(configType, 'start', targetSource).catch((err) => (0, logger_1.debug)(err));
|
|
145
151
|
if (typeof servePlugin === 'function') {
|
|
146
152
|
const event = servePlugin(details, masterPort).catch((e) => {
|
|
147
153
|
var _a, _b;
|
|
@@ -152,28 +158,29 @@ class Server {
|
|
|
152
158
|
err.errorId = 'SERVE-IDX-1';
|
|
153
159
|
err.arg = [
|
|
154
160
|
configType,
|
|
155
|
-
ansi_colors_1.bold(((_b = (_a = details.target) === null || _a === void 0 ? void 0 : _a.plugins) === null || _b === void 0 ? void 0 : _b.start)[targetSource] || 'start'),
|
|
156
|
-
ansi_colors_1.bold('Error: ') + ansi_colors_1.italic.red(err.message)
|
|
161
|
+
(0, ansi_colors_1.bold)(((_b = (_a = details.target) === null || _a === void 0 ? void 0 : _a.plugins) === null || _b === void 0 ? void 0 : _b.start)[targetSource] || 'start'),
|
|
162
|
+
(0, ansi_colors_1.bold)('Error: ') + ansi_colors_1.italic.red(err.message)
|
|
157
163
|
];
|
|
158
164
|
throw err;
|
|
159
165
|
});
|
|
160
|
-
logger_1.labeled(label, `Plugin : "${runtime_store_1.default.get(`context.${configType}.plugins.start${targetSource ? '.' + targetSource : ''}`)}" is used for ${details.type} serve`).MESSAGE();
|
|
166
|
+
(0, logger_1.labeled)(label, `Plugin : "${runtime_store_1.default.get(`context.${configType}.plugins.start${targetSource ? '.' + targetSource : ''}`)}" is used for ${details.type} serve`).MESSAGE();
|
|
161
167
|
return event;
|
|
162
168
|
}
|
|
163
169
|
if (details.type === 'client') {
|
|
164
170
|
return yield (yield Promise.resolve().then(() => __importStar(require('./lib/web_client/index.js')))).default(details, masterPort);
|
|
165
171
|
}
|
|
166
|
-
const child = shell_1.spawn('node', opts, {
|
|
172
|
+
const child = (0, shell_1.spawn)('node', opts, {
|
|
167
173
|
cwd: targetSource,
|
|
168
174
|
stdio: 'pipe',
|
|
169
175
|
env: {
|
|
170
176
|
X_ZOHO_CATALYST_IS_LOCAL: 'true',
|
|
177
|
+
X_ZOHO_CATALYST_FUNCTION_LOADED: 'true',
|
|
171
178
|
X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth,
|
|
172
179
|
X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin
|
|
173
180
|
}
|
|
174
181
|
}).RAW();
|
|
175
|
-
logger_1.labeled(label, `URL : http://localhost:${masterPort}/server/${(_c = details.target) === null || _c === void 0 ? void 0 : _c.name}/`).MESSAGE();
|
|
176
|
-
logger_1.info();
|
|
182
|
+
(0, logger_1.labeled)(label, `URL : http://localhost:${masterPort}/server/${(_c = details.target) === null || _c === void 0 ? void 0 : _c.name}/`).MESSAGE();
|
|
183
|
+
(0, logger_1.info)();
|
|
177
184
|
return child;
|
|
178
185
|
});
|
|
179
186
|
}
|
|
@@ -228,7 +235,7 @@ class Server {
|
|
|
228
235
|
exit: 2
|
|
229
236
|
});
|
|
230
237
|
}
|
|
231
|
-
const server = yield master_1.default(masterPort, this.targetDetailsArr);
|
|
238
|
+
const server = yield (0, master_1.default)(masterPort, this.targetDetailsArr);
|
|
232
239
|
this.masterServer = server;
|
|
233
240
|
return new Promise((res) => {
|
|
234
241
|
server.on('listening', () => {
|
|
@@ -249,7 +256,7 @@ class Server {
|
|
|
249
256
|
wait() {
|
|
250
257
|
return __awaiter(this, void 0, void 0, function* () {
|
|
251
258
|
if (!this.masterServer) {
|
|
252
|
-
logger_1.debug('Master server is not started yet.');
|
|
259
|
+
(0, logger_1.debug)('Master server is not started yet.');
|
|
253
260
|
throw new error_1.default('Server cannot be put to wait state.', { exit: 2 });
|
|
254
261
|
}
|
|
255
262
|
this.targetDetailsArr.forEach((targetdetails) => {
|
|
@@ -263,7 +270,7 @@ class Server {
|
|
|
263
270
|
}));
|
|
264
271
|
(_b = target.watcher) === null || _b === void 0 ? void 0 : _b.on('compiled', () => __awaiter(this, void 0, void 0, function* () {
|
|
265
272
|
yield this.restart(target);
|
|
266
|
-
logger_1.labeled(`server[${target.name}]`, 'ready!').MESSAGE();
|
|
273
|
+
(0, logger_1.labeled)(`server[${target.name}]`, 'ready!').MESSAGE();
|
|
267
274
|
setTimeout(() => {
|
|
268
275
|
var _a;
|
|
269
276
|
(_a = target.watcher) === null || _a === void 0 ? void 0 : _a.emit('next');
|
|
@@ -4,6 +4,7 @@ import java.util.logging.Handler;
|
|
|
4
4
|
import java.util.logging.LogManager;
|
|
5
5
|
import java.util.logging.LogRecord;
|
|
6
6
|
import java.util.logging.Logger;
|
|
7
|
+
import java.util.logging.SimpleFormatter;
|
|
7
8
|
|
|
8
9
|
import com.cop.main.server.DefaultCoreServer;
|
|
9
10
|
|
|
@@ -21,7 +22,7 @@ public class JavaaioServer extends DefaultCoreServer {
|
|
|
21
22
|
if (record.getThrown() != null) {
|
|
22
23
|
exceptionMessage = getStackTraceAsString(record.getThrown());
|
|
23
24
|
}
|
|
24
|
-
String message =
|
|
25
|
+
String message = new SimpleFormatter().format(record) + " " + exceptionMessage;
|
|
25
26
|
if (message.length() > MESSAGE_LENGTH) {
|
|
26
27
|
message = message.substring(0, MESSAGE_LENGTH);
|
|
27
28
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const express_1 = __importDefault(require("express"));
|
|
16
|
+
const http_1 = require("http");
|
|
16
17
|
const error_1 = __importDefault(require("../../../error"));
|
|
17
18
|
const apig_matcher_1 = __importDefault(require("../../../express_middlewares/apig-matcher"));
|
|
18
19
|
const auth_checker_1 = __importDefault(require("../../../express_middlewares/auth-checker"));
|
|
@@ -86,20 +87,20 @@ const proxyResponseHandler = (systemRoutes) => (proxyRes, req, res) => {
|
|
|
86
87
|
function spinUpMaster(listenPort, otherServerDetails) {
|
|
87
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
89
|
const projectDetails = {
|
|
89
|
-
id: project_2.getProjectId(),
|
|
90
|
-
domain_prefix: project_2.getDomainPrefix(),
|
|
90
|
+
id: (0, project_2.getProjectId)(),
|
|
91
|
+
domain_prefix: (0, project_2.getDomainPrefix)(),
|
|
91
92
|
domain: constants_1.ORIGIN.app.replace('https://', ''),
|
|
92
|
-
key: project_2.getDomainKey(),
|
|
93
|
-
env_name: project_2.getEnvName()
|
|
93
|
+
key: (0, project_2.getDomainKey)(),
|
|
94
|
+
env_name: (0, project_2.getEnvName)()
|
|
94
95
|
};
|
|
95
96
|
const rules = runtime_store_1.default.get('context.apig.local.config', -1);
|
|
96
|
-
const customProxyUrl = option_1.getOptionValue('proxy');
|
|
97
|
-
const app = express_1.default();
|
|
97
|
+
const customProxyUrl = (0, option_1.getOptionValue)('proxy');
|
|
98
|
+
const app = (0, express_1.default)();
|
|
98
99
|
let systemRoutes;
|
|
99
100
|
app.use(logger_1.default);
|
|
100
101
|
app.use(cookie_parser_1.default);
|
|
102
|
+
app.use((0, project_1.default)(projectDetails));
|
|
101
103
|
app.use(authenticator_1.default);
|
|
102
|
-
app.use(project_1.default(projectDetails));
|
|
103
104
|
if (rules !== -1) {
|
|
104
105
|
for (const [sourceURL, methodByConfig] of Object.entries(rules)) {
|
|
105
106
|
const router = app.route(sourceURL);
|
|
@@ -121,16 +122,26 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
121
122
|
}
|
|
122
123
|
app.use('/', apig_matcher_1.default, auth_checker_1.default, url_rewriter_1.default);
|
|
123
124
|
}
|
|
124
|
-
const proxy = http_proxy_1.createProxyServer()
|
|
125
|
+
const proxy = (0, http_proxy_1.createProxyServer)()
|
|
125
126
|
.on('error', (err, req, res) => {
|
|
126
|
-
res.
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
if (res instanceof http_1.ServerResponse) {
|
|
128
|
+
res.writeHead(502, { 'Content-Type': 'json' });
|
|
129
|
+
}
|
|
130
|
+
res.end(JSON.stringify({ error: 'unable to proxy request' }));
|
|
129
131
|
console.log('unable to proxy request ', req.url);
|
|
130
132
|
console.error(err);
|
|
133
|
+
})
|
|
134
|
+
.on('econnreset', (err, req, res, targetUrl) => {
|
|
135
|
+
if (res instanceof http_1.ServerResponse) {
|
|
136
|
+
res.writeHead(502, { 'Content-Type': 'json' });
|
|
137
|
+
}
|
|
138
|
+
res.end(JSON.stringify({ error: 'unable to proxy request. ECONNRESET.' }));
|
|
139
|
+
console.log('Connection reset while trying to proxy ', req.url);
|
|
140
|
+
(0, logger_2.debug)('Connection reset from target URL : ', targetUrl);
|
|
141
|
+
console.error(err);
|
|
131
142
|
})
|
|
132
143
|
.on('proxyRes', proxyResponseHandler(systemRoutes))
|
|
133
|
-
.on('close', () => logger_2.debug('proxy closed'));
|
|
144
|
+
.on('close', () => (0, logger_2.debug)('proxy closed'));
|
|
134
145
|
const proxyDestroyer = new server_js_1.ConnectionDestroyer(proxy);
|
|
135
146
|
otherServerDetails.forEach((serverDetail) => {
|
|
136
147
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -212,7 +223,7 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
212
223
|
});
|
|
213
224
|
}
|
|
214
225
|
});
|
|
215
|
-
app.use('/', unknownReqProxy_1.default(proxy, customProxyUrl));
|
|
226
|
+
app.use('/', (0, unknownReqProxy_1.default)(proxy, customProxyUrl));
|
|
216
227
|
app.use(error_handler_1.default);
|
|
217
228
|
const expressServer = app.listen(listenPort).on('error', (err) => {
|
|
218
229
|
if (proxy) {
|
|
@@ -224,8 +235,8 @@ function spinUpMaster(listenPort, otherServerDetails) {
|
|
|
224
235
|
expressServer.maxConnections = 100;
|
|
225
236
|
process.on('SIGINT', () => expressDestroyer.destroy(false));
|
|
226
237
|
expressServer.on('close', () => __awaiter(this, void 0, void 0, function* () {
|
|
227
|
-
logger_2.info('Shutting down server');
|
|
228
|
-
yield proxyDestroyer.destroy().catch((err) => logger_2.debug(err));
|
|
238
|
+
(0, logger_2.info)('Shutting down server');
|
|
239
|
+
yield proxyDestroyer.destroy().catch((err) => (0, logger_2.debug)(err));
|
|
229
240
|
}));
|
|
230
241
|
expressServer.on('upgrade', (...upgradeParam) => {
|
|
231
242
|
app.emit('upgrade', ...upgradeParam);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -36,7 +40,7 @@ const util_1 = require("util");
|
|
|
36
40
|
const args = process.argv.slice(2);
|
|
37
41
|
const listenPort = parseInt(args[0], 10);
|
|
38
42
|
const fnDetails = JSON.parse(args[1]);
|
|
39
|
-
const app = express_1.default();
|
|
43
|
+
const app = (0, express_1.default)();
|
|
40
44
|
const targetName = fnDetails.name;
|
|
41
45
|
const index = fnDetails.index;
|
|
42
46
|
app.use('/', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -47,7 +51,7 @@ app.use('/', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
47
51
|
(yield Promise.resolve().then(() => __importStar(require(index)))).default(req, res);
|
|
48
52
|
}
|
|
49
53
|
catch (e) {
|
|
50
|
-
const errorString = util_1.inspect(e);
|
|
54
|
+
const errorString = (0, util_1.inspect)(e);
|
|
51
55
|
console.error('[' + targetName + '] ' + errorString);
|
|
52
56
|
res.writeHead(500);
|
|
53
57
|
res.end(errorString);
|
|
@@ -18,13 +18,13 @@ const server_js_1 = __importDefault(require("./server.js"));
|
|
|
18
18
|
exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
19
|
var _a;
|
|
20
20
|
const target = details.target;
|
|
21
|
-
const clientListner = yield server_js_1.default(details.httpPort, target.source, target.homepage, ((_a = target.opts) === null || _a === void 0 ? void 0 : _a.watch) || false);
|
|
21
|
+
const clientListner = yield (0, server_js_1.default)(details.httpPort, target.source, target.homepage, ((_a = target.opts) === null || _a === void 0 ? void 0 : _a.watch) || false);
|
|
22
22
|
clientListner.addListener('start', () => {
|
|
23
23
|
var _a, _b;
|
|
24
24
|
const appUrl = 'http://localhost:' + masterPort;
|
|
25
25
|
const label = `${details.type}[${(_a = details.target) === null || _a === void 0 ? void 0 : _a.name}]`;
|
|
26
|
-
logger_1.labeled(label, `URL : ${appUrl}/app/`).MESSAGE();
|
|
27
|
-
((_b = details.target.opts) === null || _b === void 0 ? void 0 : _b.open) && open_1.default(appUrl).catch();
|
|
26
|
+
(0, logger_1.labeled)(label, `URL : ${appUrl}/app/`).MESSAGE();
|
|
27
|
+
((_b = details.target.opts) === null || _b === void 0 ? void 0 : _b.open) && (0, open_1.default)(appUrl).catch();
|
|
28
28
|
});
|
|
29
29
|
return clientListner;
|
|
30
30
|
});
|
|
@@ -32,7 +32,7 @@ function prepareScriptFile(dir, port) {
|
|
|
32
32
|
}
|
|
33
33
|
const scriptReady = scriptFile.replace(new RegExp(index_js_1.PLACEHOLDER.client.port, 'g'), port + '');
|
|
34
34
|
yield index_js_2.ASYNC.ensureDir(dir);
|
|
35
|
-
const scriptFilePath = path_1.join(dir, 'reload-script.js');
|
|
35
|
+
const scriptFilePath = (0, path_1.join)(dir, 'reload-script.js');
|
|
36
36
|
yield index_js_2.ASYNC.writeFile(scriptFilePath, scriptReady);
|
|
37
37
|
return scriptFilePath;
|
|
38
38
|
});
|
|
@@ -56,19 +56,19 @@ function injectScript(scriptLocale, indexHtml) {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
function reloadApp(event, path, liveSockets) {
|
|
59
|
-
logger_js_1.info(ansi_colors_1.cyan(`${event} detected in ${path} of the Web-Client.`));
|
|
59
|
+
(0, logger_js_1.info)((0, ansi_colors_1.cyan)(`${event} detected in ${path} of the Web-Client.`));
|
|
60
60
|
liveSockets.forEach((socket) => socket.send('reload'));
|
|
61
61
|
}
|
|
62
62
|
function webClientServer(httpPort, source, homepage, enableWatch) {
|
|
63
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
64
|
const eventListener = new events_1.EventEmitter();
|
|
65
|
-
const catalystTempDir = path_1.join(source, '.catalyst');
|
|
65
|
+
const catalystTempDir = (0, path_1.join)(source, '.catalyst');
|
|
66
66
|
const socketServerPort = yield port_resolver_js_1.default.getFreePort(httpPort, 20, true);
|
|
67
67
|
const reloadScriptSrc = enableWatch
|
|
68
|
-
? path_1.relative(source, yield prepareScriptFile(catalystTempDir, socketServerPort))
|
|
68
|
+
? (0, path_1.relative)(source, yield prepareScriptFile(catalystTempDir, socketServerPort))
|
|
69
69
|
: undefined;
|
|
70
70
|
if (reloadScriptSrc) {
|
|
71
|
-
const clientWatcher = chokidar_1.watch(source, {
|
|
71
|
+
const clientWatcher = (0, chokidar_1.watch)(source, {
|
|
72
72
|
ignoreInitial: true,
|
|
73
73
|
ignored: ['node_modules/**/*']
|
|
74
74
|
});
|
|
@@ -101,16 +101,16 @@ function webClientServer(httpPort, source, homepage, enableWatch) {
|
|
|
101
101
|
liveSockets.push(clientSocket);
|
|
102
102
|
clientSocket.send('connected');
|
|
103
103
|
})
|
|
104
|
-
.on('error', (err) => logger_js_1.debug(err));
|
|
104
|
+
.on('error', (err) => (0, logger_js_1.debug)(err));
|
|
105
105
|
setTimeout(() => {
|
|
106
106
|
clientWatcher.on('change', (path) => {
|
|
107
|
-
reloadApp('Change(s) is', path_1.relative(source, path), liveSockets);
|
|
107
|
+
reloadApp('Change(s) is', (0, path_1.relative)(source, path), liveSockets);
|
|
108
108
|
});
|
|
109
109
|
clientWatcher.on('add', (path) => {
|
|
110
|
-
reloadApp('Addition of file(s) is', path_1.relative(source, path), liveSockets);
|
|
110
|
+
reloadApp('Addition of file(s) is', (0, path_1.relative)(source, path), liveSockets);
|
|
111
111
|
});
|
|
112
112
|
clientWatcher.on('unlink', (path) => {
|
|
113
|
-
reloadApp('Deletion of file(s) is', path_1.relative(source, path), liveSockets);
|
|
113
|
+
reloadApp('Deletion of file(s) is', (0, path_1.relative)(source, path), liveSockets);
|
|
114
114
|
});
|
|
115
115
|
}, 1000);
|
|
116
116
|
eventListener.addListener('close', () => socketServer === null || socketServer === void 0 ? void 0 : socketServer.close());
|
|
@@ -123,13 +123,13 @@ function webClientServer(httpPort, source, homepage, enableWatch) {
|
|
|
123
123
|
index_js_2.SYNC.deleteDir(catalystTempDir);
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
|
-
const app = express_1.default();
|
|
126
|
+
const app = (0, express_1.default)();
|
|
127
127
|
app.use('/app', (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
128
128
|
const requestedFile = req.url === '/' ? homepage : decodeURIComponent(req.path);
|
|
129
129
|
if (enableWatch &&
|
|
130
130
|
requestedFile === homepage &&
|
|
131
131
|
(requestedFile.includes('.html') || requestedFile.includes('.htm'))) {
|
|
132
|
-
const homepageFile = yield index_js_2.ASYNC.readFile(path_1.join(source, homepage));
|
|
132
|
+
const homepageFile = yield index_js_2.ASYNC.readFile((0, path_1.join)(source, homepage));
|
|
133
133
|
if (!homepageFile) {
|
|
134
134
|
eventListener.emit('error', new error_js_1.default('Unable to read the homepage file', {
|
|
135
135
|
exit: 1,
|
|
@@ -146,10 +146,10 @@ function webClientServer(httpPort, source, homepage, enableWatch) {
|
|
|
146
146
|
res.send(injectedHomePage || homepageFile);
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
|
-
res.sendFile(path_1.join(source, requestedFile), (err) => {
|
|
149
|
+
res.sendFile((0, path_1.join)(source, requestedFile), (err) => {
|
|
150
150
|
if (err) {
|
|
151
|
-
logger_js_1.error('Unable to serve the requested file: ' + path_1.join(source, requestedFile));
|
|
152
|
-
logger_js_1.debug(err.stack || err.message);
|
|
151
|
+
(0, logger_js_1.error)('Unable to serve the requested file: ' + (0, path_1.join)(source, requestedFile));
|
|
152
|
+
(0, logger_js_1.debug)(err.stack || err.message);
|
|
153
153
|
res.status(404);
|
|
154
154
|
res.send('Resource not found');
|
|
155
155
|
}
|
|
@@ -160,13 +160,13 @@ function webClientServer(httpPort, source, homepage, enableWatch) {
|
|
|
160
160
|
});
|
|
161
161
|
const expressDestroyer = new server_js_1.ConnectionDestroyer(server);
|
|
162
162
|
eventListener.on('error', (err) => {
|
|
163
|
-
logger_js_1.error('Error when serving the web-client: ' + err.message);
|
|
164
|
-
logger_js_1.info('Please exit the command to get more info');
|
|
163
|
+
(0, logger_js_1.error)('Error when serving the web-client: ' + err.message);
|
|
164
|
+
(0, logger_js_1.info)('Please exit the command to get more info');
|
|
165
165
|
eventListener.emit('close');
|
|
166
166
|
});
|
|
167
167
|
eventListener.on('close', () => __awaiter(this, void 0, void 0, function* () {
|
|
168
168
|
yield expressDestroyer.destroy();
|
|
169
|
-
logger_js_1.debug('client server closed');
|
|
169
|
+
(0, logger_js_1.debug)('client server closed');
|
|
170
170
|
}));
|
|
171
171
|
return new Promise((res) => server.on('listening', () => res(eventListener)));
|
|
172
172
|
});
|