diff --git a/.travis.yml b/.travis.yml index 65795c6..5c596ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,9 @@ node_js: - '4.4' script: -- gulp build - gulp lint +- gulp build +- gulp package deploy: provider: releases @@ -13,6 +14,7 @@ deploy: file: - "./dist/Chart.Deferred.js" - "./dist/Chart.Deferred.min.js" + - "./dist/Chart.Deferred.js.zip" skip_cleanup: true on: tags: true diff --git a/README.md b/README.md index 4d07bf4..c9c6e98 100644 --- a/README.md +++ b/README.md @@ -38,13 +38,19 @@ Note that default options will defer the chart loading until the first line of p ## Development -The following commands are available from the repository root (requires [Node.js](https://nodejs.org/)) +You first need to install node dependencies (requires [Node.js](https://nodejs.org/)): + +```shell +> npm install +``` + +The following commands will then be available from the repository root: ```shell -> npm install // initialize node dependencies > gulp build // build dist files > gulp build --watch // build and watch for changes > gulp lint // perform code linting +> gulp package // create an archive with dist files and samples ``` ## License diff --git a/gulpfile.js b/gulpfile.js index a73c451..03c040e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -7,11 +7,14 @@ var replace = require('gulp-replace'); var streamify = require('gulp-streamify'); var uglify = require('gulp-uglify'); var gutil = require('gulp-util'); +var zip = require('gulp-zip'); +var merge = require('merge2'); var path = require('path'); var package = require('./package.json'); var srcDir = './src/'; var outDir = './dist/'; +var samplesDir = './samples/'; var header = "/*!\n\ * Chart.Deferred.js\n\ @@ -25,6 +28,7 @@ var header = "/*!\n\ gulp.task('build', buildTask); gulp.task('lint', lintTask); +gulp.task('package', packageTask); gulp.task('default', ['build']); function watch(glob, task) { @@ -57,9 +61,28 @@ function buildTask() { } function lintTask() { - var files = [srcDir + '**/*.js']; + var files = [ + srcDir + '**/*.js', + samplesDir + '**/*.js' + ]; + return gulp.src(files) .pipe(eslint()) .pipe(eslint.format()) .pipe(eslint.failAfterError()); } + +function packageTask() { + return merge( + // gather "regular" files landing in the package root + gulp.src([outDir + '*.js', 'LICENSE.md']), + + // dist files in the package are in the root, so we need to rewrite samples + // src="../dist/ to src="../ and then copy them in the /samples directory. + gulp.src(samplesDir + '**/*', { base: '.' }) + .pipe(streamify(replace('src="../dist/', 'src="../'))) + ) + // finally, create the zip archive + .pipe(zip('Chart.Deferred.js.zip')) + .pipe(gulp.dest(outDir)); +} diff --git a/package.json b/package.json index 04b9878..66246a7 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,8 @@ "gulp-streamify": "^1.0.2", "gulp-uglify": "^1.5.3", "gulp-util": "^3.0.7", + "gulp-zip": "^3.2.0", + "merge2": "^1.0.2", "path": "^0.12.7", "yargs": "^4.7.1" }