New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 3.3.3 to 3.4.0

138

History.md

@@ -1,126 +0,102 @@

1.0.1 / 2015-01-29
==================
# 1.0.1 / 2015-01-29
* config: fix region setting pull request #40 from klaemo
* config: fix region setting pull request #40 from klaemo
1.0.0 / 2015-01-29
==================
# 1.0.0 / 2015-01-29
* refactored to use aws-sdk instead of knox pull request #38 from ronik-design
* refactored to use aws-sdk instead of knox pull request #38 from ronik-design
0.0.24 / 2015-01-06
==================
# 0.0.24 / 2015-01-06
* Fix for windows #36 from kkolstad-trov/fix/windows-separator
* Update README.md
* Fix for windows #36 from kkolstad-trov/fix/windows-separator
* Update README.md
0.0.23 / 2014-09-02
==================
# 0.0.23 / 2014-09-02
* Merge pull request #27 from zjjw/create_only
* Merge pull request #27 from zjjw/create_only
0.0.22 / 2014-08-08
==================
# 0.0.22 / 2014-08-08
* Handling S3 - 307 Status code pull request #30 from smalltownheroes/master
* Handling S3 - 307 Status code pull request #30 from smalltownheroes/master
0.0.21 / 2014-08-06
==================
# 0.0.21 / 2014-08-06
* add simulate option
* add simulate option
0.0.20 / 2014-07-18
==================
# 0.0.20 / 2014-07-18
* dont use file.clone when gzip file to conserve file custom ppties
* dont use file.clone when gzip file to conserve file custom ppties
0.0.19 / 2014-07-15
==================
# 0.0.19 / 2014-07-15
* Fixes #22
* Merge pull request #24 from koistya/master
* Merge pull request #25 from scalableminds/master
* added concurrent upload sample
* Fix relative paths on Windows. Fixes pgherveou/gulp-awspublish#20
* Fixes #22
* Merge pull request #24 from koistya/master
* Merge pull request #25 from scalableminds/master
* added concurrent upload sample
* Fix relative paths on Windows. Fixes pgherveou/gulp-awspublish#20
0.0.18 / 2014-07-08
==================
# 0.0.18 / 2014-07-08
* add s3.date property
* add s3.date property
0.0.17 / 2014-06-16
==================
# 0.0.17 / 2014-06-16
* add user with no upload rights test
* update error reporting
* add user with no upload rights test
* update error reporting
0.0.16 / 2014-05-08
==================
# 0.0.16 / 2014-05-08
* fixes #14, add force option on publish to bypass skip/cache
* fixes #14, add force option on publish to bypass skip/cache
0.0.15 / 2014-05-08
==================
# 0.0.15 / 2014-05-08
* force end event fixes #13
* add test and doc for sync prefix option
* force end event fixes #13
* add test and doc for sync prefix option
0.0.14 / 2014-04-22
==================
# 0.0.14 / 2014-04-22
* Fixes #45
* Fixes #45
0.0.11 / 2014-02-14
==================
# 0.0.11 / 2014-02-14
* Merge window fix, pull request #3 from jonathandelgado/patch-1
* Merge window fix, pull request #3 from jonathandelgado/patch-1
0.0.10 / 2014-02-14
==================
# 0.0.10 / 2014-02-14
* update doc
* add ext option on gzip plugin
* update doc
* add ext option on gzip plugin
0.0.9 / 2014-02-14
==================
# 0.0.9 / 2014-02-14
* fix missing dep
* fix missing dep
0.0.8 / 2014-02-06
==================
# 0.0.8 / 2014-02-06
* fix cache plugin bug - too many save
* fix cache plugin bug - too many save
0.0.7 / 2014-02-06
==================
# 0.0.7 / 2014-02-06
* sync refactoring
* add options to filter files on the log reporter
* sync refactoring
* add options to filter files on the log reporter
0.0.6 / 2014-02-05
==================
# 0.0.6 / 2014-02-05
* remove first / from s3 path
* remove first / from s3 path
0.0.5 / 2014-02-05
==================
# 0.0.5 / 2014-02-05
* update sync
* update sync
0.0.4 / 2014-02-04
==================
# 0.0.4 / 2014-02-04
* update cache method
* update cache method
0.0.2 / 2014-02-04
==================
# 0.0.2 / 2014-02-04
* fix gz upload
* update logging padding
* add cache feature
* fix gz upload
* update logging padding
* add cache feature
0.0.1 / 2014-02-03
==================
# 0.0.1 / 2014-02-03
* first commit
* first commit

