zcatalyst-cli 1.16.2 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,8 +33,10 @@ const logger_1 = require("../util_modules/logger");
33
33
  const option_1 = require("../util_modules/option");
34
34
  const crypto_1 = require("crypto");
35
35
  exports.missingScopes = {
36
- [constants_1.DC_TYPE.au.value]: ['quick_ml'],
37
- [constants_1.DC_TYPE.eu.value]: ['quick_ml']
36
+ [constants_1.DC_TYPE.in.value]: ['dataverse'],
37
+ [constants_1.DC_TYPE.eu.value]: ['quick_ml', 'dataverse'],
38
+ [constants_1.DC_TYPE.au.value]: ['dataverse'],
39
+ [constants_1.DC_TYPE.ca.value]: ['quick_ml', 'dataverse']
38
40
  };
39
41
  class Login {
40
42
  constructor(localhost = true, user = true) {
@@ -283,7 +285,7 @@ class Login {
283
285
  var _a;
284
286
  const dcRef = (_a = (0, dc_1.getActiveDCType)()) === null || _a === void 0 ? void 0 : _a.ref;
285
287
  const callbackUrl = this._getCallbackUrl(port);
286
- const nonce = encodeURIComponent((0, crypto_1.randomBytes)(16).toString());
288
+ const nonce = (0, crypto_1.randomBytes)(16).toString('base64');
287
289
  const authUrl = this._getLoginUrl(callbackUrl, nonce);
288
290
  let reqCount = 0;
289
291
  const server = (0, http_1.createServer)((req, res) => __awaiter(this, void 0, void 0, function* () {
@@ -23,6 +23,7 @@ const runtime_1 = __importDefault(require("../../../util_modules/constants/lib/r
23
23
  const logger_1 = require("../../../util_modules/logger");
24
24
  const option_1 = require("../../../util_modules/option");
25
25
  const languages_1 = require("./languages");
26
+ const char_1 = require("../../../util_modules/char");
26
27
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
27
28
  fn_utils_1.fnUtils.common.executeHook({ prefix: 'pre', command: 'deploy' });
28
29
  const targets = yield fn_utils_1.fnUtils.common.validate();
@@ -48,6 +49,20 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
48
49
  (0, languages_1.java)(refinedTargets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java.value)) && target.valid; })),
49
50
  (0, languages_1.python)(refinedTargets.filter((target) => { var _a; return ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python.value)) && target.valid; }))
50
51
  ]);
52
+ refinedTargets === null || refinedTargets === void 0 ? void 0 : refinedTargets.forEach((target) => {
53
+ if (target.compilationError) {
54
+ target.compilationError.forEach((error) => {
55
+ console.log(`${(0, ansi_colors_1.red)(char_1.CHAR.error)} Error while compiling function[${target.name}]`);
56
+ console.log(error);
57
+ });
58
+ }
59
+ if (target.compilationWarning) {
60
+ target.compilationWarning.forEach((warn) => {
61
+ console.warn(`${(0, ansi_colors_1.yellow)(char_1.CHAR.warning)} Warning while compiling function[${target.name}]`);
62
+ console.warn(warn);
63
+ });
64
+ }
65
+ });
51
66
  const combinedTarget = [...(nodeTarget || []), ...(javaTarget || []), ...(pythonTarget || [])];
52
67
  const batchSize = 1;
53
68
  const fnAPI = yield (0, endpoints_1.functionsAPI)();
@@ -99,11 +114,6 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
99
114
  })));
100
115
  }
101
116
  const allTargets = refinedTargets.filter((target) => {
102
- if (target.compilationWarning) {
103
- target.compilationWarning.forEach((message) => {
104
- (0, logger_1.warning)(message);
105
- });
106
- }
107
117
  if (!target.valid) {
108
118
  (0, logger_1.warning)('skipping deploy of target [' + target.name + '] since ' + target.failure_reason);
109
119
  }
@@ -175,7 +175,7 @@ function normaliseClasspath(pth, libFolder) {
175
175
  });
176
176
  }
