gulp-awspublish
Advanced tools
Comparing version 5.0.1 to 6.0.0
@@ -1,3 +0,2 @@ | ||
var AWS = require('aws-sdk'), | ||
s3pagingStream = require('./s3-paging-stream'), | ||
var { S3 } = require('@aws-sdk/client-s3'), | ||
Stream = require('stream'), | ||
@@ -48,3 +47,3 @@ fs = require('fs'), | ||
function toAwsParams(file) { | ||
function toAwsParams(bucket, file) { | ||
var params = {}; | ||
@@ -64,2 +63,3 @@ | ||
params.Bucket = bucket; | ||
params.Key = file.s3.path; | ||
@@ -119,3 +119,3 @@ params.Body = file.contents; | ||
function buildDeleteMultiple(keys) { | ||
function buildDeleteMultiple(Bucket, keys) { | ||
if (!keys || !keys.length) return; | ||
@@ -129,2 +129,3 @@ | ||
return { | ||
Bucket, | ||
Delete: { | ||
@@ -209,4 +210,8 @@ Objects: each, | ||
function Publisher(AWSConfig, cacheOptions) { | ||
if (!AWSConfig.region) { | ||
AWSConfig.region = 'aws-global'; | ||
} | ||
this.config = AWSConfig; | ||
this.client = new AWS.S3(AWSConfig); | ||
this.client = new S3(AWSConfig); | ||
var bucket = this.config.params.Bucket; | ||
@@ -356,5 +361,10 @@ | ||
// get s3 headers | ||
_this.client.headObject({ Key: file.s3.path }, function (err, res) { | ||
const params = { | ||
Bucket: _this.client.config.params.Bucket, | ||
Key: file.s3.path, | ||
}; | ||
_this.client.headObject(params, function (err, res) { | ||
//ignore 403 and 404 errors since we're checking if a file exists on s3 | ||
if (err && [403, 404].indexOf(err.statusCode) < 0) return cb(err); | ||
if (err && [403, 404].indexOf(err.$response.statusCode) < 0) | ||
return cb(err); | ||
@@ -379,3 +389,4 @@ res = res || {}; | ||
_this.client.putObject(toAwsParams(file), function (err) { | ||
const params = toAwsParams(_this.client.config.params.Bucket, file); | ||
_this.client.putObject(params, function (err) { | ||
if (err) return cb(err); | ||
@@ -415,20 +426,23 @@ | ||
stream._flush = function (cb) { | ||
var toDelete = [], | ||
lister; | ||
stream._flush = async function (cb) { | ||
const toDelete = []; | ||
let objects = []; | ||
let token = void 0; | ||
lister = s3pagingStream( | ||
client.listObjectsV2({ Prefix: prefix }), | ||
function (_in) { | ||
return _in.Key; | ||
} | ||
); | ||
do { | ||
const { Contents, NextContinuationToken } = await client.listObjectsV2({ | ||
Bucket: client.config.params.Bucket, | ||
Prefix: prefix, | ||
ContinuationToken: token, | ||
}); | ||
objects = objects.concat(Contents); | ||
token = NextContinuationToken; | ||
} while (token); | ||
lister.on('data', function (key) { | ||
var deleteFile; | ||
if (newFiles[key]) return; | ||
if (!fileShouldBeDeleted(key, whitelistedFiles)) return; | ||
deleteFile = new Vinyl({}); | ||
for (const { Key } of objects) { | ||
if (newFiles[Key]) continue; | ||
if (!fileShouldBeDeleted(Key, whitelistedFiles)) continue; | ||
const deleteFile = new Vinyl({}); | ||
deleteFile.s3 = { | ||
path: key, | ||
path: Key, | ||
state: 'delete', | ||
@@ -439,19 +453,18 @@ headers: {}, | ||
stream.push(deleteFile); | ||
toDelete.push(key); | ||
}); | ||
toDelete.push(Key); | ||
} | ||
lister.on('end', function () { | ||
if (!toDelete.length) return cb(); | ||
Promise.all( | ||
buildDeleteMultiple(toDelete).map(function (each) { | ||
return client.deleteObjects(each).promise(); | ||
}) | ||
) | ||
.then(function () { | ||
cb(); | ||
}) | ||
.catch(function (e) { | ||
cb(e); | ||
}); | ||
}); | ||
Promise.all( | ||
buildDeleteMultiple(client.config.params.Bucket, toDelete).map(function ( | ||
each | ||
) { | ||
return client.deleteObjects(each); | ||
}) | ||
) | ||
.then(function () { | ||
cb(); | ||
}) | ||
.catch(function (e) { | ||
cb(e); | ||
}); | ||
}; | ||
@@ -458,0 +471,0 @@ |
{ | ||
"name": "gulp-awspublish", | ||
"version": "5.0.1", | ||
"version": "6.0.0", | ||
"description": "gulp plugin to publish files to amazon s3", | ||
@@ -29,4 +29,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@aws-sdk/client-s3": "^3.48.0", | ||
"ansi-colors": "^4.1.1", | ||
"aws-sdk": "^2.389.0", | ||
"clone": "^2.1.2", | ||
@@ -33,0 +33,0 @@ "fancy-log": "^2.0.0", |
@@ -176,4 +176,6 @@ # gulp-awspublish | ||
}, | ||
accessKeyId: "akid", | ||
secretAccessKey: "secret" | ||
credentials: { | ||
accessKeyId: "akid", | ||
secretAccessKey: "secret" | ||
} | ||
}); | ||
@@ -180,0 +182,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
371
28341
6
437
+ Added@aws-sdk/client-s3@^3.48.0
+ Added@aws-crypto/crc32@5.2.0(transitive)
+ Added@aws-crypto/crc32c@5.2.0(transitive)
+ Added@aws-crypto/sha256-browser@5.2.0(transitive)
+ Added@aws-crypto/sha256-js@5.2.0(transitive)
+ Added@aws-crypto/supports-web-crypto@5.2.0(transitive)
+ Added@aws-crypto/util@5.2.0(transitive)
+ Added@aws-sdk/client-s3@3.699.0(transitive)
+ Added@aws-sdk/client-sso@3.696.0(transitive)
+ Added@aws-sdk/client-sso-oidc@3.699.0(transitive)
+ Added@aws-sdk/client-sts@3.699.0(transitive)
+ Added@aws-sdk/core@3.696.0(transitive)
+ Added@aws-sdk/credential-provider-env@3.696.0(transitive)
+ Added@aws-sdk/credential-provider-http@3.696.0(transitive)
+ Added@aws-sdk/credential-provider-ini@3.699.0(transitive)
+ Added@aws-sdk/credential-provider-node@3.699.0(transitive)
+ Added@aws-sdk/credential-provider-process@3.696.0(transitive)
+ Added@aws-sdk/credential-provider-sso@3.699.0(transitive)
+ Added@aws-sdk/credential-provider-web-identity@3.696.0(transitive)
+ Added@aws-sdk/middleware-bucket-endpoint@3.696.0(transitive)
+ Added@aws-sdk/middleware-expect-continue@3.696.0(transitive)
+ Added@aws-sdk/middleware-flexible-checksums@3.697.0(transitive)
+ Added@aws-sdk/middleware-host-header@3.696.0(transitive)
+ Added@aws-sdk/middleware-location-constraint@3.696.0(transitive)
+ Added@aws-sdk/middleware-logger@3.696.0(transitive)
+ Added@aws-sdk/middleware-recursion-detection@3.696.0(transitive)
+ Added@aws-sdk/middleware-sdk-s3@3.696.0(transitive)
+ Added@aws-sdk/middleware-ssec@3.696.0(transitive)
+ Added@aws-sdk/middleware-user-agent@3.696.0(transitive)
+ Added@aws-sdk/region-config-resolver@3.696.0(transitive)
+ Added@aws-sdk/signature-v4-multi-region@3.696.0(transitive)
+ Added@aws-sdk/token-providers@3.699.0(transitive)
+ Added@aws-sdk/types@3.696.0(transitive)
+ Added@aws-sdk/util-arn-parser@3.693.0(transitive)
+ Added@aws-sdk/util-endpoints@3.696.0(transitive)
+ Added@aws-sdk/util-locate-window@3.693.0(transitive)
+ Added@aws-sdk/util-user-agent-browser@3.696.0(transitive)
+ Added@aws-sdk/util-user-agent-node@3.696.0(transitive)
+ Added@aws-sdk/xml-builder@3.696.0(transitive)
+ Added@smithy/abort-controller@3.1.8(transitive)
+ Added@smithy/chunked-blob-reader@4.0.0(transitive)
+ Added@smithy/chunked-blob-reader-native@3.0.1(transitive)
+ Added@smithy/config-resolver@3.0.12(transitive)
+ Added@smithy/core@2.5.4(transitive)
+ Added@smithy/credential-provider-imds@3.2.7(transitive)
+ Added@smithy/eventstream-codec@3.1.9(transitive)
+ Added@smithy/eventstream-serde-browser@3.0.13(transitive)
+ Added@smithy/eventstream-serde-config-resolver@3.0.10(transitive)
+ Added@smithy/eventstream-serde-node@3.0.12(transitive)
+ Added@smithy/eventstream-serde-universal@3.0.12(transitive)
+ Added@smithy/fetch-http-handler@4.1.1(transitive)
+ Added@smithy/hash-blob-browser@3.1.9(transitive)
+ Added@smithy/hash-node@3.0.10(transitive)
+ Added@smithy/hash-stream-node@3.1.9(transitive)
+ Added@smithy/invalid-dependency@3.0.10(transitive)
+ Added@smithy/is-array-buffer@2.2.03.0.0(transitive)
+ Added@smithy/md5-js@3.0.10(transitive)
+ Added@smithy/middleware-content-length@3.0.12(transitive)
+ Added@smithy/middleware-endpoint@3.2.4(transitive)
+ Added@smithy/middleware-retry@3.0.28(transitive)
+ Added@smithy/middleware-serde@3.0.10(transitive)
+ Added@smithy/middleware-stack@3.0.10(transitive)
+ Added@smithy/node-config-provider@3.1.11(transitive)
+ Added@smithy/node-http-handler@3.3.1(transitive)
+ Added@smithy/property-provider@3.1.10(transitive)
+ Added@smithy/protocol-http@4.1.7(transitive)
+ Added@smithy/querystring-builder@3.0.10(transitive)
+ Added@smithy/querystring-parser@3.0.10(transitive)
+ Added@smithy/service-error-classification@3.0.10(transitive)
+ Added@smithy/shared-ini-file-loader@3.1.11(transitive)
+ Added@smithy/signature-v4@4.2.3(transitive)
+ Added@smithy/smithy-client@3.4.5(transitive)
+ Added@smithy/types@3.7.1(transitive)
+ Added@smithy/url-parser@3.0.10(transitive)
+ Added@smithy/util-base64@3.0.0(transitive)
+ Added@smithy/util-body-length-browser@3.0.0(transitive)
+ Added@smithy/util-body-length-node@3.0.0(transitive)
+ Added@smithy/util-buffer-from@2.2.03.0.0(transitive)
+ Added@smithy/util-config-provider@3.0.0(transitive)
+ Added@smithy/util-defaults-mode-browser@3.0.28(transitive)
+ Added@smithy/util-defaults-mode-node@3.0.28(transitive)
+ Added@smithy/util-endpoints@2.1.6(transitive)
+ Added@smithy/util-hex-encoding@3.0.0(transitive)
+ Added@smithy/util-middleware@3.0.10(transitive)
+ Added@smithy/util-retry@3.0.10(transitive)
+ Added@smithy/util-stream@3.3.1(transitive)
+ Added@smithy/util-uri-escape@3.0.0(transitive)
+ Added@smithy/util-utf8@2.3.03.0.0(transitive)
+ Added@smithy/util-waiter@3.1.9(transitive)
+ Addedbowser@2.11.0(transitive)
+ Addedfast-xml-parser@4.4.1(transitive)
+ Addedstrnum@1.0.5(transitive)
+ Addeduuid@9.0.1(transitive)
- Removedaws-sdk@^2.389.0
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedaws-sdk@2.1692.0(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbuffer@4.9.2(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedevents@1.1.1(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedieee754@1.1.13(transitive)
- Removedis-arguments@1.1.1(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-generator-function@1.0.10(transitive)
- Removedis-typed-array@1.1.13(transitive)
- Removedjmespath@0.16.0(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedpunycode@1.3.2(transitive)
- Removedquerystring@0.2.0(transitive)
- Removedsax@1.2.1(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedurl@0.10.3(transitive)
- Removedutil@0.12.5(transitive)
- Removeduuid@8.0.0(transitive)
- Removedwhich-typed-array@1.1.15(transitive)
- Removedxml2js@0.6.2(transitive)
- Removedxmlbuilder@11.0.1(transitive)