zcatalyst-cli 1.17.6 → 1.18.0-beta.1
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/commands/event/generate/job.toml +7 -0
- package/docs/commands/functions/shell.toml +4 -0
- package/docs/endpoints/lib/job-scheduling.toml +3 -0
- package/docs/internal/command.toml +5 -0
- package/docs/shell/dependencies/tunnel-server.toml +4 -0
- package/docs/shell/index.toml +7 -0
- package/lib/appsail-utils.js +3 -3
- package/lib/authentication/index.js +1 -0
- package/lib/command_needs/rc.js +1 -1
- package/lib/commands/appsail/add.js +1 -0
- package/lib/commands/client/setup.js +1 -0
- package/lib/commands/event/generate/job.js +82 -0
- package/lib/commands/functions/add.js +1 -0
- package/lib/commands/functions/delete.js +2 -4
- package/lib/commands/functions/setup.js +1 -0
- package/lib/commands/functions/shell.js +98 -1
- package/lib/commands/index.js +1 -0
- package/lib/commands/init.js +2 -6
- package/lib/commands/login.js +1 -0
- package/lib/commands/logout.js +1 -0
- package/lib/commands/pull.js +1 -0
- package/lib/commands/serve.js +2 -8
- package/lib/commands/whoami.js +1 -0
- package/lib/deploy/features/appsail/index.js +19 -17
- package/lib/deploy/features/appsail/utils.js +4 -5
- package/lib/endpoints/index.js +15 -1
- package/lib/endpoints/lib/appsail.js +7 -1
- package/lib/endpoints/lib/job-scheduling.js +61 -0
- package/lib/endpoints/lib/sdk.js +2 -2
- package/lib/endpoints/lib/tunnel.js +66 -0
- package/lib/express_middlewares/logger.js +2 -4
- package/lib/fn-utils/lib/common.js +2 -3
- package/lib/fn-utils/lib/java.js +1 -1
- package/lib/fn-utils/lib/python.js +2 -2
- package/lib/fn-watcher.js +1 -1
- package/lib/init/dependencies/python/ensure-python.js +6 -8
- package/lib/init/features/appsail/index.js +14 -10
- package/lib/init/features/functions/index.js +4 -0
- package/lib/init/features/functions/languages/python.js +21 -5
- package/lib/internal/api.js +17 -1
- package/lib/internal/command.js +28 -5
- package/lib/port-resolver.js +1 -1
- package/lib/repl-server.js +9 -0
- package/lib/serve/features/appsail.js +2 -3
- package/lib/serve/index.js +1 -2
- package/lib/serve/server/index.js +8 -9
- package/lib/serve/server/lib/appsail/index.js +24 -34
- package/lib/serve/server/lib/java/aio_server/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/aio_server/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/aio_server/lib/catalyst-java-runtime-1.0.0.jar +0 -0
- package/lib/serve/server/lib/java/index.js +2 -2
- package/lib/serve/server/lib/master/appsail.js +53 -0
- package/lib/serve/server/lib/master/functions.js +34 -0
- package/lib/serve/server/lib/master/index.js +155 -0
- package/lib/{express_middlewares/unknownReqProxy.js → serve/server/lib/master/unknown-req-proxy.js} +4 -7
- package/lib/serve/server/lib/master/utils.js +130 -0
- package/lib/serve/server/lib/master/web-client.js +39 -0
- package/lib/serve/server/lib/node/index.js +3 -3
- package/lib/serve/server/lib/python/index.js +6 -3
- package/lib/shell/dependencies/http-functions.js +21 -8
- package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +28 -32
- package/lib/shell/dependencies/invoker/bio/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/shell/dependencies/invoker/bio/node.mjs +2 -2
- package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +62 -13
- package/lib/shell/dependencies/invoker/cron/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/shell/dependencies/invoker/cron/node.mjs +28 -24
- package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +41 -6
- package/lib/shell/dependencies/invoker/event/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/shell/dependencies/invoker/event/node.mjs +23 -9
- package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +3 -3
- package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/shell/dependencies/invoker/integ/node.mjs +6 -6
- package/lib/shell/dependencies/invoker/job/java/JavajobInvoker.java +254 -0
- package/lib/shell/dependencies/invoker/job/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/shell/dependencies/invoker/job/java/lib/org.json.jar +0 -0
- package/lib/shell/dependencies/invoker/job/node.mjs +93 -0
- package/lib/shell/dependencies/local-function.js +399 -200
- package/lib/shell/dependencies/tunnel-server.js +173 -0
- package/lib/shell/index.js +62 -2
- package/lib/shell/prepare/languages/index.js +4 -4
- package/lib/shell/prepare/languages/java.js +1 -2
- package/lib/shell/prepare/languages/python.js +10 -16
- package/lib/throbber/index.js +6 -1
- package/lib/userConfig.js +7 -1
- package/lib/util_modules/config/index.js +1 -1
- package/lib/util_modules/config/lib/{appSail.js → appsail.js} +61 -9
- package/lib/util_modules/config/lib/client.js +6 -8
- package/lib/util_modules/config/lib/functions.js +6 -8
- package/lib/util_modules/constants/index.js +3 -1
- package/lib/util_modules/constants/lib/default.js +1 -1
- package/lib/util_modules/constants/lib/fn-type.js +2 -1
- package/lib/util_modules/constants/lib/needed-scopes.js +61 -0
- package/lib/util_modules/constants/lib/placeholders.js +6 -0
- package/lib/util_modules/constants/lib/ref-mapping.js +2 -1
- package/lib/util_modules/constants/lib/remote-mapping.js +2 -1
- package/lib/util_modules/constants/lib/scopes.js +9 -1
- package/lib/util_modules/constants/lib/template.js +9 -4
- package/lib/util_modules/constants/lib/urls.js +16 -0
- package/lib/util_modules/fs/lib/async.js +7 -2
- package/lib/util_modules/fs/lib/sync.js +12 -1
- package/lib/util_modules/server.js +2 -4
- package/lib/winston.js +17 -11
- package/package.json +1 -1
- package/templates/event/job.json +30 -0
- package/templates/init/functions/java/job/.classpath +6 -0
- package/templates/init/functions/java/job/.project +17 -0
- package/templates/init/functions/java/job/catalyst-config.json +11 -0
- package/templates/init/functions/java/job/sample.java +34 -0
- package/templates/init/functions/node/aio/package.json +1 -1
- package/templates/init/functions/node/bio/package.json +1 -1
- package/templates/init/functions/node/cron/package.json +1 -1
- package/templates/init/functions/node/event/package.json +1 -1
- package/templates/init/functions/node/integ/cliq/package.json +1 -1
- package/templates/init/functions/node/integ/convokraft/package.json +1 -1
- package/templates/init/functions/node/{stream → job}/catalyst-config.json +3 -2
- package/templates/init/functions/node/{stream → job}/package.json +1 -1
- package/templates/init/functions/node/job/sample.js +28 -0
- package/templates/init/functions/node/job/types/job.d.ts +66 -0
- package/templates/init/functions/python/job/catalyst-config.json +11 -0
- package/templates/init/functions/python/job/requirements.txt +1 -0
- package/templates/init/functions/python/job/sample.py +23 -0
- package/templates/init.txt +13 -0
- package/lib/serve/server/lib/master.js +0 -317
- package/templates/init/functions/node/stream/sample.js +0 -15
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const ansi_colors_1 = require("ansi-colors");
|
|
16
|
+
const error_1 = __importDefault(require("../../error"));
|
|
17
|
+
const api_1 = __importDefault(require("../../internal/api"));
|
|
18
|
+
const logger_1 = require("../../util_modules/logger");
|
|
19
|
+
class JobScheduling {
|
|
20
|
+
constructor(projectId, opts) {
|
|
21
|
+
this.opts = opts;
|
|
22
|
+
this.projectId = projectId;
|
|
23
|
+
}
|
|
24
|
+
getJobpoolDetails(id) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const res = yield new api_1.default(this.opts).get(`/baas/v1/project/${this.projectId}/job_scheduling/jobpool${id ? '/' + id : ''}`, {
|
|
27
|
+
resolveOnError: true
|
|
28
|
+
});
|
|
29
|
+
if (res.status === 200) {
|
|
30
|
+
if (res.body && res.body.data) {
|
|
31
|
+
return res.body.data;
|
|
32
|
+
}
|
|
33
|
+
(0, logger_1.debug)(`get jobpool details response from server for (${id}): ${res.body}`);
|
|
34
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
35
|
+
exit: 2
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (res.status === 404 && id) {
|
|
39
|
+
const allJobpools = yield this.getJobpoolDetails();
|
|
40
|
+
throw new error_1.default(`The provided jobpool identifier (${id}) is invalid`, {
|
|
41
|
+
exit: 1,
|
|
42
|
+
context: res.body,
|
|
43
|
+
status: res.status,
|
|
44
|
+
errorId: 'JOB-SCHEDULING-1',
|
|
45
|
+
arg: [
|
|
46
|
+
(0, ansi_colors_1.bold)(id),
|
|
47
|
+
(0, ansi_colors_1.bold)(allJobpools
|
|
48
|
+
.map((pool) => `${(0, ansi_colors_1.green)('*')} ${pool.name} [${pool.id}]`)
|
|
49
|
+
.join('\n'))
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
throw new error_1.default('Error when feting details of the jobpool: ' + id, {
|
|
54
|
+
exit: 2,
|
|
55
|
+
context: res.body,
|
|
56
|
+
status: res.status
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.default = JobScheduling;
|
package/lib/endpoints/lib/sdk.js
CHANGED
|
@@ -29,10 +29,10 @@ class SDK {
|
|
|
29
29
|
if (service === constants_1.INTEG.services.cliq) {
|
|
30
30
|
return `/downloads/sdk/java/${constants_1.INTEG.service_map[service]}/${constants_1.INTEG.java_dependencies[service]}_latest.zip`;
|
|
31
31
|
}
|
|
32
|
-
return '/downloads/sdk/java/
|
|
32
|
+
return '/downloads/sdk/java/catalyst_java_sdk_beta.zip';
|
|
33
33
|
}
|
|
34
34
|
default: {
|
|
35
|
-
return '/downloads/sdk/java/
|
|
35
|
+
return '/downloads/sdk/java/catalyst_java_sdk_beta.zip';
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const error_1 = __importDefault(require("../../error"));
|
|
16
|
+
const api_1 = __importDefault(require("../../internal/api"));
|
|
17
|
+
const logger_1 = require("../../util_modules/logger");
|
|
18
|
+
class TunnelAPI {
|
|
19
|
+
constructor(projectId, opts) {
|
|
20
|
+
this.projectId = projectId;
|
|
21
|
+
this.opts = opts;
|
|
22
|
+
}
|
|
23
|
+
getTunnel() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const res = yield new api_1.default(this.opts).get(`/baas/v1/project/${this.projectId}/tunneling`);
|
|
26
|
+
if (res.body && res.body.data) {
|
|
27
|
+
return res.body.data;
|
|
28
|
+
}
|
|
29
|
+
(0, logger_1.debug)('get tunnel response from server : ' + res.body);
|
|
30
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
31
|
+
exit: 2
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
enableTunnel(tunnelUrl) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const qs = {};
|
|
38
|
+
if (tunnelUrl) {
|
|
39
|
+
qs.tunnel_url = tunnelUrl;
|
|
40
|
+
}
|
|
41
|
+
const res = yield new api_1.default(this.opts).patch(`/baas/v1/project/${this.projectId}/tunneling`, {
|
|
42
|
+
qs
|
|
43
|
+
});
|
|
44
|
+
if (res.body && res.body.data) {
|
|
45
|
+
return res.body.data;
|
|
46
|
+
}
|
|
47
|
+
(0, logger_1.debug)('enable tunnel response from server : ' + res.body);
|
|
48
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
49
|
+
exit: 2
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
disableTunnel() {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const res = yield new api_1.default(this.opts).patch(`/baas/v1/project/${this.projectId}/tunneling`);
|
|
56
|
+
if (res.body && res.body.data) {
|
|
57
|
+
return res.body.data;
|
|
58
|
+
}
|
|
59
|
+
(0, logger_1.debug)('disable tunnel response from server : ' + res.body);
|
|
60
|
+
throw new error_1.default('Server Error: Unexpected Response from server.', {
|
|
61
|
+
exit: 2
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.default = TunnelAPI;
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ansi_colors_1 = require("ansi-colors");
|
|
4
4
|
exports.default = (appSailDetails) => (req, _RES, next) => {
|
|
5
|
-
var _a
|
|
5
|
+
var _a;
|
|
6
6
|
console.log('[' +
|
|
7
7
|
new Date().getTime() +
|
|
8
8
|
'] ' +
|
|
9
|
-
(appSailDetails
|
|
10
|
-
? (0, ansi_colors_1.cyan)(` Appsail[${(_b = (_a = appSailDetails === null || appSailDetails === void 0 ? void 0 : appSailDetails.target) === null || _a === void 0 ? void 0 : _a.appSail) === null || _b === void 0 ? void 0 : _b.name}] `)
|
|
11
|
-
: '') +
|
|
9
|
+
(appSailDetails ? (0, ansi_colors_1.cyan)(` Appsail[${(_a = appSailDetails === null || appSailDetails === void 0 ? void 0 : appSailDetails.target) === null || _a === void 0 ? void 0 : _a.name}] `) : '') +
|
|
12
10
|
' "' +
|
|
13
11
|
(0, ansi_colors_1.cyan)(req.method) +
|
|
14
12
|
'" ' +
|
|
@@ -32,7 +32,6 @@ const js_1 = require("../../util_modules/js");
|
|
|
32
32
|
const logger_1 = require("../../util_modules/logger");
|
|
33
33
|
const option_1 = require("../../util_modules/option");
|
|
34
34
|
const project_1 = require("../../util_modules/project");
|
|
35
|
-
const fs_2 = require("fs");
|
|
36
35
|
const os_1 = require("os");
|
|
37
36
|
const pip_install_1 = require("../../init/dependencies/python/pip-install");
|
|
38
37
|
function validate() {
|
|
@@ -318,7 +317,7 @@ function pack(target) {
|
|
|
318
317
|
const tmpDir = (0, path_1.join)((0, os_1.tmpdir)(), '.catalyst', 'python', target.name + Date.now().toString());
|
|
319
318
|
yield fs_1.ASYNC.ensureDir(tmpDir);
|
|
320
319
|
yield fs_1.ASYNC.emptyDir(tmpDir);
|
|
321
|
-
yield (0, pip_install_1.installRequirements)(reqFile, tmpDir, target.stack.replace('python_', ''),
|
|
320
|
+
yield (0, pip_install_1.installRequirements)(reqFile, tmpDir, target.stack.replace('python_', ''), (0, os_1.platform)() === 'linux');
|
|
322
321
|
const files = yield fs_1.ASYNC.walk(tmpDir);
|
|
323
322
|
files.forEach((file) => {
|
|
324
323
|
zip.add(file.path.replace(tmpDir + path_1.sep, ''), file.stats.isSymbolicLink()
|
|
@@ -578,7 +577,7 @@ function copyModDirPerm(src, dest, perm, { replace = true } = {}) {
|
|
|
578
577
|
return res();
|
|
579
578
|
}
|
|
580
579
|
const destFile = (0, path_1.join)(dest, (0, path_1.basename)(content.path));
|
|
581
|
-
yield fs_1.ASYNC.copyFile(content.path, destFile, replace
|
|
580
|
+
yield fs_1.ASYNC.copyFile(content.path, destFile, replace).catch((err) => {
|
|
582
581
|
if (!replace && err.code === 'EEXIST') {
|
|
583
582
|
return;
|
|
584
583
|
}
|
package/lib/fn-utils/lib/java.js
CHANGED
|
@@ -287,7 +287,7 @@ function compileJavaFiles(file, spawnCommand, targetVersion, targetSource, outpu
|
|
|
287
287
|
'*' + module.exports.classPathSep + '.',
|
|
288
288
|
'-g',
|
|
289
289
|
'-Xprefer:source',
|
|
290
|
-
'-Xlint',
|
|
290
|
+
userConfig_1.default.get('javac.disable_warnings') === 'true' ? '-Xlint:none' : '-Xlint',
|
|
291
291
|
file.replace(targetSource, outputFolder)
|
|
292
292
|
], {
|
|
293
293
|
cwd: outputFolder,
|
|
@@ -37,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.removeRequirements = exports.validate = void 0;
|
|
39
39
|
const ansi_colors_1 = require("ansi-colors");
|
|
40
|
-
const os_1 = require("os");
|
|
40
|
+
const os_1 = __importStar(require("os"));
|
|
41
41
|
const path_1 = __importStar(require("path"));
|
|
42
42
|
const error_1 = __importDefault(require("../../error"));
|
|
43
43
|
const ensure_python_1 = require("../../init/dependencies/python/ensure-python");
|
|
@@ -111,7 +111,7 @@ function removeRequirements(reqFile, target) {
|
|
|
111
111
|
const tmpDir = (0, path_1.join)((0, os_1.tmpdir)(), '.catalyst', 'python', Date.now().toString());
|
|
112
112
|
yield fs_1.ASYNC.ensureDir(tmpDir);
|
|
113
113
|
yield fs_1.ASYNC.emptyDir(tmpDir);
|
|
114
|
-
yield (0, pip_install_1.installRequirements)(reqFile, tmpDir, (_a = target.stack) === null || _a === void 0 ? void 0 : _a.replace('python_', ''),
|
|
114
|
+
yield (0, pip_install_1.installRequirements)(reqFile, tmpDir, (_a = target.stack) === null || _a === void 0 ? void 0 : _a.replace('python_', ''), os_1.default.platform() === 'linux');
|
|
115
115
|
const files = yield fs_1.ASYNC.walk(tmpDir, { depth: 1, includeDirPaths: true });
|
|
116
116
|
yield Promise.all(files.map((file) => __awaiter(this, void 0, void 0, function* () {
|
|
117
117
|
yield fs_1.ASYNC.deleteFile((0, path_1.join)(target.source, path_1.default.basename(file.path)));
|
package/lib/fn-watcher.js
CHANGED
|
@@ -35,7 +35,7 @@ exports.default = (target) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
35
35
|
target.valid = true;
|
|
36
36
|
target.compilationError = undefined;
|
|
37
37
|
target.compilationWarning = undefined;
|
|
38
|
-
yield (0, languages_1.prepareFunctions)([target]
|
|
38
|
+
yield (0, languages_1.prepareFunctions)([target]);
|
|
39
39
|
if (currentLatestEvent.at === latestEvent.at) {
|
|
40
40
|
latestEvent = undefined;
|
|
41
41
|
}
|
|
@@ -99,14 +99,12 @@ function validateCommand(version, spawnCommand, skipHelp) {
|
|
|
99
99
|
const data = Buffer.concat(dataBuf).toString();
|
|
100
100
|
return resolve(data);
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}));
|
|
109
|
-
}
|
|
102
|
+
reject(new error_1.default(`unable to locate python${version} with the given binary path`, {
|
|
103
|
+
exit: 1,
|
|
104
|
+
errorId: 'PY-1',
|
|
105
|
+
arg: [version, (0, ansi_colors_1.bold)(spawnCommand)],
|
|
106
|
+
skipHelp
|
|
107
|
+
}));
|
|
110
108
|
});
|
|
111
109
|
child.on('error', (err) => {
|
|
112
110
|
reject(new error_1.default(`unable to locate python${version} with the given binary path`, {
|
|
@@ -36,7 +36,7 @@ function getAppSailZip() {
|
|
|
36
36
|
api: _gitHubAPI.appsailNodejs.bind(_gitHubAPI),
|
|
37
37
|
command: 'node index.js',
|
|
38
38
|
source: (0, project_1.resolveProjectPath)('appsail-nodejs'),
|
|
39
|
-
build:
|
|
39
|
+
build: './',
|
|
40
40
|
stack: {
|
|
41
41
|
runtime: 'node16',
|
|
42
42
|
lang: 'node'
|
|
@@ -54,7 +54,7 @@ function getAppSailZip() {
|
|
|
54
54
|
api: _gitHubAPI.appsailJava.bind(_gitHubAPI),
|
|
55
55
|
command: 'java -jar demo-0.0.1-SNAPSHOT.jar',
|
|
56
56
|
source: (0, project_1.resolveProjectPath)('appsail-java'),
|
|
57
|
-
build: (0,
|
|
57
|
+
build: (0, path_1.join)('target', 'demo-0.0.1-SNAPSHOT.jar'),
|
|
58
58
|
stack: {
|
|
59
59
|
runtime: 'java8',
|
|
60
60
|
lang: 'java'
|
|
@@ -73,7 +73,7 @@ function getAppSailZip() {
|
|
|
73
73
|
api: _gitHubAPI.appsailPython.bind(_gitHubAPI),
|
|
74
74
|
command: 'python3 app.py',
|
|
75
75
|
source: (0, project_1.resolveProjectPath)('appsail-python'),
|
|
76
|
-
build:
|
|
76
|
+
build: './',
|
|
77
77
|
stack: {
|
|
78
78
|
runtime: 'python_3_9',
|
|
79
79
|
lang: 'python'
|
|
@@ -148,15 +148,14 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
148
148
|
const appSail = yield prompt_1.default.ask(prompt_1.default.question('buildPath', 'Please provide the build path of your AppSail service: ', {
|
|
149
149
|
type: 'file-path',
|
|
150
150
|
validate: (pth) => __awaiter(void 0, void 0, void 0, function* () {
|
|
151
|
-
const buildPath = (0, path_1.resolve)(
|
|
151
|
+
const buildPath = (0, path_1.resolve)(runtime_store_1.default.get('cwd'), pth.value);
|
|
152
152
|
if ((yield fs_1.ASYNC.dirExists(buildPath)) || (yield fs_1.ASYNC.fileExists(buildPath))) {
|
|
153
153
|
return true;
|
|
154
154
|
}
|
|
155
155
|
return 'Path does not exists';
|
|
156
156
|
}),
|
|
157
|
-
when: !_appSailConfig.build
|
|
158
|
-
|
|
159
|
-
}), prompt_1.default.question('name', 'Please provide the name for your AppSail service: ', {
|
|
157
|
+
when: !_appSailConfig.build
|
|
158
|
+
}), prompt_1.default.question('name', 'Please provide the name for your AppSail: ', {
|
|
160
159
|
type: 'input',
|
|
161
160
|
default: 'AppSail',
|
|
162
161
|
validate: (name) => {
|
|
@@ -165,7 +164,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
165
164
|
: true;
|
|
166
165
|
const match = name.match(constants_1.REGEX.functions.package.name)
|
|
167
166
|
? true
|
|
168
|
-
: `Invalid
|
|
167
|
+
: `Invalid AppSail name. It should be in the following format: ${constants_1.REGEX.functions.package.name}`;
|
|
169
168
|
return typeof exists === 'string'
|
|
170
169
|
? exists
|
|
171
170
|
: typeof match === 'string'
|
|
@@ -182,7 +181,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
182
181
|
const appConfig = {
|
|
183
182
|
command: _appSailConfig.command ||
|
|
184
183
|
'echo Please specify the start-up command in the app-config.json file under the key command',
|
|
185
|
-
build_path: _appSailConfig.build || appSail.buildPath,
|
|
184
|
+
build_path: _appSailConfig.build || './' + (0, path_1.relative)(_appSailConfig.source, appSail.buildPath),
|
|
186
185
|
stack: appSailStack.runtime,
|
|
187
186
|
env_variables: {},
|
|
188
187
|
memory: _appSailConfig.memory || 256,
|
|
@@ -209,5 +208,10 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
209
208
|
}
|
|
210
209
|
}
|
|
211
210
|
runtime_store_1.default.set('payload.appsail.targets', [payload]);
|
|
212
|
-
|
|
211
|
+
if (isAppConfig) {
|
|
212
|
+
(0, logger_1.message)((0, ansi_colors_1.bold)(`app-config.json`) + ` file already exist in ${(0, ansi_colors_1.underline)(_appSailConfig.source)}`);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
yield fs_1.ASYNC.writeJSONFile(appConfigPth, appConfig);
|
|
216
|
+
}
|
|
213
217
|
});
|
|
@@ -72,6 +72,10 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
72
72
|
prompt_1.default.choice('Browser Logic', {
|
|
73
73
|
value: constants_1.FN_TYPE.browserLogic,
|
|
74
74
|
short: 'browser logic'
|
|
75
|
+
}),
|
|
76
|
+
prompt_1.default.choice('Job', {
|
|
77
|
+
value: constants_1.FN_TYPE.job,
|
|
78
|
+
short: 'job'
|
|
75
79
|
})
|
|
76
80
|
];
|
|
77
81
|
const integServicesRes = yield integServicesPromise;
|
|
@@ -79,15 +79,31 @@ exports.default = (stack) => () => __awaiter(void 0, void 0, void 0, function* (
|
|
|
79
79
|
const pyRespJson = fnType === constants_1.FN_TYPE.integration
|
|
80
80
|
? yield (0, pip_install_1.pypiRes)('zcatalyst-cliq')
|
|
81
81
|
: yield (0, pip_install_1.pypiRes)('zcatalyst-sdk');
|
|
82
|
+
const latestVersion = (() => {
|
|
83
|
+
const releases = pyRespJson.releases;
|
|
84
|
+
const latest = Object.entries(releases).reduce((latest, [version, details]) => {
|
|
85
|
+
var _a;
|
|
86
|
+
const whlDetails = details.at(0);
|
|
87
|
+
if (!(whlDetails === null || whlDetails === void 0 ? void 0 : whlDetails.upload_time)) {
|
|
88
|
+
return latest;
|
|
89
|
+
}
|
|
90
|
+
const uploadTime = new Date(whlDetails.upload_time).getTime();
|
|
91
|
+
if (!((_a = latest.details) === null || _a === void 0 ? void 0 : _a.upload_time) ||
|
|
92
|
+
uploadTime > new Date(latest.details.upload_time).getTime()) {
|
|
93
|
+
latest = {
|
|
94
|
+
version,
|
|
95
|
+
details: whlDetails
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return latest;
|
|
99
|
+
}, {});
|
|
100
|
+
return latest.version;
|
|
101
|
+
})();
|
|
82
102
|
yield fs_1.ASYNC.findAndReplace(targetPath)([
|
|
83
103
|
constants_1.PLACEHOLDER.functions.python_package.name,
|
|
84
104
|
constants_1.PLACEHOLDER.functions.python_package.main,
|
|
85
105
|
constants_1.PLACEHOLDER.functions.python_package.sdkVersion
|
|
86
|
-
], [
|
|
87
|
-
functionAns.name,
|
|
88
|
-
functionAns.main,
|
|
89
|
-
pyRespJson.info.version
|
|
90
|
-
]);
|
|
106
|
+
], [functionAns.name, functionAns.main, latestVersion]);
|
|
91
107
|
yield fs_1.ASYNC.rename((0, path_1.join)(targetPath, constants_1.FILENAME.functions.python_main), () => functionAns.main);
|
|
92
108
|
const integ_config = runtime_store_1.default.get('context.functions.integration.config', '');
|
|
93
109
|
yield fn_utils_1.fnUtils.common.findAndReplaceConfigProps(targetPath, {
|
package/lib/internal/api.js
CHANGED
|
@@ -54,8 +54,12 @@ class API {
|
|
|
54
54
|
json: true,
|
|
55
55
|
headers
|
|
56
56
|
};
|
|
57
|
+
const projectSecretKey = process.env.CATALYST_PROJECT_SECRET_KEY;
|
|
57
58
|
if (!isExternal) {
|
|
58
59
|
this.requestOpts.headers = Object.assign(Object.assign({}, this.requestOpts.headers), { Accept: 'application/vnd.catalyst.v2+json', 'X-CATALYST-Environment': env });
|
|
60
|
+
if (projectSecretKey) {
|
|
61
|
+
this.requestOpts.headers['X-ZC-PROJECT-SECRET-KEY'] = projectSecretKey;
|
|
62
|
+
}
|
|
59
63
|
if (envId) {
|
|
60
64
|
this.requestOpts.headers['CATALYST-ORG'] = envId;
|
|
61
65
|
}
|
|
@@ -92,11 +96,18 @@ class API {
|
|
|
92
96
|
'\n');
|
|
93
97
|
}
|
|
94
98
|
_logResp(resp) {
|
|
99
|
+
const ignoreHeaders = [
|
|
100
|
+
'content-security-policy-report-only',
|
|
101
|
+
'set-cookie',
|
|
102
|
+
'content-security-policy'
|
|
103
|
+
];
|
|
104
|
+
const logHeaders = Object.assign({}, resp.headers);
|
|
105
|
+
ignoreHeaders.forEach((header) => delete logHeaders[header]);
|
|
95
106
|
(0, logger_1.debug)('<<<< HTTP RESPONSE : ' +
|
|
96
107
|
resp.statusCode +
|
|
97
108
|
'\n' +
|
|
98
109
|
'Response Headers: ' +
|
|
99
|
-
JSON.stringify(
|
|
110
|
+
JSON.stringify(logHeaders) +
|
|
100
111
|
'\n');
|
|
101
112
|
if (!js_1.JS.isUndefined(resp.timings)) {
|
|
102
113
|
(0, logger_1.debug)('TOTAL TIME TAKEN : ' + Number(resp.timings.end.toFixed(3)) + ' ms\n');
|
|
@@ -279,5 +290,10 @@ class API {
|
|
|
279
290
|
return this.fire('HEAD', path);
|
|
280
291
|
});
|
|
281
292
|
}
|
|
293
|
+
patch(path, options) {
|
|
294
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
295
|
+
return this.fire('PATCH', path, options);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
282
298
|
}
|
|
283
299
|
exports.default = API;
|
package/lib/internal/command.js
CHANGED
|
@@ -46,9 +46,12 @@ const js_1 = require("../util_modules/js");
|
|
|
46
46
|
const logger_1 = require("../util_modules/logger");
|
|
47
47
|
const option_1 = require("../util_modules/option");
|
|
48
48
|
const project_1 = require("../util_modules/project");
|
|
49
|
+
const env_1 = require("../util_modules/env");
|
|
49
50
|
class Command {
|
|
50
51
|
constructor(cmd) {
|
|
52
|
+
this.subCommand = [];
|
|
51
53
|
this.isSubCommand = false;
|
|
54
|
+
this.isCICommand = true;
|
|
52
55
|
this.command = cmd;
|
|
53
56
|
this.cmdName = cmd.split(' ')[0];
|
|
54
57
|
this.aliasName = null;
|
|
@@ -88,9 +91,15 @@ class Command {
|
|
|
88
91
|
this.helpText = text;
|
|
89
92
|
return this;
|
|
90
93
|
}
|
|
91
|
-
addSubCommand(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
addSubCommand(...commands) {
|
|
95
|
+
commands.forEach((command) => {
|
|
96
|
+
this.subCommand.push(command);
|
|
97
|
+
command.isSubCommand = true;
|
|
98
|
+
});
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
ci(value) {
|
|
102
|
+
this.isCICommand = value;
|
|
94
103
|
return this;
|
|
95
104
|
}
|
|
96
105
|
helpConfig(config) {
|
|
@@ -110,9 +119,14 @@ class Command {
|
|
|
110
119
|
return this;
|
|
111
120
|
}
|
|
112
121
|
register(client, cli) {
|
|
122
|
+
var _a;
|
|
113
123
|
this.client = client;
|
|
114
124
|
const program = cli || client.cli;
|
|
115
|
-
|
|
125
|
+
let opts = {};
|
|
126
|
+
if (env_1.isCI && !this.isCICommand) {
|
|
127
|
+
opts = { hidden: true };
|
|
128
|
+
}
|
|
129
|
+
const cmd = program.command(this.command, opts);
|
|
116
130
|
if (this.aliasName !== null) {
|
|
117
131
|
cmd.alias(this.aliasName);
|
|
118
132
|
}
|
|
@@ -140,6 +154,13 @@ class Command {
|
|
|
140
154
|
const runner = this.runner();
|
|
141
155
|
const start = Date.now();
|
|
142
156
|
const argCount = cmd._args.length;
|
|
157
|
+
if (!this.isCICommand && env_1.isCI) {
|
|
158
|
+
return (0, errorOut_1.default)(new error_1.default('Environment not supported', {
|
|
159
|
+
exit: 1,
|
|
160
|
+
errorId: 'CMD-2',
|
|
161
|
+
arg: [(0, ansi_colors_1.bold)(cmd.name()), (0, ansi_colors_1.bold)('CI=true catalyst help')]
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
143
164
|
if (programArgs.slice(-1)[0].args.length > argCount &&
|
|
144
165
|
!this.allowUnknownOptions) {
|
|
145
166
|
return (0, errorOut_1.default)(new error_1.default('Too many arguments', {
|
|
@@ -163,7 +184,9 @@ class Command {
|
|
|
163
184
|
}
|
|
164
185
|
}));
|
|
165
186
|
if (this.subCommand) {
|
|
166
|
-
this.subCommand.
|
|
187
|
+
(_a = this.subCommand) === null || _a === void 0 ? void 0 : _a.forEach((subCmd) => {
|
|
188
|
+
subCmd.register(client, cmd);
|
|
189
|
+
});
|
|
167
190
|
}
|
|
168
191
|
return cmd;
|
|
169
192
|
}
|
package/lib/port-resolver.js
CHANGED
|
@@ -33,7 +33,7 @@ const featureRef = {
|
|
|
33
33
|
browserlogic: 'browser_logic'
|
|
34
34
|
};
|
|
35
35
|
class PortResolver {
|
|
36
|
-
static getFreePort(startPort, searchSpan, dupCheck) {
|
|
36
|
+
static getFreePort(startPort, searchSpan = 0, dupCheck = false) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
if (searchSpan < 0) {
|
|
39
39
|
throw new Error('unable to find port. searchSpan has reached the bottom line');
|
package/lib/repl-server.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const repl_1 = require("repl");
|
|
7
7
|
const util_1 = require("util");
|
|
8
8
|
const error_1 = __importDefault(require("./error"));
|
|
9
|
+
const logger_1 = require("./util_modules/logger");
|
|
9
10
|
const stdin = process.stdin;
|
|
10
11
|
const ASCII_ETX_CODE = 0x03;
|
|
11
12
|
class Repl {
|
|
@@ -108,5 +109,13 @@ class Repl {
|
|
|
108
109
|
});
|
|
109
110
|
});
|
|
110
111
|
}
|
|
112
|
+
write(str = '') {
|
|
113
|
+
var _a, _b, _c;
|
|
114
|
+
if (((_a = this.server) === null || _a === void 0 ? void 0 : _a.getCursorPos().cols) !== this.prompt.length) {
|
|
115
|
+
(_b = this.server) === null || _b === void 0 ? void 0 : _b.prompt();
|
|
116
|
+
}
|
|
117
|
+
(0, logger_1.info)(str);
|
|
118
|
+
(_c = this.server) === null || _c === void 0 ? void 0 : _c.prompt();
|
|
119
|
+
}
|
|
111
120
|
}
|
|
112
121
|
exports.default = Repl;
|
|
@@ -27,19 +27,18 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
27
27
|
}
|
|
28
28
|
const validated = (0, appsail_utils_1.validateAppSail)(optionTargets);
|
|
29
29
|
const filledTargets = yield Promise.all(validated.map((targ) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
-
var _a, _b;
|
|
31
30
|
if (!targ.validity.valid) {
|
|
32
31
|
return targ;
|
|
33
32
|
}
|
|
34
33
|
const proxyPort = yield port_resolver_1.default.getPort('appsail', 'http', {
|
|
35
|
-
name:
|
|
34
|
+
name: targ.name + '_proxy',
|
|
36
35
|
searchSpan: 10,
|
|
37
36
|
server: 'master'
|
|
38
37
|
}).catch((err) => {
|
|
39
38
|
throw new error_1.default('No free ports between 3000 and 3010. AppSail needs the ports within this range to function properly', { original: err });
|
|
40
39
|
});
|
|
41
40
|
const appsailPort = yield port_resolver_1.default.getPort('appsail', 'http', {
|
|
42
|
-
name:
|
|
41
|
+
name: targ.name + '_proxy',
|
|
43
42
|
server: 'service'
|
|
44
43
|
});
|
|
45
44
|
return Object.assign(Object.assign({}, targ), { port: { appsail: appsailPort, proxy: proxyPort } });
|
package/lib/serve/index.js
CHANGED
|
@@ -108,10 +108,9 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
108
108
|
if (serveTargets.includes('appsail')) {
|
|
109
109
|
const appSail = runtime_store_1.default.get('context.appsail.targets', []);
|
|
110
110
|
const validAppSail = appSail.filter((sail) => {
|
|
111
|
-
var _a;
|
|
112
111
|
if (!sail.validity.valid) {
|
|
113
112
|
(0, logger_1.warning)('skipping serve of AppSail service [' +
|
|
114
|
-
|
|
113
|
+
sail.name +
|
|
115
114
|
'] since ' +
|
|
116
115
|
sail.validity.reason);
|
|
117
116
|
return false;
|
|
@@ -117,7 +117,7 @@ class Server {
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
startServer(details, masterPort) {
|
|
120
|
-
var _a, _b
|
|
120
|
+
var _a, _b;
|
|
121
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
122
|
if (details.target === undefined) {
|
|
123
123
|
return details;
|
|
@@ -170,7 +170,7 @@ class Server {
|
|
|
170
170
|
if (details.type === 'appsail') {
|
|
171
171
|
const target = details.target;
|
|
172
172
|
target.validity.valid = false;
|
|
173
|
-
(0, logger_1.labeled)(`AppSail[${
|
|
173
|
+
(0, logger_1.labeled)(`AppSail[${target.name}]`, error).ERROR();
|
|
174
174
|
}
|
|
175
175
|
else if (details.type === 'client') {
|
|
176
176
|
const target = details.target;
|
|
@@ -252,7 +252,7 @@ class Server {
|
|
|
252
252
|
}
|
|
253
253
|
this.masterServer =
|
|
254
254
|
masterTargets.length > 0
|
|
255
|
-
? yield (0, master_1.default)(masterPort, masterTargets.targets)
|
|
255
|
+
? yield (0, master_1.default)(masterPort, { otherServerDetails: masterTargets.targets })
|
|
256
256
|
: undefined;
|
|
257
257
|
startPromise = new Promise((res) => {
|
|
258
258
|
this.masterServer
|
|
@@ -284,16 +284,16 @@ class Server {
|
|
|
284
284
|
}
|
|
285
285
|
if (this.targetsMap.appSail.length > 0) {
|
|
286
286
|
yield Promise.all(this.targetsMap.appSail.map((targSail) => this.startServer(targSail, -1).then((details) => {
|
|
287
|
-
var _a, _b, _c, _d
|
|
287
|
+
var _a, _b, _c, _d;
|
|
288
288
|
const serverDetails = details;
|
|
289
289
|
if (!((_a = serverDetails.target) === null || _a === void 0 ? void 0 : _a.validity.valid)) {
|
|
290
290
|
return;
|
|
291
291
|
}
|
|
292
292
|
logUrls.appsail.targs.push(targSail);
|
|
293
293
|
logUrls.appsail.nameMaxLength =
|
|
294
|
-
((
|
|
295
|
-
((
|
|
296
|
-
? (
|
|
294
|
+
((_b = targSail.target) === null || _b === void 0 ? void 0 : _b.name) &&
|
|
295
|
+
((_c = targSail.target) === null || _c === void 0 ? void 0 : _c.name.length) > logUrls.appsail.nameMaxLength
|
|
296
|
+
? (_d = targSail.target) === null || _d === void 0 ? void 0 : _d.name.length
|
|
297
297
|
: logUrls.appsail.nameMaxLength;
|
|
298
298
|
})));
|
|
299
299
|
}
|
|
@@ -370,9 +370,8 @@ class Server {
|
|
|
370
370
|
(0, logger_1.info)();
|
|
371
371
|
(0, logger_1.info)((0, ansi_colors_1.bold)(' >>>>>>>>>>>>>> AppSail <<<<<<<<<<<<<< '));
|
|
372
372
|
_logTarg.targs.forEach((t) => {
|
|
373
|
-
var _a;
|
|
374
373
|
const targetSail = t.target;
|
|
375
|
-
const targName =
|
|
374
|
+
const targName = targetSail.name + '';
|
|
376
375
|
(0, logger_1.labeled)(targName +
|
|
377
376
|
' '.repeat((_logTarg.nameMaxLength || targName.length) - targName.length), `http://localhost:${targetSail.port.proxy}`).MESSAGE();
|
|
378
377
|
});
|