@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
package/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# @hotglue/cli [](https://npmjs.com/package/@hotglue/cli)
|
|
2
|
+
|
|
3
|
+
The [hotglue](https://hotglue.xyz) Command Line Interface (CLI)
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [Configuration](#configuration)
|
|
10
|
+
- [Documentation](#documentation)
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
You can install the CLI globally (recommended) using
|
|
15
|
+
|
|
16
|
+
```zsh
|
|
17
|
+
npm install -g @hotglue/cli
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
And then you can run it from anywhere using
|
|
21
|
+
|
|
22
|
+
```zsh
|
|
23
|
+
hotglue --help
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Alternatively, you may install it locally in a project folder using
|
|
27
|
+
|
|
28
|
+
```zsh
|
|
29
|
+
npm install --save-dev @hotglue/cli
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
And then you can run the local installation from within that folder using
|
|
33
|
+
|
|
34
|
+
```zsh
|
|
35
|
+
npx hotglue --help
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
```zsh
|
|
41
|
+
Usage: hotglue <command>
|
|
42
|
+
|
|
43
|
+
Commands:
|
|
44
|
+
hotglue config View global CLI settings (ie. apikey)
|
|
45
|
+
hotglue config set Configure global CLI settings (ie. apikey)
|
|
46
|
+
hotglue env download Download environment settings (ie. requirements.txt)
|
|
47
|
+
hotglue env deploy Deploy environment settings (ie. requirements.txt)
|
|
48
|
+
hotglue etl download Download ETL script files
|
|
49
|
+
hotglue etl deploy Deploy ETL script files
|
|
50
|
+
hotglue snapshots download Download snapshot files
|
|
51
|
+
hotglue snapshots deploy Deploy snapshot files
|
|
52
|
+
hotglue flows list List flows for a given environment
|
|
53
|
+
hotglue jobs list List all jobs for a given flow
|
|
54
|
+
hotglue jobs download Download jobroot files to the specified location
|
|
55
|
+
hotglue tenants list List the tenants in the environment
|
|
56
|
+
|
|
57
|
+
Options:
|
|
58
|
+
-k, --apikey Your API Key [string]
|
|
59
|
+
-e, --environment Environment ID [string]
|
|
60
|
+
-f, --flow Flow ID [string]
|
|
61
|
+
-t, --tap Tap ID [string]
|
|
62
|
+
-u, --tenant Tenant ID [string]
|
|
63
|
+
-j, --jobroot A job root path [string]
|
|
64
|
+
-d, --downwloadTo The target download location [string]
|
|
65
|
+
-s, --sourceFolder The source directory [string]
|
|
66
|
+
-o, --overwrite Overwrite existing files? [boolean]
|
|
67
|
+
|
|
68
|
+
-v, --version Show version number [boolean]
|
|
69
|
+
-h, --help Show help [boolean]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Configuration
|
|
73
|
+
|
|
74
|
+
The [hotglue](https://hotglue.xyz) CLI derives its configuration from two places: the User/Profile settings and the Project settings.
|
|
75
|
+
|
|
76
|
+
The User settings are stored in a `config.yaml` file located at `$HOME/.hotglue/`. At the moment, it is only used to store your `apikey`.
|
|
77
|
+
|
|
78
|
+
The Project settings are stored in a hotglue rc-like file and can be created anywhere in your project's folder structure. A Project settings file can hold any of the CLI's parameters (including overriding the apikey, even though we do not recommend it) is used in order to define configuration values specific for that context
|
|
79
|
+
|
|
80
|
+
### Project configuration files
|
|
81
|
+
|
|
82
|
+
The configuration files can use any of the following names:
|
|
83
|
+
`hotglue.yaml`, `.hotglue.yaml`, `.hotgluerc.yaml`, `.hotgluerc.yml`, `.hotgluerc`, `.hotgluerc.json`, `.hotgluerc.js`
|
|
84
|
+
|
|
85
|
+
As the extensions suggest, the files support either yaml, json or js syntax (in case of JS, the config object has to be exported). However, we recommend using the yaml format.
|
|
86
|
+
|
|
87
|
+
### Additional info
|
|
88
|
+
|
|
89
|
+
- When deploying files, symbolic links are not followed.
|
|
90
|
+
|
|
91
|
+
## Documentation
|
|
92
|
+
|
|
93
|
+
- [hotglue CLI Documentation](https://docs.hotglue.xyz/docs/cli-overview)
|
|
94
|
+
- [hotglue General Documentation](https://docs.hotglue.xyz)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.config = void 0;
|
|
7
|
+
|
|
8
|
+
var set = _interopRequireWildcard(require("./set.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 config = [set];
|
|
15
|
+
exports.config = config;
|
|
@@ -0,0 +1,82 @@
|
|
|
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 _yaml = _interopRequireDefault(require("yaml"));
|
|
11
|
+
|
|
12
|
+
var _cliTable = _interopRequireDefault(require("cli-table"));
|
|
13
|
+
|
|
14
|
+
var _config = require("../../helpers/config.js");
|
|
15
|
+
|
|
16
|
+
var _print = require("../../helpers/print.js");
|
|
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;
|
|
@@ -0,0 +1,71 @@
|
|
|
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.js"));
|
|
11
|
+
|
|
12
|
+
var _yaml = _interopRequireDefault(require("yaml"));
|
|
13
|
+
|
|
14
|
+
var _cliTable = _interopRequireDefault(require("cli-table"));
|
|
15
|
+
|
|
16
|
+
var _config = require("../helpers/config.js");
|
|
17
|
+
|
|
18
|
+
var _print = require("../helpers/print.js");
|
|
19
|
+
|
|
20
|
+
var _index = require("./config/index.js");
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
const debug = (0, _debug.default)('commands:config');
|
|
25
|
+
const command = 'config [action]';
|
|
26
|
+
exports.command = command;
|
|
27
|
+
const desc = 'Configure your hotglue CLI';
|
|
28
|
+
exports.desc = desc;
|
|
29
|
+
|
|
30
|
+
const builder = async function (yargs) {
|
|
31
|
+
debug('builder', command);
|
|
32
|
+
return yargs.command(_index.config);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.builder = builder;
|
|
36
|
+
|
|
37
|
+
const handler = async function (argv) {
|
|
38
|
+
debug('handler', command, argv);
|
|
39
|
+
const {
|
|
40
|
+
action
|
|
41
|
+
} = argv; // implement using yarg default command
|
|
42
|
+
|
|
43
|
+
if (!action) {
|
|
44
|
+
try {
|
|
45
|
+
const profileConfig = await (0, _config.getProfileConfig)();
|
|
46
|
+
|
|
47
|
+
if (!profileConfig.config || Object.keys(profileConfig.config).length === 0) {
|
|
48
|
+
(0, _print.pr)('No profile configuration found. Run config set to configure the hotglue CLI.');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const table = new _cliTable.default({
|
|
52
|
+
head: ['Setting', 'Value', 'Config File', 'Type']
|
|
53
|
+
});
|
|
54
|
+
if (profileConfig.config) Object.entries(profileConfig.config).forEach(([k, v]) => table.push([k, v, profileConfig.filepath, `Profile`]));
|
|
55
|
+
const projectConfig = await (0, _config.getProjectConfig)();
|
|
56
|
+
if (projectConfig.config) Object.entries(projectConfig.config).forEach(([k, v]) => table.push([k, v, _path.default.relative(process.cwd(), projectConfig.filepath), 'Project']));
|
|
57
|
+
|
|
58
|
+
if (table.length > 0) {
|
|
59
|
+
// pr('CURRENT CONTEXT SETTINGS');
|
|
60
|
+
console.log(table.toString()); // console.log(YAML.stringify(fileConfig.config));
|
|
61
|
+
} // pr('The configuration file is empty. Run config set to configure the hotglue CLI.');
|
|
62
|
+
|
|
63
|
+
} catch (err) {
|
|
64
|
+
// log elsewhere
|
|
65
|
+
console.log(err);
|
|
66
|
+
throw err;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
exports.handler = handler;
|
|
@@ -0,0 +1,162 @@
|
|
|
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 _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;
|
|
@@ -0,0 +1,169 @@
|
|
|
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 _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 _utils = require("../../helpers/utils.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: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;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.env = 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 env = [deploy, download];
|
|
17
|
+
exports.env = env;
|
|
@@ -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("./env/index.js");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const debug = (0, _debug.default)('commands:env');
|
|
17
|
+
const command = 'env <action>';
|
|
18
|
+
exports.command = command;
|
|
19
|
+
const desc = 'Manage environment settings';
|
|
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.env);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.builder = builder;
|
|
29
|
+
|
|
30
|
+
const handler = async function (argv) {
|
|
31
|
+
debug('handler', command, argv);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.handler = handler;
|