zcatalyst-cli 1.15.0-beta.5 → 1.15.0-beta.6

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.
Files changed (41) hide show
  1. package/lib/archiver.js +8 -3
  2. package/lib/client-utils.js +5 -1
  3. package/lib/commands/iac/pack.js +9 -8
  4. package/lib/deploy/features/appsail/index.js +15 -5
  5. package/lib/deploy/features/client.js +1 -1
  6. package/lib/deploy/features/functions/index.js +7 -4
  7. package/lib/endpoints/lib/applogic.js +14 -2
  8. package/lib/endpoints/lib/appsail.js +11 -2
  9. package/lib/endpoints/lib/client.js +11 -2
  10. package/lib/endpoints/lib/functions.js +14 -2
  11. package/lib/express_middlewares/logger.js +6 -2
  12. package/lib/fn-utils/lib/common.js +78 -48
  13. package/lib/fn-utils/lib/java.js +10 -10
  14. package/lib/fn-utils/lib/python.js +1 -1
  15. package/lib/init/features/appsail/index.js +2 -2
  16. package/lib/internal/api.js +33 -8
  17. package/lib/option-filter.js +4 -4
  18. package/lib/port-resolver.js +24 -11
  19. package/lib/progress.js +3 -2
  20. package/lib/prompt/types/file-path.js +3 -1
  21. package/lib/serve/features/appsail.js +14 -3
  22. package/lib/serve/features/index.js +1 -1
  23. package/lib/serve/index.js +7 -2
  24. package/lib/serve/server/index.js +252 -92
  25. package/lib/serve/server/lib/appsail/index.js +19 -9
  26. package/lib/serve/server/lib/appsail/start.js +4 -15
  27. package/lib/serve/server/lib/master.js +10 -10
  28. package/lib/serve/server/lib/web_client/index.js +5 -5
  29. package/lib/shell/dependencies/http-functions.js +11 -15
  30. package/lib/shell/prepare/languages/java.js +9 -4
  31. package/lib/util_modules/constants/lib/default.js +4 -1
  32. package/lib/util_modules/constants/lib/scopes.js +1 -0
  33. package/lib/util_modules/fs/lib/async.js +10 -9
  34. package/lib/util_modules/fs/lib/sync.js +5 -1
  35. package/package.json +1 -1
  36. package/templates/init/functions/java/integ/convokraft/FallbackHandler.java +1 -0
  37. package/templates/init/functions/node/integ/convokraft/fallback.js +1 -0
  38. package/templates/init/functions/python/integ/convokraft/fallback_handler.py +2 -1
  39. package/templates/init/functions/node/.DS_Store +0 -0
  40. package/templates/init/functions/node/integ/.DS_Store +0 -0
  41. package/templates/init/functions/node/integ/convokraft/.DS_Store +0 -0
@@ -32,6 +32,8 @@ const logger_2 = require("../../util_modules/logger");
32
32
  const project_2 = require("../../util_modules/project");
33
33
  const shell_1 = require("../../util_modules/shell");
34
34
  const request_1 = __importDefault(require("request"));
35
+ const option_1 = require("../../util_modules/option");
36
+ const server_1 = require("../../util_modules/server");
35
37
  const logUrl = (name, pthName, httpPort, masterPort) => {
36
38
  (0, logger_2.labeled)(`functions(${name})`, 'URL => http://localhost:' + (masterPort === -1 ? httpPort : masterPort) + pthName).MESSAGE();
37
39
  };
@@ -323,6 +325,9 @@ class HttpFunctions {
323
325
  (_a = target.watcher) === null || _a === void 0 ? void 0 : _a.emit('next');
324
326
  }, 1000);
325
327
  });
328
+ if ((0, option_1.getCurrentCommand)() === 'functions:shell') {
329
+ logUrl(target.name, new url_1.URL(target.url).pathname, httpPort, masterPort);
330
+ }
326
331
  });
