zcatalyst-cli 1.18.0-beta.11 → 1.18.0-beta.11-slate

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 (50) hide show
  1. package/docs/commands/slate/unlink.toml +9 -0
  2. package/docs/option-filter.toml +5 -0
  3. package/docs/serve/server/lib/slate/index.toml +14 -0
  4. package/docs/slate-utils.toml +4 -0
  5. package/lib/archiver.js +18 -9
  6. package/lib/command_needs/auth.js +1 -1
  7. package/lib/command_needs/rc.js +40 -3
  8. package/lib/commands/deploy/index.js +6 -1
  9. package/lib/commands/deploy/slate.js +58 -0
  10. package/lib/commands/index.js +3 -0
  11. package/lib/commands/init.js +4 -0
  12. package/lib/commands/slate/create.js +60 -0
  13. package/lib/commands/slate/link.js +60 -0
  14. package/lib/commands/slate/unlink.js +74 -0
  15. package/lib/deploy/features/index.js +3 -0
  16. package/lib/deploy/features/slate.js +123 -0
  17. package/lib/endpoints/index.js +8 -1
  18. package/lib/endpoints/lib/slate.js +91 -0
  19. package/lib/fn-utils/lib/common.js +1 -1
  20. package/lib/init/features/appsail/index.js +1 -1
  21. package/lib/init/features/index.js +15 -2
  22. package/lib/init/features/project.js +1 -1
  23. package/lib/init/features/slate/index.js +308 -0
  24. package/lib/internal/api.js +1 -1
  25. package/lib/internal/command.js +9 -5
  26. package/lib/option-filter.js +8 -2
  27. package/lib/port-resolver.js +7 -0
  28. package/lib/prompt/types/file-path.js +8 -5
  29. package/lib/serve/features/index.js +8 -1
  30. package/lib/serve/features/slate.js +47 -0
  31. package/lib/serve/index.js +19 -0
  32. package/lib/serve/server/index.js +61 -1
  33. package/lib/serve/server/lib/appsail/index.js +1 -1
  34. package/lib/serve/server/lib/master/index.js +25 -21
  35. package/lib/serve/server/lib/master/slate.js +45 -0
  36. package/lib/serve/server/lib/master/utils.js +2 -2
  37. package/lib/serve/server/lib/slate/index.js +144 -0
  38. package/lib/serve/server/lib/slate/static-server.js +193 -0
  39. package/lib/slate-utils.js +212 -0
  40. package/lib/util_modules/config/index.js +3 -1
  41. package/lib/util_modules/config/lib/slate.js +94 -0
  42. package/lib/util_modules/constants/lib/default.js +4 -0
  43. package/lib/util_modules/constants/lib/file-names.js +7 -1
  44. package/lib/util_modules/constants/lib/folder-names.js +1 -0
  45. package/lib/util_modules/constants/lib/scopes.js +3 -1
  46. package/lib/util_modules/context-help.js +2 -2
  47. package/lib/util_modules/fs/lib/async.js +8 -1
  48. package/lib/util_modules/fs/lib/sync.js +6 -1
  49. package/lib/util_modules/parser/toml.js +20 -5
  50. package/package.json +2 -2
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
32
  });
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.tunnelAPI = exports.commonAPI = exports.jobScheduling = exports.codeDeck = exports.gitHubAPI = exports.stratusAPI = exports.zestAPI = exports.appSailAPI = exports.logAPI = exports.eventBusAPI = exports.functionsAPI = exports.applogicAPI = exports.bulkDSAPI = exports.apigAPI = exports.clientAPI = exports.datastoreAPI = exports.zcqlAPI = exports.queueAPI = exports.filestoreAPI = exports.cacheAPI = exports.sdkAPI = exports.envAPI = exports.projectAPI = exports.orgAPI = void 0;
35
+ exports.tunnelAPI = exports.commonAPI = exports.jobScheduling = exports.codeDeck = exports.gitHubAPI = exports.stratusAPI = exports.zestAPI = exports.appSailAPI = exports.logAPI = exports.eventBusAPI = exports.functionsAPI = exports.applogicAPI = exports.bulkDSAPI = exports.apigAPI = exports.slateAPI = exports.clientAPI = exports.datastoreAPI = exports.zcqlAPI = exports.queueAPI = exports.filestoreAPI = exports.cacheAPI = exports.sdkAPI = exports.envAPI = exports.projectAPI = exports.orgAPI = void 0;
36
36
  const project_1 = require("../util_modules/project");
37
37
  function orgAPI({ auth = true } = {}) {
38
38
  return __awaiter(this, void 0, void 0, function* () {
@@ -104,6 +104,13 @@ function clientAPI({ auth = true, projectId = (0, project_1.getProjectId)(), env
104
104
  });
105
105
  }
106
106
  exports.clientAPI = clientAPI;
107
+ function slateAPI({ auth = true, projectId = (0, project_1.getProjectId)(), env = (0, project_1.getEnvName)() } = {}) {
108
+ return __awaiter(this, void 0, void 0, function* () {
109
+ const slate = (yield Promise.resolve().then(() => __importStar(require('./lib/slate')))).default;
110
+ return new slate(projectId, { authNeeded: auth, env });
111
+ });
112
+ }
113
+ exports.slateAPI = slateAPI;
107
114
  function apigAPI({ auth = true, projectId = (0, project_1.getProjectId)(), env = (0, project_1.getEnvName)() } = {}) {
108
115
  return __awaiter(this, void 0, void 0, function* () {
109
116
  const apig = (yield Promise.resolve().then(() => __importStar(require('./lib/apig')))).default;
@@ -0,0 +1,91 @@
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 api_1 = __importDefault(require("../../internal/api"));
17
+ const logger_1 = require("../../util_modules/logger");
18
+ class Slate {
19
+ constructor(projectId, opts) {
20
+ this.opts = opts;
21
+ this.projectId = projectId;
22
+ }
23
+ getFrameworks() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const response = yield new api_1.default(this.opts).get('/slate/v1/frameworks', {
26
+ log: {
27
+ awaitingSpinner: 'Fetching frameworks from the server ...'
28
+ }
29
+ });
30
+ if (response.body && response.body.data) {
31
+ return response.body.data;
32
+ }
33
+ throw new error_1.default('Error while fetching the frameworks', { exit: 2 });
34
+ });
35
+ }
36
+ getAllApps() {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const response = yield new api_1.default(this.opts).get(`/slate/v1/project/${this.projectId}/app`, {
39
+ log: {
40
+ awaitingSpinner: 'Fetching slate apps'
41
+ }
42
+ });
43
+ if (response.body && response.body.data) {
44
+ return response.body.data;
45
+ }
46
+ throw new error_1.default('Error while fetching the frameworks', { exit: 2 });
47
+ });
48
+ }
49
+ downloadTemplate() {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ this.opts.origin = 'https://codeload.github.com';
52
+ this.opts.authNeeded = false;
53
+ const response = yield new api_1.default(Object.assign(Object.assign({}, this.opts), { isExternal: true })).get(`/catalystbyzoho/slate/zip/main`, {
54
+ log: {
55
+ awaitingSpinner: 'Download template from github ...'
56
+ },
57
+ encoding: null
58
+ });
59
+ if (response.body) {
60
+ return response.body;
61
+ }
62
+ throw new error_1.default('Error while downloading the template', { exit: 2 });
63
+ });
64
+ }
65
+ deploy(sourceStream, contentLength, appName, deployId, appId, config, msg) {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ const formData = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ file: sourceStream }, (appId && { app_id: appId })), (deployId && { build_id: deployId })), (appId || deployId ? {} : { name: appName })), (config && { configuration: config })), (msg && { message: msg }));
68
+ const res = yield new api_1.default(this.opts).post(`/slate/v1/project/${this.projectId}/app/upload`, {
69
+ formData,
70
+ json: false,
71
+ log: {
72
+ uploadProgress: {
73
+ title: `Slate[${appName}]`,
74
+ total: contentLength,
75
+ progressType: 'upload'
76
+ },
77
+ stream: sourceStream,
78
+ awaitingSpinner: 'deploying slate'
79
+ }
80
+ });
81
+ if (res.body && res.body.data) {
82
+ return res.body.data;
83
+ }
84
+ (0, logger_1.debug)('deploy slate response from server : ' + res.body);
85
+ throw new error_1.default('Server Error: Unexpected Response from server.', {
86
+ exit: 2
87
+ });
88
+ });
89
+ }
90
+ }
91
+ exports.default = Slate;
@@ -506,7 +506,7 @@ function getSDK(fnType, dest, stack, options = {}) {
506
506
  }
507
507
  yield new archiver_1.default()
508
508
  .load(sdkZip)
509
- .extract(dest, new RegExp(`catalyst-${stack}`), { ignoreInitial: true })
509
+ .extract(dest, new RegExp(`catalyst-${stack}`), { ignoreLevel: 1 })
510
510
  .finalize();