@@ -7,4 +7,8 @@ var xmlNodes = require('xml-nodes');

var nodes = xmlNodes(nodeFilter);
var objects = xmlObjects({ explicitRoot: false, explicitArray: false, mergeAttrs: true });
return pumpify.obj(nodes, objects)
var objects = xmlObjects({
explicitRoot: false,
explicitArray: false,
mergeAttrs: true
});
return pumpify.obj(nodes, objects);
};
var AWS = require('aws-sdk'),
converter = require('./converter'),
Stream = require('stream'),
fs = require('fs'),
through = require('through2'),
zlib = require('zlib'),
crypto = require('crypto'),
mime = require('mime-types'),
pascalCase = require('pascal-case'),
Vinyl = require('vinyl'),
PluginError = require('plugin-error');
converter = require('./converter'),
Stream = require('stream'),
fs = require('fs'),
through = require('through2'),
zlib = require('zlib'),
crypto = require('crypto'),
mime = require('mime-types'),
pascalCase = require('pascal-case'),
Vinyl = require('vinyl'),
PluginError = require('plugin-error');

@@ -39,8 +39,7 @@ var PLUGIN_NAME = 'gulp-awspublish';

function getContentType(file) {
var mimeType = mime.lookup(file.unzipPath || file.path) || 'application/octet-stream';
var mimeType =
mime.lookup(file.unzipPath || file.path) || 'application/octet-stream';
var charset = mime.charset(mimeType);
return charset
? mimeType + '; charset=' + charset.toLowerCase()
: mimeType;
return charset ? mimeType + '; charset=' + charset.toLowerCase() : mimeType;
}

@@ -59,9 +58,6 @@

if (header === 'x-amz-acl') {
params.ACL = headers[header];
} else if(header ==='Content-MD5') {
params['ContentMD5'] = headers[header];
} else if (header === 'Content-MD5') {
params.ContentMD5 = headers[header];
} else {
params[pascalCase(header)] = headers[header];

@@ -105,3 +101,3 @@ }