327
332
  if (this.repl !== undefined) {
328
333
  this.repl.showPrompt();
@@ -335,10 +340,8 @@ class HttpFunctions {
335
340
  start() {
336
341
  return __awaiter(this, void 0, void 0, function* () {
337
342
  const server = yield this._spinUpServer();
338
- server.on('connection', (socket) => {
339
- socket.unref();
340
- });
341
- HttpFunctions.server = server;
343
+ const connDestroyer = new server_1.ConnectionDestroyer(server);
344
+ this.connDestroyer = connDestroyer;
342
345
  return server;
343
346
  });
344
347
  }
@@ -349,20 +352,13 @@ class HttpFunctions {
349
352
  slave.kill('SIGINT');
350
353
  });
351
354
  this.q.destroy(() => __awaiter(this, void 0, void 0, function* () {
352
- yield Promise.all(this.targets.map((target) => __awaiter(this, void 0, void 0, function* () { var _a; return (_a = target.watcher) === null || _a === void 0 ? void 0 : _a.close(); })));
353
- if (HttpFunctions.server !== null) {
354
- HttpFunctions.server.close((err) => {
355
- (0, logger_2.debug)(err);
356
- res();
357
- });
358
- }
359
- else {
360
- res();
361
- }
355
+ var _a;
356
+ yield Promise.all(this.targets.map((target) => __awaiter(this, void 0, void 0, function* () { var _b; return (_b = target.watcher) === null || _b === void 0 ? void 0 : _b.close(); })));
357
+ yield ((_a = this.connDestroyer) === null || _a === void 0 ? void 0 : _a.destroy());
358
+ res();
362
359
  }));
363
360
  });
364
361
  });
365
362
  }
366
363
  }
367
- HttpFunctions.server = null;
368
364
  exports.default = HttpFunctions;
@@ -21,6 +21,7 @@ const constants_1 = require("../../../util_modules/constants");
21
21
  const fs_1 = require("../../../util_modules/fs");
22
22
  const fs_2 = require("fs");
23
23
  const throbber_1 = __importDefault(require("../../../throbber"));
24
+ const error_1 = __importDefault(require("../../../error"));
24
25
  exports.default = (targets) => __awaiter(void 0, void 0, void 0, function* () {
25
26
  if (targets === undefined || targets.length === 0) {
26
27
  return;
@@ -55,14 +56,18 @@ exports.default = (targets) => __awaiter(void 0, void 0, void 0, function* () {
55
56
  const javaInvoker = (0, path_1.join)(__dirname, '../../../serve/server/lib/java/aio_server/JavaaioServer.java');
56
57
  (0, java_1.ensureJavaInvoker)(javaServer, javaInvoker);
57
58
  const serverFiles = yield fs_1.ASYNC.walk((0, path_1.dirname)(javaServer));
58
- yield Promise.all(serverFiles.map((file) => {
59
- return fs_1.ASYNC.copyFile(file, (0, path_1.join)(targetBuildPath, (0, path_1.relative)((0, path_1.dirname)(javaServer), file.replace('lib' + path_1.sep, ''))), fs_2.constants.COPYFILE_EXCL).catch((err) => {
59
+ yield Promise.all(serverFiles.map((file) => __awaiter(void 0, void 0, void 0, function* () {
60
+ try {
61
+ 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, ''))), fs_2.constants.COPYFILE_EXCL);
62
+ }
63
+ catch (e) {
64
+ const err = error_1.default.getErrorInstance(e).original;
60
65
  if (err.code !== 'EEXIST') {
61
66
  throbber.remove('function_serve_' + target.name);
62
67
  throw err;
63
68
  }
64
- });
65
- }));
69
+ }
70
+ })));
66
71
  }
