zcatalyst-cli 1.17.2 → 1.17.4
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/README.md +0 -1
- package/lib/fn-utils/lib/common.js +0 -9
- package/lib/fn-watcher.js +0 -8
- package/lib/serve/index.js +0 -11
- package/lib/serve/server/lib/node/index.js +11 -4
- package/lib/shell/dependencies/http-functions.js +3 -2
- package/lib/shell/dependencies/local-function.js +5 -4
- package/lib/shell/index.js +0 -8
- package/lib/shell/prepare/languages/java.js +1 -5
- package/lib/shell/prepare/languages/node.js +2 -2
- package/lib/shell/prepare/languages/python.js +1 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
|
|
14
14
|

|
|
15
15
|

|
|
16
|
-

|
|
17
16
|

|
|
18
17
|
<br>
|
|
19
18
|
|
|
@@ -224,15 +224,6 @@ function refineTargets(rawTargets, mapRemoteFn = true) {
|
|
|
224
224
|
yield fs_1.ASYNC.writeFile(catalystJsonPth, catalystJsonString, 'utf8');
|
|
225
225
|
}
|
|
226
226
|
const fnMemory = js_1.JS.get(catalystJson, 'deployment.memory', js_1.JS.get(remoteFnMap[fnName], 'configuration.memory'));
|
|
227
|
-
if (fnMemory && !runtime_1.default.memory.includes(fnMemory)) {
|
|
228
|
-
return {
|
|
229
|
-
name: fnName,
|
|
230
|
-
source: fnPath,
|
|
231
|
-
valid: false,
|
|
232
|
-
type: fnType,
|
|
233
|
-
failure_reason: `The memory configuration ${fnMemory} is not supported. The supported values are ${runtime_1.default.memory.join(', ')}.`
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
227
|
const fnTarget = {
|
|
237
228
|
name: fnName,
|
|
238
229
|
stack: userStack,
|
package/lib/fn-watcher.js
CHANGED
|
@@ -8,16 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
const chokidar_1 = require("chokidar");
|
|
16
|
-
const path_1 = require("path");
|
|
17
|
-
const runtime_store_1 = __importDefault(require("./runtime-store"));
|
|
18
13
|
const languages_1 = require("./shell/prepare/languages");
|
|
19
|
-
const constants_1 = require("./util_modules/constants");
|
|
20
|
-
const fs_1 = require("./util_modules/fs");
|
|
21
14
|
const logger_1 = require("./util_modules/logger");
|
|
22
15
|
const char_1 = require("./util_modules/char");
|
|
23
16
|
const ansi_colors_1 = require("ansi-colors");
|
|
@@ -42,7 +35,6 @@ exports.default = (target) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
42
35
|
target.valid = true;
|
|
43
36
|
target.compilationError = undefined;
|
|
44
37
|
target.compilationWarning = undefined;
|
|
45
|
-
yield fs_1.ASYNC.chmod((0, path_1.join)(runtime_store_1.default.get('project.root'), constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, target.name), '755', { recursive: true });
|
|
46
38
|
yield (0, languages_1.prepareFunctions)([target], latestEvent);
|
|
47
39
|
if (currentLatestEvent.at === latestEvent.at) {
|
|
48
40
|
latestEvent = undefined;
|
package/lib/serve/index.js
CHANGED
|
@@ -60,9 +60,6 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
60
60
|
if (yield fs_1.ASYNC.isPathExists(buildFolder)) {
|
|
61
61
|
try {
|
|
62
62
|
(0, logger_1.debug)('Build folder already exists, starting cleanup');
|
|
63
|
-
yield fs_1.ASYNC.chmod((0, path_1.join)(buildFolder, constants_1.FOLDERNAME.functions), '755', {
|
|
64
|
-
recursive: true
|
|
65
|
-
});
|
|
66
63
|
yield fs_1.ASYNC.deleteDir(buildFolder);
|
|
67
64
|
}
|
|
68
65
|
catch (err) {
|
|
@@ -164,11 +161,6 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
164
161
|
}
|
|
165
162
|
yield advancedServer.start();
|
|
166
163
|
yield advancedServer.wait();
|
|
167
|
-
isFunctionsServed &&
|
|
168
|
-
(yield fs_1.ASYNC.chmod((0, path_1.join)(buildFolder, constants_1.FOLDERNAME.functions), '755', {
|
|
169
|
-
checkPath: false,
|
|
170
|
-
recursive: true
|
|
171
|
-
}).catch((err) => (0, logger_1.debug)('Error modifying the permissions: ', err)));
|
|
172
164
|
(0, logger_1.info)('Shutting down server');
|
|
173
165
|
yield Promise.all([
|
|
174
166
|
fs_1.ASYNC.deleteDir(buildFolder).catch((err) => (0, logger_1.debug)('Error while deleting directory ', err)),
|
|
@@ -192,9 +184,6 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
192
184
|
}
|
|
193
185
|
catch (e) {
|
|
194
186
|
(0, logger_1.debug)('Error serving the resources: ', e);
|
|
195
|
-
yield fs_1.ASYNC.chmod((0, path_1.join)(buildFolder, constants_1.FOLDERNAME.functions), '755', {
|
|
196
|
-
recursive: true
|
|
197
|
-
}).catch((err) => (0, logger_1.debug)('Error modifying the permissions: ', err));
|
|
198
187
|
yield Promise.all([
|
|
199
188
|
fs_1.ASYNC.deleteDir(buildFolder).catch(),
|
|
200
189
|
advancedServer ? advancedServer.stop() : undefined,
|
|
@@ -34,9 +34,9 @@ const logger_1 = require("../../../../util_modules/logger");
|
|
|
34
34
|
const project_1 = require("../../../../util_modules/project");
|
|
35
35
|
const shell_1 = require("../../../../util_modules/shell");
|
|
36
36
|
exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
var _a, _b;
|
|
37
|
+
var _a, _b, _c, _d, _e, _f;
|
|
38
38
|
const label = `${details.type}[${(_a = details.target) === null || _a === void 0 ? void 0 : _a.name}]`;
|
|
39
|
-
const
|
|
39
|
+
const _g = details.target, { ['watcher']: _ } = _g, serialisableTarget = __rest(_g, ['watcher']);
|
|
40
40
|
const projectRoot = runtime_store_1.default.get('project.root');
|
|
41
41
|
serialisableTarget.index = serialisableTarget.index
|
|
42
42
|
? serialisableTarget.index.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build))
|
|
@@ -44,13 +44,20 @@ exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, fun
|
|
|
44
44
|
const opts = [
|
|
45
45
|
(0, path_1.join)(__dirname, 'server'),
|
|
46
46
|
details.httpPort + '',
|
|
47
|
-
JSON.stringify(
|
|
47
|
+
JSON.stringify({
|
|
48
|
+
index: ((_b = details.target) === null || _b === void 0 ? void 0 : _b.index)
|
|
49
|
+
? details.target.index.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build))
|
|
50
|
+
: undefined,
|
|
51
|
+
name: (_c = details.target) === null || _c === void 0 ? void 0 : _c.name,
|
|
52
|
+
type: (_d = details.target) === null || _d === void 0 ? void 0 : _d.type,
|
|
53
|
+
source: (_e = details.target) === null || _e === void 0 ? void 0 : _e.source
|
|
54
|
+
})
|
|
48
55
|
];
|
|
49
56
|
if (details.debugPort !== -1) {
|
|
50
57
|
(0, logger_1.labeled)(label, 'you can attach your debugger at port : ' + details.debugPort).MESSAGE();
|
|
51
58
|
opts.unshift('--inspect=' + details.debugPort);
|
|
52
59
|
}
|
|
53
|
-
const targetSource = (
|
|
60
|
+
const targetSource = (_f = details.target) === null || _f === void 0 ? void 0 : _f.source;
|
|
54
61
|
const servePlugin = yield (0, plugin_loader_1.default)('functions', 'start', targetSource).catch((err) => (0, logger_1.debug)(err));
|
|
55
62
|
if (typeof servePlugin === 'function') {
|
|
56
63
|
const logStreamPlugin = yield (0, plugin_loader_1.default)('functions', 'logs', targetSource).catch((err) => (0, logger_1.debug)(err));
|
|
@@ -184,12 +184,13 @@ class HttpFunctions {
|
|
|
184
184
|
exit: 2
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
+
const slaveFnTarget = { index: fnTarget.index, name: fnTarget.name };
|
|
187
188
|
if ((_a = fnTarget.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.node.value)) {
|
|
188
189
|
if (debugPort !== -1) {
|
|
189
190
|
slaveOptions.push('--inspect-brk=' + debugPort);
|
|
190
191
|
}
|
|
191
192
|
slaveOptions.push(this.nodeInvoker[fnTarget.type]);
|
|
192
|
-
slaveOptions.push(JSON.stringify(
|
|
193
|
+
slaveOptions.push(JSON.stringify(slaveFnTarget));
|
|
193
194
|
slaveOptions.push(query);
|
|
194
195
|
slaveOptions.push(JSON.stringify({
|
|
195
196
|
'x-zc-projectid': request.headers['x-zc-projectid'],
|
|
@@ -232,7 +233,7 @@ class HttpFunctions {
|
|
|
232
233
|
}
|
|
233
234
|
slaveOptions.push((0, path_1.basename)(invoker));
|
|
234
235
|
slaveOptions.push(javaInvokerDir);
|
|
235
|
-
slaveOptions.push(JSON.stringify(
|
|
236
|
+
slaveOptions.push(JSON.stringify(slaveFnTarget));
|
|
236
237
|
slaveOptions.push(query);
|
|
237
238
|
slaveOptions.push(JSON.stringify({
|
|
238
239
|
'x-zc-projectid': request.headers['x-zc-projectid'],
|
|
@@ -95,12 +95,13 @@ class LocalFunction {
|
|
|
95
95
|
const debugPort = runtime_store_1.default.get('context.port.debug.' + constants_1.FN_TYPE.basic, null);
|
|
96
96
|
yield fs_1.ASYNC.ensureFile(this.responseFile, true);
|
|
97
97
|
yield fs_1.ASYNC.ensureFile(this.metaFile, true);
|
|
98
|
+
const slaveFnTarget = { index: this.target.index, name: this.target.name };
|
|
98
99
|
if ((_a = this.target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.node.value)) {
|
|
99
100
|
if (debugPort !== null) {
|
|
100
101
|
slaveOptions.push('--inspect-brk=' + debugPort);
|
|
101
102
|
}
|
|
102
103
|
slaveOptions.push(this.nodeInvoker);
|
|
103
|
-
slaveOptions.push(JSON.stringify(
|
|
104
|
+
slaveOptions.push(JSON.stringify(slaveFnTarget));
|
|
104
105
|
slaveOptions.push(data);
|
|
105
106
|
slaveOptions.push(JSON.stringify({
|
|
106
107
|
'x-zc-projectid': (0, project_1.getProjectId)(),
|
|
@@ -132,7 +133,7 @@ class LocalFunction {
|
|
|
132
133
|
}
|
|
133
134
|
slaveOptions.push((0, path_1.basename)(this.javaInvoker));
|
|
134
135
|
slaveOptions.push(javaInvokerDir);
|
|
135
|
-
slaveOptions.push(JSON.stringify(
|
|
136
|
+
slaveOptions.push(JSON.stringify(slaveFnTarget));
|
|
136
137
|
slaveOptions.push(data);
|
|
137
138
|
slaveOptions.push(JSON.stringify({
|
|
138
139
|
'x-zc-projectid': (0, project_1.getProjectId)(),
|
|
@@ -164,9 +165,9 @@ class LocalFunction {
|
|
|
164
165
|
yield fs_1.ASYNC.ensureFile(this.responseFile, true);
|
|
165
166
|
yield fs_1.ASYNC.ensureFile(this.metaFile, true);
|
|
166
167
|
slaveOptions.push('-u');
|
|
167
|
-
slaveOptions.push('main.py');
|
|
168
|
+
slaveOptions.push((0, path_1.join)(runtimesDir, runtime_1.default.language.python.value, `zcatalyst_runtime_${stackVersion.replace('_', '')}`, 'main.py'));
|
|
168
169
|
this.slave = (0, shell_1.spawn)(userConfig_1.default.get(`python${stackVersion}.bin`), slaveOptions, {
|
|
169
|
-
cwd: (0, path_1.join)(
|
|
170
|
+
cwd: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, this.target.name),
|
|
170
171
|
stdio: 'pipe',
|
|
171
172
|
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)
|
|
172
173
|
}).RAW();
|
package/lib/shell/index.js
CHANGED
|
@@ -88,20 +88,12 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
88
88
|
return target.localFn.shutdown();
|
|
89
89
|
}
|
|
90
90
|
})));
|
|
91
|
-
yield fs_1.ASYNC.chmod((0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions), '755', {
|
|
92
|
-
recursive: true,
|
|
93
|
-
checkPath: false
|
|
94
|
-
}).catch((err) => (0, logger_js_1.debug)('Error modifying permissions: ', err));
|
|
95
91
|
yield fs_1.ASYNC.deleteDir((0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)).catch();
|
|
96
92
|
fn_utils_1.fnUtils.common.executeHook({ prefix: 'post', command: 'serve' });
|
|
97
93
|
(0, logger_js_1.info)();
|
|
98
94
|
(0, logger_js_1.success)('shell complete');
|
|
99
95
|
}
|
|
100
96
|
catch (e) {
|
|
101
|
-
yield fs_1.ASYNC.chmod((0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions), '755', {
|
|
102
|
-
recursive: true,
|
|
103
|
-
checkPath: false
|
|
104
|
-
}).catch((err) => (0, logger_js_1.debug)('Error modifying permissions: ', err));
|
|
105
97
|
yield Promise.all([
|
|
106
98
|
fs_1.ASYNC.deleteDir((0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)).catch(),
|
|
107
99
|
httpServer ? httpServer.stop() : undefined
|
|
@@ -14,7 +14,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const path_1 = require("path");
|
|
16
16
|
const fn_utils_1 = require("../../../fn-utils");
|
|
17
|
-
const common_1 = require("../../../fn-utils/lib/common");
|
|
18
17
|
const java_1 = require("../../../fn-utils/lib/java");
|
|
19
18
|
const runtime_store_1 = __importDefault(require("../../../runtime-store"));
|
|
20
19
|
const constants_1 = require("../../../util_modules/constants");
|
|
@@ -46,7 +45,6 @@ exports.default = (targets) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
46
45
|
}
|
|
47
46
|
const targetBuildPath = (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, target.name);
|
|
48
47
|
if (yield fs_1.ASYNC.isPathExists(targetBuildPath)) {
|
|
49
|
-
yield fs_1.ASYNC.chmod(targetBuildPath, '755', { recursive: true });
|
|
50
48
|
yield fs_1.ASYNC.deleteDir(targetBuildPath);
|
|
51
49
|
}
|
|
52
50
|
if (target.type === constants_1.FN_TYPE.advanced ||
|
|
@@ -69,9 +67,7 @@ exports.default = (targets) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
69
67
|
}
|
|
70
68
|
})));
|
|
71
69
|
}
|
|
72
|
-
yield
|
|
73
|
-
replace: false
|
|
74
|
-
});
|
|
70
|
+
yield fs_1.ASYNC.copyDir((0, path_1.join)(target.source, constants_1.FOLDERNAME.output), targetBuildPath);
|
|
75
71
|
throbber.remove('function_serve_' + target.name);
|
|
76
72
|
return target;
|
|
77
73
|
})));
|
|
@@ -14,10 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const path_1 = require("path");
|
|
16
16
|
const fn_utils_1 = require("../../../fn-utils");
|
|
17
|
-
const common_1 = require("../../../fn-utils/lib/common");
|
|
18
17
|
const runtime_store_1 = __importDefault(require("../../../runtime-store"));
|
|
19
18
|
const throbber_1 = __importDefault(require("../../../throbber"));
|
|
20
19
|
const constants_1 = require("../../../util_modules/constants");
|
|
20
|
+
const fs_1 = require("../../../util_modules/fs");
|
|
21
21
|
exports.default = (targets) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
22
|
if (targets === undefined || targets.length === 0) {
|
|
23
23
|
return;
|
|
@@ -36,7 +36,7 @@ exports.default = (targets) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
36
36
|
return target;
|
|
37
37
|
});
|
|
38
38
|
return Promise.all(nodeTargets.map((target) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
yield
|
|
39
|
+
yield fs_1.ASYNC.copyDir(target.source, (0, path_1.join)(runtime_store_1.default.get('project.root'), constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, target.name));
|
|
40
40
|
throbber.remove('function_serve_' + target.name);
|
|
41
41
|
return target;
|
|
42
42
|
})));
|
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const path_1 = require("path");
|
|
16
16
|
const fn_utils_1 = require("../../../fn-utils");
|
|
17
17
|
const runtime_store_1 = __importDefault(require("../../../runtime-store"));
|
|
18
|
-
const common_1 = require("../../../fn-utils/lib/common");
|
|
19
18
|
const constants_1 = require("../../../util_modules/constants");
|
|
20
19
|
const fs_1 = require("../../../util_modules/fs");
|
|
21
20
|
const pip_install_1 = require("../../../init/dependencies/python/pip-install");
|
|
@@ -58,7 +57,7 @@ exports.default = (targets, fnWatchEvent) => __awaiter(void 0, void 0, void 0, f
|
|
|
58
57
|
target.failure_reason = error.message;
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
|
-
yield
|
|
60
|
+
yield fs_1.ASYNC.copyDir(target.source, buildPath);
|
|
62
61
|
throbber.remove('function_serve_' + target.name);
|
|
63
62
|
return target;
|
|
64
63
|
})));
|