Example #1
0
gulp.task('deploy', function () {
    var publisher = awspublish.create({ key: process.env.AWS_KEY,  secret: process.env.AWS_SECRET, bucket: 'mapworldnews.com' });

    var headers = {
        'Cache-Control': 'max-age=315360000, no-transform, public'
        // ...
    };

    gulp.src('./iris/static/index.html')
        .pipe(publisher.publish(headers))
        .pipe(publisher.cache())
        .pipe(awspublish.reporter());

    gulp.src('./iris/static/js/**')

        // gzip, Set Content-Encoding headers and add .gz extension
        // .pipe(awspublish.gzip({ ext: '.gz' }))

        .pipe(rename(function (path) {
            path.dirname = '/static/js/' + path.dirname;
        }))

        // 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())

         // print upload updates to console
        .pipe(awspublish.reporter());

    gulp.src('./iris/static/css/*')
        .pipe(rename(function (path) {
            path.dirname += '/static/css';
        }))
        .pipe(publisher.publish(headers))
        .pipe(publisher.cache())
        .pipe(awspublish.reporter());

    gulp.src('./iris/static/img/*')
        .pipe(rename(function (path) {
            path.dirname += '/static/img';
        }))
        .pipe(publisher.publish(headers))
        .pipe(publisher.cache())
        .pipe(awspublish.reporter());

    gulp.src('./iris/static/json/*')
        .pipe(rename(function (path) {
            path.dirname += '/static/json';
        }))
        .pipe(publisher.publish(headers))
        .pipe(publisher.cache())
        .pipe(awspublish.reporter());

});
  gulp.task('upload', ['clean','build'], function(done) {

    var folderName = 'snapshot';
    if(process.env.BRANCH) {
      folderName = process.env.BRANCH;
    }

    if(folderName.lastIndexOf('/') >= 0) {
      folderName = folderName.slice(folderName.lastIndexOf('/') + 1);
    }

    var publisher = awspublish.create({
      params: {
        Bucket: 'bancaplus-web'
      },
      "accessKeyId": process.env.AWS_KEY,
      "secretAccessKey": process.env.AWS_SECRET
    });

    gulp.src('**/*', { cwd: 'dist' })
      .pipe(rename(function(path){
        path.dirname = folderName + '/' + path.dirname;
      }))
      .pipe(publisher.publish())
      .pipe(awspublish.reporter())
      .on('end', done);
  });
