zcatalyst-cli 1.9.1 → 1.10.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 +3 -3
- 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/lib/api-timer.js +81 -0
- package/lib/apig-utils.js +16 -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 +22 -22
- 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/status.js +6 -4
- package/lib/commands/client/delete.js +2 -4
- package/lib/commands/client/setup.js +1 -1
- package/lib/commands/deploy.js +3 -1
- package/lib/commands/ds/export.js +3 -1
- package/lib/commands/ds/import.js +3 -1
- package/lib/commands/ds/status.js +145 -149
- package/lib/commands/functions/config.js +1 -1
- package/lib/commands/functions/setup.js +1 -1
- package/lib/commands/help.js +1 -23
- package/lib/commands/iac/export.js +85 -0
- package/lib/commands/iac/import.js +187 -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 +33 -26
- package/lib/commands/project/list.js +10 -6
- package/lib/commands/project/use.js +42 -25
- 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 +29 -0
- package/lib/errorOut.js +3 -2
- package/lib/fn-utils/lib/common.js +32 -12
- package/lib/fn-utils/lib/java.js +6 -8
- 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 +8 -14
- package/lib/init/features/client.js +2 -3
- package/lib/init/features/functions/languages/java.js +2 -5
- package/lib/init/features/functions/languages/node.js +2 -5
- package/lib/init/features/index.js +8 -3
- package/lib/init/features/project.js +70 -33
- 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 +2 -2
- package/lib/internal/config.js +6 -4
- package/lib/migration/index.js +10 -6
- package/lib/option-filter.js +4 -1
- package/lib/port-resolver.js +18 -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/shell/dependencies/http-functions.js +1 -1
- package/lib/shell/index.js +3 -1
- package/lib/track.js +3 -1
- package/lib/util_modules/constants/index.js +3 -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/regex.js +2 -1
- package/lib/util_modules/constants/lib/scopes.js +5 -0
- package/lib/util_modules/constants/project.js +6 -0
- package/lib/util_modules/contextHelp.js +5 -1
- package/lib/util_modules/env.js +2 -5
- package/lib/util_modules/fs/index.js +9 -1
- package/lib/util_modules/fs/lib/async.js +29 -22
- package/lib/util_modules/js.js +6 -0
- package/lib/util_modules/parser/toml.js +5 -1
- package/lib/util_modules/project.js +3 -0
- package/lib/util_modules/shell.js +3 -6
- package/package.json +7 -4
- package/templates/iacSuccess.html +391 -0
- package/lib/prompt.js +0 -49
package/README.md
CHANGED
|
@@ -86,12 +86,12 @@ Command | Description
|
|
|
86
86
|
**ds:import** | Bulk write records to a table in the Catalyst Data Store.
|
|
87
87
|
**ds:export** | Bulk read records from a table in the Catalyst Data Store.
|
|
88
88
|
**ds:status** | Display the job status of a Data Store import or export operation.
|
|
89
|
-
**client:setup** | Set up the client directory in your project directory.
|
|
89
|
+
**client:setup** | Set up and configure the client directory in your project directory.
|
|
90
90
|
**client:delete** | Delete a version of the client from the remote console or the local directory.
|
|
91
|
-
**functions:setup** | Set up the function directory in your project directory.
|
|
91
|
+
**functions:setup** | Set up and configure the function directory in your project directory.
|
|
92
92
|
**functions:add** | Add a function of the required stack to the function directory.
|
|
93
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** |
|
|
94
|
+
**functions:config** | Perform advanced configurations such as memory allocation on a function in your project.
|
|
95
95
|
**functions:delete** | Delete a function from the remote console or the local directory.
|
|
96
96
|
**event:generate \| generate:event** | Generate sample payloads from different components or custom event sources to test Event functions.
|
|
97
97
|
**event:generate:integ** | Generate sample payloads for the required integration service to test Integration functions.
|
|
@@ -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, or provide different auth token via ${arg[1]} param'''
|
|
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,20 @@ exports.apigUtils = {
|
|
|
197
198
|
rule.name, new RegExp(regexParts[1]);
|
|
198
199
|
}
|
|
199
200
|
catch (regexError) {
|
|
200
|
-
|
|
201
|
-
rule
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
errorId: 'APIG-UTILS-9',
|
|
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
|
|
212
206
|
});
|
|
207
|
+
err.errorId = 'APIG-UTILS-9';
|
|
208
|
+
err.arg = [
|
|
209
|
+
ansi_colors_1.bold('source_endpoint'),
|
|
210
|
+
ansi_colors_1.bold(rule.name),
|
|
211
|
+
ansi_colors_1.italic(source_endpoint.replace(part, ansi_colors_1.red(part))),
|
|
212
|
+
ansi_colors_1.bold('Error: ') + ansi_colors_1.italic.red(util_1.inspect(regexError))
|
|
213
|
+
];
|
|
214
|
+
throw err;
|
|
213
215
|
}
|
|
214
216
|
if (regexParts[1].includes('^') || regexParts[1].includes('$')) {
|
|
215
217
|
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 = true) {
|
|
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 = true) {
|
|
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 = true } = {}) {
|
|
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
|
@@ -28,8 +28,8 @@ 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
30
|
exports.clientUtils = {
|
|
31
|
-
validate: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
-
const sourceDir = project_1.resolveProjectPath(config_1.clientConfig.source());
|
|
31
|
+
validate: (source) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
const sourceDir = source || project_1.resolveProjectPath(config_1.clientConfig.source());
|
|
33
33
|
const packageJsonFile = path_1.join(sourceDir, constants_1.FILENAME.client.package_json);
|
|
34
34
|
const sourceDirExists = yield fs_1.ASYNC.dirExists(sourceDir);
|
|
35
35
|
if (!sourceDirExists) {
|
|
@@ -80,16 +80,16 @@ exports.clientUtils = {
|
|
|
80
80
|
yield validatePlugin(option_1.getCurrentCommand(), sourceDir, runtime_store_1.default, packageJson);
|
|
81
81
|
}
|
|
82
82
|
catch (e) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
errorId: 'CLIENT-UTILS-5',
|
|
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
|
-
]
|
|
83
|
+
const err = error_1.default.getErrorInstance(e, {
|
|
84
|
+
skipHelp: false
|
|
92
85
|
});
|
|
86
|
+
err.errorId = 'CLIENT-UTILS-5';
|
|
87
|
+
err.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(err.message)
|
|
91
|
+
];
|
|
92
|
+
throw err;
|
|
93
93
|
}
|
|
94
94
|
runtime_store_1.default.set('context.client.valid', true);
|
|
95
95
|
return packageJson;
|
|
@@ -118,20 +118,20 @@ exports.clientUtils = {
|
|
|
118
118
|
source = outputDir;
|
|
119
119
|
}
|
|
120
120
|
catch (e) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
errorId: 'CLIENT-UTILS-5',
|
|
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
|
-
]
|
|
121
|
+
const err = error_1.default.getErrorInstance(e, {
|
|
122
|
+
skipHelp: false
|
|
130
123
|
});
|
|
124
|
+
err.errorId = 'CLIENT-UTILS-5';
|
|
125
|
+
err.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(err.message)
|
|
129
|
+
];
|
|
130
|
+
throw err;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
const
|
|
134
|
-
const files = yield fs_1.ASYNC.walk(source,
|
|
133
|
+
const exclude = config_1.clientConfig.ignore(source);
|
|
134
|
+
const files = yield fs_1.ASYNC.walk(source, { exclude });
|
|
135
135
|
const zip = new archiver_1.default();
|
|
136
136
|
files.forEach((file) => {
|
|
137
137
|
zip.add(file.replace(source + path_1.sep, ''), fs_1.SYNC.getReadStream(file));
|
package/lib/client.js
CHANGED
|
@@ -41,9 +41,18 @@ exports.default = (inScopes = []) => {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
logger_1.debug(`> authorizing via ${tokenObj.option} option`);
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const existingScopes = config_store_1.default.get(`${activeDC}.scopes`, []);
|
|
45
|
+
const requiredScopes = [constants_1.SCOPE.projects, ...inScopes];
|
|
46
|
+
logger_1.debug('> command requires scopes: ' + JSON.stringify(requiredScopes));
|
|
47
|
+
const hasAllScope = requiredScopes.every((scope) => existingScopes.includes(scope));
|
|
48
|
+
if (!hasAllScope) {
|
|
49
|
+
throw new error_1.default('Re-login required due to missing scopes!!', {
|
|
50
|
+
exit: 0,
|
|
51
|
+
errorId: 'AUTH-2',
|
|
52
|
+
arg: [ansi_colors_1.bold('catalyst login --force'), ansi_colors_1.bold('--token')]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
runtime_store_1.default.set('auth_scopes', requiredScopes);
|
|
47
56
|
runtime_store_1.default.set('user', config_store_1.default.get(`${activeDC}.user`, null));
|
|
48
57
|
runtime_store_1.default.set('credential', credential_1.default.init(tokenObj.token, tokenObj.temp));
|
|
49
58
|
};
|
package/lib/command_needs/rc.js
CHANGED
|
@@ -18,16 +18,17 @@ const error_1 = __importDefault(require("../error"));
|
|
|
18
18
|
const rc_1 = __importDefault(require("../internal/rc"));
|
|
19
19
|
const runtime_store_1 = __importDefault(require("../runtime-store"));
|
|
20
20
|
const constants_1 = require("../util_modules/constants");
|
|
21
|
+
const project_1 = __importDefault(require("../util_modules/constants/project"));
|
|
21
22
|
const js_1 = require("../util_modules/js");
|
|
22
23
|
const logger_1 = require("../util_modules/logger");
|
|
23
24
|
const option_1 = require("../util_modules/option");
|
|
24
|
-
const
|
|
25
|
+
const project_2 = require("../util_modules/project");
|
|
25
26
|
exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
27
|
const projectOpt = option_1.getGlobalOptionValue('project', null);
|
|
27
28
|
const projectApi = yield endpoints_1.projectAPI();
|
|
28
29
|
const envApi = yield endpoints_1.envAPI();
|
|
29
30
|
const convertProjectToProperties = (project) => {
|
|
30
|
-
project =
|
|
31
|
+
project = project_2.transformProject(project);
|
|
31
32
|
runtime_store_1.default.set('project.name', project.name);
|
|
32
33
|
runtime_store_1.default.set('project.id', project.id + '');
|
|
33
34
|
runtime_store_1.default.set('project.domain', project.domain);
|
|
@@ -39,7 +40,7 @@ exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __aw
|
|
|
39
40
|
exit: 2
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
|
-
runtime_store_1.default.set('project.env',
|
|
43
|
+
runtime_store_1.default.set('project.env', project_2.transformEnv(envObj));
|
|
43
44
|
};
|
|
44
45
|
let ignoreRC = false;
|
|
45
46
|
if (projectOpt !== null) {
|
|
@@ -60,7 +61,11 @@ exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __aw
|
|
|
60
61
|
arg: [
|
|
61
62
|
ansi_colors_1.bold(projectOpt),
|
|
62
63
|
ansi_colors_1.bold('--project'),
|
|
63
|
-
ansi_colors_1.bold(projectArr
|
|
64
|
+
ansi_colors_1.bold(projectArr
|
|
65
|
+
.filter((proj) => proj.project_type &&
|
|
66
|
+
project_1.default.accepted_types.includes(proj.project_type))
|
|
67
|
+
.map((project) => '* ' + project.project_name)
|
|
68
|
+
.join('\n'))
|
|
64
69
|
]
|
|
65
70
|
});
|
|
66
71
|
}
|
|
@@ -146,7 +151,7 @@ exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __aw
|
|
|
146
151
|
logger_1.message('cleaning up ' +
|
|
147
152
|
constants_1.FILENAME.rc +
|
|
148
153
|
' since the current active project for this folder is not found in remote');
|
|
149
|
-
yield
|
|
154
|
+
yield project_2.removeProject(finalProjectObj.id + '');
|
|
150
155
|
if (resolveOnNotFound) {
|
|
151
156
|
finalProjectObj = undefined;
|
|
152
157
|
return;
|
|
@@ -170,8 +175,8 @@ exports.default = ({ optional = false, resolveOnNotFound = false } = {}) => __aw
|
|
|
170
175
|
exit: 2
|
|
171
176
|
});
|
|
172
177
|
}
|
|
173
|
-
finalEnvObj =
|
|
174
|
-
yield
|
|
178
|
+
finalEnvObj = project_2.transformEnv(envObj);
|
|
179
|
+
yield project_2.upsertEnv(finalProjectObj.id + '', envObj, {
|
|
175
180
|
active: true,
|
|
176
181
|
base: js_1.JS.isEmpty(defaultRCEnv)
|
|
177
182
|
});
|
|
@@ -46,13 +46,14 @@ exports.default = new command_1.default('apig:status')
|
|
|
46
46
|
report = (yield api.getScheduleReport(previousOpt));
|
|
47
47
|
}
|
|
48
48
|
catch (e) {
|
|
49
|
-
|
|
49
|
+
const err = error_1.default.getErrorInstance(e);
|
|
50
|
+
if (err.status && err.status === 404) {
|
|
50
51
|
throw new error_1.default('There is no report available.', {
|
|
51
52
|
exit: 0,
|
|
52
53
|
errorId: 'STAT-1'
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
|
-
throw
|
|
56
|
+
throw err;
|
|
56
57
|
}
|
|
57
58
|
const spinner = 'API Gateway Upsert';
|
|
58
59
|
const throbber = throbber_1.default.getInstance();
|
|
@@ -192,13 +193,14 @@ exports.default = new command_1.default('apig:status')
|
|
|
192
193
|
report = (yield api.getScheduleReport(false));
|
|
193
194
|
}
|
|
194
195
|
catch (ex) {
|
|
195
|
-
|
|
196
|
+
const err = error_1.default.getErrorInstance(ex);
|
|
197
|
+
if (err.status && err.status === 404) {
|
|
196
198
|
report = (yield api.getScheduleReport(true));
|
|
197
199
|
}
|
|
198
200
|
else {
|
|
199
201
|
throbber.stopAll();
|
|
200
202
|
needIteration = false;
|
|
201
|
-
reject(
|
|
203
|
+
reject(err);
|
|
202
204
|
}
|
|
203
205
|
}
|
|
204
206
|
}
|
|
@@ -87,10 +87,8 @@ exports.default = new command_1.default('client:delete [client_version]')
|
|
|
87
87
|
localDel.version = version;
|
|
88
88
|
}
|
|
89
89
|
catch (error) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
' Reason: ' +
|
|
93
|
-
error.message);
|
|
90
|
+
const err = error_1.default.getErrorInstance(error);
|
|
91
|
+
logger_1.debug('Failed to read ' + constants_1.FILENAME.client.package_json + ' Reason: ' + err.message);
|
|
94
92
|
}
|
|
95
93
|
if (clientVersion !== undefined && clientVersion !== localDel.version) {
|
|
96
94
|
throw new error_1.default('version unavailable in local', {
|
|
@@ -37,7 +37,7 @@ const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
|
37
37
|
const constants_1 = require("../../util_modules/constants");
|
|
38
38
|
const logger_1 = require("../../util_modules/logger");
|
|
39
39
|
exports.default = new command_1.default('client:setup')
|
|
40
|
-
.description('Set up the client directory in your project directory')
|
|
40
|
+
.description('Set up and configure the client directory in your project directory')
|
|
41
41
|
.needs('auth', [constants_1.SCOPE.webapp])
|
|
42
42
|
.needs('config')
|
|
43
43
|
.needs('rc')
|