zcatalyst-cli 1.15.0-beta.2 → 1.15.0-beta.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.
Files changed (122) hide show
  1. package/lib/appsail-utils.js +84 -0
  2. package/lib/archiver.js +18 -1
  3. package/lib/code-deck.js +114 -0
  4. package/lib/command_needs/rc.js +7 -6
  5. package/lib/commands/appsail/add.js +55 -0
  6. package/lib/commands/codelib/install.js +143 -0
  7. package/lib/commands/config/set.js +1 -1
  8. package/lib/commands/deploy/appsail.js +62 -0
  9. package/lib/commands/{deploy.js → deploy/index.js} +20 -14
  10. package/lib/commands/iac/pack.js +3 -3
  11. package/lib/commands/index.js +2 -0
  12. package/lib/commands/init.js +5 -1
  13. package/lib/commands/pull.js +1 -1
  14. package/lib/commands/serve.js +1 -1
  15. package/lib/commands/whoami.js +2 -1
  16. package/lib/deploy/features/appsail/index.js +246 -0
  17. package/lib/deploy/features/appsail/utils.js +91 -0
  18. package/lib/deploy/features/functions/index.js +12 -10
  19. package/lib/deploy/features/index.js +3 -0
  20. package/lib/deploy/index.js +3 -3
  21. package/lib/endpoints/index.js +22 -1
  22. package/lib/endpoints/lib/appsail.js +98 -0
  23. package/lib/endpoints/lib/code-deck.js +71 -0
  24. package/lib/endpoints/lib/common.js +8 -5
  25. package/lib/endpoints/lib/git-hub.js +148 -0
  26. package/lib/endpoints/lib/iac.js +15 -0
  27. package/lib/endpoints/lib/sdk.js +4 -1
  28. package/lib/execute-script.js +35 -27
  29. package/lib/fn-utils/lib/browserLogic.js +17 -20
  30. package/lib/fn-utils/lib/common.js +3 -4
  31. package/lib/fn-utils/lib/integ.js +6 -4
  32. package/lib/fn-utils/lib/java.js +7 -1
  33. package/lib/fn-watcher.js +3 -0
  34. package/lib/iac/status/deploy.js +26 -4
  35. package/lib/iac/status/util/index.js +3 -0
  36. package/lib/init/dependencies/python/ensure-python.js +2 -2
  37. package/lib/init/dependencies/python/pip-install.js +4 -4
  38. package/lib/init/features/appsail/index.js +213 -0
  39. package/lib/init/features/functions/index.js +5 -72
  40. package/lib/init/features/functions/languages/java.js +7 -3
  41. package/lib/init/features/functions/languages/node.js +9 -7
  42. package/lib/init/features/functions/languages/python.js +1 -1
  43. package/lib/init/features/index.js +28 -12
  44. package/lib/init/features/project.js +3 -3
  45. package/lib/init/index.js +1 -1
  46. package/lib/init/util/common.js +103 -0
  47. package/lib/internal/api.js +5 -5
  48. package/lib/internal/command.js +26 -3
  49. package/lib/option-filter.js +40 -21
  50. package/lib/prompt/index.js +5 -0
  51. package/lib/prompt/types/file-path.js +4 -1
  52. package/lib/prompt/types/tree.js +297 -0
  53. package/lib/pull/features/functions/index.js +70 -47
  54. package/lib/serve/features/appsail.js +37 -0
  55. package/lib/serve/features/index.js +8 -1
  56. package/lib/serve/index.js +23 -6
  57. package/lib/serve/server/index.js +111 -233
  58. package/lib/serve/server/lib/appsail/index.js +134 -0
  59. package/lib/serve/server/lib/appsail/start.js +75 -0
  60. package/lib/serve/server/lib/java/index.js +54 -0
  61. package/lib/serve/server/lib/master.js +84 -60
  62. package/lib/serve/server/lib/node/index.js +85 -74
  63. package/lib/serve/server/lib/node/server/index.js +77 -0
  64. package/lib/serve/server/lib/python/index.js +46 -0
  65. package/lib/serve/server/lib/web_client/index.js +33 -0
  66. package/lib/serve/server/lib/web_client/server.js +3 -0
  67. package/lib/shell/dependencies/http-functions.js +7 -7
  68. package/lib/shell/dependencies/local-function.js +6 -6
  69. package/lib/shell/prepare/index.js +1 -1
  70. package/lib/shell/prepare/languages/index.js +3 -3
  71. package/lib/shell/prepare/languages/java.js +2 -2
  72. package/lib/util_modules/config/index.js +3 -1
  73. package/lib/util_modules/config/lib/appSail.js +89 -0
  74. package/lib/util_modules/constants/index.js +3 -1
  75. package/lib/util_modules/constants/lib/default.js +4 -2
  76. package/lib/util_modules/constants/lib/file-names.js +4 -1
  77. package/lib/util_modules/constants/lib/runtime.js +12 -3
  78. package/lib/util_modules/constants/lib/scopes.js +4 -0
  79. package/lib/util_modules/constants/lib/template.js +23 -20
  80. package/lib/util_modules/constants/lib/urls.js +5 -0
  81. package/lib/util_modules/context-help.js +3 -0
  82. package/lib/util_modules/fs/lib/async.js +10 -3
  83. package/lib/util_modules/fs/lib/sync.js +2 -2
  84. package/lib/util_modules/js.js +4 -0
  85. package/lib/util_modules/project.js +2 -2
  86. package/lib/util_modules/server.js +2 -1
  87. package/package.json +1 -1
  88. package/scripts/postInstall.js +27 -18
  89. package/templates/init/functions/java/browserLogic/playwright/sample.java +1 -1
  90. package/templates/init/functions/java/browserLogic/selenium/sample.java +1 -1
  91. package/templates/init/functions/node/browserlogic/playwright/sample.js +1 -1
  92. package/templates/init/functions/node/browserlogic/puppeteer/sample.js +1 -1
  93. package/templates/init/functions/node/browserlogic/selenium/sample.js +1 -1
  94. package/templates/init/functions/node/integ/cliq/package.json +1 -0
  95. package/templates/init/functions/python/aio/requirements.txt +1 -1
  96. package/templates/init/functions/python/bio/requirements.txt +1 -1
  97. package/templates/init/functions/python/cron/requirements.txt +1 -1
  98. package/templates/init/functions/python/event/requirements.txt +1 -1
  99. package/templates/init/functions/python/integ/cliq/requirements.txt +1 -1
  100. /package/lib/serve/server/lib/java/{JavaaioServer.java → aio_server/JavaaioServer.java} +0 -0
  101. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/catalyst-cli-java-runtime-1.0.0.jar +0 -0
  102. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/catalyst-function-sdk-1.0.0.jar +0 -0
  103. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/catalyst-java-runtime-1.0.0.jar +0 -0
  104. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/gradle-wrapper.jar +0 -0
  105. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-http-9.3.24.v20180605.jar +0 -0
  106. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-io-9.3.24.v20180605.jar +0 -0
  107. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-security-9.3.24.v20180605.jar +0 -0
  108. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-server-9.3.24.v20180605.jar +0 -0
  109. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-servlet-9.3.24.v20180605.jar +0 -0
  110. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/jetty-util-9.3.24.v20180605.jar +0 -0
  111. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/org.json.jar +0 -0
  112. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/servlet-api-3.1.jar +0 -0
  113. /package/lib/serve/server/lib/java/{lib → aio_server/lib}/zip4j-2.5.0.jar +0 -0
  114. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/browserlogic-playwright.js +0 -0
  115. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/browserlogic-puppeteer.js +0 -0
  116. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/browserlogic-selenium.js +0 -0
  117. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/index.js +0 -0
  118. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/deferred_promise.js +0 -0
  119. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/playwright-handler.js +0 -0
  120. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/puppeteer-handler.js +0 -0
  121. /package/lib/serve/server/lib/node/{browserlogic → server/browserlogic}/utils/selenium-handler.js +0 -0
  122. /package/lib/serve/server/lib/node/{package.json → server/package.json} +0 -0
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ var _CodeDeck_instances, _CodeDeck_manifest;
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const error_1 = __importDefault(require("../../error"));
22
+ const api_1 = __importDefault(require("../../internal/api"));
23
+ const constants_1 = require("../../util_modules/constants");
24
+ const logger_1 = require("../../util_modules/logger");
25
+ class CodeDeck {
26
+ constructor(opts) {
27
+ _CodeDeck_instances.add(this);
28
+ this.opts = opts;
29
+ }
30
+ data() {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const manifestData = yield __classPrivateFieldGet(this, _CodeDeck_instances, "m", _CodeDeck_manifest).call(this);
33
+ if (!manifestData['data.json']) {
34
+ throw new error_1.default('Invalid manifest data', { exit: 2 });
35
+ }
36
+ const res = yield new api_1.default(this.opts).get(`/catalyst-library/codelib/${manifestData['data.json']}`, {
37
+ json: true,
38
+ origin: constants_1.ORIGIN.zohoCDN,
39
+ headers: {
40
+ 'Cache-Control': 'no-cache'
41
+ }
42
+ });
43
+ if (res.body) {
44
+ return res.body;
45
+ }
46
+ (0, logger_1.debug)('Code Lib data json response from server : ' + res.body);
47
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
48
+ exit: 2
49
+ });
50
+ });
51
+ }
52
+ }
53
+ exports.default = CodeDeck;
54
+ _CodeDeck_instances = new WeakSet(), _CodeDeck_manifest = function _CodeDeck_manifest() {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ const res = yield new api_1.default(this.opts).get('/catalyst-library/codelib/config.json', {
57
+ json: true,
58
+ origin: constants_1.ORIGIN.zohoCDN,
59
+ headers: {
60
+ 'Cache-Control': 'no-cache'
61
+ }
62
+ });
63
+ if (res.body) {
64
+ return res.body;
65
+ }
66
+ (0, logger_1.debug)('Code Lib manifest json response from server : ' + res.body);
67
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
68
+ exit: 2
69
+ });
70
+ });
71
+ };
@@ -14,6 +14,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const ansi_colors_1 = require("ansi-colors");
16
16
  const api_1 = __importDefault(require("../../internal/api"));
17
+ const logger_1 = require("../../util_modules/logger");
18
+ const error_1 = __importDefault(require("../../error"));
17
19
  class Common {
18
20
  download(url, title) {
19
21
  return __awaiter(this, void 0, void 0, function* () {
@@ -28,10 +30,8 @@ class Common {
28
30
  reqOpts.log = {
29
31
  progress: {
30
32
  title,
31
- failure: (err) => {
32
- return (0, ansi_colors_1.red)(`Download failure with error: ` +
33
- (err instanceof Error ? err.message : err) || 'Unknown error');
34
- }
33
+ failure: (err) => (0, ansi_colors_1.red)(`Download failure with error: ` +
34
+ (err instanceof Error ? err.message : err) || 'Unknown error')
35
35
  }
36
36
  };
37
37
  }
@@ -39,7 +39,10 @@ class Common {
39
39
  if (res.status === 200 && res.body) {
40
40
  return res.body;
41
41
  }
42
- return;
42
+ (0, logger_1.debug)('Download response from server : ' + res.body);
43
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
44
+ exit: 2
45
+ });
43
46
  });
44
47
  }
45
48
  }
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const console_1 = require("console");
16
+ const error_1 = __importDefault(require("../../error"));
17
+ const api_1 = __importDefault(require("../../internal/api"));
18
+ const constants_1 = require("../../util_modules/constants");
19
+ const ansi_colors_1 = require("ansi-colors");
20
+ class GitHub {
21
+ constructor() {
22
+ this.opts = {
23
+ authNeeded: false,
24
+ origin: constants_1.ORIGIN.external.gitHubAPI,
25
+ isExternal: true
26
+ };
27
+ }
28
+ getGitHubLatestRelease(repo) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ const res = yield new api_1.default(this.opts).get(`/repos/catalystbyzoho/${repo}/releases/latest`);
31
+ if (res.body) {
32
+ return res.body;
33
+ }
34
+ (0, console_1.debug)('Get GitHub latest release response from server : ' + res.body);
35
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
36
+ exit: 2
37
+ });
38
+ });
39
+ }
40
+ getLatestZipUrl(repo) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const latest = yield this.getGitHubLatestRelease(repo);
43
+ return new URL(latest.zipball_url).pathname;
44
+ });
45
+ }
46
+ appsailNodejs() {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ const res = yield new api_1.default(this.opts).get(yield this.getLatestZipUrl('appsail-nodejs'), {
49
+ encoding: null,
50
+ log: { progress: { title: 'Code' } }
51
+ });
52
+ if (res.body) {
53
+ return res.body;
54
+ }
55
+ (0, console_1.debug)('Code Download response from server : ' + res.body);
56
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
57
+ exit: 2
58
+ });
59
+ });
60
+ }
61
+ appsailJava() {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ const res = yield new api_1.default(this.opts).get(yield this.getLatestZipUrl('appsail-java'), {
64
+ encoding: null,
65
+ log: { progress: { title: 'Code' } }
66
+ });
67
+ if (res.body) {
68
+ return res.body;
69
+ }
70
+ (0, console_1.debug)('Code Download response from server : ' + res.body);
71
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
72
+ exit: 2
73
+ });
74
+ });
75
+ }
76
+ appsailPython() {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ const res = yield new api_1.default(this.opts).get(yield this.getLatestZipUrl('appsail-python'), {
79
+ encoding: null,
80
+ log: { progress: { title: 'Code' } }
81
+ });
82
+ if (res.body) {
83
+ return res.body;
84
+ }
85
+ (0, console_1.debug)('Code Download response from server : ' + res.body);
86
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
87
+ exit: 2
88
+ });
89
+ });
90
+ }
91
+ validateUrl(url) {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ let _url;
94
+ try {
95
+ _url = new URL(url);
96
+ }
97
+ catch (err) {
98
+ throw new error_1.default('Invalid GitHub repo URL: ' + url, { original: err });
99
+ }
100
+ const res = yield new api_1.default({
101
+ isExternal: true,
102
+ showWarning: false,
103
+ resolveOnError: true,
104
+ authNeeded: false,
105
+ headers: {
106
+ 'Cache-control': 'no-cache'
107
+ },
108
+ origin: constants_1.ORIGIN.external.gitHubWeb
109
+ }).head(_url.pathname);
110
+ if (res.status) {
111
+ return res.status;
112
+ }
113
+ (0, console_1.debug)('Git hub head response from server : ' + res.body);
114
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
115
+ exit: 2
116
+ });
117
+ });
118
+ }
119
+ download(url, title) {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ const _url = new URL(url);
122
+ const reqOpts = {
123
+ json: false,
124
+ encoding: null,
125
+ resolveOnError: true
126
+ };
127
+ if (title !== null) {
128
+ reqOpts.log = {
129
+ progress: {
130
+ title: 'CodeLib' + (title ? ` (${title})` : ''),
131
+ failure: (err) => {
132
+ return (0, ansi_colors_1.red)(`CodeLib download failure with error: ` +
133
+ (err instanceof Error ? err.message : err) || 'Unknown error');
134
+ }
135
+ }
136
+ };
137
+ }
138
+ const res = yield new api_1.default({ origin: constants_1.ORIGIN.external.gitHubWeb }).get(_url.pathname +
139
+ (_url.pathname.endsWith('/') ? '' : '/') +
140
+ 'releases/latest/download/release.zip', reqOpts);
141
+ if (res.status === 200 && res.body) {
142
+ return res.body;
143
+ }
144
+ return;
145
+ });
146
+ }
147
+ }
148
+ exports.default = GitHub;
@@ -39,6 +39,21 @@ class IacAPI {
39
39
  throw new error_1.default('Server Error: Unexpected Response from server.', { exit: 2 });
40
40
  });
