@hotglue/cli 1.0.25
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 +94 -0
- package/lib/commands/config/index.js +15 -0
- package/lib/commands/config/set.js +82 -0
- package/lib/commands/config.js +71 -0
- package/lib/commands/env/deploy.js +162 -0
- package/lib/commands/env/download.js +169 -0
- package/lib/commands/env/index.js +17 -0
- package/lib/commands/env.js +34 -0
- package/lib/commands/etl/delete.js +171 -0
- package/lib/commands/etl/deploy.js +261 -0
- package/lib/commands/etl/download.js +205 -0
- package/lib/commands/etl/index.js +19 -0
- package/lib/commands/etl.js +34 -0
- package/lib/commands/flows/index.js +15 -0
- package/lib/commands/flows/list.js +104 -0
- package/lib/commands/flows.js +34 -0
- package/lib/commands/index.js +27 -0
- package/lib/commands/jobs/download.js +188 -0
- package/lib/commands/jobs/index.js +17 -0
- package/lib/commands/jobs/list.js +108 -0
- package/lib/commands/jobs.js +34 -0
- package/lib/commands/snapshots/deploy.js +202 -0
- package/lib/commands/snapshots/download.js +213 -0
- package/lib/commands/snapshots/index.js +17 -0
- package/lib/commands/snapshots.js +34 -0
- package/lib/commands/tenants/customCatalog.js +199 -0
- package/lib/commands/tenants/customEtl.js +183 -0
- package/lib/commands/tenants/customFieldMap.js +191 -0
- package/lib/commands/tenants/delete.js +150 -0
- package/lib/commands/tenants/index.js +23 -0
- package/lib/commands/tenants/list.js +97 -0
- package/lib/commands/tenants/updateConfig.js +188 -0
- package/lib/commands/tenants.js +34 -0
- package/lib/esm/index.js +2312 -0
- package/lib/helpers/api.js +326 -0
- package/lib/helpers/baseBuilder.js +30 -0
- package/lib/helpers/config.js +105 -0
- package/lib/helpers/debug.js +19 -0
- package/lib/helpers/descriptions.js +137 -0
- package/lib/helpers/flow.js +32 -0
- package/lib/helpers/print.js +92 -0
- package/lib/helpers/utils.js +245 -0
- package/lib/index.js +34 -0
- package/package.json +80 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.flows = void 0;
|
|
7
|
+
|
|
8
|
+
var list = _interopRequireWildcard(require("./list.js"));
|
|
9
|
+
|
|
10
|
+
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); }
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
const flows = [list];
|
|
15
|
+
exports.flows = flows;
|
|
@@ -0,0 +1,104 @@
|
|
|
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 _util = require("util");
|
|
9
|
+
|
|
10
|
+
var _debug = _interopRequireDefault(require("../../helpers/debug.js"));
|
|
11
|
+
|
|
12
|
+
var _ora = _interopRequireDefault(require("ora"));
|
|
13
|
+
|
|
14
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
15
|
+
|
|
16
|
+
var _cliTable = _interopRequireDefault(require("cli-table"));
|
|
17
|
+
|
|
18
|
+
var _descriptions = _interopRequireDefault(require("../../helpers/descriptions.js"));
|
|
19
|
+
|
|
20
|
+
var _print = require("../../helpers/print.js");
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
const debug = (0, _debug.default)('commands:flows:list');
|
|
25
|
+
const command = 'list';
|
|
26
|
+
exports.command = command;
|
|
27
|
+
const desc = 'List flows';
|
|
28
|
+
exports.desc = desc;
|
|
29
|
+
|
|
30
|
+
const builder = async yargs => {
|
|
31
|
+
debug('builder', command);
|
|
32
|
+
return yargs.option('tenant', { ..._descriptions.default.options['tenant'].config
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.builder = builder;
|
|
37
|
+
|
|
38
|
+
const handler = async argv => {
|
|
39
|
+
debug('handler', command, argv);
|
|
40
|
+
const {
|
|
41
|
+
hg,
|
|
42
|
+
json,
|
|
43
|
+
apikey,
|
|
44
|
+
env,
|
|
45
|
+
tenant
|
|
46
|
+
} = argv;
|
|
47
|
+
const {
|
|
48
|
+
clientApiBaseUri
|
|
49
|
+
} = hg;
|
|
50
|
+
let message;
|
|
51
|
+
let spinner = (0, _ora.default)();
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
// 1. get data from client-api backend
|
|
55
|
+
message = (0, _print.themed)(`Retrieving ${!tenant ? `the` : `${(0, _print.themed)(tenant, 'info')} tenant's`} flows for environment: ${(0, _print.themed)(env, 'info')}`); // todo: look into changing when if client-api combined these two endpoints
|
|
56
|
+
|
|
57
|
+
const uri = `${clientApiBaseUri}/${env}/flows/${tenant ? `linked?user_id=${tenant}` : `supported`}`;
|
|
58
|
+
debug('requesting:', uri);
|
|
59
|
+
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
60
|
+
const {
|
|
61
|
+
data
|
|
62
|
+
} = await _axios.default.get(uri, {
|
|
63
|
+
headers: {
|
|
64
|
+
'x-api-key': apikey
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
|
|
68
|
+
debug('response-data', data); // exit if there is no data
|
|
69
|
+
|
|
70
|
+
if (!data || data.length === 0) {
|
|
71
|
+
json ? (0, _print.printJSON)([]) : spinner.warn((0, _print.themed)(`Warning: ${(0, _print.themed)('No flows for specified environment and tenant')}.`, 'secondary'));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (json) {
|
|
76
|
+
(0, _print.printJSON)(data);
|
|
77
|
+
} else {
|
|
78
|
+
// generate results table
|
|
79
|
+
const table = new _cliTable.default({
|
|
80
|
+
head: ['ID', 'Name', 'isPush', 'Taps', 'Targets']
|
|
81
|
+
});
|
|
82
|
+
data.forEach(item => table.push([item.id, item.name || '', item.type || false, item.taps ? (0, _util.inspect)(item.taps) : '', item.targets ? (0, _util.inspect)(item.targets) : 'none'])); // print results
|
|
83
|
+
|
|
84
|
+
console.log(table.toString());
|
|
85
|
+
}
|
|
86
|
+
} catch (err) {
|
|
87
|
+
if (json) {
|
|
88
|
+
(0, _print.printJSON)({
|
|
89
|
+
status: 'error',
|
|
90
|
+
error: err
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
spinner.fail((0, _print.themed)(`Error: ${message}.`, 'secondary'));
|
|
94
|
+
(0, _print.pr)((0, _print.themed)(`Message: ${(0, _print.themed)(err.message)}`, 'secondary'));
|
|
95
|
+
debug(err);
|
|
96
|
+
|
|
97
|
+
if (err && err.response && err.response.data) {
|
|
98
|
+
debug('response', err.response.data);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
exports.handler = handler;
|
|
@@ -0,0 +1,34 @@
|
|
|
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("./flows/index.js");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const debug = (0, _debug.default)('commands:flows');
|
|
17
|
+
const command = 'flows <action>';
|
|
18
|
+
exports.command = command;
|
|
19
|
+
const desc = 'Manage flows';
|
|
20
|
+
exports.desc = desc;
|
|
21
|
+
|
|
22
|
+
const builder = async function (yargs) {
|
|
23
|
+
debug('builder', command);
|
|
24
|
+
const base = await (0, _baseBuilder.baseApiBuilder)(yargs);
|
|
25
|
+
return base.command(_index.flows);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.builder = builder;
|
|
29
|
+
|
|
30
|
+
const handler = async function (argv) {
|
|
31
|
+
debug('handler', command, argv);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.handler = handler;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.commands = void 0;
|
|
7
|
+
|
|
8
|
+
var config = _interopRequireWildcard(require("./config.js"));
|
|
9
|
+
|
|
10
|
+
var env = _interopRequireWildcard(require("./env.js"));
|
|
11
|
+
|
|
12
|
+
var etl = _interopRequireWildcard(require("./etl.js"));
|
|
13
|
+
|
|
14
|
+
var flows = _interopRequireWildcard(require("./flows.js"));
|
|
15
|
+
|
|
16
|
+
var jobs = _interopRequireWildcard(require("./jobs.js"));
|
|
17
|
+
|
|
18
|
+
var snapshots = _interopRequireWildcard(require("./snapshots.js"));
|
|
19
|
+
|
|
20
|
+
var tenants = _interopRequireWildcard(require("./tenants.js"));
|
|
21
|
+
|
|
22
|
+
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); }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
const commands = [config, env, etl, flows, jobs, snapshots, tenants];
|
|
27
|
+
exports.commands = commands;
|
|
@@ -0,0 +1,188 @@
|
|
|
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("node: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 = require("../../helpers/print.js");
|
|
25
|
+
|
|
26
|
+
var _api = require("../../helpers/api.js");
|
|
27
|
+
|
|
28
|
+
var _eachSeries = _interopRequireDefault(require("async/eachSeries.js"));
|
|
29
|
+
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
+
|
|
32
|
+
const debug = (0, _debug.default)('commands:jobs:download');
|
|
33
|
+
const command = 'download <jobroot>';
|
|
34
|
+
exports.command = command;
|
|
35
|
+
const desc = 'Download Job files';
|
|
36
|
+
exports.desc = desc;
|
|
37
|
+
|
|
38
|
+
const builder = async yargs => {
|
|
39
|
+
debug('builder', command);
|
|
40
|
+
return yargs.option('downloadTo', _descriptions.default.options['downloadTo'].config); // .option('jobroot', descriptions.options['jobroot'].config)
|
|
41
|
+
// .demandOption('jobroot', descriptions.options['jobroot'].demandText)
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
exports.builder = builder;
|
|
45
|
+
|
|
46
|
+
const handler = async argv => {
|
|
47
|
+
debug('handler', command, argv);
|
|
48
|
+
const {
|
|
49
|
+
hg,
|
|
50
|
+
json,
|
|
51
|
+
apikey,
|
|
52
|
+
env,
|
|
53
|
+
jobroot,
|
|
54
|
+
downloadTo
|
|
55
|
+
} = argv;
|
|
56
|
+
const {
|
|
57
|
+
clientApiBaseUri
|
|
58
|
+
} = hg;
|
|
59
|
+
let message;
|
|
60
|
+
let spinner = (0, _ora.default)();
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
// 1. get STS credentials
|
|
64
|
+
message = (0, _print.themed)(`Verifying user and authorizing`);
|
|
65
|
+
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
66
|
+
const {
|
|
67
|
+
accessKeyId,
|
|
68
|
+
secretAccessKey,
|
|
69
|
+
sessionToken
|
|
70
|
+
} = await (0, _api.genCredentialsOnClientApi)({
|
|
71
|
+
debug,
|
|
72
|
+
baseUri: clientApiBaseUri,
|
|
73
|
+
task: 'job-download',
|
|
74
|
+
env,
|
|
75
|
+
apikey,
|
|
76
|
+
jobroot
|
|
77
|
+
}); // get data from AWS bucket
|
|
78
|
+
|
|
79
|
+
const s3 = new _awsSdk.default.S3({
|
|
80
|
+
accessKeyId,
|
|
81
|
+
secretAccessKey,
|
|
82
|
+
sessionToken
|
|
83
|
+
});
|
|
84
|
+
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary')); // 2. get list of available files
|
|
85
|
+
|
|
86
|
+
message = (0, _print.themed)(`Scanning for downloadable files`);
|
|
87
|
+
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
88
|
+
const params = {
|
|
89
|
+
Bucket: env,
|
|
90
|
+
Prefix: jobroot
|
|
91
|
+
};
|
|
92
|
+
const {
|
|
93
|
+
Contents: filesList
|
|
94
|
+
} = await s3.listObjectsV2(params).promise();
|
|
95
|
+
debug('res', filesList);
|
|
96
|
+
|
|
97
|
+
if (!filesList || filesList.length === 0) {
|
|
98
|
+
if (json) {
|
|
99
|
+
(0, _print.printJSON)({
|
|
100
|
+
status: 'error',
|
|
101
|
+
error: 'Nothing to download!'
|
|
102
|
+
});
|
|
103
|
+
} else {
|
|
104
|
+
spinner.fail((0, _print.themed)(`Error: ${message}.`, 'secondary'));
|
|
105
|
+
(0, _print.pr)((0, _print.themed)(`Message: ${(0, _print.themed)('Nothing to download!')}`, 'secondary'));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
|
|
112
|
+
|
|
113
|
+
if (!json) {
|
|
114
|
+
// print remote files
|
|
115
|
+
const table = new _cliTable.default({
|
|
116
|
+
head: ['File', 'Size', 'LastModified']
|
|
117
|
+
});
|
|
118
|
+
filesList.forEach(item => {
|
|
119
|
+
const subPath = item.Key.substring(jobroot.length + 1); // const details = { LastModified: item.LastModified, Size: item.Size };
|
|
120
|
+
|
|
121
|
+
table.push([subPath, item.Size, item.LastModified.toLocaleString('en-US')]); // JSON.stringify(details, undefined, 2)]);
|
|
122
|
+
});
|
|
123
|
+
console.log(table.toString());
|
|
124
|
+
} // 3. download job files one-by-one
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
const localRoot = _path.default.resolve(process.cwd(), downloadTo, _path.default.basename(jobroot));
|
|
128
|
+
|
|
129
|
+
await (0, _eachSeries.default)( // Filter out tap/target config files
|
|
130
|
+
filesList.filter(({
|
|
131
|
+
Key
|
|
132
|
+
}) => {
|
|
133
|
+
// Filter out all *-config.json files in the root of "jobroo"
|
|
134
|
+
const regex = new RegExp(`${jobroot}/([^\/]+)-config\.json`);
|
|
135
|
+
return !regex.test(Key);
|
|
136
|
+
}), async item => {
|
|
137
|
+
message = (0, _print.themed)(`Downloading file: ${(0, _print.themed)(item.Key, 'info')}`);
|
|
138
|
+
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
139
|
+
|
|
140
|
+
const file = _path.default.resolve(localRoot, item.Key.substring(jobroot.length + 1));
|
|
141
|
+
|
|
142
|
+
debug('file', file); // ensure destination folder exists
|
|
143
|
+
|
|
144
|
+
await (0, _promises.mkdir)(_path.default.dirname(file), {
|
|
145
|
+
recursive: true
|
|
146
|
+
}); // download s3 object into destination folder
|
|
147
|
+
|
|
148
|
+
const fileStream = s3.getObject({
|
|
149
|
+
Bucket: env,
|
|
150
|
+
Key: item.Key
|
|
151
|
+
}).createReadStream();
|
|
152
|
+
const writableStream = (0, _fs.createWriteStream)(file, {
|
|
153
|
+
flags: 'w'
|
|
154
|
+
});
|
|
155
|
+
fileStream.pipe(writableStream);
|
|
156
|
+
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
|
|
157
|
+
}); // print final success message
|
|
158
|
+
|
|
159
|
+
if (json) {
|
|
160
|
+
(0, _print.printJSON)({
|
|
161
|
+
status: 'success',
|
|
162
|
+
downloadedFiles: filesList.map(({
|
|
163
|
+
Key
|
|
164
|
+
}) => Key)
|
|
165
|
+
});
|
|
166
|
+
} else {
|
|
167
|
+
message = (0, _print.themed)(`Downloading job files.`);
|
|
168
|
+
spinner.succeed((0, _print.themed)(`Finished: ${message}`, 'secondary'));
|
|
169
|
+
}
|
|
170
|
+
} catch (err) {
|
|
171
|
+
if (json) {
|
|
172
|
+
(0, _print.printJSON)({
|
|
173
|
+
status: 'error',
|
|
174
|
+
error: err
|
|
175
|
+
});
|
|
176
|
+
} else {
|
|
177
|
+
spinner.fail((0, _print.themed)(`Error: ${message}.`, 'secondary'));
|
|
178
|
+
(0, _print.pr)((0, _print.themed)(`Message: ${(0, _print.themed)(err.message)}`, 'secondary'));
|
|
179
|
+
debug(err);
|
|
180
|
+
|
|
181
|
+
if (err && err.response && err.response.data) {
|
|
182
|
+
debug('response', err.response.data);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
exports.handler = handler;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.jobs = void 0;
|
|
7
|
+
|
|
8
|
+
var download = _interopRequireWildcard(require("./download.js"));
|
|
9
|
+
|
|
10
|
+
var list = _interopRequireWildcard(require("./list.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 jobs = [download, list];
|
|
17
|
+
exports.jobs = jobs;
|
|
@@ -0,0 +1,108 @@
|
|
|
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 _axios = _interopRequireDefault(require("axios"));
|
|
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
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
const debug = (...args) => {
|
|
23
|
+
const debug = (0, _debug.default)('commands:jobs:list');
|
|
24
|
+
debug(...args);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const command = 'list';
|
|
28
|
+
exports.command = command;
|
|
29
|
+
const desc = 'List jobs';
|
|
30
|
+
exports.desc = desc;
|
|
31
|
+
|
|
32
|
+
const builder = async yargs => {
|
|
33
|
+
debug('builder', command);
|
|
34
|
+
return yargs.option('flow', _descriptions.default.options['flow'].config).demandOption('flow', _descriptions.default.options['flow'].demandText).option('tenant', { ..._descriptions.default.options['tenant'].config,
|
|
35
|
+
default: 'default'
|
|
36
|
+
}).option('count', _descriptions.default.options['count'].config);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.builder = builder;
|
|
40
|
+
|
|
41
|
+
const handler = async argv => {
|
|
42
|
+
debug('handler', command, argv);
|
|
43
|
+
const {
|
|
44
|
+
hg,
|
|
45
|
+
json,
|
|
46
|
+
apikey,
|
|
47
|
+
env,
|
|
48
|
+
flow,
|
|
49
|
+
tenant,
|
|
50
|
+
count
|
|
51
|
+
} = argv;
|
|
52
|
+
const {
|
|
53
|
+
clientApiBaseUri
|
|
54
|
+
} = hg;
|
|
55
|
+
let message;
|
|
56
|
+
let spinner = (0, _ora.default)();
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
// 1. get data from client-api backend
|
|
60
|
+
message = (0, _print.themed)(`Retrieving jobs for environment: ${(0, _print.themed)(env, 'info')} flow: ${(0, _print.themed)(flow, 'info')} tenant: ${(0, _print.themed)(tenant, 'info')}...`);
|
|
61
|
+
const uri = `${clientApiBaseUri}/${env}/${flow}/${tenant}/jobs${count ? `?count=${count}` : ''}`;
|
|
62
|
+
debug('requesting:', uri);
|
|
63
|
+
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
64
|
+
const {
|
|
65
|
+
data
|
|
66
|
+
} = await _axios.default.get(uri, {
|
|
67
|
+
headers: {
|
|
68
|
+
'x-api-key': apikey
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
|
|
72
|
+
debug('response-data', data); // exit if there is no data
|
|
73
|
+
|
|
74
|
+
if (!data || data.length === 0) {
|
|
75
|
+
json ? (0, _print.printJSON)([]) : spinner.warn((0, _print.themed)(`Warning: ${(0, _print.themed)('No jobs for the specified environment, flow and tenant')}.`, 'secondary'));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (json) {
|
|
80
|
+
(0, _print.printJSON)(data);
|
|
81
|
+
} else {
|
|
82
|
+
// generate results table
|
|
83
|
+
const table = new _cliTable.default({
|
|
84
|
+
head: ['name', 'details']
|
|
85
|
+
});
|
|
86
|
+
data.forEach(item => table.push([item.job_name, JSON.stringify(item, undefined, 2)])); // print results
|
|
87
|
+
|
|
88
|
+
console.log(table.toString());
|
|
89
|
+
}
|
|
90
|
+
} catch (err) {
|
|
91
|
+
if (json) {
|
|
92
|
+
(0, _print.printJSON)({
|
|
93
|
+
status: 'error',
|
|
94
|
+
error: err
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
spinner.fail((0, _print.themed)(`Error: ${message}.`, 'secondary'));
|
|
98
|
+
(0, _print.pr)((0, _print.themed)(`Message: ${(0, _print.themed)(err.message)}`, 'secondary'));
|
|
99
|
+
debug(err);
|
|
100
|
+
|
|
101
|
+
if (err && err.response && err.response.data) {
|
|
102
|
+
debug('response', err.response.data);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
exports.handler = handler;
|
|
@@ -0,0 +1,34 @@
|
|
|
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("./jobs/index.js");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const debug = (0, _debug.default)('commands:jobs');
|
|
17
|
+
const command = 'jobs <action>';
|
|
18
|
+
exports.command = command;
|
|
19
|
+
const desc = 'Manage ETL jobs';
|
|
20
|
+
exports.desc = desc;
|
|
21
|
+
|
|
22
|
+
const builder = async function (yargs) {
|
|
23
|
+
debug('builder', command);
|
|
24
|
+
const base = await (0, _baseBuilder.baseApiBuilder)(yargs);
|
|
25
|
+
return base.command(_index.jobs);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.builder = builder;
|
|
29
|
+
|
|
30
|
+
const handler = async function (argv) {
|
|
31
|
+
debug('handler', command, argv);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.handler = handler;
|