Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Fix deploying to aws v4 regions #21

Merged
merged 6 commits into from
Dec 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 25 additions & 20 deletions dist/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
fs = require('fs'),
Q = require('q'),
_ = require('lodash'),
s3 = require('s3'),
s3sync = require('s3-sync-aws'),
readdirp = require('readdirp'),
loginFile = path.join(process.cwd(), '.chcplogin');

module.exports = {
Expand Down Expand Up @@ -57,35 +58,39 @@
// console.log('Credentials: ', credentials);
// console.log('Config: ', config);

var client = s3.createClient({
maxAsyncS3: 20,
s3RetryCount: 3,
s3RetryDelay: 1000,
multipartUploadThreshold: 20971520,
multipartUploadSize: 15728640,
s3Options: {
accessKeyId: credentials.key,
secretAccessKey: credentials.secret,
region: config.s3region
}
var files = readdirp({
root: context.sourceDirectory
});
var params = {
localDir: context.sourceDirectory,
deleteRemoved: true,
s3Params: {
Bucket: config.s3bucket,
ACL: 'public-read',

var uploader = s3sync({
key: credentials.key,
secret: credentials.secret,
region: config.s3region,
bucket: config.s3bucket,
acl: 'public-read',
headers: {
CacheControl: 'no-cache, no-store, must-revalidate',
Expires: 0
},
concurrency: 20
}).on('data', function (file) {
if (file.fresh) {
console.log("Updated " + file.fullPath + ' -> ' + file.url);
}
};
});

files.pipe(uploader);

console.log('Deploy started');
var uploader = client.uploadDir(params);
uploader.on('error', function (err) {
console.error("unable to sync:", err.stack);
executeDfd.reject();
});
uploader.on('fail', function (err) {
console.error("unable to sync:", err);
executeDfd.reject();
});

//uploader.on('progress', function() {
// var progress = uploader.progressTotal - uploader.progressAmount;
// console.log("progress", progress, uploader.progressTotal, uploader.progressAmount);
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,18 @@
"es6-promise": "^2.3.0",
"express": "^4.13.1",
"fs-extra": "^0.22.1",
"hidefile": "^1.1.0",
"lodash": "^3.10.0",
"minimatch": "^3.0.0",
"ngrok": "^0.1.99",
"prompt": "^0.2.14",
"q": "^1.4.1",
"readdirp": "^2.0.0",
"recursive-readdir": "^1.2.1",
"s3": "^4.4.0",
"s3-sync-aws": "^1.1.0",
"socket.io": "^1.3.6",
"watch": "^0.16.0",
"yargs": "^3.16.1",
"minimatch": "^3.0.0",
"hidefile": "^1.1.0"
"yargs": "^3.16.1"
},
"devDependencies": {
"babel": "^5.8.19",
Expand Down
45 changes: 25 additions & 20 deletions src/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
fs = require('fs'),
Q = require('q'),
_ = require('lodash'),
s3 = require('s3'),
s3sync = require('s3-sync-aws'),
readdirp = require('readdirp'),
loginFile = path.join(process.cwd(), '.chcplogin');

module.exports = {
Expand Down Expand Up @@ -55,35 +56,39 @@
// console.log('Credentials: ', credentials);
// console.log('Config: ', config);

var client = s3.createClient({
maxAsyncS3: 20,
s3RetryCount: 3,
s3RetryDelay: 1000,
multipartUploadThreshold: 20971520,
multipartUploadSize: 15728640,
s3Options: {
accessKeyId: credentials.key,
secretAccessKey: credentials.secret,
region: config.s3region
},
var files = readdirp({
root: context.sourceDirectory
});
var params = {
localDir: context.sourceDirectory,
deleteRemoved: true,
s3Params: {
Bucket: config.s3bucket,
ACL: 'public-read',

var uploader = s3sync({
key: credentials.key,
secret: credentials.secret,
region: config.s3region,
bucket: config.s3bucket,
acl: 'public-read',
headers: {
CacheControl: 'no-cache, no-store, must-revalidate',
Expires: 0
},
};
concurrency: 20
}).on('data', function(file) {
if (file.fresh) {
console.log("Updated " + file.fullPath + ' -> ' + file.url)
}
});

files.pipe(uploader);

console.log('Deploy started');
var uploader = client.uploadDir(params);
uploader.on('error', function(err) {
console.error("unable to sync:", err.stack);
executeDfd.reject();
});
uploader.on('fail', function(err) {
console.error("unable to sync:", err);
executeDfd.reject();
});

//uploader.on('progress', function() {
// var progress = uploader.progressTotal - uploader.progressAmount;
// console.log("progress", progress, uploader.progressTotal, uploader.progressAmount);
Expand Down