511
511
  });
512
512
  }
@@ -97,7 +97,7 @@ function getAppSailZip() {
97
97
  zip.load(code);
98
98
  zip.extract(repoDir, '/', {
99
99
  isFolder: true,
100
- ignoreInitial: true
100
+ ignoreLevel: 1
101
101
  });
102
102
  yield zip.finalize();
103
103
  (0, logger_1.success)(`Successfully downloaded the code to ${ansi_colors_1.bold.green(gitRepo.repo.source)}`);
@@ -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.project = exports.client = exports.functions = exports.setCatalystConfig = void 0;
38
+ exports.appsail = exports.project = exports.slate = exports.client = exports.functions = exports.setCatalystConfig = void 0;
39
39
  const ansi_colors_1 = require("ansi-colors");
40
40
  const path_1 = require("path");
41
41
  const error_1 = __importDefault(require("../../error"));
@@ -118,6 +118,11 @@ function setCatalystConfig(featureName, add) {
118
118
  config.unset('client.plugin');
119
119
  }
120
120
  break;
121
+ case 'slate': {
122
+ const targetArr = config.get('slate', []);
123
+ config.set('slate', js_1.JS.uniq(targetArr.concat([context])));
124
+ break;
125
+ }
121
126
  case 'apig':
122
127
  config.set('apig.rules', targetSource);
123
128
  config.set('apig.enabled', true);
@@ -140,6 +145,13 @@ function client() {
140
145
  });
141
146
  }
142
147
  exports.client = client;
