zcatalyst-cli 1.17.1 → 1.17.3

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 CHANGED
@@ -13,7 +13,6 @@
13
13
 
14
14
  ![catalyst](https://img.shields.io/badge/%E2%9A%A1-catalyst-blue.svg)
15
15
  ![npm](https://img.shields.io/npm/v/zcatalyst-cli.svg?color=blue)
16
- ![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/zcatalyst-cli.svg)
17
16
  ![NPM](https://img.shields.io/npm/l/zcatalyst-cli.svg?color=brightgreen)
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;
@@ -24,6 +24,7 @@ const runtime_1 = __importDefault(require("../../../util_modules/constants/lib/r
24
24
  const env_1 = require("../../../util_modules/env");
25
25
  const ensure_python_1 = require("./ensure-python");
26
26
  const userConfig_1 = __importDefault(require("../../../userConfig"));
27
+ const logger_1 = require("../../../util_modules/logger");
27
28
  const sdkPipOpts = (0, env_1.envOverride)('CATALYST_SDK_PIP_OPTS', 'zcatalyst-sdk');
28
29
  const cliqSdkPipOpts = (0, env_1.envOverride)('CATALYST_CLIQ_SDK_PIP_OPTS', 'zcatalyst-cliq');
29
30
  const testPypi = (0, env_1.envOverride)('CATALYST_TEST_PYPI', 'false');
@@ -90,6 +91,7 @@ function ensurePyRuntime(pth, stack) {
90
91
  errData.push(chunk);
91
92
  });
92
93
  child.on('error', (err) => {
94
+ (0, logger_1.info)(Buffer.concat(errData).toString());
93
95
  reject(new error_1.default(`Error while installing python${stackVersion.replace('_', '.')} runtime`, {
94
96
  original: err,
95
97
  exit: 2
@@ -168,6 +170,7 @@ function installRequirements(reqFile, pth, stackVersion, linuxMode = false) {
168
170
  errData.push(chunk);
169
171
  });
170
172
  child.on('error', (err) => {
173
+ (0, logger_1.info)(Buffer.concat(errData).toString());
171
174
  reject(new error_1.default('unable to process requirements.txt', {
172
175
  exit: 2,
173
176
  original: err
@@ -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,
@@ -19,8 +19,8 @@ const userConfig_1 = __importDefault(require("../../../../userConfig"));
19
19
  const constants_1 = require("../../../../util_modules/constants");
20
20
  const project_1 = require("../../../../util_modules/project");
21
21
  const shell_1 = require("../../../../util_modules/shell");
22
+ const error_1 = __importDefault(require("../../../../error"));
22
23
  const logger_1 = require("../../../../util_modules/logger");
23
- const util_1 = require("util");
24
24
  exports.default = (details) => __awaiter(void 0, void 0, void 0, function* () {
25
25
  var _a, _b;
26
26
  const projectRoot = runtime_store_1.default.get('project.root');
@@ -31,7 +31,8 @@ exports.default = (details) => __awaiter(void 0, void 0, void 0, function* () {
31
31
  '-u',
32
32
  (0, path_1.join)(runtimesDir, constants_1.RUNTIME.language.python.value, `zcatalyst_runtime_${stackVersion === null || stackVersion === void 0 ? void 0 : stackVersion.replace('_', '')}`, 'main.py')
33
33
  ];
34
- return new Promise((res) => {
34
+ return new Promise((resolve, reject) => {
35
+ var _a;
35
36
  const child = (0, shell_1.spawn)(userConfig_1.default.get(`python${stackVersion}.bin`), opts, {
36
37
  cwd: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)),
37
38
  stdio: 'pipe',
@@ -40,10 +41,17 @@ exports.default = (details) => __awaiter(void 0, void 0, void 0, function* () {
40
41
  child.on('spawn', () => __awaiter(void 0, void 0, void 0, function* () {
41
42
  yield (0, http_functions_1.checkIfRuntimeServerRunning)(details.httpPort.toString());
42
43
  }));
44
+ const errData = [];
45
+ (_a = child.stderr) === null || _a === void 0 ? void 0 : _a.on('data', (chunk) => {
46
+ errData.push(chunk);
47
+ });
43
48
  child.on('error', (err) => {
44
- (0, logger_1.debug)('Python Child spawn error');
45
- (0, logger_1.debug)((0, util_1.inspect)(err));
49
+ (0, logger_1.info)(Buffer.concat(errData).toString());
50
+ reject(new error_1.default(`Error while starting python runtime server`, {
51
+ original: err,
52
+ exit: 2
53
+ }));
46
54
  });
47
- res(child);
55
+ resolve(child);
48
56
  });
49
57
  });
@@ -164,9 +164,9 @@ class LocalFunction {
164
164
  yield fs_1.ASYNC.ensureFile(this.responseFile, true);
165
165
  yield fs_1.ASYNC.ensureFile(this.metaFile, true);
166
166
  slaveOptions.push('-u');
167
- slaveOptions.push('main.py');
167
+ slaveOptions.push((0, path_1.join)(runtimesDir, runtime_1.default.language.python.value, `zcatalyst_runtime_${stackVersion.replace('_', '')}`, 'main.py'));
168
168
  this.slave = (0, shell_1.spawn)(userConfig_1.default.get(`python${stackVersion}.bin`), slaveOptions, {
169
- cwd: (0, path_1.join)(runtimesDir, runtime_1.default.language.python.value, `zcatalyst_runtime_${stackVersion.replace('_', '')}`),
169
+ cwd: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, this.target.name),
170
170
  stdio: 'pipe',
171
171
  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
172
  }).RAW();
@@ -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 (0, common_1.copyModDirPerm)((0, path_1.join)(target.source, constants_1.FOLDERNAME.output), targetBuildPath, '555', {
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 (0, common_1.copyModDirPerm)(target.source, (0, path_1.join)(runtime_store_1.default.get('project.root'), constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, target.name), '555');
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 (0, common_1.copyModDirPerm)(target.source, buildPath, '555');
60
+ yield fs_1.ASYNC.copyDir(target.source, buildPath);
62
61
  throbber.remove('function_serve_' + target.name);
63
62
  return target;
64
63
  })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcatalyst-cli",
3
- "version": "1.17.1",
3
+ "version": "1.17.3",
4
4
  "description": "Command Line Tool for CATALYST",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {