zcatalyst-cli 1.18.0-beta.0 → 1.18.0-beta.10
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/command_needs/rc.toml +8 -8
- package/docs/commands/ds/import.toml +5 -5
- package/docs/commands/event/generate/job.toml +7 -0
- package/docs/commands/zest/generate/index.toml +4 -0
- package/docs/endpoints/lib/job-scheduling.toml +3 -0
- package/docs/internal/command.toml +5 -0
- package/docs/serve/server/lib/appsail/index.toml +22 -1
- package/lib/appsail-utils.js +4 -10
- package/lib/authentication/index.js +1 -0
- package/lib/authentication/login.js +8 -4
- package/lib/bin/catalyst.js +1 -1
- package/lib/code-deck.js +7 -7
- package/lib/command_needs/rc.js +8 -8
- package/lib/commands/appsail/add.js +3 -2
- package/lib/commands/client/setup.js +2 -1
- package/lib/commands/codelib/install.js +6 -2
- package/lib/commands/ds/import.js +37 -21
- package/lib/commands/event/generate/index.js +16 -3
- package/lib/commands/event/generate/integ.js +2 -1
- package/lib/commands/event/generate/job.js +82 -0
- package/lib/commands/functions/add.js +2 -1
- package/lib/commands/functions/delete.js +2 -4
- package/lib/commands/functions/setup.js +2 -1
- package/lib/commands/functions/shell.js +1 -0
- package/lib/commands/iac/export.js +5 -1
- package/lib/commands/iac/import.js +4 -1
- package/lib/commands/index.js +4 -1
- package/lib/commands/init.js +10 -7
- 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 +1 -1
- package/lib/commands/whoami.js +1 -0
- package/lib/commands/zest/generate/index.js +304 -0
- package/lib/deploy/features/appsail/index.js +42 -25
- package/lib/deploy/features/appsail/utils.js +4 -5
- package/lib/endpoints/index.js +24 -3
- package/lib/endpoints/lib/appsail.js +7 -1
- package/lib/endpoints/lib/ds-bulk.js +1 -0
- package/lib/endpoints/lib/job-scheduling.js +61 -0
- package/lib/endpoints/lib/stratus.js +63 -0
- package/lib/endpoints/lib/tunnel.js +18 -0
- package/lib/endpoints/lib/zest.js +124 -0
- package/lib/event_generate/stratus.js +52 -0
- package/lib/express_middlewares/logger.js +2 -4
- package/lib/fn-utils/lib/common.js +8 -4
- 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/iac/status/deploy.js +1 -5
- package/lib/init/dependencies/python/ensure-python.js +6 -8
- package/lib/init/features/appsail/index.js +38 -27
- package/lib/init/features/client/index.js +2 -1
- package/lib/init/features/functions/index.js +4 -0
- package/lib/init/features/functions/languages/python.js +21 -5
- package/lib/init/features/project.js +6 -15
- package/lib/internal/api.js +26 -7
- package/lib/internal/command.js +31 -7
- package/lib/migration/index.js +4 -2
- package/lib/optional-import.js +3 -2
- package/lib/prompt/index.js +5 -2
- package/lib/prompt/types/file-path.js +1 -1
- package/lib/prompt/types/search-box.js +281 -0
- package/lib/prompt/types/tree.js +3 -3
- package/lib/serve/features/appsail.js +3 -4
- package/lib/serve/index.js +1 -2
- package/lib/serve/server/index.js +52 -23
- package/lib/serve/server/lib/appsail/index.js +89 -39
- package/lib/serve/server/lib/appsail/start.js +9 -1
- 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 → catalyst-function-sdk-1.1.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} +9 -9
- package/lib/serve/server/lib/master/utils.js +142 -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/node/server/package-lock.json +12 -0
- package/lib/serve/server/lib/python/index.js +3 -3
- package/lib/shell/dependencies/http-functions.js +1 -1
- package/lib/shell/dependencies/invoker/bio/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
- package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +1 -1
- package/lib/shell/dependencies/invoker/cron/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
- package/lib/shell/dependencies/invoker/event/java/JavaeventInvoker.java +2 -1
- package/lib/shell/dependencies/invoker/event/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
- package/lib/shell/dependencies/invoker/event/node.mjs +1 -0
- package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +15 -0
- package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
- package/lib/shell/dependencies/invoker/integ/node.mjs +13 -0
- package/lib/shell/dependencies/invoker/job/java/JavajobInvoker.java +268 -0
- package/lib/shell/dependencies/invoker/job/java/lib/catalyst-function-sdk-1.1.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 +122 -13
- package/lib/shell/dependencies/tunnel-server.js +52 -23
- package/lib/shell/index.js +22 -22
- 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} +64 -10
- 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/lib/dc-type.js +8 -0
- package/lib/util_modules/constants/lib/default.js +9 -9
- package/lib/util_modules/constants/lib/event-action.js +1 -0
- package/lib/util_modules/constants/lib/event-source.js +1 -0
- package/lib/util_modules/constants/lib/fn-type.js +2 -1
- package/lib/util_modules/constants/lib/needed-scopes.js +53 -44
- package/lib/util_modules/constants/lib/placeholders.js +7 -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 +17 -2
- 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 +14 -4
- 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 +4 -2
- package/templates/event/job.json +30 -0
- package/templates/init/client/react/react_js/template/src/index.js +3 -3
- package/templates/init/client/react/react_ts/template/src/index.tsx +3 -3
- package/templates/init/client/react/react_ts/template.json +3 -3
- 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/aio/sample.js +7 -0
- package/templates/init/functions/node/bio/package.json +1 -1
- package/templates/init/functions/node/bio/sample.js +5 -0
- package/templates/init/functions/node/bio/types/basicio.d.ts +57 -0
- package/templates/init/functions/node/cron/package.json +1 -1
- package/templates/init/functions/node/cron/sample.js +5 -0
- package/templates/init/functions/node/cron/types/cron.d.ts +64 -0
- package/templates/init/functions/node/event/package.json +1 -1
- package/templates/init/functions/node/event/sample.js +11 -8
- package/templates/init/functions/node/event/types/event.d.ts +82 -0
- 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 +27 -0
- package/templates/init/functions/node/job/types/job.d.ts +62 -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 +22 -0
- package/templates/init.txt +14 -0
- package/lib/serve/server/lib/master.js +0 -326
- package/lib/shell/dependencies/invoker/bio/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/shell/dependencies/invoker/cron/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/shell/dependencies/invoker/event/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
- package/templates/init/functions/node/stream/sample.js +0 -15
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import { pathToFileURL } from 'url';
|
|
6
|
+
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
const target = JSON.parse(args[0]);
|
|
9
|
+
const userData = JSON.parse(args[1]);
|
|
10
|
+
const projectJson = JSON.parse(args[2]);
|
|
11
|
+
const authJson = JSON.parse(args[3]);
|
|
12
|
+
const buildDir = JSON.parse(args[4]);
|
|
13
|
+
|
|
14
|
+
const requestFile = path.join(buildDir, '.catalyst', 'user_req_body');
|
|
15
|
+
const responseFile = path.join(buildDir, '.catalyst', 'user_res_body');
|
|
16
|
+
const metaFile = path.join(buildDir, '.catalyst', 'user_meta.json');
|
|
17
|
+
|
|
18
|
+
const writeToFile = (resp, status) => {
|
|
19
|
+
fs.writeFileSync(responseFile, resp);
|
|
20
|
+
fs.writeFileSync(metaFile, JSON.stringify({ response: { statusCode: status } }));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
let body = {};
|
|
24
|
+
|
|
25
|
+
if (fs.existsSync(requestFile)) {
|
|
26
|
+
const content = fs.readFileSync(requestFile);
|
|
27
|
+
try {
|
|
28
|
+
body = JSON.parse(content.toString());
|
|
29
|
+
} catch (err) {
|
|
30
|
+
body = {};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* execution timeout 15 minutes
|
|
36
|
+
*/
|
|
37
|
+
const timeout = 15 * 60 * 1000;
|
|
38
|
+
const endTime = timeout + Date.now();
|
|
39
|
+
|
|
40
|
+
// exit on timeout
|
|
41
|
+
process.env.DEBUG === 'false' &&
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
writeToFile('TIMEOUT', 408);
|
|
44
|
+
process.exit(0);
|
|
45
|
+
}, timeout);
|
|
46
|
+
|
|
47
|
+
const context = {
|
|
48
|
+
catalystHeaders: Object.assign(projectJson, authJson),
|
|
49
|
+
getMaxExecutionTimeMs: () => timeout,
|
|
50
|
+
getRemainingExecutionTimeMs: () => endTime - Date.now(),
|
|
51
|
+
closeWithSuccess: () => {
|
|
52
|
+
writeToFile('SUCCESS', 200);
|
|
53
|
+
process.exit(0);
|
|
54
|
+
},
|
|
55
|
+
closeWithFailure: () => {
|
|
56
|
+
writeToFile('FAILURE', 530);
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const jobReq = {
|
|
62
|
+
getJobDetails: () => ('job_details' in userData ? userData.job_details : {}),
|
|
63
|
+
getJobMetaDetails: () => jobReq.getJobDetails()?.job_meta_details || {},
|
|
64
|
+
getJobpoolDetails: () => jobReq.getJobMetaDetails()?.jobpool_details || {},
|
|
65
|
+
getProjectDetails: () => jobReq.getJobpoolDetails()?.project_details || {},
|
|
66
|
+
getJobCapacityAttributes: () => jobReq.getJobDetails()?.capacity || {},
|
|
67
|
+
getAllJobParams: () => jobReq.getJobMetaDetails()?.params || {},
|
|
68
|
+
getJobParam: (key) => (jobReq.getAllJobParams() || {})[key]
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
import(pathToFileURL(target.index))
|
|
72
|
+
.then((module) => {
|
|
73
|
+
try {
|
|
74
|
+
if (!('default' in module)) {
|
|
75
|
+
throw new Error('Could not find any default export');
|
|
76
|
+
}
|
|
77
|
+
if (typeof module.default !== 'function') {
|
|
78
|
+
throw new Error('The default export is not a function');
|
|
79
|
+
}
|
|
80
|
+
module.default(jobReq, context);
|
|
81
|
+
} catch (e) {
|
|
82
|
+
// eslint-disable-next-line no-console
|
|
83
|
+
console.error(e);
|
|
84
|
+
writeToFile('CODE_EXCEPTION', 532);
|
|
85
|
+
process.exit(0);
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
.catch((e) => {
|
|
89
|
+
// eslint-disable-next-line no-console
|
|
90
|
+
console.error(e);
|
|
91
|
+
writeToFile('INTERNAL_SERVER_ERROR', 500);
|
|
92
|
+
process.exit(0);
|
|
93
|
+
});
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -13,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
36
|
};
|
|
14
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
38
|
const path_1 = require("path");
|
|
16
|
-
const http_1 =
|
|
39
|
+
const http_1 = __importStar(require("http"));
|
|
17
40
|
const error_1 = __importDefault(require("../../error"));
|
|
18
41
|
const fn_utils_1 = require("../../fn-utils");
|
|
19
42
|
const credential_1 = __importDefault(require("../../internal/credential"));
|
|
@@ -30,6 +53,7 @@ const shell_1 = require("../../util_modules/shell");
|
|
|
30
53
|
const http_functions_1 = require("../dependencies/http-functions");
|
|
31
54
|
const events_1 = __importDefault(require("events"));
|
|
32
55
|
const ensure_java_userconfig_1 = require("../../fn-utils/lib/ensure-java-userconfig");
|
|
56
|
+
const server_1 = require("../../util_modules/server");
|
|
33
57
|
class LocalFunction {
|
|
34
58
|
constructor(repl, target) {
|
|
35
59
|
var _a, _b, _c;
|
|
@@ -73,15 +97,44 @@ class LocalFunction {
|
|
|
73
97
|
return new error_1.default('Invalid input');
|
|
74
98
|
}
|
|
75
99
|
return (() => __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
var _a, _b, _c, _d, _e, _f;
|
|
100
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
77
101
|
const projectRoot = runtime_store_1.default.get('project.root');
|
|
78
102
|
const accessToken = yield credential_1.default.getAccessToken();
|
|
79
103
|
const slaveOptions = [];
|
|
80
104
|
const debugPort = runtime_store_1.default.get('context.port.debug.' + constants_1.FN_TYPE.basic, null);
|
|
81
105
|
yield fs_1.ASYNC.ensureFile(this.responseFile, true);
|
|
82
106
|
yield fs_1.ASYNC.ensureFile(this.metaFile, true);
|
|
107
|
+
if (this.target.type === constants_1.FN_TYPE.job) {
|
|
108
|
+
const jobData = data;
|
|
109
|
+
const jobMetaDetails = {
|
|
110
|
+
headers: Object.assign(Object.assign({}, (_b = (_a = jobData === null || jobData === void 0 ? void 0 : jobData.job_details) === null || _a === void 0 ? void 0 : _a.job_meta_details) === null || _b === void 0 ? void 0 : _b.headers), {
|
|
111
|
+
'x-zc-projectid': (0, project_1.getProjectId)(),
|
|
112
|
+
'x-zc-project-domain': (0, project_1.getDomainPrefix)() + '.' + constants_1.ORIGIN.app.replace('https://', ''),
|
|
113
|
+
'x-zc-project-key': (0, project_1.getDomainKey)(),
|
|
114
|
+
'x-zc-environment': (0, project_1.getEnvName)(),
|
|
115
|
+
'x-zc-user-cred-type': 'token',
|
|
116
|
+
'x-zc-user-cred-token': accessToken,
|
|
117
|
+
'x-zc-admin-cred-type': 'token',
|
|
118
|
+
'x-zc-admin-cred-token': accessToken,
|
|
119
|
+
'x-zc-user-type': 'admin'
|
|
120
|
+
}),
|
|
121
|
+
params: ((_d = (_c = jobData === null || jobData === void 0 ? void 0 : jobData.job_details) === null || _c === void 0 ? void 0 : _c.job_meta_details) === null || _d === void 0 ? void 0 : _d.params) || {},
|
|
122
|
+
jobpool_details: ((_f = (_e = jobData === null || jobData === void 0 ? void 0 : jobData.job_details) === null || _e === void 0 ? void 0 : _e.job_meta_details) === null || _f === void 0 ? void 0 : _f.jobpool_details) || {
|
|
123
|
+
type: 'Function',
|
|
124
|
+
project_details: {
|
|
125
|
+
project_name: (0, project_1.getProjectName)(),
|
|
126
|
+
id: (0, project_1.getProjectId)()
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
jobData.job_details = Object.assign(Object.assign({}, jobData.job_details), { job_meta_details: jobMetaDetails });
|
|
131
|
+
jobData.capacity = jobData.capacity || {
|
|
132
|
+
memory: '256'
|
|
133
|
+
};
|
|
134
|
+
data = jobData;
|
|
135
|
+
}
|
|
83
136
|
const slaveFnTarget = { index: this.target.index, name: this.target.name };
|
|
84
|
-
if ((
|
|
137
|
+
if ((_g = this.target.stack) === null || _g === void 0 ? void 0 : _g.startsWith(runtime_1.default.language.node.value)) {
|
|
85
138
|
if (debugPort !== null) {
|
|
86
139
|
slaveOptions.push('--inspect-brk=' + debugPort);
|
|
87
140
|
}
|
|
@@ -105,10 +158,10 @@ class LocalFunction {
|
|
|
105
158
|
this.slave = (0, shell_1.spawn)('node', slaveOptions, {
|
|
106
159
|
cwd: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, this.target.name),
|
|
107
160
|
stdio: 'pipe',
|
|
108
|
-
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', 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) }, this.target.env_var)
|
|
161
|
+
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_h = this.target) === null || _h === void 0 ? void 0 : _h.id, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, CATALYST_PORTAL_DOMAIN: constants_1.ORIGIN.iamPortal, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, this.target.env_var)
|
|
109
162
|
}).RAW();
|
|
110
163
|
}
|
|
111
|
-
else if ((
|
|
164
|
+
else if ((_j = this.target.stack) === null || _j === void 0 ? void 0 : _j.startsWith(runtime_1.default.language.java.value)) {
|
|
112
165
|
const javaInvokerDir = (0, path_1.parse)(this.javaInvoker).dir;
|
|
113
166
|
slaveOptions.push('-cp');
|
|
114
167
|
slaveOptions.push(javaInvokerDir +
|
|
@@ -143,11 +196,11 @@ class LocalFunction {
|
|
|
143
196
|
this.slave = (0, shell_1.spawn)(spawnCommand, slaveOptions, {
|
|
144
197
|
cwd: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, this.target.name),
|
|
145
198
|
stdio: 'pipe',
|
|
146
|
-
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', 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) }, this.target.env_var)
|
|
199
|
+
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_k = this.target) === null || _k === void 0 ? void 0 : _k.id, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, CATALYST_PORTAL_DOMAIN: constants_1.ORIGIN.iamPortal, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, this.target.env_var)
|
|
147
200
|
}).RAW();
|
|
148
201
|
}
|
|
149
|
-
else if ((
|
|
150
|
-
const stackVersion = (
|
|
202
|
+
else if ((_l = this.target.stack) === null || _l === void 0 ? void 0 : _l.startsWith(runtime_1.default.language.python.value)) {
|
|
203
|
+
const stackVersion = (_m = this.target.stack) === null || _m === void 0 ? void 0 : _m.replace('python_', '');
|
|
151
204
|
const runtimesDir = constants_1.ENVPATH.runtimes.data;
|
|
152
205
|
const httpPort = parseInt(runtime_store_1.default.get('context.port.http.' + constants_1.REMOTE_REF.functions.type[constants_1.FN_TYPE.basic]), 10);
|
|
153
206
|
const runTimePort = yield port_resolver_1.default.getFreePort(httpPort, 20, false);
|
|
@@ -158,17 +211,72 @@ class LocalFunction {
|
|
|
158
211
|
this.slave = (0, shell_1.spawn)(userConfig_1.default.get(`python${stackVersion}.bin`), slaveOptions, {
|
|
159
212
|
cwd: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, this.target.name),
|
|
160
213
|
stdio: 'pipe',
|
|
161
|
-
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_CODE_LOCATION: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, this.target.name), X_ZOHO_CATALYST_SERVER_LISTEN_PORT: runTimePort.toString(), CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, this.target.env_var)
|
|
214
|
+
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_o = this.target) === null || _o === void 0 ? void 0 : _o.id, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, CATALYST_PORTAL_DOMAIN: constants_1.ORIGIN.iamPortal, X_ZOHO_CATALYST_CODE_LOCATION: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, this.target.name), X_ZOHO_CATALYST_SERVER_LISTEN_PORT: runTimePort.toString(), X_ZOHO_DATA_URL: `http://localhost:${runTimePort}/data`, X_ZOHO_CALLBACK_URL: `http://localhost:${runTimePort}/callback`, CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone), X_ZOHO_ADMIN_CRED_TOKEN: 'dummy', X_ZOHO_PROJECT_SECRET_KEY: 'dummy', X_ZOHO_CATALYST_ORG: (0, project_1.getEnvId)(), X_ZOHO_CATALYST_ENVIRONMENT: 'Local', X_ZOHO_JOBMETA_JOBID: 'dummy', CATALYST_FUNCTION_TYPE: constants_1.REMOTE_REF.functions.type[this.target.type] }, this.target.env_var)
|
|
162
215
|
}).RAW();
|
|
163
216
|
this.slave.once('spawn', () => __awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
var _r;
|
|
164
218
|
const jsonData = data;
|
|
165
219
|
jsonData.timestamp = Date.now();
|
|
166
|
-
const reqJson = JSON.stringify(jsonData);
|
|
167
|
-
yield (0, http_functions_1.checkIfRuntimeServerRunning)(runTimePort.toString());
|
|
168
220
|
const writeResponse = (response, status) => {
|
|
169
221
|
fs_1.SYNC.writeFile(this.responseFile, response);
|
|
170
222
|
fs_1.SYNC.writeFile(this.metaFile, JSON.stringify({ response: { statusCode: status } }));
|
|
171
223
|
};
|
|
224
|
+
if (this.target.type === constants_1.FN_TYPE.job) {
|
|
225
|
+
const jobDetailsServer = new http_1.Server((serverReq, serverRes) => __awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
var _s, _t, _u;
|
|
227
|
+
if ((_s = serverReq.url) === null || _s === void 0 ? void 0 : _s.includes('data')) {
|
|
228
|
+
serverRes.writeHead(200);
|
|
229
|
+
serverRes.write(JSON.stringify({
|
|
230
|
+
data: jsonData
|
|
231
|
+
}));
|
|
232
|
+
serverRes.end();
|
|
233
|
+
}
|
|
234
|
+
else if ((_t = serverReq.url) === null || _t === void 0 ? void 0 : _t.includes('callback')) {
|
|
235
|
+
const reqData = yield new Promise((resolve) => {
|
|
236
|
+
const data = [];
|
|
237
|
+
serverReq.on('data', (chunk) => data.push(chunk));
|
|
238
|
+
serverReq.on('end', () => resolve(JSON.parse(Buffer.concat(data).toString())));
|
|
239
|
+
});
|
|
240
|
+
switch (reqData.job_status) {
|
|
241
|
+
case 200: {
|
|
242
|
+
writeResponse('SUCCESS', 200);
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
case 532: {
|
|
246
|
+
writeResponse('CODE_EXCEPTION', 532);
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
case 530: {
|
|
250
|
+
writeResponse('FAILURE', 530);
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
case 500: {
|
|
254
|
+
writeResponse('INTERNAL_SERVER_ERROR', 500);
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
serverRes.writeHead(200);
|
|
259
|
+
serverRes.end();
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
(0, logger_1.debug)(`Invalid request: (${serverReq.method}) ${serverReq.url}`);
|
|
264
|
+
writeResponse('INTERNAL_SERVER_ERROR', 500);
|
|
265
|
+
(_u = this.slave) === null || _u === void 0 ? void 0 : _u.kill('SIGINT');
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
}));
|
|
269
|
+
const jobConnDestroyer = new server_1.ConnectionDestroyer(jobDetailsServer);
|
|
270
|
+
jobDetailsServer.listen(runTimePort, () => {
|
|
271
|
+
(0, logger_1.debug)('server listening on port :' + runTimePort);
|
|
272
|
+
});
|
|
273
|
+
(_r = this.slave) === null || _r === void 0 ? void 0 : _r.once('exit', () => {
|
|
274
|
+
jobConnDestroyer.destroy();
|
|
275
|
+
});
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const reqJson = JSON.stringify(jsonData);
|
|
279
|
+
yield (0, http_functions_1.checkIfRuntimeServerRunning)(runTimePort.toString());
|
|
172
280
|
const req = http_1.default
|
|
173
281
|
.request(`http://127.0.0.1:${runTimePort}`, {
|
|
174
282
|
headers: {
|
|
@@ -239,11 +347,11 @@ class LocalFunction {
|
|
|
239
347
|
exit: 2
|
|
240
348
|
});
|
|
241
349
|
}
|
|
242
|
-
(
|
|
350
|
+
(_p = this.slave.stdout) === null || _p === void 0 ? void 0 : _p.on('data', (message) => {
|
|
243
351
|
(0, shell_1.clearLine)(process.stdout);
|
|
244
352
|
(0, logger_1.info)(message.toString());
|
|
245
353
|
});
|
|
246
|
-
(
|
|
354
|
+
(_q = this.slave.stderr) === null || _q === void 0 ? void 0 : _q.on('data', (message) => {
|
|
247
355
|
const errorStr = js_1.JS.trim(message.toString());
|
|
248
356
|
(0, shell_1.clearLine)(process.stdout);
|
|
249
357
|
(0, logger_1.info)(errorStr);
|
|
@@ -271,6 +379,7 @@ class LocalFunction {
|
|
|
271
379
|
});
|
|
272
380
|
break;
|
|
273
381
|
case constants_1.FN_TYPE.cron:
|
|
382
|
+
case constants_1.FN_TYPE.job:
|
|
274
383
|
case constants_1.FN_TYPE.event:
|
|
275
384
|
(0, logger_1.info)(`[status - ${this.target.name}] ${response || 'Unknown'}`);
|
|
276
385
|
if (!response) {
|
|
@@ -33,6 +33,7 @@ const server_1 = require("../../util_modules/server");
|
|
|
33
33
|
const ansi_colors_1 = require("ansi-colors");
|
|
34
34
|
const util_1 = require("util");
|
|
35
35
|
const project_1 = require("../../util_modules/project");
|
|
36
|
+
const endpoints_1 = require("../../endpoints");
|
|
36
37
|
class TunnelServer {
|
|
37
38
|
constructor(repel) {
|
|
38
39
|
_TunnelServer_contextMap.set(this, {});
|
|
@@ -42,6 +43,29 @@ class TunnelServer {
|
|
|
42
43
|
_TunnelServer_projectId.set(this, (0, project_1.getProjectId)());
|
|
43
44
|
__classPrivateFieldSet(this, _TunnelServer_repel, repel, "f");
|
|
44
45
|
}
|
|
46
|
+
isAsyncFn(fnType) {
|
|
47
|
+
switch (fnType) {
|
|
48
|
+
case 'cron':
|
|
49
|
+
case 'event':
|
|
50
|
+
case 'job': {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
send(req, res, status = 200, data, contentType) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const body = req.body;
|
|
59
|
+
if (this.isAsyncFn(body.function_details.function_type)) {
|
|
60
|
+
const tunnelAPI = yield (0, endpoints_1.tunnelAPI)();
|
|
61
|
+
yield tunnelAPI.tunnelCallback(status, body.default, data);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
contentType && res.contentType(contentType);
|
|
65
|
+
res.status(status);
|
|
66
|
+
res.send(data);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
45
69
|
startServer() {
|
|
46
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
71
|
const tunnelPortOpt = Number.parseInt(runtime_store_1.default.get('context.port.tunnel'));
|
|
@@ -59,23 +83,33 @@ class TunnelServer {
|
|
|
59
83
|
const app = (0, express_1.default)();
|
|
60
84
|
app.use(express_1.default.json());
|
|
61
85
|
app.all('/', (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
if (req.method !== 'POST') {
|
|
87
|
+
res.status(200);
|
|
88
|
+
res.send();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const body = req.body;
|
|
92
|
+
if (!body.function_details ||
|
|
93
|
+
!body.function_data ||
|
|
94
|
+
(body.function_details.function_type !== 'integration' && !body.default)) {
|
|
95
|
+
res.status(400);
|
|
96
|
+
res.send();
|
|
97
|
+
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write();
|
|
98
|
+
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write('Invalid tunnel request: ' + (0, util_1.inspect)(body));
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (this.isAsyncFn(body.function_details.function_type)) {
|
|
102
|
+
res.status(200);
|
|
103
|
+
res.send();
|
|
104
|
+
}
|
|
62
105
|
try {
|
|
63
|
-
const body = req.body;
|
|
64
|
-
if (!body.function_details || !body.function_data) {
|
|
65
|
-
res.status(400);
|
|
66
|
-
res.send();
|
|
67
|
-
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write();
|
|
68
|
-
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write('Invalid tunnel request: ' + (0, util_1.inspect)(body));
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
106
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write();
|
|
72
107
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write((0, ansi_colors_1.bold)(`Received tunnel request from ${body.function_details.function_name}(${body.function_details.function_id})`));
|
|
73
108
|
const target = body.function_details.function_id in __classPrivateFieldGet(this, _TunnelServer_contextMap, "f")
|
|
74
109
|
? __classPrivateFieldGet(this, _TunnelServer_contextMap, "f")[body.function_details.function_id]
|
|
75
|
-
: (() => {
|
|
110
|
+
: yield (() => __awaiter(this, void 0, void 0, function* () {
|
|
76
111
|
if (__classPrivateFieldGet(this, _TunnelServer_projectId, "f") !== body.function_details.project_id) {
|
|
77
|
-
|
|
78
|
-
res.send();
|
|
112
|
+
yield this.send(req, res, 403);
|
|
79
113
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write();
|
|
80
114
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write('Invalid access: the tunnel is trying to access the functions from a different project');
|
|
81
115
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write();
|
|
@@ -87,15 +121,14 @@ class TunnelServer {
|
|
|
87
121
|
if (namedFn) {
|
|
88
122
|
return namedFn;
|
|
89
123
|
}
|
|
90
|
-
|
|
91
|
-
res.send();
|
|
124
|
+
yield this.send(req, res, 404);
|
|
92
125
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write();
|
|
93
126
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write(`The tunneled function ${(0, ansi_colors_1.bold)(body.function_details.function_name)} is not present in local project directory`);
|
|
94
127
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write();
|
|
95
128
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write('[STATUS]');
|
|
96
129
|
__classPrivateFieldGet(this, _TunnelServer_repel, "f").write('NOT_FOUND');
|
|
97
130
|
return;
|
|
98
|
-
}).bind(this)();
|
|
131
|
+
})).bind(this)();
|
|
99
132
|
if (!target) {
|
|
100
133
|
return;
|
|
101
134
|
}
|
|
@@ -103,11 +136,10 @@ class TunnelServer {
|
|
|
103
136
|
? JSON.parse(body.function_data)
|
|
104
137
|
: body.function_data;
|
|
105
138
|
target.call(false)(fnData);
|
|
106
|
-
const errorHandler = (e) => {
|
|
107
|
-
|
|
108
|
-
res.send();
|
|
139
|
+
const errorHandler = (e) => __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
yield this.send(req, res, 500);
|
|
109
141
|
(0, logger_1.debug)('Target error: ' + e);
|
|
110
|
-
};
|
|
142
|
+
});
|
|
111
143
|
target.once('error', errorHandler);
|
|
112
144
|
const response = yield new Promise((resolve, reject) => {
|
|
113
145
|
target.once('response', (response) => {
|
|
@@ -118,13 +150,10 @@ class TunnelServer {
|
|
|
118
150
|
resolve(response);
|
|
119
151
|
});
|
|
120
152
|
});
|
|
121
|
-
|
|
122
|
-
res.status(response.status || 200);
|
|
123
|
-
res.send(response.responseBody);
|
|
153
|
+
yield this.send(req, res, response.status, response.responseBody, response.ContentType);
|
|
124
154
|
}
|
|
125
155
|
catch (e) {
|
|
126
|
-
|
|
127
|
-
res.send();
|
|
156
|
+
yield this.send(req, res, 500);
|
|
128
157
|
(0, logger_1.debug)(e);
|
|
129
158
|
}
|
|
130
159
|
}));
|
package/lib/shell/index.js
CHANGED
|
@@ -49,29 +49,29 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
49
49
|
const httpServer = new http_functions_1.default({ repl: replServer });
|
|
50
50
|
const tunnelServer = new tunnel_server_1.default(replServer);
|
|
51
51
|
const projectRoot = runtime_store_1.default.get('project.root');
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
target.compilationWarning.forEach((warn) => (0, logger_js_1.warning)(warn));
|
|
66
|
-
}
|
|
67
|
-
return target.valid;
|
|
68
|
-
});
|
|
69
|
-
if (targets.length === 0) {
|
|
70
|
-
throw new error_1.default('No functions are ready for serving', {
|
|
71
|
-
exit: 0,
|
|
72
|
-
errorId: 'SHELL-IDX-1'
|
|
73
|
-
});
|
|
52
|
+
yield (0, prepare_1.default)([constants_1.FN_TYPE.basic, constants_1.FN_TYPE.cron, constants_1.FN_TYPE.event, constants_1.FN_TYPE.integration, constants_1.FN_TYPE.job]);
|
|
53
|
+
const targets = runtime_store_1.default
|
|
54
|
+
.get('context.functions.targets', [])
|
|
55
|
+
.filter((target) => {
|
|
56
|
+
if (!target.valid) {
|
|
57
|
+
(0, logger_js_1.warning)('target [' +
|
|
58
|
+
target.name +
|
|
59
|
+
'] is not a valid one reason : ' +
|
|
60
|
+
target.failure_reason);
|
|
61
|
+
Array.isArray(target.compilationError) &&
|
|
62
|
+
target.compilationError.forEach((er) => (0, logger_js_1.error)(er));
|
|
63
|
+
Array.isArray(target.compilationWarning) &&
|
|
64
|
+
target.compilationWarning.forEach((warn) => (0, logger_js_1.warning)(warn));
|
|
74
65
|
}
|
|
66
|
+
return target.valid;
|
|
67
|
+
});
|
|
68
|
+
if (targets.length === 0) {
|
|
69
|
+
throw new error_1.default('No functions are ready for serving', {
|
|
70
|
+
exit: 0,
|
|
71
|
+
errorId: 'SHELL-IDX-1'
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
75
|
replServer.start();
|
|
76
76
|
yield tunnelServer.startServer();
|
|
77
77
|
const tunnelUrl = runtime_store_1.default.get('context.fn_shell.enable_tunnel', undefined);
|
|
@@ -47,17 +47,17 @@ function java(targets) {
|
|
|
47
47
|
return (yield Promise.resolve().then(() => __importStar(require('./java')))).default(targets);
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
function python(targets
|
|
50
|
+
function python(targets) {
|
|
51
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
return (yield Promise.resolve().then(() => __importStar(require('./python')))).default(targets
|
|
52
|
+
return (yield Promise.resolve().then(() => __importStar(require('./python')))).default(targets);
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
function prepareFunctions(targets
|
|
55
|
+
function prepareFunctions(targets) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
57
|
return Promise.all([
|
|
58
58
|
node(targets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.node.value)) && target.valid; })),
|
|
59
59
|
java(targets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java.value)) && target.valid; })),
|
|
60
|
-
python(targets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python.value)) && target.valid; })
|
|
60
|
+
python(targets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python.value)) && target.valid; }))
|
|
61
61
|
]);
|
|
62
62
|
});
|
|
63
63
|
}
|
|
@@ -18,7 +18,6 @@ const java_1 = require("../../../fn-utils/lib/java");
|
|
|
18
18
|
const runtime_store_1 = __importDefault(require("../../../runtime-store"));
|
|
19
19
|
const constants_1 = require("../../../util_modules/constants");
|
|
20
20
|
const fs_1 = require("../../../util_modules/fs");
|
|
21
|
-
const fs_2 = require("fs");
|
|
22
21
|
const throbber_1 = __importDefault(require("../../../throbber"));
|
|
23
22
|
const error_1 = __importDefault(require("../../../error"));
|
|
24
23
|
exports.default = (targets) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -56,7 +55,7 @@ exports.default = (targets) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
56
55
|
const serverFiles = yield fs_1.ASYNC.walk((0, path_1.dirname)(javaServer));
|
|
57
56
|
yield Promise.all(serverFiles.map((file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
57
|
try {
|
|
59
|
-
return fs_1.ASYNC.copyFile(file.path, (0, path_1.join)(targetBuildPath, (0, path_1.relative)((0, path_1.dirname)(javaServer), file.path.replace('lib' + path_1.sep, ''))),
|
|
58
|
+
return fs_1.ASYNC.copyFile(file.path, (0, path_1.join)(targetBuildPath, (0, path_1.relative)((0, path_1.dirname)(javaServer), file.path.replace('lib' + path_1.sep, ''))), false);
|
|
60
59
|
}
|
|
61
60
|
catch (e) {
|
|
62
61
|
const err = error_1.default.getErrorInstance(e).original;
|
|
@@ -21,7 +21,7 @@ const pip_install_1 = require("../../../init/dependencies/python/pip-install");
|
|
|
21
21
|
const error_1 = __importDefault(require("../../../error"));
|
|
22
22
|
const fs_extra_1 = require("fs-extra");
|
|
23
23
|
const throbber_1 = __importDefault(require("../../../throbber"));
|
|
24
|
-
exports.default = (targets
|
|
24
|
+
exports.default = (targets) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
25
|
if (targets === undefined || targets.length === 0) {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
@@ -42,22 +42,16 @@ exports.default = (targets, fnWatchEvent) => __awaiter(void 0, void 0, void 0, f
|
|
|
42
42
|
var _a;
|
|
43
43
|
const buildPath = (0, path_1.join)(runtime_store_1.default.get('project.root'), constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, target.name);
|
|
44
44
|
const reqFile = (0, path_1.join)(target.source, constants_1.FILENAME.functions.python_requirements);
|
|
45
|
-
|
|
46
|
-
const watch = fnWatchEvent
|
|
47
|
-
? fnWatchEvent.pth === constants_1.FILENAME.functions.python_requirements
|
|
48
|
-
: true;
|
|
49
|
-
if (requirementsExists && watch) {
|
|
50
|
-
yield (0, fs_extra_1.ensureDir)(buildPath);
|
|
51
|
-
try {
|
|
52
|
-
yield (0, pip_install_1.installRequirements)(reqFile, buildPath, (_a = target.stack) === null || _a === void 0 ? void 0 : _a.replace('python_', ''));
|
|
53
|
-
}
|
|
54
|
-
catch (err) {
|
|
55
|
-
const error = error_1.default.getErrorInstance(err);
|
|
56
|
-
target.valid = false;
|
|
57
|
-
target.failure_reason = error.message;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
45
|
+
yield (0, fs_extra_1.ensureDir)(buildPath);
|
|
60
46
|
yield fs_1.ASYNC.emptyDir(buildPath);
|
|
47
|
+
try {
|
|
48
|
+
yield (0, pip_install_1.installRequirements)(reqFile, buildPath, (_a = target.stack) === null || _a === void 0 ? void 0 : _a.replace('python_', ''));
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
const error = error_1.default.getErrorInstance(err);
|
|
52
|
+
target.valid = false;
|
|
53
|
+
target.failure_reason = error.message;
|
|
54
|
+
}
|
|
61
55
|
yield fs_1.ASYNC.copyDir(target.source, buildPath);
|
|
62
56
|
throbber.remove('function_serve_' + target.name);
|
|
63
57
|
return target;
|
package/lib/throbber/index.js
CHANGED
|
@@ -42,7 +42,9 @@ class Throbber {
|
|
|
42
42
|
options.text = name;
|
|
43
43
|
}
|
|
44
44
|
const spinnerProperties = Object.assign(Object.assign({}, this.options), options);
|
|
45
|
-
this.
|
|
45
|
+
if (this.spin) {
|
|
46
|
+
this.spinners[name] = spinnerProperties;
|
|
47
|
+
}
|
|
46
48
|
this.updateSpinnerState();
|
|
47
49
|
return spinnerProperties;
|
|
48
50
|
}
|
|
@@ -94,6 +96,9 @@ class Throbber {
|
|
|
94
96
|
return !!Object.values(this.spinners).find(({ status }) => status === 'spinning');
|
|
95
97
|
}
|
|
96
98
|
setSpinnerProperties(name, options, status = 'spinning') {
|
|
99
|
+
if (!this.spin) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
97
102
|
if (!this.spinners[name]) {
|
|
98
103
|
throw new error_js_1.default(`No spinner initialized with name ${name}`);
|
|
99
104
|
}
|
package/lib/userConfig.js
CHANGED
|
@@ -9,7 +9,13 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
const error_1 = __importDefault(require("./error"));
|
|
10
10
|
class UserConfig {
|
|
11
11
|
constructor() {
|
|
12
|
-
this.validKeys = [
|
|
12
|
+
this.validKeys = [
|
|
13
|
+
'python3_9.bin',
|
|
14
|
+
'java8.bin',
|
|
15
|
+
'java11.bin',
|
|
16
|
+
'java17.bin',
|
|
17
|
+
'javac.disable_warnings'
|
|
18
|
+
];
|
|
13
19
|
this.configFilePath = path_1.default.join(constants_1.ENVPATH.userConfig.config, '.zcconfig');
|
|
14
20
|
this.config = fs_1.SYNC.readJSONFile(this.configFilePath, { checkpath: true }) || {};
|
|
15
21
|
}
|
|
@@ -30,5 +30,5 @@ const clientConfig = __importStar(require("./lib/client"));
|
|
|
30
30
|
exports.clientConfig = clientConfig;
|
|
31
31
|
const functionsConfig = __importStar(require("./lib/functions"));
|
|
32
32
|
exports.functionsConfig = functionsConfig;
|
|
33
|
-
const appSailConfig = __importStar(require("./lib/
|
|
33
|
+
const appSailConfig = __importStar(require("./lib/appsail"));
|
|
34
34
|
exports.appSailConfig = appSailConfig;
|