zcatalyst-cli 1.10.1 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/.DS_Store +0 -0
- package/docs/client-utils.toml +5 -0
- package/docs/command_needs/auth.toml +1 -1
- package/docs/optional-import.toml +10 -0
- package/docs/plugin-loader.toml +4 -0
- package/docs/serve/server/index.toml +4 -0
- package/docs/serve/server/lib/web_client/server.toml +4 -0
- package/lib/apig-utils.js +2 -1
- package/lib/authentication/login.js +10 -12
- package/lib/client-utils.js +8 -6
- package/lib/command_needs/auth.js +2 -2
- package/lib/commands/client/delete.js +2 -1
- package/lib/commands/ds/status.js +5 -5
- package/lib/commands/event/generate/index.js +4 -13
- package/lib/commands/functions/delete.js +2 -2
- package/lib/commands/functions/shell.js +5 -2
- package/lib/commands/iac/import.js +37 -10
- package/lib/commands/init.js +1 -1
- package/lib/commands/pull.js +1 -1
- package/lib/commands/serve.js +2 -1
- package/lib/endpoints/lib/sdk.js +2 -2
- package/lib/error.js +16 -13
- package/lib/errorOut.js +2 -2
- package/lib/fn-utils/lib/common.js +4 -4
- package/lib/fn-utils/lib/java.js +6 -4
- package/lib/fn-utils/lib/node.js +2 -2
- package/lib/init/dependencies/npm-install.js +10 -10
- package/lib/init/features/client/index.js +47 -0
- package/lib/init/features/client/initializers/angular.js +104 -0
- package/lib/init/features/client/initializers/basic.js +50 -0
- package/lib/init/features/client/initializers/lyte.js +56 -0
- package/lib/init/features/client/initializers/react.js +78 -0
- package/lib/init/features/functions/index.js +14 -5
- package/lib/init/features/functions/languages/node.js +3 -1
- package/lib/init/features/index.js +10 -3
- package/lib/init/features/project.js +1 -1
- package/lib/init/util/client.js +89 -4
- package/lib/internal/command.js +4 -1
- package/lib/internal/config.js +2 -1
- package/lib/optional-import.js +27 -26
- package/lib/plugin-loader.js +27 -10
- package/lib/port-resolver.js +4 -2
- package/lib/prompt/index.js +1 -1
- package/lib/pull/features/functions/index.js +1 -1
- package/lib/serve/index.js +6 -1
- package/lib/serve/server/index.js +52 -8
- package/lib/serve/server/lib/java/JavaaioServer.java +3 -2
- package/lib/serve/server/lib/master.js +22 -24
- package/lib/serve/server/lib/web_client/index.js +30 -0
- package/lib/serve/server/lib/web_client/server.js +174 -0
- package/lib/shell/dependencies/invoker/bio/java/JavabioInvoker.java +7 -1
- package/lib/shell/dependencies/invoker/bio/node.js +5 -2
- package/lib/shell/index.js +10 -6
- package/lib/util_modules/char.js +1 -1
- package/lib/util_modules/config/lib/apig.js +2 -1
- package/lib/util_modules/config/lib/client.js +18 -21
- package/lib/util_modules/constants/index.js +3 -1
- package/lib/util_modules/constants/lib/placeholders.js +1 -0
- package/lib/util_modules/constants/lib/plugin.js +28 -0
- package/lib/util_modules/constants/lib/template.js +11 -1
- package/lib/util_modules/constants/lib/urls.js +29 -13
- package/lib/util_modules/{contextHelp.js → context-help.js} +0 -0
- package/lib/util_modules/env.js +13 -12
- package/lib/util_modules/fs/index.js +1 -9
- package/lib/util_modules/fs/lib/async.js +3 -3
- package/lib/util_modules/fs/utils.js +8 -0
- package/lib/util_modules/global-space.js +2 -0
- package/lib/util_modules/option.js +5 -1
- package/lib/util_modules/server.js +53 -0
- package/lib/util_modules/shell.js +10 -6
- package/lib/winston.js +1 -1
- package/package.json +8 -5
- package/templates/.DS_Store +0 -0
- package/templates/init/.DS_Store +0 -0
- package/templates/init/client/.DS_Store +0 -0
- package/templates/init/client/{client-package.json → basic/client-package.json} +0 -0
- package/templates/init/client/{index.html → basic/index.html} +0 -0
- package/templates/init/client/{main.css → basic/main.css} +0 -0
- package/templates/init/client/{main.js → basic/main.js} +0 -0
- package/templates/init/client/lyte/build/build.js +301 -0
- package/templates/init/client/lyte/build/scripts/cliDownloadScript.js +54 -0
- package/templates/init/client/lyte/client-package.json +5 -0
- package/templates/init/client/lyte/components/javascript/welcome-comp.js +13 -0
- package/templates/init/client/lyte/components/styles/welcome-comp.css +0 -0
- package/templates/init/client/lyte/components/templates/welcome-comp.html +8 -0
- package/templates/init/client/lyte/data-store/adapters/.gitkeep +0 -0
- package/templates/init/client/lyte/data-store/models/.gitkeep +0 -0
- package/templates/init/client/lyte/data-store/serializers/.gitkeep +0 -0
- package/templates/init/client/lyte/index.html +17 -0
- package/templates/init/client/lyte/package.json +12 -0
- package/templates/init/client/lyte/router.js +14 -0
- package/templates/init/client/lyte/routes/index.js +54 -0
- package/templates/init/client/react/.DS_Store +0 -0
- package/templates/init/client/react/react_js/package.json +11 -0
- package/templates/init/client/react/react_js/template/README.md +70 -0
- package/templates/init/client/react/react_js/template/client-package.json +5 -0
- package/templates/init/client/react/react_js/template/gitignore +23 -0
- package/templates/init/client/react/react_js/template/public/favicon.ico +0 -0
- package/templates/init/client/react/react_js/template/public/index.html +43 -0
- package/templates/init/client/react/react_js/template/public/logo192.png +0 -0
- package/templates/init/client/react/react_js/template/public/logo512.png +0 -0
- package/templates/init/client/react/react_js/template/public/manifest.json +25 -0
- package/templates/init/client/react/react_js/template/public/robots.txt +3 -0
- package/templates/init/client/react/react_js/template/src/App.css +38 -0
- package/templates/init/client/react/react_js/template/src/App.js +25 -0
- package/templates/init/client/react/react_js/template/src/App.test.js +8 -0
- package/templates/init/client/react/react_js/template/src/index.css +13 -0
- package/templates/init/client/react/react_js/template/src/index.js +17 -0
- package/templates/init/client/react/react_js/template/src/logo.svg +1 -0
- package/templates/init/client/react/react_js/template/src/reportWebVitals.js +13 -0
- package/templates/init/client/react/react_js/template/src/setupTests.js +5 -0
- package/templates/init/client/react/react_js/template.json +13 -0
- package/templates/init/client/react/react_ts/package.json +11 -0
- package/templates/init/client/react/react_ts/template/README.md +46 -0
- package/templates/init/client/react/react_ts/template/client-package.json +5 -0
- package/templates/init/client/react/react_ts/template/gitignore +23 -0
- package/templates/init/client/react/react_ts/template/public/favicon.ico +0 -0
- package/templates/init/client/react/react_ts/template/public/index.html +43 -0
- package/templates/init/client/react/react_ts/template/public/logo192.png +0 -0
- package/templates/init/client/react/react_ts/template/public/logo512.png +0 -0
- package/templates/init/client/react/react_ts/template/public/manifest.json +25 -0
- package/templates/init/client/react/react_ts/template/public/robots.txt +3 -0
- package/templates/init/client/react/react_ts/template/src/App.css +38 -0
- package/templates/init/client/react/react_ts/template/src/App.test.tsx +9 -0
- package/templates/init/client/react/react_ts/template/src/App.tsx +26 -0
- package/templates/init/client/react/react_ts/template/src/index.css +13 -0
- package/templates/init/client/react/react_ts/template/src/index.tsx +17 -0
- package/templates/init/client/react/react_ts/template/src/logo.svg +1 -0
- package/templates/init/client/react/react_ts/template/src/reportWebVitals.ts +15 -0
- package/templates/init/client/react/react_ts/template/src/setupTests.ts +5 -0
- package/templates/init/client/react/react_ts/template.json +18 -0
- package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +116 -113
- package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +20 -27
- package/templates/init/functions/java/integ/cliq/com/handlers/FunctionHandler.java +143 -112
- package/templates/init/functions/java/integ/cliq/com/handlers/InstallationHandler.java +4 -7
- package/templates/init/functions/java/integ/cliq/com/handlers/InstallationValidator.java +4 -7
- package/templates/init/functions/java/integ/cliq/com/handlers/MessageActionHandler.java +10 -12
- package/templates/init/functions/java/integ/cliq/com/handlers/WidgetHandler.java +100 -66
- package/templates/init/functions/java/integ/cliq/sample.java +5 -7
- package/templates/init/functions/node/integ/cliq/.DS_Store +0 -0
- package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +23 -8
- package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -4
- package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +46 -0
- package/templates/init/functions/node/integ/cliq/handlers/widget-handler.js +31 -0
- package/templates/init/functions/node/integ/cliq/package.json +2 -1
- package/templates/init/functions/node/integ/cliq/sample.js +3 -1
- package/templates/web-socket.txt +21 -0
- package/lib/init/features/client.js +0 -50
- package/lib/serve/server/lib/client.js +0 -30
package/docs/.DS_Store
ADDED
|
Binary file
|
package/docs/client-utils.toml
CHANGED
|
@@ -22,3 +22,8 @@ link = 'https://www.zoho.com/catalyst/help/project-directory-structure.html#Clie
|
|
|
22
22
|
context = '''Error when ${arg[0]} the Client with the ${arg[1]} plugin.'''
|
|
23
23
|
aid = '''Please rectify the below error to continue. \n${arg[2]}'''
|
|
24
24
|
link = ''
|
|
25
|
+
|
|
26
|
+
[CLIENT-UTILS-6]
|
|
27
|
+
context = '''Client Setup Skipped: Since the consent to overwrite the existing directory was not given.'''
|
|
28
|
+
aid = '''Existing directory: ${arg[0]}'''
|
|
29
|
+
link = ''
|
|
@@ -5,5 +5,5 @@ link = 'https://www.zoho.com/catalyst/help/cli-login.html'
|
|
|
5
5
|
|
|
6
6
|
[AUTH-2]
|
|
7
7
|
context = '''Oops! It looks like there is a scope missing for running this command'''
|
|
8
|
-
aid = '''Please use the ${arg[0]} command to re-login
|
|
8
|
+
aid = '''Please use the ${arg[0]} command to re-login'''
|
|
9
9
|
link = 'https://www.zoho.com/catalyst/help/cli-login.html'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
[OPT-IMP-1]
|
|
2
|
+
context='''The Plugin(${arg[0]}) cannot be found in the ${arg[1]} path.'''
|
|
3
|
+
aid='''Please ensure that the ${arg[0]} plugin is installed in the ${arg[2]} directory or
|
|
4
|
+
Try providing the exact path to the ${arg[0]} plugin directory relative to the project root directory.'''
|
|
5
|
+
link=''
|
|
6
|
+
|
|
7
|
+
[OPT-IMP-2]
|
|
8
|
+
context='''The Plugin directory(${arg[0]}) cannot be found in the ${arg[1]} path.'''
|
|
9
|
+
aid='''Please ensure that you have provided the correct path to the Plugin directory.'''
|
|
10
|
+
link=''
|
package/lib/apig-utils.js
CHANGED
|
@@ -13,7 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const ansi_colors_1 = require("ansi-colors");
|
|
16
|
-
const http_1 =
|
|
16
|
+
const http_1 = require("http");
|
|
17
|
+
const server_js_1 = require("../util_modules/server.js");
|
|
17
18
|
const open_1 = __importDefault(require("open"));
|
|
18
19
|
const path_1 = require("path");
|
|
19
20
|
const portfinder_1 = require("portfinder");
|
|
@@ -277,12 +278,10 @@ class Login {
|
|
|
277
278
|
const callbackUrl = this._getCallbackUrl(port);
|
|
278
279
|
const authUrl = this._getLoginUrl(callbackUrl);
|
|
279
280
|
let reqCount = 0;
|
|
280
|
-
const server = http_1.
|
|
281
|
+
const server = http_1.createServer((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
281
282
|
try {
|
|
282
283
|
let processReq = true;
|
|
283
|
-
if (reqCount + 1 > 1 ||
|
|
284
|
-
req.url === '/favicon.ico' ||
|
|
285
|
-
req.url === undefined) {
|
|
284
|
+
if (reqCount + 1 > 1 || req.url === '/favicon.ico' || req.url === undefined) {
|
|
286
285
|
logger_1.debug('unknown request received : ' + req.url);
|
|
287
286
|
processReq = false;
|
|
288
287
|
res.writeHead(404);
|
|
@@ -305,7 +304,7 @@ class Login {
|
|
|
305
304
|
defaultAns: true
|
|
306
305
|
}));
|
|
307
306
|
if (!ans.DC) {
|
|
308
|
-
|
|
307
|
+
yield destroyer.destroy(true).catch((err) => logger_1.debug(err));
|
|
309
308
|
reject(new error_1.default('Aborted by user.\n', {
|
|
310
309
|
exit: 1
|
|
311
310
|
}));
|
|
@@ -317,7 +316,8 @@ class Login {
|
|
|
317
316
|
js_1.JS.set(result, 'token', this.salt + '_' + result.refresh_token);
|
|
318
317
|
credential_1.default.oneTimeToken = result.access_token;
|
|
319
318
|
const userDetails = yield this._getUserDetails();
|
|
320
|
-
|
|
319
|
+
yield destroyer.destroy(true).catch((err) => logger_1.debug(err));
|
|
320
|
+
yield new Promise((res) => setTimeout(res, 2000));
|
|
321
321
|
resolve({
|
|
322
322
|
user: userDetails,
|
|
323
323
|
token: result,
|
|
@@ -327,23 +327,21 @@ class Login {
|
|
|
327
327
|
}
|
|
328
328
|
else if (processReq) {
|
|
329
329
|
yield this._respondWithFile(req, res, 400, '../../templates/loginFailure.html');
|
|
330
|
-
|
|
330
|
+
yield destroyer.destroy(true).catch((err) => logger_1.debug(err));
|
|
331
331
|
reject(new error_1.default("Credentials doesn't seem to be valid.\n", {
|
|
332
332
|
exit: 1
|
|
333
333
|
}));
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
336
|
catch (e) {
|
|
337
|
-
|
|
337
|
+
yield destroyer.destroy(true).catch((err) => logger_1.debug(err));
|
|
338
338
|
reject(new error_1.default('Server crashed with error.\n', {
|
|
339
339
|
exit: 2,
|
|
340
340
|
original: error_1.default.getErrorInstance(e)
|
|
341
341
|
}));
|
|
342
342
|
}
|
|
343
343
|
}));
|
|
344
|
-
|
|
345
|
-
socket.unref();
|
|
346
|
-
});
|
|
344
|
+
const destroyer = new server_js_1.ConnectionDestroyer(server);
|
|
347
345
|
server.listen(port, () => {
|
|
348
346
|
logger_1.info();
|
|
349
347
|
logger_1.info('Visit this URL on this device to log in:');
|
package/lib/client-utils.js
CHANGED
|
@@ -71,8 +71,8 @@ exports.clientUtils = {
|
|
|
71
71
|
runtime_store_1.default.set('context.client.source', sourceDir);
|
|
72
72
|
runtime_store_1.default.set('context.client.login_redirect', loginRedirect || homepage);
|
|
73
73
|
runtime_store_1.default.set('context.client.package_json', packageJsonFile);
|
|
74
|
-
const validatePlugin = yield plugin_loader_1.default('client', 'validate');
|
|
75
|
-
if (validatePlugin
|
|
74
|
+
const validatePlugin = yield plugin_loader_1.default('client', 'validate').catch((err) => logger_1.debug(err));
|
|
75
|
+
if (typeof validatePlugin !== 'function') {
|
|
76
76
|
runtime_store_1.default.set('context.client.valid', true);
|
|
77
77
|
return packageJson;
|
|
78
78
|
}
|
|
@@ -81,7 +81,8 @@ exports.clientUtils = {
|
|
|
81
81
|
}
|
|
82
82
|
catch (e) {
|
|
83
83
|
const err = error_1.default.getErrorInstance(e, {
|
|
84
|
-
skipHelp: false
|
|
84
|
+
skipHelp: false,
|
|
85
|
+
fileName: __filename
|
|
85
86
|
});
|
|
86
87
|
err.errorId = 'CLIENT-UTILS-5';
|
|
87
88
|
err.arg = [
|
|
@@ -107,8 +108,8 @@ exports.clientUtils = {
|
|
|
107
108
|
},
|
|
108
109
|
pack: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
110
|
let source = project_1.resolveProjectPath(config_1.clientConfig.source());
|
|
110
|
-
const buildPlugin = yield plugin_loader_1.default('client', 'build');
|
|
111
|
-
if (buildPlugin
|
|
111
|
+
const buildPlugin = yield plugin_loader_1.default('client', 'build').catch((err) => logger_1.debug(err));
|
|
112
|
+
if (typeof buildPlugin === 'function') {
|
|
112
113
|
try {
|
|
113
114
|
logger_1.message(`Plugin : "${runtime_store_1.default.get(`context.client.plugins.build`)}" is used for client deploy`);
|
|
114
115
|
const outputDir = yield buildPlugin(source, runtime_store_1.default);
|
|
@@ -119,7 +120,8 @@ exports.clientUtils = {
|
|
|
119
120
|
}
|
|
120
121
|
catch (e) {
|
|
121
122
|
const err = error_1.default.getErrorInstance(e, {
|
|
122
|
-
skipHelp: false
|
|
123
|
+
skipHelp: false,
|
|
124
|
+
fileName: __filename
|
|
123
125
|
});
|
|
124
126
|
err.errorId = 'CLIENT-UTILS-5';
|
|
125
127
|
err.arg = [
|
|
@@ -45,11 +45,11 @@ exports.default = (inScopes = []) => {
|
|
|
45
45
|
const requiredScopes = [constants_1.SCOPE.projects, ...inScopes];
|
|
46
46
|
logger_1.debug('> command requires scopes: ' + JSON.stringify(requiredScopes));
|
|
47
47
|
const hasAllScope = requiredScopes.every((scope) => existingScopes.includes(scope));
|
|
48
|
-
if (!hasAllScope) {
|
|
48
|
+
if (!tokenObj.temp && !env_1.isCI && !hasAllScope) {
|
|
49
49
|
throw new error_1.default('Re-login required due to missing scopes!!', {
|
|
50
50
|
exit: 0,
|
|
51
51
|
errorId: 'AUTH-2',
|
|
52
|
-
arg: [ansi_colors_1.bold('catalyst login --force')
|
|
52
|
+
arg: [ansi_colors_1.bold('catalyst login --force')]
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
runtime_store_1.default.set('auth_scopes', requiredScopes);
|
|
@@ -88,6 +88,7 @@ exports.default = new command_1.default('client:delete [client_version]')
|
|
|
88
88
|
}
|
|
89
89
|
catch (error) {
|
|
90
90
|
const err = error_1.default.getErrorInstance(error);
|
|
91
|
+
err.exit = 2;
|
|
91
92
|
logger_1.debug('Failed to read ' + constants_1.FILENAME.client.package_json + ' Reason: ' + err.message);
|
|
92
93
|
}
|
|
93
94
|
if (clientVersion !== undefined && clientVersion !== localDel.version) {
|
|
@@ -153,7 +154,7 @@ exports.default = new command_1.default('client:delete [client_version]')
|
|
|
153
154
|
}
|
|
154
155
|
historyArr = [ipVersion];
|
|
155
156
|
}
|
|
156
|
-
choicesArray.push(prompt_1.default.
|
|
157
|
+
choicesArray.push(prompt_1.default.separator('-------REMOTE-------'));
|
|
157
158
|
js_1.JS.forEach(historyArr, (history) => {
|
|
158
159
|
const version = js_1.JS.get(history, 'status', false)
|
|
159
160
|
? `${history.app_version} (${ansi_colors_1.cyan('live')})`
|
|
@@ -123,7 +123,7 @@ const spinnerFn = (jobId, dsReport, cumulativeStatus, throbber, spinner, bulkApi
|
|
|
123
123
|
text: getSpinnerTxt(reportTable, dsReport)
|
|
124
124
|
});
|
|
125
125
|
needIteration = false;
|
|
126
|
-
resolve();
|
|
126
|
+
resolve(dsReport);
|
|
127
127
|
break;
|
|
128
128
|
case 'Failed':
|
|
129
129
|
reportTable.unshift([
|
|
@@ -137,7 +137,7 @@ const spinnerFn = (jobId, dsReport, cumulativeStatus, throbber, spinner, bulkApi
|
|
|
137
137
|
text: getSpinnerTxt(reportTable, dsReport)
|
|
138
138
|
});
|
|
139
139
|
needIteration = false;
|
|
140
|
-
resolve();
|
|
140
|
+
resolve(dsReport);
|
|
141
141
|
break;
|
|
142
142
|
default:
|
|
143
143
|
needIteration = false;
|
|
@@ -231,13 +231,13 @@ exports.default = new command_1.default('ds:status <operation> [jobid]')
|
|
|
231
231
|
const spinner = 'DS bulk ' + operation;
|
|
232
232
|
const throbber = throbber_1.default.getInstance();
|
|
233
233
|
throbber.add(spinner);
|
|
234
|
-
yield new Promise(spinnerFn(jobId, dsReport, cumulativeStatus, throbber, spinner, bulkApi, displayOpr, action));
|
|
235
|
-
if (
|
|
234
|
+
const finalDsReport = yield new Promise(spinnerFn(jobId, dsReport, cumulativeStatus, throbber, spinner, bulkApi, displayOpr, action));
|
|
235
|
+
if (finalDsReport.results && finalDsReport.results.download_url) {
|
|
236
236
|
const ans = yield prompt_1.default.ask(prompt_1.default.question('download', 'Do you like to download the report of this job to your cmd execution directory?', { type: 'confirm', defaultAns: false }));
|
|
237
237
|
if (ans.download) {
|
|
238
238
|
const hrTime = process.hrtime();
|
|
239
239
|
const fileName = `${displayOpr}_${jobId}_${hrTime[0] * 1000000000 + hrTime[1]}.zip`;
|
|
240
|
-
const bulkReport = (yield bulkApi.downloadReport(
|
|
240
|
+
const bulkReport = (yield bulkApi.downloadReport(finalDsReport.results.download_url, fileName));
|
|
241
241
|
return fs_1.ASYNC.writeFile(path_1.join(process.cwd(), fileName), bulkReport);
|
|
242
242
|
}
|
|
243
243
|
}
|
|
@@ -49,14 +49,8 @@ exports.default = new command_1.default('event:generate <source> <action>')
|
|
|
49
49
|
.needs('rc')
|
|
50
50
|
.needs('auth')
|
|
51
51
|
.action(function generate(source, action) {
|
|
52
|
-
var _a;
|
|
53
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
const
|
|
55
|
-
let unknownArgs = args.unknown;
|
|
56
|
-
if (unknownArgs === undefined) {
|
|
57
|
-
logger_1.debug('No unknownArgs supplied');
|
|
58
|
-
unknownArgs = [];
|
|
59
|
-
}
|
|
53
|
+
const unknownArgs = option_1.getUnknownOpts([]);
|
|
60
54
|
if (unknownArgs.length % 2 !== 0) {
|
|
61
55
|
throw new error_1.default('Unknown options are not provided as key value pairs', {
|
|
62
56
|
exit: 1,
|
|
@@ -89,8 +83,8 @@ exports.default = new command_1.default('event:generate <source> <action>')
|
|
|
89
83
|
if (currentIndex % 2 === 0) {
|
|
90
84
|
if (!currentValue.startsWith('--') &&
|
|
91
85
|
currentValue !== '-e' &&
|
|
92
|
-
currentValue !== '-rid'
|
|
93
|
-
|
|
86
|
+
currentValue !== '-rid' &&
|
|
87
|
+
currentValue !== '--verbose') {
|
|
94
88
|
const fault = unknownArgs === null || unknownArgs === void 0 ? void 0 : unknownArgs.map((arg) => {
|
|
95
89
|
if (arg === currentValue) {
|
|
96
90
|
return ansi_colors_1.red(arg);
|
|
@@ -100,10 +94,7 @@ exports.default = new command_1.default('event:generate <source> <action>')
|
|
|
100
94
|
throw new error_1.default('Invalid option format detected', {
|
|
101
95
|
exit: 1,
|
|
102
96
|
errorId: 'IDX-3',
|
|
103
|
-
arg: [
|
|
104
|
-
ansi_colors_1.bold('[catalyst ' + knownArgs + ' ' + fault + ']'),
|
|
105
|
-
ansi_colors_1.bold('--<option> <value>')
|
|
106
|
-
]
|
|
97
|
+
arg: [ansi_colors_1.italic(fault), ansi_colors_1.bold('--<option> <value>')]
|
|
107
98
|
});
|
|
108
99
|
}
|
|
109
100
|
previousValue[currentValue.slice(2)] = optionArr[currentIndex + 1];
|
|
@@ -116,7 +116,7 @@ exports.default = new command_1.default('functions:delete [function_name_or_id]'
|
|
|
116
116
|
});
|
|
117
117
|
});
|
|
118
118
|
if (localChoices.length > 0) {
|
|
119
|
-
localChoices.unshift(prompt_1.default.
|
|
119
|
+
localChoices.unshift(prompt_1.default.separator('-------LOCAL-------'));
|
|
120
120
|
}
|
|
121
121
|
choiceArr.push(...localChoices);
|
|
122
122
|
}
|
|
@@ -165,7 +165,7 @@ exports.default = new command_1.default('functions:delete [function_name_or_id]'
|
|
|
165
165
|
});
|
|
166
166
|
});
|
|
167
167
|
if (remoteChoices.length > 0) {
|
|
168
|
-
remoteChoices.unshift(prompt_1.default.
|
|
168
|
+
remoteChoices.unshift(prompt_1.default.separator('-------REMOTE------'));
|
|
169
169
|
}
|
|
170
170
|
choiceArr.push(...remoteChoices);
|
|
171
171
|
}
|
|
@@ -41,8 +41,11 @@ exports.default = new command_1.default('functions:shell')
|
|
|
41
41
|
`(default: ${constants_1.DEFAULT.serve_port.http.basicio})`)
|
|
42
42
|
.option('--debug [port]', 'the functions are invoked from local environment enabling debugging options on provided port.' +
|
|
43
43
|
`(default: ${constants_1.DEFAULT.serve_port.debug.basicio})`)
|
|
44
|
-
.option('--ignore-scripts', 'ignore the pre and post
|
|
45
|
-
.option('--watch', 'watch for file and directory changes and enable hot reload'
|
|
44
|
+
.option('--ignore-scripts', 'ignore the pre and post lifecycle scripts')
|
|
45
|
+
.option('--watch', 'watch for file and directory changes and enable hot reload' +
|
|
46
|
+
'\n' +
|
|
47
|
+
'(deprecated: The watch mode will be enabled by default. To disable watch mode use the --no-watch option)')
|
|
48
|
+
.option('--no-watch', 'disable watching the files for changes')
|
|
46
49
|
.needs('auth', [constants_1.SCOPE.functions, constants_1.SCOPE.functions_execution])
|
|
47
50
|
.needs('config')
|
|
48
51
|
.needs('rc')
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -27,14 +46,17 @@ const prompt_1 = __importDefault(require("../../prompt"));
|
|
|
27
46
|
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
28
47
|
const constants_1 = require("../../util_modules/constants");
|
|
29
48
|
const env_1 = require("../../util_modules/env");
|
|
30
|
-
const
|
|
49
|
+
const ASYNC = __importStar(require("../../util_modules/fs/lib/async.js"));
|
|
50
|
+
const SYNC = __importStar(require("../../util_modules/fs/lib/sync.js"));
|
|
51
|
+
const utils_js_1 = require("../../util_modules/fs/utils.js");
|
|
31
52
|
const js_1 = require("../../util_modules/js");
|
|
32
53
|
const logger_1 = require("../../util_modules/logger");
|
|
33
54
|
const option_1 = require("../../util_modules/option");
|
|
34
55
|
const shell_1 = require("../../util_modules/shell");
|
|
56
|
+
const server_js_1 = require("../../util_modules/server.js");
|
|
35
57
|
const getZipAndTemplate = (filePath, stagedDeploy) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
58
|
const zipFile = filePath
|
|
37
|
-
? yield
|
|
59
|
+
? yield ASYNC.readFile(utils_js_1.untildify(filePath), 'buffer')
|
|
38
60
|
: (stagedDeploy === null || stagedDeploy === void 0 ? void 0 : stagedDeploy.id)
|
|
39
61
|
? yield new iac_1.default().deployDownload(stagedDeploy.id)
|
|
40
62
|
: undefined;
|
|
@@ -65,18 +87,21 @@ const ensureUserAction = (deployRes) => __awaiter(void 0, void 0, void 0, functi
|
|
|
65
87
|
resp.end();
|
|
66
88
|
return;
|
|
67
89
|
}
|
|
68
|
-
const htmlFile = yield
|
|
90
|
+
const htmlFile = yield ASYNC.readFile(path_1.join(__dirname, '../../../templates/iacSuccess.html'));
|
|
69
91
|
resp.setHeader('Content-Type', 'text/html');
|
|
70
92
|
resp.writeHead(200);
|
|
71
|
-
resp.end(htmlFile, () => {
|
|
93
|
+
resp.end(htmlFile, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
94
|
req.socket.destroy();
|
|
73
|
-
|
|
74
|
-
|
|
95
|
+
yield destroyer.destroy().catch((err) => logger_1.debug(err));
|
|
96
|
+
res();
|
|
97
|
+
}));
|
|
75
98
|
}
|
|
76
99
|
catch (e) {
|
|
77
|
-
|
|
100
|
+
yield destroyer.destroy().catch((err) => logger_1.debug(err));
|
|
101
|
+
res(e);
|
|
78
102
|
}
|
|
79
103
|
}));
|
|
104
|
+
const destroyer = new server_js_1.ConnectionDestroyer(server);
|
|
80
105
|
server.listen(callbackPort, () => {
|
|
81
106
|
const urlString = accessUrl.toString();
|
|
82
107
|
logger_1.info();
|
|
@@ -111,7 +136,9 @@ const ensureUserAction = (deployRes) => __awaiter(void 0, void 0, void 0, functi
|
|
|
111
136
|
yield shell_1.spawn('catalyst', ['iac:status', 'import', ...optsArr], {
|
|
112
137
|
shell: true,
|
|
113
138
|
stdio: 'inherit'
|
|
114
|
-
})
|
|
139
|
+
})
|
|
140
|
+
.ASYNC()
|
|
141
|
+
.catch((err) => logger_1.debug(err));
|
|
115
142
|
(exitListeners || []).forEach((listner) => {
|
|
116
143
|
process.addListener('exit', listner);
|
|
117
144
|
});
|
|
@@ -150,7 +177,7 @@ const iacImport = (filePath, projectName) => __awaiter(void 0, void 0, void 0, f
|
|
|
150
177
|
exclude: ['**/!(*.zip)', '**/.*'],
|
|
151
178
|
validate: ({ value }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
152
179
|
if (value && value.endsWith('.zip')) {
|
|
153
|
-
return (yield
|
|
180
|
+
return (yield ASYNC.fileExists(value)) ? true : 'File does not exists!';
|
|
154
181
|
}
|
|
155
182
|
return 'Invalid zip file!';
|
|
156
183
|
})
|
|
@@ -163,7 +190,7 @@ const iacImport = (filePath, projectName) => __awaiter(void 0, void 0, void 0, f
|
|
|
163
190
|
const [zipArchive, templateFile] = yield getZipAndTemplate(filePath);
|
|
164
191
|
const parsedJSON = js_1.JS.parseJSON(templateFile);
|
|
165
192
|
const format = parsedJSON ? constants_1.IAC.template_format.json : constants_1.IAC.template_format.yml;
|
|
166
|
-
const deployRes = yield new iac_1.default().deploy(projectName, format,
|
|
193
|
+
const deployRes = yield new iac_1.default().deploy(projectName, format, SYNC.getReadStream(filePath));
|
|
167
194
|
yield ensureUserAction(deployRes);
|
|
168
195
|
return [zipArchive, templateFile, deployRes];
|
|
169
196
|
});
|
package/lib/commands/init.js
CHANGED
|
@@ -90,7 +90,7 @@ exports.default = new command_1.default('init [feature]')
|
|
|
90
90
|
ansi_colors_1.bold(runtime_store_1.default.get('project.root')) +
|
|
91
91
|
'\n' +
|
|
92
92
|
warningText);
|
|
93
|
-
const windownConfirmation = env_1.isWindows
|
|
93
|
+
const windownConfirmation = env_1.isWindows
|
|
94
94
|
? yield prompt_1.default.ask(prompt_1.default.question('confirmation', 'Are you ready to proceed?', {
|
|
95
95
|
type: 'confirm'
|
|
96
96
|
}))
|
package/lib/commands/pull.js
CHANGED
|
@@ -72,7 +72,7 @@ exports.default = new command_1.default('pull [feature]')
|
|
|
72
72
|
ansi_colors_1.bold(runtime_store_1.default.get('project.root')) +
|
|
73
73
|
'\n' +
|
|
74
74
|
warningText);
|
|
75
|
-
const ans = env_1.isWindows
|
|
75
|
+
const ans = env_1.isWindows
|
|
76
76
|
? yield prompt_1.default.ask(prompt_1.default.question('confirmation', 'Are you ready to proceed?', {
|
|
77
77
|
type: 'confirm'
|
|
78
78
|
}))
|
package/lib/commands/serve.js
CHANGED
|
@@ -41,9 +41,10 @@ exports.default = new command_1.default('serve')
|
|
|
41
41
|
.option('--proxy <url>', 'proxy url to proxy any unknown request to the given url ' +
|
|
42
42
|
'(e.g. "http://localhost:8080")')
|
|
43
43
|
.option('--only <targets>', 'only serve specified, comma-separated targets (e.g. "client,functions:f1")')
|
|
44
|
-
.option('--watch', '
|
|
44
|
+
.option('--no-watch', 'disable watching the files for changes')
|
|
45
45
|
.option('--except <targets>', 'serve all targets except specified (e.g. "client")')
|
|
46
46
|
.option('--ignore-scripts', 'ignore the pre and post lifescycle scripts')
|
|
47
|
+
.option('--no-open', 'disable opening the client automatically when served')
|
|
47
48
|
.needs('auth', [constants_1.SCOPE.functions, constants_1.SCOPE.functions_execution, constants_1.SCOPE.webapp])
|
|
48
49
|
.needs('config')
|
|
49
50
|
.needs('rc')
|
package/lib/endpoints/lib/sdk.js
CHANGED
|
@@ -31,10 +31,10 @@ class SDK {
|
|
|
31
31
|
if (targetSDK === undefined || targetUrl === undefined) {
|
|
32
32
|
throw new error_1.default('SDK target missing', { exit: 2 });
|
|
33
33
|
}
|
|
34
|
-
const res = yield new api_1.default(this.opts).get(`/
|
|
34
|
+
const res = yield new api_1.default(this.opts).get(`/downloads/sdk/java/${targetUrl}_latest.zip`, {
|
|
35
35
|
json: false,
|
|
36
36
|
encoding: null,
|
|
37
|
-
origin: constants_1.ORIGIN.
|
|
37
|
+
origin: constants_1.ORIGIN.catalystStatic,
|
|
38
38
|
log: {
|
|
39
39
|
progress: {
|
|
40
40
|
title: targetSDK.replace(new RegExp('_', 'g'), '-')
|
package/lib/error.js
CHANGED
|
@@ -8,7 +8,7 @@ const runtime_store_1 = __importDefault(require("./runtime-store"));
|
|
|
8
8
|
const default_1 = __importDefault(require("./util_modules/constants/lib/default"));
|
|
9
9
|
class CatalystError extends Error {
|
|
10
10
|
constructor(message, options = {}) {
|
|
11
|
-
var _a;
|
|
11
|
+
var _a, _b;
|
|
12
12
|
super(message);
|
|
13
13
|
this.name = default_1.default.catalystError;
|
|
14
14
|
this.status = options.status || 500;
|
|
@@ -24,15 +24,15 @@ class CatalystError extends Error {
|
|
|
24
24
|
this.fileName =
|
|
25
25
|
options.fileName === undefined && stackArr[1] !== undefined
|
|
26
26
|
? stackArr[1].replace(/\.[^.]+$/, '').replace(/^[^(]+\(/, '')
|
|
27
|
-
: options.fileName;
|
|
28
|
-
runtime_store_1.default.set(
|
|
27
|
+
: (_b = options.fileName) === null || _b === void 0 ? void 0 : _b.replace(/\.[^.]+$/, '');
|
|
28
|
+
runtime_store_1.default.set(`[log]["${this.fileName}"]`, runtime_store_1.default.get(`[log]["${this.fileName}"]`, []).concat(this));
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
catch (e) {
|
|
32
32
|
runtime_store_1.default.set('log.faultyError', runtime_store_1.default.get('log.faultyError', []).concat(this));
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
static getErrorInstance(unknownError, { message, skipHelp } = {}) {
|
|
35
|
+
static getErrorInstance(unknownError, { message, skipHelp, fileName } = {}) {
|
|
36
36
|
if (unknownError instanceof CatalystError) {
|
|
37
37
|
if (message) {
|
|
38
38
|
unknownError.message = message;
|
|
@@ -42,21 +42,24 @@ class CatalystError extends Error {
|
|
|
42
42
|
if (unknownError instanceof Error) {
|
|
43
43
|
return new CatalystError(message || unknownError.message, {
|
|
44
44
|
original: unknownError,
|
|
45
|
-
skipHelp: skipHelp === undefined ? true : skipHelp
|
|
45
|
+
skipHelp: skipHelp === undefined ? true : skipHelp,
|
|
46
|
+
fileName
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
const newError = new CatalystError(message || 'Malformed error', {
|
|
49
50
|
original: util_1.inspect(unknownError),
|
|
50
51
|
skipHelp: skipHelp === undefined ? true : skipHelp
|
|
51
52
|
});
|
|
52
|
-
if ('
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
if (typeof unknownError === 'object') {
|
|
54
|
+
if ('message' in unknownError) {
|
|
55
|
+
newError.message = unknownError.message;
|
|
56
|
+
}
|
|
57
|
+
if ('stack' in unknownError) {
|
|
58
|
+
newError.stack = unknownError.stack;
|
|
59
|
+
}
|
|
60
|
+
if ('name' in unknownError) {
|
|
61
|
+
newError.name = unknownError.name;
|
|
62
|
+
}
|
|
60
63
|
}
|
|
61
64
|
return newError;
|
|
62
65
|
}
|
package/lib/errorOut.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const logger_1 = require("./util_modules/logger");
|
|
7
7
|
const error_1 = __importDefault(require("./error"));
|
|
8
8
|
const constants_1 = require("./util_modules/constants");
|
|
9
|
-
const
|
|
9
|
+
const context_help_1 = __importDefault(require("./util_modules/context-help"));
|
|
10
10
|
exports.default = (error, status) => {
|
|
11
11
|
if (typeof error === 'string') {
|
|
12
12
|
error = new error_1.default('An unexpected error has occurred.', {
|
|
@@ -23,7 +23,7 @@ exports.default = (error, status) => {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
try {
|
|
26
|
-
const exitCode =
|
|
26
|
+
const exitCode = context_help_1.default();
|
|
27
27
|
process.exitCode = typeof exitCode === 'number' ? exitCode : 2;
|
|
28
28
|
}
|
|
29
29
|
catch (err) {
|
|
@@ -158,8 +158,8 @@ function refineTargets(rawTargets, mapRemoteFn = true) {
|
|
|
158
158
|
failure_reason: 'there is no valid ' + constants_1.FILENAME.catalyst_config + ' file present'
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
|
-
const validatePlugin = yield plugin_loader_1.default('functions', 'validate', fnPath);
|
|
162
|
-
if (validatePlugin
|
|
161
|
+
const validatePlugin = yield plugin_loader_1.default('functions', 'validate', fnPath).catch((err) => logger_1.debug(err));
|
|
162
|
+
if (typeof validatePlugin === 'function') {
|
|
163
163
|
try {
|
|
164
164
|
yield validatePlugin(option_1.getCurrentCommand(), fnPath, runtime_store_1.default, catalystJson);
|
|
165
165
|
}
|
|
@@ -249,8 +249,8 @@ function pack(target) {
|
|
|
249
249
|
return __awaiter(this, void 0, void 0, function* () {
|
|
250
250
|
try {
|
|
251
251
|
let source = target.source;
|
|
252
|
-
const buildPlugin = yield plugin_loader_1.default('functions', 'build', source);
|
|
253
|
-
if (buildPlugin
|
|
252
|
+
const buildPlugin = yield plugin_loader_1.default('functions', 'build', source).catch((err) => logger_1.debug(err));
|
|
253
|
+
if (typeof buildPlugin === 'function') {
|
|
254
254
|
try {
|
|
255
255
|
logger_1.message(`Plugin : "${runtime_store_1.default.get(`context.functions.plugins.build.${source}`)}" is used for functions deploy`);
|
|
256
256
|
const outputDir = yield buildPlugin(source, runtime_store_1.default);
|
package/lib/fn-utils/lib/java.js
CHANGED
|
@@ -82,7 +82,7 @@ const keyWords = [
|
|
|
82
82
|
'volatile',
|
|
83
83
|
'while'
|
|
84
84
|
];
|
|
85
|
-
exports.classPathSep = env_1.isWindows
|
|
85
|
+
exports.classPathSep = env_1.isWindows ? ';' : ':';
|
|
86
86
|
function containsKeyWord(name) {
|
|
87
87
|
return keyWords.some((keyWord) => {
|
|
88
88
|
if (name === keyWord ||
|
|
@@ -192,16 +192,17 @@ function normaliseClasspath(pth, libFolder) {
|
|
|
192
192
|
}
|
|
193
193
|
exports.normaliseClasspath = normaliseClasspath;
|
|
194
194
|
function compileTarget(target) {
|
|
195
|
+
var _a;
|
|
195
196
|
return __awaiter(this, void 0, void 0, function* () {
|
|
196
197
|
const targetSource = target.source;
|
|
197
198
|
const outputFolder = path_1.join(targetSource, '.output');
|
|
198
199
|
const integ = target.integ_config;
|
|
199
|
-
const entries = [path_1.join(targetSource, target.index + '.java')];
|
|
200
|
+
const entries = [path_1.join(targetSource, ((_a = target.index) === null || _a === void 0 ? void 0 : _a.replace(/\./g, path_1.sep)) + '.java')];
|
|
200
201
|
if (integ && integ.length > 0) {
|
|
201
202
|
integ.forEach((integConf) => {
|
|
202
203
|
const handlers = integConf.handlers;
|
|
203
204
|
Object.keys(handlers).forEach((handler) => {
|
|
204
|
-
entries.push(path_1.join(targetSource, handlers[handler].replace(
|
|
205
|
+
entries.push(path_1.join(targetSource, handlers[handler].replace(/\./g, path_1.sep) + '.java'));
|
|
205
206
|
});
|
|
206
207
|
});
|
|
207
208
|
}
|
|
@@ -338,6 +339,7 @@ function checkJavaCompatibility() {
|
|
|
338
339
|
});
|
|
339
340
|
}
|
|
340
341
|
function validate(targets, idx) {
|
|
342
|
+
var _a;
|
|
341
343
|
return __awaiter(this, void 0, void 0, function* () {
|
|
342
344
|
if (targets.length < idx + 1) {
|
|
343
345
|
return;
|
|
@@ -348,7 +350,7 @@ function validate(targets, idx) {
|
|
|
348
350
|
const classpath = path_1.join(targetSource, constants_1.FILENAME.functions.java_classpath);
|
|
349
351
|
const projectPath = path_1.join(targetSource, constants_1.FILENAME.functions.java_project);
|
|
350
352
|
const libFolder = path_1.join(targetSource, 'lib');
|
|
351
|
-
const entry = path_1.join(targetSource, currentTarget.index + '.java');
|
|
353
|
+
const entry = path_1.join(targetSource, ((_a = currentTarget.index) === null || _a === void 0 ? void 0 : _a.replace(/\./g, path_1.sep)) + '.java');
|
|
352
354
|
const entryFileExists = yield fs_1.ASYNC.fileExists(entry);
|
|
353
355
|
const classPathExists = yield fs_1.ASYNC.fileExists(classpath);
|
|
354
356
|
if (!entryFileExists) {
|