-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,9 @@ git: | |
language: node_js | ||
|
||
node_js: | ||
- 6 | ||
- 8 | ||
- 9 | ||
- 10 | ||
|
||
dist: trusty | ||
sudo: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
@@ -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('**/*.*', { | ||
|
@@ -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 | ||
|
@@ -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) => { | ||
|
@@ -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')) | ||
|
@@ -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())) | ||
|
@@ -120,75 +103,81 @@ 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)) | ||
// Include hidden files by default | ||
dot: true | ||
}).pipe(gulp.dest(dirs.dist)) | ||
); | ||
|
||
gulp.task('copy:normalize', () => | ||
gulp.src('node_modules/normalize.css/normalize.css') | ||
.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')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eslint complains that this should have a semicolon at the end here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nitpick here - but the indentation is a little bit off. should be 4 spaces (not 6) on lines 124 and 125 and indent of 2 spaces on line 126.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed