Changed s3-sync dependency to the s3 module, better maintained. API hasn't changed
This commit is contained in:
@@ -1,24 +1,22 @@
|
||||
var s3 = require('s3');
|
||||
var chalk = require('chalk');
|
||||
var s3sync = require('s3-sync');
|
||||
var readdirp = require('readdirp');
|
||||
|
||||
module.exports = function(args) {
|
||||
|
||||
var config = {
|
||||
maxAsyncS3: args.concurrency,
|
||||
s3Options: {
|
||||
accessKeyId: args.aws_key || process.env.AWS_KEY,
|
||||
secretAccessKey: args.aws_secret || process.env.AWS_SECRET,
|
||||
region: args.region
|
||||
}
|
||||
};
|
||||
var client = s3.createClient(config);
|
||||
|
||||
var publicDir = this.config.public_dir;
|
||||
var log = this.log;
|
||||
|
||||
if (!args.hasOwnProperty('concurrency')) {
|
||||
args.concurrency = 8;
|
||||
}
|
||||
|
||||
if (!args.hasOwnProperty('aws_key')) {
|
||||
args.aws_key = process.env.AWS_KEY
|
||||
}
|
||||
|
||||
if (!args.hasOwnProperty('aws_secret')) {
|
||||
args.aws_secret = process.env.AWS_SECRET;
|
||||
}
|
||||
|
||||
if (!args.bucket || !args.aws_key || !args.aws_secret) {
|
||||
if (!args.bucket || !config.s3Options.accessKeyId || !config.s3Options.secretAccessKey) {
|
||||
var help = '';
|
||||
|
||||
help += 'You should configure deployment settings in _config.yml first!\n\n';
|
||||
@@ -35,21 +33,23 @@ module.exports = function(args) {
|
||||
console.log(help);
|
||||
return;
|
||||
}
|
||||
|
||||
var params = {
|
||||
localDir: publicDir,
|
||||
deleteRemoved: true,
|
||||
s3Params: {
|
||||
Bucket: args.bucket
|
||||
}
|
||||
}
|
||||
|
||||
// s3sync takes the same options arguments as `knox`,
|
||||
// plus some additional options listed above
|
||||
return readdirp({root: publicDir, entryType: 'both'})
|
||||
.pipe(s3sync({
|
||||
key: args.aws_key,
|
||||
secret: args.aws_secret,
|
||||
bucket: args.bucket,
|
||||
concurrency: args.concurrency,
|
||||
region: args.region
|
||||
}).on('data', function(file) {
|
||||
log.info(file.fullPath + ' -> ' + file.url)
|
||||
var uploader = client.uploadDir(params);
|
||||
|
||||
return uploader
|
||||
.on('progress', function() {
|
||||
log.info(uploader.progressAmount + ' / ' + uploader.progressTotal);
|
||||
}).on('end', function() {
|
||||
log.info('Done!');
|
||||
}).on('fail', function(err) {
|
||||
}).on('error', function(err) {
|
||||
log.error(err)
|
||||
}));
|
||||
});
|
||||
};
|
||||
22
package.json
22
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hexo-deployer-s3",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"description": "Amazon S3 deployer plugin for Hexo",
|
||||
"main": "index",
|
||||
"keywords": [
|
||||
@@ -10,10 +10,16 @@
|
||||
"deployer"
|
||||
],
|
||||
"author": "Nicholas Terwoord <nicholas.terwoord+code@gmail.com>",
|
||||
"contributors": [{
|
||||
"name": "Josh Strange",
|
||||
"email": "josh@joshstrange.com"
|
||||
}],
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Josh Strange",
|
||||
"email": "josh@joshstrange.com"
|
||||
},
|
||||
{
|
||||
"name": "Jack Guy",
|
||||
"email": "jack@thatguyjackguy.com"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/nt3rp/hexo-deployer-s3.git"
|
||||
@@ -25,9 +31,7 @@
|
||||
"hexo": "3.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^1.0.0",
|
||||
"level": "^0.18.0",
|
||||
"readdirp": "^0.3.3",
|
||||
"s3-sync": "^0.5.1"
|
||||
"chalk": "^1.1.1",
|
||||
"s3": "^4.4.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user