177
177
  }
178
- row.path = (0, path_1.join)((0, path_1.basename)(libFolder), jarName);
178
+ row.path = (0, path_1.basename)(libFolder) + '/' + jarName;
179
179
  if ((0, path_1.dirname)(libPath) === (0, path_1.dirname)(libFolder)) {
180
180
  try {
181
181
  yield fs_1.ASYNC.deleteFile(libPath);
@@ -238,13 +238,16 @@ function compileTarget(target) {
238
238
  const targetVersion = getTargetVersion(target.stack);
239
239
  yield Promise.all(entries.map((file) => compileJavaFiles(file, spawnCommand, targetVersion, targetSource, outputFolder)
240
240
  .then((result) => {
241
- const code = result[2];
241
+ const [_stdout, stderr, code] = result;
242
242
  if (code === 1) {
243
243
  const error = [];
244
- error === null || error === void 0 ? void 0 : error.push(result[1]);
244
+ error === null || error === void 0 ? void 0 : error.push(stderr);
245
245
  target.valid = false;
246
246
  target.compilationError = error;
247
247
  }
248
+ else if (stderr) {
249
+ target.compilationWarning = [stderr];
250
+ }
248
251
  })
249
252
  .catch((error) => {
250
253
  target.failure_reason = error.message;
@@ -282,6 +285,7 @@ function compileJavaFiles(file, spawnCommand, targetVersion, targetSource, outpu
282
285
  '*' + module.exports.classPathSep + '.',
283
286
  '-g',
284
287
  '-Xprefer:source',
288
+ '-Xlint',
285
289
  file.replace(targetSource, outputFolder)
286
290
  ], {
287
291
  cwd: outputFolder,
@@ -439,11 +443,6 @@ function validate(targets, idx) {
439
443
  currentTarget.valid = true;
440
444
  return validate(targets, ++idx);
441
445
  }
442
- throw new error_1.default('there was a compilation error!', {
443
- exit: 1,
444
- errorId: 'JAVA-7',
445
- skipHelp: !!(0, option_1.getOptionValue)('watch', false)
446
- });
447
446
  }
448
447
  catch (err) {
449
448
  currentTarget.valid = false;
package/lib/fn-watcher.js CHANGED
@@ -19,6 +19,8 @@ const languages_1 = require("./shell/prepare/languages");
19
19
  const constants_1 = require("./util_modules/constants");
20
20
  const fs_1 = require("./util_modules/fs");
21
21
  const logger_1 = require("./util_modules/logger");
22
+ const char_1 = require("./util_modules/char");
23
+ const ansi_colors_1 = require("ansi-colors");
22
24
  exports.default = (target) => __awaiter(void 0, void 0, void 0, function* () {
23
25
  return new Promise((res) => {
24
26
  let paused = false;
@@ -48,6 +50,18 @@ exports.default = (target) => __awaiter(void 0, void 0, void 0, function* () {
48
50
  return;
49
51
  }
50
52
  (0, logger_1.warning)('target [' + target.name + '] is not a valid one reason : ' + target.failure_reason);
53
+ if (target.compilationError) {
54
+ target.compilationError.forEach((error) => {
55
+ console.log(`${(0, ansi_colors_1.red)(char_1.CHAR.error)} Error while compiling function[${target.name}]`);
56
+ console.log(error);
57
+ });
58
+ }
59
+ if (target.compilationWarning) {
60
+ target.compilationWarning.forEach((warn) => {
61
+ console.warn(`${(0, ansi_colors_1.yellow)(char_1.CHAR.warning)} Warning while compiling function[${target.name}]`);
62
+ console.warn(warn);
63
+ });
64
+ }
51
65
  (0, logger_1.info)('Waiting for correction..');
52
66
  (0, logger_1.info)('\n(To exit, press ^C)');
53
67
  watcher.emit('next');
@@ -30,6 +30,7 @@ const error_1 = __importDefault(require("../../../error"));
30
30
  const python_1 = require("../../../fn-utils/lib/python");
31
31
  const throbber_1 = __importDefault(require("../../../throbber"));
32
32
  const ensure_java_userconfig_1 = require("../../../fn-utils/lib/ensure-java-userconfig");
33
+ const char_1 = require("../../../util_modules/char");
33
34
  function selFnsPrompt(targs, fnDirPath) {
34
35
  return __awaiter(this, void 0, void 0, function* () {
35
36
  const choicesObj = targs.reduce((accumulator, fn) => {
@@ -202,6 +203,18 @@ exports.default = (_fns) => __awaiter(void 0, void 0, void 0, function* () {
202
203
  else if (!target.valid && ((_c = target.failure_reason) === null || _c === void 0 ? void 0 : _c.startsWith('unable to locate python'))) {
203
204
  (0, logger_1.warning)(`skipping pull of function(${target.name}) since ${target.failure_reason}`);
204
205
  }
206
+ if (target.compilationError) {
207
+ target.compilationError.forEach((error) => {
208
+ console.log(`${(0, ansi_colors_1.red)(char_1.CHAR.error)} Error while compiling function[${target.name}]`);
209
+ console.log(error);
210
+ });
211
+ }
212
+ if (target.compilationWarning) {
213
+ target.compilationWarning.forEach((warn) => {
214
+ console.warn(`${(0, ansi_colors_1.yellow)(char_1.CHAR.warning)} Warning while compiling function[${target.name}]`);
215
+ console.warn(warn);
216
+ });
217
+ }
205
218
  return target.valid;
206
219
  });
207
220
  if (isFnPulled) {
@@ -51,7 +51,6 @@ const logger_1 = require("../util_modules/logger");
51
51
  const option_1 = require("../util_modules/option");
52
52
  const features = __importStar(require("./features"));
53
53
  const server_1 = __importDefault(require("./server"));
54
- const char_1 = require("../util_modules/char");
55
54
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
56
55
  const serveTargets = runtime_store_1.default.get('context.targets', []);
57
56
  const advancedServer = new server_1.default();
@@ -90,11 +89,6 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
90
89
  }
91
90
  const functionTargets = rawTargets.filter((target) => {
92
91
  var _a;
93
- if (target.compilationError) {
94
- target.compilationError.forEach((error) => {
95
- console.log(`${(0, ansi_colors_1.red)(char_1.CHAR.error)} Error while compiling function[${target.name}] : ${error}`);
96
- });
97
- }
98
92
  if (!target.valid) {
99
93
  (0, logger_1.warning)('skipping serve of function [' +
100
94
  target.name +
@@ -102,11 +96,6 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
102
96
  target.failure_reason);
103
97
  return false;
104
98
  }
105
- if (target.compilationWarning) {
106
- target.compilationWarning.forEach((message) => {
107
- (0, logger_1.warning)(message);
108
- });
109
- }
110
99
  if (target.type === constants_1.FN_TYPE.advanced) {
111
100
  advancedServer.add('server', target);
112
101
  }
@@ -24,9 +24,9 @@ const project_1 = require("../../../../util_modules/project");
24
24
  const shell_1 = require("../../../../util_modules/shell");
25
25
  exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, function* () {
26
26
  var _a, _b, _c, _d, _e;
27
- const cwd = runtime_store_1.default.get('cwd');
28
- const javaServer = (0, path_1.join)(cwd, constants_1.FOLDERNAME.build, '.catalyst', 'aioserver', 'JavaaioServer');
29
- const targetDir = (0, path_1.join)(cwd, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, (_a = details.target) === null || _a === void 0 ? void 0 : _a.name);
27
+ const projectRoot = runtime_store_1.default.get('project.root');
28
+ const javaServer = (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, '.catalyst', 'aioserver', 'JavaaioServer');
29
+ const targetDir = (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, (_a = details.target) === null || _a === void 0 ? void 0 : _a.name);
30
30
  const label = `${details.type}[${(_b = details.target) === null || _b === void 0 ? void 0 : _b.name}]`;
31
31
  const opts = [
32
32
  '-cp',
@@ -52,7 +52,7 @@ exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, fun
52
52
  const userConfigCmd = userConfig_1.default.get(configKey);
53
53
  const spawnCommand = (0, ensure_java_userconfig_1.getJavaSpawnCommand)(userConfigCmd, 'java', (_e = details.target) === null || _e === void 0 ? void 0 : _e.stack);
54
54
  return (0, shell_1.spawn)(spawnCommand, opts, {
55
- cwd: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(cwd, (0, path_1.join)(cwd, constants_1.FOLDERNAME.build)),
55
+ cwd: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)),
56
56
  stdio: 'pipe',
57
57
  env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_CODE_LOCATION: targetDir + path_1.sep, 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) }, details.target.env_var)
58
58
  }).RAW();
@@ -37,9 +37,9 @@ exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, fun
37
37
  var _a, _b;
38
38
  const label = `${details.type}[${(_a = details.target) === null || _a === void 0 ? void 0 : _a.name}]`;
39
39
  const _c = details.target, { ['watcher']: _ } = _c, serialisableTarget = __rest(_c, ['watcher']);
40
- const cwd = runtime_store_1.default.get('cwd');
40
+ const projectRoot = runtime_store_1.default.get('project.root');
41
41
  serialisableTarget.index = serialisableTarget.index
42
- ? serialisableTarget.index.replace(cwd, (0, path_1.join)(cwd, constants_1.FOLDERNAME.build))
42
+ ? serialisableTarget.index.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build))
43
43
  : undefined;
44
44
  const opts = [
45
45
  (0, path_1.join)(__dirname, 'server'),
@@ -79,7 +79,7 @@ exports.default = (details, masterPort) => __awaiter(void 0, void 0, void 0, fun
79
79
  return event;
80
80
  }
81
81
  return (0, shell_1.spawn)('node', opts, {
82
- cwd: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(cwd, (0, path_1.join)(cwd, constants_1.FOLDERNAME.build)),
82
+ cwd: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)),
83
83
  stdio: 'pipe',
84
84
  env: Object.assign({ NODE_PATH: targetSource + path_1.sep + 'node_modules', 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) }, details.target.env_var)
85
85
  }).RAW();
@@ -26,7 +26,6 @@ exports.default = (details) => __awaiter(void 0, void 0, void 0, function* () {
26
26
  const projectRoot = runtime_store_1.default.get('project.root');
27
27
  const targetSource = (_a = details.target) === null || _a === void 0 ? void 0 : _a.source;
28
28
  const runtimesDir = constants_1.ENVPATH.runtimes.data;
29
- const cwd = runtime_store_1.default.get('cwd');
30
29
  const stackVersion = (_b = details.target.stack) === null || _b === void 0 ? void 0 : _b.replace('python_', '');
31
30
  const opts = [
32
31
  '-u',
@@ -34,7 +33,7 @@ exports.default = (details) => __awaiter(void 0, void 0, void 0, function* () {
34
33
  ];
35
34
  return new Promise((res) => {
36
35
  const child = (0, shell_1.spawn)(userConfig_1.default.get(`python${stackVersion}.bin`), opts, {
37
- cwd: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(cwd, (0, path_1.join)(cwd, constants_1.FOLDERNAME.build)),
36
+ cwd: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)),
38
37
  stdio: 'pipe',
39
38
  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: targetSource === null || targetSource === void 0 ? void 0 : targetSource.replace(projectRoot, (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build)), X_ZOHO_CATALYST_SERVER_LISTEN_PORT: details.httpPort.toString(), CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, details.target.env_var)
40
39
  }).RAW();
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const ansi_colors_1 = require("ansi-colors");
15
16
  const fn_utils_1 = require("../../fn-utils");
16
17
  const common_1 = require("../../fn-utils/lib/common");
17
18
  const pip_install_1 = require("../../init/dependencies/python/pip-install");
@@ -20,6 +21,7 @@ const throbber_1 = __importDefault(require("../../throbber"));
20
21
  const constants_1 = require("../../util_modules/constants");
21
22
  const runtime_1 = __importDefault(require("../../util_modules/constants/lib/runtime"));
22
23
  const languages_1 = require("./languages");
24
+ const char_1 = require("../../util_modules/char");
23
25
  exports.default = (fnTypes) => __awaiter(void 0, void 0, void 0, function* () {
24
26
  fn_utils_1.fnUtils.common.executeHook({ prefix: 'pre', command: 'serve' });
25
27
  const throbber = throbber_1.default.getInstance();
@@ -42,6 +44,20 @@ exports.default = (fnTypes) => __awaiter(void 0, void 0, void 0, function* () {
42
44
  });
43
45
  runtime_store_1.default.set('context.functions.targets', refinedTargets);
44
46
  yield (0, languages_1.prepareFunctions)(refinedTargets);
47
+ refinedTargets.forEach((target) => {
48
+ if (target.compilationError) {
49
+ target.compilationError.forEach((error) => {
50
+ console.log(`${(0, ansi_colors_1.red)(char_1.CHAR.error)} Error while compiling function[${target.name}]`);
51
+ console.log(error);
52
+ });
53
+ }
54
+ if (target.compilationWarning) {
55
+ target.compilationWarning.forEach((warn) => {
56
+ console.warn(`${(0, ansi_colors_1.yellow)(char_1.CHAR.warning)} Warning while compiling function[${target.name}]`);
57
+ console.warn(warn);
58
+ });
59
+ }
60
+ });
45
61
  const pyStacks = [];
46
62
  refinedTargets.filter((target) => {
47
63
  var _a;
@@ -32,5 +32,13 @@ exports.default = Object.freeze({
32
32
  w_auth: 'us',
33
33
  m_auth: 'us',
34
34
  ext: '.com.au'
35
+ },
36
+ ca: {
37
+ loc: 'Canada',
38
+ ref: 'ca',
39
+ value: 'ca',
40
+ w_auth: 'us',
41
+ m_auth: 'us',
42
+ ext: '.ca'
35
43
  }
36
44
  });
@@ -12,6 +12,9 @@ class URL {
12
12
  if (dc === undefined) {
13
13
  return URL._auth;
14
14
  }
15
+ if (dc.value === dc_type_js_1.default.ca.value) {
16
+ return URL._auth.replace('.zoho.com', '.zohocloud.ca');
17
+ }
15
18
  return URL._auth.replace('.com', dc.ext);
16
19
  }
17
20
  static get admin() {
@@ -19,6 +22,9 @@ class URL {
19
22
  if (dc === undefined) {
20
23
  return URL._admin;
21
24
  }
25
+ if (dc.value === dc_type_js_1.default.ca.value) {
26
+ return URL._admin.replace('.zoho.com', '.zohocloud.ca');
27
+ }
22
28
  return URL._admin.replace('.com', dc.ext);
23
29
  }
24
30
  static get app() {
@@ -33,6 +39,9 @@ class URL {
33
39
  if (dc === undefined) {
34
40
  return URL._zohoStatic;
35
41
  }
42
+ if (dc.value === dc_type_js_1.default.ca.value) {
43
+ return URL._zohoStatic.replace('.zoho.com', '.zohocloud.ca');
44
+ }
36
45
  return URL._zohoStatic.replace(dc_type_js_1.default.us.ext, dc.ext);
37
46
  }
38
47
  static get console() {
@@ -40,6 +49,9 @@ class URL {
40
49
  if (dc === undefined) {
41
50
  return URL._console;
42
51
  }
52
+ if (dc.value === dc_type_js_1.default.ca.value) {
53
+ return URL._console.replace('.zoho.com', '.zohocloud.ca');
54
+ }
43
55
  return URL._console.replace('.com', dc.ext);
44
56
  }
45
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcatalyst-cli",
3
- "version": "1.16.2",
3
+ "version": "1.17.0",
4
4
  "description": "Command Line Tool for CATALYST",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {