zcatalyst-cli 1.9.1 → 1.11.1

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 (189) hide show
  1. package/README.md +3 -3
  2. package/docs/.DS_Store +0 -0
  3. package/docs/client-utils.toml +5 -0
  4. package/docs/command_needs/auth.toml +5 -0
  5. package/docs/commands/iac/export.toml +4 -0
  6. package/docs/commands/iac/import.toml +4 -0
  7. package/docs/commands/iac/status.toml +4 -0
  8. package/docs/commands/project/use.toml +6 -0
  9. package/docs/iac/status/bundle.toml +4 -0
  10. package/docs/plugin-loader.toml +4 -0
  11. package/docs/serve/server/index.toml +4 -0
  12. package/docs/serve/server/lib/web_client/server.toml +4 -0
  13. package/lib/api-timer.js +81 -0
  14. package/lib/apig-utils.js +17 -14
  15. package/lib/archiver.js +83 -45
  16. package/lib/authentication/login.js +4 -2
  17. package/lib/bin/catalyst.js +0 -1
  18. package/lib/client-utils.js +28 -26
  19. package/lib/client.js +0 -3
  20. package/lib/command_needs/auth.js +12 -3
  21. package/lib/command_needs/rc.js +12 -7
  22. package/lib/commands/apig/status.js +6 -4
  23. package/lib/commands/client/delete.js +3 -4
  24. package/lib/commands/client/setup.js +1 -1
  25. package/lib/commands/deploy.js +3 -1
  26. package/lib/commands/ds/export.js +3 -1
  27. package/lib/commands/ds/import.js +3 -1
  28. package/lib/commands/ds/status.js +145 -149
  29. package/lib/commands/event/generate/index.js +4 -13
  30. package/lib/commands/functions/config.js +1 -1
  31. package/lib/commands/functions/setup.js +1 -1
  32. package/lib/commands/help.js +1 -23
  33. package/lib/commands/iac/export.js +85 -0
  34. package/lib/commands/iac/import.js +210 -0
  35. package/lib/commands/iac/pack.js +129 -0
  36. package/lib/commands/iac/status.js +63 -0
  37. package/lib/commands/index.js +4 -0
  38. package/lib/commands/init.js +34 -27
  39. package/lib/commands/project/list.js +10 -6
  40. package/lib/commands/project/use.js +42 -25
  41. package/lib/commands/pull.js +1 -1
  42. package/lib/commands/serve.js +2 -1
  43. package/lib/deploy/features/functions/index.js +2 -1
  44. package/lib/deploy/index.js +3 -1
  45. package/lib/endpoints/lib/iac.js +134 -0
  46. package/lib/endpoints/lib/sdk.js +2 -2
  47. package/lib/error.js +33 -3
  48. package/lib/errorOut.js +4 -3
  49. package/lib/fn-utils/lib/common.js +37 -16
  50. package/lib/fn-utils/lib/java.js +7 -9
  51. package/lib/fn-utils/lib/node.js +7 -1
  52. package/lib/iac/status/bundle.js +82 -0
  53. package/lib/iac/status/deploy.js +74 -0
  54. package/lib/iac/status/util/index.js +26 -0
  55. package/lib/index.js +8 -14
  56. package/lib/init/dependencies/npm-install.js +2 -9
  57. package/lib/init/features/client/index.js +47 -0
  58. package/lib/init/features/client/initializers/angular.js +106 -0
  59. package/lib/init/features/client/initializers/basic.js +50 -0
  60. package/lib/init/features/client/initializers/lyte.js +61 -0
  61. package/lib/init/features/client/initializers/react.js +77 -0
  62. package/lib/init/features/functions/languages/java.js +2 -5
  63. package/lib/init/features/functions/languages/node.js +5 -6
  64. package/lib/init/features/index.js +18 -6
  65. package/lib/init/features/project.js +72 -34
  66. package/lib/init/util/client.js +96 -0
  67. package/lib/init/util/functions.js +20 -0
  68. package/lib/init/util/project.js +35 -0
  69. package/lib/internal/api.js +6 -9
  70. package/lib/internal/command.js +6 -3
  71. package/lib/internal/config.js +7 -4
  72. package/lib/migration/index.js +10 -6
  73. package/lib/option-filter.js +4 -1
  74. package/lib/optional-import.js +11 -25
  75. package/lib/plugin-loader.js +8 -2
  76. package/lib/port-resolver.js +20 -16
  77. package/lib/prompt/index.js +92 -0
  78. package/lib/prompt/types/file-path.js +95 -0
  79. package/lib/pull/features/client.js +1 -1
  80. package/lib/pull/features/functions/index.js +5 -7
  81. package/lib/pull/index.js +4 -1
  82. package/lib/serve/features/index.js +3 -1
  83. package/lib/serve/index.js +6 -1
  84. package/lib/serve/server/index.js +52 -8
  85. package/lib/serve/server/lib/master.js +24 -12
  86. package/lib/serve/server/lib/web_client/index.js +30 -0
  87. package/lib/serve/server/lib/web_client/server.js +171 -0
  88. package/lib/shell/dependencies/http-functions.js +1 -1
  89. package/lib/shell/index.js +3 -1
  90. package/lib/track.js +3 -1
  91. package/lib/util_modules/char.js +1 -1
  92. package/lib/util_modules/config/lib/apig.js +2 -1
  93. package/lib/util_modules/constants/index.js +5 -1
  94. package/lib/util_modules/constants/lib/file-names.js +2 -1
  95. package/lib/util_modules/constants/lib/iac.js +8 -0
  96. package/lib/util_modules/constants/lib/placeholders.js +1 -0
  97. package/lib/util_modules/constants/lib/plugin.js +28 -0
  98. package/lib/util_modules/constants/lib/regex.js +2 -1
  99. package/lib/util_modules/constants/lib/scopes.js +5 -0
  100. package/lib/util_modules/constants/lib/template.js +11 -1
  101. package/lib/util_modules/constants/lib/urls.js +12 -4
  102. package/lib/util_modules/constants/project.js +6 -0
  103. package/lib/util_modules/{contextHelp.js → context-help.js} +5 -1
  104. package/lib/util_modules/env.js +14 -16
  105. package/lib/util_modules/fs/lib/async.js +29 -22
  106. package/lib/util_modules/fs/utils.js +8 -0
  107. package/lib/util_modules/global-space.js +99 -0
  108. package/lib/util_modules/js.js +6 -0
  109. package/lib/util_modules/option.js +5 -1
  110. package/lib/util_modules/parser/toml.js +5 -1
  111. package/lib/util_modules/project.js +3 -0
  112. package/lib/util_modules/shell.js +9 -8
  113. package/lib/winston.js +1 -1
  114. package/package.json +11 -5
  115. package/templates/.DS_Store +0 -0
  116. package/templates/iacSuccess.html +391 -0
  117. package/templates/init/.DS_Store +0 -0
  118. package/templates/init/client/.DS_Store +0 -0
  119. package/templates/init/client/{client-package.json → basic/client-package.json} +0 -0
  120. package/templates/init/client/{index.html → basic/index.html} +0 -0
  121. package/templates/init/client/{main.css → basic/main.css} +0 -0
  122. package/templates/init/client/{main.js → basic/main.js} +0 -0
  123. package/templates/init/client/lyte/build/build.js +301 -0
  124. package/templates/init/client/lyte/build/scripts/cliDownloadScript.js +54 -0
  125. package/templates/init/client/lyte/client-package.json +5 -0
  126. package/templates/init/client/lyte/components/javascript/welcome-comp.js +13 -0
  127. package/templates/init/client/lyte/components/styles/welcome-comp.css +0 -0
  128. package/templates/init/client/lyte/components/templates/welcome-comp.html +8 -0
  129. package/templates/init/client/lyte/data-store/adapters/.gitkeep +0 -0
  130. package/templates/init/client/lyte/data-store/models/.gitkeep +0 -0
  131. package/templates/init/client/lyte/data-store/serializers/.gitkeep +0 -0
  132. package/templates/init/client/lyte/index.html +17 -0
  133. package/templates/init/client/lyte/package.json +12 -0
  134. package/templates/init/client/lyte/router.js +14 -0
  135. package/templates/init/client/lyte/routes/index.js +54 -0
  136. package/templates/init/client/react/.DS_Store +0 -0
  137. package/templates/init/client/react/react_js/package.json +11 -0
  138. package/templates/init/client/react/react_js/template/README.md +70 -0
  139. package/templates/init/client/react/react_js/template/client-package.json +5 -0
  140. package/templates/init/client/react/react_js/template/gitignore +23 -0
  141. package/templates/init/client/react/react_js/template/public/favicon.ico +0 -0
  142. package/templates/init/client/react/react_js/template/public/index.html +43 -0
  143. package/templates/init/client/react/react_js/template/public/logo192.png +0 -0
  144. package/templates/init/client/react/react_js/template/public/logo512.png +0 -0
  145. package/templates/init/client/react/react_js/template/public/manifest.json +25 -0
  146. package/templates/init/client/react/react_js/template/public/robots.txt +3 -0
  147. package/templates/init/client/react/react_js/template/src/App.css +38 -0
  148. package/templates/init/client/react/react_js/template/src/App.js +25 -0
  149. package/templates/init/client/react/react_js/template/src/App.test.js +8 -0
  150. package/templates/init/client/react/react_js/template/src/index.css +13 -0
  151. package/templates/init/client/react/react_js/template/src/index.js +17 -0
  152. package/templates/init/client/react/react_js/template/src/logo.svg +1 -0
  153. package/templates/init/client/react/react_js/template/src/reportWebVitals.js +13 -0
  154. package/templates/init/client/react/react_js/template/src/setupTests.js +5 -0
  155. package/templates/init/client/react/react_js/template.json +13 -0
  156. package/templates/init/client/react/react_ts/package.json +11 -0
  157. package/templates/init/client/react/react_ts/template/README.md +46 -0
  158. package/templates/init/client/react/react_ts/template/client-package.json +5 -0
  159. package/templates/init/client/react/react_ts/template/gitignore +23 -0
  160. package/templates/init/client/react/react_ts/template/public/favicon.ico +0 -0
  161. package/templates/init/client/react/react_ts/template/public/index.html +43 -0
  162. package/templates/init/client/react/react_ts/template/public/logo192.png +0 -0
  163. package/templates/init/client/react/react_ts/template/public/logo512.png +0 -0
  164. package/templates/init/client/react/react_ts/template/public/manifest.json +25 -0
  165. package/templates/init/client/react/react_ts/template/public/robots.txt +3 -0
  166. package/templates/init/client/react/react_ts/template/src/App.css +38 -0
  167. package/templates/init/client/react/react_ts/template/src/App.test.tsx +9 -0
  168. package/templates/init/client/react/react_ts/template/src/App.tsx +26 -0
  169. package/templates/init/client/react/react_ts/template/src/index.css +13 -0
  170. package/templates/init/client/react/react_ts/template/src/index.tsx +17 -0
  171. package/templates/init/client/react/react_ts/template/src/logo.svg +1 -0
  172. package/templates/init/client/react/react_ts/template/src/reportWebVitals.ts +15 -0
  173. package/templates/init/client/react/react_ts/template/src/setupTests.ts +5 -0
  174. package/templates/init/client/react/react_ts/template.json +18 -0
  175. package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +94 -109
  176. package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +20 -27
  177. package/templates/init/functions/java/integ/cliq/com/handlers/FunctionHandler.java +143 -112
  178. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationHandler.java +4 -7
  179. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationValidator.java +4 -7
  180. package/templates/init/functions/java/integ/cliq/com/handlers/MessageActionHandler.java +10 -12
  181. package/templates/init/functions/java/integ/cliq/com/handlers/WidgetHandler.java +100 -66
  182. package/templates/init/functions/java/integ/cliq/sample.java +5 -7
  183. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +0 -1
  184. package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +46 -0
  185. package/templates/init/functions/node/integ/cliq/handlers/widget-handler.js +31 -0
  186. package/templates/web-socket.txt +21 -0
  187. package/lib/init/features/client.js +0 -51
  188. package/lib/prompt.js +0 -49
  189. package/lib/serve/server/lib/client.js +0 -30
