chore: migrate AWS SDK for JavaScript v2 APIs to v3 (#7653)
* chore: convert s3.promise callback to async-await * chore: run codemod on detox/utils/artifacts.js * chore: format * chore(deps): replace AWS SDK for JavaScript v2 to v3 * chore: eslint --fix
This commit is contained in:
parent
a1401faa53
commit
89ebfbdadf
3 changed files with 2946 additions and 507 deletions
3416
detox/package-lock.json
generated
3416
detox/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -4,6 +4,8 @@
|
|||
"repository": "git@github.com:mattermost/mattermost-mobile.git",
|
||||
"author": "Mattermost, Inc.",
|
||||
"devDependencies": {
|
||||
"@aws-sdk/client-s3": "3.445.0",
|
||||
"@aws-sdk/lib-storage": "3.445.0",
|
||||
"@babel/plugin-proposal-class-properties": "7.18.6",
|
||||
"@babel/plugin-transform-modules-commonjs": "7.22.15",
|
||||
"@babel/plugin-transform-runtime": "7.22.15",
|
||||
|
|
@ -12,7 +14,6 @@
|
|||
"@types/jest": "29.5.5",
|
||||
"@types/tough-cookie": "4.0.3",
|
||||
"@types/uuid": "9.0.4",
|
||||
"aws-sdk": "2.1462.0",
|
||||
"axios": "1.5.0",
|
||||
"axios-cookiejar-support": "4.0.7",
|
||||
"babel-jest": "29.7.0",
|
||||
|
|
|
|||
|
|
@ -6,8 +6,9 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const {S3} = require('@aws-sdk/client-s3');
|
||||
const {Upload} = require('@aws-sdk/lib-storage');
|
||||
const async = require('async');
|
||||
const AWS = require('aws-sdk');
|
||||
const mime = require('mime-types');
|
||||
const readdir = require('recursive-readdir');
|
||||
|
||||
|
|
@ -26,10 +27,11 @@ const {
|
|||
} = process.env;
|
||||
const platform = IOS === 'true' ? 'ios' : 'android';
|
||||
|
||||
const s3 = new AWS.S3({
|
||||
signatureVersion: 'v4',
|
||||
accessKeyId: DETOX_AWS_ACCESS_KEY_ID,
|
||||
secretAccessKey: DETOX_AWS_SECRET_ACCESS_KEY,
|
||||
const s3 = new S3({
|
||||
credentials: {
|
||||
accessKeyId: DETOX_AWS_ACCESS_KEY_ID,
|
||||
secretAccessKey: DETOX_AWS_SECRET_ACCESS_KEY,
|
||||
},
|
||||
});
|
||||
|
||||
function getFiles(dirPath) {
|
||||
|
|
@ -56,23 +58,21 @@ async function saveArtifacts() {
|
|||
const contentType = mime.lookup(file);
|
||||
const charset = mime.charset(contentType);
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
s3.upload(
|
||||
{
|
||||
try {
|
||||
await new Upload({
|
||||
client: s3,
|
||||
params: {
|
||||
Key,
|
||||
Bucket: DETOX_AWS_S3_BUCKET,
|
||||
Body: fs.readFileSync(file),
|
||||
ContentType: `${contentType}${charset ? '; charset=' + charset : ''}`,
|
||||
},
|
||||
(err) => {
|
||||
if (err) {
|
||||
console.log('Failed to upload artifact:', file);
|
||||
return rej(new Error(err));
|
||||
}
|
||||
res({success: true});
|
||||
},
|
||||
);
|
||||
});
|
||||
}).done();
|
||||
return {success: true};
|
||||
} catch (e) {
|
||||
console.log('Failed to upload artifact:', file);
|
||||
throw new Error(e);
|
||||
}
|
||||
}),
|
||||
(err) => {
|
||||
if (err) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue