zcatalyst-cli 1.20.2 → 1.21.0
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.
- package/README.md +7 -5
- package/docs/serve/server/lib/slate/index.toml +7 -6
- package/docs/slate-utils.toml +5 -0
- package/lib/commands/deploy/index.js +2 -1
- package/lib/commands/deploy/slate.js +1 -1
- package/lib/commands/index.js +3 -0
- package/lib/commands/init.js +4 -0
- package/lib/commands/slate/create.js +2 -2
- package/lib/commands/slate/link.js +5 -5
- package/lib/commands/slate/unlink.js +1 -1
- package/lib/deploy/features/slate.js +10 -3
- package/lib/endpoints/lib/slate.js +8 -24
- package/lib/init/features/index.js +2 -1
- package/lib/init/features/slate/index.js +107 -34
- package/lib/option-filter.js +8 -2
- package/lib/serve/index.js +19 -0
- package/lib/serve/server/lib/master/index.js +1 -1
- package/lib/serve/server/lib/master/slate.js +1 -17
- package/lib/serve/server/lib/master/utils.js +4 -2
- package/lib/serve/server/lib/slate/index.js +30 -33
- package/lib/serve/server/lib/slate/static-server.js +1 -1
- package/lib/slate-utils.js +7 -1
- package/lib/util_modules/config/lib/slate.js +1 -5
- package/lib/util_modules/constants/lib/scopes.js +3 -1
- package/lib/util_modules/constants/lib/urls.js +30 -61
- package/package.json +1 -1
- package/scripts/send-notification.js +1 -1
- package/templates/event/integ/cliq/command/suggestion_handler.json +1 -1
- package/templates/event/integ/cliq/link_preview/action_handler.json +2 -2
- package/templates/event/integ/cliq/link_preview/after_send_handler.json +2 -2
- package/templates/event/integ/cliq/link_preview/menu_handler.json +2 -2
- package/templates/event/integ/cliq/link_preview/preview_handler.json +2 -2
- package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +3 -3
- package/templates/init/functions/java/integ/cliq/com/handlers/WidgetHandler.java +1 -1
- package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -3
- package/templates/init/functions/node/integ/cliq/handlers/widget-handler.js +1 -1
- package/templates/init/functions/python/integ/cliq/handlers/command_handler.py +3 -3
- package/templates/init/functions/python/integ/cliq/handlers/widget_handler.py +1 -1
- package/docs/endpoints/lib/slate.toml +0 -3
- package/docs/util_modules/config/lib/slate.toml +0 -4
package/README.md
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
<center>
|
|
2
|
-
<a href="https://catalyst.zoho.com/
|
|
3
|
-
<img width="
|
|
2
|
+
<a href="https://catalyst.zoho.com/">
|
|
3
|
+
<img width="150" src="https://static.zohocdn.com/catalyst-cdn/img/Catalyst-Logo-857518f26c.svg">
|
|
4
4
|
</a>
|
|
5
|
+
<h1>Catalyst CLI</h1>
|
|
5
6
|
</center>
|
|
6
7
|
|
|
7
|
-
<center><h1>Catalyst CLI</h1></center>
|
|
8
|
-
|
|
9
8
|
<p>
|
|
10
9
|
The official command line interface of Zoho Catalyst
|
|
11
10
|
</p>
|
|
@@ -16,7 +15,7 @@
|
|
|
16
15
|

|
|
17
16
|
<br>
|
|
18
17
|
|
|
19
|
-
<img align="right" width="350" src="https://
|
|
18
|
+
<img align="right" width="350" src="https://static.zohocdn.com/catalyst-cdn/img/getstartedcli-bb68093919.gif"/>
|
|
20
19
|
|
|
21
20
|
This is the Catalyst Command Line Interface (CLI) Tool. They can be used to:
|
|
22
21
|
|
|
@@ -98,6 +97,9 @@ Command | Description
|
|
|
98
97
|
**functions:config** | Perform advanced configurations such as memory allocation on a function in your project.
|
|
99
98
|
**functions:delete** | Delete a function from the remote console or the local directory.
|
|
100
99
|
**appsail:add** | Link an already existing AppSail app to Catalyst Project.
|
|
100
|
+
**slate:create** | Generates a new Slate app with starter examples.
|
|
101
|
+
**slate:link** | Links an existing local app to the Catalyst Slate service.
|
|
102
|
+
**slate:unlink** | Removes the linked Slate configuration from the local app.
|
|
101
103
|
**codelib:install** | Install the code library functionalities into your project.
|
|
102
104
|
**event:generate \| generate:event** | Generate sample payloads from different components or custom event sources to test Event functions.
|
|
103
105
|
**event:generate:integ** | Generate sample payloads for the required integration service to test Integration functions.
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
[SERVE-SLATE-1]
|
|
2
2
|
context = '''The given app is not configured with catalyst project.'''
|
|
3
|
-
aid = '''Please run the command ${arg[
|
|
4
|
-
link = ''
|
|
3
|
+
aid = '''Please run the command ${arg[0]} to link your app with catalyst project.'''
|
|
4
|
+
link = 'https://docs.catalyst.zoho.com/en/cli/v1/working-with-slate/create-slate-app/'
|
|
5
5
|
|
|
6
6
|
[SERVE-SLATE-2]
|
|
7
|
-
context = '''Not able to start the server using the given development command ${arg[
|
|
7
|
+
context = '''Not able to start the server using the given development command ${arg[0]}.'''
|
|
8
8
|
aid = '''Please provide a valid development command'''
|
|
9
|
-
link = ''
|
|
9
|
+
link = 'https://docs.catalyst.zoho.com/en/cli/v1/serve-resources/serve-all-resources/#serve-a-slate-app'
|
|
10
10
|
|
|
11
11
|
[SERVE-SLATE-3]
|
|
12
12
|
context = '''Error when installing the dependencies.'''
|
|
13
|
-
aid = '''Please install the necessary packages before running the command ${arg[
|
|
14
|
-
link = ''
|
|
13
|
+
aid = '''Please install the necessary packages before running the command ${arg[0]}'''
|
|
14
|
+
link = 'https://docs.catalyst.zoho.com/en/cli/v1/serve-resources/serve-all-resources/#serve-a-slate-app'
|
|
15
|
+
|
package/docs/slate-utils.toml
CHANGED
|
@@ -2,3 +2,8 @@
|
|
|
2
2
|
context = '''The slate source directory ${arg[0]} does not exist.'''
|
|
3
3
|
aid = '''Please specify a valid source directory for the slate.'''
|
|
4
4
|
link = 'https://www.zoho.com/catalyst/help/slate-client.html'
|
|
5
|
+
|
|
6
|
+
[SLATE-UTILS-2]
|
|
7
|
+
context = '''The Slate port configuration is not set properly in ${arg[0]}'''
|
|
8
|
+
aid = '''Please update the port configuration in your development command to use ${arg[1]}'''
|
|
9
|
+
link = 'https://docs.catalyst.zoho.com/en/cli/v1/serve-resources/serve-all-resources/#serve-a-slate-app'
|
|
@@ -42,6 +42,7 @@ const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
|
42
42
|
const constants_1 = require("../../util_modules/constants");
|
|
43
43
|
const logger_1 = require("../../util_modules/logger");
|
|
44
44
|
const appsail_1 = __importDefault(require("./appsail"));
|
|
45
|
+
const slate_2 = __importDefault(require("./slate"));
|
|
45
46
|
exports.default = new command_1.default('deploy')
|
|
46
47
|
.description('Deploy the Catalyst project and project resources to the Catalyst development environment from the local directory')
|
|
47
48
|
.option('--only <targets>', 'only deploy specified, comma-separated targets (e.g. "functions,client,appsail").' +
|
|
@@ -52,7 +53,7 @@ exports.default = new command_1.default('deploy')
|
|
|
52
53
|
.needs('auth', [constants_1.SCOPE.functions, constants_1.SCOPE.webapp, constants_1.SCOPE.appsail_update])
|
|
53
54
|
.needs('config')
|
|
54
55
|
.needs('rc', { optional: true })
|
|
55
|
-
.addSubCommand(appsail_1.default)
|
|
56
|
+
.addSubCommand(appsail_1.default, slate_2.default)
|
|
56
57
|
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
58
|
const optionFilter = yield Promise.resolve().then(() => __importStar(require('../../option-filter')));
|
|
58
59
|
optionFilter.filterTargets();
|
package/lib/commands/index.js
CHANGED
|
@@ -78,6 +78,9 @@ exports.default = (client) => {
|
|
|
78
78
|
loadCommand('functions:config'),
|
|
79
79
|
loadCommand('functions:delete'),
|
|
80
80
|
loadCommand('appsail:add'),
|
|
81
|
+
loadCommand('slate:link'),
|
|
82
|
+
loadCommand('slate:create'),
|
|
83
|
+
loadCommand('slate:unlink'),
|
|
81
84
|
loadCommand('codelib:install'),
|
|
82
85
|
loadCommand('event:generate'),
|
|
83
86
|
loadCommand('event:generate:integ'),
|
package/lib/commands/init.js
CHANGED
|
@@ -115,6 +115,10 @@ exports.default = new command_1.default('init [feature]')
|
|
|
115
115
|
prompt_1.default.choice('AppSail: Configure and deploy AppSail services', {
|
|
116
116
|
value: 'appsail',
|
|
117
117
|
short: 'AppSail'
|
|
118
|
+
}),
|
|
119
|
+
prompt_1.default.choice('Slate: Configure and deploy slate apps', {
|
|
120
|
+
value: 'slate',
|
|
121
|
+
short: 'Slate'
|
|
118
122
|
})
|
|
119
123
|
],
|
|
120
124
|
when: !runtime_store_1.default.get('payload.project.import', false) &&
|
|
@@ -41,8 +41,8 @@ const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
|
41
41
|
const constants_1 = require("../../util_modules/constants");
|
|
42
42
|
const logger_1 = require("../../util_modules/logger");
|
|
43
43
|
exports.default = new command_1.default('slate:create')
|
|
44
|
-
.description('
|
|
45
|
-
.option('--name <app_name>', 'Please provide name for your slate')
|
|
44
|
+
.description('Generates a new Slate app with starter examples')
|
|
45
|
+
.option('--name <app_name>', 'Please provide name for your slate app')
|
|
46
46
|
.option('--framework <framework_name>', 'Specify framework name for your slate')
|
|
47
47
|
.option('--template <template_url>', 'Provide template url for your slate')
|
|
48
48
|
.option('--default', 'Set default app configurations')
|
|
@@ -41,11 +41,11 @@ const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
|
41
41
|
const constants_1 = require("../../util_modules/constants");
|
|
42
42
|
const logger_1 = require("../../util_modules/logger");
|
|
43
43
|
exports.default = new command_1.default('slate:link')
|
|
44
|
-
.description('
|
|
45
|
-
.option('--name <app_name>', '
|
|
46
|
-
.option('--framework <framework_name>', 'Specify
|
|
47
|
-
.option('--template <template_url>', 'Provide template
|
|
48
|
-
.option('--default', '
|
|
44
|
+
.description('Links an existing local application to the Catalyst Slate service for web hosting')
|
|
45
|
+
.option('--name <app_name>', 'Specify the name for your Slate application')
|
|
46
|
+
.option('--framework <framework_name>', 'Specify the frontend framework used (e.g., React, Angular, Vue)')
|
|
47
|
+
.option('--template <template_url>', 'Provide a template URL to initialize your Slate application')
|
|
48
|
+
.option('--default', 'Use default application configurations without prompting')
|
|
49
49
|
.needs('auth')
|
|
50
50
|
.needs('config', { optional: true })
|
|
51
51
|
.needs('rc', { optional: true, generateRc: true })
|
|
@@ -24,7 +24,7 @@ const fs_1 = require("../../util_modules/fs");
|
|
|
24
24
|
const error_1 = __importDefault(require("../../error"));
|
|
25
25
|
const path_1 = require("path");
|
|
26
26
|
exports.default = new command_1.default('slate:unlink')
|
|
27
|
-
.description('
|
|
27
|
+
.description('Removes the linked Slate configuration from the local app')
|
|
28
28
|
.option('--name <app_name>', 'Please provide name for your slate app')
|
|
29
29
|
.needs('auth')
|
|
30
30
|
.needs('config')
|
|
@@ -22,6 +22,8 @@ const throbber_1 = __importDefault(require("../../throbber"));
|
|
|
22
22
|
const logger_1 = require("../../util_modules/logger");
|
|
23
23
|
const ansi_colors_1 = require("ansi-colors");
|
|
24
24
|
const option_1 = require("../../util_modules/option");
|
|
25
|
+
const urls_1 = __importDefault(require("../../util_modules/constants/lib/urls"));
|
|
26
|
+
const project_1 = require("../../util_modules/project");
|
|
25
27
|
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
28
|
const dId = process.env.ZC_APP_DEPLOYMENT_BUILD_ID;
|
|
27
29
|
const env = getEnvironmentType();
|
|
@@ -57,13 +59,16 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
57
59
|
throbber.add(throbberName, {
|
|
58
60
|
text: `Preparing Slate[${targ.name}]`
|
|
59
61
|
});
|
|
60
|
-
const isAppExists = slateAppConfigs.find((app) => app.name === targ.name);
|
|
62
|
+
const isAppExists = slateAppConfigs.find((app) => app.name === targ.name && app.app_type === 'cli');
|
|
61
63
|
const configDetails = !isAppExists
|
|
62
64
|
? (_a = (yield config_1.slateConfig.getTargetDetails(targ))) === null || _a === void 0 ? void 0 : _a.config
|
|
63
65
|
: undefined;
|
|
66
|
+
const deploymentName = configDetails === null || configDetails === void 0 ? void 0 : configDetails.deployment_name;
|
|
67
|
+
deploymentName ? configDetails === null || configDetails === void 0 ? true : delete configDetails.deployment_name : null;
|
|
64
68
|
const readStream = yield slate_utils_1.slateUtils.pack(targ.source);
|
|
65
69
|
throbber.remove(throbberName);
|
|
66
|
-
yield (yield (0, endpoints_1.slateAPI)({ env })).deploy(readStream.stream, readStream.length, targ.name, '', isAppExists === null || isAppExists === void 0 ? void 0 : isAppExists.id, configDetails ? JSON.stringify(configDetails) : '', (0, option_1.getOptionValue)('m') || '');
|
|
70
|
+
const response = yield (yield (0, endpoints_1.slateAPI)({ env })).deploy(readStream.stream, readStream.length, targ.name, '', deploymentName ? deploymentName : '', isAppExists === null || isAppExists === void 0 ? void 0 : isAppExists.id, configDetails ? JSON.stringify(configDetails) : '', (0, option_1.getOptionValue)('m') || '');
|
|
71
|
+
targ.details = response;
|
|
67
72
|
}
|
|
68
73
|
catch (err) {
|
|
69
74
|
(0, logger_1.debug)(err);
|
|
@@ -115,7 +120,9 @@ exports.getEnvironmentType = getEnvironmentType;
|
|
|
115
120
|
function slateLogger() {
|
|
116
121
|
const deployTargets = runtime_store_1.default.get('payload.slate.targets', []);
|
|
117
122
|
deployTargets.forEach((slate) => {
|
|
118
|
-
|
|
123
|
+
var _a, _b;
|
|
124
|
+
(0, logger_1.labeled)(`Slate(${slate.name})`, 'Deploy is live!').SUCCESS();
|
|
125
|
+
(0, logger_1.labeled)((0, ansi_colors_1.cyan)(`Build Url(${slate.name})`), `${urls_1.default.admin}/baas/${(0, project_1.getEnvId)()}/project/${(0, project_1.getProjectId)()}/${getEnvironmentType()}#/slate/app/${(_a = slate.details) === null || _a === void 0 ? void 0 : _a.id}/deployment/${(_b = slate.details) === null || _b === void 0 ? void 0 : _b.deployment_type_config.upcoming_build.deployment_id}/overview`).MESSAGE();
|
|
119
126
|
(0, logger_1.info)();
|
|
120
127
|
});
|
|
121
128
|
return deployTargets;
|
|
@@ -15,8 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const error_1 = __importDefault(require("../../error"));
|
|
16
16
|
const api_1 = __importDefault(require("../../internal/api"));
|
|
17
17
|
const logger_1 = require("../../util_modules/logger");
|
|
18
|
-
const ansi_colors_1 = require("ansi-colors");
|
|
19
|
-
const config_store_1 = __importDefault(require("../../config-store"));
|
|
20
18
|
class Slate {
|
|
21
19
|
constructor(projectId, opts) {
|
|
22
20
|
this.opts = opts;
|
|
@@ -24,27 +22,13 @@ class Slate {
|
|
|
24
22
|
}
|
|
25
23
|
getFrameworks() {
|
|
26
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
awaitingSpinner: 'Fetching frameworks from the server ...'
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
if (response.body && response.body.data) {
|
|
34
|
-
return response.body.data;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
if (err.status === 404) {
|
|
39
|
-
throw new error_1.default('API Error: Slate not accessible', {
|
|
40
|
-
exit: 1,
|
|
41
|
-
errorId: 'SLDC-1',
|
|
42
|
-
arg: [(0, ansi_colors_1.bold)(config_store_1.default.get('active_dc') + ''), (0, ansi_colors_1.bold)('support@zohocatalyst.com')]
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
throw err;
|
|
25
|
+
const response = yield new api_1.default(this.opts).get('/slate/v1/frameworks', {
|
|
26
|
+
log: {
|
|
27
|
+
awaitingSpinner: 'Fetching frameworks from the server ...'
|
|
47
28
|
}
|
|
29
|
+
});
|
|
30
|
+
if (response.body && response.body.data) {
|
|
31
|
+
return response.body.data;
|
|
48
32
|
}
|
|
49
33
|
throw new error_1.default('Error while fetching the frameworks', { exit: 2 });
|
|
50
34
|
});
|
|
@@ -78,9 +62,9 @@ class Slate {
|
|
|
78
62
|
throw new error_1.default('Error while downloading the template', { exit: 2 });
|
|
79
63
|
});
|
|
80
64
|
}
|
|
81
|
-
deploy(sourceStream, contentLength, appName, deployId, appId, config, msg) {
|
|
65
|
+
deploy(sourceStream, contentLength, appName, deployId, deploymentName, appId, config, msg) {
|
|
82
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
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 }));
|
|
67
|
+
const formData = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ file: sourceStream }, (appId && { app_id: appId })), (deployId && { build_id: deployId })), (deploymentName && { deployment_name: deploymentName })), (appId || deployId ? {} : { name: appName })), (config && { configuration: config })), (msg && { message: msg }));
|
|
84
68
|
const res = yield new api_1.default(this.opts).post(`/slate/v1/project/${this.projectId}/app/upload`, {
|
|
85
69
|
formData,
|
|
86
70
|
json: false,
|
|
@@ -70,15 +70,15 @@ function getFrameworkOption(frameworks, source) {
|
|
|
70
70
|
return { name: frameworkOpt, source };
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
-
function validateAppName(appName) {
|
|
73
|
+
function validateAppName(appName, key) {
|
|
74
74
|
if (appName.length === 0) {
|
|
75
|
-
return
|
|
75
|
+
return `${key} name cannot be empty`;
|
|
76
76
|
}
|
|
77
77
|
if (appName.length > 45) {
|
|
78
|
-
return
|
|
78
|
+
return `${key} name cannot be more than 45 characters`;
|
|
79
79
|
}
|
|
80
80
|
if (!appName.match(/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/)) {
|
|
81
|
-
return
|
|
81
|
+
return `${key} name must be alphanumeric and cannot contain consecutive hyphens or hyphens at the beginning or end.`;
|
|
82
82
|
}
|
|
83
83
|
return true;
|
|
84
84
|
}
|
|
@@ -92,7 +92,7 @@ function getAppName(existingSlates, frameworkOpt) {
|
|
|
92
92
|
validate: (name) => {
|
|
93
93
|
if (existingSlates.findIndex((targ) => targ.name === name) !== -1)
|
|
94
94
|
return 'Slate already configured with this name.';
|
|
95
|
-
return validateAppName(name);
|
|
95
|
+
return validateAppName(name, 'App');
|
|
96
96
|
}
|
|
97
97
|
}));
|
|
98
98
|
appName = name;
|
|
@@ -102,7 +102,7 @@ function getAppName(existingSlates, frameworkOpt) {
|
|
|
102
102
|
throw new error_1.default('Slate already configured with this name.');
|
|
103
103
|
}
|
|
104
104
|
else {
|
|
105
|
-
const isValidApp = validateAppName(appName);
|
|
105
|
+
const isValidApp = validateAppName(appName, 'App');
|
|
106
106
|
if (isValidApp !== true) {
|
|
107
107
|
throw new error_1.default(isValidApp + '');
|
|
108
108
|
}
|
|
@@ -183,35 +183,95 @@ function detectFramework(source, frameworkList) {
|
|
|
183
183
|
(0, logger_1.warning)('The package.json file does not contain dependencies');
|
|
184
184
|
return getFrameworkOption(frameworkList, source);
|
|
185
185
|
}
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
186
|
+
const dependencyNames = Object.keys(dependencies);
|
|
187
|
+
const matchesKeywordPattern = (dep, keyword) => {
|
|
188
|
+
if (!keyword)
|
|
189
|
+
return false;
|
|
190
|
+
const normalizedKeyword = keyword.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
191
|
+
const normalizedDep = dep.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
192
|
+
if (normalizedDep === normalizedKeyword) {
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
if (normalizedDep.startsWith(`${normalizedKeyword}-`) ||
|
|
196
|
+
normalizedDep.endsWith(`-${normalizedKeyword}`) ||
|
|
197
|
+
normalizedDep.startsWith(`@${normalizedKeyword}/`) ||
|
|
198
|
+
normalizedDep.endsWith(`/${normalizedKeyword}`) ||
|
|
199
|
+
normalizedDep === `@${normalizedKeyword}`) {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
const segments = dep.split(/[-/@]/).map((s) => s.toLowerCase());
|
|
203
|
+
if (segments.includes(normalizedKeyword)) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
return false;
|
|
207
|
+
};
|
|
208
|
+
let bestMatch = null;
|
|
209
|
+
let maxMatches = 0;
|
|
210
|
+
const frameworkScores = [];
|
|
211
|
+
for (const framework of frameworkList) {
|
|
212
|
+
if (!framework.keywords || framework.keywords.length === 0 || framework.name === 'other') {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const matchingKeywords = framework.keywords.filter((keyword) => {
|
|
216
|
+
if (!keyword || keyword.trim() === '')
|
|
217
|
+
return false;
|
|
218
|
+
return dependencyNames.some((dep) => matchesKeywordPattern(dep, keyword));
|
|
219
|
+
});
|
|
220
|
+
const matchCount = matchingKeywords.length;
|
|
221
|
+
let score = matchCount;
|
|
222
|
+
const priorityKeywords = ['next', 'nuxt', 'gatsby', 'angular', 'vue', 'solid-js'];
|
|
223
|
+
const hasPriorityKeyword = matchingKeywords.some((keyword) => priorityKeywords.includes(keyword.toLowerCase()));
|
|
224
|
+
if (hasPriorityKeyword) {
|
|
225
|
+
score += 10;
|
|
226
|
+
}
|
|
227
|
+
if (matchCount > 1) {
|
|
228
|
+
score += matchCount * 2;
|
|
229
|
+
}
|
|
230
|
+
if (matchCount > 0) {
|
|
231
|
+
frameworkScores.push({ framework, score, matches: matchingKeywords });
|
|
232
|
+
}
|
|
233
|
+
if (score > maxMatches) {
|
|
234
|
+
maxMatches = score;
|
|
235
|
+
bestMatch = framework;
|
|
236
|
+
}
|
|
190
237
|
}
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
238
|
+
const perfectMatches = frameworkScores.filter(({ framework }) => framework.keywords.length > 0 &&
|
|
239
|
+
framework.keywords.every((keyword) => dependencyNames.some((dep) => matchesKeywordPattern(dep, keyword))));
|
|
240
|
+
if (perfectMatches.length > 0) {
|
|
241
|
+
const filteredPerfectMatches = perfectMatches.filter((a) => !perfectMatches.some((b) => b !== a &&
|
|
242
|
+
b.framework.keywords.length > a.framework.keywords.length &&
|
|
243
|
+
a.framework.keywords.every((k) => b.framework.keywords.includes(k))));
|
|
244
|
+
filteredPerfectMatches.sort((a, b) => b.framework.keywords.length - a.framework.keywords.length);
|
|
245
|
+
const best = filteredPerfectMatches[0];
|
|
246
|
+
return { name: best.framework.name, source };
|
|
194
247
|
}
|
|
195
|
-
|
|
196
|
-
const framework = frameworkList.find(({ keywords }) => keywords.every((keyword) => dependencies[keyword] !== undefined));
|
|
197
|
-
if (!framework) {
|
|
248
|
+
if (!bestMatch) {
|
|
198
249
|
(0, logger_1.warning)('No matching framework found in package.json dependencies');
|
|
199
|
-
return getFrameworkOption(frameworkList);
|
|
250
|
+
return getFrameworkOption(frameworkList, source);
|
|
200
251
|
}
|
|
201
|
-
return { name:
|
|
252
|
+
return { name: bestMatch.name, source };
|
|
202
253
|
});
|
|
203
254
|
}
|
|
204
255
|
function getConfigDetails(frameworkOpt, frameworks) {
|
|
205
256
|
return __awaiter(this, void 0, void 0, function* () {
|
|
206
257
|
const slateConfigs = frameworks.find((framework) => frameworkOpt.toLowerCase() === framework.name);
|
|
207
258
|
if (frameworkOpt === 'static') {
|
|
208
|
-
|
|
259
|
+
let deploymentName = 'default';
|
|
260
|
+
({ deploymentName } = yield prompt_1.default.ask(prompt_1.default.question('deploymentName', 'Provide your Deployment Name:', {
|
|
261
|
+
type: 'input',
|
|
262
|
+
default: 'default',
|
|
263
|
+
validate: (name) => {
|
|
264
|
+
return validateAppName(name, 'Deployment');
|
|
265
|
+
}
|
|
266
|
+
})));
|
|
267
|
+
return { framework: 'static', deployment_name: deploymentName };
|
|
209
268
|
}
|
|
210
269
|
const slateConfigDetails = {
|
|
211
270
|
framework: frameworkOpt,
|
|
212
271
|
install_command: slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.install_command.value,
|
|
213
272
|
build_path: slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.output_dir.value,
|
|
214
273
|
build_command: slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.build_command.value,
|
|
274
|
+
deployment_name: 'default',
|
|
215
275
|
root_path: './'
|
|
216
276
|
};
|
|
217
277
|
let editDefaultConfig;
|
|
@@ -221,7 +281,8 @@ function getConfigDetails(frameworkOpt, frameworks) {
|
|
|
221
281
|
`${(0, ansi_colors_1.grey)((0, ansi_colors_1.bold)('Install Command: ') +
|
|
222
282
|
(slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.install_command.placeholder))}\n` +
|
|
223
283
|
`${(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))}`
|
|
284
|
+
`${(0, ansi_colors_1.grey)((0, ansi_colors_1.bold)('Build Path: ') + (slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.output_dir.placeholder))}\n` +
|
|
285
|
+
`${(0, ansi_colors_1.grey)((0, ansi_colors_1.bold)('Deployment Name: ') + slateConfigDetails.deployment_name)}`);
|
|
225
286
|
editDefaultConfig = yield prompt_1.default.ask(prompt_1.default.question('config', 'Do you want to modify these default configurations?', {
|
|
226
287
|
type: 'confirm',
|
|
227
288
|
default: false
|
|
@@ -234,6 +295,7 @@ function getConfigDetails(frameworkOpt, frameworks) {
|
|
|
234
295
|
if (!(slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings) || (editDefaultConfig === null || editDefaultConfig === void 0 ? void 0 : editDefaultConfig.config)) {
|
|
235
296
|
const config = yield prompt_1.default.ask(prompt_1.default.question('installCommand', 'Provide your Install Command:', {
|
|
236
297
|
type: 'input',
|
|
298
|
+
default: slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.install_command.value,
|
|
237
299
|
validate: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
238
300
|
value = value.trim();
|
|
239
301
|
if (value === '')
|
|
@@ -244,6 +306,7 @@ function getConfigDetails(frameworkOpt, frameworks) {
|
|
|
244
306
|
})
|
|
245
307
|
}), prompt_1.default.question('buildCommand', 'Provide your Build Command:', {
|
|
246
308
|
type: 'input',
|
|
309
|
+
default: slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.build_command.value,
|
|
247
310
|
validate: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
248
311
|
value = value.trim();
|
|
249
312
|
if (value === '')
|
|
@@ -254,6 +317,7 @@ function getConfigDetails(frameworkOpt, frameworks) {
|
|
|
254
317
|
})
|
|
255
318
|
}), prompt_1.default.question('buildPath', 'Provide your Build Path:', {
|
|
256
319
|
type: 'input',
|
|
320
|
+
default: slateConfigs === null || slateConfigs === void 0 ? void 0 : slateConfigs.settings.output_dir.value,
|
|
257
321
|
validate: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
258
322
|
value = value.trim();
|
|
259
323
|
if (value === '')
|
|
@@ -264,10 +328,17 @@ function getConfigDetails(frameworkOpt, frameworks) {
|
|
|
264
328
|
return 'Cannot exceed 50 characters.';
|
|
265
329
|
return true;
|
|
266
330
|
})
|
|
331
|
+
}), prompt_1.default.question('deploymentName', 'Provide your Deployment Name:', {
|
|
332
|
+
type: 'input',
|
|
333
|
+
default: 'default',
|
|
334
|
+
validate: (name) => {
|
|
335
|
+
return validateAppName(name, 'Deployment');
|
|
336
|
+
}
|
|
267
337
|
}));
|
|
268
338
|
(slateConfigDetails.install_command = config.installCommand),
|
|
269
339
|
(slateConfigDetails.build_path = config.buildPath),
|
|
270
|
-
(slateConfigDetails.build_command = config.buildCommand)
|
|
340
|
+
(slateConfigDetails.build_command = config.buildCommand),
|
|
341
|
+
(slateConfigDetails.deployment_name = config.deploymentName);
|
|
271
342
|
}
|
|
272
343
|
return slateConfigDetails || {};
|
|
273
344
|
});
|
|
@@ -286,18 +357,20 @@ exports.default = (add) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
286
357
|
};
|
|
287
358
|
const slateConfigDetails = yield getConfigDetails(frameworkOpt.name, frameworks);
|
|
288
359
|
if (frameworkOpt.name !== 'static') {
|
|
289
|
-
const slateRunConfig =
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
360
|
+
const slateRunConfig = (0, option_1.getOptionValue)('default')
|
|
361
|
+
? { devCommand: 'npm start' }
|
|
362
|
+
: yield prompt_1.default.ask(prompt_1.default.question('devCommand', 'Please provide your Development Command:', {
|
|
363
|
+
type: 'input',
|
|
364
|
+
default: 'npm start',
|
|
365
|
+
validate: (value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
366
|
+
value = value.trim();
|
|
367
|
+
if (value === '')
|
|
368
|
+
return 'Please provide a valid development command';
|
|
369
|
+
else if (value.length > 50)
|
|
370
|
+
return 'Cannot exceed 50 characters.';
|
|
371
|
+
return true;
|
|
372
|
+
})
|
|
373
|
+
}));
|
|
301
374
|
yield fs_1.ASYNC.writeJSONFile((0, path_1.join)(payload.source, constants_1.FILENAME.cli_config), {
|
|
302
375
|
slate: {
|
|
303
376
|
dev_command: slateRunConfig.devCommand
|
|
@@ -308,6 +381,6 @@ exports.default = (add) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
308
381
|
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
382
|
\n# ⚠️ Please do not modify this file, as it is fully managed by the CLI.\n';
|
|
310
383
|
yield (0, async_1.ensureFile)(pth, true);
|
|
311
|
-
fs_1.ASYNC.writeFile(pth, warnContent + '\n' + (0, toml_1.convertTOML)(slateConfigDetails));
|
|
384
|
+
yield fs_1.ASYNC.writeFile(pth, warnContent + '\n' + (0, toml_1.convertTOML)(slateConfigDetails));
|
|
312
385
|
runtime_store_1.default.set('payload.slate.targets', [payload]);
|
|
313
386
|
});
|
package/lib/option-filter.js
CHANGED
|
@@ -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' ||
|
|
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
|
}
|
package/lib/serve/index.js
CHANGED
|
@@ -124,6 +124,25 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
124
124
|
runtime_store_1.default.set('context.targets', serveTargets);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
+
if (serveTargets.includes('slate')) {
|
|
128
|
+
const slates = runtime_store_1.default.get('context.slate.targets', []);
|
|
129
|
+
const validSlates = slates.filter((slate) => {
|
|
130
|
+
if (!slate.validity.valid) {
|
|
131
|
+
(0, logger_1.warning)('skipping serve of Slate service [' +
|
|
132
|
+
slate.name +
|
|
133
|
+
'] since ' +
|
|
134
|
+
slate.validity.reason);
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
advancedServer.add('slate', slate);
|
|
138
|
+
return true;
|
|
139
|
+
});
|
|
140
|
+
if (validSlates.length === 0) {
|
|
141
|
+
(0, logger_1.labeled)('Slate', 'No targets are ready to be served in local').WARN();
|
|
142
|
+
serveTargets.splice(serveTargets.indexOf('slate'), 1);
|
|
143
|
+
runtime_store_1.default.set('context.targets', serveTargets);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
127
146
|
if (serveTargets.includes('client')) {
|
|
128
147
|
const client = runtime_store_1.default.get('context.client', false);
|
|
129
148
|
if (client && client.valid) {
|
|
@@ -97,7 +97,7 @@ function spinUpMaster(listenPort, { otherServerDetails, appSailDetails, slateDet
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
const proxy = (0, utils_1.createProxyServer)(listenPort);
|
|
100
|
-
const signRedirectUrl = slateDetails ?
|
|
100
|
+
const signRedirectUrl = slateDetails ? '/' : '/app/local-redirect';
|
|
101
101
|
appSailDetails && ((_b = (_a = appSailDetails.target) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.catalyst_auth) === true
|
|
102
102
|
? proxy.on('proxyRes', (0, utils_1.proxyResponseHandler)({
|
|
103
103
|
signInRedirect: appSailDetails.target.config.login_redirect || '/'
|
|
@@ -11,25 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.addSlateRoutes = void 0;
|
|
13
13
|
function addSlateRoutes(app, details, proxy, unknownProxy) {
|
|
14
|
-
app.use('/
|
|
14
|
+
app.use(['/accounts', '/oauthorize', '/__catalyst'], (req, res) => {
|
|
15
15
|
req.url = req.originalUrl;
|
|
16
16
|
unknownProxy(req, res);
|
|
17
|
-
}));
|
|
18
|
-
app.use(['/accounts', '/oauthorize'], (req, res) => {
|
|
19
|
-
req.url = req.originalUrl;
|
|
20
|
-
unknownProxy(req, res);
|
|
21
|
-
});
|
|
22
|
-
app.use('/__catalyst', (req, res) => {
|
|
23
|
-
req.url = req.originalUrl;
|
|
24
|
-
if (req.url.includes('redirect_url')) {
|
|
25
|
-
res.redirect(req.url.split('redirect_url=')[1]);
|
|
26
|
-
}
|
|
27
|
-
else if (req.url.includes('service_url')) {
|
|
28
|
-
res.redirect(req.url.split('service_url=')[1]);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
unknownProxy(req, res);
|
|
32
|
-
}
|
|
33
17
|
});
|
|
34
18
|
app.use('/', (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
35
19
|
if (req.header('catalyst-component') === 'true') {
|
|
@@ -89,9 +89,11 @@ const proxyResponseHandler = ({ systemRoutes, signInRedirect }) => (proxyRes, re
|
|
|
89
89
|
return cookie;
|
|
90
90
|
});
|
|
91
91
|
if (req.url.startsWith('/baas') || req.url.startsWith('/__catalyst')) {
|
|
92
|
-
|
|
92
|
+
const urlParams = new URLSearchParams(req.url.split('?')[1] || '');
|
|
93
|
+
const redirectUrl = urlParams.get('redirect_url') || urlParams.get('service_url') || signInRedirect;
|
|
94
|
+
if (req.url.includes('/signin-redirect') && redirectUrl) {
|
|
93
95
|
if (systemRoutes === undefined) {
|
|
94
|
-
(0, exports.redirectByAuth)(req, res,
|
|
96
|
+
(0, exports.redirectByAuth)(req, res, redirectUrl);
|
|
95
97
|
return;
|
|
96
98
|
}
|
|
97
99
|
const sourceRedirectUrl = Object.keys(systemRoutes).find((sourceUrl) => {
|
|
@@ -14,11 +14,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const path_1 = require("path");
|
|
16
16
|
const error_1 = __importDefault(require("../../../../error"));
|
|
17
|
-
const fs_1 = require("../../../../util_modules/fs");
|
|
18
17
|
const logger_1 = require("../../../../util_modules/logger");
|
|
19
18
|
const shell_1 = require("../../../../util_modules/shell");
|
|
20
19
|
const master_1 = __importDefault(require("../master"));
|
|
21
|
-
const ansi_colors_1 = require("ansi-colors");
|
|
22
20
|
const file_names_1 = __importDefault(require("../../../../util_modules/constants/lib/file-names"));
|
|
23
21
|
const static_server_1 = __importDefault(require("./static-server"));
|
|
24
22
|
const open_1 = __importDefault(require("open"));
|
|
@@ -53,28 +51,34 @@ exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function*
|
|
|
53
51
|
}
|
|
54
52
|
else {
|
|
55
53
|
const configFile = (0, path_1.join)(targetSlate.source, file_names_1.default.cli_config);
|
|
56
|
-
if (!fs_1.ASYNC.fileExists(configFile)) {
|
|
57
|
-
throw new error_1.default('Unable to find the development command.', {
|
|
58
|
-
exit: 1,
|
|
59
|
-
errorId: 'SERVE-SLATE-1',
|
|
60
|
-
arg: ['catalyst slate:create']
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
if (!(yield fs_1.ASYNC.isPathExists(targetSlate.source))) {
|
|
64
|
-
throw new error_1.default('The given Slate source path does not exist', {
|
|
65
|
-
exit: 1,
|
|
66
|
-
errorId: 'SERVE-SLATE-2',
|
|
67
|
-
arg: [ansi_colors_1.italic.underline.red(targetSlate.source), (0, ansi_colors_1.bold)(targetSlate.name)]
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
54
|
const configJson = yield (0, async_1.readJSONFile)(configFile);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
55
|
+
const installDeps = (0, shell_1.spawn)('npm', ['install'], {
|
|
56
|
+
cwd: targetSlate.source
|
|
57
|
+
}).RAW();
|
|
58
|
+
yield new Promise((resolve, reject) => {
|
|
59
|
+
installDeps.on('exit', (code) => {
|
|
60
|
+
var _a;
|
|
61
|
+
if (code === 0) {
|
|
62
|
+
resolve();
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
reject(new error_1.default('Failed to install dependencies', {
|
|
66
|
+
exit: 1,
|
|
67
|
+
errorId: 'SERVE-SLATE-3',
|
|
68
|
+
arg: [((_a = targetSlate.config) === null || _a === void 0 ? void 0 : _a.install_command) + ''],
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
76
71
|
});
|
|
77
|
-
|
|
72
|
+
installDeps.on('error', (err) => {
|
|
73
|
+
var _a;
|
|
74
|
+
reject(new error_1.default('Failed to install dependencies', {
|
|
75
|
+
exit: 1,
|
|
76
|
+
errorId: 'SERVE-SLATE-3',
|
|
77
|
+
arg: [((_a = targetSlate.config) === null || _a === void 0 ? void 0 : _a.install_command) + '', 'catalyst serve'],
|
|
78
|
+
original: err
|
|
79
|
+
}));
|
|
80
|
+
});
|
|
81
|
+
});
|
|
78
82
|
child = yield startSlate(targetSlate.port.slate, {
|
|
79
83
|
target: targetSlate.source,
|
|
80
84
|
command: (_a = configJson === null || configJson === void 0 ? void 0 : configJson.slate) === null || _a === void 0 ? void 0 : _a.dev_command
|
|
@@ -84,23 +88,16 @@ exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function*
|
|
|
84
88
|
slateDetails: serverDetails
|
|
85
89
|
});
|
|
86
90
|
child.once('exit', (code) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
});
|
|
91
|
+
masterServe.close((err) => {
|
|
92
|
+
if (err) {
|
|
93
|
+
(0, logger_1.debug)('Error stopping the Slate proxy server: ', err);
|
|
94
|
+
}
|
|
93
95
|
});
|
|
94
96
|
if (code === 150) {
|
|
95
97
|
targetSlate.validity = {
|
|
96
98
|
valid: false,
|
|
97
99
|
reason: 'Unable to start the Slate'
|
|
98
100
|
};
|
|
99
|
-
throw new error_1.default('Slate start failed', {
|
|
100
|
-
exit: 1,
|
|
101
|
-
errorId: 'SERVE-SLATE-5',
|
|
102
|
-
arg: [(0, ansi_colors_1.bold)(targetSlate.name)]
|
|
103
|
-
});
|
|
104
101
|
}
|
|
105
102
|
});
|
|
106
103
|
process.on('SIGINT', () => {
|
|
@@ -76,7 +76,7 @@ function slateServer(httpPort, source, { homepage = '/index.html', enableWatch =
|
|
|
76
76
|
let watcherReady = false;
|
|
77
77
|
clientWatcher.on('error', (err) => {
|
|
78
78
|
watcherReady = false;
|
|
79
|
-
eventListener.emit('error', new error_js_1.default('
|
|
79
|
+
eventListener.emit('error', new error_js_1.default('slate watcher error', {
|
|
80
80
|
original: err,
|
|
81
81
|
exit: 1,
|
|
82
82
|
skipHelp: true
|
package/lib/slate-utils.js
CHANGED
|
@@ -196,7 +196,7 @@ exports.slateUtils = {
|
|
|
196
196
|
};
|
|
197
197
|
function validateServeCommand(targDetails) {
|
|
198
198
|
targDetails.forEach((targ) => {
|
|
199
|
-
var _a, _b;
|
|
199
|
+
var _a, _b, _c;
|
|
200
200
|
if (((_a = targ.config) === null || _a === void 0 ? void 0 : _a.framework) !== 'static') {
|
|
201
201
|
const serveConfig = fs_1.SYNC.readJSONFile((0, path_1.join)(targ.source, constants_1.FILENAME.cli_config));
|
|
202
202
|
if (targ.validity.valid && !((_b = serveConfig === null || serveConfig === void 0 ? void 0 : serveConfig.slate) === null || _b === void 0 ? void 0 : _b.dev_command)) {
|
|
@@ -205,6 +205,12 @@ function validateServeCommand(targDetails) {
|
|
|
205
205
|
reason: 'Development command missing'
|
|
206
206
|
};
|
|
207
207
|
}
|
|
208
|
+
if (!((_c = serveConfig === null || serveConfig === void 0 ? void 0 : serveConfig.slate) === null || _c === void 0 ? void 0 : _c.dev_command).includes('ZC_SLATE_PORT')) {
|
|
209
|
+
targ.validity = {
|
|
210
|
+
valid: false,
|
|
211
|
+
reason: `Port configuration is missing. Please set the ${(0, ansi_colors_1.bold)('ZC_SLATE_PORT')} as the port value in ${(0, ansi_colors_1.bold)('cli-config.json')} under your development command.`
|
|
212
|
+
};
|
|
213
|
+
}
|
|
208
214
|
}
|
|
209
215
|
});
|
|
210
216
|
return targDetails;
|
|
@@ -55,11 +55,7 @@ function getAllTargetDetails(throwErr = true) {
|
|
|
55
55
|
const rawTargets = raw();
|
|
56
56
|
if (!rawTargets) {
|
|
57
57
|
if (throwErr) {
|
|
58
|
-
throw new error_1.default('No Slate targets found'
|
|
59
|
-
errorId: 'SLTARG-UTIL-1',
|
|
60
|
-
arg: [(0, ansi_colors_1.bold)('catalyst slate:create')],
|
|
61
|
-
exit: 1
|
|
62
|
-
});
|
|
58
|
+
throw new error_1.default('No Slate targets found');
|
|
63
59
|
}
|
|
64
60
|
return;
|
|
65
61
|
}
|
|
@@ -75,5 +75,7 @@ exports.default = Object.freeze({
|
|
|
75
75
|
bucket_read: 'ZohoCatalyst.buckets.READ',
|
|
76
76
|
object_create: 'ZohoCatalyst.buckets.objects.CREATE',
|
|
77
77
|
pipline_read: 'ZohoCatalyst.pipeline.READ',
|
|
78
|
-
pipeline_exec_create: 'ZohoCatalyst.pipeline.execution.CREATE'
|
|
78
|
+
pipeline_exec_create: 'ZohoCatalyst.pipeline.execution.CREATE',
|
|
79
|
+
slate_read: 'ZohoCatalyst.Slate.app.READ',
|
|
80
|
+
slate_create: 'ZohoCatalyst.Slate.app.CREATE'
|
|
79
81
|
});
|
|
@@ -7,86 +7,55 @@ const env_js_1 = require("../../env.js");
|
|
|
7
7
|
const dc_js_1 = require("../../../dc.js");
|
|
8
8
|
const dc_type_js_1 = __importDefault(require("./dc-type.js"));
|
|
9
9
|
class URL {
|
|
10
|
+
static get zohoCDN() {
|
|
11
|
+
return (0, env_js_1.envOverride)('ZOHO_CDN', mapDataCenterUrl(URL._zohoCDNBase));
|
|
12
|
+
}
|
|
10
13
|
static get auth() {
|
|
11
|
-
|
|
12
|
-
if (dc === undefined) {
|
|
13
|
-
return URL._auth;
|
|
14
|
-
}
|
|
15
|
-
if (dc.value === dc_type_js_1.default.ca.value) {
|
|
16
|
-
return URL._auth.replace('.zoho.com', '.zohocloud.ca');
|
|
17
|
-
}
|
|
18
|
-
return URL._auth.replace('.com', dc.ext);
|
|
14
|
+
return (0, env_js_1.envOverride)('CATALYST_AUTH_URL', mapDataCenterUrl(URL._authBase));
|
|
19
15
|
}
|
|
20
16
|
static get iamPortal() {
|
|
21
|
-
|
|
22
|
-
if (dc === undefined) {
|
|
23
|
-
return URL._portal;
|
|
24
|
-
}
|
|
25
|
-
return URL._portal.replace('.com', dc.ext);
|
|
17
|
+
return (0, env_js_1.envOverride)('CATALYST_PORTAL_DOMAIN', mapDataCenterUrl(URL._portalBase));
|
|
26
18
|
}
|
|
27
19
|
static get admin() {
|
|
28
|
-
|
|
29
|
-
if (dc === undefined) {
|
|
30
|
-
return URL._admin;
|
|
31
|
-
}
|
|
32
|
-
if (dc.value === dc_type_js_1.default.ca.value) {
|
|
33
|
-
return URL._admin.replace('.zoho.com', '.zohocloud.ca');
|
|
34
|
-
}
|
|
35
|
-
return URL._admin.replace('.com', dc.ext);
|
|
20
|
+
return (0, env_js_1.envOverride)('CATALYST_ADMIN_URL', mapDataCenterUrl(URL._adminBase));
|
|
36
21
|
}
|
|
37
22
|
static get app() {
|
|
38
|
-
|
|
39
|
-
if (dc === undefined) {
|
|
40
|
-
return URL._app;
|
|
41
|
-
}
|
|
42
|
-
return URL._app.replace('.com', dc.ext);
|
|
23
|
+
return (0, env_js_1.envOverride)('CATALYST_APP_URL', mapDataCenterUrl(URL._appBase));
|
|
43
24
|
}
|
|
44
25
|
static get appSailDomain() {
|
|
45
|
-
|
|
46
|
-
if (dc === undefined) {
|
|
47
|
-
return URL._appSailDomain;
|
|
48
|
-
}
|
|
49
|
-
return URL._appSailDomain.replace('.com', dc.ext);
|
|
26
|
+
return (0, env_js_1.envOverride)('CATALYST_APPSAIL_URL', mapDataCenterUrl(URL._appSailDomainBase));
|
|
50
27
|
}
|
|
51
28
|
static get catalystStatic() {
|
|
52
|
-
|
|
53
|
-
if (dc === undefined) {
|
|
54
|
-
return URL._zohoStatic;
|
|
55
|
-
}
|
|
56
|
-
if (dc.value === dc_type_js_1.default.ca.value) {
|
|
57
|
-
return URL._zohoStatic.replace('.zoho.com', '.zohocloud.ca');
|
|
58
|
-
}
|
|
59
|
-
return URL._zohoStatic.replace(dc_type_js_1.default.us.ext, dc.ext);
|
|
29
|
+
return (0, env_js_1.envOverride)('ZOHO_STATIC', mapDataCenterUrl(URL._zohoStaticBase));
|
|
60
30
|
}
|
|
61
31
|
static get console() {
|
|
62
|
-
|
|
63
|
-
if (dc === undefined) {
|
|
64
|
-
return URL._console;
|
|
65
|
-
}
|
|
66
|
-
if (dc.value === dc_type_js_1.default.ca.value) {
|
|
67
|
-
return URL._console.replace('.zoho.com', '.zohocloud.ca');
|
|
68
|
-
}
|
|
69
|
-
return URL._console.replace('.com', dc.ext);
|
|
32
|
+
return (0, env_js_1.envOverride)('CATALYST_CONSOLE_URL', mapDataCenterUrl(URL._consoleBase));
|
|
70
33
|
}
|
|
71
34
|
static get stratusSuffix() {
|
|
72
|
-
|
|
73
|
-
if (dc === undefined) {
|
|
74
|
-
return URL._stratusSuffix;
|
|
75
|
-
}
|
|
76
|
-
return URL._stratusSuffix.replace('.com', dc.ext);
|
|
35
|
+
return (0, env_js_1.envOverride)('CATALYST_STRATUS_RESOURCE_SUFFIX', mapDataCenterUrl(URL._stratusSuffixBase));
|
|
77
36
|
}
|
|
78
37
|
}
|
|
79
38
|
exports.default = URL;
|
|
80
|
-
URL.
|
|
81
|
-
URL.
|
|
82
|
-
URL.
|
|
83
|
-
URL.
|
|
84
|
-
URL.
|
|
85
|
-
URL.
|
|
86
|
-
URL.
|
|
87
|
-
URL.
|
|
88
|
-
URL.
|
|
39
|
+
URL._authBase = 'https://accounts.zoho.com';
|
|
40
|
+
URL._portalBase = 'https://accounts.zohoportal.com';
|
|
41
|
+
URL._adminBase = 'https://api.catalyst.zoho.com';
|
|
42
|
+
URL._appBase = 'https://catalystserverless.com';
|
|
43
|
+
URL._appSailDomainBase = 'https://catalystappsail.com';
|
|
44
|
+
URL._zohoStaticBase = 'https://www.zoho.com/catalyst';
|
|
45
|
+
URL._consoleBase = 'https://console.catalyst.zoho.com';
|
|
46
|
+
URL._stratusSuffixBase = '.zohostratus.com';
|
|
47
|
+
URL._zohoCDNBase = 'https://static.zohocdn.com';
|
|
89
48
|
URL.external = Object.freeze({
|
|
90
49
|
gitHubAPI: 'https://api.github.com',
|
|
91
50
|
gitHubWeb: 'https://github.com'
|
|
92
51
|
});
|
|
52
|
+
function mapDataCenterUrl(url) {
|
|
53
|
+
const dc = (0, dc_js_1.getActiveDCType)();
|
|
54
|
+
if (dc === undefined) {
|
|
55
|
+
return url;
|
|
56
|
+
}
|
|
57
|
+
if (dc.value === dc_type_js_1.default.ca.value && url.includes('.zoho.com')) {
|
|
58
|
+
return url.replace('.zoho.com', '.zohocloud.ca');
|
|
59
|
+
}
|
|
60
|
+
return url.replace(dc_type_js_1.default.us.ext, dc.ext);
|
|
61
|
+
}
|
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@ const notify = async () => {
|
|
|
24
24
|
text,
|
|
25
25
|
bot: {
|
|
26
26
|
name: 'Dx Tools Update',
|
|
27
|
-
image: 'https://www.
|
|
27
|
+
image: 'https://www.zoho.com/sites/zweb/images/producticon/catalyst.svg'
|
|
28
28
|
},
|
|
29
29
|
card: {
|
|
30
30
|
title: 'Announcement',
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"selections": [
|
|
63
63
|
{
|
|
64
64
|
"description": "Catalyst help documentation",
|
|
65
|
-
"imageurl": "https://www.
|
|
65
|
+
"imageurl": "https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png",
|
|
66
66
|
"title": "Help docs"
|
|
67
67
|
}
|
|
68
68
|
],
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"type": "link_preview",
|
|
6
6
|
"timestamp": 1569520690703,
|
|
7
7
|
"params" : {
|
|
8
|
-
"url": "https://www.
|
|
9
|
-
"domain": "
|
|
8
|
+
"url": "https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png",
|
|
9
|
+
"domain": "zoho.com",
|
|
10
10
|
"environment" : {
|
|
11
11
|
"tld": ".com",
|
|
12
12
|
"data_center": "US",
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"type": "link_preview",
|
|
6
6
|
"timestamp": 1569520690703,
|
|
7
7
|
"params" : {
|
|
8
|
-
"url": "https://www.
|
|
9
|
-
"domain": "
|
|
8
|
+
"url": "https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png",
|
|
9
|
+
"domain": "zoho.com",
|
|
10
10
|
"environment" : {
|
|
11
11
|
"tld": ".com",
|
|
12
12
|
"data_center": "US",
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"type": "link_preview",
|
|
6
6
|
"timestamp": 1569520690703,
|
|
7
7
|
"params" : {
|
|
8
|
-
"url": "https://www.
|
|
9
|
-
"domain": "
|
|
8
|
+
"url": "https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png",
|
|
9
|
+
"domain": "zoho.com",
|
|
10
10
|
"environment" : {
|
|
11
11
|
"tld": ".com",
|
|
12
12
|
"data_center": "US",
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"type": "link_preview",
|
|
6
6
|
"timestamp": 1569520690703,
|
|
7
7
|
"params" : {
|
|
8
|
-
"url": "https://www.
|
|
9
|
-
"domain": "
|
|
8
|
+
"url": "https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png",
|
|
9
|
+
"domain": "zoho.com",
|
|
10
10
|
"environment" : {
|
|
11
11
|
"tld": ".com",
|
|
12
12
|
"data_center": "US",
|
|
@@ -49,9 +49,9 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
|
|
|
49
49
|
public List<CommandSuggestion> suggestionHandler(CommandHandlerRequest req) {
|
|
50
50
|
List<CommandSuggestion> suggestionList = new ArrayList<CommandSuggestion>();
|
|
51
51
|
if (req.getName().equals("catalystresource")) {
|
|
52
|
-
CommandSuggestion sugg1 = CommandSuggestion.getInstance("API doc", "Catalyst API documentation", "https://www.
|
|
53
|
-
CommandSuggestion sugg2 = CommandSuggestion.getInstance("CLI doc", "Catalyst CLI documentation", "https://www.
|
|
54
|
-
CommandSuggestion sugg3 = CommandSuggestion.getInstance("Help doc", "Catalyst Help documentation", "https://www.
|
|
52
|
+
CommandSuggestion sugg1 = CommandSuggestion.getInstance("API doc", "Catalyst API documentation", "https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png");
|
|
53
|
+
CommandSuggestion sugg2 = CommandSuggestion.getInstance("CLI doc", "Catalyst CLI documentation", "https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png");
|
|
54
|
+
CommandSuggestion sugg3 = CommandSuggestion.getInstance("Help doc", "Catalyst Help documentation", "https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png");
|
|
55
55
|
suggestionList.add(sugg1);
|
|
56
56
|
suggestionList.add(sugg2);
|
|
57
57
|
suggestionList.add(sugg3);
|
|
@@ -96,7 +96,7 @@ public class WidgetHandler implements com.zc.cliq.interfaces.WidgetHandler {
|
|
|
96
96
|
WidgetInfo info = new WidgetInfo();
|
|
97
97
|
info.setTitle("Sorry! No tables found.");
|
|
98
98
|
info.setDescription("Catalyst Datastore can be used to create and manage tables to store persistent data of your applications!");
|
|
99
|
-
info.setImageUrl("https://www.
|
|
99
|
+
info.setImageUrl("https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png");
|
|
100
100
|
WidgetButton linkBtn = new WidgetButton();
|
|
101
101
|
linkBtn.setLabel("Visit Zoho Catalyst");
|
|
102
102
|
linkBtn.setType(ACTION_TYPE.OPEN_URL);
|
|
@@ -38,17 +38,17 @@ command.suggestionHandler(async (req, res) => {
|
|
|
38
38
|
const suggestion1 = command.newCommandSuggestion();
|
|
39
39
|
suggestion1.title = 'API doc';
|
|
40
40
|
suggestion1.description = 'Catalyst API documentation';
|
|
41
|
-
suggestion1.imageurl = 'https://www.
|
|
41
|
+
suggestion1.imageurl = 'https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png';
|
|
42
42
|
|
|
43
43
|
const suggestion2 = command.newCommandSuggestion();
|
|
44
44
|
suggestion2.title = 'CLI doc';
|
|
45
45
|
suggestion2.description = 'Catalyst CLI documentation';
|
|
46
|
-
suggestion2.imageurl = 'https://www.
|
|
46
|
+
suggestion2.imageurl = 'https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png';
|
|
47
47
|
|
|
48
48
|
const suggestion3 = command.newCommandSuggestion();
|
|
49
49
|
suggestion3.title = 'Help docs';
|
|
50
50
|
suggestion3.description = 'Catalyst help documentation';
|
|
51
|
-
suggestion3.imageurl = 'https://www.
|
|
51
|
+
suggestion3.imageurl = 'https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png';
|
|
52
52
|
|
|
53
53
|
res.push(suggestion1,suggestion2,suggestion3);
|
|
54
54
|
}
|
|
@@ -85,7 +85,7 @@ widget.viewHandler(async (req, res) => {
|
|
|
85
85
|
const info = res.newWidgetInfo();
|
|
86
86
|
info.title = 'Sorry! No tables found.';
|
|
87
87
|
info.description = 'Catalyst Datastore can be used to create and manage tables to store persistent data of your applications!';
|
|
88
|
-
info.image_url = 'https://www.
|
|
88
|
+
info.image_url = 'https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png';
|
|
89
89
|
|
|
90
90
|
const linkBtn = info.newWidgetButton();
|
|
91
91
|
linkBtn.label = 'Visit Zoho Catalyst';
|
|
@@ -39,17 +39,17 @@ def suggester(req: CommandHandlerRequest, res: List[CommandSuggestion], *args):
|
|
|
39
39
|
suggestion1 = command.new_command_suggestion()
|
|
40
40
|
suggestion1.title = 'API doc'
|
|
41
41
|
suggestion1.description = 'Catalyst API documentation'
|
|
42
|
-
suggestion1.imageurl = 'https://www.
|
|
42
|
+
suggestion1.imageurl = 'https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png'
|
|
43
43
|
|
|
44
44
|
suggestion2 = command.new_command_suggestion()
|
|
45
45
|
suggestion2.title = 'CLI doc'
|
|
46
46
|
suggestion2.description = 'Catalyst CLI documentation'
|
|
47
|
-
suggestion2.imageurl = 'https://www.
|
|
47
|
+
suggestion2.imageurl = 'https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png'
|
|
48
48
|
|
|
49
49
|
suggestion3 = command.new_command_suggestion()
|
|
50
50
|
suggestion3.title = 'Help docs'
|
|
51
51
|
suggestion3.description = 'Catalyst help documentation'
|
|
52
|
-
suggestion3.imageurl = 'https://www.
|
|
52
|
+
suggestion3.imageurl = 'https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png'
|
|
53
53
|
|
|
54
54
|
res.extend([suggestion1,suggestion2,suggestion3])
|
|
55
55
|
return res
|
|
@@ -89,7 +89,7 @@ def view_handler(req: WidgetExecutionHandlerRequest, res: WidgetResponse, *args)
|
|
|
89
89
|
info = res.new_widget_info()
|
|
90
90
|
info.title = 'Sorry! No tables found.'
|
|
91
91
|
info.description = 'Catalyst Datastore can be used to create and manage tables to store persistent data of your applications!'
|
|
92
|
-
info.image_url = 'https://www.
|
|
92
|
+
info.image_url = 'https://www.zoho.com/sites/zweb/images/brandingkit/catalyst-128.png'
|
|
93
93
|
|
|
94
94
|
link_btn = info.new_widget_button()
|
|
95
95
|
link_btn.label = 'Visit Zoho Catalyst'
|