zcatalyst-cli 1.10.0 → 1.12.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/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/archiver.js +3 -3
- package/lib/client-utils.js +8 -6
- package/lib/command_needs/auth.js +2 -2
- package/lib/commands/client/delete.js +1 -0
- package/lib/commands/event/generate/index.js +4 -13
- package/lib/commands/functions/shell.js +5 -2
- package/lib/commands/iac/import.js +29 -6
- 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 +6 -5
- package/lib/fn-utils/lib/java.js +1 -1
- 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/languages/node.js +3 -1
- package/lib/init/features/index.js +10 -3
- package/lib/init/features/project.js +2 -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/serve/index.js +6 -1
- package/lib/serve/server/index.js +52 -8
- package/lib/serve/server/lib/master.js +24 -12
- package/lib/serve/server/lib/web_client/index.js +30 -0
- package/lib/serve/server/lib/web_client/server.js +171 -0
- 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/shell.js +10 -6
- package/lib/winston.js +1 -1
- package/package.json +7 -4
- 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 +96 -111
- 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/handlers/bot-handler.js +2 -3
- package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +0 -1
- 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/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
package/lib/archiver.js
CHANGED
|
@@ -50,12 +50,12 @@ class Archiver {
|
|
|
50
50
|
this.jszip = jszip_1.loadAsync(content, { createFolders });
|
|
51
51
|
return this;
|
|
52
52
|
}
|
|
53
|
-
_writeFolder(folder, to, recursive = false, ignoreInitial =
|
|
53
|
+
_writeFolder(folder, to, recursive = false, ignoreInitial = false) {
|
|
54
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
55
|
return this._writeAllFile(folder.filter((_relPath, file) => !file.dir), to, recursive, ignoreInitial);
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
_writeAllFile(files, to, recursive = false, ignoreInitial =
|
|
58
|
+
_writeAllFile(files, to, recursive = false, ignoreInitial = false) {
|
|
59
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
60
|
while (files.length > 0) {
|
|
61
61
|
const limit = files.length < Archiver.maxWriteLimit ? files.length : Archiver.maxWriteLimit;
|
|
@@ -106,7 +106,7 @@ class Archiver {
|
|
|
106
106
|
return fileObjArr[0].async('string');
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
-
extract(to, from = '/', { isFolder = true, recursive = false, ignoreInitial =
|
|
109
|
+
extract(to, from = '/', { isFolder = true, recursive = false, ignoreInitial = false } = {}) {
|
|
110
110
|
const extractPromise = this.jszip.then((zip) => __awaiter(this, void 0, void 0, function* () {
|
|
111
111
|
if (isFolder) {
|
|
112
112
|
let folder = null;
|
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) {
|
|
@@ -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];
|
|
@@ -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,16 @@ 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");
|
|
35
56
|
const getZipAndTemplate = (filePath, stagedDeploy) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
57
|
const zipFile = filePath
|
|
37
|
-
? yield
|
|
58
|
+
? yield ASYNC.readFile(utils_js_1.untildify(filePath), 'buffer')
|
|
38
59
|
: (stagedDeploy === null || stagedDeploy === void 0 ? void 0 : stagedDeploy.id)
|
|
39
60
|
? yield new iac_1.default().deployDownload(stagedDeploy.id)
|
|
40
61
|
: undefined;
|
|
@@ -65,7 +86,7 @@ const ensureUserAction = (deployRes) => __awaiter(void 0, void 0, void 0, functi
|
|
|
65
86
|
resp.end();
|
|
66
87
|
return;
|
|
67
88
|
}
|
|
68
|
-
const htmlFile = yield
|
|
89
|
+
const htmlFile = yield ASYNC.readFile(path_1.join(__dirname, '../../../templates/iacSuccess.html'));
|
|
69
90
|
resp.setHeader('Content-Type', 'text/html');
|
|
70
91
|
resp.writeHead(200);
|
|
71
92
|
resp.end(htmlFile, () => {
|
|
@@ -111,7 +132,9 @@ const ensureUserAction = (deployRes) => __awaiter(void 0, void 0, void 0, functi
|
|
|
111
132
|
yield shell_1.spawn('catalyst', ['iac:status', 'import', ...optsArr], {
|
|
112
133
|
shell: true,
|
|
113
134
|
stdio: 'inherit'
|
|
114
|
-
})
|
|
135
|
+
})
|
|
136
|
+
.ASYNC()
|
|
137
|
+
.catch((err) => logger_1.debug(err));
|
|
115
138
|
(exitListeners || []).forEach((listner) => {
|
|
116
139
|
process.addListener('exit', listner);
|
|
117
140
|
});
|
|
@@ -150,7 +173,7 @@ const iacImport = (filePath, projectName) => __awaiter(void 0, void 0, void 0, f
|
|
|
150
173
|
exclude: ['**/!(*.zip)', '**/.*'],
|
|
151
174
|
validate: ({ value }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
152
175
|
if (value && value.endsWith('.zip')) {
|
|
153
|
-
return (yield
|
|
176
|
+
return (yield ASYNC.fileExists(value)) ? true : 'File does not exists!';
|
|
154
177
|
}
|
|
155
178
|
return 'Invalid zip file!';
|
|
156
179
|
})
|
|
@@ -163,7 +186,7 @@ const iacImport = (filePath, projectName) => __awaiter(void 0, void 0, void 0, f
|
|
|
163
186
|
const [zipArchive, templateFile] = yield getZipAndTemplate(filePath);
|
|
164
187
|
const parsedJSON = js_1.JS.parseJSON(templateFile);
|
|
165
188
|
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,
|
|
189
|
+
const deployRes = yield new iac_1.default().deploy(projectName, format, SYNC.getReadStream(filePath));
|
|
167
190
|
yield ensureUserAction(deployRes);
|
|
168
191
|
return [zipArchive, templateFile, deployRes];
|
|
169
192
|
});
|
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) {
|
|
@@ -144,6 +144,7 @@ function refineTargets(rawTargets, mapRemoteFn = true) {
|
|
|
144
144
|
}, remoteFnIdMap);
|
|
145
145
|
}
|
|
146
146
|
return Promise.all(rawTargets.map((fnPath) => __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
fnPath = project_1.resolveProjectPath(fnPath);
|
|
147
148
|
const catalystJsonPth = path_1.join(fnPath, constants_1.FILENAME.catalyst_config);
|
|
148
149
|
const catalystJson = yield fs_1.ASYNC.readJSONFile(catalystJsonPth, {
|
|
149
150
|
checkpath: true,
|
|
@@ -157,8 +158,8 @@ function refineTargets(rawTargets, mapRemoteFn = true) {
|
|
|
157
158
|
failure_reason: 'there is no valid ' + constants_1.FILENAME.catalyst_config + ' file present'
|
|
158
159
|
};
|
|
159
160
|
}
|
|
160
|
-
const validatePlugin = yield plugin_loader_1.default('functions', 'validate', fnPath);
|
|
161
|
-
if (validatePlugin
|
|
161
|
+
const validatePlugin = yield plugin_loader_1.default('functions', 'validate', fnPath).catch((err) => logger_1.debug(err));
|
|
162
|
+
if (typeof validatePlugin === 'function') {
|
|
162
163
|
try {
|
|
163
164
|
yield validatePlugin(option_1.getCurrentCommand(), fnPath, runtime_store_1.default, catalystJson);
|
|
164
165
|
}
|
|
@@ -248,8 +249,8 @@ function pack(target) {
|
|
|
248
249
|
return __awaiter(this, void 0, void 0, function* () {
|
|
249
250
|
try {
|
|
250
251
|
let source = target.source;
|
|
251
|
-
const buildPlugin = yield plugin_loader_1.default('functions', 'build', source);
|
|
252
|
-
if (buildPlugin
|
|
252
|
+
const buildPlugin = yield plugin_loader_1.default('functions', 'build', source).catch((err) => logger_1.debug(err));
|
|
253
|
+
if (typeof buildPlugin === 'function') {
|
|
253
254
|
try {
|
|
254
255
|
logger_1.message(`Plugin : "${runtime_store_1.default.get(`context.functions.plugins.build.${source}`)}" is used for functions deploy`);
|
|
255
256
|
const outputDir = yield buildPlugin(source, runtime_store_1.default);
|
|
@@ -416,7 +417,7 @@ function getSDK(fnType, dest, stack, options = {}) {
|
|
|
416
417
|
}
|
|
417
418
|
yield new archiver_1.default()
|
|
418
419
|
.load(sdkZip)
|
|
419
|
-
.extract(dest, new RegExp(`catalyst-${stack}`))
|
|
420
|
+
.extract(dest, new RegExp(`catalyst-${stack}`), { ignoreInitial: true })
|
|
420
421
|
.finalize();
|
|
421
422
|
});
|
|
422
423
|
}
|
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 ||
|
package/lib/fn-utils/lib/node.js
CHANGED
|
@@ -16,10 +16,10 @@ exports.validate = void 0;
|
|
|
16
16
|
const ansi_colors_1 = require("ansi-colors");
|
|
17
17
|
const path_1 = require("path");
|
|
18
18
|
const error_1 = __importDefault(require("../../error"));
|
|
19
|
+
const npm_install_1 = __importDefault(require("../../init/dependencies/npm-install"));
|
|
19
20
|
const constants_1 = require("../../util_modules/constants");
|
|
20
21
|
const fs_1 = require("../../util_modules/fs");
|
|
21
22
|
const js_1 = require("../../util_modules/js");
|
|
22
|
-
const shell_1 = require("../../util_modules/shell");
|
|
23
23
|
function validate(targets, idx) {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
if (targets.length < idx + 1) {
|
|
@@ -50,7 +50,7 @@ function validate(targets, idx) {
|
|
|
50
50
|
}
|
|
51
51
|
const nodeModuleExists = yield fs_1.ASYNC.dirExists(path_1.join(currentTarget.source, constants_1.FILENAME.node_modules));
|
|
52
52
|
if (!nodeModuleExists) {
|
|
53
|
-
yield
|
|
53
|
+
yield npm_install_1.default(currentTarget.source, true);
|
|
54
54
|
}
|
|
55
55
|
currentTarget.valid = true;
|
|
56
56
|
return validate(targets, ++idx);
|
|
@@ -12,23 +12,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const error_1 = __importDefault(require("../../error"));
|
|
15
16
|
const prompt_1 = __importDefault(require("../../prompt"));
|
|
16
|
-
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
17
|
-
const constants_1 = require("../../util_modules/constants");
|
|
18
17
|
const shell_1 = require("../../util_modules/shell");
|
|
19
|
-
exports.default = (pth) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
exports.default = (pth, skipPrompt = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
19
|
const ans = yield prompt_1.default.ask(prompt_1.default.question('NPMinstall', 'Do you wish to install all dependencies now ? ', {
|
|
21
20
|
type: 'confirm',
|
|
22
21
|
defaultAns: true,
|
|
23
|
-
when: () =>
|
|
24
|
-
if (runtime_store_1.default.get('context.functions.type') === constants_1.FN_TYPE.integration) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
22
|
+
when: () => !skipPrompt
|
|
29
23
|
}));
|
|
30
24
|
if (ans.NPMinstall === undefined || ans.NPMinstall) {
|
|
31
|
-
return shell_1.spawn('npm', ['install'], { cwd: pth })
|
|
25
|
+
return shell_1.spawn('npm', ['install'], { cwd: pth })
|
|
26
|
+
.ASYNC()
|
|
27
|
+
.catch((err) => {
|
|
28
|
+
throw error_1.default.getErrorInstance(err, {
|
|
29
|
+
message: 'Failure when executing npm install.'
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
32
|
}
|
|
33
33
|
return;
|
|
34
34
|
});
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
const index_js_1 = __importDefault(require("../../../prompt/index.js"));
|
|
35
|
+
const index_js_2 = require("../../../util_modules/constants/index.js");
|
|
36
|
+
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
const clientInitAnswer = yield index_js_1.default.ask(index_js_1.default.question('clientFlavour', 'Choose the type of client to initialise: ', {
|
|
38
|
+
type: 'list',
|
|
39
|
+
choices: index_js_2.PLUGIN.client.map((plugin) => {
|
|
40
|
+
return index_js_1.default.choice(plugin + ' web app', {
|
|
41
|
+
value: plugin.toLowerCase(),
|
|
42
|
+
short: plugin.toUpperCase()
|
|
43
|
+
});
|
|
44
|
+
})
|
|
45
|
+
}));
|
|
46
|
+
return (yield Promise.resolve().then(() => __importStar(require('./initializers/' + clientInitAnswer.clientFlavour)))).default();
|
|
47
|
+
});
|