zcatalyst-cli 1.8.0 → 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 +31 -10
- 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/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 +3 -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 +1 -1
- 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 +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 +34 -27
- 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 +1 -1
- package/lib/commands/run.js +1 -1
- package/lib/commands/serve.js +6 -5
- 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 +43 -9
- package/lib/errorOut.js +9 -2
- package/lib/express_middlewares/unknownReqProxy.js +18 -7
- package/lib/fn-utils/lib/common.js +32 -12
- package/lib/fn-utils/lib/java.js +8 -9
- package/lib/fn-utils/lib/node.js +7 -1
- package/lib/fn-watcher.js +67 -0
- 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/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 +3 -3
- 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/serve/index.js +8 -4
- package/lib/serve/server/index.js +134 -64
- package/lib/serve/server/lib/master.js +5 -4
- package/lib/shell/dependencies/http-functions.js +46 -21
- package/lib/shell/dependencies/local-function.js +17 -48
- package/lib/shell/index.js +9 -10
- package/lib/shell/prepare/index.js +1 -5
- package/lib/shell/prepare/languages/index.js +14 -3
- 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 +25 -14
- 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/logger.js +11 -10
- package/lib/util_modules/parser/toml.js +5 -1
- package/lib/util_modules/project.js +34 -19
- package/lib/util_modules/shell.js +6 -5
- package/package.json +12 -7
- package/scripts/postInstall.js +31 -0
- package/templates/iacSuccess.html +391 -0
- package/lib/prompt.js +0 -49
|
@@ -22,7 +22,7 @@ const constants_1 = require("../../util_modules/constants");
|
|
|
22
22
|
const logger_1 = require("../../util_modules/logger");
|
|
23
23
|
const option_1 = require("../../util_modules/option");
|
|
24
24
|
exports.default = new command_1.default('apig:status')
|
|
25
|
-
.description('
|
|
25
|
+
.description('Obtain the current status of API Gateway for your project and the schedule progress')
|
|
26
26
|
.option('--previous', 'show previous schedule status instead of current one')
|
|
27
27
|
.needs('auth', [constants_1.SCOPE.projects])
|
|
28
28
|
.needs('config')
|
|
@@ -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
|
}
|
|
@@ -28,7 +28,7 @@ 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.default = new command_1.default('client:delete [client_version]')
|
|
31
|
-
.description('
|
|
31
|
+
.description('Delete a version of the client from the remote console or the local directory')
|
|
32
32
|
.option('--local', 'removes the client from local machine')
|
|
33
33
|
.option('--remote', 'removes the selected client from remote console')
|
|
34
34
|
.needs('auth', [constants_1.SCOPE.webapp])
|
|
@@ -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('
|
|
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')
|
package/lib/commands/deploy.js
CHANGED
|
@@ -36,7 +36,7 @@ const runtime_store_1 = __importDefault(require("../runtime-store"));
|
|
|
36
36
|
const constants_1 = require("../util_modules/constants");
|
|
37
37
|
const logger_1 = require("../util_modules/logger");
|
|
38
38
|
exports.default = new command_1.default('deploy')
|
|
39
|
-
.description('Deploy
|
|
39
|
+
.description('Deploy the Catalyst project and project resources to the remote console from the local directory')
|
|
40
40
|
.option('--only <targets>', 'only deploy specified, comma-separated targets (e.g. "functions,client").' +
|
|
41
41
|
' For Functions you can specify which functions to deploy with colon notation' +
|
|
42
42
|
' (e.g. "--only functions:<function_name>,functions:<function_name>"). ')
|
|
@@ -49,7 +49,9 @@ exports.default = new command_1.default('deploy')
|
|
|
49
49
|
const optionFilter = yield Promise.resolve().then(() => __importStar(require('../option-filter')));
|
|
50
50
|
optionFilter.filterTargets();
|
|
51
51
|
yield (yield Promise.resolve().then(() => __importStar(require('../deploy')))).default();
|
|
52
|
-
const deployTargets = runtime_store_1.default
|
|
52
|
+
const deployTargets = runtime_store_1.default
|
|
53
|
+
.get('payload.targets', [])
|
|
54
|
+
.filter((deploytarget) => {
|
|
53
55
|
if (!runtime_store_1.default.get('payload.' + deploytarget + '.deploy', false)) {
|
|
54
56
|
logger_1.info();
|
|
55
57
|
logger_1.labeled(deploytarget, 'deploy skipped').ERROR();
|
|
@@ -35,7 +35,7 @@ const getReadConfigFromPath = (pth) => __awaiter(void 0, void 0, void 0, functio
|
|
|
35
35
|
return configJSON;
|
|
36
36
|
});
|
|
37
37
|
exports.default = new command_1.default('ds:export [table]')
|
|
38
|
-
.description('
|
|
38
|
+
.description('Bulk read records from a table in the Catalyst Data Store')
|
|
39
39
|
.option('--table <name|id>', 'Name or ID of the table from which data is to be read (eg. "UserDetails")')
|
|
40
40
|
.option('--config <path>', 'Path of the configuration json file to be used for export.')
|
|
41
41
|
.option('--page <page>', 'Number which denotes the range of rows to be fetched (eg. "1")')
|
|
@@ -69,7 +69,9 @@ exports.default = new command_1.default('ds:export [table]')
|
|
|
69
69
|
const allGlobalOpts = runtime_store_1.default.get('opts.globalOpts', {});
|
|
70
70
|
const optsArr = Object.keys(allGlobalOpts).reduce((arr, key) => {
|
|
71
71
|
arr.push('--' + key);
|
|
72
|
-
|
|
72
|
+
if (allGlobalOpts[key]) {
|
|
73
|
+
arr.push(allGlobalOpts[key]);
|
|
74
|
+
}
|
|
73
75
|
return arr;
|
|
74
76
|
}, (env === 'Production' ? ['--production'] : []));
|
|
75
77
|
shell_1.spawn('catalyst', ['ds:status', 'export', readResponse.job_id + '', ...optsArr], {
|
|
@@ -36,7 +36,7 @@ const getWriteConfigFromPath = (pth) => __awaiter(void 0, void 0, void 0, functi
|
|
|
36
36
|
return configJSON;
|
|
37
37
|
});
|
|
38
38
|
exports.default = new command_1.default('ds:import [file]')
|
|
39
|
-
.description('
|
|
39
|
+
.description('Bulk write records to a table in the Catalyst Data Store')
|
|
40
40
|
.option('--table <name|id>', 'Name or ID of the table to which data to be written (e.g. "UserDetails")')
|
|
41
41
|
.option('--config <path>', 'Path of the configuration json file to be used for import.')
|
|
42
42
|
.option('--production', 'flag for pointing to production environment')
|
|
@@ -82,7 +82,9 @@ exports.default = new command_1.default('ds:import [file]')
|
|
|
82
82
|
const allGlobalOpts = runtime_store_1.default.get('opts.globalOpts', {});
|
|
83
83
|
const optsArr = Object.keys(allGlobalOpts).reduce((arr, key) => {
|
|
84
84
|
arr.push('--' + key);
|
|
85
|
-
|
|
85
|
+
if (allGlobalOpts[key]) {
|
|
86
|
+
arr.push(allGlobalOpts[key]);
|
|
87
|
+
}
|
|
86
88
|
return arr;
|
|
87
89
|
}, (env === 'Production' ? ['--production'] : []));
|
|
88
90
|
shell_1.spawn('catalyst', ['ds:status', 'import', writeResponse.job_id + '', ...optsArr], {
|
|
@@ -24,8 +24,151 @@ const constants_1 = require("../../util_modules/constants");
|
|
|
24
24
|
const fs_1 = require("../../util_modules/fs");
|
|
25
25
|
const logger_1 = require("../../util_modules/logger");
|
|
26
26
|
const option_1 = require("../../util_modules/option");
|
|
27
|
+
const getSpinnerTxt = (mainTable, finalReport) => {
|
|
28
|
+
var _a, _b, _c, _d;
|
|
29
|
+
const spaceRpt = ' '.repeat(35);
|
|
30
|
+
let spinnerTxt = '\n' + spaceRpt;
|
|
31
|
+
spinnerTxt += mainTable
|
|
32
|
+
.toString()
|
|
33
|
+
.split('\n')
|
|
34
|
+
.join('\n' + spaceRpt);
|
|
35
|
+
spinnerTxt += '\n';
|
|
36
|
+
if (finalReport === undefined) {
|
|
37
|
+
return spinnerTxt;
|
|
38
|
+
}
|
|
39
|
+
if (finalReport.status === 'Completed') {
|
|
40
|
+
spinnerTxt += ansi_colors_1.green(((_a = finalReport.results) === null || _a === void 0 ? void 0 : _a.description) + '');
|
|
41
|
+
if (((_b = finalReport.results) === null || _b === void 0 ? void 0 : _b.download_url) !== undefined) {
|
|
42
|
+
spinnerTxt += '\n';
|
|
43
|
+
spinnerTxt += ansi_colors_1.bold(`Download URL : ${(_c = finalReport.results) === null || _c === void 0 ? void 0 : _c.download_url}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
spinnerTxt += ansi_colors_1.red(ansi_colors_1.bold('Reason : ') + ((_d = finalReport.results) === null || _d === void 0 ? void 0 : _d.description));
|
|
48
|
+
}
|
|
49
|
+
return spinnerTxt;
|
|
50
|
+
};
|
|
51
|
+
const spinnerFn = (jobId, dsReport, cumulativeStatus, throbber, spinner, bulkApi, displayOpr, action) => (resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
if (jobId === undefined) {
|
|
53
|
+
reject('Job Id cannot be empty!');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
let needIteration = true;
|
|
57
|
+
const reportTable = new cli_table_1.default();
|
|
58
|
+
Object.keys(cumulativeStatus).forEach((table) => {
|
|
59
|
+
const initialCount = reportTable.length;
|
|
60
|
+
let tableRowCount = reportTable.length;
|
|
61
|
+
['insert', 'update', 'upsert', 'read'].forEach((statusAct) => {
|
|
62
|
+
const operationObj = cumulativeStatus[table][statusAct];
|
|
63
|
+
if (operationObj !== null && operationObj !== undefined) {
|
|
64
|
+
let operationRowCount = 0;
|
|
65
|
+
if (operationObj.rows_processed !== undefined &&
|
|
66
|
+
operationObj.rows_processed >= 0) {
|
|
67
|
+
reportTable[tableRowCount++] = [
|
|
68
|
+
'Processed',
|
|
69
|
+
operationObj.rows_processed + ''
|
|
70
|
+
];
|
|
71
|
+
operationRowCount++;
|
|
72
|
+
}
|
|
73
|
+
if (operationObj.fail_count !== undefined && operationObj.fail_count >= 0) {
|
|
74
|
+
reportTable[tableRowCount++] = ['Failure', operationObj.fail_count + ''];
|
|
75
|
+
operationRowCount++;
|
|
76
|
+
}
|
|
77
|
+
if (operationRowCount > 0) {
|
|
78
|
+
reportTable[tableRowCount - operationRowCount].unshift({
|
|
79
|
+
hAlign: 'center',
|
|
80
|
+
vAlign: 'center',
|
|
81
|
+
rowSpan: operationRowCount,
|
|
82
|
+
content: statusAct.toUpperCase()
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
if (tableRowCount > 0) {
|
|
88
|
+
reportTable[initialCount].unshift({
|
|
89
|
+
hAlign: 'center',
|
|
90
|
+
vAlign: 'center',
|
|
91
|
+
rowSpan: tableRowCount,
|
|
92
|
+
content: ansi_colors_1.cyan.bold(table)
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
switch (dsReport.status) {
|
|
97
|
+
case 'In-Progress':
|
|
98
|
+
if (reportTable.length === 0) {
|
|
99
|
+
reportTable.unshift([
|
|
100
|
+
{ hAlign: 'center', content: ansi_colors_1.yellow.bold('Yet to start') }
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
reportTable.unshift([
|
|
105
|
+
{
|
|
106
|
+
hAlign: 'center',
|
|
107
|
+
colSpan: 4,
|
|
108
|
+
content: ansi_colors_1.cyan.bold('In-Progress')
|
|
109
|
+
}
|
|
110
|
+
]);
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
case 'Completed':
|
|
114
|
+
reportTable.unshift([
|
|
115
|
+
{
|
|
116
|
+
hAlign: 'center',
|
|
117
|
+
colSpan: 4,
|
|
118
|
+
content: ansi_colors_1.green.bold(displayOpr + ' Job Completed')
|
|
119
|
+
}
|
|
120
|
+
]);
|
|
121
|
+
dsReport = (yield bulkApi.getReport(action, jobId));
|
|
122
|
+
throbber.succeed(spinner, {
|
|
123
|
+
text: getSpinnerTxt(reportTable, dsReport)
|
|
124
|
+
});
|
|
125
|
+
needIteration = false;
|
|
126
|
+
resolve();
|
|
127
|
+
break;
|
|
128
|
+
case 'Failed':
|
|
129
|
+
reportTable.unshift([
|
|
130
|
+
{
|
|
131
|
+
hAlign: 'center',
|
|
132
|
+
content: ansi_colors_1.red.bold(displayOpr + ' Job Failed!')
|
|
133
|
+
}
|
|
134
|
+
]);
|
|
135
|
+
dsReport = (yield bulkApi.getReport(action, jobId));
|
|
136
|
+
throbber.fail(spinner, {
|
|
137
|
+
text: getSpinnerTxt(reportTable, dsReport)
|
|
138
|
+
});
|
|
139
|
+
needIteration = false;
|
|
140
|
+
resolve();
|
|
141
|
+
break;
|
|
142
|
+
default:
|
|
143
|
+
needIteration = false;
|
|
144
|
+
reject(new error_1.default('unknown state received', { exit: 2 }));
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
if (dsReport.status === 'In-Progress') {
|
|
148
|
+
throbber.update(spinner, {
|
|
149
|
+
text: getSpinnerTxt(reportTable) + 'Press CTRL + C to exit listening to the status'
|
|
150
|
+
});
|
|
151
|
+
try {
|
|
152
|
+
cumulativeStatus = (yield bulkApi.getStatus(action, jobId));
|
|
153
|
+
if (Object.keys(cumulativeStatus).length === 0) {
|
|
154
|
+
dsReport = (yield bulkApi.getReport(action, jobId));
|
|
155
|
+
if (dsReport.status === 'Completed') {
|
|
156
|
+
cumulativeStatus = (yield bulkApi.getStatus(action, jobId, true));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (ex) {
|
|
161
|
+
throbber.stopAll();
|
|
162
|
+
needIteration = false;
|
|
163
|
+
reject(ex);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (needIteration) {
|
|
167
|
+
setTimeout(() => spinnerFn(jobId, dsReport, cumulativeStatus, throbber, spinner, bulkApi, displayOpr, action)(resolve, reject), 2000);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
27
170
|
exports.default = new command_1.default('ds:status <operation> [jobid]')
|
|
28
|
-
.description('
|
|
171
|
+
.description('Display the job status of a Data Store import or export operation')
|
|
29
172
|
.option('--production', 'flag for pointing to production environment.')
|
|
30
173
|
.needs('auth', [constants_1.SCOPE.projects, constants_1.SCOPE.datastore, constants_1.SCOPE.row])
|
|
31
174
|
.needs('config')
|
|
@@ -70,7 +213,7 @@ exports.default = new command_1.default('ds:status <operation> [jobid]')
|
|
|
70
213
|
if (jobId === undefined) {
|
|
71
214
|
throw new error_1.default('Job ID is empty!', { exit: 2 });
|
|
72
215
|
}
|
|
73
|
-
|
|
216
|
+
const dsReport = (yield bulkApi.getReport(action, jobId).catch((err) => {
|
|
74
217
|
if (err.status === 404) {
|
|
75
218
|
throw new error_1.default('No jobs found for the given id', {
|
|
76
219
|
exit: 1,
|
|
@@ -88,154 +231,7 @@ exports.default = new command_1.default('ds:status <operation> [jobid]')
|
|
|
88
231
|
const spinner = 'DS bulk ' + operation;
|
|
89
232
|
const throbber = throbber_1.default.getInstance();
|
|
90
233
|
throbber.add(spinner);
|
|
91
|
-
|
|
92
|
-
var _a, _b, _c, _d;
|
|
93
|
-
const spaceRpt = ' '.repeat(35);
|
|
94
|
-
let spinnerTxt = '\n' + spaceRpt;
|
|
95
|
-
spinnerTxt += mainTable
|
|
96
|
-
.toString()
|
|
97
|
-
.split('\n')
|
|
98
|
-
.join('\n' + spaceRpt);
|
|
99
|
-
spinnerTxt += '\n';
|
|
100
|
-
if (finalReport === undefined) {
|
|
101
|
-
return spinnerTxt;
|
|
102
|
-
}
|
|
103
|
-
if (finalReport.status === 'Completed') {
|
|
104
|
-
spinnerTxt += ansi_colors_1.green(((_a = finalReport.results) === null || _a === void 0 ? void 0 : _a.description) + '');
|
|
105
|
-
if (((_b = finalReport.results) === null || _b === void 0 ? void 0 : _b.download_url) !== undefined) {
|
|
106
|
-
spinnerTxt += '\n';
|
|
107
|
-
spinnerTxt += ansi_colors_1.bold(`Download URL : ${(_c = finalReport.results) === null || _c === void 0 ? void 0 : _c.download_url}`);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
spinnerTxt += ansi_colors_1.red(ansi_colors_1.bold('Reason : ') + ((_d = finalReport.results) === null || _d === void 0 ? void 0 : _d.description));
|
|
112
|
-
}
|
|
113
|
-
return spinnerTxt;
|
|
114
|
-
};
|
|
115
|
-
const spinnerFn = (resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
116
|
-
if (jobId === undefined) {
|
|
117
|
-
reject('Job Id cannot be empty!');
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
let needIteration = true;
|
|
121
|
-
const reportTable = new cli_table_1.default();
|
|
122
|
-
Object.keys(cumulativeStatus).forEach((table) => {
|
|
123
|
-
const initialCount = reportTable.length;
|
|
124
|
-
let tableRowCount = reportTable.length;
|
|
125
|
-
['insert', 'update', 'upsert', 'read'].forEach((statusAct) => {
|
|
126
|
-
const operationObj = cumulativeStatus[table][statusAct];
|
|
127
|
-
if (operationObj !== null && operationObj !== undefined) {
|
|
128
|
-
let operationRowCount = 0;
|
|
129
|
-
if (operationObj.rows_processed !== undefined &&
|
|
130
|
-
operationObj.rows_processed >= 0) {
|
|
131
|
-
reportTable[tableRowCount++] = [
|
|
132
|
-
'Processed',
|
|
133
|
-
operationObj.rows_processed + ''
|
|
134
|
-
];
|
|
135
|
-
operationRowCount++;
|
|
136
|
-
}
|
|
137
|
-
if (operationObj.fail_count !== undefined && operationObj.fail_count >= 0) {
|
|
138
|
-
reportTable[tableRowCount++] = [
|
|
139
|
-
'Failure',
|
|
140
|
-
operationObj.fail_count + ''
|
|
141
|
-
];
|
|
142
|
-
operationRowCount++;
|
|
143
|
-
}
|
|
144
|
-
if (operationRowCount > 0) {
|
|
145
|
-
reportTable[tableRowCount - operationRowCount].unshift({
|
|
146
|
-
hAlign: 'center',
|
|
147
|
-
vAlign: 'center',
|
|
148
|
-
rowSpan: operationRowCount,
|
|
149
|
-
content: statusAct.toUpperCase()
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
if (tableRowCount > 0) {
|
|
155
|
-
reportTable[initialCount].unshift({
|
|
156
|
-
hAlign: 'center',
|
|
157
|
-
vAlign: 'center',
|
|
158
|
-
rowSpan: tableRowCount,
|
|
159
|
-
content: ansi_colors_1.cyan.bold(table)
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
switch (dsReport.status) {
|
|
164
|
-
case 'In-Progress':
|
|
165
|
-
if (reportTable.length === 0) {
|
|
166
|
-
reportTable.unshift([
|
|
167
|
-
{ hAlign: 'center', content: ansi_colors_1.yellow.bold('Yet to start') }
|
|
168
|
-
]);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
reportTable.unshift([
|
|
172
|
-
{
|
|
173
|
-
hAlign: 'center',
|
|
174
|
-
colSpan: 4,
|
|
175
|
-
content: ansi_colors_1.cyan.bold('In-Progress')
|
|
176
|
-
}
|
|
177
|
-
]);
|
|
178
|
-
}
|
|
179
|
-
break;
|
|
180
|
-
case 'Completed':
|
|
181
|
-
reportTable.unshift([
|
|
182
|
-
{
|
|
183
|
-
hAlign: 'center',
|
|
184
|
-
colSpan: 4,
|
|
185
|
-
content: ansi_colors_1.green.bold(displayOpr + ' Job Completed')
|
|
186
|
-
}
|
|
187
|
-
]);
|
|
188
|
-
dsReport = (yield bulkApi.getReport(action, jobId));
|
|
189
|
-
throbber.succeed(spinner, {
|
|
190
|
-
text: getSpinnerTxt(reportTable, dsReport)
|
|
191
|
-
});
|
|
192
|
-
needIteration = false;
|
|
193
|
-
resolve();
|
|
194
|
-
break;
|
|
195
|
-
case 'Failed':
|
|
196
|
-
reportTable.unshift([
|
|
197
|
-
{
|
|
198
|
-
hAlign: 'center',
|
|
199
|
-
content: ansi_colors_1.red.bold(displayOpr + ' Job Failed!')
|
|
200
|
-
}
|
|
201
|
-
]);
|
|
202
|
-
dsReport = (yield bulkApi.getReport(action, jobId));
|
|
203
|
-
throbber.fail(spinner, {
|
|
204
|
-
text: getSpinnerTxt(reportTable, dsReport)
|
|
205
|
-
});
|
|
206
|
-
needIteration = false;
|
|
207
|
-
resolve();
|
|
208
|
-
break;
|
|
209
|
-
default:
|
|
210
|
-
needIteration = false;
|
|
211
|
-
reject(new error_1.default('unknown state received', { exit: 2 }));
|
|
212
|
-
break;
|
|
213
|
-
}
|
|
214
|
-
if (dsReport.status === 'In-Progress') {
|
|
215
|
-
throbber.update(spinner, {
|
|
216
|
-
text: getSpinnerTxt(reportTable) +
|
|
217
|
-
'Press CTRL + C to exit listening to the status'
|
|
218
|
-
});
|
|
219
|
-
try {
|
|
220
|
-
cumulativeStatus = (yield bulkApi.getStatus(action, jobId));
|
|
221
|
-
if (Object.keys(cumulativeStatus).length === 0) {
|
|
222
|
-
dsReport = (yield bulkApi.getReport(action, jobId));
|
|
223
|
-
if (dsReport.status === 'Completed') {
|
|
224
|
-
cumulativeStatus = (yield bulkApi.getStatus(action, jobId, true));
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
catch (ex) {
|
|
229
|
-
throbber.stopAll();
|
|
230
|
-
needIteration = false;
|
|
231
|
-
reject(ex);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
if (needIteration) {
|
|
235
|
-
setTimeout(() => spinnerFn(resolve, reject), 2000);
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
yield new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () { return spinnerFn(resolve, reject); }));
|
|
234
|
+
yield new Promise(spinnerFn(jobId, dsReport, cumulativeStatus, throbber, spinner, bulkApi, displayOpr, action));
|
|
239
235
|
if (dsReport.results && dsReport.results.download_url) {
|
|
240
236
|
const ans = yield prompt_1.default.ask(prompt_1.default.question('download', 'Do you like to download the report of this job to your cmd execution directory?', { type: 'confirm', defaultAns: false }));
|
|
241
237
|
if (ans.download) {
|
|
@@ -42,7 +42,7 @@ const option_1 = require("../../../util_modules/option");
|
|
|
42
42
|
const project_1 = require("../../../util_modules/project");
|
|
43
43
|
exports.default = new command_1.default('event:generate <source> <action>')
|
|
44
44
|
.alias('generate:event')
|
|
45
|
-
.description('Generate sample payloads from different event sources
|
|
45
|
+
.description('Generate sample payloads from different components or custom event sources to test Event functions')
|
|
46
46
|
.option('-rid, --rule-id <rule_identifier>', 'rule_identifier that will be used if the source is custom')
|
|
47
47
|
.option('-e, --event-bus <event_bus_name>', 'event bus name that should be used')
|
|
48
48
|
.allowUnknownOpts()
|
|
@@ -37,7 +37,7 @@ const command_1 = __importDefault(require("../../../internal/command"));
|
|
|
37
37
|
const constants_1 = require("../../../util_modules/constants");
|
|
38
38
|
const option_1 = require("../../../util_modules/option");
|
|
39
39
|
exports.default = new command_1.default('event:generate:integ <service>')
|
|
40
|
-
.description('
|
|
40
|
+
.description('Generate sample payloads for the required integration service to test Integration functions')
|
|
41
41
|
.option('--inputs <inputs>', 'inputs to generate the integ event provided as comma seperated values')
|
|
42
42
|
.needs('rc')
|
|
43
43
|
.needs('auth')
|
|
@@ -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('functions:add')
|
|
40
|
-
.description('Add
|
|
40
|
+
.description('Add a function of the required stack to the function directory')
|
|
41
41
|
.needs('auth', [constants_1.SCOPE.functions])
|
|
42
42
|
.needs('config')
|
|
43
43
|
.needs('rc')
|
|
@@ -20,7 +20,7 @@ const ansi_colors_1 = require("ansi-colors");
|
|
|
20
20
|
const prompt_1 = __importDefault(require("../../prompt"));
|
|
21
21
|
const common_1 = require("../../fn-utils/lib/common");
|
|
22
22
|
exports.default = new command_1.default('functions:config [function_name_or_id]')
|
|
23
|
-
.description('
|
|
23
|
+
.description('Perform advanced configurations such as memory allocation on a function in your project')
|
|
24
24
|
.option('--memory <value>', 'use this option to configure the memory for the function. ex: --memory 128')
|
|
25
25
|
.needs('auth', [constants_1.SCOPE.functions])
|
|
26
26
|
.needs('config')
|
|
@@ -26,7 +26,7 @@ const logger_1 = require("../../util_modules/logger");
|
|
|
26
26
|
const option_1 = require("../../util_modules/option");
|
|
27
27
|
const project_1 = require("../../util_modules/project");
|
|
28
28
|
exports.default = new command_1.default('functions:delete [function_name_or_id]')
|
|
29
|
-
.description('
|
|
29
|
+
.description('Delete a function from the remote console or the local directory')
|
|
30
30
|
.option('--local', 'delete the functions in local machine.')
|
|
31
31
|
.option('--remote', 'delete the functions in remote console.')
|
|
32
32
|
.needs('auth', [constants_1.SCOPE.projects])
|
|
@@ -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('functions:setup')
|
|
40
|
-
.description('
|
|
40
|
+
.description('Set up and configure the function directory in your project directory')
|
|
41
41
|
.needs('auth', [constants_1.SCOPE.functions])
|
|
42
42
|
.needs('config')
|
|
43
43
|
.needs('rc')
|
|
@@ -36,7 +36,7 @@ const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
|
36
36
|
const constants_1 = require("../../util_modules/constants");
|
|
37
37
|
const option_1 = require("../../util_modules/option");
|
|
38
38
|
exports.default = new command_1.default('functions:shell')
|
|
39
|
-
.description('Launch a node shell
|
|
39
|
+
.description('Launch a node shell to test emulated functions of any stack or type, other than Advanced I/O functions')
|
|
40
40
|
.option('--http [port]', 'enables http mode for the basicIO functions and start server at specified port' +
|
|
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.' +
|
package/lib/commands/help.js
CHANGED
|
@@ -5,33 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const ansi_colors_1 = require("ansi-colors");
|
|
7
7
|
const command_1 = __importDefault(require("../internal/command"));
|
|
8
|
-
const fs_1 = require("../util_modules/fs");
|
|
9
|
-
const constants_1 = require("../util_modules/constants");
|
|
10
8
|
const logger_1 = require("../util_modules/logger");
|
|
11
|
-
const option_1 = require("../util_modules/option");
|
|
12
|
-
const project_1 = require("../util_modules/project");
|
|
13
9
|
exports.default = new command_1.default('help [command]')
|
|
14
10
|
.description('Display help information')
|
|
15
11
|
.action(function help(commandName) {
|
|
16
12
|
var _a, _b, _c;
|
|
17
|
-
if (option_1.getOptionValue('info', false)) {
|
|
18
|
-
const helpPth = project_1.resolveProjectPath(constants_1.FILENAME.command_log);
|
|
19
|
-
const rawHelp = fs_1.SYNC.readFile(helpPth);
|
|
20
|
-
if (rawHelp === undefined) {
|
|
21
|
-
logger_1.info('No recent logs');
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const logHelp = JSON.parse(rawHelp);
|
|
25
|
-
const helpMsg = ansi_colors_1.bold('\nCOMMAND : ') +
|
|
26
|
-
logHelp.command +
|
|
27
|
-
ansi_colors_1.bold('\nEXECUTION : ') +
|
|
28
|
-
logHelp.status +
|
|
29
|
-
'\n' +
|
|
30
|
-
(logHelp.help !== undefined ? '\n' + logHelp.help.join('\n') : '');
|
|
31
|
-
logger_1.info(helpMsg);
|
|
32
|
-
logger_1.info(`If you couldn't find the needed help here, feel free to reach us through ${ansi_colors_1.bold.underline('support@zohocatalyst.com')}`);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
13
|
if (commandName === undefined) {
|
|
36
14
|
(_a = this.client) === null || _a === void 0 ? void 0 : _a.cli.outputHelp();
|
|
37
15
|
logger_1.info();
|
|
@@ -0,0 +1,85 @@
|
|
|
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 endpoints_1 = require("../../endpoints");
|
|
16
|
+
const iac_1 = __importDefault(require("../../endpoints/lib/iac"));
|
|
17
|
+
const error_1 = __importDefault(require("../../error"));
|
|
18
|
+
const command_1 = __importDefault(require("../../internal/command"));
|
|
19
|
+
const prompt_1 = __importDefault(require("../../prompt"));
|
|
20
|
+
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
21
|
+
const constants_1 = require("../../util_modules/constants");
|
|
22
|
+
const env_1 = require("../../util_modules/env");
|
|
23
|
+
const logger_1 = require("../../util_modules/logger");
|
|
24
|
+
const option_1 = require("../../util_modules/option");
|
|
25
|
+
const project_1 = require("../../util_modules/project");
|
|
26
|
+
const shell_1 = require("../../util_modules/shell");
|
|
27
|
+
const getExportProjectId = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
const projectId = project_1.getProjectId(null);
|
|
29
|
+
if (projectId !== null) {
|
|
30
|
+
return projectId;
|
|
31
|
+
}
|
|
32
|
+
const allProjects = (yield (yield endpoints_1.projectAPI()).getAllProjects());
|
|
33
|
+
if (allProjects.length === 0) {
|
|
34
|
+
throw new error_1.default('No projects found', {
|
|
35
|
+
exit: 0,
|
|
36
|
+
errorId: 'PROJ-USE-1'
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (allProjects.length === 1) {
|
|
40
|
+
logger_1.message('only one project found in remote, using that');
|
|
41
|
+
return allProjects[0].id;
|
|
42
|
+
}
|
|
43
|
+
const projectAns = yield prompt_1.default.ask(prompt_1.default.question('project', 'Which project do you wish to export ? ', {
|
|
44
|
+
type: 'list',
|
|
45
|
+
choices: allProjects.map((project) => {
|
|
46
|
+
return prompt_1.default.choice(project.project_name, {
|
|
47
|
+
value: project.id,
|
|
48
|
+
short: project.project_name
|
|
49
|
+
});
|
|
50
|
+
})
|
|
51
|
+
}));
|
|
52
|
+
return projectAns.project;
|
|
53
|
+
});
|
|
54
|
+
exports.default = new command_1.default('iac:export')
|
|
55
|
+
.description('Create a zip file out of existing project in console')
|
|
56
|
+
.option('--production', 'flag for pointing to production environment')
|
|
57
|
+
.needs('auth', [constants_1.SCOPE.project_export_read, constants_1.SCOPE.project_export_create])
|
|
58
|
+
.needs('config', { optional: true })
|
|
59
|
+
.needs('rc', { optional: true })
|
|
60
|
+
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
const env = option_1.getOptionValue('production', false) ? 'Production' : 'Development';
|
|
62
|
+
const projectId = yield getExportProjectId();
|
|
63
|
+
const bundleResp = yield new iac_1.default(projectId, { env }).bundle(constants_1.IAC.template_format.json);
|
|
64
|
+
logger_1.info();
|
|
65
|
+
logger_1.success(`Successfully scheduled export job for project "${project_1.getProjectName(projectId)}" with jobid "${bundleResp.id}"`);
|
|
66
|
+
if (env_1.isPrimaryShell()) {
|
|
67
|
+
const exitListeners = process.listeners('exit');
|
|
68
|
+
process.removeAllListeners('exit');
|
|
69
|
+
const allGlobalOpts = runtime_store_1.default.get('opts.globalOpts', {});
|
|
70
|
+
const optsArr = Object.keys(allGlobalOpts).reduce((arr, key) => {
|
|
71
|
+
arr.push('--' + key);
|
|
72
|
+
if (allGlobalOpts[key]) {
|
|
73
|
+
arr.push(allGlobalOpts[key]);
|
|
74
|
+
}
|
|
75
|
+
return arr;
|
|
76
|
+
}, (env === 'Production' ? ['--production'] : []));
|
|
77
|
+
shell_1.spawn('catalyst', ['iac:status', 'export', ...optsArr], {
|
|
78
|
+
shell: true,
|
|
79
|
+
stdio: 'inherit'
|
|
80
|
+
}).SYNC();
|
|
81
|
+
(exitListeners || []).forEach((listner) => {
|
|
82
|
+
process.addListener('exit', listner);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}));
|