41
41
  }
42
+ update(file) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const res = yield new api_1.default(this.opts).put(`/baas/v1/project/${this.projectId}/import`, {
45
+ formData: {
46
+ code: file
47
+ },
48
+ json: false
49
+ });
50
+ if (res.body && res.body.data) {
51
+ return res.body.data;
52
+ }
53
+ (0, logger_1.debug)('deploy response from server : ' + JSON.stringify(res.body));
54
+ throw new error_1.default('Server Error: Unexpected Response from server.', { exit: 2 });
55
+ });
56
+ }
42
57
  bundle(format) {
43
58
  return __awaiter(this, void 0, void 0, function* () {
44
59
  const res = yield new api_1.default(this.opts).post(`/baas/v1/project/${this.projectId}/export`, {
@@ -29,7 +29,7 @@ class SDK {
29
29
  return `/downloads/sdk/java/${constants_1.INTEG.service_map[service]}/${constants_1.INTEG.java_dependencies[service]}_latest.zip`;
30
30
  }
31
31
  case constants_1.FN_TYPE.browserLogic: {
32
- return `/downloads/sdk/java/catalyst-java-sdk-1.12.0-beta01.zip`;
32
+ return `/downloads/sdk/java/catalyst_java_sdk_beta.zip`;
33
33
  }
34
34
  default: {
35
35
  return `/downloads/sdk/java/catalyst_java_sdk_latest.zip`;
@@ -44,6 +44,9 @@ class SDK {
44
44
  json: false,
45
45
  encoding: null,
46
46
  origin: constants_1.ORIGIN.catalystStatic,
47
+ headers: {
48
+ 'Cache-Control': 'no-cache'
49
+ },
47
50
  log: {
48
51
  progress: {
49
52
  title: (_a = targetSDK.split('/').pop()) === null || _a === void 0 ? void 0 : _a.replace(new RegExp('_', 'g'), '-')
@@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.executeCommand = void 0;
29
30
  const ansi_colors_1 = require("ansi-colors");
30
31
  const error_1 = __importDefault(require("./error"));
31
32
  const runtime_store_1 = __importDefault(require("./runtime-store"));
@@ -36,6 +37,36 @@ const js_1 = require("./util_modules/js");
36
37
  const logger_1 = require("./util_modules/logger");
37
38
  const project_1 = require("./util_modules/project");
38
39
  const shell_1 = require("./util_modules/shell");
40
+ function executeCommand(exeCommand, { moduleSource, feature }) {
41
+ const cwd = moduleSource || runtime_store_1.default.get('project.root');
42
+ const exeDir = (0, project_1.resolveProjectPath)(cwd);
43
+ (0, logger_1.info)();
44
+ (0, logger_1.info)(`Executing ${(0, ansi_colors_1.cyan)(feature)} script in ${(0, ansi_colors_1.underline)(exeDir)}`);
45
+ (0, logger_1.debug)('Executing command > ' + exeCommand);
46
+ (0, logger_1.info)(`> ${exeCommand}`);
47
+ const exitListeners = process.listeners('exit');
48
+ process.removeAllListeners('exit');
49
+ const result = (0, shell_1.spawn)(exeCommand, [], {
50
+ cwd: exeDir,
51
+ shell: true,
52
+ stdio: 'inherit'
53
+ }).SYNC();
54
+ if ((0, env_1.isPrimaryShell)()) {
55
+ js_1.JS.forEach(exitListeners || [], (listener) => {
56
+ process.addListener('exit', listener);
57
+ });
58
+ }
59
+ if (result.status === null || result.status > 0 || result.error) {
60
+ throw new error_1.default('The script exited with code greater than 0 or an error', {
61
+ exit: 0,
62
+ original: new Error(JSON.stringify(result)),
63
+ errorId: 'EXEC-SCRIPT-4',
64
+ arg: [(0, ansi_colors_1.bold)(feature), ansi_colors_1.italic.red(JSON.stringify(result, null, ' '))]
65
+ });
66
+ }
67
+ return result;
68
+ }
69
+ exports.executeCommand = executeCommand;
39
70
  exports.default = (commandName) => {
40
71
  const featureByScript = commandName.split(':');
41
72
  if (featureByScript.length !== 2) {
@@ -84,31 +115,8 @@ exports.default = (commandName) => {
84
115
  })
85
116
  .join(' ')
86
117
  .value();
87
- const workingDir = runtime_store_1.default.get('project.root', configModule.source());
88
- const exeDir = (0, project_1.resolveProjectPath)(workingDir);
89
- (0, logger_1.info)();
90
- (0, logger_1.info)(`Executing ${(0, ansi_colors_1.cyan)(featureByScript[1])} script in ${(0, ansi_colors_1.underline)(exeDir)}`);
91
- (0, logger_1.debug)('Executing command > ' + exeCommand);
92
- (0, logger_1.info)(`> ${exeCommand}`);
93
- const exitListeners = process.listeners('exit');
94
- process.removeAllListeners('exit');
95
- const result = (0, shell_1.spawn)(exeCommand, [], {
96
- cwd: exeDir,
97
- shell: true,
98
- stdio: 'inherit'
99
- }).SYNC();
100
- if ((0, env_1.isPrimaryShell)()) {
101
- js_1.JS.forEach(exitListeners || [], (listner) => {
102
- process.addListener('exit', listner);
103
- });
104
- }
105
- if (result.status === null || result.status > 0 || result.error) {
106
- throw new error_1.default('The script exited with code greater than 0 or an error', {
107
- exit: 0,
108
- original: new Error(JSON.stringify(result)),
109
- errorId: 'EXEC-SCRIPT-4',
110
- arg: [(0, ansi_colors_1.bold)(commandName), ansi_colors_1.italic.red(JSON.stringify(result, null, ' '))]
111
- });
112
- }
113
- return result;
118
+ return executeCommand(exeCommand, {
119
+ moduleSource: configModule.source(),
120
+ feature: featureByScript[1]
121
+ });
114
122
  };
@@ -43,28 +43,25 @@ exports.getBrowserLogicFramework = getBrowserLogicFramework;
43
43
  function downloadJavaDependencies(path, deps, isZip = true) {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
45
  const _commonAPI = yield (0, endpoints_1.commonAPI)();
46
- return Promise.all(deps.map((dep) => {
47
- return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
48
- try {
49
- const fileName = (0, path_1.basename)(dep);
50
- const res = yield _commonAPI.download(dep, fileName);
51
- yield fs_1.ASYNC.ensureDir(path);
52
- if (isZip) {
53
- const zip = new archiver_1.default();
54
- zip.load(res).extract(path);
55
- yield zip.finalize();
56
- }
57
- else {
58
- yield fs_1.ASYNC.writeFile((0, path_1.join)(path, fileName), res);
59
- }
46
+ return Promise.all(deps.map((dep) => __awaiter(this, void 0, void 0, function* () {
47
+ try {
48
+ const fileName = (0, path_1.basename)(dep);
49
+ const res = yield _commonAPI.download(dep, fileName);
50
+ yield fs_1.ASYNC.ensureDir(path);
51
+ if (isZip) {
52
+ const zip = new archiver_1.default();
53
+ zip.load(res).extract(path);
54
+ yield zip.finalize();
60
55
  }
61
- catch (err) {
62
- (0, logger_1.labeled)(`Browser Logic[${name}]`, 'Unable to download the dependencies because of the following error');
63
- (0, logger_1.error)((0, util_1.inspect)(err));
56
+ else {
57
+ yield fs_1.ASYNC.writeFile((0, path_1.join)(path, fileName), res);
64
58
  }
65
- resolve();
66
- }));
67
- }));
59
+ }
60
+ catch (err) {
61
+ (0, logger_1.labeled)(`Browser Logic[${name}]`, 'Unable to download the dependencies because of the following error');
62
+ (0, logger_1.error)((0, util_1.inspect)(err));
63
+ }
64
+ })));
68
65
  });
69
66
  }
70
67
  exports.downloadJavaDependencies = downloadJavaDependencies;
@@ -159,7 +159,6 @@ function refineTargets(rawTargets, mapRemoteFn = true) {
159
159
  name: (0, path_1.basename)(fnPath),
160
160
  source: fnPath,
161
161
  valid: false,
162
- type: constants_1.FN_TYPE.basic,
163
162
  failure_reason: 'there is no valid ' + constants_1.FILENAME.catalyst_config + ' file present'
164
163
  };
165
164
  }
@@ -297,7 +296,7 @@ function pack(target) {
297
296
  }
298
297
  }
299
298
  const zip = new archiver_1.default(target.name);
300
- if ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java)) {
299
+ if ((_a = target.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.java.value)) {
301
300
  const outputFolder = (0, path_1.join)(source, constants_1.FOLDERNAME.output);
302
301
  const outputFiles = yield fs_1.ASYNC.walk(outputFolder);
303
302
  outputFiles.forEach((file) => {
@@ -311,7 +310,7 @@ function pack(target) {
311
310
  zip.add(file.replace(source + path_1.sep, ''), fs_1.SYNC.getReadStream(file));
312
311
  });
313
312
  }
314
- if ((_b = target.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.python)) {
313
+ if ((_b = target.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.python.value)) {
315
314
  const reqFile = (0, path_1.join)(target.source, constants_1.FILENAME.functions.python_requirements);
316
315
  const requirementsExists = yield fs_1.ASYNC.readFile(reqFile);
317
316
  if (requirementsExists) {
@@ -382,7 +381,7 @@ function resolveAllFnPorts(targets, idx = 0) {
382
381
  switch ((0, option_1.getCurrentCommand)()) {
383
382
  case 'serve':
384
383
  const isPyBio = currentTargetType === constants_1.FN_TYPE.basic &&
385
- ((_a = currentTarget.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python));
384
+ ((_a = currentTarget.stack) === null || _a === void 0 ? void 0 : _a.startsWith(runtime_1.default.language.python.value));
386
385
  httpPort = yield port_resolver_1.default.getPort(constants_1.REMOTE_REF.functions.type[currentTargetType], 'http', currentTarget.name, currentTargetType === constants_1.FN_TYPE.advanced ||
387
386
  currentTargetType === constants_1.FN_TYPE.browserLogic, isPyBio);
388
387
  runtime_store_1.default.set('context.port.http.functions.' + currentTarget.name, httpPort);
@@ -78,7 +78,7 @@ function copyIntegHandlers(templatePath, targetPath, lang) {
78
78
  switch (service) {
79
79
  case constants_1.INTEG.services.cliq:
80
80
  const handlers = runtime_store_1.default.get('context.function.integration.cliq.handlers', []);
81
- if (lang === runtime_1.default.language.nodejs) {
81
+ if (lang === runtime_1.default.language.node.value) {
82
82
  const filePaths = constants_1.CLIQ.node_template_contents_initial_copy.map((path) => (0, path_1.join)(templatePath, path));
83
83
  yield fs_1.ASYNC.copyFiles(filePaths, targetPath);
84
84
  const integHandlerConfig = {};
@@ -89,18 +89,20 @@ function copyIntegHandlers(templatePath, targetPath, lang) {
89
89
  yield fs_1.ASYNC.copyFiles(handlerPaths, (0, path_1.join)(targetPath, constants_1.CLIQ.node_handlers_template_dir));
90
90
  integ_config.handlers = integHandlerConfig;
91
91
  }
92
- else if (lang === runtime_1.default.language.java) {
92
+ else if (lang === runtime_1.default.language.java.value) {
93
93
  const filePaths = constants_1.CLIQ.java_template_contents_initial_copy.map((path) => (0, path_1.join)(templatePath, path));
94
94
  yield fs_1.ASYNC.copyFiles(filePaths, targetPath);
95
95
  const integHandlerConfig = {};
96
96
  const handlerPaths = handlers.map((handler) => {
97
- integHandlerConfig[handler] = (0, path_1.join)(constants_1.CLIQ.java_handlers_path, constants_1.CLIQ.java_handler_file_mapping[handler].replace('.java', ''));
97
+ integHandlerConfig[handler] =
98
+ constants_1.CLIQ.java_handlers_path +
99
+ constants_1.CLIQ.java_handler_file_mapping[handler].replace('.java', '');
98
100
  return (0, path_1.join)(templatePath, constants_1.CLIQ.java_handlers_template_dir, constants_1.CLIQ.java_handler_file_mapping[handler]);
99
101
  });
100
102
  yield fs_1.ASYNC.copyFiles(handlerPaths, (0, path_1.join)(targetPath, constants_1.CLIQ.java_handlers_template_dir));
101
103
  integ_config.handlers = integHandlerConfig;
102
104
  }
103
- else if (lang === runtime_1.default.language.python) {
105
+ else if (lang === runtime_1.default.language.python.value) {
104
106
  const filePaths = constants_1.CLIQ.python_template_contents_initial_copy.map((path) => (0, path_1.join)(templatePath, path));
105
107
  yield fs_1.ASYNC.copyFiles(filePaths, targetPath);
106
108
  const integHandlerConfig = {};
@@ -433,12 +433,18 @@ function getTemplatePath(target) {
433
433
  const targetType = target.type;
434
434
  switch (targetType) {
435
435
  case constants_1.FN_TYPE.integration: {
436
- return js_1.JS.get(constants_1.TEMPLATE.functions.java.integ, js_1.JS.get(target.integ_config[0], 'service', ''));
436
+ if (!Array.isArray(target.integ_config) || target.integ_config.length === 0) {
437
+ throw new error_1.default('Invalid integ_config', { exit: 2 });
438
+ }
439
+ return constants_1.TEMPLATE.functions.java.integ[target.integ_config[0].service];
437
440
  }
438
441
  case constants_1.FN_TYPE.browserLogic: {
439
442
  return constants_1.TEMPLATE.functions.java.browserlogic.selenium;
440
443
  }
441
444
  default: {
445
+ if (!targetType) {
446
+ throw new error_1.default('Invalid target type', { exit: 2 });
447
+ }
442
448
  return constants_1.TEMPLATE.functions.java[targetType];
443
449
  }
444
450
  }
package/lib/fn-watcher.js CHANGED
@@ -53,6 +53,9 @@ exports.default = (target) => __awaiter(void 0, void 0, void 0, function* () {
53
53
  watcher.emit('next');
54
54
  }));
55
55
  watcher.on('all', (evnt, pth) => {
56
+ if ((latestEvent === null || latestEvent === void 0 ? void 0 : latestEvent.at) && Date.now() - latestEvent.at < 1000) {
57
+ return;
58
+ }
56
59
  latestEvent = { evnt, pth, at: Date.now() };
57
60
  if (paused) {
58
61
  return;
@@ -19,8 +19,11 @@ const error_1 = __importDefault(require("../../error"));
19
19
  const throbber_1 = __importDefault(require("../../throbber"));
20
20
  const logger_1 = require("../../util_modules/logger");
21
21
  const util_1 = require("./util");
22
+ const env_1 = require("../../util_modules/env");
23
+ const ansi_colors_1 = require("ansi-colors");
24
+ const code_deck_1 = require("../../code-deck");
22
25
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
23
- const getSpinnerTxt = (0, util_1.getSpinnerTxt)('deploy');
26
+ const getSpinnerTxt = (0, util_1.getSpinnerTxt)(process.env.PARENT_COMMAND === 'codedeck' ? 'codedeck' : 'deploy');
24
27
  const idOpt = (0, option_1.getOptionValue)('id', false);
25
28
  const iacAPI = new iac_1.default();
26
29
  const allDeploys = yield iacAPI.allDeploys();
@@ -40,12 +43,16 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
40
43
  text: getSpinnerTxt(deployDetails)
41
44
  });
42
45
  const timerAPI = new api_timer_1.default(iacAPI.deployStatus.bind(iacAPI, deployDetails.id), 2000, 1);
46
+ let lastStatus;
43
47
  timerAPI.on('data', (data) => __awaiter(void 0, void 0, void 0, function* () {
44
48
  switch (data.status) {
45
49
  case 'Scheduled':
46
50
  case 'Processing':
47
51
  throbber.update(spinner, {
48
- text: getSpinnerTxt(data) + '\nPress CTRL + C to exit listening to the status'
52
+ text: getSpinnerTxt(data) +
53
+ (process.env.PARENT_COMMAND !== 'codedeck'
54
+ ? '\nPress CTRL + C to exit listening to the status'
55
+ : '')
49
56
  });
50
57
  break;
51
58
  case 'Error_Processing':
@@ -64,11 +71,26 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
64
71
  (0, logger_1.debug)('Unknown status received : ', data.status);
65
72
  timerAPI.end();
66
73
  }
74
+ lastStatus = data.status;
67
75
  }));
68
76
  timerAPI.on('error', (e) => {
69
- (0, logger_1.debug)('Error encounted : ', e);
77
+ (0, logger_1.debug)('Error encountered : ', e);
70
78
  });
71
- timerAPI.on('end', () => throbber.stopAll());
79
+ timerAPI.on('end', (_error, data) => {
80
+ if (data === true && !(0, env_1.isPrimaryShell)() && process.send) {
81
+ process.send('success');
82
+ }
83
+ throbber.stopAll();
84
+ });
85
+ process.env.PARENT_COMMAND === 'codedeck' &&
86
+ process.on('exit', () => {
87
+ if (lastStatus === 'Scheduled' || lastStatus === 'Processing') {
88
+ (0, logger_1.info)();
89
+ (0, logger_1.message)((0, ansi_colors_1.bold)('You can listen to the status of this CodeLib install by executing the below command'));
90
+ process.env.GIT_URL &&
91
+ (0, logger_1.info)(`catalyst codelib:install --continue ${code_deck_1.CodeDeckToken.createToken(deployDetails.id, process.env.GIT_URL)}`);
92
+ }
93
+ });
72
94
  timerAPI.start();
73
95
  yield timerAPI.waitForEnd();
74
96
  });
@@ -18,6 +18,9 @@ const getSpinnerTxt = (type) => (deployDetails, status) => {
18
18
  logs.push('Error while validating : ');
19
19
  logs.push(...validationError);
20
20
  }
21
+ if (type === 'codedeck') {
22
+ return ['Status >> ' + (status ? status : deployDetails.status), ...logs].join('\n' + ' '.repeat(status ? 2 : 4));
23
+ }
21
24
  return [
22
25
  `${type === 'bundle' ? 'Export' : 'Import'} Project "${deployDetails.project_details.project_name}" ${status ? status : deployDetails.status.toLowerCase()}`,
23
26
  ...logs
@@ -74,7 +74,7 @@ function ensurePython(version, fallBackNeeded, skipHelp) {
74
74
  }
75
75
  }));
76
76
  child.on('exit', (code) => {
77
- if (code == 0) {
77
+ if (code === 0) {
78
78
  userConfig_1.default.set(configKey, 'python' + version);
79
79
  }
80
80
  resolve();
@@ -95,7 +95,7 @@ function validateCommand(version, spawnCommand, skipHelp) {
95
95
  dataBuf.push(chunk);
96
96
  });
97
97
  child.on('exit', (code) => {
98
- if (code == 0) {
98
+ if (code === 0) {
99
99
  const data = Buffer.concat(dataBuf).toString();
100
100
  return resolve(data);
101
101
  }
@@ -66,12 +66,12 @@ function ensurePyRuntime(pth, stack) {
66
66
  const stackVersion = stack.replace('python_', '');
67
67
  const runtimePkgName = 'zcatalyst-runtime-' + stackVersion.replace('_', '');
68
68
  yield fs_1.ASYNC.ensureDir(pth);
69
- const runtimeDir = (0, path_1.join)(pth, runtime_1.default.language.python, `zcatalyst_runtime_${stackVersion.replace('_', '')}`);
69
+ const runtimeDir = (0, path_1.join)(pth, runtime_1.default.language.python.value, `zcatalyst_runtime_${stackVersion.replace('_', '')}`);
70
70
  const isInitializerExists = yield fs_1.ASYNC.fileExists((0, path_1.join)(runtimeDir, 'main.py'));
71
71
  if (isInitializerExists) {
72
72
  const runtimeMetaData = yield fs_1.ASYNC.readJSONFile((0, path_1.join)(runtimeDir, 'meta.json'));
73
73
  const pyRespJson = yield (0, exports.pypiRes)(runtimePkgName);
74
- if ((runtimeMetaData === null || runtimeMetaData === void 0 ? void 0 : runtimeMetaData.version) == pyRespJson.info.version) {
74
+ if ((runtimeMetaData === null || runtimeMetaData === void 0 ? void 0 : runtimeMetaData.version) === pyRespJson.info.version) {
75
75
  return;
76
76
  }
77
77
  }
@@ -96,7 +96,7 @@ function ensurePyRuntime(pth, stack) {
96
96
  }));
97
97
  });
98
98
  child.on('exit', (code) => {
99
- if (code != 0) {
99
+ if (code !== 0) {
100
100
  process.stderr.write(Buffer.concat(errData).toString());
101
101
  reject(new error_1.default(`Error while installing python${stackVersion.replace('_', '.')} runtime`, {
102
102
  exit: 1
@@ -174,7 +174,7 @@ function installRequirements(reqFile, pth, stackVersion, linuxMode = false) {
174
174
  }));
175
175
  });
176
176
  child.on('exit', (code) => {
177
- if (code != 0) {
177
+ if (code !== 0) {
178
178
  process.stderr.write(Buffer.concat(errData).toString());
179
179
  reject(new error_1.default('unable to process requirements.txt', {
180
180
  exit: 1,