@@ -0,0 +1,171 @@
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 express_1 = __importDefault(require("express"));
16
+ const events_1 = require("events");
17
+ const chokidar_1 = require("chokidar");
18
+ const logger_js_1 = require("../../../../util_modules/logger.js");
19
+ const index_js_1 = require("../../../../util_modules/constants/index.js");
20
+ const error_js_1 = __importDefault(require("../../../../error.js"));
21
+ const index_js_2 = require("../../../../util_modules/fs/index.js");
22
+ const path_1 = require("path");
23
+ const ws_1 = require("ws");
24
+ const port_resolver_js_1 = __importDefault(require("../../../../port-resolver.js"));
25
+ const ansi_colors_1 = require("ansi-colors");
26
+ function prepareScriptFile(dir, port) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const scriptFile = yield index_js_2.ASYNC.readFile(index_js_1.TEMPLATE.client.basic.socket);
29
+ if (!scriptFile) {
30
+ throw new error_js_1.default('Unable to read the script file', { exit: 2 });
31
+ }
32
+ const scriptReady = scriptFile.replace(new RegExp(index_js_1.PLACEHOLDER.client.port, 'g'), port + '');
33
+ yield index_js_2.ASYNC.ensureDir(dir);
34
+ const scriptFilePath = path_1.join(dir, 'reload-script.js');
35
+ yield index_js_2.ASYNC.writeFile(scriptFilePath, scriptReady);
36
+ return scriptFilePath;
37
+ });
38
+ }
39
+ function stringInjector(source, anchorIdx, marker, inject) {
40
+ const headLastIdx = anchorIdx + marker.length;
41
+ const scriptPrefix = source.slice(0, headLastIdx);
42
+ const scriptSufix = source.slice(headLastIdx + 1);
43
+ return scriptPrefix + inject + scriptSufix;
44
+ }
45
+ function injectScript(scriptLocale, indexHtml) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ const headIdx = indexHtml.search(/<head>/gi);
48
+ const scriptTag = `\n<!-- Catalyst web client reload script -->\n<script type="text/javascript" src="${scriptLocale}"></script>\n`;
49
+ if (headIdx !== -1) {
50
+ return stringInjector(indexHtml, headIdx, '<head>', scriptTag);
51
+ }
52
+ const htmlIdx = indexHtml.search(/<html>/gi);
53
+ const headTag = `\n<head>${scriptTag}</head>\n`;
54
+ return stringInjector(indexHtml, htmlIdx, '<html>', headTag);
55
+ });
56
+ }
57
+ function reloadApp(event, path, liveSockets) {
58
+ logger_js_1.info(ansi_colors_1.cyan(`${event} detected in ${path} of the Web-Client.`));
59
+ liveSockets.forEach((socket) => socket.send('reload'));
60
+ }
61
+ function webClientServer(httpPort, source, homepage, enableWatch) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ const eventListner = new events_1.EventEmitter();
64
+ const catalystTempDir = path_1.join(source, '.catalyst');
65
+ const socketServerPort = yield port_resolver_js_1.default.getFreePort(httpPort, 20, true);
66
+ const reloadScriptSrc = enableWatch
67
+ ? path_1.relative(source, yield prepareScriptFile(catalystTempDir, socketServerPort))
68
+ : undefined;
69
+ if (reloadScriptSrc) {
70
+ const clientWatcher = chokidar_1.watch(source, {
71
+ ignoreInitial: true,
72
+ ignored: ['node_modules/**/*']
73
+ });
74
+ const liveSockets = [];
75
+ let watcherReady = false;
76
+ clientWatcher.on('error', (err) => {
77
+ watcherReady = false;
78
+ eventListner.emit('error', new error_js_1.default('client watcher error', {
79
+ original: err,
80
+ exit: 1,
81
+ skipHelp: true
82
+ }));
83
+ });
84
+ clientWatcher.on('ready', () => {
85
+ watcherReady = true;
86
+ const socketServer = new ws_1.WebSocketServer({
87
+ port: socketServerPort,
88
+ path: '/client-reload'
89
+ })
90
+ .on('connection', (clientSocket) => {
91
+ if (!watcherReady) {
92
+ clientSocket.send('watcher not ready');
93
+ clientSocket.close();
94
+ return;
95
+ }
96
+ clientSocket.on('close', () => {
97
+ const socketIdx = liveSockets.findIndex((socket) => socket === clientSocket);
98
+ liveSockets.splice(socketIdx, 1);
99
+ });
100
+ liveSockets.push(clientSocket);
101
+ clientSocket.send('connected');
102
+ })
103
+ .on('error', (err) => logger_js_1.debug(err));
104
+ setTimeout(() => {
105
+ clientWatcher.on('change', (path) => {
106
+ reloadApp('Change(s) is', path_1.relative(source, path), liveSockets);
107
+ });
108
+ clientWatcher.on('add', (path) => {
109
+ reloadApp('Addition of file(s) is', path_1.relative(source, path), liveSockets);
110
+ });
111
+ clientWatcher.on('unlink', (path) => {
112
+ reloadApp('Deletion of file(s) is', path_1.relative(source, path), liveSockets);
113
+ });
114
+ }, 1000);
115
+ eventListner.addListener('close', () => socketServer === null || socketServer === void 0 ? void 0 : socketServer.close());
116
+ });
117
+ eventListner.addListener('close', () => {
118
+ if (clientWatcher) {
119
+ clientWatcher.close();
120
+ }
121
+ liveSockets.forEach((socket) => socket.close());
122
+ index_js_2.SYNC.deleteDir(catalystTempDir);
123
+ });
124
+ }
125
+ const app = express_1.default();
126
+ app.use('/app', (req, res) => __awaiter(this, void 0, void 0, function* () {
127
+ const requestedFile = req.url === '/' ? homepage : decodeURIComponent(req.path);
128
+ if (enableWatch &&
129
+ requestedFile === homepage &&
130
+ (requestedFile.includes('.html') || requestedFile.includes('.htm'))) {
131
+ const homepageFile = yield index_js_2.ASYNC.readFile(path_1.join(source, homepage));
132
+ if (!homepageFile) {
133
+ eventListner.emit('error', new error_js_1.default('Unable to read the homepage file', {
134
+ exit: 1,
135
+ errorId: 'WEB-CLIENT-SERVER-1',
136
+ arg: [ansi_colors_1.red.italic(homepage)]
137
+ }));
138
+ return;
139
+ }
140
+ const injectedHomePage = reloadScriptSrc
141
+ ? yield injectScript(encodeURIComponent(reloadScriptSrc), homepageFile)
142
+ : undefined;
143
+ res.contentType('text/html');
144
+ res.status(200);
145
+ res.send(injectedHomePage || homepageFile);
146
+ return;
147
+ }
148
+ res.sendFile(path_1.join(source, requestedFile), (err) => {
149
+ if (err) {
150
+ logger_js_1.error('Unable to serve the requested file: ' + path_1.join(source, requestedFile));
151
+ logger_js_1.debug(err.stack || err.message);
152
+ res.status(404);
153
+ res.send('Resource not found');
154
+ }
155
+ });
156
+ }));
157
+ const server = app.listen(httpPort).on('error', (err) => {
158
+ eventListner.emit('error', err);
159
+ });
160
+ eventListner.on('error', (err) => {
161
+ logger_js_1.error('Error when serving the web-client: ' + err.message);
162
+ logger_js_1.info('Please exit the command to get more info');
163
+ eventListner.emit('close');
164
+ });
165
+ eventListner.on('close', () => {
166
+ server.close(() => logger_js_1.debug('client server closed'));
167
+ });
168
+ return new Promise((res) => server.on('listening', () => res(eventListner)));
169
+ });
170
+ }
171
+ exports.default = webClientServer;
@@ -235,7 +235,7 @@ class HttpFunctions {
235
235
  };
