Skip to content

Commit

Permalink
Merge pull request #4 from wkurniawan07/publish
Browse files Browse the repository at this point in the history
[ONLINE-239] Add means to publish new SDK versions
  • Loading branch information
wkurniawan07 committed Jan 24, 2019
2 parents c0900bc + 0ebeabd commit 1599096
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .npmignore
Expand Up @@ -5,3 +5,6 @@ webpack.config.js
testServer.js
test*.js
*.tgz
.codeclimate.yml
.eslintrc.js
aws-profile.json
1 change: 1 addition & 0 deletions aws-profile.json
@@ -0,0 +1 @@
{}
23 changes: 23 additions & 0 deletions gulpfile.js
Expand Up @@ -3,10 +3,12 @@ const uglify = require('gulp-uglify');
const sourcemaps = require('gulp-sourcemaps');
const stream = require('webpack-stream');
const rename = require('gulp-rename');
const awspublish = require('gulp-awspublish');
const replace = require('gulp-replace-task');
const { exec } = require('child_process');
const { version } = require('./package.json');
const webpackConfig = require('./webpack.config.js');
const awsProfile = require('./aws-profile.json');

const SETTINGS = {
DEST_BUILD: 'dist/js',
Expand Down Expand Up @@ -34,6 +36,27 @@ gulp.task('webpack-snippet', () => gulp.src('./examples/js/snippet.js') // gulp
.pipe(uglify()) // minifies the code for better compression
.pipe(gulp.dest(SETTINGS.DEST_BUILD)));

if (awsProfile && awsProfile.params && awsProfile.params.Bucket) {

// create a new publisher
const publisher = awspublish.create(awsProfile);

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

gulp.task('deploy', () => gulp.src(`dist/js/visearch-${version}.min.js`)
.pipe(rename((path) => {
// upload folder name
path.dirname = '/visearch/dist/js/';
}))
.pipe(awspublish.gzip({ ext: '' }))
.pipe(publisher.publish(headers, { force: true }))
.pipe(awspublish.reporter()));

}

gulp.task('watch', () => {
gulp.watch('./js/visearch.js', gulp.series('webpack'));
gulp.watch('./examples/js/snippet.js', gulp.series('webpack-snippet'));
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -22,6 +22,7 @@
"eslint-plugin-import": "^2.14.0",
"exports-loader": "^0.7.0",
"gulp": "^4.0.0",
"gulp-awspublish": "^4.0.0",
"gulp-rename": "^1.2.2",
"gulp-replace-task": "^0.11.0",
"gulp-sourcemaps": "^2.6.4",
Expand Down

0 comments on commit 1599096

Please sign in to comment.