@enplug/scripts 1.11.5 → 1.11.6
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.
|
@@ -1,45 +1,10 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
const rootPath = process.cwd();
|
|
5
1
|
const AWS = require('aws-sdk');
|
|
6
2
|
|
|
7
|
-
function getAwsPrivateFile() {
|
|
8
|
-
const fileName = 'aws.private.json';
|
|
9
|
-
let prefix = '';
|
|
10
|
-
let file = null;
|
|
11
|
-
let maxDepth = 2;
|
|
12
|
-
do {
|
|
13
|
-
file = path.resolve(rootPath, prefix + fileName);
|
|
14
|
-
prefix += '../';
|
|
15
|
-
} while (!fs.existsSync(file) && maxDepth--);
|
|
16
|
-
|
|
17
|
-
return file;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
3
|
function createS3Client(pkg) {
|
|
21
|
-
let creds;
|
|
22
4
|
const s3Options = Object.assign({}, pkg.config.aws.s3);
|
|
23
|
-
const credsFile = getAwsPrivateFile();
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
creds = JSON.parse(fs.readFileSync(credsFile, 'utf8'));
|
|
27
|
-
} catch (e) {
|
|
28
|
-
console.error(`Error finding/parsing ${chalk.default.cyan(credsFile)}`);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (creds.accessKeyId == null || creds.secretAccessKey == null) {
|
|
33
|
-
console.error(`Error could not fine accessKeyId or secretAccessKey in ${chalk.default.cyan(credsFile)} file.`);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
5
|
|
|
37
|
-
|
|
38
|
-
AWS.config.
|
|
39
|
-
accessKeyId: creds.accessKeyId,
|
|
40
|
-
secretAccessKey: creds.secretAccessKey,
|
|
41
|
-
maxRetries: 3,
|
|
42
|
-
});
|
|
6
|
+
const credentials = new AWS.SharedIniFileCredentials({ profile: pkg.config.aws.profile });
|
|
7
|
+
AWS.config.credentials = credentials;
|
|
43
8
|
|
|
44
9
|
return new AWS.S3(s3Options);
|
|
45
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enplug/scripts",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.6",
|
|
4
4
|
"description": "Enplug scripts",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"check-packages": "bin/check-packages.js"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"aws-sdk": "
|
|
30
|
+
"aws-sdk": "2.1692.0",
|
|
31
31
|
"axios": "^0.19.2",
|
|
32
32
|
"chalk": "2.4.1",
|
|
33
33
|
"command-line-args": "5.0.2",
|