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/lib/commands/deploy.js
CHANGED
|
@@ -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();
|
|
@@ -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], {
|
|
@@ -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,6 +24,149 @@ 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
171
|
.description('Display the job status of a Data Store import or export operation')
|
|
29
172
|
.option('--production', 'flag for pointing to production environment.')
|
|
@@ -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) {
|
|
@@ -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')
|
|
@@ -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('Set up the function directory in your project directory')
|
|
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')
|
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
|
-
.description('Display
|
|
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
|
+
}));
|