zcatalyst-cli 1.18.0-beta.8 → 1.18.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 (145) hide show
  1. package/README.md +11 -6
  2. package/docs/commands/slate/unlink.toml +9 -0
  3. package/docs/endpoints/lib/env.toml +3 -1
  4. package/docs/endpoints/lib/slate.toml +3 -0
  5. package/docs/serve/server/lib/slate/index.toml +14 -0
  6. package/docs/slate-utils.toml +4 -0
  7. package/docs/util_modules/config/lib/slate.toml +4 -0
  8. package/lib/archiver.js +18 -9
  9. package/lib/authentication/login.js +6 -5
  10. package/lib/code-deck.js +5 -6
  11. package/lib/command_needs/auth.js +1 -1
  12. package/lib/command_needs/rc.js +40 -3
  13. package/lib/commands/codelib/install.js +1 -0
  14. package/lib/commands/deploy/index.js +4 -0
  15. package/lib/commands/deploy/slate.js +58 -0
  16. package/lib/commands/index.js +2 -3
  17. package/lib/commands/init.js +0 -10
  18. package/lib/commands/slate/create.js +59 -0
  19. package/lib/commands/slate/link.js +59 -0
  20. package/lib/commands/slate/unlink.js +75 -0
  21. package/lib/commands/zest/generate/index.js +1 -6
  22. package/lib/config-store.js +2 -1
  23. package/lib/deploy/features/index.js +3 -0
  24. package/lib/deploy/features/slate.js +123 -0
  25. package/lib/endpoints/index.js +8 -1
  26. package/lib/endpoints/lib/env.js +2 -1
  27. package/lib/endpoints/lib/sdk.js +2 -2
  28. package/lib/endpoints/lib/slate.js +107 -0
  29. package/lib/fn-utils/lib/common.js +1 -1
  30. package/lib/iac/status/deploy.js +1 -5
  31. package/lib/index.js +1 -1
  32. package/lib/init/features/appsail/index.js +2 -3
  33. package/lib/init/features/index.js +13 -1
  34. package/lib/init/features/project.js +1 -1
  35. package/lib/init/features/slate/index.js +313 -0
  36. package/lib/internal/api.js +1 -1
  37. package/lib/internal/command.js +10 -6
  38. package/lib/port-resolver.js +7 -0
  39. package/lib/prompt/index.js +22 -6
  40. package/lib/prompt/types/file-path.js +10 -7
  41. package/lib/serve/features/index.js +8 -1
  42. package/lib/serve/features/slate.js +47 -0
  43. package/lib/serve/server/index.js +61 -1
  44. package/lib/serve/server/lib/appsail/index.js +2 -2
  45. package/lib/serve/server/lib/java/aio_server/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
  46. package/lib/serve/server/lib/java/aio_server/lib/{catalyst-function-sdk-1.0.0.jar → catalyst-function-sdk-1.1.0.jar} +0 -0
  47. package/lib/serve/server/lib/java/aio_server/lib/catalyst-java-runtime-1.0.0.jar +0 -0
  48. package/lib/serve/server/lib/java/index.js +1 -1
  49. package/lib/serve/server/lib/master/index.js +25 -21
  50. package/lib/serve/server/lib/master/slate.js +45 -0
  51. package/lib/serve/server/lib/master/unknown-req-proxy.js +1 -1
  52. package/lib/serve/server/lib/master/utils.js +9 -3
  53. package/lib/serve/server/lib/node/index.js +1 -1
  54. package/lib/serve/server/lib/python/index.js +1 -1
  55. package/lib/serve/server/lib/slate/index.js +115 -0
  56. package/lib/serve/server/lib/slate/static-server.js +194 -0
  57. package/lib/serve/server/lib/web_client/server.js +2 -1
  58. package/lib/shell/dependencies/http-functions.js +1 -1
  59. package/lib/shell/dependencies/invoker/bio/java/lib/{catalyst-function-sdk-1.0.0.jar → catalyst-function-sdk-1.1.0.jar} +0 -0
  60. package/lib/shell/dependencies/invoker/cron/java/lib/{catalyst-function-sdk-1.0.0.jar → catalyst-function-sdk-1.1.0.jar} +0 -0
  61. package/lib/shell/dependencies/invoker/event/java/lib/{catalyst-function-sdk-1.0.0.jar → catalyst-function-sdk-1.1.0.jar} +0 -0
  62. package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
  63. package/lib/shell/dependencies/invoker/job/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
  64. package/lib/shell/dependencies/local-function.js +3 -3
  65. package/lib/slate-utils.js +212 -0
  66. package/lib/util_modules/config/index.js +3 -1
  67. package/lib/util_modules/config/lib/slate.js +98 -0
  68. package/lib/util_modules/constants/lib/cliq-handlers.js +18 -10
  69. package/lib/util_modules/constants/lib/dc-type.js +8 -0
  70. package/lib/util_modules/constants/lib/default.js +4 -0
  71. package/lib/util_modules/constants/lib/file-names.js +7 -1
  72. package/lib/util_modules/constants/lib/folder-names.js +1 -0
  73. package/lib/util_modules/constants/lib/placeholders.js +2 -1
  74. package/lib/util_modules/constants/lib/scopes.js +1 -6
  75. package/lib/util_modules/context-help.js +2 -2
  76. package/lib/util_modules/fs/lib/async.js +14 -3
  77. package/lib/util_modules/fs/lib/sync.js +6 -1
  78. package/lib/util_modules/parser/toml.js +20 -5
  79. package/package.json +3 -3
  80. package/templates/event/integ/cliq/bot/action_handler.json +13 -4
  81. package/templates/event/integ/cliq/bot/call_handler.json +41 -0
  82. package/templates/event/integ/cliq/bot/context_handler.json +11 -3
  83. package/templates/event/integ/cliq/bot/incomingwebhook_handler.json +11 -3
  84. package/templates/event/integ/cliq/bot/mention_handler.json +12 -4
  85. package/templates/event/integ/cliq/bot/message_handler.json +13 -4
  86. package/templates/event/integ/cliq/bot/participation_handler.json +13 -3
  87. package/templates/event/integ/cliq/bot/welcome_handler.json +12 -8
  88. package/templates/event/integ/cliq/command/execution_handler.json +12 -3
  89. package/templates/event/integ/cliq/command/suggestion_handler.json +18 -4
  90. package/templates/event/integ/cliq/{installation → extension}/installation_handler.json +13 -4
  91. package/templates/event/integ/cliq/{installation → extension}/installation_validator.json +13 -5
  92. package/templates/event/integ/cliq/extension/uninstallation_handler.json +37 -0
  93. package/templates/event/integ/cliq/function/button_handler.json +13 -5
  94. package/templates/event/integ/cliq/function/form_change_handler.json +9 -3
  95. package/templates/event/integ/cliq/function/form_handler.json +11 -3
  96. package/templates/event/integ/cliq/function/form_values_handler.json +9 -3
  97. package/templates/event/integ/cliq/function/form_view_handler.json +26 -0
  98. package/templates/event/integ/cliq/function/widget_button_handler.json +14 -5
  99. package/templates/event/integ/cliq/link_preview/action_handler.json +54 -0
  100. package/templates/event/integ/cliq/link_preview/after_send_handler.json +47 -0
  101. package/templates/event/integ/cliq/link_preview/menu_handler.json +47 -0
  102. package/templates/event/integ/cliq/link_preview/preview_handler.json +47 -0
  103. package/templates/event/integ/cliq/messageaction/execution_handler.json +11 -3
  104. package/templates/event/integ/cliq/widget/view_handler.json +12 -4
  105. package/templates/init/client/react/react_js/template/src/index.js +3 -3
  106. package/templates/init/client/react/react_ts/template/src/index.tsx +3 -3
  107. package/templates/init/client/react/react_ts/template.json +3 -3
  108. package/templates/init/functions/java/event/sample.java +4 -0
  109. package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +29 -23
  110. package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +14 -17
  111. package/templates/init/functions/java/integ/cliq/com/handlers/ExtensionHandler.java +41 -0
  112. package/templates/init/functions/java/integ/cliq/com/handlers/FunctionHandler.java +74 -22
  113. package/templates/init/functions/java/integ/cliq/com/handlers/LinkPreviewHandler.java +108 -0
  114. package/templates/init/functions/java/integ/cliq/com/handlers/MessageActionHandler.java +6 -8
  115. package/templates/init/functions/java/integ/cliq/sample.java +10 -0
  116. package/templates/init/functions/node/aio/package.json +1 -1
  117. package/templates/init/functions/node/bio/package.json +1 -1
  118. package/templates/init/functions/node/cron/package.json +1 -1
  119. package/templates/init/functions/node/event/package.json +1 -1
  120. package/templates/init/functions/node/event/sample.js +1 -0
  121. package/templates/init/functions/node/event/types/event.d.ts +7 -0
  122. package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +4 -0
  123. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -5
  124. package/templates/init/functions/node/integ/cliq/handlers/{installation-validator.js → extension-handler.js} +20 -3
  125. package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +42 -0
  126. package/templates/init/functions/node/integ/cliq/handlers/link-preview-handler.js +73 -0
  127. package/templates/init/functions/node/integ/cliq/package.json +1 -1
  128. package/templates/init/functions/node/integ/convokraft/package.json +1 -1
  129. package/templates/init/functions/node/job/package.json +1 -1
  130. package/templates/init/functions/python/event/sample.py +9 -5
  131. package/templates/init/functions/python/integ/cliq/handlers/bot_handler.py +13 -3
  132. package/templates/init/functions/python/integ/cliq/handlers/command_handler.py +7 -7
  133. package/templates/init/functions/python/integ/cliq/handlers/extension_handler.py +25 -0
  134. package/templates/init/functions/python/integ/cliq/handlers/function_handler.py +54 -10
  135. package/templates/init/functions/python/integ/cliq/handlers/link_preview_handler.py +76 -0
  136. package/templates/init/functions/python/integ/cliq/handlers/widget_handler.py +10 -9
  137. package/templates/init/functions/python/integ/cliq/sample.py +2 -2
  138. package/templates/init.txt +2 -1
  139. package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  140. package/lib/shell/dependencies/invoker/job/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  141. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationHandler.java +0 -20
  142. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationValidator.java +0 -22
  143. package/templates/init/functions/node/integ/cliq/handlers/installation-handler.js +0 -15
  144. package/templates/init/functions/python/integ/cliq/handlers/installation_handler.py +0 -12
  145. package/templates/init/functions/python/integ/cliq/handlers/installation_validator.py +0 -16
