From 1566c702ed01e7ba034f5ce4e730e088285d6931 Mon Sep 17 00:00:00 2001 From: Kushagra Gour Date: Thu, 21 Jun 2018 01:01:48 +0530 Subject: [PATCH] add extension packaging task --- .gitignore | 3 ++- gulpfile.js | 29 +++++++++++++++++++++++++++++ package.json | 1 + yarn.lock | 18 +++++++++++++++++- 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a7636f8..a53c3c1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ ### Misc ### node_modules/ *.map -.sass-cache \ No newline at end of file +.sass-cache +extension/ \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index e707005..85f92ae 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -10,6 +10,7 @@ const concat = require('gulp-concat'); const babelMinify = require('babel-minify'); const child_process = require('child_process'); const merge = require('merge-stream'); +const zip = require('gulp-zip'); function minifyJs(fileName) { const content = fs.readFileSync(fileName, 'utf8'); @@ -152,6 +153,33 @@ gulp.task('generate-service-worker', function(callback) { ); }); +gulp.task('packageExtension', function() { + child_process.execSync('cp -R app extension/'); + child_process.execSync('cp src/manifest.json extension'); + child_process.execSync('cp src/options.js extension'); + child_process.execSync('cp src/options.html extension'); + child_process.execSync('cp src/eventPage.js extension'); + child_process.execSync('cp src/icon-16.png extension'); + child_process.execSync( + 'rm -rf extension/service-worker.js extension/partials' + ); + return merge( + gulp + .src('build/bundle.*.js') + .pipe(rename('script.js')) + .pipe(gulp.dest('extension')), + gulp + .src('build/vendor.*.js') + .pipe(rename('vendor.js')) + .pipe(gulp.dest('extension')), + + gulp + .src('extension/*') + .pipe(zip('extension.zip')) + .pipe(gulp.dest('./')) + ); +}); + gulp.task('cleanup', function() { return child_process.execSync('rm -rf build'); }); @@ -165,6 +193,7 @@ gulp.task('release', function(callback) { 'concatSwRegistration', 'minify', 'generate-service-worker', + 'packageExtension', 'cleanup', function(error) { if (error) { diff --git a/package.json b/package.json index 2bc1d34..8e0e4d0 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "gulp-rename": "^1.3.0", "gulp-uglify": "^3.0.0", "gulp-useref": "^3.1.3", + "gulp-zip": "^4.1.0", "husky": "^0.14.3", "identity-obj-proxy": "^3.0.0", "if-env": "^1.0.0", diff --git a/yarn.lock b/yarn.lock index 0439023..449bda3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4463,6 +4463,16 @@ gulp-util@^3.0.0, gulp-util@^3.0.1: through2 "^2.0.0" vinyl "^0.5.0" +gulp-zip@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/gulp-zip/-/gulp-zip-4.1.0.tgz#dab178bd99afa190923f1eb78abaf0db47817704" + dependencies: + get-stream "^3.0.0" + plugin-error "^0.1.2" + through2 "^2.0.1" + vinyl "^2.1.0" + yazl "^2.1.0" + gulp@^3.9.1: version "3.9.1" resolved "https://registry.yarnpkg.com/gulp/-/gulp-3.9.1.tgz#571ce45928dd40af6514fc4011866016c13845b4" @@ -9692,7 +9702,7 @@ vinyl@^1.0.0: clone-stats "^0.0.1" replace-ext "0.0.1" -vinyl@^2.0.0: +vinyl@^2.0.0, vinyl@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.1.0.tgz#021f9c2cf951d6b939943c89eb5ee5add4fd924c" dependencies: @@ -10082,3 +10092,9 @@ yauzl@^2.2.1: dependencies: buffer-crc32 "~0.2.3" fd-slicer "~1.1.0" + +yazl@^2.1.0: + version "2.4.3" + resolved "https://registry.yarnpkg.com/yazl/-/yazl-2.4.3.tgz#ec26e5cc87d5601b9df8432dbdd3cd2e5173a071" + dependencies: + buffer-crc32 "~0.2.3"