Example #3
0
gulp.task('aws', function () {
  var awsConfig = require('./aws_config.json');

  // create a new publisher
  var publisher = awspublish.create(awsConfig);

  // define custom headers
  var headers = {
    'Cache-Control': 'max-age=315360000, no-transform, public'
  };

  return gulp.src(paths.dist + '/**/*')

    // gzip, Set Content-Encoding headers and add .gz extension
     .pipe(awspublish.gzip())

    // 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())

    // print upload updates to console
    .pipe(awspublish.reporter());

    // invalidate root files in cloudfront to update
    //.pipe(cloudfront(invalidationBatch, aws));
});
Example #4
0
gulp.task('s3:upload', function(){
  init();
  return gulp.src('dist/**/*')
    .pipe(awspublish.gzip())
    .pipe(parallelize(publisher.publish({}, { force: true }), 10))
    .pipe(awspublish.reporter());
});
Example #5
0
gulp.task('deploy', function() {
  return gulp.src(config.dist)
     // gzip, Set Content-Encoding headers and add .gz extension
    .pipe(parallelize(publisher.publish(headers, 'force'), 50))
    .pipe(publisher.cache())
    .pipe(awspublish.reporter());
});
Example #6
0
gulp.task('deploy', function() {
  if (!awsCredentials) {
    console.log("Aws-credentials.json is missing. You will be unable to publish. " +
      "To publish, create a file in the project root called aws-credentials.json. Example:");
    console.log('{\n' +
      '  "params": {\n' +
      '    "Bucket": "the-bucket-name-goes-here"\n' +
      '  },\n' +
      '  "accessKeyId": "your-aws-access-key-id",\n' +
      '  "secretAccessKey": "your-aws-secret-access-key"\n' +
    '}');
    return;
  }

  var plain = gulp.src('dist/assets/**/*', { base: 'dist' });
  var gzip = gulp.src(['dist/**/*', '!dist/assets/images/**/*'])
    .pipe(awspublish.gzip());

  var publisher = awspublish.create(awsCredentials);

  return merge(gzip, plain)
    .pipe(publisher.publish({
      'Cache-Control': 'max-age=315360000, no-transform, public'
    }))
    .pipe(publisher.sync())
    .pipe(publisher.cache())
    .pipe(awspublish.reporter());
});
Example #7
0
gulp.task('publish', function (cb) {
  var awsCredentials = JSON.parse(fs.readFileSync(process.env.HOME + '/.aws/credentials.json'))[packageJson.appConfig.s3.profile];

  var publisher = awspublish.create({
    accessKeyId: awsCredentials.aws_access_key_id,
    secretAccessKey: awsCredentials.aws_secret_access_key,
    region: packageJson.appConfig.s3.region,
    params: {
      Bucket: packageJson.appConfig.s3.bucket
    }
  });

  var target = argv.target;

  if (!target) {
    throw new $.util.PluginError('publish', 'Specify a target using --target=<name>');
  }

  var destPath = 'public/dist/' + target + '/';
  var headers = {
    'Cache-Control': 'max-age=60, must-revalidate'
  };
  return gulp.src('server/public/dist/**/*')
    .pipe($.rename(function (p) {
      p.dirname = path.join(destPath, p.dirname);
    }))
    .pipe($.parallelize(publisher.publish(headers), 5))
    .pipe(awspublish.reporter());
});
Example #8
0
gulp.task('publish',['build'], function(done) {

	var aws;
	try {
		aws = require('./aws-config.json').AWS;
	}
	catch (ex) {
		console.log('>>> no config.json found', ex);
		done();
	}

	var publisher = awspublish.create({
		region: aws.Region,
		params: {Bucket: aws.Bucket},
		accessKeyId: aws.Credentials.AccessKeyId,
		secretAccessKey: aws.Credentials.SecretAccessKey
	});

	return gulp.src(['build/**/*.{html,css,js}'])
		.pipe(rename(function (path) {
			if(aws.FolderPath) {
				path.dirname = '/'+ aws.FolderPath +'/'+ path.dirname;
			}
		}))
		.pipe(awspublish.gzip())
		.pipe(publisher.publish({}, {simulate: debugMode, createOnly: false}))
		.pipe(publisher.cache())
		.pipe(awspublish.reporter());
});
Example #9
0
gulp.task('publish-s3', 'Sync the site to S3', (cb) => {
  // create a new publisher using S3 options
  // http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property
  var publisher = awspublish.create({
    region: 'us-west-1',
    params: {
      Bucket: 'typesetwithme'
    },
  });

  // define custom headers
  var headers = {
    'Cache-Control': 'max-age=2592000, no-transform, public'
  };

  return gulp.src('./dist/**/*.*')
    // 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))

    .pipe(publisher.sync())

    // create a cache file to speed up consecutive uploads
    .pipe(publisher.cache())

     // print upload updates to console
    .pipe(awspublish.reporter());
});
Example #10
0
gulp.task('s3', ['rev'], function () {
  var aws = JSON.parse(fs.readFileSync( './.aws.json' ));
  // create a new publisher using S3 options
  // http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property
  // https://www.npmjs.com/package/gulp-awspublish
  // https://www.npmjs.com/package/gulp-cloudfront
  aws.cloudfront.patternIndex = /^index\.[a-f0-9]{8}\.html(\.gz)*$/gi;
  var publisher = awspublish.create( aws.s3 );

  // define custom headers
  var headers = {
    'Cache-Control': 'max-age=315360000, no-transform, public'
  };

  return gulp.src('./.rev/**')
    // gzip, Set Content-Encoding headers and add .gz extension
    .pipe(awspublish.gzip())

    // 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())

    // update CloudFront distribution Default Root Object to latest revisioned index.html
    .pipe($.cloudfront(aws.cloudfront))

    // delete old files from the bucket
    .pipe(publisher.sync())

    // print upload updates to console
    .pipe(awspublish.reporter());
});
Example #11
0
function upload(){
    var publisher = awspublish.create({
        params: {
            Bucket: config.aws.bucket,
            Key:'./builds/'+yargsv.on+'/'+yargsv.repo+'.tar.gz'
        },
        region:config.aws.region,
        accessKeyId: config.aws.key,
        secretAccessKey: config.aws.secret
    });
 
    return gulp.src('./dist/*')
    .pipe(gulpRename(function(path) {
        path.dirname = 'builds/'+yargsv.on+'/';
    }))
     // 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())
 
    // create a cache file to speed up consecutive uploads 
    .pipe(publisher.cache())
 
     // print upload updates to console 
    .pipe(awspublish.reporter());
    
}
gulp.task('deploy-example-aws', function() {

    let bucket = 'example-partner-staging-viewsay',
        distributionId = "E3EOMUL56KH5LD";

    const aws = {
        "key": "AKIAILU7O2X5ZUUVNE2Q",
        "secret": "+vs+wRc/E2jlP1H6WnH1xmTo3cNT8r77xjL3mE+u",
        "accessKeyId": 'AKIAILU7O2X5ZUUVNE2Q',
        "secretAccessKey": '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',
        "region": "us-east-1",
        "distributionId": distributionId,
        "params": {
            "Bucket" : bucket
        }
    };

    var publisher = awspublish.create(aws),
        headers = {'Cache-Control': 'max-age=60, no-transform, public'},
        revAll = new RevAll({
            dontRenameFile: ['.png','.jpg'],
            dontUpdateReference : ['.png','.jpg']
        });

    return gulp.src(['example/**','!example/src/**'])
        .pipe(revAll.revision())
        .pipe(awspublish.gzip())
        .pipe(publisher.publish(headers))
        .pipe(publisher.cache())
        .pipe(awspublish.reporter({
            states: ['create', 'update', 'delete']
        }))
        .pipe(cloudfront(aws));
});
function publishToS3(credentials, fileSpec) {
    var publisher = awspublish.create(credentials);

    return gulp.src(fileSpec)
        .pipe(publisher.publish())
        .pipe(awspublish.reporter());
}
Example #14
0
gulp.task('publish-build', ['publish-fonts'], function () {
  if (!isS3Available()) {
    return;
  }

  var
    publisher, headers,
    awspublish = require('gulp-awspublish'),
    gzip = require('gulp-gzip');

  publisher = awspublish.create({
    params: {
      Bucket: 'jc-build'
    },
    accessKeyId: process.env.S3_KEY,
    secretAccessKey: process.env.S3_SECRET
  });

  headers = {
   'Cache-Control': 'max-age=31536000, no-transform, public',
   'Content-Encoding': 'gzip'
  };

  return gulp.src(paths.build + '/**/*.{css,js}')
    .pipe(gzip({ append: false }))
    .pipe(publisher.publish(headers))
    .pipe(awspublish.reporter());
});
Example #15
0
gulp.task('publish-fonts', function () {
  if (!isS3Available()) {
    return;
  }

  var
    publisher, headers,
    awspublish = require('gulp-awspublish'),
    gzip = require('gulp-gzip'),
    rename = require('gulp-rename');

  publisher = awspublish.create({
    params: {
      Bucket: 'jc-build'
    },
    accessKeyId: process.env.S3_KEY,
    secretAccessKey: process.env.S3_SECRET
  });

  headers = {
   'Cache-Control': 'max-age=604800, no-transform, public',
   'Content-Encoding': 'gzip'
  };

  return gulp.src(paths.fonts + '/**/*.{eot,svg,ttf,woff}')
    .pipe(gzip({ append: false }))
    .pipe(rename(function (path) {
        path.dirname += '/' + paths.fonts;
    }))
    .pipe(publisher.publish(headers))
    .pipe(awspublish.reporter());
});
Example #16
0
gulp.task('s3-setup', function() {
    var idempotent = true;
    init();
    if(!Config.isOnProduction) {
        return deleteBucket(idempotent)
        .then(createBucket)
        .then(makeBucketWebsite)
        .then(function(){
            var defered = Q.defer();
            gulp.src('dist/**/*')
                    .pipe(awspublish.gzip())
                    .pipe(parallelize(publisher.publish({}, { force: true }), 10))
                    .pipe(awspublish.reporter())
                    .on('error', defered.reject)
                    .on('end', defered.resolve);
            return defered.promise;
        })
        .catch(function(error){
            $.util.log('Error while doing the s3 setup');
            $.util.log(error);
            throw error;
        });
    } else {
        return gulp.src('dist/**/*')
            .pipe(awspublish.gzip())
            .pipe(parallelize(publisher.publish({}, { force: true }), 10))
            .pipe(publisher.sync())
            .pipe(awspublish.reporter());
    }
});
Example #17
0
gulp.task('aws', ['build'], function() {
  var cacheLife, publisher, headers;
  if (!process.env.AWS_KEY || !process.env.AWS_SECRET) {
    throw 'AWS credentials are required!';
  }
  cacheLife = (1000 * 60 * 60); // 1 hour (* 24 * 365)
  headers = {
    'Cache-Control': 'max-age=' + cacheLife + ', public'
  };
  publisher = aws.create({
    'accessKeyId': process.env.AWS_KEY,
    'secretAccessKey': process.env.AWS_SECRET,
    'params': {
      'Bucket': 'keen-js',
      'Expires': new Date(Date.now() + cacheLife)
    }
  });

  return gulp.src([
      './dist/' + pkg.name + '.js',
      './dist/' + pkg.name + '.min.js',
      './dist/' + pkg.name + '.css',
      './dist/' + pkg.name + '.min.css'
    ])
    .pipe(rename(function(path) {
      path.dirname += '/';
      var name = pkg.name + '-' + pkg.version;
      path.basename = (path.basename.indexOf('min') > -1) ? name + '.min' : name;
    }))
    .pipe(aws.gzip())
    .pipe(publisher.publish(headers, { force: true }))
    .pipe(publisher.cache())
    .pipe(aws.reporter());

});
Example #18
0
gulp.task('publish-beta', function() {

  // create a new publisher using S3 options
  var publisher = awspublish.create({
    params: {
      Bucket: 'blaaast-beta'
    },
    accessKeyId: process.env.AWS_STATIC_HOST_KEY,
    secretAccessKey: process.env.AWS_STATIC_HOST_SECRET,
    region: 'eu-central-1'
  });

  // define custom headers
  var headers = {
    'Cache-Control': 'public, must-revalidate, proxy-revalidate, max-age=0'
  };
  var headersStatics = {
    'Cache-Control': 'max-age=315360000, no-transform, public'
  };

  gulp.src(htmlPages)
    .pipe(awspublish.gzip({ ext: '.gz' }))
    .pipe(publisher.publish(headers, {
      // Always update index.html
      force: true
    }))
    .pipe(awspublish.reporter());

  gulp.src('./fonts/**')
    .pipe(rename(function (path) {
      path.dirname = 'fonts/' + path.dirname;
    }))
    .pipe(awspublish.gzip())
    .pipe(parallelize(publisher.publish(headersStatics), 50))
    .pipe(publisher.cache())
    .pipe(awspublish.reporter());

  return gulp.src('./build/**')
    .pipe(rename(function (path) {
      path.dirname = 'build/' + path.dirname;
    }))
    .pipe(awspublish.gzip())
    .pipe(parallelize(publisher.publish(headersStatics), 50))
    .pipe(publisher.cache())
    .pipe(awspublish.reporter());
});
Example #19
0
gulp.task('publish', function() {
    var publisher = awspublish.create(awsconfig);
    return gulp.src(paths.publish)
        .pipe(publisher.publish())
        .pipe(publisher.cache())
        .pipe(publisher.sync())
        .pipe(awspublish.reporter());
});
Example #20
0
gulp.task('sync', function() {
    gulp.src(config.dist)
    .pipe(publisher.publish())
    .pipe(publisher.sync())
    .pipe(awspublish.reporter({
        states: ['create', 'update', 'delete']
    }));
});
Example #21
0
gulp.task('build:s3:publish:assets', function () {
  validateAWSConfig()
  return gulp.src([
    '!' + buildPath + '/**/*.{html,html.gz}',
    buildPath + '/**'
  ])
    .pipe(publisher.publish(headers))
    .pipe(publisher.cache())
    .pipe(awspublish.reporter())
})
Example #22
0
gulp.task('s3:production', ['build:production'], function() {
  var awsConf = localConfig.getAwsConf('production');
  var publisher = awspublish.create(awsConf.keys);
  return gulp.src(localConfig.buildSrc)
    .pipe(awspublish.gzip({ ext: '' }))
    .pipe(publisher.publish(awsConf.headers))
    .pipe(publisher.cache())
    .pipe(publisher.sync())
    .pipe(awspublish.reporter());
});
Example #23
0
	runSequence('build', function() {
		gulp.src(localConfig.buildSrc)
		//.pipe(awspublish.gzip({ ext: '' }))
		.pipe(publisher.publish(awsConf.headers))
		.pipe(cloudfront(cfSettings))
		.pipe(publisher.cache())
		.pipe(publisher.sync())
		.pipe(awspublish.reporter());
		done();
	});