148
+ function slate(add = false) {
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ yield (yield Promise.resolve().then(() => __importStar(require('./slate/index.js')))).default(add);
151
+ setCatalystConfig('slate', false);
152
+ });
153
+ }
154
+ exports.slate = slate;
143
155
  function project() {
144
156
  return __awaiter(this, void 0, void 0, function* () {
145
157
  yield (yield Promise.resolve().then(() => __importStar(require('./project.js')))).default();
@@ -175,5 +187,6 @@ exports.default = {
175
187
  functions,
176
188
  client,
177
189
  project,
178
- appsail
190
+ appsail,
191
+ slate
179
192
  };
@@ -103,7 +103,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
103
103
  }
104
104
  const [zipArchive, template, importRes] = yield (0, import_1.iacImport)();
105
105
  yield zipArchive
106
- .extract(runtime_store_1.default.get('cwd'), '/', { recursive: true, ignoreInitial: false })
106
+ .extract(runtime_store_1.default.get('cwd'), '/', { recursive: true, ignoreLevel: 0 })
107
107
  .finalize();
108
108
  const parsedJSON = js_1.JS.parseJSON(template);
109
109
  const templateJson = parsedJSON ? parsedJSON : (0, yaml_1.parse)(template);
@@ -0,0 +1,308 @@
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 slate_1 = require("../../../deploy/features/slate");
53
+ const toml_1 = require("../../../util_modules/parser/toml");
54
+ const async_1 = require("../../../util_modules/fs/lib/async");
55
+ function getFrameworkOption(frameworks, source) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ let frameworkOpt = (0, option_1.getOptionValue)('framework');
58
+ if (frameworkOpt &&
59
+ frameworks.findIndex((framework) => framework.name === frameworkOpt) === -1) {
60
+ (0, logger_1.warning)('Given framework is not supported in Slate.');
61
+ frameworkOpt = '';
62
+ }
63
+ if (!frameworkOpt) {
64
+ const filteredFrameworks = frameworks.filter((framework) => framework.name !== 'other');
65
+ const { selectedFramework } = yield prompt_1.default.ask(prompt_1.default.question('selectedFramework', 'Select a framework to start with: ', {
66
+ type: 'list',
67
+ choices: filteredFrameworks.map(({ label, name }) => prompt_1.default.choice(label, { value: name, short: label }))
68
+ }));
69
+ frameworkOpt = selectedFramework;
70
+ }
71
+ return { name: frameworkOpt, source };
72
+ });
73
+ }
74
+ function validateAppName(appName) {
75
+ if (appName.length === 0) {
76
+ return 'App name cannot be empty';
77
+ }
78
+ if (appName.length > 45) {
79
+ return 'App name cannot be more than 45 characters';
80
+ }
81
+ if (!appName.match(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/)) {
82
+ return 'App name must be alphanumeric and contain only a single hyphen in the middle.';
83
+ }
84
+ return true;
85
+ }
86
+ function getAppName(existingSlates, frameworkOpt) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ let appName = (0, option_1.getOptionValue)('name');
89
+ const remoteApps = yield (yield (0, endpoints_1.slateAPI)({ env: (0, slate_1.getEnvironmentType)() })).getAllApps();
90
+ if (!appName) {
91
+ const { name } = yield prompt_1.default.ask(prompt_1.default.question('name', 'Please provide the name for your app:', {
92
+ type: 'input',
93
+ default: frameworkOpt,
94
+ validate: (name) => {
95
+ if (existingSlates.findIndex((targ) => targ.name === name) !== -1)
96
+ return 'Slate already configured with this name.';
97
+ if (remoteApps.findIndex((targ) => targ.name === name) !== -1)
98
+ return 'App with this name already exists in remote.';
99
+ return validateAppName(name);
100
+ }
101
+ }));
102
+ appName = name;
103
+ }
104
+ else {
105
+ if (existingSlates.findIndex((targ) => targ.name === appName) !== -1) {
106
+ throw new error_1.default('Slate already configured with this name.');
107
+ }
108
+ else if (remoteApps.findIndex((targ) => targ.name === appName) !== -1)
109
+ return 'App with this name already exists in remote.';
110
+ else {
111
+ const isValidApp = validateAppName(appName);
112
+ if (isValidApp !== true) {
113
+ throw new error_1.default(isValidApp + '');
114
+ }
115
+ }
116
+ }
117
+ return appName;
118
+ });
119
+ }
120
+ function handleTemplate(appName, { templateName, frameworkName } = {}) {
121
+ return __awaiter(this, void 0, void 0, function* () {
122
+ const projectRoot = (0, project_1.getProjectRoot)();
123
+ const appPath = path_1.default.join(projectRoot, appName);
124
+ const folderExists = yield fs_1.ASYNC.dirExists(appPath);
125
+ const overwriteAns = folderExists
126
+ ? yield prompt_1.default.ask(prompt_1.default.question('overwrite', `Directory ${(0, ansi_colors_1.underline)(appPath)} already exists. Overwrite?`, {
127
+ type: 'confirm',
128
+ default: false
129
+ }))
130
+ : { overwrite: true };
131
+ if (!overwriteAns.overwrite) {
132
+ (0, logger_1.warning)('Skipping slate template setup');
133
+ return appPath;
134
+ }
135
+ yield fs_1.ASYNC.deleteDir(appPath).catch(console_1.error);
136
+ const templatePath = 'slate-main' + (templateName ? `/templates/${templateName}` : `/examples/${frameworkName}`);
137
+ const responseZip = (yield (yield (0, endpoints_1.slateAPI)()).downloadTemplate());
138
+ yield new archiver_1.default()
139
+ .load(responseZip)
140
+ .extract(appPath, templatePath, {
141
+ ignoreLevel: 3
142
+ })
143
+ .finalize();
144
+ return appPath;
145
+ });
146
+ }
147
+ function addExistingSlate(existingSlates) {
148
+ return __awaiter(this, void 0, void 0, function* () {
149
+ yield prompt_1.default.register('file-path');
150
+ const projectRoot = (0, project_1.getProjectRoot)();
151
+ const { sourcePath } = yield prompt_1.default.ask(prompt_1.default.question('sourcePath', 'Please provide the source path of your slate service: ', {
152
+ type: 'file-path',
153
+ validate: (pth) => __awaiter(this, void 0, void 0, function* () {
154
+ const buildPath = (0, path_1.resolve)(projectRoot, pth.value);
155
+ if (existingSlates.findIndex((targ) => targ.source === buildPath) !== -1)
156
+ return 'Path is already linked.';
157
+ if (yield fs_1.ASYNC.dirExists(buildPath)) {
158
+ return true;
159
+ }
160
+ return 'Path does not exist';
161
+ }),
162
+ depth: 5,
163
+ empTxt: ' ',
164
+ rootPath: projectRoot
165
+ }));
166
+ return sourcePath;
167
+ });
168
+ }
169
+ function detectFramework(source, frameworkList) {
170
+ return __awaiter(this, void 0, void 0, function* () {
171
+ const frameworkOpt = (0, option_1.getOptionValue)('framework');
172
+ if (frameworkOpt &&
173
+ frameworkList.findIndex((framework) => framework.name === frameworkOpt) === -1) {
174
+ return { name: frameworkOpt, source };
175
+ }
176
+ const packageJsonPath = (0, path_1.join)(source, constants_1.FILENAME.package_json);
177
+ const packageJsonExists = yield fs_1.ASYNC.fileExists(packageJsonPath);
178
+ if (!packageJsonExists) {
179
+ (0, logger_1.warning)('Unable to find the package.json file at the given source path');
180
+ return getFrameworkOption(frameworkList, source);
181
+ }
182
+ const data = yield fs_1.ASYNC.readJSONFile(packageJsonPath);
183
+ const dependencies = Object.assign(Object.assign({}, data === null || data === void 0 ? void 0 : data.dependencies), data === null || data === void 0 ? void 0 : data.devDependencies);
184
+ if (!dependencies) {
185
+ (0, logger_1.warning)('The package.json file does not contain dependencies');
186
+ return getFrameworkOption(frameworkList, source);
187
+ }
188
+ const isReact = dependencies['react'] !== undefined && dependencies['react-dom'] !== undefined;
189
+ const isVite = dependencies['vite'] !== undefined || dependencies['@vitejs/plugin-react'] !== undefined;
190
+ if (isReact && isVite) {
191
+ return { name: 'react-vite', source };
192
+ }
193
+ const isNextJs = dependencies['react'] !== undefined && dependencies['next'] !== undefined;
194
+ if (isNextJs) {
195
+ return { name: 'nextjs', source };
196
+ }
197
+ const framework = frameworkList.find(({ keywords }) => keywords.some((keyword) => dependencies[keyword] !== undefined));
198
+ if (!framework) {
199
+ (0, logger_1.warning)('No matching framework found in package.json dependencies');
200
+ return getFrameworkOption(frameworkList);
201
+ }
202
+ return { name: framework.name, source };
203
+ });
204
+ }
205
+ function getConfigDetails(frameworkOpt, frameworks) {
206
+ return __awaiter(this, void 0, void 0, function* () {
207
+ const slateConfigs = frameworks.find((framework) => frameworkOpt.toLowerCase() === framework.name);
208
+ if (frameworkOpt === 'static') {
209
+ return { framework: 'static' };
210
+ }
211
+ const slateConfigDetails = {
212
+ framework: frameworkOpt,
213
+ install_command: slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.install_command.value,
214
+ build_path: slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.output_dir.value,
215
+ build_command: slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.build_command.value,
216
+ root_path: './'
217
+ };
218
+ let editDefaultConfig;
219
+ if (!(0, option_1.getOptionValue)('default')) {
220
+ if (slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings) {
221
+ (0, console_1.log)(`Auto-detected App Configuration (${(0, ansi_colors_1.bold)(frameworkOpt)}):\n` +
222
+ `${(0, ansi_colors_1.grey)((0, ansi_colors_1.bold)('Install Command: ') +
223
+ (slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.install_command.placeholder))}\n` +
224
+ `${(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` +
225
+ `${(0, ansi_colors_1.grey)((0, ansi_colors_1.bold)('Build Path: ') + (slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.output_dir.placeholder))}`);
226
+ editDefaultConfig = yield prompt_1.default.ask(prompt_1.default.question('config', 'Do you want to modify these default configurations?', {
227
+ type: 'confirm',
228
+ default: false
229
+ }));
230
+ }
231
+ else {
232
+ (0, logger_1.warning)('Unable to detect the app configuration for the selected framework.');
233
+ }
234
+ }
235
+ if (!(slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings) || (editDefaultConfig === null || editDefaultConfig === void 0 ? void 0 : editDefaultConfig.config)) {
236
+ const config = yield prompt_1.default.ask(prompt_1.default.question('installCommand', 'Provide your Install Command:', {
237
+ type: 'input',
238
+ validate: (value) => __awaiter(this, void 0, void 0, function* () {
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
+ if (value === '')
249
+ return 'Please provide a valid build command';
250
+ else if (value.length > 50)
251
+ return 'Cannot exceed 50 characters.';
252
+ return true;
253
+ })
254
+ }), prompt_1.default.question('buildPath', 'Provide your Build Path:', {
255
+ type: 'input',
256
+ validate: (value) => __awaiter(this, void 0, void 0, function* () {
257
+ if (value === '')
258
+ return 'Please provide a valid build path';
259
+ else if (value.length > 50)
260
+ return 'Cannot exceed 50 characters.';
261
+ return true;
262
+ })
263
+ }));
264
+ (slateConfigDetails.install_command = config.installCommand),
265
+ (slateConfigDetails.build_path = config.buildCommand),
266
+ (slateConfigDetails.build_command = config.buildPath);
267
+ }
268
+ return slateConfigDetails || {};
269
+ });
270
+ }
271
+ exports.default = (add) => __awaiter(void 0, void 0, void 0, function* () {
272
+ const frameworks = yield (yield (0, endpoints_1.slateAPI)()).getFrameworks();
273
+ const templateName = (0, option_1.getOptionValue)('template');
274
+ const frameworkOpt = add
275
+ ? yield detectFramework(yield addExistingSlate(config_1.slateConfig.raw() || []), frameworks)
276
+ : yield getFrameworkOption(frameworks);
277
+ const appName = yield getAppName(config_1.slateConfig.raw() || [], frameworkOpt.name);
278
+ const payload = {
279
+ name: appName,
280
+ source: frameworkOpt.source ||
281
+ (yield handleTemplate(appName, { templateName, frameworkName: frameworkOpt.name }))
282
+ };
283
+ const slateConfigDetails = yield getConfigDetails(frameworkOpt.name, frameworks);
284
+ if (frameworkOpt.name !== 'static') {
285
+ const slateRunConfig = yield prompt_1.default.ask(prompt_1.default.question('devCommand', 'Please provide your Development Command:', {
286
+ type: 'input',
287
+ default: 'npm start',
288
+ validate: (value) => __awaiter(void 0, void 0, void 0, function* () {
289
+ if (value === '')
290
+ return 'Please provide a valid dev command';
291
+ else if (value.length > 50)
292
+ return 'Cannot exceed 50 characters.';
293
+ return true;
294
+ })
295
+ }));
296
+ yield fs_1.ASYNC.writeJSONFile((0, path_1.join)(payload.source, constants_1.FILENAME.cli_config), {
297
+ slate: {
298
+ dev_command: slateRunConfig.devCommand
299
+ }
300
+ });
301
+ }
302
+ const pth = path_1.default.join(payload.source, '.catalyst', constants_1.FILENAME.slate_config);
303
+ 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. \
304
+ \n# ⚠️ Please do not modify this file, as it is fully managed by the CLI.\n';
305
+ yield (0, async_1.ensureFile)(pth, true);
306
+ fs_1.ASYNC.writeFile(pth, warnContent + '\n' + (0, toml_1.convertTOML)(slateConfigDetails));
307
+ runtime_store_1.default.set('payload.slate.targets', [payload]);
308
+ });
@@ -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) {
@@ -40,7 +40,8 @@ const onlyExceptTargets = [
40
40
  { filterName: ['functions'], target: 'functions' },
41
41
  { filterName: ['client'], target: 'client' },
42
42
  { filterName: ['apig'], target: 'apig' },
43
- { filterName: ['appsail'], target: 'appsail' }
43
+ { filterName: ['appsail'], target: 'appsail' },
44
+ { filterName: ['slate'], target: 'slate' }
44
45
  ];
45
46
  const portTargets = [
46
47
  { filterName: ['appsail'], target: 'appsail' },
@@ -221,6 +222,9 @@ function filterTargets(pathSense = true) {
221
222
  if (target === 'appsail') {
222
223
  return true;
223
224
  }
225
+ if (target === 'slate') {
226
+ return true;
227
+ }
224
228
  if (target === 'apig' && (0, option_1.getCurrentCommand)() === 'serve') {
225
229
  return true;
226
230
  }
@@ -241,7 +245,9 @@ function filterTargets(pathSense = true) {
241
245
  else if ((0, option_1.getOptionValue)('except', false)) {
242
246
  const unwantedTargets = validTargetResultants
243
247
  .filter((val) => {
244
- if ((val.target.target === 'functions' || val.target.target === 'appsail') &&
248
+ if ((val.target.target === 'functions' ||
249
+ val.target.target === 'appsail' ||
250
+ val.target.target === 'slate') &&
245
251
  val.hasFilter) {
246
252
  return false;
247
253
  }
@@ -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
  }
@@ -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, defaultItem, depth) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
22
  const nodeList = yield fs_1.ASYNC.walk(rootPath, {
23
23
  filter: { exclude, excludeDir: false },
24
+ depth,
24
25
  includeDirPaths: true
25
26
  });
26
27
  const filteredNodes = fuzzy_1.default
@@ -36,11 +37,13 @@ class InquirerFilePath extends inquirer_autocomplete_prompt_1.default {
36
37
  constructor(question, rl, answers) {
37
38
  const { rootPath = '.', exclude = [] } = 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, 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;