@@ -0,0 +1,313 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ const prompt_1 = __importDefault(require("../../../prompt"));
39
+ const logger_1 = require("../../../util_modules/logger");
40
+ const endpoints_1 = require("../../../endpoints");
41
+ const archiver_1 = __importDefault(require("../../../archiver"));
42
+ const option_1 = require("../../../util_modules/option");
43
+ const path_1 = __importStar(require("path"));
44
+ const runtime_store_1 = __importDefault(require("../../../runtime-store"));
45
+ const fs_1 = require("../../../util_modules/fs");
46
+ const ansi_colors_1 = require("ansi-colors");
47
+ const config_1 = require("../../../util_modules/config");
48
+ const console_1 = require("console");
49
+ const error_1 = __importDefault(require("../../../error"));
50
+ const constants_1 = require("../../../util_modules/constants");
51
+ const project_1 = require("../../../util_modules/project");
52
+ const toml_1 = require("../../../util_modules/parser/toml");
53
+ const async_1 = require("../../../util_modules/fs/lib/async");
54
+ function getFrameworkOption(frameworks, source) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ let frameworkOpt = (0, option_1.getOptionValue)('framework');
57
+ if (frameworkOpt &&
58
+ frameworks.findIndex((framework) => framework.name === frameworkOpt) === -1) {
59
+ (0, logger_1.warning)('Given framework is not supported in Slate.');
60
+ frameworkOpt = '';
61
+ }
62
+ if (!frameworkOpt) {
63
+ const filteredFrameworks = frameworks.filter((framework) => framework.name !== 'other');
64
+ const { selectedFramework } = yield prompt_1.default.ask(prompt_1.default.question('selectedFramework', 'Select a framework to start with: ', {
65
+ type: 'list',
66
+ choices: filteredFrameworks.map(({ label, name }) => prompt_1.default.choice(label, { value: name, short: label }))
67
+ }));
68
+ frameworkOpt = selectedFramework;
69
+ }
70
+ return { name: frameworkOpt, source };
71
+ });
72
+ }
73
+ function validateAppName(appName) {
74
+ if (appName.length === 0) {
75
+ return 'App name cannot be empty';
76
+ }
77
+ if (appName.length > 45) {
78
+ return 'App name cannot be more than 45 characters';
79
+ }
80
+ if (!appName.match(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/)) {
81
+ return 'App name must be alphanumeric and contain only a single hyphen in the middle.';
82
+ }
83
+ return true;
84
+ }
85
+ function getAppName(existingSlates, frameworkOpt) {
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ let appName = (0, option_1.getOptionValue)('name');
88
+ if (!appName) {
89
+ const { name } = yield prompt_1.default.ask(prompt_1.default.question('name', 'Please provide the name for your app:', {
90
+ type: 'input',
91
+ default: frameworkOpt,
92
+ validate: (name) => {
93
+ if (existingSlates.findIndex((targ) => targ.name === name) !== -1)
94
+ return 'Slate already configured with this name.';
95
+ return validateAppName(name);
96
+ }
97
+ }));
98
+ appName = name;
99
+ }
100
+ else {
101
+ if (existingSlates.findIndex((targ) => targ.name === appName) !== -1) {
102
+ throw new error_1.default('Slate already configured with this name.');
103
+ }
104
+ else {
105
+ const isValidApp = validateAppName(appName);
106
+ if (isValidApp !== true) {
107
+ throw new error_1.default(isValidApp + '');
108
+ }
109
+ }
110
+ }
111
+ return appName;
112
+ });
113
+ }
114
+ function handleTemplate(appName, { templateName, frameworkName } = {}) {
115
+ return __awaiter(this, void 0, void 0, function* () {
116
+ const projectRoot = (0, project_1.getProjectRoot)();
117
+ const appPath = path_1.default.join(projectRoot, appName);
118
+ const folderExists = yield fs_1.ASYNC.dirExists(appPath);
119
+ const overwriteAns = folderExists
120
+ ? yield prompt_1.default.ask(prompt_1.default.question('overwrite', `Directory ${(0, ansi_colors_1.underline)(appPath)} already exists. Overwrite?`, {
121
+ type: 'confirm',
122
+ default: false
123
+ }))
124
+ : { overwrite: true };
125
+ if (!overwriteAns.overwrite) {
126
+ (0, logger_1.warning)('Skipping slate template setup');
127
+ return appPath;
128
+ }
129
+ yield fs_1.ASYNC.deleteDir(appPath).catch(console_1.error);
130
+ const templatePath = 'slate-main' + (templateName ? `/templates/${templateName}` : `/examples/${frameworkName}`);
131
+ const responseZip = (yield (yield (0, endpoints_1.slateAPI)()).downloadTemplate());
132
+ yield new archiver_1.default()
133
+ .load(responseZip)
134
+ .extract(appPath, templatePath, {
135
+ ignoreLevel: 3
136
+ })
137
+ .finalize();
138
+ return appPath;
139
+ });
140
+ }
141
+ function addExistingSlate(existingSlates) {
142
+ return __awaiter(this, void 0, void 0, function* () {
143
+ yield prompt_1.default.register('file-path');
144
+ const projectRoot = (0, project_1.getProjectRoot)();
145
+ const { sourcePath } = yield prompt_1.default.ask(prompt_1.default.question('sourcePath', 'Please provide the source path of your slate service: ', {
146
+ type: 'file-path',
147
+ validate: (pth) => __awaiter(this, void 0, void 0, function* () {
148
+ const buildPath = (0, path_1.resolve)(projectRoot, pth.value);
149
+ if (existingSlates.findIndex((targ) => targ.source === buildPath) !== -1)
150
+ return 'Path is already linked.';
151
+ if (yield fs_1.ASYNC.dirExists(buildPath)) {
152
+ return true;
153
+ }
154
+ return 'Path does not exist';
155
+ }),
156
+ depth: 5,
157
+ empTxt: ' ',
158
+ rootPath: projectRoot,
159
+ ignoreFiles: true,
160
+ excludeDir: true,
161
+ exclude: ['**/node_modules', '**/.git', '**/.catalyst']
162
+ }));
163
+ prompt_1.default.deregister('file-path');
164
+ return sourcePath;
165
+ });
166
+ }
167
+ function detectFramework(source, frameworkList) {
168
+ return __awaiter(this, void 0, void 0, function* () {
169
+ const frameworkOpt = (0, option_1.getOptionValue)('framework');
170
+ if (frameworkOpt &&
171
+ frameworkList.findIndex((framework) => framework.name === frameworkOpt) === -1) {
172
+ return { name: frameworkOpt, source };
173
+ }
174
+ const packageJsonPath = (0, path_1.join)(source, constants_1.FILENAME.package_json);
175
+ const packageJsonExists = yield fs_1.ASYNC.fileExists(packageJsonPath);
176
+ if (!packageJsonExists) {
177
+ (0, logger_1.warning)('Unable to find the package.json file at the given source path');
178
+ return getFrameworkOption(frameworkList, source);
179
+ }
180
+ const data = yield fs_1.ASYNC.readJSONFile(packageJsonPath);
181
+ const dependencies = Object.assign(Object.assign({}, data === null || data === void 0 ? void 0 : data.dependencies), data === null || data === void 0 ? void 0 : data.devDependencies);
182
+ if (!dependencies) {
183
+ (0, logger_1.warning)('The package.json file does not contain dependencies');
184
+ return getFrameworkOption(frameworkList, source);
185
+ }
186
+ const isReact = dependencies['react'] !== undefined && dependencies['react-dom'] !== undefined;
187
+ const isVite = dependencies['vite'] !== undefined || dependencies['@vitejs/plugin-react'] !== undefined;
188
+ if (isReact && isVite) {
189
+ return { name: 'react-vite', source };
190
+ }
191
+ const isNextJs = dependencies['react'] !== undefined && dependencies['next'] !== undefined;
192
+ if (isNextJs) {
193
+ return { name: 'nextjs', source };
194
+ }
195
+ frameworkList = frameworkList.filter((framework) => !['static', 'react-vite', 'nextjs'].includes(framework.name));
196
+ const framework = frameworkList.find(({ keywords }) => keywords.every((keyword) => dependencies[keyword] !== undefined));
197
+ if (!framework) {
198
+ (0, logger_1.warning)('No matching framework found in package.json dependencies');
199
+ return getFrameworkOption(frameworkList);
200
+ }
201
+ return { name: framework.name, source };
202
+ });
203
+ }
204
+ function getConfigDetails(frameworkOpt, frameworks) {
205
+ return __awaiter(this, void 0, void 0, function* () {
206
+ const slateConfigs = frameworks.find((framework) => frameworkOpt.toLowerCase() === framework.name);
207
+ if (frameworkOpt === 'static') {
208
+ return { framework: 'static' };
209
+ }
210
+ const slateConfigDetails = {
211
+ framework: frameworkOpt,
212
+ install_command: slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.install_command.value,
213
+ build_path: slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.output_dir.value,
214
+ build_command: slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.build_command.value,
215
+ root_path: './'
216
+ };
217
+ let editDefaultConfig;
218
+ if (!(0, option_1.getOptionValue)('default')) {
219
+ if (slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings) {
220
+ (0, console_1.log)(`Auto-detected App Configuration (${(0, ansi_colors_1.bold)(frameworkOpt)}):\n` +
221
+ `${(0, ansi_colors_1.grey)((0, ansi_colors_1.bold)('Install Command: ') +
222
+ (slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.install_command.placeholder))}\n` +
223
+ `${(0, ansi_colors_1.grey)((0, ansi_colors_1.bold)('Build Command: ') + (slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.build_command.placeholder))}\n` +
224
+ `${(0, ansi_colors_1.grey)((0, ansi_colors_1.bold)('Build Path: ') + (slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.output_dir.placeholder))}`);
225
+ editDefaultConfig = yield prompt_1.default.ask(prompt_1.default.question('config', 'Do you want to modify these default configurations?', {
226
+ type: 'confirm',
227
+ default: false
228
+ }));
229
+ }
230
+ else {
231
+ (0, logger_1.warning)('Unable to detect the app configuration for the selected framework.');
232
+ }
233
+ }
234
+ if (!(slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings) || (editDefaultConfig === null || editDefaultConfig === void 0 ? void 0 : editDefaultConfig.config)) {
235
+ const config = yield prompt_1.default.ask(prompt_1.default.question('installCommand', 'Provide your Install Command:', {
236
+ type: 'input',
237
+ validate: (value) => __awaiter(this, void 0, void 0, function* () {
238
+ value = value.trim();
239
+ if (value === '')
240
+ return 'Please provide a valid install command';
241
+ else if (value.length > 50)
242
+ return 'Cannot exceed 50 characters.';
243
+ return true;
244
+ })
245
+ }), prompt_1.default.question('buildCommand', 'Provide your Build Command:', {
246
+ type: 'input',
247
+ validate: (value) => __awaiter(this, void 0, void 0, function* () {
248
+ value = value.trim();
249
+ if (value === '')
250
+ return 'Please provide a valid build command';
251
+ else if (value.length > 50)
252
+ return 'Cannot exceed 50 characters.';
253
+ return true;
254
+ })
255
+ }), prompt_1.default.question('buildPath', 'Provide your Build Path:', {
256
+ type: 'input',
257
+ validate: (value) => __awaiter(this, void 0, void 0, function* () {
258
+ value = value.trim();
259
+ if (value === '')
260
+ return 'Please provide a valid build path';
261
+ else if (/[#%*$@?]/.test(value))
262
+ return 'Build path containing invalid characters.';
263
+ else if (value.length > 50)
264
+ return 'Cannot exceed 50 characters.';
265
+ return true;
266
+ })
267
+ }));
268
+ (slateConfigDetails.install_command = config.installCommand),
269
+ (slateConfigDetails.build_path = config.buildPath),
270
+ (slateConfigDetails.build_command = config.buildCommand);
271
+ }
272
+ return slateConfigDetails || {};
273
+ });
274
+ }
275
+ exports.default = (add) => __awaiter(void 0, void 0, void 0, function* () {
276
+ const frameworks = yield (yield (0, endpoints_1.slateAPI)()).getFrameworks();
277
+ const templateName = (0, option_1.getOptionValue)('template');
278
+ const frameworkOpt = add
279
+ ? yield detectFramework(yield addExistingSlate(config_1.slateConfig.raw() || []), frameworks)
280
+ : yield getFrameworkOption(frameworks);
281
+ const appName = yield getAppName(config_1.slateConfig.raw() || [], frameworkOpt.name);
282
+ const payload = {
283
+ name: appName,
284
+ source: frameworkOpt.source ||
285
+ (yield handleTemplate(appName, { templateName, frameworkName: frameworkOpt.name }))
286
+ };
287
+ const slateConfigDetails = yield getConfigDetails(frameworkOpt.name, frameworks);
288
+ if (frameworkOpt.name !== 'static') {
289
+ const slateRunConfig = yield prompt_1.default.ask(prompt_1.default.question('devCommand', 'Please provide your Development Command:', {
290
+ type: 'input',
291
+ default: 'npm start',
292
+ validate: (value) => __awaiter(void 0, void 0, void 0, function* () {
293
+ value = value.trim();
294
+ if (value === '')
295
+ return 'Please provide a valid development command';
296
+ else if (value.length > 50)
297
+ return 'Cannot exceed 50 characters.';
298
+ return true;
299
+ })
300
+ }));
301
+ yield fs_1.ASYNC.writeJSONFile((0, path_1.join)(payload.source, constants_1.FILENAME.cli_config), {
302
+ slate: {
303
+ dev_command: slateRunConfig.devCommand
304
+ }
305
+ });
306
+ }
307
+ const pth = path_1.default.join(payload.source, '.catalyst', constants_1.FILENAME.slate_config);
308
+ const warnContent = '# ⚠️ This file is automatically generated by the Catalyst CLI when you link or create a Slate app,and is used only for the initial deployment to the Catalyst console. \
309
+ \n# ⚠️ Please do not modify this file, as it is fully managed by the CLI.\n';
310
+ yield (0, async_1.ensureFile)(pth, true);
311
+ fs_1.ASYNC.writeFile(pth, warnContent + '\n' + (0, toml_1.convertTOML)(slateConfigDetails));
312
+ runtime_store_1.default.set('payload.slate.targets', [payload]);
313
+ });
@@ -54,7 +54,7 @@ class API {
54
54
  json,
55
55
  headers
56
56
  };
57
- const projectSecretKey = process.env.CATALYST_PROJECT_SECRET_KEY;
57
+ const projectSecretKey = process.env.CATALYST_PROJECT_SECRET_KEY || process.env.ZC_PROJECT_SECRET_KEY;
58
58
  if (!isExternal) {
59
59
  this.requestOpts.headers = Object.assign(Object.assign({}, this.requestOpts.headers), { Accept: 'application/vnd.catalyst.v2+json', 'X-CATALYST-Environment': env });
60
60
  if (projectSecretKey) {
@@ -173,14 +173,18 @@ class Command {
173
173
  yield runner.apply(this, programArgs);
174
174
  const duration = Date.now() - start;
175
175
  (0, errorOut_1.default)();
176
- yield (0, track_1.default)(this.cmdName, 'success', duration);
176
+ if (!env_1.isCI) {
177
+ yield (0, track_1.default)(this.cmdName, 'success', duration);
178
+ }
177
179
  }
178
180
  catch (err) {
179
- const duration = Date.now() - start;
180
- const errorEvent = err.exit === 1 ? 'Error (User)' : 'Error (Unexpected)';
181
- const preppedMessage = (0, strip_ansi_1.default)(err.message || '');
182
181
  (0, errorOut_1.default)(err);
183
- yield (0, track_1.default)(errorEvent, preppedMessage, duration);
182
+ if (!env_1.isCI) {
183
+ const duration = Date.now() - start;
184
+ const errorEvent = err.exit === 1 ? 'Error (User)' : 'Error (Unexpected)';
185
+ const preppedMessage = (0, strip_ansi_1.default)(err.message || '');
186
+ yield (0, track_1.default)(errorEvent, preppedMessage, duration);
187
+ }
184
188
  }
185
189
  }));
186
190
  if (this.subCommand) {
@@ -237,5 +241,5 @@ class Command {
237
241
  });
238
242
  }
