Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to gulp 4 and update others dev dependencies #2151

Merged
merged 4 commits into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ git:
language: node_js

node_js:
- 6
- 8
- 9
- 10

dist: trusty
sudo: false
81 changes: 35 additions & 46 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import gulp from 'gulp';
// and attach them to the `plugins` object
import plugins from 'gulp-load-plugins';

// Temporary solution until gulp 4
// https://github.com/gulpjs/gulp/issues/355
import runSequence from 'run-sequence';

import archiver from 'archiver';
import glob from 'glob';
import del from 'del';
Expand All @@ -20,19 +16,18 @@ import modernizr from 'modernizr';
import pkg from './package.json';
import modernizrConfig from './modernizr-config.json';


const dirs = pkg['h5bp-configs'].directories;

// ---------------------------------------------------------------------
// | Helper tasks |
// ---------------------------------------------------------------------

gulp.task('archive:create_archive_dir', () => {
gulp.task('archive:create_archive_dir', (done) => {
fs.mkdirSync(path.resolve(dirs.archive), '0755');
done();
});

gulp.task('archive:zip', (done) => {

const archiveName = path.resolve(dirs.archive, `${pkg.name}_v${pkg.version}.zip`);
const zip = archiver('zip');
const files = glob.sync('**/*.*', {
Expand All @@ -49,7 +44,6 @@ gulp.task('archive:zip', (done) => {
output.on('close', done);

files.forEach((file) => {

const filePath = path.resolve(dirs.dist, file);

// `zip.bulk` does not maintain the file
Expand All @@ -58,12 +52,11 @@ gulp.task('archive:zip', (done) => {
'name': file,
'mode': fs.statSync(filePath).mode
});

});

zip.pipe(output);
zip.finalize();

done();
});

gulp.task('clean', (done) => {
Expand All @@ -75,16 +68,6 @@ gulp.task('clean', (done) => {
});
});

gulp.task('copy', [
'copy:.htaccess',
'copy:index.html',
'copy:jquery',
'copy:license',
'copy:main.css',
'copy:misc',
'copy:normalize'
]);

gulp.task('copy:.htaccess', () =>
gulp.src('node_modules/apache-server-configs/dist/.htaccess')
.pipe(plugins().replace(/# ErrorDocument/g, 'ErrorDocument'))
Expand All @@ -94,12 +77,12 @@ gulp.task('copy:.htaccess', () =>
gulp.task('copy:index.html', () => {
const hash = ssri.fromData(
fs.readFileSync('node_modules/jquery/dist/jquery.min.js'),
{algorithms: ['sha256']}
{ algorithms: ['sha256'] }
);
let version = pkg.devDependencies.jquery;
let modernizrVersion = pkg.devDependencies.modernizr;

gulp.src(`${dirs.src}/index.html`)
return gulp.src(`${dirs.src}/index.html`)
.pipe(plugins().replace(/{{JQUERY_VERSION}}/g, version))
.pipe(plugins().replace(/{{MODERNIZR_VERSION}}/g, modernizrVersion))
.pipe(plugins().replace(/{{JQUERY_SRI_HASH}}/g, hash.toString()))
Expand All @@ -120,31 +103,26 @@ gulp.task('copy:license', () =>
gulp.task('copy:main.css', () => {
const banner = `/*! HTML5 Boilerplate v${pkg.version} | ${pkg.license} License | ${pkg.homepage} */\n\n`;

gulp.src(`node_modules/main.css/dist/main.css`)
return gulp.src('node_modules/main.css/dist/main.css')
.pipe(plugins().header(banner))
.pipe(plugins().autoprefixer({
browsers: ['last 2 versions', 'ie >= 9', '> 1%'],
cascade: false
}))
.pipe(gulp.dest(`${dirs.dist}/css`));
});

gulp.task('copy:misc', () =>
gulp.src([

// Copy all files
`${dirs.src}/**/*`,

// Exclude the following files
// (other tasks will handle the copying of these files)
`!${dirs.src}/css/main.css`,
`!${dirs.src}/index.html`

], {

// Include hidden files by default
dot: true

}).pipe(gulp.dest(dirs.dist))
);

Expand All @@ -153,42 +131,53 @@ gulp.task('copy:normalize', () =>
.pipe(gulp.dest(`${dirs.dist}/css`))
);

gulp.task('modernizr', (done) =>{

gulp.task('modernizr', (done) => {
modernizr.build(modernizrConfig, (code) => {
fs.writeFile(`${dirs.dist}/js/vendor/modernizr-${pkg.devDependencies.modernizr}.min.js`, code, done);
});

});

gulp.task('lint:js', () =>
gulp.src([
'gulpfile.js',
`${dirs.src}/js/*.js`,
`${dirs.test}/*.js`
]).pipe(plugins().jscs())
.pipe(plugins().eslint())
.pipe(plugins().eslint.failOnError())
);


// ---------------------------------------------------------------------
// | Main tasks |
// ---------------------------------------------------------------------
gulp.task(
'copy',
gulp.series(
'copy:.htaccess',
'copy:index.html',
'copy:jquery',
'copy:license',
'copy:main.css',
'copy:misc',
'copy:normalize'
)
);

gulp.task(
'build',
gulp.series(
gulp.parallel('clean', 'lint:js'),
'copy',
'modernizr'
)
);

gulp.task('archive', (done) => {
runSequence(
gulp.task(
'archive',
gulp.series(
'build',
'archive:create_archive_dir',
'archive:zip',
done);
});

gulp.task('build', (done) => {
runSequence(
['clean', 'lint:js'],
'copy', 'modernizr',
done);
});
'archive:zip'
)
);

gulp.task('default', ['build']);
gulp.task('default', gulp.series('build'));
Loading