Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gulp
.src(config.assetsPath)
.pipe(
rename(function(filepath) {
filepath.dirname = path.join(config.dirname, filepath.dirname);
}),
)
// gzip, Set Content-Encoding headers and add .gz extension
.pipe(gulpIf(file => !file.path.match(/\.(mp4|ogg|webm|avi|mov|mkv)$/), aws.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(aws.reporter())
);
}
// define custom headers
var headers = {
'Cache-Control': 'max-age=315360000, no-transform, public'
};
var revAll = new RevAll({
dontRenameFile: ['\.woff', '\.woff2', '\.svg', '\.ttf', '\.eot']
});
return gulp.src('./dist/app/**/*.*')
.pipe(revAll.revision())
.pipe(awspublish.gzip())
.pipe(publisher.publish(headers))
.pipe(publisher.cache())
.pipe(awspublish.reporter())
.pipe(cloudfront(aws));
});
question: deline`You're about to publish this project to AWS
under the directory '${awsDirectory}'.
In the process, we'll also wipe out any
uploads to the test directory.
Are you sure you want to do this?`,
input: '_key:y',
}))
.pipe(rename((filePath) => {
// eslint-disable-next-line no-param-reassign
filePath.dirname = awsDirectory + filePath.dirname.replace('.\\', '');
}))
.pipe(awspublishRouter(routes))
.pipe(publisher.publish({}, { force: false }))
.pipe(cloudfront(cfSettings))
.pipe(publisher.cache())
.pipe(awspublish.reporter())
.on(
'end',
gutil.log.bind(
gutil,
// eslint-disable-next-line comma-dangle
`Published at 'http://interactives.dallasnews.com/${awsDirectory}'.`
) // eslint-disable-line comma-dangle
);
};
return gulp
.src([
`./dist/static/js/${manifestJSON['vendor.js']}`,
`./dist/static/js/${manifestJSON['vendor.js.map']}`
])
.pipe(
rename(function renamePlugin(path) {
path.dirname = `/${vendor}/${path.dirname}`; // eslint-disable-line no-param-reassign
return path;
})
)
.pipe(awspublish.gzip())
.pipe(publisher.publish(headers))
.pipe(awspublish.reporter());
});
gulp.task('publish', function() {
var awsconfig = require('../../../aws-credentials')
var publisher = awspublish.create(awsconfig)
return gulp.src(config.publishPaths)
.pipe(publisher.publish({}))
.pipe(publisher.cache())
.pipe(awspublish.reporter())
})
dotenv.config();
var publisher = s3.create({
region: process.env.AWS_REGION,
params: {
Bucket: process.env.AWS_BUCKET
},
accessKeyId: process.env.AWS_KEY,
secretAccessKey: process.env.AWS_SECRET
});
return gulp.src(`${dest}/**/*`)
.pipe(publisher.publish({}, { noAcl: true }))
.pipe(publisher.cache())
.pipe(publisher.sync())
.pipe(s3.reporter());
});
secretAccessKey: awsConfig.secretAccessKey,
httpOptions: { timeout: 300000 }
})
const gzipFilter = filter(['cdnassets/**/*.{txt,csv,json,js,css}'], {restore: true})
return gulp.src('cdnassets/**/*.{jpg,png,gif,mp3,ogg,flac,mp4,mov,avi,webm,zip,rar,webp,txt,csv,json,pdf}')
.pipe(rename(function (path) {
path.dirname = `/cdnassets/projects/${initDate.year}/${initDate.month}/${config.projectSlug}/${path.dirname}`
}))
.pipe(gzipFilter)
.pipe(awspublish.gzip())
.pipe(gzipFilter.restore)
.pipe(publisherAssets.publish({}, {simulate: SIM, createOnly: true}))
.pipe(publisherAssets.cache())
.pipe(awspublish.reporter(''))
.on('finish', function () {
log.ok(`Published to: http://s3-${awsConfig.region}.amazonaws.com/${awsConfig.bucketName}/cdnassets/projects/`)
})
}
}
.pipe(aws.gzip())
.pipe(publisher.publish(jsHeaders, { force: true }))
.pipe(publisher.cache())
.pipe(aws.reporter());
return gulp.src([
'./dist/keen.css',
'./dist/keen.min.css'
])
.pipe(rename(function(path) {
path.dirname += '/' + pkg['version'];
}))
.pipe(aws.gzip())
.pipe(publisher.publish(cssHeaders, { force: true }))
.pipe(publisher.cache())
.pipe(aws.reporter());
});
gulp.task('upload-images', function() {
var publisher = awspublish.create(getAWSConfig());
return gulp.src(['public/images/**/*'])
.pipe(rename(function (path) {
path.dirname = 'images/' + path.dirname;
}))
.pipe(publisher.publish(s3Headers))
.pipe(publisher.cache())
.pipe(awspublish.reporter());
});