239
243
  }
240
- Command.globalOpts = ['project', 'token', 'dc', 'org'];
244
+ Command.globalOpts = ['project', 'token', 'dc', 'org', 'verbose'];
241
245
  exports.default = Command;
@@ -30,6 +30,7 @@ const featureRef = {
30
30
  bio: 'basicio',
31
31
  master: 'master',
32
32
  appsail: 'appsail',
33
+ slate: 'slate',
33
34
  browserlogic: 'browser_logic'
34
35
  };
35
36
  class PortResolver {
@@ -69,6 +70,12 @@ class PortResolver {
69
70
  }
70
71
  port = constants_1.DEFAULT.serve_port['http']['appsail'][server];
71
72
  }
73
+ else if (feature === 'slate') {
74
+ if (!server || type !== 'http') {
75
+ throw new error_1.default('Invalid slate details', { exit: 2 });
76
+ }
77
+ port = constants_1.DEFAULT.serve_port['http']['slate'][server];
78
+ }
72
79
  else {
73
80
  port = constants_1.DEFAULT.serve_port[type][featureRef[feature]];
74
81
  }
@@ -56,30 +56,46 @@ const choice = (name, _a = {}) => {
56
56
  disabled,
57
57
  checked }, otherOpts);
58
58
  };
59
+ const registeredTypes = new Map();
59
60
  exports.default = {
60
61
  register: (type) => __awaiter(void 0, void 0, void 0, function* () {
62
+ if (registeredTypes.has(type))
63
+ return;
64
+ let module;
61
65
  switch (type) {
62
66
  case 'file-path':
63
- const filePathExt = yield Promise.resolve().then(() => __importStar(require('./types/file-path')));
64
- inquirer_1.default.registerPrompt('file-path', filePathExt.default);
67
+ module = yield Promise.resolve().then(() => __importStar(require('./types/file-path')));
65
68
  break;
66
69
  case 'tree':
67
- const treeExt = yield Promise.resolve().then(() => __importStar(require('./types/tree')));
68
- inquirer_1.default.registerPrompt('tree', treeExt.default);
70
+ module = yield Promise.resolve().then(() => __importStar(require('./types/tree')));
69
71
  break;
70
72
  case 'search-box':
71
- const searchExt = yield Promise.resolve().then(() => __importStar(require('./types/search-box')));
72
- inquirer_1.default.registerPrompt('search-box', searchExt.default);
73
+ module = yield Promise.resolve().then(() => __importStar(require('./types/search-box')));
73
74
  break;
74
75
  default:
75
76
  throw new error_1.default('No such type registered', { exit: 2 });
76
77
  }
78
+ inquirer_1.default.registerPrompt(type, module.default);
79
+ registeredTypes.set(type, module.default);
77
80
  }),
81
+ deregister: (type) => {
82
+ registeredTypes.delete(type);
83
+ inquirer_1.default.restoreDefaultPrompts();
84
+ },
78
85
  separator: (line) => {
79
86
  return new inquirer_1.default.Separator(line);
80
87
  },
81
88
  choice,
82
89
  ask: (...questions) => {
90
+ for (const question of questions) {
91
+ if (question.type && ['file-path', 'tree', 'search-box'].includes(question.type)) {
92
+ if (!registeredTypes.has(question.type)) {
93
+ throw new error_1.default(`Prompt type "${question.type}" is not registered.`, {
94
+ exit: 2
95
+ });
96
+ }
97
+ }
98
+ }
83
99
  return inquirer_1.default.prompt(questions);
84
100
  },
85
101
  question: (name, question, _a = {}) => {
@@ -17,10 +17,11 @@ const inquirer_autocomplete_prompt_1 = __importDefault(require("inquirer-autocom
17
17
  const fuzzy_1 = __importDefault(require("fuzzy"));
18
18
  const fs_1 = require("../../util_modules/fs");
19
19
  const ansi_colors_1 = require("ansi-colors");
20
- function getPaths(rootPath, pattern, exclude, defaultItem) {
20
+ function getPaths(rootPath, pattern, exclude, excludeDir, ignoreFiles, defaultItem, depth) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
22
  const nodeList = yield fs_1.ASYNC.walk(rootPath, {
23
- filter: { exclude, excludeDir: false },
23
+ filter: { exclude, excludeDir, ignoreFiles },
24
+ depth,
24
25
  includeDirPaths: true
25
26
  });
26
27
  const filteredNodes = fuzzy_1.default
@@ -34,13 +35,15 @@ function getPaths(rootPath, pattern, exclude, defaultItem) {
34
35
  }
35
36
  class InquirerFilePath extends inquirer_autocomplete_prompt_1.default {
36
37
  constructor(question, rl, answers) {
37
- const { rootPath = '.', exclude = [] } = question;
38
+ const { rootPath = '.', exclude = [], excludeDir = false, ignoreFiles = false } = question;
38
39
  const questionBase = Object.assign({
39
- emptyText: 'No valid file path inside current directory!. Try giving the entire path and press ' +
40
- (0, ansi_colors_1.cyan)('<return> ') +
41
- 'key'
40
+ emptyText: question.empTxt
41
+ ? question.empTxt
42
+ : 'No valid file path inside current directory!. Try giving the entire path and press ' +
43
+ (0, ansi_colors_1.cyan)('<return> ') +
44
+ 'key'
42
45
  }, question, {
43
- source: (_, pattern) => getPaths(rootPath, pattern, exclude, question.default)
46
+ source: (_, pattern) => getPaths(rootPath, pattern, exclude, excludeDir, ignoreFiles, question.default, question.depth)
44
47
  });
45
48
  super(questionBase, rl, answers);
46
49
  }
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.appsail = exports.apig = exports.functions = exports.client = void 0;
38
+ exports.slate = exports.appsail = exports.apig = exports.functions = exports.client = void 0;
39
39
  const error_1 = __importDefault(require("../../error"));
40
40
  const port_resolver_1 = __importDefault(require("../../port-resolver"));
41
41
  const runtime_store_1 = __importDefault(require("../../runtime-store"));
@@ -81,3 +81,10 @@ function appsail() {
81
81
  });
82
82
  }
83
83
  exports.appsail = appsail;
84
+ function slate() {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ const appSailModule = yield Promise.resolve().then(() => __importStar(require('./slate.js')));
87
+ yield appSailModule.default();
88
+ });
89
+ }
90
+ exports.slate = slate;
@@ -0,0 +1,47 @@
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 error_1 = __importDefault(require("../../error"));
16
+ const port_resolver_1 = __importDefault(require("../../port-resolver"));
17
+ const runtime_store_1 = __importDefault(require("../../runtime-store"));
18
+ const slate_utils_1 = require("../../slate-utils");
19
+ const config_1 = require("../../util_modules/config");
20
+ const logger_1 = require("../../util_modules/logger");
21
+ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
22
+ const allTargets = yield config_1.slateConfig.getAllTargetDetails();
23
+ const optionTargets = slate_utils_1.slateUtils.filterTargets(allTargets || []);
24
+ if (optionTargets.length === 0) {
25
+ (0, logger_1.debug)('Slate targets are empty');
26
+ return;
27
+ }
28
+ const validated = (0, slate_utils_1.validateServeCommand)(optionTargets);
29
+ const filledTargets = yield Promise.all(validated.map((targ) => __awaiter(void 0, void 0, void 0, function* () {
30
+ if (!targ.validity.valid) {
31
+ return targ;
32
+ }
33
+ const proxyPort = yield port_resolver_1.default.getPort('slate', 'http', {
34
+ name: targ.name + '_proxy',
35
+ searchSpan: 10,
36
+ server: 'master'
37
+ }).catch((err) => {
38
+ throw new error_1.default('No free ports between 3000 and 3010. Slate needs the ports within this range to function properly', { original: err });
39
+ });
40
+ const slatePort = yield port_resolver_1.default.getPort('slate', 'http', {
41
+ name: targ.name + '_proxy',
42
+ server: 'service'
43
+ });
44
+ return Object.assign(Object.assign({}, targ), { port: { slate: slatePort, proxy: proxyPort }, trigger: { kill: false } });
45
+ })));
46
+ runtime_store_1.default.set('context.slate.targets', filledTargets);
47
+ });
@@ -24,6 +24,7 @@ const index_js_2 = __importDefault(require("./lib/node/index.js"));
24
24
  const index_js_3 = __importDefault(require("./lib/python/index.js"));
