@hotglue/cli 1.0.32 → 1.0.34
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 +1 -1
- package/lib/cjs/index.js +9 -8
- package/lib/cjs/index.js.map +1 -1
- package/lib/mjs/index.js +9 -8
- package/lib/mjs/index.js.map +1 -1
- package/package.json +2 -1
- package/lib/commands/config/set.js +0 -82
- package/lib/commands/config.js +0 -69
- package/lib/commands/env/deploy.js +0 -162
- package/lib/commands/env/download.js +0 -169
- package/lib/commands/env.js +0 -32
- package/lib/commands/etl/delete.js +0 -171
- package/lib/commands/etl/deploy.js +0 -263
- package/lib/commands/etl/download.js +0 -205
- package/lib/commands/etl.js +0 -32
- package/lib/commands/flows/list.js +0 -104
- package/lib/commands/flows.js +0 -32
- package/lib/commands/jobs/download.js +0 -188
- package/lib/commands/jobs/list.js +0 -108
- package/lib/commands/jobs.js +0 -32
- package/lib/commands/snapshots/deploy.js +0 -202
- package/lib/commands/snapshots/download.js +0 -213
- package/lib/commands/snapshots.js +0 -32
- package/lib/commands/tenants/custom-etl.js +0 -183
- package/lib/commands/tenants/custom-field-map.js +0 -191
- package/lib/commands/tenants/delete.js +0 -150
- package/lib/commands/tenants/list.js +0 -97
- package/lib/commands/tenants/updateConfig.js +0 -188
- package/lib/commands/tenants.js +0 -32
- 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 -12
- package/lib/main.js +0 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hotglue/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.34",
|
|
4
4
|
"description": "hotglue CLI tools",
|
|
5
5
|
"main": "./lib/mjs/index.js",
|
|
6
6
|
"module": "./lib/mjs/index.js",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"node": ">=18.0.0"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
+
"@hotglue/cli": "file:",
|
|
45
46
|
"async": "^3.2.5",
|
|
46
47
|
"aws-sdk": "^2.1530.0",
|
|
47
48
|
"axios": "^1.6.5",
|
|
@@ -1,82 +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"));
|
|
9
|
-
|
|
10
|
-
var _yaml = _interopRequireDefault(require("yaml"));
|
|
11
|
-
|
|
12
|
-
var _cliTable = _interopRequireDefault(require("cli-table"));
|
|
13
|
-
|
|
14
|
-
var _config = require("../../helpers/config");
|
|
15
|
-
|
|
16
|
-
var _print = require("../../helpers/print");
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
|
-
const debug = (0, _debug.default)('commands:config:set');
|
|
21
|
-
const command = 'set <setting> <value>';
|
|
22
|
-
exports.command = command;
|
|
23
|
-
const desc = 'Set configuration key-value pairs';
|
|
24
|
-
exports.desc = desc;
|
|
25
|
-
|
|
26
|
-
const builder = async yargs => {
|
|
27
|
-
debug('builder', command, yargs);
|
|
28
|
-
yargs.option('setting', {
|
|
29
|
-
describe: 'The configuration parameter you wish to set',
|
|
30
|
-
type: 'string'
|
|
31
|
-
}).option('value', {
|
|
32
|
-
describe: "The configuration parameter's value",
|
|
33
|
-
type: 'string'
|
|
34
|
-
});
|
|
35
|
-
return yargs;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
exports.builder = builder;
|
|
39
|
-
|
|
40
|
-
const handler = async argv => {
|
|
41
|
-
debug('handler', command, argv);
|
|
42
|
-
const {
|
|
43
|
-
json,
|
|
44
|
-
setting,
|
|
45
|
-
value
|
|
46
|
-
} = argv;
|
|
47
|
-
const allowedSettings = ['apikey'];
|
|
48
|
-
|
|
49
|
-
if (!allowedSettings.includes(setting)) {
|
|
50
|
-
json ? (0, _print.printJSON)({
|
|
51
|
-
status: 'error',
|
|
52
|
-
error: 'Invalid settings parameter'
|
|
53
|
-
}) : console.error('Invalid settings parameter'); // throw new Error('Invalid settings parameter');
|
|
54
|
-
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
const profileConfig = await (0, _config.getProfileConfig)();
|
|
60
|
-
if (profileConfig && profileConfig.config) !json && (0, _print.pp)('Updating profile config file...');else !json && (0, _print.pp)('Creating profile config file...');
|
|
61
|
-
const data = profileConfig && profileConfig.config ? { ...profileConfig.config,
|
|
62
|
-
[setting]: value
|
|
63
|
-
} : {
|
|
64
|
-
[setting]: value
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const yamlData = _yaml.default.stringify(data);
|
|
68
|
-
|
|
69
|
-
const filePath = profileConfig && profileConfig.filepath ? profileConfig.filepath : (0, _config.getProfileConfigFilePath)();
|
|
70
|
-
await (0, _config.writeConfigFile)(filePath, yamlData);
|
|
71
|
-
json ? (0, _print.printJSON)({
|
|
72
|
-
status: 'success'
|
|
73
|
-
}) : (0, _print.pp)('Done').pr();
|
|
74
|
-
} catch (err) {
|
|
75
|
-
json ? (0, _print.printJSON)({
|
|
76
|
-
status: 'error',
|
|
77
|
-
error: err
|
|
78
|
-
}) : console.log(err);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
exports.handler = handler;
|
package/lib/commands/config.js
DELETED
|
@@ -1,69 +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 _debug = _interopRequireDefault(require("../helpers/debug"));
|
|
11
|
-
|
|
12
|
-
var _yaml = _interopRequireDefault(require("yaml"));
|
|
13
|
-
|
|
14
|
-
var _cliTable = _interopRequireDefault(require("cli-table"));
|
|
15
|
-
|
|
16
|
-
var _config = require("../helpers/config");
|
|
17
|
-
|
|
18
|
-
var _print = require("../helpers/print");
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
const debug = (0, _debug.default)('commands:config');
|
|
23
|
-
const command = 'config [action]';
|
|
24
|
-
exports.command = command;
|
|
25
|
-
const desc = 'Configure your hotglue CLI';
|
|
26
|
-
exports.desc = desc;
|
|
27
|
-
|
|
28
|
-
const builder = async function (yargs) {
|
|
29
|
-
debug('builder', command);
|
|
30
|
-
return yargs.commandDir('config');
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
exports.builder = builder;
|
|
34
|
-
|
|
35
|
-
const handler = async function (argv) {
|
|
36
|
-
debug('handler', command, argv);
|
|
37
|
-
const {
|
|
38
|
-
action
|
|
39
|
-
} = argv; // implement using yarg default command
|
|
40
|
-
|
|
41
|
-
if (!action) {
|
|
42
|
-
try {
|
|
43
|
-
const profileConfig = await (0, _config.getProfileConfig)();
|
|
44
|
-
|
|
45
|
-
if (!profileConfig.config || Object.keys(profileConfig.config).length === 0) {
|
|
46
|
-
(0, _print.pr)('No profile configuration found. Run config set to configure the hotglue CLI.');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const table = new _cliTable.default({
|
|
50
|
-
head: ['Setting', 'Value', 'Config File', 'Type']
|
|
51
|
-
});
|
|
52
|
-
if (profileConfig.config) Object.entries(profileConfig.config).forEach(([k, v]) => table.push([k, v, profileConfig.filepath, `Profile`]));
|
|
53
|
-
const projectConfig = await (0, _config.getProjectConfig)();
|
|
54
|
-
if (projectConfig.config) Object.entries(projectConfig.config).forEach(([k, v]) => table.push([k, v, _path.default.relative(process.cwd(), projectConfig.filepath), 'Project']));
|
|
55
|
-
|
|
56
|
-
if (table.length > 0) {
|
|
57
|
-
// pr('CURRENT CONTEXT SETTINGS');
|
|
58
|
-
console.log(table.toString()); // console.log(YAML.stringify(fileConfig.config));
|
|
59
|
-
} // pr('The configuration file is empty. Run config set to configure the hotglue CLI.');
|
|
60
|
-
|
|
61
|
-
} catch (err) {
|
|
62
|
-
// log elsewhere
|
|
63
|
-
console.log(err);
|
|
64
|
-
throw err;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
exports.handler = handler;
|
|
@@ -1,162 +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"));
|
|
13
|
-
|
|
14
|
-
var _ora = _interopRequireDefault(require("ora"));
|
|
15
|
-
|
|
16
|
-
var _axios = _interopRequireDefault(require("axios/dist/node/axios.cjs"));
|
|
17
|
-
|
|
18
|
-
var _awsSdk = _interopRequireDefault(require("aws-sdk"));
|
|
19
|
-
|
|
20
|
-
var _cliTable = _interopRequireDefault(require("cli-table"));
|
|
21
|
-
|
|
22
|
-
var _descriptions = _interopRequireDefault(require("../../helpers/descriptions.js"));
|
|
23
|
-
|
|
24
|
-
var _utils = require("../../helpers/utils.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
|
-
// import logUpdate from 'log-update';
|
|
33
|
-
const debug = (0, _debug.default)('commands:env:deploy');
|
|
34
|
-
const command = 'deploy';
|
|
35
|
-
exports.command = command;
|
|
36
|
-
const desc = 'Deploy Environment settings';
|
|
37
|
-
exports.desc = desc;
|
|
38
|
-
|
|
39
|
-
const builder = async yargs => {
|
|
40
|
-
debug('builder', command);
|
|
41
|
-
return yargs.option('sourceFolder', _descriptions.default.options['sourceFolder'].config).demandOption('sourceFolder', _descriptions.default.options['sourceFolder'].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
|
-
sourceFolder
|
|
54
|
-
} = argv;
|
|
55
|
-
const {
|
|
56
|
-
clientApiBaseUri
|
|
57
|
-
} = hg;
|
|
58
|
-
|
|
59
|
-
const folderPrefix = _path.default.resolve(process.cwd(), sourceFolder);
|
|
60
|
-
|
|
61
|
-
let message;
|
|
62
|
-
let spinner = (0, _ora.default)();
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
// 1. build list of deployable files
|
|
66
|
-
message = (0, _print.themed)(`Scanning ${(0, _print.themed)(folderPrefix, 'info')} for deployable files`);
|
|
67
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
68
|
-
const deployableFiles = await (0, _utils.getFolderFiles)(folderPrefix, {
|
|
69
|
-
filter: {
|
|
70
|
-
pattern: '((**/requirements.txt)|(**/availableSources.json)|(**/availableTargets.json)|(**/availableConnectors.json))'
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
if (deployableFiles.length === 0) {
|
|
75
|
-
if (json) {
|
|
76
|
-
(0, _print.printJSON)({
|
|
77
|
-
status: 'error',
|
|
78
|
-
error: 'There are no files to deploy at the specified location!'
|
|
79
|
-
});
|
|
80
|
-
} else {
|
|
81
|
-
spinner.fail((0, _print.themed)(`Error: ${message}.`, 'secondary'));
|
|
82
|
-
(0, _print.pr)((0, _print.themed)(`Message: ${(0, _print.themed)('There are no files to deploy at the specified location!')}`, 'secondary'));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary')); // 2. get STS credentials
|
|
89
|
-
|
|
90
|
-
message = (0, _print.themed)(`Verifying user and authorizing`);
|
|
91
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
92
|
-
const {
|
|
93
|
-
accessKeyId,
|
|
94
|
-
secretAccessKey,
|
|
95
|
-
sessionToken
|
|
96
|
-
} = await (0, _api.genCredentialsOnClientApi)({
|
|
97
|
-
debug,
|
|
98
|
-
baseUri: clientApiBaseUri,
|
|
99
|
-
task: 'env-deploy',
|
|
100
|
-
env,
|
|
101
|
-
apikey
|
|
102
|
-
});
|
|
103
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary')); // create authenticated S3 instance
|
|
104
|
-
|
|
105
|
-
const s3 = new _awsSdk.default.S3({
|
|
106
|
-
accessKeyId,
|
|
107
|
-
secretAccessKey,
|
|
108
|
-
sessionToken
|
|
109
|
-
}); // 3. upload new files
|
|
110
|
-
|
|
111
|
-
message = (0, _print.themed)(`Deploying environment files`);
|
|
112
|
-
!json && spinner.info((0, _print.themed)(`Info: ${message}.`, 'secondary'));
|
|
113
|
-
const rootKey = `config/`;
|
|
114
|
-
const table = new _cliTable.default({
|
|
115
|
-
head: ['File', 'Status']
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
for await (const file of deployableFiles) {
|
|
119
|
-
const filename = _path.default.basename(file);
|
|
120
|
-
|
|
121
|
-
message = (0, _print.themed)(`Pushing file: ${(0, _print.themed)(filename, 'info')}`);
|
|
122
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
123
|
-
const readBuffer = await (0, _promises.readFile)(file);
|
|
124
|
-
const params = {
|
|
125
|
-
Bucket: env,
|
|
126
|
-
Key: `${rootKey}${filename}`,
|
|
127
|
-
Body: readBuffer
|
|
128
|
-
};
|
|
129
|
-
const res = await s3.putObject(params).promise();
|
|
130
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
|
|
131
|
-
debug('s3-put-res', res);
|
|
132
|
-
table.push([filename, 'Deployed']); // handling redis change
|
|
133
|
-
|
|
134
|
-
await (0, _api.resetAvailableEntities)({
|
|
135
|
-
debug,
|
|
136
|
-
baseUri: clientApiBaseUri,
|
|
137
|
-
env,
|
|
138
|
-
apiKey: apikey
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (json) {
|
|
143
|
-
(0, _print.printJSON)({
|
|
144
|
-
status: 'success',
|
|
145
|
-
deployedFiles: deployableFiles
|
|
146
|
-
});
|
|
147
|
-
} else {
|
|
148
|
-
// print results
|
|
149
|
-
(0, _print.cl)(table.toString());
|
|
150
|
-
}
|
|
151
|
-
} catch (err) {
|
|
152
|
-
!json && spinner.fail((0, _print.themed)(`Error: ${message}.`, 'secondary'));
|
|
153
|
-
(0, _print.pr)((0, _print.themed)(`Message: ${(0, _print.themed)(err.message)}`, 'secondary'));
|
|
154
|
-
debug(err);
|
|
155
|
-
|
|
156
|
-
if (err && err.response && err.response.data) {
|
|
157
|
-
debug('response', err.response.data);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
exports.handler = handler;
|
|
@@ -1,169 +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"));
|
|
13
|
-
|
|
14
|
-
var _ora = _interopRequireDefault(require("ora"));
|
|
15
|
-
|
|
16
|
-
var _axios = _interopRequireDefault(require("axios/dist/node/axios.cjs"));
|
|
17
|
-
|
|
18
|
-
var _cliTable = _interopRequireDefault(require("cli-table"));
|
|
19
|
-
|
|
20
|
-
var _awsSdk = _interopRequireDefault(require("aws-sdk"));
|
|
21
|
-
|
|
22
|
-
var _descriptions = _interopRequireDefault(require("../../helpers/descriptions"));
|
|
23
|
-
|
|
24
|
-
var _print = require("../../helpers/print");
|
|
25
|
-
|
|
26
|
-
var _utils = require("../../helpers/utils");
|
|
27
|
-
|
|
28
|
-
var _api = require("../../helpers/api");
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
|
-
const debug = (0, _debug.default)('commands:env:download');
|
|
33
|
-
const command = 'download';
|
|
34
|
-
exports.command = command;
|
|
35
|
-
const desc = 'Download Environment settings';
|
|
36
|
-
exports.desc = desc;
|
|
37
|
-
|
|
38
|
-
const builder = async yargs => {
|
|
39
|
-
debug('builder', command); // hotglue environment download -e <env> -o -d downloads
|
|
40
|
-
|
|
41
|
-
return yargs.option('downloadTo', _descriptions.default.options['downloadTo'].config); // .option('overwrite', descriptions.options['overwrite'].config);
|
|
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
|
-
downloadTo
|
|
54
|
-
} = argv;
|
|
55
|
-
const {
|
|
56
|
-
clientApiBaseUri
|
|
57
|
-
} = hg;
|
|
58
|
-
|
|
59
|
-
const folderPrefix = _path.default.resolve(process.cwd(), downloadTo);
|
|
60
|
-
|
|
61
|
-
let message;
|
|
62
|
-
let spinner = (0, _ora.default)();
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
// 1. get STS credentials
|
|
66
|
-
message = (0, _print.themed)(`Verifying user and authorizing`);
|
|
67
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
68
|
-
const {
|
|
69
|
-
accessKeyId,
|
|
70
|
-
secretAccessKey,
|
|
71
|
-
sessionToken
|
|
72
|
-
} = await (0, _api.genCredentialsOnClientApi)({
|
|
73
|
-
debug,
|
|
74
|
-
baseUri: clientApiBaseUri,
|
|
75
|
-
task: 'env-download',
|
|
76
|
-
env,
|
|
77
|
-
apikey
|
|
78
|
-
});
|
|
79
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary')); // create authenticated S3 instance
|
|
80
|
-
|
|
81
|
-
const s3 = new _awsSdk.default.S3({
|
|
82
|
-
accessKeyId,
|
|
83
|
-
secretAccessKey,
|
|
84
|
-
sessionToken
|
|
85
|
-
}); // 2. get list of files from AWS bucket
|
|
86
|
-
|
|
87
|
-
message = (0, _print.themed)(`Scanning environment ${(0, _print.themed)(env, 'info')}`);
|
|
88
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
89
|
-
const params = {
|
|
90
|
-
Bucket: env,
|
|
91
|
-
Prefix: `config/`
|
|
92
|
-
};
|
|
93
|
-
const {
|
|
94
|
-
Contents: s3Files
|
|
95
|
-
} = await s3.listObjectsV2(params).promise();
|
|
96
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary'));
|
|
97
|
-
debug('s3-files', s3Files); // 3. filter only downloadable files
|
|
98
|
-
|
|
99
|
-
const filesToDownload = s3Files ? (0, _utils.filterFiles)(s3Files.map(item => item.Key), {
|
|
100
|
-
pattern: '((*/requirements.txt)|(*/availableSources.json)|(*/availableTargets.json)|(*/availableConnectors.json))'
|
|
101
|
-
}) : [];
|
|
102
|
-
|
|
103
|
-
if (!filesToDownload || filesToDownload.length === 0) {
|
|
104
|
-
json ? (0, _print.printJSON)({
|
|
105
|
-
status: 'success',
|
|
106
|
-
downloadedFiles: []
|
|
107
|
-
}) : spinner.warn((0, _print.themed)(`Warning: ${(0, _print.themed)('Nothing to download!')}`, 'secondary'));
|
|
108
|
-
return;
|
|
109
|
-
} // 4. download environment config files
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
message = (0, _print.themed)(`Downloading to ${(0, _print.themed)(folderPrefix, 'info')}`);
|
|
113
|
-
!json && spinner.info((0, _print.themed)(`Info: ${message}.`, 'secondary'));
|
|
114
|
-
const table = new _cliTable.default({
|
|
115
|
-
head: ['File', 'Status']
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
for await (const item of filesToDownload) {
|
|
119
|
-
// create destination folder
|
|
120
|
-
const filename = _path.default.basename(item);
|
|
121
|
-
|
|
122
|
-
const fullPath = _path.default.resolve(folderPrefix, filename);
|
|
123
|
-
|
|
124
|
-
debug('local-file', fullPath); // ensure destination folder exists
|
|
125
|
-
|
|
126
|
-
await (0, _promises.mkdir)(_path.default.dirname(fullPath), {
|
|
127
|
-
recursive: true
|
|
128
|
-
}); // download s3 object into destination folder
|
|
129
|
-
|
|
130
|
-
message = (0, _print.themed)(`Downloading file: ${(0, _print.themed)(filename, 'info')}`);
|
|
131
|
-
!json && spinner.start((0, _print.themed)(`In progress: ${message}...`, 'secondary'));
|
|
132
|
-
const fileStream = s3.getObject({
|
|
133
|
-
Bucket: env,
|
|
134
|
-
Key: item
|
|
135
|
-
}).createReadStream();
|
|
136
|
-
await (0, _promises.writeFile)(fullPath, await (0, _utils.streamToString)(fileStream));
|
|
137
|
-
!json && spinner.succeed((0, _print.themed)(`Finished: ${message}.`, 'secondary')); // debug('downloaded', env + item);
|
|
138
|
-
|
|
139
|
-
table.push([filename, 'Downloaded']);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (json) {
|
|
143
|
-
(0, _print.printJSON)({
|
|
144
|
-
status: 'success',
|
|
145
|
-
downloadedFiles: filesToDownload
|
|
146
|
-
});
|
|
147
|
-
} else {
|
|
148
|
-
// print results
|
|
149
|
-
(0, _print.cl)(table.toString());
|
|
150
|
-
}
|
|
151
|
-
} catch (err) {
|
|
152
|
-
if (json) {
|
|
153
|
-
(0, _print.printJSON)({
|
|
154
|
-
status: 'error',
|
|
155
|
-
error: err
|
|
156
|
-
});
|
|
157
|
-
} else {
|
|
158
|
-
spinner.fail((0, _print.themed)(`Error: ${message}.`, 'secondary'));
|
|
159
|
-
(0, _print.pr)((0, _print.themed)(`Message: ${(0, _print.themed)(err.message)}`, 'secondary'));
|
|
160
|
-
debug(err);
|
|
161
|
-
|
|
162
|
-
if (err && err.response && err.response.data) {
|
|
163
|
-
debug('response', err.response.data);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
exports.handler = handler;
|
package/lib/commands/env.js
DELETED
|
@@ -1,32 +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"));
|
|
9
|
-
|
|
10
|
-
var _baseBuilder = require("../helpers/baseBuilder");
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
const debug = (0, _debug.default)('commands:env');
|
|
15
|
-
const command = 'env <action>';
|
|
16
|
-
exports.command = command;
|
|
17
|
-
const desc = 'Manage environment settings';
|
|
18
|
-
exports.desc = desc;
|
|
19
|
-
|
|
20
|
-
const builder = async function (yargs) {
|
|
21
|
-
debug('builder', command);
|
|
22
|
-
const base = await (0, _baseBuilder.baseApiBuilder)(yargs);
|
|
23
|
-
return base.commandDir('env');
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
exports.builder = builder;
|
|
27
|
-
|
|
28
|
-
const handler = async function (argv) {
|
|
29
|
-
debug('handler', command, argv);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
exports.handler = handler;
|