@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,188 +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 _cliTable = _interopRequireDefault(require("cli-table"));
|
|
13
|
-
|
|
14
|
-
var _descriptions = _interopRequireDefault(require("../../helpers/descriptions.js"));
|
|
15
|
-
|
|
16
|
-
var _print = require("../../helpers/print.js");
|
|
17
|
-
|
|
18
|
-
var _api = require("../../helpers/api.js");
|
|
19
|
-
|
|
20
|
-
var _utils = require("../../helpers/utils.js");
|
|
21
|
-
|
|
22
|
-
var _fs = require("fs");
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
const debug = (0, _debug.default)('commands:tenants:update-config');
|
|
27
|
-
const command = 'update-config';
|
|
28
|
-
exports.command = command;
|
|
29
|
-
const desc = 'Update the config of a specific connector and flow for all tenants';
|
|
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('connector', _descriptions.default.options['connector'].config).demandOption('connector', _descriptions.default.options['connector'].demandText).option('configFilePath', _descriptions.default.options['configFilePath'].config).demandOption('configFilePath', _descriptions.default.options['configFilePath'].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
|
-
connectorId,
|
|
47
|
-
config,
|
|
48
|
-
isV2Flow
|
|
49
|
-
}) => {
|
|
50
|
-
const lookupKey = isV2Flow ? 'id' : 'tap'; // Get all linked connectors/sources of the tuple (env, flow, tenant)
|
|
51
|
-
|
|
52
|
-
const linkedConnectors = isV2Flow ? await (0, _api.getLinkedConnectors)({
|
|
53
|
-
debug,
|
|
54
|
-
baseUri,
|
|
55
|
-
env,
|
|
56
|
-
flow,
|
|
57
|
-
tenant,
|
|
58
|
-
apikey,
|
|
59
|
-
config: true
|
|
60
|
-
}) : await (0, _api.getLinkedSources)({
|
|
61
|
-
debug,
|
|
62
|
-
baseUri,
|
|
63
|
-
env,
|
|
64
|
-
flow,
|
|
65
|
-
tenant,
|
|
66
|
-
apikey,
|
|
67
|
-
config: true
|
|
68
|
-
});
|
|
69
|
-
const connector = linkedConnectors.find(c => c[lookupKey] === connectorId);
|
|
70
|
-
if (!connector) return null;
|
|
71
|
-
const patchFunction = isV2Flow ? _api.patchLinkedConnectorConfig : _api.patchLinkedSourceConfig;
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
await patchFunction({
|
|
75
|
-
debug,
|
|
76
|
-
baseUri,
|
|
77
|
-
env,
|
|
78
|
-
flow,
|
|
79
|
-
tenant,
|
|
80
|
-
apikey,
|
|
81
|
-
connectorId,
|
|
82
|
-
config
|
|
83
|
-
});
|
|
84
|
-
} catch (e) {
|
|
85
|
-
console.log((0, _print.themed)(`Error patching: ${tenant}. ${e}`, 'secondary'));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return tenant;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const handler = async argv => {
|
|
92
|
-
debug('handler', command, argv);
|
|
93
|
-
const {
|
|
94
|
-
hg,
|
|
95
|
-
json,
|
|
96
|
-
apikey,
|
|
97
|
-
env,
|
|
98
|
-
flow,
|
|
99
|
-
connector,
|
|
100
|
-
configFilePath
|
|
101
|
-
} = argv;
|
|
102
|
-
let message;
|
|
103
|
-
let spinner = (0, _ora.default)();
|
|
104
|
-
|
|
105
|
-
try {
|
|
106
|
-
if (!configFilePath) {
|
|
107
|
-
throw new Error('Config file path not provided');
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (!configFilePath.endsWith('.json')) {
|
|
111
|
-
throw new Error('Config file must have .json extension');
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (!(0, _fs.existsSync)(configFilePath)) {
|
|
115
|
-
throw new Error('Config file not found');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const config = JSON.parse((0, _fs.readFileSync)(configFilePath, {
|
|
119
|
-
encoding: 'utf-8'
|
|
120
|
-
}));
|
|
121
|
-
message = (0, _print.themed)(`Retrieving tenants for environment ${(0, _print.themed)(env, 'info')}`);
|
|
122
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
123
|
-
const [allTenants, supportedFlow] = await Promise.all([(0, _api.getTenants)({
|
|
124
|
-
debug,
|
|
125
|
-
baseUri: hg.clientApiBaseUri,
|
|
126
|
-
apikey,
|
|
127
|
-
env
|
|
128
|
-
}), (0, _api.getSupportedFlow)({
|
|
129
|
-
debug,
|
|
130
|
-
baseUri: hg.clientApiBaseUri,
|
|
131
|
-
apikey,
|
|
132
|
-
env,
|
|
133
|
-
flow
|
|
134
|
-
})]);
|
|
135
|
-
const isV2Flow = (supportedFlow === null || supportedFlow === void 0 ? void 0 : supportedFlow.version) === 2;
|
|
136
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
|
|
137
|
-
const tenantsUpdated = [];
|
|
138
|
-
message = (0, _print.themed)(`Updating config for connector ${(0, _print.themed)(connector, 'info')} and flow ${(0, _print.themed)(flow, 'info')}`);
|
|
139
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary')); // Break the tenants array in to an array of arrays so we can make
|
|
140
|
-
// parallel calls and make it faster
|
|
141
|
-
|
|
142
|
-
for (const tenants of (0, _utils.buildChunks)(allTenants)) {
|
|
143
|
-
const maybeTenantsUpdated = await Promise.all(tenants.map(tenant => processTenant({
|
|
144
|
-
debug,
|
|
145
|
-
baseUri: hg.clientApiBaseUri,
|
|
146
|
-
apikey,
|
|
147
|
-
env,
|
|
148
|
-
flow,
|
|
149
|
-
tenant,
|
|
150
|
-
connectorId: connector,
|
|
151
|
-
config,
|
|
152
|
-
isV2Flow
|
|
153
|
-
})));
|
|
154
|
-
tenantsUpdated.push(...maybeTenantsUpdated.filter(Boolean));
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
|
|
158
|
-
|
|
159
|
-
if (json) {
|
|
160
|
-
(0, _print.printJSON)(tenantsUpdated);
|
|
161
|
-
} else {
|
|
162
|
-
// generate results table
|
|
163
|
-
const table = new _cliTable.default({
|
|
164
|
-
head: ['Tenant ID']
|
|
165
|
-
});
|
|
166
|
-
tenantsUpdated.forEach(t => table.push([t])); // print results
|
|
167
|
-
|
|
168
|
-
console.log(table.toString());
|
|
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;
|
package/lib/commands/tenants.js
DELETED
|
@@ -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("./tenants/index.js");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
const debug = (0, _debug.default)('commands:tenants');
|
|
17
|
-
const command = 'tenants <action>';
|
|
18
|
-
exports.command = command;
|
|
19
|
-
const desc = 'Manage tenants';
|
|
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.tenants);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
exports.builder = builder;
|
|
29
|
-
|
|
30
|
-
const handler = async function (argv) {
|
|
31
|
-
debug('handler', command, argv);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
exports.handler = handler;
|