zcatalyst-cli 1.18.0-beta.11-slate → 1.18.0-beta.13
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 +14 -6
- package/docs/endpoints/lib/env.toml +3 -1
- package/docs/option-filter.toml +0 -5
- package/lib/authentication/login.js +3 -2
- package/lib/commands/index.js +3 -3
- package/lib/commands/init.js +0 -10
- package/lib/commands/slate/create.js +2 -3
- package/lib/commands/slate/link.js +0 -1
- package/lib/commands/slate/unlink.js +3 -2
- package/lib/config-store.js +2 -1
- package/lib/endpoints/lib/env.js +2 -1
- package/lib/index.js +1 -1
- package/lib/init/features/slate/index.js +16 -11
- package/lib/prompt/index.js +22 -6
- package/lib/prompt/types/file-path.js +4 -4
- package/lib/serve/server/lib/master/slate.js +1 -1
- package/lib/serve/server/lib/slate/index.js +23 -52
- package/lib/util_modules/constants/lib/dc-type.js +8 -0
- package/lib/util_modules/constants/lib/urls.js +30 -61
- package/lib/util_modules/fs/lib/async.js +6 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<center>
|
|
2
|
-
<a href="https://
|
|
2
|
+
<a href="https://catalyst.zoho.com/
|
|
3
3
|
<img width="200" height="200" src="https://www.zohowebstatic.com/sites/default/files/catalyst/catalyst-logo.svg">
|
|
4
4
|
</a>
|
|
5
5
|
</center>
|
|
@@ -25,7 +25,7 @@ This is the Catalyst Command Line Interface (CLI) Tool. They can be used to:
|
|
|
25
25
|
- Interact with data in your Catalyst projects via console
|
|
26
26
|
- Deploy code and assets to your Catalyst projects
|
|
27
27
|
|
|
28
|
-
To get started with the Catalyst CLI, you can go through our documentation [CLI documentation](https://
|
|
28
|
+
To get started with the Catalyst CLI, you can go through our documentation [CLI documentation](https://docs.catalyst.zoho.com/en/cli/v1/cli-command-reference/).
|
|
29
29
|
|
|
30
30
|
## Installation
|
|
31
31
|
|
|
@@ -37,7 +37,7 @@ Then you need to install [Node.js](http://nodejs.org/) and [npm](https://npmjs.o
|
|
|
37
37
|
**NOTE**
|
|
38
38
|
|
|
39
39
|
1. Installing Node.js should install npm as well.
|
|
40
|
-
2. The ZCatalyst-CLI is compatible only with node versions >=
|
|
40
|
+
2. The ZCatalyst-CLI is compatible only with node versions >=14.
|
|
41
41
|
|
|
42
42
|
---
|
|
43
43
|
|
|
@@ -55,7 +55,7 @@ This will provide you with the globally accessible `catalyst` command.
|
|
|
55
55
|
|
|
56
56
|
1. If you need to setup the cli in current directory alone use the same command without `-g` option.
|
|
57
57
|
|
|
58
|
-
2. Alternatively you can visit [CLI Installation Documentation](https://
|
|
58
|
+
2. Alternatively you can visit [CLI Installation Documentation](https://docs.catalyst.zoho.com/en/getting-started/installing-catalyst-cli/) for installation instructions.
|
|
59
59
|
|
|
60
60
|
---
|
|
61
61
|
|
|
@@ -69,6 +69,7 @@ Certain command are project specific and for it to work you must be inside a pro
|
|
|
69
69
|
|
|
70
70
|
Command | Description
|
|
71
71
|
------- | -----------
|
|
72
|
+
**help** | Display the command reference or help for a specific command.
|
|
72
73
|
**login** | Log the CLI in to your Catalyst account. *Requires access to a web browser*.
|
|
73
74
|
**whoami** | Print the email address of the user currently logged in.
|
|
74
75
|
**token:generate** | Generate a token to authenticate accessing the CLI from a remote system.
|
|
@@ -96,13 +97,16 @@ Command | Description
|
|
|
96
97
|
**functions:shell** | Launch a node shell to test emulated functions of any stack or type, other than Advanced I/O functions.
|
|
97
98
|
**functions:config** | Perform advanced configurations such as memory allocation on a function in your project.
|
|
98
99
|
**functions:delete** | Delete a function from the remote console or the local directory.
|
|
99
|
-
**appsail:add** | Link an already existing AppSail
|
|
100
|
+
**appsail:add** | Link an already existing AppSail app to Catalyst Project.
|
|
101
|
+
**slate:link** | Configure your existing app in slate service
|
|
102
|
+
**slate:create** | Create a new slate app
|
|
103
|
+
**slate:unlink** | Unlink your existing slate app
|
|
100
104
|
**codelib:install** | Install the code library functionalities into your project.
|
|
101
105
|
**event:generate \| generate:event** | Generate sample payloads from different components or custom event sources to test Event functions.
|
|
102
106
|
**event:generate:integ** | Generate sample payloads for the required integration service to test Integration functions.
|
|
107
|
+
**event:generate:job** | Generate sample payloads to test the job functions
|
|
103
108
|
**serve** | Serve Basic I/O and Advanced I/O functions, and the client, to test them locally.
|
|
104
109
|
**deploy** | Deploy the Catalyst project and project resources to the remote console from the local directory.
|
|
105
|
-
**help** | Display the command reference or help for a specific command.
|
|
106
110
|
**run-script \| run** | Run a particular command script defined in *catalyst.json*.
|
|
107
111
|
**config:set** | Set catalyst configuration as a key value pair.
|
|
108
112
|
**config:get** | Get catalyst config value for the specified key.
|
|
@@ -122,3 +126,7 @@ This is to make sure your local project is upto date with the CLI version that i
|
|
|
122
126
|
### **v1.4.0**
|
|
123
127
|
|
|
124
128
|
- Global configuration file (zcatalyst-cli-nodejs/zcatalyst-cli.json) structure change.
|
|
129
|
+
|
|
130
|
+
### **v1.6.2**
|
|
131
|
+
|
|
132
|
+
- Global configuration file (zcatalyst-cli-nodejs/zcatalyst-cli.json) structure change.
|
package/docs/option-filter.toml
CHANGED
|
@@ -43,8 +43,3 @@ link = ''
|
|
|
43
43
|
context = '''The API Gateway cannot be served seperately in local.'''
|
|
44
44
|
aid = '''Please include atleast one other component like functions or client along with the APIG to serve the APIG in local.'''
|
|
45
45
|
link = ''
|
|
46
|
-
|
|
47
|
-
[OPT-FILTER-10]
|
|
48
|
-
context = '''Slate does not have a serve support.'''
|
|
49
|
-
aid = '''Please start your Slate apps using the framework-specific commands.'''
|
|
50
|
-
link = ''
|
|
@@ -34,10 +34,11 @@ const option_1 = require("../util_modules/option");
|
|
|
34
34
|
const crypto_1 = require("crypto");
|
|
35
35
|
exports.missingScopes = {
|
|
36
36
|
[constants_1.DC_TYPE.in.value]: getScopes(['zest', 'dataverse']),
|
|
37
|
-
[constants_1.DC_TYPE.eu.value]: getScopes(['zest', '
|
|
37
|
+
[constants_1.DC_TYPE.eu.value]: getScopes(['zest', 'dataverse']),
|
|
38
38
|
[constants_1.DC_TYPE.au.value]: getScopes(['zest', 'dataverse']),
|
|
39
39
|
[constants_1.DC_TYPE.ca.value]: getScopes(['zest', 'quick_ml', 'dataverse']),
|
|
40
|
-
[constants_1.DC_TYPE.sa.value]: getScopes(['zest', 'quick_ml', 'dataverse'])
|
|
40
|
+
[constants_1.DC_TYPE.sa.value]: getScopes(['zest', 'quick_ml', 'dataverse']),
|
|
41
|
+
[constants_1.DC_TYPE.jp.value]: getScopes(['zest', 'dataverse'])
|
|
41
42
|
};
|
|
42
43
|
function getScopes(keys) {
|
|
43
44
|
return Object.keys(constants_1.SCOPE).filter((scope) => keys.some((prefix) => scope.startsWith(prefix)));
|
package/lib/commands/index.js
CHANGED
|
@@ -49,6 +49,7 @@ exports.default = (client) => {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
return Promise.all([
|
|
52
|
+
loadCommand('help'),
|
|
52
53
|
loadCommand('login'),
|
|
53
54
|
loadCommand('whoami'),
|
|
54
55
|
loadCommand('token:generate'),
|
|
@@ -72,10 +73,10 @@ exports.default = (client) => {
|
|
|
72
73
|
loadCommand('client:setup'),
|
|
73
74
|
loadCommand('client:delete'),
|
|
74
75
|
loadCommand('functions:setup'),
|
|
75
|
-
loadCommand('functions:delete'),
|
|
76
76
|
loadCommand('functions:add'),
|
|
77
77
|
loadCommand('functions:shell'),
|
|
78
78
|
loadCommand('functions:config'),
|
|
79
|
+
loadCommand('functions:delete'),
|
|
79
80
|
loadCommand('appsail:add'),
|
|
80
81
|
loadCommand('slate:link'),
|
|
81
82
|
loadCommand('slate:create'),
|
|
@@ -83,11 +84,10 @@ exports.default = (client) => {
|
|
|
83
84
|
loadCommand('codelib:install'),
|
|
84
85
|
loadCommand('event:generate'),
|
|
85
86
|
loadCommand('event:generate:integ'),
|
|
86
|
-
loadCommand('zest:generate'),
|
|
87
87
|
loadCommand('event:generate:job'),
|
|
88
|
+
loadCommand('zest:generate'),
|
|
88
89
|
loadCommand('serve'),
|
|
89
90
|
loadCommand('deploy'),
|
|
90
|
-
loadCommand('help'),
|
|
91
91
|
loadCommand('run'),
|
|
92
92
|
loadCommand('config:set'),
|
|
93
93
|
loadCommand('config:get'),
|
package/lib/commands/init.js
CHANGED
|
@@ -41,7 +41,6 @@ const command_1 = __importDefault(require("../internal/command"));
|
|
|
41
41
|
const prompt_1 = __importDefault(require("../prompt"));
|
|
42
42
|
const runtime_store_1 = __importDefault(require("../runtime-store"));
|
|
43
43
|
const constants_1 = require("../util_modules/constants");
|
|
44
|
-
const env_1 = require("../util_modules/env");
|
|
45
44
|
const fs_1 = require("../util_modules/fs");
|
|
46
45
|
const js_1 = require("../util_modules/js");
|
|
47
46
|
const logger_1 = require("../util_modules/logger");
|
|
@@ -90,15 +89,6 @@ exports.default = new command_1.default('init [feature]')
|
|
|
90
89
|
(0, ansi_colors_1.bold)(runtime_store_1.default.get('project.root')) +
|
|
91
90
|
'\n' +
|
|
92
91
|
warningText);
|
|
93
|
-
const windownConfirmation = env_1.isWindows
|
|
94
|
-
? yield prompt_1.default.ask(prompt_1.default.question('confirmation', 'Are you ready to proceed?', {
|
|
95
|
-
type: 'confirm'
|
|
96
|
-
}))
|
|
97
|
-
: { confirmation: true };
|
|
98
|
-
if (!windownConfirmation.confirmation) {
|
|
99
|
-
(0, logger_1.message)('Aborted by user.');
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
92
|
if (feature !== 'project') {
|
|
103
93
|
try {
|
|
104
94
|
yield (0, features_1.project)();
|
|
@@ -41,12 +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:create')
|
|
44
|
-
.description('Configure a new slate
|
|
44
|
+
.description('Configure a new slate app in catalyst')
|
|
45
45
|
.option('--name <app_name>', 'Please provide name for your slate')
|
|
46
|
-
.option('--framework <framework_name>', 'Specify
|
|
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')
|
|
49
|
-
.option('--production', 'Set production app configurations')
|
|
50
49
|
.needs('auth')
|
|
51
50
|
.needs('config', { optional: true })
|
|
52
51
|
.needs('rc', { optional: true, generateRc: true })
|
|
@@ -46,7 +46,6 @@ exports.default = new command_1.default('slate:link')
|
|
|
46
46
|
.option('--framework <framework_name>', 'Specify frame work name for your slate')
|
|
47
47
|
.option('--template <template_url>', 'Provide template url for your slate')
|
|
48
48
|
.option('--default', 'Set default app configurations')
|
|
49
|
-
.option('--production', 'Create a app with production configurations')
|
|
50
49
|
.needs('auth')
|
|
51
50
|
.needs('config', { optional: true })
|
|
52
51
|
.needs('rc', { optional: true, generateRc: true })
|
|
@@ -59,11 +59,12 @@ exports.default = new command_1.default('slate:unlink')
|
|
|
59
59
|
type: 'confirm',
|
|
60
60
|
default: false
|
|
61
61
|
}));
|
|
62
|
+
yield fs_1.ASYNC.deleteDir((0, path_1.join)(slateDetails.source, constants_1.FILENAME.cli_config));
|
|
62
63
|
if (removeSource) {
|
|
63
|
-
fs_1.ASYNC.deleteDir(slateDetails.source);
|
|
64
|
+
yield fs_1.ASYNC.deleteDir(slateDetails.source);
|
|
64
65
|
}
|
|
65
66
|
else {
|
|
66
|
-
fs_1.ASYNC.deleteDir((0, path_1.join)(slateDetails.source, '.catalyst'));
|
|
67
|
+
yield fs_1.ASYNC.deleteDir((0, path_1.join)(slateDetails.source, '.catalyst'));
|
|
67
68
|
}
|
|
68
69
|
config.unset('slate');
|
|
69
70
|
config.set('slate', slateServices.filter((slateCon) => slateCon.name !== appName));
|
package/lib/config-store.js
CHANGED
|
@@ -6,4 +6,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const conf_1 = __importDefault(require("conf"));
|
|
7
7
|
const runtime_store_1 = __importDefault(require("./runtime-store"));
|
|
8
8
|
const name = runtime_store_1.default.get('context.cli.package.name');
|
|
9
|
-
|
|
9
|
+
const path = process.env['X_ZC_CREDENTIAL_PATH'];
|
|
10
|
+
exports.default = new conf_1.default({ configName: name, projectName: name, cwd: path });
|
package/lib/endpoints/lib/env.js
CHANGED
|
@@ -37,7 +37,8 @@ class Env {
|
|
|
37
37
|
(0, ansi_colors_1.bold)(constants_1.DEFAULT.env_name),
|
|
38
38
|
(0, ansi_colors_1.bold)(projectId),
|
|
39
39
|
ansi_colors_1.bold.red('blocked'),
|
|
40
|
-
ansi_colors_1.italic.underline('support@zohocatalyst.com')
|
|
40
|
+
ansi_colors_1.italic.underline('support@zohocatalyst.com'),
|
|
41
|
+
ansi_colors_1.italic.red(JSON.stringify(devEnv.blocked_reason) || 'Unknown')
|
|
41
42
|
]
|
|
42
43
|
});
|
|
43
44
|
}
|
package/lib/index.js
CHANGED
|
@@ -23,6 +23,6 @@ program.helpOption('-h, --help', 'Display help for a Catalyst command');
|
|
|
23
23
|
program.showSuggestionAfterError();
|
|
24
24
|
program.showHelpAfterError(`For more usage information use the ${(0, ansi_colors_1.bold)('catalyst help')} command`);
|
|
25
25
|
program.addHelpText('before', fs_1.SYNC.readFile(constants_1.TEMPLATE.banner, 'utf-8') || '');
|
|
26
|
-
program.addHelpText('afterAll', `\nFor detailed documentations please visit ${(0, ansi_colors_1.underline)('https://
|
|
26
|
+
program.addHelpText('afterAll', `\nFor detailed documentations please visit ${(0, ansi_colors_1.underline)('https://docs.catalyst.zoho.com/en/cli/v1/cli-command-reference/')}`);
|
|
27
27
|
const cli = new client_1.Client(program);
|
|
28
28
|
exports.default = cli;
|
|
@@ -49,7 +49,6 @@ const console_1 = require("console");
|
|
|
49
49
|
const error_1 = __importDefault(require("../../../error"));
|
|
50
50
|
const constants_1 = require("../../../util_modules/constants");
|
|
51
51
|
const project_1 = require("../../../util_modules/project");
|
|
52
|
-
const slate_1 = require("../../../deploy/features/slate");
|
|
53
52
|
const toml_1 = require("../../../util_modules/parser/toml");
|
|
54
53
|
const async_1 = require("../../../util_modules/fs/lib/async");
|
|
55
54
|
function getFrameworkOption(frameworks, source) {
|
|
@@ -86,7 +85,6 @@ function validateAppName(appName) {
|
|
|
86
85
|
function getAppName(existingSlates, frameworkOpt) {
|
|
87
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
87
|
let appName = (0, option_1.getOptionValue)('name');
|
|
89
|
-
const remoteApps = yield (yield (0, endpoints_1.slateAPI)({ env: (0, slate_1.getEnvironmentType)() })).getAllApps();
|
|
90
88
|
if (!appName) {
|
|
91
89
|
const { name } = yield prompt_1.default.ask(prompt_1.default.question('name', 'Please provide the name for your app:', {
|
|
92
90
|
type: 'input',
|
|
@@ -94,8 +92,6 @@ function getAppName(existingSlates, frameworkOpt) {
|
|
|
94
92
|
validate: (name) => {
|
|
95
93
|
if (existingSlates.findIndex((targ) => targ.name === name) !== -1)
|
|
96
94
|
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
95
|
return validateAppName(name);
|
|
100
96
|
}
|
|
101
97
|
}));
|
|
@@ -105,8 +101,6 @@ function getAppName(existingSlates, frameworkOpt) {
|
|
|
105
101
|
if (existingSlates.findIndex((targ) => targ.name === appName) !== -1) {
|
|
106
102
|
throw new error_1.default('Slate already configured with this name.');
|
|
107
103
|
}
|
|
108
|
-
else if (remoteApps.findIndex((targ) => targ.name === appName) !== -1)
|
|
109
|
-
return 'App with this name already exists in remote.';
|
|
110
104
|
else {
|
|
111
105
|
const isValidApp = validateAppName(appName);
|
|
112
106
|
if (isValidApp !== true) {
|
|
@@ -161,8 +155,12 @@ function addExistingSlate(existingSlates) {
|
|
|
161
155
|
}),
|
|
162
156
|
depth: 5,
|
|
163
157
|
empTxt: ' ',
|
|
164
|
-
rootPath: projectRoot
|
|
158
|
+
rootPath: projectRoot,
|
|
159
|
+
ignoreFiles: true,
|
|
160
|
+
excludeDir: true,
|
|
161
|
+
exclude: ['**/node_modules', '**/.git', '**/.catalyst']
|
|
165
162
|
}));
|
|
163
|
+
prompt_1.default.deregister('file-path');
|
|
166
164
|
return sourcePath;
|
|
167
165
|
});
|
|
168
166
|
}
|
|
@@ -194,7 +192,8 @@ function detectFramework(source, frameworkList) {
|
|
|
194
192
|
if (isNextJs) {
|
|
195
193
|
return { name: 'nextjs', source };
|
|
196
194
|
}
|
|
197
|
-
|
|
195
|
+
frameworkList = frameworkList.filter((framework) => !['static', 'react-vite', 'nextjs'].includes(framework.name));
|
|
196
|
+
const framework = frameworkList.find(({ keywords }) => keywords.every((keyword) => dependencies[keyword] !== undefined));
|
|
198
197
|
if (!framework) {
|
|
199
198
|
(0, logger_1.warning)('No matching framework found in package.json dependencies');
|
|
200
199
|
return getFrameworkOption(frameworkList);
|
|
@@ -236,6 +235,7 @@ function getConfigDetails(frameworkOpt, frameworks) {
|
|
|
236
235
|
const config = yield prompt_1.default.ask(prompt_1.default.question('installCommand', 'Provide your Install Command:', {
|
|
237
236
|
type: 'input',
|
|
238
237
|
validate: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
238
|
+
value = value.trim();
|
|
239
239
|
if (value === '')
|
|
240
240
|
return 'Please provide a valid install command';
|
|
241
241
|
else if (value.length > 50)
|
|
@@ -245,6 +245,7 @@ function getConfigDetails(frameworkOpt, frameworks) {
|
|
|
245
245
|
}), prompt_1.default.question('buildCommand', 'Provide your Build Command:', {
|
|
246
246
|
type: 'input',
|
|
247
247
|
validate: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
248
|
+
value = value.trim();
|
|
248
249
|
if (value === '')
|
|
249
250
|
return 'Please provide a valid build command';
|
|
250
251
|
else if (value.length > 50)
|
|
@@ -254,16 +255,19 @@ function getConfigDetails(frameworkOpt, frameworks) {
|
|
|
254
255
|
}), prompt_1.default.question('buildPath', 'Provide your Build Path:', {
|
|
255
256
|
type: 'input',
|
|
256
257
|
validate: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
258
|
+
value = value.trim();
|
|
257
259
|
if (value === '')
|
|
258
260
|
return 'Please provide a valid build path';
|
|
261
|
+
else if (/[#%*$@?]/.test(value))
|
|
262
|
+
return 'Build path containing invalid characters.';
|
|
259
263
|
else if (value.length > 50)
|
|
260
264
|
return 'Cannot exceed 50 characters.';
|
|
261
265
|
return true;
|
|
262
266
|
})
|
|
263
267
|
}));
|
|
264
268
|
(slateConfigDetails.install_command = config.installCommand),
|
|
265
|
-
(slateConfigDetails.build_path = config.
|
|
266
|
-
(slateConfigDetails.build_command = config.
|
|
269
|
+
(slateConfigDetails.build_path = config.buildPath),
|
|
270
|
+
(slateConfigDetails.build_command = config.buildCommand);
|
|
267
271
|
}
|
|
268
272
|
return slateConfigDetails || {};
|
|
269
273
|
});
|
|
@@ -286,8 +290,9 @@ exports.default = (add) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
286
290
|
type: 'input',
|
|
287
291
|
default: 'npm start',
|
|
288
292
|
validate: (value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
293
|
+
value = value.trim();
|
|
289
294
|
if (value === '')
|
|
290
|
-
return 'Please provide a valid
|
|
295
|
+
return 'Please provide a valid development command';
|
|
291
296
|
else if (value.length > 50)
|
|
292
297
|
return 'Cannot exceed 50 characters.';
|
|
293
298
|
return true;
|
package/lib/prompt/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,10 @@ 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, depth) {
|
|
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
|
|
23
|
+
filter: { exclude, excludeDir, ignoreFiles },
|
|
24
24
|
depth,
|
|
25
25
|
includeDirPaths: true
|
|
26
26
|
});
|
|
@@ -35,7 +35,7 @@ function getPaths(rootPath, pattern, exclude, defaultItem, depth) {
|
|
|
35
35
|
}
|
|
36
36
|
class InquirerFilePath extends inquirer_autocomplete_prompt_1.default {
|
|
37
37
|
constructor(question, rl, answers) {
|
|
38
|
-
const { rootPath = '.', exclude = [] } = question;
|
|
38
|
+
const { rootPath = '.', exclude = [], excludeDir = false, ignoreFiles = false } = question;
|
|
39
39
|
const questionBase = Object.assign({
|
|
40
40
|
emptyText: question.empTxt
|
|
41
41
|
? question.empTxt
|
|
@@ -43,7 +43,7 @@ class InquirerFilePath extends inquirer_autocomplete_prompt_1.default {
|
|
|
43
43
|
(0, ansi_colors_1.cyan)('<return> ') +
|
|
44
44
|
'key'
|
|
45
45
|
}, question, {
|
|
46
|
-
source: (_, pattern) => getPaths(rootPath, pattern, exclude, question.default, question.depth)
|
|
46
|
+
source: (_, pattern) => getPaths(rootPath, pattern, exclude, excludeDir, ignoreFiles, question.default, question.depth)
|
|
47
47
|
});
|
|
48
48
|
super(questionBase, rl, answers);
|
|
49
49
|
}
|
|
@@ -36,18 +36,8 @@ const startSlate = (port, opts) => {
|
|
|
36
36
|
child.on('error', (reason) => _rej(reason));
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
|
-
const installPackages = (opts) => {
|
|
40
|
-
const child = (0, shell_1.spawn)(opts.command, [], {
|
|
41
|
-
cwd: opts.target,
|
|
42
|
-
shell: true
|
|
43
|
-
}).RAW();
|
|
44
|
-
return new Promise((_res, _rej) => {
|
|
45
|
-
child.on('spawn', () => _res(child));
|
|
46
|
-
child.on('error', (reason) => _rej(reason));
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
39
|
exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
-
var _a
|
|
40
|
+
var _a;
|
|
51
41
|
const targetSlate = serverDetails.target;
|
|
52
42
|
if (!targetSlate || !targetSlate.config) {
|
|
53
43
|
throw new error_1.default('Slate details not found');
|
|
@@ -71,9 +61,9 @@ exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function*
|
|
|
71
61
|
});
|
|
72
62
|
}
|
|
73
63
|
if (!(yield fs_1.ASYNC.isPathExists(targetSlate.source))) {
|
|
74
|
-
throw new error_1.default('The given Slate source path does not
|
|
64
|
+
throw new error_1.default('The given Slate source path does not exist', {
|
|
75
65
|
exit: 1,
|
|
76
|
-
errorId: 'SERVE-
|
|
66
|
+
errorId: 'SERVE-SLATE-2',
|
|
77
67
|
arg: [ansi_colors_1.italic.underline.red(targetSlate.source), (0, ansi_colors_1.bold)(targetSlate.name)]
|
|
78
68
|
});
|
|
79
69
|
}
|
|
@@ -81,56 +71,37 @@ exports.default = (serverDetails) => __awaiter(void 0, void 0, void 0, function*
|
|
|
81
71
|
if (!configJson) {
|
|
82
72
|
throw new error_1.default('Development command not found', {
|
|
83
73
|
exit: 1,
|
|
84
|
-
errorId: 'SERVE-SLATE-
|
|
74
|
+
errorId: 'SERVE-SLATE-3',
|
|
85
75
|
arg: ['catalyst slate:create']
|
|
86
76
|
});
|
|
87
77
|
}
|
|
88
|
-
if ((_a = targetSlate.config) === null || _a === void 0 ? void 0 : _a.install_command) {
|
|
89
|
-
const spwnProcess = yield installPackages({
|
|
90
|
-
target: targetSlate.source,
|
|
91
|
-
command: (_b = targetSlate.config) === null || _b === void 0 ? void 0 : _b.install_command
|
|
92
|
-
});
|
|
93
|
-
spwnProcess.once('exit', (code) => {
|
|
94
|
-
if (code === 150) {
|
|
95
|
-
targetSlate.validity = {
|
|
96
|
-
valid: false,
|
|
97
|
-
reason: 'Unable to install the dependencies'
|
|
98
|
-
};
|
|
99
|
-
throw new error_1.default('Unable to start the Slate', {
|
|
100
|
-
exit: 1,
|
|
101
|
-
errorId: 'SERVE-SLATE-3',
|
|
102
|
-
arg: [(0, ansi_colors_1.bold)('catalyst serve')]
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
78
|
child = yield startSlate(targetSlate.port.slate, {
|
|
108
79
|
target: targetSlate.source,
|
|
109
|
-
command: (
|
|
110
|
-
});
|
|
111
|
-
child.once('exit', (code) => {
|
|
112
|
-
if (code === 150) {
|
|
113
|
-
targetSlate.validity = {
|
|
114
|
-
valid: false,
|
|
115
|
-
reason: 'Unable to start the Slate'
|
|
116
|
-
};
|
|
117
|
-
throw new error_1.default('Unable to start the Slate', {
|
|
118
|
-
exit: 1,
|
|
119
|
-
errorId: 'SERVE-SLATE-2',
|
|
120
|
-
arg: [(0, ansi_colors_1.bold)(targetSlate.name), (0, ansi_colors_1.underline)((configJson === null || configJson === void 0 ? void 0 : configJson.dev_command) || '')]
|
|
121
|
-
});
|
|
122
|
-
}
|
|
80
|
+
command: (_a = configJson === null || configJson === void 0 ? void 0 : configJson.slate) === null || _a === void 0 ? void 0 : _a.dev_command
|
|
123
81
|
});
|
|
124
82
|
}
|
|
125
83
|
const masterServe = yield (0, master_1.default)(targetSlate.port.proxy, {
|
|
126
84
|
slateDetails: serverDetails
|
|
127
85
|
});
|
|
128
|
-
child.once('exit', () => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
86
|
+
child.once('exit', (code) => {
|
|
87
|
+
child.once('exit', () => {
|
|
88
|
+
masterServe.close((err) => {
|
|
89
|
+
if (err) {
|
|
90
|
+
(0, logger_1.debug)('Error stopping the Slate proxy server: ', err);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
133
93
|
});
|
|
94
|
+
if (code === 150) {
|
|
95
|
+
targetSlate.validity = {
|
|
96
|
+
valid: false,
|
|
97
|
+
reason: 'Unable to start the Slate'
|
|
98
|
+
};
|
|
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
|
+
}
|
|
134
105
|
});
|
|
135
106
|
process.on('SIGINT', () => {
|
|
136
107
|
masterServe.close((err) => {
|
|
@@ -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
|
+
}
|
|
@@ -84,7 +84,8 @@ function dirList(dir) {
|
|
|
84
84
|
exports.dirList = dirList;
|
|
85
85
|
function walk(dir, { filter = {
|
|
86
86
|
exclude: [],
|
|
87
|
-
excludeDir: true
|
|
87
|
+
excludeDir: true,
|
|
88
|
+
ignoreFiles: false
|
|
88
89
|
}, depth = -1, includeDirPaths = false } = {}) {
|
|
89
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
91
|
const stats = yield fs_extra_1.default.lstat(dir);
|
|
@@ -98,7 +99,7 @@ function walk(dir, { filter = {
|
|
|
98
99
|
const entryPathStats = yield fs_extra_1.default.lstat(entryPath);
|
|
99
100
|
const isEntryPthDir = entryPathStats.isDirectory() && !entryPathStats.isSymbolicLink();
|
|
100
101
|
let excludeMatch = false;
|
|
101
|
-
if (!
|
|
102
|
+
if (!isEntryPthDir || filter.excludeDir) {
|
|
102
103
|
if (typeof filter.exclude === 'function') {
|
|
103
104
|
excludeMatch = excludeMatch || (yield filter.exclude(entryPath));
|
|
104
105
|
}
|
|
@@ -108,6 +109,9 @@ function walk(dir, { filter = {
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
}
|
|
112
|
+
if (!isEntryPthDir && filter.ignoreFiles && !excludeMatch) {
|
|
113
|
+
excludeMatch = true;
|
|
114
|
+
}
|
|
111
115
|
if (excludeMatch) {
|
|
112
116
|
return [];
|
|
113
117
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zcatalyst-cli",
|
|
3
|
-
"version": "1.18.0-beta.
|
|
3
|
+
"version": "1.18.0-beta.13",
|
|
4
4
|
"description": "Command Line Tool for CATALYST",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"functions",
|
|
22
22
|
"zcatalyst"
|
|
23
23
|
],
|
|
24
|
-
"author": "Catalyst (https://
|
|
24
|
+
"author": "Catalyst (https://github.com/catalystbyzoho)",
|
|
25
25
|
"homepage": "https://catalyst.zoho.com",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|