236
236
  shell_1.clearLine(process.stdout);
237
237
  const masterPort = runtime_store_1.default.get(`context.port.http.master`, -1);
238
- const fnTargets = runtime_store_1.default.get('context.functions.targets');
238
+ const fnTargets = runtime_store_1.default.get('context.functions.targets', []);
239
239
  fnTargets
240
240
  .filter((t) => t.url !== undefined && t.type === constants_1.FN_TYPE.basic)
241
241
  .map((t) => {
@@ -46,7 +46,9 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
46
46
  const httpServer = new http_functions_1.default(replServer);
47
47
  try {
48
48
  yield prepare_1.default([constants_1.FN_TYPE.basic, constants_1.FN_TYPE.cron, constants_1.FN_TYPE.event, constants_1.FN_TYPE.integration]);
49
- const targets = runtime_store_1.default.get('context.functions.targets', []).filter((target) => {
49
+ const targets = runtime_store_1.default
50
+ .get('context.functions.targets', [])
51
+ .filter((target) => {
50
52
  if (!target.valid) {
51
53
  logger_1.warning('target [' +
52
54
  target.name +
package/lib/track.js CHANGED
@@ -16,6 +16,7 @@ const path_1 = require("path");
16
16
  const readline_1 = require("readline");
17
17
  const config_store_1 = __importDefault(require("./config-store"));
18
18
  const endpoints_1 = require("./endpoints");
19
+ const error_1 = __importDefault(require("./error"));
19
20
  const runtime_store_1 = __importDefault(require("./runtime-store"));
20
21
  const fs_1 = require("./util_modules/fs");
21
22
  const logger_1 = require("./util_modules/logger");
@@ -52,7 +53,8 @@ exports.default = (event, message, duration) => __awaiter(void 0, void 0, void 0
52
53
  yield httpLogger.log(logInput);
53
54
  }
54
55
  }
55
- catch (err) {
56
+ catch (e) {
57
+ const err = error_1.default.getErrorInstance(e);
56
58
  logger_1.debug('Unable to send debug log to server: ' + err.message);
57
59
  }
58
60
  });
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CHAR = void 0;
4
4
  const ansi_colors_1 = require("ansi-colors");
5
5
  const env_1 = require("./env");
6
- const isSupported = !env_1.isWindows() || process.env.CI || process.env.TERM === 'xterm-256color';
6
+ const isSupported = !env_1.isWindows || process.env.CI || process.env.TERM === 'xterm-256color';
7
7
  exports.CHAR = {
8
8
  success: isSupported ? ansi_colors_1.bold.green('✔') : ansi_colors_1.bold.green('√'),
9
9
  warning: isSupported ? ansi_colors_1.bold.yellow('⚠') : ansi_colors_1.bold.yellow('‼'),
@@ -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.script = exports.enabled = exports.rules = exports.raw = void 0;
6
+ exports.source = exports.script = exports.enabled = exports.rules = exports.raw = void 0;
7
7
  const error_1 = __importDefault(require("../../../error"));
8
8
  const runtime_store_1 = __importDefault(require("../../../runtime-store"));
9
9
  const constants_1 = require("../../constants");
@@ -43,3 +43,4 @@ function script(name, fallback) {
43
43
  return (rawScripts && rawScripts[name]) || fallback;
44
44
  }
45
45
  exports.script = script;
46
+ exports.source = rules;
@@ -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.ORIGIN = exports.TEMPLATE = exports.SCOPE = exports.REMOTE_REF = exports.REGEX = exports.REFERENCE = exports.PLACEHOLDER = exports.INTEG = exports.FOLDERNAME = exports.FN_TYPE = exports.DC_TYPE = exports.FILENAME = exports.EVENT_SOURCE = exports.EVENT_REF = exports.DEFAULT = exports.CLIQ = exports.AUTH = exports.APIG_RULES = void 0;
6
+ exports.IAC = exports.PLUGIN = exports.ORIGIN = exports.TEMPLATE = exports.SCOPE = exports.REMOTE_REF = exports.REGEX = exports.REFERENCE = exports.PLACEHOLDER = exports.INTEG = exports.FOLDERNAME = exports.FN_TYPE = exports.DC_TYPE = exports.FILENAME = exports.EVENT_SOURCE = exports.EVENT_REF = exports.DEFAULT = exports.CLIQ = exports.AUTH = exports.APIG_RULES = void 0;
7
7
  var apig_rules_1 = require("./lib/apig-rules");
8
8
  Object.defineProperty(exports, "APIG_RULES", { enumerable: true, get: function () { return __importDefault(apig_rules_1).default; } });
9
9
  var auth_1 = require("./lib/auth");
@@ -40,3 +40,7 @@ var template_1 = require("./lib/template");
40
40
  Object.defineProperty(exports, "TEMPLATE", { enumerable: true, get: function () { return __importDefault(template_1).default; } });
41
41
  var urls_1 = require("./lib/urls");
42
42
  Object.defineProperty(exports, "ORIGIN", { enumerable: true, get: function () { return __importDefault(urls_1).default; } });
43
+ var plugin_1 = require("./lib/plugin");
44
+ Object.defineProperty(exports, "PLUGIN", { enumerable: true, get: function () { return __importDefault(plugin_1).default; } });
45
+ var iac_1 = require("./lib/iac");
46
+ Object.defineProperty(exports, "IAC", { enumerable: true, get: function () { return __importDefault(iac_1).default; } });
@@ -20,5 +20,6 @@ exports.default = Object.freeze({
20
20
  system_rules: 'catalyst-system-rules.json'
21
21
  },
22
22
  catalyst_config: 'catalyst-config.json',
23
- command_log: '.command.log'
23
+ command_log: '.command.log',
24
+ node_modules: 'node_modules'
24
25
  });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = Object.freeze({
4
+ template_format: {
5
+ json: 'JSON',
6
+ yml: 'YAML'
7
+ }
8
+ });
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = Object.freeze({
4
4
  client: {
5
+ port: '{{_PORT_}}',
5
6
  package: {
6
7
  name: '{{_NAME_}}'
7
8
  }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = Object.freeze({
4
+ mangaer: {
5
+ npm: {
6
+ command: 'npm',
7
+ opts: ['config', 'get', 'prefix', '--json']
8
+ },
9
+ yarn: {
10
+ command: 'yarn',
11
+ opts: ['global', 'dir']
12
+ }
13
+ },
14
+ client: ['Angular', 'React', 'Basic'],
15
+ react: {
16
+ plugin: 'zcatalyst-cli-plugin-react',
17
+ runner_command: ['create-react-app']
18
+ },
19
+ lyte: {
20
+ plugin: 'zcatalyst-cli-plugin-lyte'
21
+ },
22
+ angular: {
23
+ plugin: 'zcatalyst-cli-plugin-angular',
24
+ runner_command: ['ng', 'new'],
25
+ collection_name: 'zcatalyst-angular-schematics',
26
+ runner_package: '@angular/cli@v12-lts'
27
+ }
28
+ });
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const functionName = /(?!^\d+$)^(\w|-)+$/g;
4
4
  exports.default = Object.freeze({
5
5
  project: {
6
- name: /^[a-zA-Z0-9][a-zA-Z0-9-]*$/g
6
+ name: /^[a-zA-Z0-9][a-zA-Z0-9-]*$/g,
7
+ template: /project-template-\d{1,2}\.\d{1,2}\.\d{1,2}.(yml|json)/g
7
8
  },
8
9
  client: {
9
10
  package_name: /^[a-zA-Z0-9][a-zA-Z0-9-]*$/g
@@ -15,6 +15,11 @@ exports.default = Object.freeze({
15
15
  queue_data_read: 'ZohoCatalyst.queue.data.READ',
16
16
  queue_data_create: 'ZohoCatalyst.queue.data.CREATE',
17
17
  projects: 'ZohoCatalyst.projects.ALL',
18
+ project_export_read: 'ZohoCatalyst.project.export.READ',
19
+ project_export_create: 'ZohoCatalyst.project.export.CREATE',
20
+ project_import_read: 'ZohoCatalyst.project.import.READ',
21
+ project_import_create: 'ZohoCatalyst.project.import.CREATE',
22
+ project_import_delete: 'ZohoCatalyst.project.import.DELETE',
18
23
  cron: 'ZohoCatalyst.cron.ALL',
19
24
  zcql: 'ZohoCatalyst.zcql.CREATE',
20
25
  webapp: 'ZohoCatalyst.webapp.ALL',
@@ -7,7 +7,17 @@ exports.default = Object.freeze({
7
7
  banner: path_1.join(TEMPLATE_ROOT, 'banner.txt'),
8
8
  login_success: path_1.join(TEMPLATE_ROOT, 'loginSuccess.html'),
9
9
  login_fail: path_1.join(TEMPLATE_ROOT, 'loginFailure.html'),
10
- client: path_1.join(TEMPLATE_ROOT, 'init/client'),
10
+ client: {
11
+ basic: {
12
+ new: path_1.join(TEMPLATE_ROOT, 'init', 'client', 'basic'),
13
+ socket: path_1.join(TEMPLATE_ROOT, 'web-socket.txt')
14
+ },
15
+ lyte: path_1.join(TEMPLATE_ROOT, 'init', 'client', 'lyte'),
16
+ react: {
17
+ js: path_1.join(TEMPLATE_ROOT, 'init', 'client', 'react', 'react_js'),
18
+ ts: path_1.join(TEMPLATE_ROOT, 'init', 'client', 'react', 'react_ts')
19
+ }
20
+ },
11
21
  applogic: {
12
22
  node: path_1.join(TEMPLATE_ROOT, 'init', 'applogic', 'node')
13
23
  },
@@ -24,16 +24,24 @@ class URL {
24
24
  }
25
25
  return URL._app.replace('.com', dc.ext);
26
26
  }
27
- static get zoho() {
27
+ static get catalystStatic() {
28
28
  const dc = dc_1.getActiveDCType();
29
29
  if (dc === undefined) {
30
- return URL._zoho;
30
+ return URL._catalystStatic;
31
31
  }
32
- return URL._zoho.replace('.com', dc.ext);
32
+ return URL._catalystStatic.replace('.com', dc.ext);
33
+ }
34
+ static get console() {
35
+ const dc = dc_1.getActiveDCType();
36
+ if (dc === undefined) {
37
+ return URL._console;
38
+ }
39
+ return URL._console.replace('.com', dc.ext);
33
40
  }
34
41
  }
35
42
  exports.default = URL;
36
43
  URL._auth = env_1.envOverride('CATALYST_AUTH_URL', 'https://accounts.zoho.com');
37
44
  URL._admin = env_1.envOverride('CATALYST_ADMIN_URL', 'https://api.catalyst.zoho.com');
38
45
  URL._app = env_1.envOverride('CATALYST_APP_URL', 'https://catalystserverless.com');
39
- URL._zoho = env_1.envOverride('ZOHO_URL', 'https://www.zoho.com');
46
+ URL._catalystStatic = env_1.envOverride('CATALYST_STATIC', 'https://catalyst.zoho.com');
47
+ URL._console = env_1.envOverride('CATALYST_CONSOLE_URL', 'https://console.catalyst.zoho.com');
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const PROJECT = Object.freeze({
4
+ accepted_types: ['Live', 'Demo']
5
+ });
6
+ exports.default = PROJECT;
@@ -10,10 +10,11 @@ const fs_1 = require("./fs");
10
10
  const logger_1 = require("./logger");
11
11
  const toml_1 = __importDefault(require("./parser/toml"));
12
12
  function help() {
13
+ let exitCode = 0;
13
14
  const logs = runtime_store_1.default.get('log');
14
15
  if (logs === undefined) {
15
16
  logger_1.debug('NO ERRORS REGISTERED');
16
- return;
17
+ return exitCode;
17
18
  }
18
19
  const logKeys = Object.keys(logs);
19
20
  const fillTemplate = (...arg) => {
@@ -28,6 +29,7 @@ function help() {
28
29
  const errQueue = logs[key];
29
30
  if (key === 'faultyError') {
30
31
  errQueue.forEach((err) => {
32
+ exitCode = err.exit > exitCode ? err.exit : exitCode;
31
33
  outputError(err, errQueue);
32
34
  return;
33
35
  });
@@ -36,6 +38,7 @@ function help() {
36
38
  const doc = fs_1.SYNC.readFile(docPath) || '';
37
39
  const catHelp = toml_1.default(doc);
38
40
  errQueue.forEach((err) => {
41
+ exitCode = err.exit > exitCode ? err.exit : exitCode;
39
42
  if (err.errorId === undefined || catHelp === undefined || catHelp === {}) {
40
43
  outputError(err, errQueue);
41
44
  return;
@@ -59,6 +62,7 @@ function help() {
59
62
  errQueue.shift();
60
63
  });
61
64
  });
65
+ return exitCode;
62
66
  }
63
67
  exports.default = help;
64
68
  function outputError(err, errQueue) {
@@ -1,24 +1,22 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEnvVariable = exports.envOverride = exports.isPrimaryShell = exports.isWindows = exports.isMac = void 0;
4
- function isMac() {
5
- return process && process.platform === 'darwin';
6
- }
7
- exports.isMac = isMac;
8
- function isWindows() {
9
- return (process &&
10
- (process.platform === 'win32' ||
11
- (process.env.OSTYPE !== undefined && /^(msys|cygwin)$/.test(process.env.OSTYPE))));
12
- }
13
- exports.isWindows = isWindows;
3
+ exports.getEnvVariable = exports.envOverride = exports.isPrimaryShell = exports.isWindows = exports.isMac = exports.isCI = void 0;
4
+ exports.isCI = process &&
5
+ !!(process.env.CI ||
6
+ process.env.CONTINUOUS_INTEGRATION ||
7
+ process.env.BUILD_NUMBER ||
8
+ process.env.RUN_ID ||
9
+ exports.name ||
10
+ false);
11
+ exports.isMac = process && process.platform === 'darwin';
12
+ exports.isWindows = process &&
13
+ (process.platform === 'win32' ||
14
+ (process.env.OSTYPE !== undefined && /^(msys|cygwin)$/.test(process.env.OSTYPE)));
14
15
  function isPrimaryShell() {
15
- if (!process) {
16
+ if (!process || process.env.CATALYST_SUB_PROCESS) {
16
17
  return false;
17
18
  }
18
- if (process.env.CATALYST_SUB_PROCESS) {
19
- return !process.env.CATALYST_SUB_PROCESS;
20
- }
21
- if (process.env.SHLVL) {
19
+ if (!exports.isWindows && process.env.SHLVL) {
22
20
  return parseInt(process.env.SHLVL) <= 1;
23
21
  }
24
22
  return false;
@@ -17,26 +17,31 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
17
17
  const minimatch_1 = __importDefault(require("minimatch"));
18
18
  const os_1 = __importDefault(require("os"));
19
19
  const path_1 = __importDefault(require("path"));
20
+ const utils_js_1 = require("../utils.js");
20
21
  function dirExists(pth) {
21
22
  return __awaiter(this, void 0, void 0, function* () {
22
- const stats = yield fs_extra_1.default.stat(pth).catch(() => false);
23
+ const stats = yield fs_extra_1.default.stat(utils_js_1.untildify(pth)).catch(() => false);
23
24
  return stats && stats.isDirectory();
24
25
  });
25
26
  }
26
27
  exports.dirExists = dirExists;
27
28
  function fileExists(pth) {
28
29
  return __awaiter(this, void 0, void 0, function* () {
29
- const stats = yield fs_extra_1.default.stat(pth).catch(() => false);
30
+ const stats = yield fs_extra_1.default.stat(utils_js_1.untildify(pth)).catch(() => false);
30
31
  return stats && stats.isFile();
31
32
  });
32
33
  }
33
34
  exports.fileExists = fileExists;
34
- function readFile(pth, encoding = 'utf8') {
35
+ function readFile(pth, type) {
35
36
  return __awaiter(this, void 0, void 0, function* () {
36
- if (yield fileExists(pth)) {
37
- return fs_extra_1.default.readFile(pth, encoding);
37
+ if (!(yield fileExists(pth))) {
38
+ return undefined;
38
39
  }
39
- return undefined;
40
+ return (type === 'buffer'
41
+ ? fs_extra_1.default.readFile(pth)
42
+ : type
43
+ ? fs_extra_1.default.readFile(pth, type)
44
+ : fs_extra_1.default.readFile(pth, 'utf8'));
40
45
  });
41
46
  }
42
47
  exports.readFile = readFile;
@@ -70,27 +75,29 @@ function dirList(dir) {
70
75
  });
71
76
  }
72
77
  exports.dirList = dirList;
73
- function walk(dir, exclude = []) {
78
+ function walk(dir, { exclude = [], excludeDir = true, depth = -1 } = {}) {
74
79
  return __awaiter(this, void 0, void 0, function* () {
80
+ if (depth === 0) {
81
+ return [];
82
+ }
75
83
  const isDir = yield fs_extra_1.default.stat(dir).then((stat) => stat.isDirectory());
76
84
  const files = isDir ? yield fs_extra_1.default.readdir(dir) : [path_1.default.basename(dir)];
77
- const folderContentPromise = files
78
- .map((entry) => {
79
- return isDir ? path_1.default.join(dir, entry) : dir;
80
- })
81
- .filter((entryPath) => {
82
- let match = false;
83
- for (const glob of exclude) {
84
- match = minimatch_1.default(entryPath, glob);
85
- if (match) {
86
- return false;
85
+ const folderContentPromise = files.map((entry) => __awaiter(this, void 0, void 0, function* () {
86
+ const entryPath = isDir ? path_1.default.join(dir, entry) : dir;
87
+ const stats = yield fs_extra_1.default.stat(entryPath);
88
+ const isEntryPthDir = stats.isDirectory();
89
+ let excludeMatch = false;
90
+ if (!(isEntryPthDir && !excludeDir)) {
91
+ for (const glob of exclude) {
92
+ excludeMatch = excludeMatch || minimatch_1.default(entryPath, glob);
87
93
  }
88
94
  }
89
- return true;
90
- })
91
- .map((entryPath) => __awaiter(this, void 0, void 0, function* () {
92
- const stats = yield fs_extra_1.default.stat(entryPath);
93
- return stats.isDirectory() ? walk(entryPath, exclude) : [entryPath];
95
+ if (excludeMatch) {
96
+ return [];
97
+ }
98
+ return isEntryPthDir
99
+ ? walk(entryPath, { exclude, excludeDir, depth: --depth })
100
+ : [entryPath];
94
101
  }));
95
102
  const folderContents = yield Promise.all(folderContentPromise);
96
103
  return folderContents.reduce((all, folderContent) => all.concat(folderContent), []);
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.untildify = void 0;
4
+ const os_1 = require("os");
5
+ const tildRegex = /^~(?=$|\/|\\)/;
6
+ const homeDirectory = os_1.homedir();
7
+ const untildify = (pth) => homeDirectory ? pth.replace(tildRegex, homeDirectory) : pth;
8
+ exports.untildify = untildify;