25
25
  const index_js_4 = __importDefault(require("./lib/web_client/index.js"));
26
26
  const index_js_5 = __importDefault(require("./lib/appsail/index.js"));
27
+ const index_js_6 = __importDefault(require("./lib/slate/index.js"));
27
28
  const cli_table_1 = require("../../cli_table");
28
29
  const ansi_colors_1 = require("ansi-colors");
29
30
  const bioLogUrl = (details, masterPort, addSpaces) => {
@@ -50,7 +51,8 @@ class Server {
50
51
  functions: [],
51
52
  server: [],
52
53
  client: [],
53
- appSail: []
54
+ appSail: [],
55
+ slate: []
54
56
  };
55
57
  }
56
58
  _addBasicFnDetails(bioUrlLogs) {
@@ -95,6 +97,15 @@ class Server {
95
97
  });
96
98
  return;
97
99
  }
100
+ if (type === 'slate') {
101
+ this.targetsMap.slate.push({
102
+ type,
103
+ target: target,
104
+ httpPort: -1,
105
+ debugPort: -1
106
+ });
107
+ return;
108
+ }
98
109
  const httpPort = runtime_store_1.default.get(`context.port.http.${type === 'server' ? 'functions' : type}.${target.name}`, -1);
99
110
  const debugPort = runtime_store_1.default.get(`context.port.debug.${type === 'server' ? 'functions' : type}.${target.name}`, -1);
