|
2 | 2 | /* eslint-disable no-undef */ |
3 | 3 |
|
4 | 4 | const ex = require('execa') |
5 | | -const S3 = require('aws-sdk/clients/s3') |
| 5 | +const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3') |
6 | 6 | const fs = require('fs-extra') |
7 | 7 | const path = require('path') |
8 | 8 | const mime = require('mime') |
@@ -62,11 +62,13 @@ async function getFiles(dir) { |
62 | 62 | } |
63 | 63 |
|
64 | 64 | async function upload(meta) { |
65 | | - const s3 = new S3({ |
66 | | - accessKeyId, |
67 | | - secretAccessKey, |
68 | | - sessionToken, |
| 65 | + const s3 = new S3Client({ |
69 | 66 | region: 'us-west-2', |
| 67 | + credentials: { |
| 68 | + accessKeyId, |
| 69 | + secretAccessKey, |
| 70 | + sessionToken, |
| 71 | + }, |
70 | 72 | }) |
71 | 73 |
|
72 | 74 | const files = await getFiles(path.join(process.cwd(), './dist/umd')) |
@@ -98,29 +100,29 @@ async function upload(meta) { |
98 | 100 | options.ContentEncoding = 'gzip' |
99 | 101 | } |
100 | 102 |
|
101 | | - const output = await s3.putObject(options).promise() |
102 | | - await s3.putObject(shadowOptions).promise() // upload build to shadow pipeline bucket as well |
| 103 | + const output = await s3.send(new PutObjectCommand(options)) |
| 104 | + await s3.send(new PutObjectCommand(shadowOptions)) // upload build to shadow pipeline bucket as well |
103 | 105 |
|
104 | 106 | // put latest version with only 5 minutes caching |
105 | | - await s3 |
106 | | - .putObject({ |
| 107 | + await s3.send( |
| 108 | + new PutObjectCommand({ |
107 | 109 | ...options, |
108 | 110 | CacheControl: 'public,max-age=300,immutable', |
109 | 111 | Key: path.join(`analytics-next`, meta.branch, 'latest', f), |
110 | 112 | }) |
111 | | - .promise() |
| 113 | + ) |
112 | 114 |
|
113 | 115 | // put chunks in a separate path. Regardless of branch, version, etc. |
114 | 116 | // there are immutable scripts that will be loaded by webpack in runtime |
115 | 117 | if (filePath.includes('bundle')) { |
116 | 118 | options.GrantRead = `${cloudfrontCanonicalUserId},${customDomainCanonicalUserId}` |
117 | | - await s3 |
118 | | - .putObject({ |
| 119 | + await s3.send( |
| 120 | + new PutObjectCommand({ |
119 | 121 | ...options, |
120 | 122 | Key: path.join(`analytics-next`, 'bundles', f), |
121 | 123 | CacheControl: 'public,max-age=31536000,immutable', |
122 | 124 | }) |
123 | | - .promise() |
| 125 | + ) |
124 | 126 | } |
125 | 127 |
|
126 | 128 | progress++ |
|
0 commit comments