Example #24
0
gulp.task('publish', ['write-publish', 'prepare-publish', 'check'], function () {
    var publisher = awspublish.create({bucket: 'eastasiastudent.net'}),
        headers = {'Cache-Control': 'max-age=315360000, no-transform, public'};
    return gulp.src('./publish/**/*.*')
        .pipe(awspublish.gzip())
        .pipe(parallelize(publisher.publish(headers), 10))
        .pipe(publisher.sync())
        .pipe(publisher.cache())
        .pipe(awspublish.reporter());
});
Example #25
0
gulp.task('aws:publish', function() {
  var publisher = awspublish.create({bucket: process.env.AWS_BUCKET});
  //var headers = {'Cache-Control': 'max-age=315360000, public'};
  var headers = {};
  return gulp.src('./public/**/*')
    .pipe(awspublish.gzip())
    .pipe(parallelize(publisher.publish(headers), 20))
    .pipe(publisher.cache())
    .pipe(awspublish.reporter());
});
Example #26
0
 .then(function(){
     var defered = Q.defer();
     gulp.src('dist/**/*')
             .pipe(awspublish.gzip())
             .pipe(parallelize(publisher.publish({}, { force: true }), 10))
             .pipe(awspublish.reporter())
             .on('error', defered.reject)
             .on('end', defered.resolve);
     return defered.promise;
 })
Example #27
0
gulp.task('deploy', ['less', 'templates', 'jsmin'], function () {
    var aws = JSON.parse(fs.readFileSync('./aws.json'));
    var publisher = awspublish.create(aws);
    var headers = {
        'Cache-Control': 'max-age=315360000, no-transform, public'
    };
    return gulp.src('./assets/**').
        pipe(publisher.publish(headers)).
        pipe(publisher.cache()).
        pipe(awspublish.reporter());
});
Example #28
0
gulp.task('build:s3:publish:html', function () {
  validateAWSConfig()
  return gulp.src(buildPath + '/**/*.{html,html.gz}')
    .pipe(publisher.publish(headers))
    .pipe(publisher.cache())
    .pipe(awspublish.reporter())
    .pipe(cloudfront({
      distribution: process.env.CLOUDFRONT_DISTRIBUTION,
      indexRootPath: true
    }))
})
Example #29
0
gulp.task('publish', function() {
  var awspublish  = require('gulp-awspublish');
  var parallelize = require("concurrent-transform");
  var rename      = require("gulp-rename");
  var gulpif      = require("gulp-if");
  var path_join   = require('path').join;

  // Select bucket
  var bucket = process.env[
    "AWS_PACKAGE_BUCKET_" + (azk_gulp.yargs.argv.production ? "PROD" : "STAGE")
  ];

  // create a new publisher
  var publisher = awspublish.create({
    params: {
      Bucket: bucket,
    },
    accessKeyId: process.env.AWS_ACCESS_KEY_ID,
    secretAccessKey: process.env.AWS_SECRET_KEY,
    region: 'sa-east-1',
  });

  // define custom headers
  var headers = {
    'Cache-Control': 'max-age=31536000, no-transform, public',
  };

  var src = [
    'package/brew/*.tar.gz',
    'package/public/!(fedora20)/**/*',
    'package/fedora20/**/*',
    'package/public/!(fedora23)/**/*',
    'package/fedora23/**/*',
  ];

  var add_prefix = function(cond, prefix) {
    return gulpif(cond, rename(function (path) {
      path.dirname = path_join(prefix, path.dirname);
    }));
  };

  return gulp.src(src)
    // Set dest path
    .pipe(add_prefix(/package\/fedora20/, 'fedora20'))
    .pipe(add_prefix(/package\/fedora23/, 'fedora23'))
    .pipe(add_prefix(/package\/brew/, 'mac'))

    // 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(parallelize(publisher.publish(headers), 10))

    // print upload updates to console
    .pipe(awspublish.reporter());
});
Example #30
0
gulp.task('deploy', ['base'], function () {
    return gulp.src([gulp.paths.statics + '/**', '!'+ gulp.paths.dist + '/**/index.html'])
        .pipe(rename(function (path) {
            path.dirname = 'static/' + path.dirname;
        }))
        .pipe(awspublish.gzip())
        .pipe(publisher.publish(headers))
        .pipe(publisher.cache())
        .pipe(awspublish.reporter())
        .pipe(cloudfront(aws));
});