67
72
  yield (0, common_1.copyModDirPerm)((0, path_1.join)(target.source, constants_1.FOLDERNAME.output), targetBuildPath, '555', {
68
73
  replace: false
@@ -12,10 +12,13 @@ exports.default = Object.freeze({
12
12
  serve_port: {
13
13
  http: {
14
14
  master: 3000,
15
+ appsail: {
16
+ master: 3000,
17
+ service: 3060
18
+ },
15
19
  advancedio: 3010,
16
20
  basicio: 3040,
17
21
  client: 3050,
18
- appsail: 3060,
19
22
  browser_logic: 3100
20
23
  },
21
24
  debug: {
@@ -47,6 +47,7 @@ exports.default = Object.freeze({
47
47
  notification_web: 'ZohoCatalyst.notifications.web',
48
48
  search_read: 'ZohoCatalyst.search.READ',
49
49
  zia: 'ZohoCatalyst.mlkit.READ',
50
+ zia_hub: 'ZiaHub.deployment.READ',
50
51
  circuits_execute: 'ZohoCatalyst.circuits.execute',
51
52
  circuits_exe_read: 'ZohoCatalyst.circuits.execution.READ',
52
53
  circuits_exe_delete: 'ZohoCatalyst.circuits.execution.DELETE',
@@ -94,15 +94,16 @@ function walk(dir, { filter = {
94
94
  excludeDir: true
95
95
  }, depth = -1, includeDirPaths = false } = {}) {
96
96
  return __awaiter(this, void 0, void 0, function* () {
97
+ const stats = yield fs_extra_1.default.lstat(dir);
97
98
  if (depth === 0) {
98
- return includeDirPaths ? [dir] : [];
99
+ return includeDirPaths ? [{ path: dir, stats }] : [];
99
100
  }
100
- const isDir = yield fs_extra_1.default.stat(dir).then((stat) => stat.isDirectory());
101
+ const isDir = stats.isDirectory() && !stats.isSymbolicLink();
101
102
  const files = isDir ? yield fs_extra_1.default.readdir(dir) : [path_1.default.basename(dir)];
102
103
  const folderContentPromise = files.map((entry) => __awaiter(this, void 0, void 0, function* () {
103
104
  const entryPath = isDir ? path_1.default.join(dir, entry) : dir;
104
- const stats = yield fs_extra_1.default.stat(entryPath);
105
- const isEntryPthDir = stats.isDirectory();
105
+ const entryPathStats = yield fs_extra_1.default.lstat(entryPath);
106
+ const isEntryPthDir = entryPathStats.isDirectory() && !entryPathStats.isSymbolicLink();
106
107
  let excludeMatch = false;
107
108
  if (!(isEntryPthDir && !filter.excludeDir)) {
108
109
  for (const glob of filter.exclude || []) {
@@ -114,10 +115,10 @@ function walk(dir, { filter = {
114
115
  }
115
116
  return isEntryPthDir && depth !== 0
116
117
  ? walk(entryPath, { filter, depth: depth - 1, includeDirPaths })
117
- : [entryPath];
118
+ : [{ path: entryPath, stats: entryPathStats }];
118
119
  }));
119
120
  const folderContents = yield Promise.all(folderContentPromise);
120
- return folderContents.reduce((all, folderContent) => all.concat(folderContent), includeDirPaths ? [dir] : []);
121
+ return folderContents.reduce((all, folderContent) => all.concat(folderContent), includeDirPaths ? [{ path: dir, stats }] : []);
121
122
  });
122
123
  }
123
124
  exports.walk = walk;
@@ -193,7 +194,7 @@ const findAndReplace = (pth) => (templates, finalWords) => __awaiter(void 0, voi
193
194
  }
194
195
  const files = yield walk(pth);
195
196
  yield Promise.all(files.map((file) => __awaiter(void 0, void 0, void 0, function* () {
196
- let content = yield readFile(file);
197
+ let content = yield readFile(file.path);
197
198
  if (content === undefined) {
198
199
  return Promise.resolve();
199
200
  }
@@ -205,7 +206,7 @@ const findAndReplace = (pth) => (templates, finalWords) => __awaiter(void 0, voi
205
206
  else {
206
207
  content = content.replace(new RegExp(templates, 'g'), finalWords);
207
208
  }
208
- return writeFile(file, content);
209
+ return writeFile(file.path, content);
209
210
  })));
210
211
  });
211
212
  exports.findAndReplace = findAndReplace;
@@ -239,7 +240,7 @@ function chmod(path, mode, { checkPath = true, recursive = false } = {}) {
239
240
  if (recursive && (yield dirExists(path))) {
240
241
  const paths = yield walk(path, { includeDirPaths: true, depth: 1 });
241
242
  paths.shift();
242
- yield Promise.all(paths.map((_path) => chmod(_path, mode, { recursive, checkPath })));
243
+ yield Promise.all(paths.map((_path) => chmod(_path.path, mode, { recursive, checkPath })));
243
244
  }
244
245
  return fs_extra_1.default.chmod(path, mode);
245
246
  });
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.writeJSONFile = exports.readJSONFile = exports.emptyDir = exports.copyDir = exports.copyFiles = exports.copyFile = exports.deleteTempDir = exports.tempFile = exports.deleteDir = exports.isPathInside = exports.isPathOutside = exports.renameFile = exports.modifyFileName = exports.appendFile = exports.writeFile = exports.ensureFile = exports.ensureDir = exports.readFile = exports.deleteFile = exports.getAllFiles = exports.getAllDirs = exports.dirExists = exports.fileExists = exports.getReadStream = exports.getWriteStream = void 0;
6
+ exports.writeJSONFile = exports.readJSONFile = exports.emptyDir = exports.copyDir = exports.copyFiles = exports.copyFile = exports.deleteTempDir = exports.tempFile = exports.deleteDir = exports.isPathInside = exports.isPathOutside = exports.renameFile = exports.modifyFileName = exports.appendFile = exports.writeFile = exports.ensureFile = exports.ensureDir = exports.readFile = exports.deleteFile = exports.getAllFiles = exports.getAllDirs = exports.dirExists = exports.fileExists = exports.readSymLink = exports.getReadStream = exports.getWriteStream = void 0;
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const os_1 = __importDefault(require("os"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -15,6 +15,10 @@ function getReadStream(pth) {
15
15
  return fs_extra_1.default.createReadStream(pth);
16
16
  }
17
17
  exports.getReadStream = getReadStream;
18
+ function readSymLink(pth) {
19
+ return fs_extra_1.default.readlinkSync(pth);
20
+ }
21
+ exports.readSymLink = readSymLink;
18
22
  function fileExists(pth) {
19
23
  try {
20
24
  const stats = fs_extra_1.default.statSync(pth);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcatalyst-cli",
3
- "version": "1.15.0-beta.5",
3
+ "version": "1.15.0-beta.6",
4
4
  "description": "Command Line Tool for CATALYST",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -7,6 +7,7 @@ public class FallbackHandler {
7
7
  JSONObject jsonResponse = new JSONObject();
8
8
  LOGGER.info("Fallback Handler : : TODO : "+ reqBody.get("todo"));
9
9
  jsonResponse.put("message", "Fallback Response: Please define this question and try again");
10
+ jsonResponse.put("status", "handled");
10
11
  return jsonResponse;
11
12
  }
12
13
  }
@@ -5,6 +5,7 @@ export default function handleFallback(request) {
5
5
  logger.info('Handling fallback request');
6
6
 
7
7
  return {
8
+ "status" : "handled",
8
9
  "message": "Fallback Response: Please define this question and try again"
9
10
  };
10
11
  }
@@ -11,5 +11,6 @@ def handle_fallback_request(req_body):
11
11
  logging.info('Handling fallback request')
12
12
 
13
13
  return {
14
- 'message': 'Fallback Response: Please define this question and try again'
14
+ 'message': 'Fallback Response: Please define this question and try again',
15
+ 'status':'handled'
15
16
  }