Skip to content

Commit

Permalink
Merge pull request #276 from mjeanroy/greenkeeper/gulp-4.0.0
Browse files Browse the repository at this point in the history
Update gulp to the latest version 🚀
  • Loading branch information
mjeanroy committed Dec 26, 2018
2 parents 892fdd2 + bcae8b5 commit 4ae09eb
Show file tree
Hide file tree
Showing 9 changed files with 347 additions and 90 deletions.
109 changes: 21 additions & 88 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,92 +22,25 @@
* SOFTWARE.
*/

const path = require('path');
const log = require('fancy-log');
const gulp = require('gulp');
const jasmine = require('gulp-jasmine');
const babel = require('gulp-babel');
const del = require('del');
const eslint = require('gulp-eslint');
const conventionalChangelog = require('gulp-conventional-changelog');
const git = require('gulp-git');
const bump = require('gulp-bump');
const runSequence = require('run-sequence');

const ROOT = __dirname;
const SRC = path.join(ROOT, 'src');
const TEST = path.join(ROOT, 'test');
const DIST = path.join(ROOT, 'dist');

gulp.task('test', ['build'], () => {
const src = [
path.join(TEST, 'base.spec.js'),
path.join(TEST, '**', '*.spec.js'),
];

return gulp.src(src).pipe(jasmine());
});

gulp.task('clean', () => {
return del([DIST]);
});

gulp.task('build', ['clean', 'lint'], () => {
return gulp.src(path.join(SRC, '*.js'))
.pipe(babel())
.pipe(gulp.dest(DIST));
});

gulp.task('lint', () => {
const src = [
path.join(ROOT, '*.js'),
path.join(SRC, '**', '*.js'),
path.join(TEST, '**', '*.js'),
];

return gulp.src(src)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});

gulp.task('changelog', () => {
const changelog = path.join(ROOT, 'CHANGELOG.md');
return gulp.src(changelog, {buffer: false})
.pipe(conventionalChangelog({
releaseCount: 0,
}))
.pipe(gulp.dest(ROOT));
});

gulp.task('commit:pre', () => {
const packageJson = path.join(ROOT, 'package.json');
return gulp.src([packageJson, DIST])
.pipe(git.add({args: '-f'}))
.pipe(git.commit('release: release version'));
});

gulp.task('commit:post', () => {
return gulp.src(DIST)
.pipe(git.rm({args: '-r'}))
.pipe(git.commit('release: prepare next release'));
});

gulp.task('tag', (done) => {
const pkg = require(path.join(ROOT, 'package.json'));
const version = pkg.version;
git.tag(`v${version}`, `release: tag version ${version}`, done);
});

['major', 'minor', 'patch'].forEach((level) => {
gulp.task(`bump:${level}`, () => {
return gulp.src(path.join(ROOT, 'package.json'))
.pipe(bump({type: level}))
.on('error', (e) => log.error(e))
.pipe(gulp.dest(ROOT));
});

gulp.task('release:' + level, ['build'], () => {
return runSequence(`bump:${level}`, 'commit:pre', 'tag', 'commit:post');
});
});
const clean = require('./scripts/clean');
const lint = require('./scripts/lint');
const build = require('./scripts/build');
const test = require('./scripts/test');
const release = require('./scripts/release');
const changelog = require('./scripts/changelog');

const prebuild = gulp.series(clean, lint);
const pretest = gulp.series(prebuild, build);
const prerelease = gulp.series(pretest, test);

module.exports = {
'clean': clean,
'lint': lint,
'build': gulp.series(prebuild, build),
'test': gulp.series(pretest, test),
'changelog': changelog,
'release:patch': gulp.series(prerelease, release.patch),
'release:minor': gulp.series(prerelease, release.minor),
'release:major': gulp.series(prerelease, release.major),
};
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"eslint": "5.5.0",
"eslint-config-google": "0.11.0",
"fancy-log": "1.3.3",
"gulp": "3.9.1",
"gulp": "4.0.0",
"gulp-babel": "8.0.0",
"gulp-bump": "3.1.1",
"gulp-conventional-changelog": "2.0.9",
Expand All @@ -53,7 +53,6 @@
"rollup": "0.68.2",
"rollup-plugin-commonjs": "9.2.0",
"rollup-plugin-node-resolve": "4.0.0",
"run-sequence": "2.2.1",
"tmp": "0.0.33"
}
}
34 changes: 34 additions & 0 deletions scripts/build/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2016 Mickael Jeanroy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

const path = require('path');
const gulp = require('gulp');
const babel = require('gulp-babel');
const config = require('../config');

module.exports = function build() {
return gulp.src(path.join(config.src, '**', '*.js'))
.pipe(babel())
.pipe(gulp.dest(config.dist));
};
35 changes: 35 additions & 0 deletions scripts/changelog/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2016 Mickael Jeanroy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

const path = require('path');
const gulp = require('gulp');
const conventionalChangelog = require('gulp-conventional-changelog');
const config = require('../config');

module.exports = function changelog() {
const changelog = path.join(config.root, 'CHANGELOG.md');
return gulp.src(changelog, {buffer: false})
.pipe(conventionalChangelog({releaseCount: 0}))
.pipe(gulp.dest(config.root));
};
30 changes: 30 additions & 0 deletions scripts/clean/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2016 Mickael Jeanroy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

const del = require('del');
const config = require('../config');

module.exports = function clean() {
return del([config.dist]);
};
35 changes: 35 additions & 0 deletions scripts/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2016 Mickael Jeanroy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

const path = require('path');
const ROOT = path.join(__dirname, '..');

module.exports = {
root: ROOT,
src: path.join(ROOT, 'src'),
test: path.join(ROOT, 'test'),
scripts: path.join(ROOT, 'scripts'),
dist: path.join(ROOT, 'dist'),
pkg: path.join(ROOT, 'package.json'),
};
42 changes: 42 additions & 0 deletions scripts/lint/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2016 Mickael Jeanroy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

const path = require('path');
const gulp = require('gulp');
const eslint = require('gulp-eslint');
const config = require('../config');

module.exports = function lint() {
const src = [
path.join(config.root, '*.js'),
path.join(config.src, '**', '*.js'),
path.join(config.test, '**', '*.js'),
path.join(config.scripts, '**', '*.js'),
];

return gulp.src(src)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
};
Loading

0 comments on commit 4ae09eb

Please sign in to comment.