function fileShouldBeDeleted (key, whitelist) {
function fileShouldBeDeleted(key, whitelist) {
for (var i = 0; i < whitelist.length; i++) {

@@ -118,3 +114,5 @@ var expr = whitelist[i];

} else {
throw new Error('whitelist param can only contain regular expressions or strings');
throw new Error(
'whitelist param can only contain regular expressions or strings'
);
}

@@ -128,3 +126,5 @@ }

var deleteObjects = keys.map(function (k) { return { Key: k }; });
var deleteObjects = keys.map(function(k) {
return { Key: k };
});

@@ -147,2 +147,3 @@ return {

* ext: extension to add to gzipped files
* smaller: whether to only gzip files if the result is smaller
*

@@ -154,8 +155,6 @@ * @return {Stream}

module.exports.gzip = function(options) {
if (!options) options = {};
if (!options.ext) options.ext = '';
return through.obj(function (file, enc, cb) {
return through.obj(function(file, enc, cb) {
// Do nothing if no contents

@@ -166,4 +165,6 @@ if (file.isNull()) return cb();

if (file.isStream()) {
this.emit('error',
new PluginError(PLUGIN_NAME, 'Stream content is not supported'));
this.emit(
'error',
new PluginError(PLUGIN_NAME, 'Stream content is not supported')
);
return cb();

@@ -174,11 +175,11 @@ }

if (file.isBuffer()) {
initFile(file);
// add content-encoding header
file.s3.headers['Content-Encoding'] = 'gzip';
// zip file
zlib.gzip(file.contents, options, function(err, buf) {
if (err) return cb(err);
if (options.smaller && buf.length >= file.contents.length)
return cb(err, file);
// add content-encoding header
file.s3.headers['Content-Encoding'] = 'gzip';
file.unzipPath = file.path;

@@ -221,7 +222,7 @@ file.path += options.ext;

// init Cache file
this._cacheFile = cacheOptions && cacheOptions.cacheFileName
? cacheOptions.cacheFileName
: '.awspublish-' + bucket;
this._cacheFile =
cacheOptions && cacheOptions.cacheFileName
? cacheOptions.cacheFileName
: '.awspublish-' + bucket;

@@ -255,3 +256,3 @@ // load cache

var _this = this,
counter = 0;
counter = 0;

@@ -262,5 +263,4 @@ function saveCache() {

var stream = through.obj(function (file, enc, cb) {
var stream = through.obj(function(file, enc, cb) {
if (file.s3 && file.s3.path) {
// do nothing for file already cached

@@ -273,3 +273,3 @@ if (file.s3.state === 'cache') return cb(null, file);

// update others
// update others
} else if (file.s3.etag) {

@@ -291,3 +291,2 @@ _this._cache[file.s3.path] = file.s3.etag;

/**

@@ -308,4 +307,3 @@ * create a through stream that publish files to s3

Publisher.prototype.publish = function (headers, options) {
Publisher.prototype.publish = function(headers, options) {
var _this = this;

@@ -320,5 +318,6 @@

// add public-read header by default
if(!headers['x-amz-acl'] && !options.noAcl) headers['x-amz-acl'] = 'public-read';
if (!headers['x-amz-acl'] && !options.noAcl)
headers['x-amz-acl'] = 'public-read';
return through.obj(function (file, enc, cb) {
return through.obj(function(file, enc, cb) {
var header, etag;

@@ -331,4 +330,6 @@

if (file.isStream()) {
this.emit('error',
new PluginError(PLUGIN_NAME, 'Stream content is not supported'));
this.emit(
'error',
new PluginError(PLUGIN_NAME, 'Stream content is not supported')
);
return cb();

@@ -339,3 +340,2 @@ }

if (file.isBuffer()) {
initFile(file);

@@ -356,6 +356,8 @@

// add content-type header
if (!file.s3.headers['Content-Type']) file.s3.headers['Content-Type'] = getContentType(file);
if (!file.s3.headers['Content-Type'])
file.s3.headers['Content-Type'] = getContentType(file);
// add content-length header
if (!file.s3.headers['Content-Length']) file.s3.headers['Content-Length'] = file.contents.length;
if (!file.s3.headers['Content-Length'])
file.s3.headers['Content-Length'] = file.contents.length;

@@ -386,7 +388,5 @@ // add extra headers

// update: file are different
// update: file are different
} else {
file.s3.state = res.ETag
? 'update'
: 'create';
file.s3.state = res.ETag ? 'update' : 'create';

@@ -417,6 +417,5 @@ _this.client.putObject(toAwsParams(file), function(err) {

var client = this.client,
stream = new Stream.Transform({ objectMode : true }),
newFiles = {},
prefix = prefix || '',
whitelistedFiles = whitelistedFiles || [];
stream = new Stream.Transform({ objectMode: true }),
newFiles = {};
(prefix = prefix || ''), (whitelistedFiles = whitelistedFiles || []);

@@ -432,9 +431,10 @@ // push file to stream and add files to s3 path to list of new files

var toDelete = [],
lister;
lister;
lister = client.listObjects({ Prefix: prefix })
lister = client
.listObjects({ Prefix: prefix })
.createReadStream()
.pipe(converter('Key'));
lister.on('data', function (key) {
lister.on('data', function(key) {
var deleteFile;

@@ -474,4 +474,4 @@ if (newFiles[key]) return;

exports.create = function(AWSConfig, cacheOptions){
exports.create = function(AWSConfig, cacheOptions) {
return new Publisher(AWSConfig, cacheOptions);
};
var pad = require('pad-component'),
colors = require('ansi-colors');
fancyLog = require('fancy-log');
colors = require('ansi-colors'),
fancyLog = require('fancy-log'),
through = require('through2');

@@ -17,8 +17,8 @@

var stream = through.obj(function (file, enc, cb) {
var stream = through.obj(function(file, enc, cb) {
var state;
if (!file.s3) return cb(null, file);
if (!file.s3.state) return cb(null, file);
if (options.states &&
options.states.indexOf(file.s3.state) === -1) return cb(null, file);
if (options.states && options.states.indexOf(file.s3.state) === -1)
return cb(null, file);

@@ -25,0 +25,0 @@ state = '[' + file.s3.state + ']';

{
"name": "gulp-awspublish",
"version": "3.3.3",
"version": "3.4.0",
"description": "gulp plugin to publish files to amazon s3",

@@ -24,2 +24,4 @@ "keywords": [

"scripts": {
"lint": "prettier --single-quote --write **/*.js && eslint --fix .",
"pretest": "npm run lint",
"test": "istanbul test _mocha --report html -- test/*.js --reporter spec",

@@ -47,2 +49,3 @@ "coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"

"coveralls": "*",
"eslint": "^4.18.2",
"event-stream": "^3.2.1",

@@ -53,3 +56,4 @@ "gulp": "^3.9.0",

"mocha": "*",
"mocha-lcov-reporter": "*"
"mocha-lcov-reporter": "*",
"prettier": "1.11.1"
},

@@ -56,0 +60,0 @@ "engines": {

# gulp-awspublish
[![NPM version][npm-image]][npm-url] [![Dependency Status][depstat-image]][depstat-url]

@@ -17,36 +18,41 @@

```javascript
var awspublish = require('gulp-awspublish');
var awspublish = require("gulp-awspublish");
gulp.task('publish', function() {
gulp.task("publish", function() {
// create a new publisher using S3 options
// http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property
var publisher = awspublish.create({
region: 'your-region-id',
params: {
Bucket: '...'
var publisher = awspublish.create(
{
region: "your-region-id",
params: {
Bucket: "..."
}
},
{
cacheFileName: "your-cache-location"
}
}, {
cacheFileName: 'your-cache-location'
});
);
// define custom headers
var headers = {
'Cache-Control': 'max-age=315360000, no-transform, public'
"Cache-Control": "max-age=315360000, no-transform, public"
// ...
};
return gulp.src('./public/*.js')
// gzip, Set Content-Encoding headers and add .gz extension
.pipe(awspublish.gzip({ ext: '.gz' }))
return (
gulp
.src("./public/*.js")
// gzip, Set Content-Encoding headers and add .gz extension
.pipe(awspublish.gzip({ ext: ".gz" }))
// publisher will add Content-Length, Content-Type and headers specified above
// If not specified it will set x-amz-acl to public-read by default
.pipe(publisher.publish(headers))
// publisher will add Content-Length, Content-Type and headers specified above
// If not specified it will set x-amz-acl to public-read by default
.pipe(publisher.publish(headers))
// create a cache file to speed up consecutive uploads
.pipe(publisher.cache())
// create a cache file to speed up consecutive uploads
.pipe(publisher.cache())
// print upload updates to console
.pipe(awspublish.reporter());
// print upload updates to console
.pipe(awspublish.reporter())
);
});

@@ -101,7 +107,7 @@

1. Create an S3 bucket which will be used for the tests. Optionally create an IAM user for running the tests.
2. Set the buckets Permission, so it can be edited by the IAM user who will run the tests.
3. Add an aws-credentials.json file to the project directory with the name of your testing buckets
and the credentials of the user who will run the tests.
4. Run `npm test`
1. Create an S3 bucket which will be used for the tests. Optionally create an IAM user for running the tests.
2. Set the buckets Permission, so it can be edited by the IAM user who will run the tests.
3. Add an aws-credentials.json file to the project directory with the name of your testing buckets
and the credentials of the user who will run the tests.
4. Run `npm test`

@@ -130,5 +136,7 @@ ```json

Available options:
- ext: file extension to add to gzipped file (eg: { ext: '.gz' })
- Any options that can be passed to [zlib.gzip](https://nodejs.org/api/zlib.html#zlib_options)
* ext: file extension to add to gzipped file (eg: { ext: '.gz' })
* smaller: gzip files only when result is smaller
* Any options that can be passed to [zlib.gzip](https://nodejs.org/api/zlib.html#zlib_options)
### awspublish.create(AWSConfig, cacheOptions)

@@ -142,2 +150,3 @@

#### Adjusting upload timeout
The AWS client has a default timeout which may be too low when pushing large files (> 50mb).

@@ -154,10 +163,10 @@ To adjust timeout, add `httpOptions: { timeout: 300000 }` to the AWSConfig object.

```
```javascript
var publisher = awspublish.create({
region: 'your-region-id',
region: "your-region-id",
params: {
Bucket: '...'
Bucket: "..."
},
accessKeyId: 'akid',
secretAccessKey: 'secret'
accessKeyId: "akid",
secretAccessKey: "secret"
});

@@ -168,11 +177,11 @@ ```

```
var AWS = require('aws-sdk');
```javascript
var AWS = require("aws-sdk");
var publisher = awspublish.create({
region: 'your-region-id',
region: "your-region-id",
params: {
Bucket: '...'
Bucket: "..."
},
credentials: new AWS.SharedIniFileCredentials({profile: 'myprofile'})
credentials: new AWS.SharedIniFileCredentials({ profile: "myprofile" })
});

@@ -186,19 +195,20 @@ ```

Create a through stream, that push files to s3.
- header: hash of headers to add or override to existing s3 headers.
- options: optional additional publishing options
- force: bypass cache / skip
- noAcl: do not set x-amz-acl by default
- simulate: debugging option to simulate s3 upload
- createOnly: skip file updates
* header: hash of headers to add or override to existing s3 headers.
* options: optional additional publishing options
* force: bypass cache / skip
* noAcl: do not set x-amz-acl by default
* simulate: debugging option to simulate s3 upload
* createOnly: skip file updates
Files that go through the stream receive extra properties:
- s3.path: s3 path
- s3.etag: file etag
- s3.date: file last modified date
- s3.state: publication state (create, update, delete, cache or skip)
- s3.headers: s3 headers for this file. Defaults headers are:
- x-amz-acl: public-read
- Content-Type
- Content-Length
* s3.path: s3 path
* s3.etag: file etag
* s3.date: file last modified date
* s3.state: publication state (create, update, delete, cache or skip)
* s3.headers: s3 headers for this file. Defaults headers are:
* x-amz-acl: public-read
* Content-Type
* Content-Length

@@ -217,13 +227,16 @@ > Note: `publish` will never delete files remotely. To clean up unused remote files use `sync`.

create a transform stream that delete old files from the bucket.
- prefix: prefix to sync a specific directory
- whitelistedFiles: array that can contain regular expressions or strings that match against filenames that
should never be deleted from the bucket.
* prefix: prefix to sync a specific directory
* whitelistedFiles: array that can contain regular expressions or strings that match against filenames that
should never be deleted from the bucket.
e.g.
```js
// only directory bar will be synced
// files in folder /foo/bar and file baz.txt will not be removed from the bucket despite not being in your local folder
gulp.src('./public/*')
gulp
.src("./public/*")
.pipe(publisher.publish())
.pipe(publisher.sync('bar', [/^foo\/bar/, 'baz.txt']))
.pipe(publisher.sync("bar", [/^foo\/bar/, "baz.txt"]))
.pipe(awspublish.reporter());

@@ -236,3 +249,4 @@ ```

// this will publish and sync bucket files with the one in your public directory
gulp.src('./public/*')
gulp
.src("./public/*")
.pipe(publisher.publish())

@@ -247,3 +261,2 @@ .pipe(publisher.sync())

// ...
```

@@ -260,12 +273,16 @@

Available options:
- states: list of state to log (default to all)
* states: list of state to log (default to all)
```js
// this will publish,sync bucket files and print created, updated and deleted files
gulp.src('./public/*')
gulp
.src("./public/*")
.pipe(publisher.publish())
.pipe(publisher.sync())
.pipe(awspublish.reporter({
states: ['create', 'update', 'delete']
}));
.pipe(
awspublish.reporter({
states: ["create", "update", "delete"]
})
);
```

@@ -282,9 +299,12 @@

gulp.src('examples/fixtures/*.js')
.pipe(rename(function (path) {
path.dirname += '/s3-examples';
path.basename += '-s3';
}))
.pipe(publisher.publish())
.pipe(awspublish.reporter());
gulp
.src("examples/fixtures/*.js")
.pipe(
rename(function(path) {
path.dirname += "/s3-examples";
path.basename += "-s3";
})
)
.pipe(publisher.publish())
.pipe(awspublish.reporter());

@@ -304,3 +324,3 @@ // output

gulp
.src('examples/fixtures/*.js')
.src("examples/fixtures/*.js")
.pipe(parallelize(publisher.publish(), 10))

@@ -317,5 +337,5 @@ .pipe(awspublish.reporter());

```js
var merge = require('merge-stream');
var gzip = gulp.src('public/**/*.js').pipe(awspublish.gzip());
var plain = gulp.src([ 'public/**/*', '!public/**/*.js' ]);
var merge = require("merge-stream");
var gzip = gulp.src("public/**/*.js").pipe(awspublish.gzip());
var plain = gulp.src(["public/**/*", "!public/**/*.js"]);

@@ -331,2 +351,3 @@ merge(gzip, plain)

### gulp-awspublish-router
A router for defining file-specific rules

@@ -336,2 +357,3 @@ https://www.npmjs.org/package/gulp-awspublish-router

### gulp-cloudfront-invalidate-aws-publish
Invalidate cloudfront cache based on output from awspublish

@@ -346,4 +368,3 @@ https://www.npmjs.com/package/gulp-cloudfront-invalidate-aws-publish

[npm-image]: https://badge.fury.io/js/gulp-awspublish.svg
[depstat-url]: https://david-dm.org/pgherveou/gulp-awspublish
[depstat-image]: https://david-dm.org/pgherveou/gulp-awspublish.svg
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