zcatalyst-cli 1.9.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -29
- package/docs/client-utils.toml +5 -0
- package/docs/command_needs/auth.toml +5 -0
- package/docs/commands/iac/export.toml +4 -0
- package/docs/commands/iac/import.toml +4 -0
- package/docs/commands/iac/status.toml +4 -0
- package/docs/commands/project/use.toml +6 -0
- package/docs/iac/status/bundle.toml +4 -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/api-timer.js +81 -0
- package/lib/apig-utils.js +17 -14
- package/lib/archiver.js +83 -45
- package/lib/authentication/login.js +4 -2
- package/lib/bin/catalyst.js +0 -1
- package/lib/client-utils.js +55 -26
- package/lib/client.js +0 -3
- package/lib/command_needs/auth.js +12 -3
- package/lib/command_needs/rc.js +12 -7
- package/lib/commands/apig/disable.js +1 -1
- package/lib/commands/apig/enable.js +1 -1
- package/lib/commands/apig/status.js +7 -5
- package/lib/commands/client/delete.js +4 -5
- package/lib/commands/client/setup.js +1 -1
- package/lib/commands/deploy.js +4 -2
- package/lib/commands/ds/export.js +4 -2
- package/lib/commands/ds/import.js +4 -2
- package/lib/commands/ds/status.js +146 -150
- package/lib/commands/event/generate/index.js +5 -14
- package/lib/commands/event/generate/integ.js +1 -1
- package/lib/commands/functions/add.js +1 -1
- package/lib/commands/functions/config.js +1 -1
- package/lib/commands/functions/delete.js +1 -1
- package/lib/commands/functions/setup.js +1 -1
- package/lib/commands/functions/shell.js +1 -1
- package/lib/commands/help.js +0 -22
- package/lib/commands/iac/export.js +85 -0
- package/lib/commands/iac/import.js +189 -0
- package/lib/commands/iac/pack.js +129 -0
- package/lib/commands/iac/status.js +63 -0
- package/lib/commands/index.js +4 -0
- package/lib/commands/init.js +35 -28
- package/lib/commands/login.js +1 -1
- package/lib/commands/logout.js +1 -1
- package/lib/commands/project/list.js +11 -7
- package/lib/commands/project/reset.js +1 -1
- package/lib/commands/project/use.js +42 -25
- package/lib/commands/pull.js +2 -2
- package/lib/commands/run.js +1 -1
- package/lib/commands/serve.js +3 -2
- package/lib/commands/token/generate.js +1 -1
- package/lib/commands/token/list.js +1 -1
- package/lib/commands/token/revoke.js +1 -1
- package/lib/commands/whoami.js +1 -1
- package/lib/deploy/features/functions/index.js +2 -1
- package/lib/deploy/index.js +3 -1
- package/lib/endpoints/lib/iac.js +134 -0
- package/lib/error.js +33 -3
- package/lib/errorOut.js +4 -3
- package/lib/fn-utils/lib/common.js +37 -16
- package/lib/fn-utils/lib/java.js +7 -9
- package/lib/fn-utils/lib/node.js +7 -1
- package/lib/iac/status/bundle.js +82 -0
- package/lib/iac/status/deploy.js +74 -0
- package/lib/iac/status/util/index.js +26 -0
- package/lib/index.js +13 -19
- package/lib/init/dependencies/npm-install.js +2 -9
- package/lib/init/features/client/index.js +47 -0
- package/lib/init/features/client/initializers/angular.js +88 -0
- package/lib/init/features/client/initializers/basic.js +27 -0
- package/lib/init/features/client/initializers/lyte.js +44 -0
- package/lib/init/features/client/initializers/react.js +53 -0
- package/lib/init/features/functions/languages/java.js +2 -5
- package/lib/init/features/functions/languages/node.js +5 -6
- package/lib/init/features/index.js +18 -6
- package/lib/init/features/project.js +72 -34
- package/lib/init/util/client.js +12 -0
- package/lib/init/util/functions.js +20 -0
- package/lib/init/util/project.js +35 -0
- package/lib/internal/api.js +6 -9
- package/lib/internal/command.js +6 -3
- package/lib/internal/config.js +7 -4
- package/lib/migration/index.js +10 -6
- package/lib/option-filter.js +4 -1
- package/lib/optional-import.js +11 -25
- package/lib/plugin-loader.js +8 -2
- package/lib/port-resolver.js +20 -16
- package/lib/prompt/index.js +92 -0
- package/lib/prompt/types/file-path.js +95 -0
- package/lib/pull/features/client.js +1 -1
- package/lib/pull/features/functions/index.js +5 -7
- package/lib/pull/index.js +4 -1
- package/lib/serve/features/index.js +3 -1
- package/lib/serve/index.js +6 -1
- package/lib/serve/server/index.js +74 -29
- package/lib/serve/server/lib/master.js +28 -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/serve/server/lib/web_client/utils.js +10 -0
- package/lib/shell/dependencies/http-functions.js +1 -1
- package/lib/shell/index.js +3 -1
- package/lib/track.js +3 -1
- package/lib/util_modules/char.js +1 -1
- package/lib/util_modules/config/lib/apig.js +2 -1
- package/lib/util_modules/constants/index.js +5 -1
- package/lib/util_modules/constants/lib/file-names.js +2 -1
- package/lib/util_modules/constants/lib/iac.js +8 -0
- package/lib/util_modules/constants/lib/placeholders.js +3 -1
- package/lib/util_modules/constants/lib/plugin.js +28 -0
- package/lib/util_modules/constants/lib/regex.js +2 -1
- package/lib/util_modules/constants/lib/scopes.js +5 -0
- package/lib/util_modules/constants/lib/template.js +11 -1
- package/lib/util_modules/constants/lib/urls.js +8 -0
- package/lib/util_modules/constants/project.js +6 -0
- package/lib/util_modules/{contextHelp.js → context-help.js} +5 -1
- package/lib/util_modules/env.js +14 -16
- package/lib/util_modules/fs/index.js +9 -1
- package/lib/util_modules/fs/lib/async.js +29 -22
- package/lib/util_modules/global-space.js +99 -0
- package/lib/util_modules/js.js +6 -0
- package/lib/util_modules/option.js +5 -1
- package/lib/util_modules/parser/toml.js +5 -1
- package/lib/util_modules/project.js +3 -0
- package/lib/util_modules/shell.js +9 -8
- package/lib/winston.js +1 -1
- package/package.json +11 -5
- package/templates/iacSuccess.html +391 -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/web-socket.txt +21 -0
- package/lib/init/features/client.js +0 -51
- package/lib/prompt.js +0 -49
- package/lib/serve/server/lib/client.js +0 -30
package/README.md
CHANGED
|
@@ -70,36 +70,36 @@ Certain command are project specific and for it to work you must be inside a pro
|
|
|
70
70
|
|
|
71
71
|
Command | Description
|
|
72
72
|
------- | -----------
|
|
73
|
-
**login** |
|
|
74
|
-
**whoami** |
|
|
75
|
-
**token:generate** |
|
|
76
|
-
**token:revoke** | Revoke
|
|
77
|
-
**token:list** | List all the available tokens
|
|
78
|
-
**project:list** | List the Catalyst projects you have access to.
|
|
73
|
+
**login** | Log the CLI in to your Catalyst account. *Requires access to a web browser*.
|
|
74
|
+
**whoami** | Print the email address of the user currently logged in.
|
|
75
|
+
**token:generate** | Generate a token to authenticate accessing the CLI from a remote system.
|
|
76
|
+
**token:revoke** | Revoke a token generated in this CLI.
|
|
77
|
+
**token:list** | List all the available tokens generated in this CLI.
|
|
78
|
+
**project:list** | List all the Catalyst projects you have access to.
|
|
79
79
|
**project:use** | Set an active Catalyst project for your working directory.
|
|
80
|
-
**project:reset** | Clear an active selection
|
|
81
|
-
**init** | Initialize a Catalyst
|
|
82
|
-
**pull** | Pull
|
|
83
|
-
**apig:status** |
|
|
84
|
-
**apig:enable** |
|
|
85
|
-
**apig:disable** | Disable API Gateway
|
|
86
|
-
**ds:import** |
|
|
87
|
-
**ds:export** |
|
|
88
|
-
**ds:status** |
|
|
89
|
-
**client:setup** |
|
|
90
|
-
**client:delete** |
|
|
91
|
-
**functions:setup** |
|
|
92
|
-
**functions:
|
|
93
|
-
**functions:
|
|
94
|
-
**functions:
|
|
95
|
-
**functions:
|
|
96
|
-
**event:generate \| generate:event** | Generate sample payloads from different event sources
|
|
97
|
-
**event:generate:integ** | Generate sample
|
|
98
|
-
**serve** | Serve
|
|
99
|
-
**deploy** | Deploy
|
|
100
|
-
**help** | Display help
|
|
101
|
-
**run-script \| run** | Run a particular command script.
|
|
102
|
-
**logout** | Log the CLI out of your
|
|
80
|
+
**project:reset** | Clear an active project selection and reset to the base project.
|
|
81
|
+
**init** | Initialize a Catalyst project, function, and client resources in the local directory.
|
|
82
|
+
**pull** | Pull resources of your project from the remote console to the local directory.
|
|
83
|
+
**apig:status** | Obtain the current status of API Gateway for your project and the schedule progress.
|
|
84
|
+
**apig:enable** | Enable API Gateway for your project. *In both Console and Local*.
|
|
85
|
+
**apig:disable** | Disable API Gateway for your project. *In both Console and Local*.
|
|
86
|
+
**ds:import** | Bulk write records to a table in the Catalyst Data Store.
|
|
87
|
+
**ds:export** | Bulk read records from a table in the Catalyst Data Store.
|
|
88
|
+
**ds:status** | Display the job status of a Data Store import or export operation.
|
|
89
|
+
**client:setup** | Set up and configure the client directory in your project directory.
|
|
90
|
+
**client:delete** | Delete a version of the client from the remote console or the local directory.
|
|
91
|
+
**functions:setup** | Set up and configure the function directory in your project directory.
|
|
92
|
+
**functions:add** | Add a function of the required stack to the function directory.
|
|
93
|
+
**functions:shell** | Launch a node shell to test emulated functions of any stack or type, other than Advanced I/O functions.
|
|
94
|
+
**functions:config** | Perform advanced configurations such as memory allocation on a function in your project.
|
|
95
|
+
**functions:delete** | Delete a function from the remote console or the local directory.
|
|
96
|
+
**event:generate \| generate:event** | Generate sample payloads from different components or custom event sources to test Event functions.
|
|
97
|
+
**event:generate:integ** | Generate sample payloads for the required integration service to test Integration functions.
|
|
98
|
+
**serve** | Serve Basic I/O and Advanced I/O functions, and the client, to test them locally.
|
|
99
|
+
**deploy** | Deploy the Catalyst project and project resources to the remote console from the local directory.
|
|
100
|
+
**help** | Display the command reference or help for a specific command.
|
|
101
|
+
**run-script \| run** | Run a particular command script defined in *catalyst.json*.
|
|
102
|
+
**logout** | Log the CLI out of your Catalyst account.
|
|
103
103
|
|
|
104
104
|
---
|
|
105
105
|
|
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 = ''
|
|
@@ -2,3 +2,8 @@
|
|
|
2
2
|
context = '''Oops! It looks like you haven't logged in yet'''
|
|
3
3
|
aid = '''Please use the ${arg[0]} command to log in, or provide auth token via ${arg[1]} param'''
|
|
4
4
|
link = 'https://www.zoho.com/catalyst/help/cli-login.html'
|
|
5
|
+
|
|
6
|
+
[AUTH-2]
|
|
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'''
|
|
9
|
+
link = 'https://www.zoho.com/catalyst/help/cli-login.html'
|
|
@@ -7,3 +7,9 @@ link = 'https://www.zoho.com/catalyst/help/catalyst-console.html#Projects'
|
|
|
7
7
|
context = '''The project ${arg[0]} does not exist in the Catalyst remote console.'''
|
|
8
8
|
aid = '''Please specify only the projects from this list : \n${arg[1]}'''
|
|
9
9
|
link = 'https://www.zoho.com/catalyst/help/cli-projects.html#Use'
|
|
10
|
+
|
|
11
|
+
[PROJ-USE-3]
|
|
12
|
+
context = '''The project ${arg[0]} is not live and is possibily still in import phase.'''
|
|
13
|
+
aid = '''Please specify only the projects from this list : \n${arg[1]}'''
|
|
14
|
+
link = 'https://www.zoho.com/catalyst/help/cli-projects.html#Use'
|
|
15
|
+
|
package/lib/api-timer.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const events_1 = __importDefault(require("events"));
|
|
16
|
+
const error_1 = __importDefault(require("./error"));
|
|
17
|
+
class APITimer extends events_1.default {
|
|
18
|
+
constructor(apiFn, frequency, errorTolerance) {
|
|
19
|
+
super();
|
|
20
|
+
this.apiFn = apiFn;
|
|
21
|
+
this.frequency = frequency || 5000;
|
|
22
|
+
this.interval = null;
|
|
23
|
+
this.execCount = 0;
|
|
24
|
+
this.maxErrors = errorTolerance || 10;
|
|
25
|
+
this.errorCount = 0;
|
|
26
|
+
this.ended = false;
|
|
27
|
+
}
|
|
28
|
+
emit(eventName, ...args) {
|
|
29
|
+
if (this.ended || this.listenerCount(eventName) <= 0) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return super.emit(eventName, ...args);
|
|
33
|
+
}
|
|
34
|
+
waitForEnd() {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
return new Promise((res, rej) => {
|
|
37
|
+
this.on('end', (e, data) => {
|
|
38
|
+
if (e) {
|
|
39
|
+
rej(e);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
res(data);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
fire() {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
if (this.ended) {
|
|
50
|
+
this.end();
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const data = yield this.apiFn();
|
|
54
|
+
this.emit('data', data, ++this.execCount);
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
this.emit('error', e, ++this.errorCount);
|
|
58
|
+
const err = error_1.default.getErrorInstance(e);
|
|
59
|
+
if (this.errorCount >= this.maxErrors) {
|
|
60
|
+
this.end(err);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
start() {
|
|
66
|
+
this.fire();
|
|
67
|
+
this.interval = setInterval(this.fire.bind(this), this.frequency);
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
end(e, data) {
|
|
71
|
+
if (this.interval) {
|
|
72
|
+
clearInterval(this.interval);
|
|
73
|
+
this.execCount = 0;
|
|
74
|
+
this.errorCount = 0;
|
|
75
|
+
this.interval = null;
|
|
76
|
+
}
|
|
77
|
+
this.emit('end', e, data);
|
|
78
|
+
this.ended = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.default = APITimer;
|
package/lib/apig-utils.js
CHANGED
|
@@ -25,6 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.apigUtils = void 0;
|
|
27
27
|
const ansi_colors_1 = require("ansi-colors");
|
|
28
|
+
const util_1 = require("util");
|
|
28
29
|
const client_utils_1 = require("./client-utils");
|
|
29
30
|
const error_1 = __importDefault(require("./error"));
|
|
30
31
|
const execute_script_1 = __importDefault(require("./execute-script"));
|
|
@@ -64,14 +65,14 @@ exports.apigUtils = {
|
|
|
64
65
|
yield client_utils_1.clientUtils.validate();
|
|
65
66
|
const homepage = runtime_store_1.default.get('context.client.homepage', 'index.html');
|
|
66
67
|
const loginRedirect = runtime_store_1.default.get('context.client.login_redirect', homepage);
|
|
67
|
-
if (loginRedirect) {
|
|
68
|
+
if (typeof loginRedirect === 'string') {
|
|
68
69
|
redirectPath = loginRedirect.startsWith('/')
|
|
69
70
|
? loginRedirect
|
|
70
71
|
: '/app/' + loginRedirect;
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
catch (e) {
|
|
74
|
-
logger_1.debug(e.message);
|
|
75
|
+
logger_1.debug(error_1.default.getErrorInstance(e).message);
|
|
75
76
|
}
|
|
76
77
|
let redirectIdx = -1;
|
|
77
78
|
const namesArr = [];
|
|
@@ -197,19 +198,21 @@ exports.apigUtils = {
|
|
|
197
198
|
rule.name, new RegExp(regexParts[1]);
|
|
198
199
|
}
|
|
199
200
|
catch (regexError) {
|
|
200
|
-
|
|
201
|
-
rule
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
arg: [
|
|
207
|
-
ansi_colors_1.bold('source_endpoint'),
|
|
208
|
-
ansi_colors_1.bold(rule.name),
|
|
209
|
-
ansi_colors_1.italic(source_endpoint.replace(part, ansi_colors_1.red(part))),
|
|
210
|
-
ansi_colors_1.bold('Error: ') + ansi_colors_1.italic.red(regexError)
|
|
211
|
-
]
|
|
201
|
+
const err = error_1.default.getErrorInstance(regexError, {
|
|
202
|
+
message: 'source_endpoint provided for apig rule "' +
|
|
203
|
+
rule.name +
|
|
204
|
+
'" is not valid',
|
|
205
|
+
skipHelp: false,
|
|
206
|
+
fileName: __filename
|
|
212
207
|
});
|
|
208
|
+
err.errorId = 'APIG-UTILS-9';
|
|
209
|
+
err.arg = [
|
|
210
|
+
ansi_colors_1.bold('source_endpoint'),
|
|
211
|
+
ansi_colors_1.bold(rule.name),
|
|
212
|
+
ansi_colors_1.italic(source_endpoint.replace(part, ansi_colors_1.red(part))),
|
|
213
|
+
ansi_colors_1.bold('Error: ') + ansi_colors_1.italic.red(util_1.inspect(regexError))
|
|
214
|
+
];
|
|
215
|
+
throw err;
|
|
213
216
|
}
|
|
214
217
|
if (regexParts[1].includes('^') || regexParts[1].includes('$')) {
|
|
215
218
|
throw new error_1.default('source_endpoint provided for apig rule "' +
|
package/lib/archiver.js
CHANGED
|
@@ -43,27 +43,38 @@ class Archiver {
|
|
|
43
43
|
this.promiseArr = [];
|
|
44
44
|
}
|
|
45
45
|
load(content, { createFolders = true } = {}) {
|
|
46
|
-
if (Buffer.isBuffer(content)
|
|
47
|
-
this.content = content;
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
46
|
+
if (!Buffer.isBuffer(content) && !js_1.JS.isString(content)) {
|
|
50
47
|
throw new error_1.default('Unable to parse zip content, content should be either a string or buffer', { exit: 2 });
|
|
51
48
|
}
|
|
49
|
+
this.content = content;
|
|
52
50
|
this.jszip = jszip_1.loadAsync(content, { createFolders });
|
|
53
51
|
return this;
|
|
54
52
|
}
|
|
55
|
-
_writeFolder(folder, to) {
|
|
53
|
+
_writeFolder(folder, to, recursive = false, ignoreInitial = false) {
|
|
56
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
return this._writeAllFile(folder.filter((_relPath, file) => !file.dir), to, recursive, ignoreInitial);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
_writeAllFile(files, to, recursive = false, ignoreInitial = false) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
while (files.length > 0) {
|
|
61
|
+
const limit = files.length < Archiver.maxWriteLimit ? files.length : Archiver.maxWriteLimit;
|
|
62
|
+
yield Promise.all(files.splice(0, limit).map((file) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const filePath = path_1.join(to, path_1.dirname(ignoreInitial ? file.name.substr(file.name.indexOf('/') + 1) : file.name));
|
|
64
|
+
yield fs_1.ASYNC.ensureDir(filePath);
|
|
65
|
+
if (file.name.endsWith('.zip') && recursive) {
|
|
66
|
+
const zipContent = yield file.async('nodebuffer');
|
|
67
|
+
return new Archiver()
|
|
68
|
+
.load(zipContent)
|
|
69
|
+
.extract(path_1.join(filePath, path_1.basename(file.name).replace('.zip', '')), '/', {
|
|
70
|
+
recursive,
|
|
71
|
+
ignoreInitial
|
|
72
|
+
})
|
|
73
|
+
.finalize();
|
|
74
|
+
}
|
|
75
|
+
return this._writeFile(file, filePath);
|
|
76
|
+
})));
|
|
77
|
+
}
|
|
67
78
|
});
|
|
68
79
|
}
|
|
69
80
|
_writeFile(file, to) {
|
|
@@ -76,35 +87,51 @@ class Archiver {
|
|
|
76
87
|
});
|
|
77
88
|
});
|
|
78
89
|
}
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
readFile(relPath) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const actualZip = yield this.jszip;
|
|
93
|
+
const fileObjArr = [];
|
|
94
|
+
if (typeof relPath === 'string') {
|
|
95
|
+
const fileObj = actualZip.file(relPath);
|
|
96
|
+
if (fileObj) {
|
|
97
|
+
fileObjArr.push(fileObj);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
fileObjArr.push(...actualZip.file(relPath));
|
|
102
|
+
}
|
|
103
|
+
if (fileObjArr.length === 0) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
return fileObjArr[0].async('string');
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
extract(to, from = '/', { isFolder = true, recursive = false, ignoreInitial = false } = {}) {
|
|
110
|
+
const extractPromise = this.jszip.then((zip) => __awaiter(this, void 0, void 0, function* () {
|
|
81
111
|
if (isFolder) {
|
|
82
|
-
|
|
112
|
+
let folder = null;
|
|
83
113
|
if (typeof from === 'string') {
|
|
84
|
-
|
|
85
|
-
fromFolderObj.push(zip);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
const folder = zip.folder(from);
|
|
89
|
-
if (folder) {
|
|
90
|
-
fromFolderObj.push(folder);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
114
|
+
folder = from === '/' ? zip : zip.folder(from);
|
|
93
115
|
}
|
|
94
116
|
else {
|
|
95
117
|
const folderObjects = zip.folder(from);
|
|
96
|
-
folderObjects.
|
|
97
|
-
|
|
98
|
-
|
|
118
|
+
if (folderObjects.length > 0) {
|
|
119
|
+
folder = zip.folder(folderObjects[0].name);
|
|
120
|
+
if (folderObjects.length > 1) {
|
|
121
|
+
folderObjects.forEach((folderObj) => {
|
|
122
|
+
if (folder !== null && folderObj.name.length > folder.name.length) {
|
|
123
|
+
folder = zip.folder(folderObj.name);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
99
126
|
}
|
|
100
|
-
}
|
|
127
|
+
}
|
|
101
128
|
}
|
|
102
|
-
if (
|
|
129
|
+
if (!folder) {
|
|
103
130
|
throw new error_1.default('Unable to extract zip, FolderObj is null', {
|
|
104
131
|
exit: 2
|
|
105
132
|
});
|
|
106
133
|
}
|
|
107
|
-
yield
|
|
134
|
+
yield this._writeFolder(folder, to, recursive, ignoreInitial);
|
|
108
135
|
return true;
|
|
109
136
|
}
|
|
110
137
|
const fromFileObj = [];
|
|
@@ -115,28 +142,21 @@ class Archiver {
|
|
|
115
142
|
}
|
|
116
143
|
}
|
|
117
144
|
else {
|
|
118
|
-
fromFileObj.
|
|
119
|
-
if (fileObj) {
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
return false;
|
|
123
|
-
}));
|
|
145
|
+
fromFileObj.concat(zip.file(from));
|
|
124
146
|
}
|
|
125
147
|
if (fromFileObj.length === 0) {
|
|
126
148
|
throw new error_1.default('Unable to extract zip, FileObj is null', {
|
|
127
149
|
exit: 2
|
|
128
150
|
});
|
|
129
151
|
}
|
|
130
|
-
|
|
131
|
-
const limit = fromFileObj.length < 20 ? fromFileObj.length : 20;
|
|
132
|
-
yield Promise.all(fromFileObj.splice(0, limit).map((obj) => this._writeFile(obj, to)));
|
|
133
|
-
}
|
|
152
|
+
yield this._writeAllFile(fromFileObj, to, recursive, ignoreInitial);
|
|
134
153
|
return true;
|
|
135
|
-
}))
|
|
154
|
+
}));
|
|
155
|
+
this.promiseArr.push(extractPromise);
|
|
136
156
|
return this;
|
|
137
157
|
}
|
|
138
158
|
getUnixPath(pth) {
|
|
139
|
-
return
|
|
159
|
+
return pth.split(path_1.sep).join('/');
|
|
140
160
|
}
|
|
141
161
|
add(pth, content, { createFolders = true } = {}) {
|
|
142
162
|
this.promiseArr.push(this.jszip.then((zip) => {
|
|
@@ -189,6 +209,23 @@ class Archiver {
|
|
|
189
209
|
});
|
|
190
210
|
yield fs_1.ASYNC.writeFile(tempFilePath, content);
|
|
191
211
|
return fs_1.SYNC.getReadStream(tempFilePath);
|
|
212
|
+
}),
|
|
213
|
+
writeZip: (pth) => __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
const zip = yield this.jszip;
|
|
215
|
+
const content = yield zip.generateAsync({
|
|
216
|
+
type: 'nodebuffer',
|
|
217
|
+
compression: 'DEFLATE',
|
|
218
|
+
compressionOptions: {
|
|
219
|
+
level: 9
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
if (pth.endsWith('.zip')) {
|
|
223
|
+
pth = path_1.join(path_1.dirname(pth), this.name + '.zip');
|
|
224
|
+
}
|
|
225
|
+
if (path_1.parse(pth).ext === '') {
|
|
226
|
+
pth = path_1.join(pth, this.name + '.zip');
|
|
227
|
+
}
|
|
228
|
+
yield fs_1.ASYNC.writeFile(pth, content);
|
|
192
229
|
})
|
|
193
230
|
};
|
|
194
231
|
}
|
|
@@ -199,4 +236,5 @@ class Archiver {
|
|
|
199
236
|
});
|
|
200
237
|
}
|
|
201
238
|
}
|
|
239
|
+
Archiver.maxWriteLimit = 50;
|
|
202
240
|
exports.default = Archiver;
|
|
@@ -287,9 +287,11 @@ class Login {
|
|
|
287
287
|
processReq = false;
|
|
288
288
|
res.writeHead(404);
|
|
289
289
|
res.end();
|
|
290
|
+
return;
|
|
290
291
|
}
|
|
291
292
|
reqCount += 1;
|
|
292
|
-
const queryParamsObj = new url_1.URL(req.url, `http://${req.headers.host}`)
|
|
293
|
+
const queryParamsObj = new url_1.URL(req.url, `http://${req.headers.host}`)
|
|
294
|
+
.searchParams;
|
|
293
295
|
const code = queryParamsObj !== undefined && queryParamsObj.get('code');
|
|
294
296
|
const location = queryParamsObj !== undefined && queryParamsObj.get('location');
|
|
295
297
|
if (processReq && typeof code === 'string') {
|
|
@@ -335,7 +337,7 @@ class Login {
|
|
|
335
337
|
server.close();
|
|
336
338
|
reject(new error_1.default('Server crashed with error.\n', {
|
|
337
339
|
exit: 2,
|
|
338
|
-
original: e
|
|
340
|
+
original: error_1.default.getErrorInstance(e)
|
|
339
341
|
}));
|
|
340
342
|
}
|
|
341
343
|
}));
|
package/lib/bin/catalyst.js
CHANGED
package/lib/client-utils.js
CHANGED
|
@@ -27,9 +27,10 @@ const js_1 = require("./util_modules/js");
|
|
|
27
27
|
const logger_1 = require("./util_modules/logger");
|
|
28
28
|
const option_1 = require("./util_modules/option");
|
|
29
29
|
const project_1 = require("./util_modules/project");
|
|
30
|
+
const prompt_1 = __importDefault(require("./prompt"));
|
|
30
31
|
exports.clientUtils = {
|
|
31
|
-
validate: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
-
const sourceDir = project_1.resolveProjectPath(config_1.clientConfig.source());
|
|
32
|
+
validate: (source) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
const sourceDir = source || project_1.resolveProjectPath(config_1.clientConfig.source());
|
|
33
34
|
const packageJsonFile = path_1.join(sourceDir, constants_1.FILENAME.client.package_json);
|
|
34
35
|
const sourceDirExists = yield fs_1.ASYNC.dirExists(sourceDir);
|
|
35
36
|
if (!sourceDirExists) {
|
|
@@ -71,8 +72,8 @@ exports.clientUtils = {
|
|
|
71
72
|
runtime_store_1.default.set('context.client.source', sourceDir);
|
|
72
73
|
runtime_store_1.default.set('context.client.login_redirect', loginRedirect || homepage);
|
|
73
74
|
runtime_store_1.default.set('context.client.package_json', packageJsonFile);
|
|
74
|
-
const validatePlugin = yield plugin_loader_1.default('client', 'validate');
|
|
75
|
-
if (validatePlugin
|
|
75
|
+
const validatePlugin = yield plugin_loader_1.default('client', 'validate').catch((err) => logger_1.debug(err));
|
|
76
|
+
if (typeof validatePlugin !== 'function') {
|
|
76
77
|
runtime_store_1.default.set('context.client.valid', true);
|
|
77
78
|
return packageJson;
|
|
78
79
|
}
|
|
@@ -80,16 +81,17 @@ exports.clientUtils = {
|
|
|
80
81
|
yield validatePlugin(option_1.getCurrentCommand(), sourceDir, runtime_store_1.default, packageJson);
|
|
81
82
|
}
|
|
82
83
|
catch (e) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
original: e,
|
|
87
|
-
arg: [
|
|
88
|
-
'validating',
|
|
89
|
-
ansi_colors_1.bold(config_1.clientConfig.plugin('validate') || 'unknown'),
|
|
90
|
-
ansi_colors_1.bold('Error: ') + ansi_colors_1.italic.red(e.message)
|
|
91
|
-
]
|
|
84
|
+
const err = error_1.default.getErrorInstance(e, {
|
|
85
|
+
skipHelp: false,
|
|
86
|
+
fileName: __filename
|
|
92
87
|
});
|
|
88
|
+
err.errorId = 'CLIENT-UTILS-5';
|
|
89
|
+
err.arg = [
|
|
90
|
+
'validating',
|
|
91
|
+
ansi_colors_1.bold(config_1.clientConfig.plugin('validate') || 'unknown'),
|
|
92
|
+
ansi_colors_1.bold('Error: ') + ansi_colors_1.italic.red(err.message)
|
|
93
|
+
];
|
|
94
|
+
throw err;
|
|
93
95
|
}
|
|
94
96
|
runtime_store_1.default.set('context.client.valid', true);
|
|
95
97
|
return packageJson;
|
|
@@ -107,8 +109,8 @@ exports.clientUtils = {
|
|
|
107
109
|
},
|
|
108
110
|
pack: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
111
|
let source = project_1.resolveProjectPath(config_1.clientConfig.source());
|
|
110
|
-
const buildPlugin = yield plugin_loader_1.default('client', 'build');
|
|
111
|
-
if (buildPlugin
|
|
112
|
+
const buildPlugin = yield plugin_loader_1.default('client', 'build').catch((err) => logger_1.debug(err));
|
|
113
|
+
if (typeof buildPlugin === 'function') {
|
|
112
114
|
try {
|
|
113
115
|
logger_1.message(`Plugin : "${runtime_store_1.default.get(`context.client.plugins.build`)}" is used for client deploy`);
|
|
114
116
|
const outputDir = yield buildPlugin(source, runtime_store_1.default);
|
|
@@ -118,20 +120,21 @@ exports.clientUtils = {
|
|
|
118
120
|
source = outputDir;
|
|
119
121
|
}
|
|
120
122
|
catch (e) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
original: e,
|
|
125
|
-
arg: [
|
|
126
|
-
'building',
|
|
127
|
-
ansi_colors_1.bold(config_1.clientConfig.plugin('build') || 'unknown'),
|
|
128
|
-
ansi_colors_1.bold('Error: ') + ansi_colors_1.italic.red(e.message)
|
|
129
|
-
]
|
|
123
|
+
const err = error_1.default.getErrorInstance(e, {
|
|
124
|
+
skipHelp: false,
|
|
125
|
+
fileName: __filename
|
|
130
126
|
});
|
|
127
|
+
err.errorId = 'CLIENT-UTILS-5';
|
|
128
|
+
err.arg = [
|
|
129
|
+
'building',
|
|
130
|
+
ansi_colors_1.bold(config_1.clientConfig.plugin('build') || 'unknown'),
|
|
131
|
+
ansi_colors_1.bold('Error: ') + ansi_colors_1.italic.red(err.message)
|
|
132
|
+
];
|
|
133
|
+
throw err;
|
|
131
134
|
}
|
|
132
135
|
}
|
|
133
|
-
const
|
|
134
|
-
const files = yield fs_1.ASYNC.walk(source,
|
|
136
|
+
const exclude = config_1.clientConfig.ignore(source);
|
|
137
|
+
const files = yield fs_1.ASYNC.walk(source, { exclude });
|
|
135
138
|
const zip = new archiver_1.default();
|
|
136
139
|
files.forEach((file) => {
|
|
137
140
|
zip.add(file.replace(source + path_1.sep, ''), fs_1.SYNC.getReadStream(file));
|
|
@@ -147,5 +150,31 @@ exports.clientUtils = {
|
|
|
147
150
|
}
|
|
148
151
|
conf.unset('client');
|
|
149
152
|
yield conf.save();
|
|
153
|
+
}),
|
|
154
|
+
directoryOverridePrompt: (dir) => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
|
+
const foldeExists = yield fs_1.ASYNC.dirExists(dir);
|
|
156
|
+
if (foldeExists) {
|
|
157
|
+
const overwriteAns = yield prompt_1.default.ask(prompt_1.default.question('overwrite', 'Directory ' + ansi_colors_1.underline(dir) + ' already exists. Overwrite ?', {
|
|
158
|
+
type: 'confirm',
|
|
159
|
+
defaultAns: false
|
|
160
|
+
}));
|
|
161
|
+
if (!overwriteAns.overwrite) {
|
|
162
|
+
throw new error_1.default('Skipping client setup since unable to override the already existing client', { exit: 0, errorId: 'CLIENT-UTILS-6', arg: [ansi_colors_1.italic.red(dir)] });
|
|
163
|
+
}
|
|
164
|
+
yield fs_1.ASYNC.deleteDir(dir);
|
|
165
|
+
}
|
|
166
|
+
}),
|
|
167
|
+
clientNamePrompt: (question, defaultAns) => __awaiter(void 0, void 0, void 0, function* () {
|
|
168
|
+
const namePrompt = yield prompt_1.default.ask(prompt_1.default.question('name', question, {
|
|
169
|
+
type: 'input',
|
|
170
|
+
defaultAns,
|
|
171
|
+
validate: (ans) => {
|
|
172
|
+
if (ans.match(constants_1.REGEX.client.package_name)) {
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
return 'Invalid client name';
|
|
176
|
+
}
|
|
177
|
+
}));
|
|
178
|
+
return namePrompt.name;
|
|
150
179
|
})
|
|
151
180
|
};
|