100
111
  if (httpPort === -1) {
@@ -129,6 +140,10 @@ class Server {
129
140
  currentProcess = yield (0, index_js_5.default)(details);
130
141
  break;
131
142
  }
143
+ case 'slate': {
144
+ currentProcess = yield (0, index_js_6.default)(details);
145
+ break;
146
+ }
132
147
  case 'client': {
133
148
  currentProcess = yield (0, index_js_4.default)(details, masterPort);
134
149
  break;
@@ -177,6 +192,11 @@ class Server {
177
192
  target.valid = false;
178
193
  (0, logger_1.labeled)(`WebClient[${details.target}]`, error).ERROR();
179
194
  }
195
+ else if (details.type === 'slate') {
196
+ const target = details.target;
197
+ target.validity.valid = false;
198
+ (0, logger_1.labeled)(`Slate[${target.name}]`, error).ERROR();
199
+ }
180
200
  else {
181
201
  const target = details.target;
182
202
  target.valid = false;
@@ -195,6 +215,7 @@ class Server {
195
215
  browserlogic: { targs: [], nameMaxLength: 0 }
196
216
  },
197
217
  appsail: { targs: [], nameMaxLength: 0 },
218
+ slate: { targs: [], nameMaxLength: 0 },
198
219
  client: {}
199
220
  };
200
221
  this._addBasicFnDetails(logUrls.functions.bio);
@@ -297,6 +318,21 @@ class Server {
297
318
  : logUrls.appsail.nameMaxLength;
298
319
  })));
