Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-awspublish

Package Overview
Dependencies
Maintainers
4
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-awspublish - npm Package Compare versions

Comparing version 5.0.1 to 6.0.0

91

lib/index.js

@@ -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 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc