@hotglue/cli 1.0.25 → 1.0.27
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/lib/cjs/index.js +34 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/mjs/index.js +34 -0
- package/lib/mjs/index.js.map +1 -0
- package/package.json +20 -21
- package/lib/commands/config/index.js +0 -15
- package/lib/commands/config/set.js +0 -82
- package/lib/commands/config.js +0 -71
- package/lib/commands/env/deploy.js +0 -162
- package/lib/commands/env/download.js +0 -169
- package/lib/commands/env/index.js +0 -17
- package/lib/commands/env.js +0 -34
- package/lib/commands/etl/delete.js +0 -171
- package/lib/commands/etl/deploy.js +0 -261
- package/lib/commands/etl/download.js +0 -205
- package/lib/commands/etl/index.js +0 -19
- package/lib/commands/etl.js +0 -34
- package/lib/commands/flows/index.js +0 -15
- package/lib/commands/flows/list.js +0 -104
- package/lib/commands/flows.js +0 -34
- package/lib/commands/index.js +0 -27
- package/lib/commands/jobs/download.js +0 -188
- package/lib/commands/jobs/index.js +0 -17
- package/lib/commands/jobs/list.js +0 -108
- package/lib/commands/jobs.js +0 -34
- package/lib/commands/snapshots/deploy.js +0 -202
- package/lib/commands/snapshots/download.js +0 -213
- package/lib/commands/snapshots/index.js +0 -17
- package/lib/commands/snapshots.js +0 -34
- package/lib/commands/tenants/customCatalog.js +0 -199
- package/lib/commands/tenants/customEtl.js +0 -183
- package/lib/commands/tenants/customFieldMap.js +0 -191
- package/lib/commands/tenants/delete.js +0 -150
- package/lib/commands/tenants/index.js +0 -23
- package/lib/commands/tenants/list.js +0 -97
- package/lib/commands/tenants/updateConfig.js +0 -188
- package/lib/commands/tenants.js +0 -34
- package/lib/esm/index.js +0 -2312
- package/lib/helpers/api.js +0 -326
- package/lib/helpers/baseBuilder.js +0 -30
- package/lib/helpers/config.js +0 -105
- package/lib/helpers/debug.js +0 -19
- package/lib/helpers/descriptions.js +0 -137
- package/lib/helpers/flow.js +0 -32
- package/lib/helpers/print.js +0 -92
- package/lib/helpers/utils.js +0 -245
- package/lib/index.js +0 -34
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.handler = exports.desc = exports.command = exports.builder = void 0;
|
|
7
|
-
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
|
-
var _promises = require("fs/promises");
|
|
11
|
-
|
|
12
|
-
var _debug = _interopRequireDefault(require("../../helpers/debug.js"));
|
|
13
|
-
|
|
14
|
-
var _ora = _interopRequireDefault(require("ora"));
|
|
15
|
-
|
|
16
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
17
|
-
|
|
18
|
-
var _awsSdk = _interopRequireDefault(require("aws-sdk"));
|
|
19
|
-
|
|
20
|
-
var _cliTable = _interopRequireDefault(require("cli-table"));
|
|
21
|
-
|
|
22
|
-
var _utils = require("../../helpers/utils.js");
|
|
23
|
-
|
|
24
|
-
var _descriptions = _interopRequireDefault(require("../../helpers/descriptions.js"));
|
|
25
|
-
|
|
26
|
-
var _print = require("../../helpers/print.js");
|
|
27
|
-
|
|
28
|
-
var _api = require("../../helpers/api.js");
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
|
-
const debug = (0, _debug.default)('commands:snapshots:deploy');
|
|
33
|
-
const command = 'deploy';
|
|
34
|
-
exports.command = command;
|
|
35
|
-
const desc = 'Deploy Snapshots';
|
|
36
|
-
exports.desc = desc;
|
|
37
|
-
|
|
38
|
-
const builder = async yargs => {
|
|
39
|
-
debug('builder', command);
|
|
40
|
-
return yargs.option('tenant', { ..._descriptions.default.options['tenant'].config,
|
|
41
|
-
default: 'default'
|
|
42
|
-
}).option('sourceFolder', _descriptions.default.options['sourceFolder'].config).demandOption('sourceFolder', _descriptions.default.options['sourceFolder'].demandText);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
exports.builder = builder;
|
|
46
|
-
|
|
47
|
-
const handler = async argv => {
|
|
48
|
-
debug('handler', command, argv);
|
|
49
|
-
const {
|
|
50
|
-
hg,
|
|
51
|
-
json,
|
|
52
|
-
apikey,
|
|
53
|
-
env,
|
|
54
|
-
tenant,
|
|
55
|
-
sourceFolder
|
|
56
|
-
} = argv;
|
|
57
|
-
const {
|
|
58
|
-
clientApiBaseUri
|
|
59
|
-
} = hg;
|
|
60
|
-
let message;
|
|
61
|
-
let spinner = (0, _ora.default)();
|
|
62
|
-
|
|
63
|
-
const folderPrefix = _path.default.resolve(process.cwd(), sourceFolder);
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
message = (0, _print.themed)(`Deploying Snapshots for Tenant ${(0, _print.themed)(tenant, 'info')} to ${(0, _print.themed)(env, 'info')}`);
|
|
67
|
-
!json && spinner.info((0, _print.themed)(`Info: ${message}.`, 'secondary')); // 1. build list of deployable files
|
|
68
|
-
|
|
69
|
-
const deployableFiles = await (0, _utils.getFolderFiles)(folderPrefix, {
|
|
70
|
-
recursive: true
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
if (deployableFiles.length === 0) {
|
|
74
|
-
json ? (0, _print.printJSON)({
|
|
75
|
-
status: 'error',
|
|
76
|
-
error: 'There are no files to deploy at the specified location!'
|
|
77
|
-
}) : spinner.fail((0, _print.themed)(`Error: ${(0, _print.themed)('There are no files to deploy at the specified location!')}.`, 'secondary'));
|
|
78
|
-
return;
|
|
79
|
-
} // 2. get STS credentials
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
message = (0, _print.themed)(`Verifying user and authorizing`);
|
|
83
|
-
const {
|
|
84
|
-
accessKeyId,
|
|
85
|
-
secretAccessKey,
|
|
86
|
-
sessionToken
|
|
87
|
-
} = await (0, _api.genCredentialsOnClientApi)({
|
|
88
|
-
debug,
|
|
89
|
-
baseUri: clientApiBaseUri,
|
|
90
|
-
task: 'snapshot-deploy',
|
|
91
|
-
env,
|
|
92
|
-
tenant,
|
|
93
|
-
apikey
|
|
94
|
-
});
|
|
95
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary')); // create authenticated S3 instance
|
|
96
|
-
|
|
97
|
-
const s3 = new _awsSdk.default.S3({
|
|
98
|
-
accessKeyId,
|
|
99
|
-
secretAccessKey,
|
|
100
|
-
sessionToken
|
|
101
|
-
}); // 3. verify tenant is valid
|
|
102
|
-
|
|
103
|
-
message = (0, _print.themed)(`Validating tenant exists`);
|
|
104
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
105
|
-
|
|
106
|
-
try {
|
|
107
|
-
const {
|
|
108
|
-
CommonPrefixes: tenantFolders
|
|
109
|
-
} = await s3.listObjectsV2({
|
|
110
|
-
Bucket: env,
|
|
111
|
-
Prefix: `${tenant}/`,
|
|
112
|
-
Delimiter: '/'
|
|
113
|
-
}).promise();
|
|
114
|
-
if (tenantFolders.length === 0) throw new Error('Invalid tenant');
|
|
115
|
-
} catch (err) {
|
|
116
|
-
debug('err', err);
|
|
117
|
-
throw new Error(`Tenant doesn't exist. Please check your tenant (-u) argument.`);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
|
|
121
|
-
const rootKey = `${tenant}/snapshots/`;
|
|
122
|
-
const table = new _cliTable.default({
|
|
123
|
-
head: ['File', 'Status']
|
|
124
|
-
}); // 4. cleanup old files
|
|
125
|
-
|
|
126
|
-
message = (0, _print.themed)(`Preparing deployment target`);
|
|
127
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
128
|
-
const {
|
|
129
|
-
Contents
|
|
130
|
-
} = await s3.listObjectsV2({
|
|
131
|
-
Bucket: env,
|
|
132
|
-
Prefix: `${rootKey}`
|
|
133
|
-
}).promise();
|
|
134
|
-
!json && spinner.stop();
|
|
135
|
-
debug('contents', Contents);
|
|
136
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
137
|
-
const filesToDelete = Contents.map(item => ({
|
|
138
|
-
Key: item.Key
|
|
139
|
-
}));
|
|
140
|
-
|
|
141
|
-
if (filesToDelete.length > 0) {
|
|
142
|
-
const delParams = {
|
|
143
|
-
Bucket: env,
|
|
144
|
-
Delete: {
|
|
145
|
-
Objects: filesToDelete,
|
|
146
|
-
Quiet: true
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
await s3.deleteObjects(delParams).promise();
|
|
150
|
-
filesToDelete.forEach(({
|
|
151
|
-
Key
|
|
152
|
-
}) => table.push([Key.substring(rootKey.length), (0, _print.themed)('Deleted', 'warn')]));
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary')); // 5. upload new files
|
|
156
|
-
|
|
157
|
-
for await (const file of deployableFiles) {
|
|
158
|
-
const relativePath = _path.default.relative(sourceFolder, file);
|
|
159
|
-
|
|
160
|
-
const key = `${rootKey}${relativePath}`;
|
|
161
|
-
message = (0, _print.themed)(`Deploying file: ${(0, _print.themed)(relativePath, 'info')}`);
|
|
162
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
163
|
-
const readBuffer = await (0, _promises.readFile)(file);
|
|
164
|
-
const params = {
|
|
165
|
-
Bucket: env,
|
|
166
|
-
Key: key,
|
|
167
|
-
Body: readBuffer
|
|
168
|
-
};
|
|
169
|
-
const res = await s3.putObject(params).promise();
|
|
170
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
|
|
171
|
-
debug('s3-put-res', res);
|
|
172
|
-
table.push([relativePath, (0, _print.themed)('Deployed', 'info')]);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (json) {
|
|
176
|
-
(0, _print.printJSON)({
|
|
177
|
-
status: 'success',
|
|
178
|
-
deployedFiles: deployableFiles
|
|
179
|
-
});
|
|
180
|
-
} else {
|
|
181
|
-
// print results
|
|
182
|
-
(0, _print.cl)(table.toString());
|
|
183
|
-
}
|
|
184
|
-
} catch (err) {
|
|
185
|
-
if (json) {
|
|
186
|
-
(0, _print.printJSON)({
|
|
187
|
-
status: 'error',
|
|
188
|
-
error: err
|
|
189
|
-
});
|
|
190
|
-
} else {
|
|
191
|
-
spinner.fail((0, _print.themed)(`Error: ${message}.`, 'secondary'));
|
|
192
|
-
(0, _print.pr)((0, _print.themed)(`Message: ${(0, _print.themed)(err.message)}`, 'secondary'));
|
|
193
|
-
debug(err);
|
|
194
|
-
|
|
195
|
-
if (err && err.response && err.response.data) {
|
|
196
|
-
debug('response', err.response.data);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
exports.handler = handler;
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.handler = exports.desc = exports.command = exports.builder = void 0;
|
|
7
|
-
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
|
-
var _promises = require("fs/promises");
|
|
11
|
-
|
|
12
|
-
var _fs = require("fs");
|
|
13
|
-
|
|
14
|
-
var _debug = _interopRequireDefault(require("../../helpers/debug.js"));
|
|
15
|
-
|
|
16
|
-
var _ora = _interopRequireDefault(require("ora"));
|
|
17
|
-
|
|
18
|
-
var _cliTable = _interopRequireDefault(require("cli-table"));
|
|
19
|
-
|
|
20
|
-
var _awsSdk = _interopRequireDefault(require("aws-sdk"));
|
|
21
|
-
|
|
22
|
-
var _descriptions = _interopRequireDefault(require("../../helpers/descriptions.js"));
|
|
23
|
-
|
|
24
|
-
var _print = _interopRequireWildcard(require("../../helpers/print.js"));
|
|
25
|
-
|
|
26
|
-
var _utils = require("../../helpers/utils.js");
|
|
27
|
-
|
|
28
|
-
var _api = require("../../helpers/api.js");
|
|
29
|
-
|
|
30
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
-
|
|
32
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
-
|
|
34
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
|
-
|
|
36
|
-
const debug = (0, _debug.default)('commands:snapshots:download');
|
|
37
|
-
const command = 'download';
|
|
38
|
-
exports.command = command;
|
|
39
|
-
const desc = 'Download Snapshots';
|
|
40
|
-
exports.desc = desc;
|
|
41
|
-
|
|
42
|
-
const builder = async yargs => {
|
|
43
|
-
debug('builder', command);
|
|
44
|
-
return yargs.option('downloadTo', _descriptions.default.options['downloadTo'].config).demandOption('downloadTo', _descriptions.default.options['downloadTo'].demandText).option('tenant', { ..._descriptions.default.options['tenant'].config,
|
|
45
|
-
default: 'default'
|
|
46
|
-
}).option('overwrite', _descriptions.default.options['overwrite'].config).demandOption('overwrite', _descriptions.default.options['overwrite'].demandText);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
exports.builder = builder;
|
|
50
|
-
|
|
51
|
-
const handler = async argv => {
|
|
52
|
-
debug('handler', command, argv);
|
|
53
|
-
const {
|
|
54
|
-
hg,
|
|
55
|
-
json,
|
|
56
|
-
apikey,
|
|
57
|
-
env,
|
|
58
|
-
tenant,
|
|
59
|
-
downloadTo,
|
|
60
|
-
overwrite
|
|
61
|
-
} = argv;
|
|
62
|
-
const {
|
|
63
|
-
clientApiBaseUri
|
|
64
|
-
} = hg;
|
|
65
|
-
let message;
|
|
66
|
-
let spinner = (0, _ora.default)();
|
|
67
|
-
|
|
68
|
-
const folderPrefix = _path.default.resolve(process.cwd(), (0, _utils.userSetOption)('downloadTo') ? downloadTo : 'snapshots');
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
// 1. get STS credentials
|
|
72
|
-
message = (0, _print.themed)(`Verifying user and authorizing`);
|
|
73
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
74
|
-
const {
|
|
75
|
-
accessKeyId,
|
|
76
|
-
secretAccessKey,
|
|
77
|
-
sessionToken
|
|
78
|
-
} = await (0, _api.genCredentialsOnClientApi)({
|
|
79
|
-
debug,
|
|
80
|
-
baseUri: clientApiBaseUri,
|
|
81
|
-
task: 'snapshot-download',
|
|
82
|
-
env,
|
|
83
|
-
tenant,
|
|
84
|
-
apikey
|
|
85
|
-
}); // created authenticated S3 instance
|
|
86
|
-
|
|
87
|
-
const s3 = new _awsSdk.default.S3({
|
|
88
|
-
accessKeyId,
|
|
89
|
-
secretAccessKey,
|
|
90
|
-
sessionToken
|
|
91
|
-
});
|
|
92
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary')); // 2. verify tenant is valid
|
|
93
|
-
|
|
94
|
-
message = (0, _print.themed)(`Validating tenant exists`);
|
|
95
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
// this may also throw access denied
|
|
99
|
-
const {
|
|
100
|
-
CommonPrefixes: tenantFolders
|
|
101
|
-
} = await s3.listObjectsV2({
|
|
102
|
-
Bucket: env,
|
|
103
|
-
Prefix: `${tenant}/`,
|
|
104
|
-
Delimiter: '/'
|
|
105
|
-
}).promise();
|
|
106
|
-
if (tenantFolders.length === 0) throw new Error('Invalid tenant');
|
|
107
|
-
} catch (err) {
|
|
108
|
-
debug('err', err);
|
|
109
|
-
throw new Error(`Tenant doesn't exist. Please check your tenant (-u) argument.`);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary')); // 3. get list of downloadable files
|
|
113
|
-
|
|
114
|
-
message = (0, _print.themed)(`Scanning for downloadable files`);
|
|
115
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
116
|
-
const keyPrefix = `${tenant}/snapshots/`;
|
|
117
|
-
const params = {
|
|
118
|
-
Bucket: env,
|
|
119
|
-
Prefix: keyPrefix
|
|
120
|
-
};
|
|
121
|
-
const {
|
|
122
|
-
Contents: s3Files
|
|
123
|
-
} = await s3.listObjectsV2(params).promise();
|
|
124
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
|
|
125
|
-
debug('s3-list-res', s3Files); // filter unwanted files from source
|
|
126
|
-
|
|
127
|
-
const filesToDownload = s3Files ? s3Files.map(item => item.Key).filter(item => item !== keyPrefix) : [];
|
|
128
|
-
|
|
129
|
-
if (!filesToDownload || filesToDownload.length === 0) {
|
|
130
|
-
json ? (0, _print.printJSON)({
|
|
131
|
-
status: 'success',
|
|
132
|
-
downloadedFiles: []
|
|
133
|
-
}) : spinner.warn((0, _print.themed)(`Warning: ${(0, _print.themed)('Nothing to download!')}`, 'secondary'));
|
|
134
|
-
return;
|
|
135
|
-
} // 4. download files
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
message = (0, _print.themed)(`Downloading snapshot files to ${(0, _print.themed)(folderPrefix, 'info')}`);
|
|
139
|
-
!json && spinner.info((0, _print.themed)(`Info: ${message}.`, 'secondary'));
|
|
140
|
-
const table = new _cliTable.default({
|
|
141
|
-
head: ['File', 'Status']
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
for await (const file of filesToDownload) {
|
|
145
|
-
const subPath = file.substring(keyPrefix.length);
|
|
146
|
-
|
|
147
|
-
const fullPath = _path.default.resolve(folderPrefix, subPath);
|
|
148
|
-
|
|
149
|
-
debug('file', fullPath);
|
|
150
|
-
|
|
151
|
-
if (file.endsWith('/')) {
|
|
152
|
-
!(0, _fs.existsSync)(fullPath) && (await (0, _promises.mkdir)(fullPath, {
|
|
153
|
-
recursive: true
|
|
154
|
-
}));
|
|
155
|
-
continue;
|
|
156
|
-
} // skip if exists and overwrite is false
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (!overwrite) {
|
|
160
|
-
try {
|
|
161
|
-
await (0, _promises.stat)(fullPath);
|
|
162
|
-
debug('exists, skipping');
|
|
163
|
-
table.push([subPath, 'Skipped']);
|
|
164
|
-
continue;
|
|
165
|
-
} catch (err) {
|
|
166
|
-
if (err.code !== 'ENOENT') (0, _print.cl)(err);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
message = (0, _print.themed)(`Downloading file: ${(0, _print.themed)(subPath, 'info')}`);
|
|
171
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary')); // ensure destination folder exists
|
|
172
|
-
|
|
173
|
-
await (0, _promises.mkdir)(_path.default.dirname(fullPath), {
|
|
174
|
-
recursive: true
|
|
175
|
-
}); // download s3 object into destination folder
|
|
176
|
-
|
|
177
|
-
const fileStream = s3.getObject({
|
|
178
|
-
Bucket: env,
|
|
179
|
-
Key: file
|
|
180
|
-
}).createReadStream();
|
|
181
|
-
await (0, _promises.writeFile)(fullPath, await (0, _utils.streamToString)(fileStream));
|
|
182
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
|
|
183
|
-
table.push([subPath, 'Downloaded']);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (json) {
|
|
187
|
-
(0, _print.printJSON)({
|
|
188
|
-
status: 'success',
|
|
189
|
-
downloadedFiles: filesToDownload
|
|
190
|
-
});
|
|
191
|
-
} else {
|
|
192
|
-
// print results
|
|
193
|
-
(0, _print.cl)(table.toString());
|
|
194
|
-
}
|
|
195
|
-
} catch (err) {
|
|
196
|
-
if (json) {
|
|
197
|
-
(0, _print.printJSON)({
|
|
198
|
-
status: 'error',
|
|
199
|
-
error: err
|
|
200
|
-
});
|
|
201
|
-
} else {
|
|
202
|
-
spinner.fail((0, _print.themed)(`Error: ${message}.`, 'secondary'));
|
|
203
|
-
(0, _print.pr)((0, _print.themed)(`Message: ${(0, _print.themed)(err.message)}`, 'secondary'));
|
|
204
|
-
debug(err);
|
|
205
|
-
|
|
206
|
-
if (err && err.response && err.response.data) {
|
|
207
|
-
debug('response', err.response.data);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
exports.handler = handler;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.snapshots = void 0;
|
|
7
|
-
|
|
8
|
-
var deploy = _interopRequireWildcard(require("./deploy.js"));
|
|
9
|
-
|
|
10
|
-
var download = _interopRequireWildcard(require("./download.js"));
|
|
11
|
-
|
|
12
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
-
|
|
14
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
-
|
|
16
|
-
const snapshots = [deploy, download];
|
|
17
|
-
exports.snapshots = snapshots;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.handler = exports.desc = exports.command = exports.builder = void 0;
|
|
7
|
-
|
|
8
|
-
var _debug = _interopRequireDefault(require("../helpers/debug.js"));
|
|
9
|
-
|
|
10
|
-
var _baseBuilder = require("../helpers/baseBuilder.js");
|
|
11
|
-
|
|
12
|
-
var _index = require("./snapshots/index.js");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
const debug = (0, _debug.default)('commands:snapshots');
|
|
17
|
-
const command = 'snapshots <action>';
|
|
18
|
-
exports.command = command;
|
|
19
|
-
const desc = 'Manage tenant snapshots';
|
|
20
|
-
exports.desc = desc;
|
|
21
|
-
|
|
22
|
-
const builder = async function (yargs) {
|
|
23
|
-
debug('builder', command, yargs);
|
|
24
|
-
const base = await (0, _baseBuilder.baseApiBuilder)(yargs);
|
|
25
|
-
return base.command(_index.snapshots);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
exports.builder = builder;
|
|
29
|
-
|
|
30
|
-
const handler = async function (argv) {
|
|
31
|
-
debug('handler', command, argv);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
exports.handler = handler;
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.handler = exports.desc = exports.command = exports.builder = void 0;
|
|
7
|
-
|
|
8
|
-
var _debug = _interopRequireDefault(require("../../helpers/debug.js"));
|
|
9
|
-
|
|
10
|
-
var _ora = _interopRequireDefault(require("ora"));
|
|
11
|
-
|
|
12
|
-
var _awsSdk = _interopRequireDefault(require("aws-sdk"));
|
|
13
|
-
|
|
14
|
-
var _cliTable = _interopRequireDefault(require("cli-table"));
|
|
15
|
-
|
|
16
|
-
var _descriptions = _interopRequireDefault(require("../../helpers/descriptions.js"));
|
|
17
|
-
|
|
18
|
-
var _print = require("../../helpers/print.js");
|
|
19
|
-
|
|
20
|
-
var _api = require("../../helpers/api.js");
|
|
21
|
-
|
|
22
|
-
var _utils = require("../../helpers/utils.js");
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
const debug = (0, _debug.default)('commands:tenants:custom-catalog');
|
|
27
|
-
const command = 'custom-catalog';
|
|
28
|
-
exports.command = command;
|
|
29
|
-
const desc = 'List tenants with custom catalog in a specific flow';
|
|
30
|
-
exports.desc = desc;
|
|
31
|
-
|
|
32
|
-
const builder = async yargs => {
|
|
33
|
-
debug('builder', command);
|
|
34
|
-
return yargs.option('tenant', _descriptions.default.options['tenant'].config).option('flow', _descriptions.default.options['flow'].config).demandOption('flow', _descriptions.default.options['flow'].demandText);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
exports.builder = builder;
|
|
38
|
-
|
|
39
|
-
const processTenant = async ({
|
|
40
|
-
debug,
|
|
41
|
-
baseUri,
|
|
42
|
-
apikey,
|
|
43
|
-
env,
|
|
44
|
-
flow,
|
|
45
|
-
tenant,
|
|
46
|
-
isV2Flow
|
|
47
|
-
}) => {
|
|
48
|
-
try {
|
|
49
|
-
// Get all linked connectors/sources of the tuple (env, flow, tenant)
|
|
50
|
-
const linkedConnectors = isV2Flow ? await (0, _api.getLinkedConnectors)({
|
|
51
|
-
debug,
|
|
52
|
-
baseUri,
|
|
53
|
-
env,
|
|
54
|
-
flow,
|
|
55
|
-
tenant,
|
|
56
|
-
apikey
|
|
57
|
-
}) : await (0, _api.getLinkedSources)({
|
|
58
|
-
debug,
|
|
59
|
-
baseUri,
|
|
60
|
-
env,
|
|
61
|
-
flow,
|
|
62
|
-
tenant,
|
|
63
|
-
apikey
|
|
64
|
-
});
|
|
65
|
-
const connectors = []; // Generate AWS credentials in order to read the S3 tap folder
|
|
66
|
-
|
|
67
|
-
const {
|
|
68
|
-
accessKeyId,
|
|
69
|
-
secretAccessKey,
|
|
70
|
-
sessionToken
|
|
71
|
-
} = await (0, _api.genCredentialsOnClientApi)({
|
|
72
|
-
debug,
|
|
73
|
-
baseUri,
|
|
74
|
-
task: 'field-map-download',
|
|
75
|
-
env,
|
|
76
|
-
tenant,
|
|
77
|
-
flow,
|
|
78
|
-
apikey
|
|
79
|
-
});
|
|
80
|
-
const s3 = new _awsSdk.default.S3({
|
|
81
|
-
accessKeyId,
|
|
82
|
-
secretAccessKey,
|
|
83
|
-
sessionToken
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
for (const {
|
|
87
|
-
id,
|
|
88
|
-
tap
|
|
89
|
-
} of linkedConnectors) {
|
|
90
|
-
const entityLabel = isV2Flow ? 'connectors' : 'taps';
|
|
91
|
-
const params = {
|
|
92
|
-
Bucket: env,
|
|
93
|
-
Key: `${tenant}/flows/${flow}/${entityLabel}/${isV2Flow ? id : tap}/catalog.json`
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
await s3.headObject(params).promise();
|
|
98
|
-
connectors.push(isV2Flow ? id : tap);
|
|
99
|
-
} catch (error) {// Does not have catalog.json
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
tenant,
|
|
105
|
-
connectors
|
|
106
|
-
};
|
|
107
|
-
} catch (error) {
|
|
108
|
-
console.error(error);
|
|
109
|
-
return {
|
|
110
|
-
tenant,
|
|
111
|
-
connectors: []
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const handler = async argv => {
|
|
117
|
-
debug('handler', command, argv);
|
|
118
|
-
const {
|
|
119
|
-
hg,
|
|
120
|
-
json,
|
|
121
|
-
apikey,
|
|
122
|
-
env,
|
|
123
|
-
flow
|
|
124
|
-
} = argv;
|
|
125
|
-
let message;
|
|
126
|
-
let spinner = (0, _ora.default)();
|
|
127
|
-
|
|
128
|
-
try {
|
|
129
|
-
message = (0, _print.themed)(`Retrieving tenants for environment ${(0, _print.themed)(env, 'info')}`);
|
|
130
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
131
|
-
const [allTenants, supportedFlow] = await Promise.all([(0, _api.getTenants)({
|
|
132
|
-
debug,
|
|
133
|
-
baseUri: hg.clientApiBaseUri,
|
|
134
|
-
apikey,
|
|
135
|
-
env
|
|
136
|
-
}), (0, _api.getSupportedFlow)({
|
|
137
|
-
debug,
|
|
138
|
-
baseUri: hg.clientApiBaseUri,
|
|
139
|
-
apikey,
|
|
140
|
-
env,
|
|
141
|
-
flow
|
|
142
|
-
})]);
|
|
143
|
-
const isV2Flow = (supportedFlow === null || supportedFlow === void 0 ? void 0 : supportedFlow.version) === 2;
|
|
144
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
|
|
145
|
-
const tenantsWithCustomFieldMap = [];
|
|
146
|
-
message = (0, _print.themed)(`Querying for custom catalogs for flow ${(0, _print.themed)(flow, 'info')}`);
|
|
147
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary')); // Break the tenants array in to an array of arrays so we can make
|
|
148
|
-
// parallel calls and make it faster
|
|
149
|
-
|
|
150
|
-
for (const tenants of (0, _utils.buildChunks)(allTenants)) {
|
|
151
|
-
const maybeTenantsWithCustomFieldMap = await Promise.all(tenants.map(tenant => processTenant({
|
|
152
|
-
debug,
|
|
153
|
-
baseUri: hg.clientApiBaseUri,
|
|
154
|
-
apikey,
|
|
155
|
-
env,
|
|
156
|
-
flow,
|
|
157
|
-
tenant,
|
|
158
|
-
isV2Flow
|
|
159
|
-
})));
|
|
160
|
-
tenantsWithCustomFieldMap.push(...maybeTenantsWithCustomFieldMap.filter(({
|
|
161
|
-
connectors
|
|
162
|
-
}) => connectors.length > 0));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
|
|
166
|
-
|
|
167
|
-
if (json) {
|
|
168
|
-
(0, _print.printJSON)(tenantsWithCustomFieldMap);
|
|
169
|
-
} else {
|
|
170
|
-
// generate results table
|
|
171
|
-
const table = new _cliTable.default({
|
|
172
|
-
head: ['Tenant ID', 'Connector IDs']
|
|
173
|
-
});
|
|
174
|
-
table.push(...tenantsWithCustomFieldMap.map(({
|
|
175
|
-
tenant,
|
|
176
|
-
connectors
|
|
177
|
-
}) => [tenant, connectors.join(', ')])); // print results
|
|
178
|
-
|
|
179
|
-
console.log(table.toString());
|
|
180
|
-
}
|
|
181
|
-
} catch (err) {
|
|
182
|
-
if (json) {
|
|
183
|
-
(0, _print.printJSON)({
|
|
184
|
-
status: 'error',
|
|
185
|
-
error: err
|
|
186
|
-
});
|
|
187
|
-
} else {
|
|
188
|
-
spinner.fail((0, _print.themed)(`Error: ${message}.`, 'secondary'));
|
|
189
|
-
(0, _print.pr)((0, _print.themed)(`Message: ${(0, _print.themed)(err.message)}`, 'secondary'));
|
|
190
|
-
debug(err);
|
|
191
|
-
|
|
192
|
-
if (err && err.response && err.response.data) {
|
|
193
|
-
debug('response', err.response.data);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
exports.handler = handler;
|