299
320
  }
321
+ if (this.targetsMap.slate.length > 0) {
322
+ yield Promise.all(this.targetsMap.slate.map((targSlate) => this.startServer(targSlate, -1).then((details) => {
323
+ var _a, _b, _c, _d;
324
+ const serverDetails = details;
325
+ if (!((_a = serverDetails.target) === null || _a === void 0 ? void 0 : _a.validity.valid)) {
326
+ return;
327
+ }
328
+ logUrls.slate.targs.push(targSlate);
329
+ logUrls.slate.nameMaxLength =
330
+ ((_b = targSlate.target) === null || _b === void 0 ? void 0 : _b.name) &&
331
+ ((_c = targSlate.target) === null || _c === void 0 ? void 0 : _c.name.length) > logUrls.slate.nameMaxLength
332
+ ? (_d = targSlate.target) === null || _d === void 0 ? void 0 : _d.name.length
333
+ : logUrls.slate.nameMaxLength;
334
+ })));
335
+ }
300
336
  let loggedEntries = 0;
301
337
  Object.entries(logUrls).forEach(([targType, logTarg]) => {
302
338
  var _a;
@@ -422,6 +458,30 @@ class Server {
422
458
  (0, logger_1.info)();
423
459
  break;
424
460
  }
461
+ case 'slate': {
462
+ const _logTarg = logTarg;
463
+ if (_logTarg.targs.length === 0) {
464
+ return;
465
+ }
466
+ loggedEntries++;
467
+ let isHeaderDisplayed = false;
468
+ _logTarg.targs.forEach((t) => {
469
+ const targetSlate = t.target;
470
+ if (!targetSlate.validity.valid) {
471
+ return;
472
+ }
473
+ if (isHeaderDisplayed === false) {
474
+ (0, logger_1.info)();
475
+ (0, logger_1.info)((0, ansi_colors_1.bold)(' >>>>>>>>>>>>>> Slate <<<<<<<<<<<<<< '));
476
+ isHeaderDisplayed = true;
477
+ }
478
+ const targName = targetSlate.name + '';
479
+ (0, logger_1.labeled)(targName +
480
+ ' '.repeat((_logTarg.nameMaxLength || targName.length) - targName.length), `http://localhost:${targetSlate.port.proxy}`).MESSAGE();
481
+ });
482
+ (0, logger_1.info)();
483
+ break;
484
+ }
425
485
  }
426
486
  });
427
487
  return loggedEntries > 0