Use gulp for the dev pipeline (#2429)

Fixes #2332 #2355 
Creates #2446 #2447
This commit is contained in:
Veeck
2019-05-15 15:04:11 +02:00
committed by GitHub
parent 7599d26b7f
commit f5604363a5
11 changed files with 4728 additions and 2220 deletions

5
.babelrc Normal file
View File

@@ -0,0 +1,5 @@
{
"presets": [
"@babel/preset-env"
]
}

View File

@@ -1,27 +1,25 @@
sudo: false
language: node_js
node_js:
- 6
- 8
- 10
- 12
before_install:
- npm install -g npm@latest
before_script:
- npm install grunt-cli -g
- npm install -g gulp-cli
- export CI_BUILD_NUMBER=$(git rev-parse HEAD)
- if [ "${TRAVIS_NODE_VERSION}" = "0.12" ] && [ "${TRAVIS_REPO_SLUG}" = "modernizr-savage/Modernizr" ]; then export BROWSER_COVERAGE=true; fi
after_success:
- |
# Remove grunt-saucelabs since we don't use it on GH Pages, and it complains
# about large files in the repo from this module
npm uninstall --force grunt-saucelabs
# Automatically update the content from the `gh-pages` branch
$(npm bin)/update-branch --commands "grunt copy:gh-pages" \
$(npm bin)/update-branch --commands "gulp copy:gh-pages" \
--commit-message "Hey server, this content is for you! [skip ci]" \
--directory "gh-pages" \
--distribution-branch "gh-pages" \
--source-branch "master"
script:
- grunt test
- npm test
notifications:
webhooks:
- http://patrickkettner.com:8080/savage/travis

View File

@@ -1,13 +1,13 @@
# Modernizr
[![npm version](https://badge.fury.io/js/modernizr.svg)](https://badge.fury.io/js/modernizr)
[![Build Status](https://api.travis-ci.org/Modernizr/Modernizr.svg?branch=master)](https://travis-ci.org/Modernizr/Modernizr)
[![Coverage Status](https://coveralls.io/repos/github/Modernizr/Modernizr/badge.svg?branch=master)](https://coveralls.io/github/Modernizr/Modernizr?branch=master)
[![Inline docs](https://inch-ci.org/github/Modernizr/Modernizr.svg?branch=master)](https://inch-ci.org/github/Modernizr/Modernizr)
##### Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the users browser.
- [Website](https://modernizr.com)
- [Documentation](https://modernizr.com/docs/)
- [Test Suite](https://modernizr.github.io/Modernizr/test/)
Modernizr tests which native CSS3 and HTML5 features are available in the current UA and makes the results available to you in two ways: as properties on a global `Modernizr` object, and as classes on the `<html>` element. This information allows you to progressively enhance your pages with a granular level of control over the experience.
@@ -42,46 +42,9 @@ a method for exposing the `trigger` functionality. Instead, if you'd like to hav
- Clone or download the repository
- Install project dependencies with `npm install`
## Test suite
## Building Modernizr
Run the [test suite](https://modernizr.github.io/Modernizr/test/)
## Building Modernizr v3
### To generate everything in 'config-all.json':
```shell
npm install
./bin/modernizr -c lib/config-all.json
//outputs to ./modernizr.js
```
### To run tests on the console (in phantom):
```shell
grunt test
```
### To run tests in the browser:
```shell
grunt browserResults
```
then visit `http://localhost:9090/test/unit.html` for unit test results
or visit `http://localhost:9090/test/index.html` to see which features that browser supports
### To see the build tool:
* checkout the modernizr.com code
* install all your gems and bundles and jekyll
* `jekyll`
* `serve ./_sites`
* visit <url>/download
* It should be just a big list of things you can build with no frills.
### API Reference
### From javascript
Modernizr can be used programmatically via npm:
@@ -89,8 +52,6 @@ Modernizr can be used programmatically via npm:
var modernizr = require("modernizr");
```
#### Building
A `build` method is exposed for generating custom Modernizr builds. Example:
```javascript
@@ -105,6 +66,30 @@ The first parameter takes a JSON object of options and feature-detects to includ
The second parameter is a function invoked on task completion.
### From the command-line
We also provide a command line interface for building modernizr.
To see all available options run:
```shell
./bin/modernizr
```
Or to generate everything in 'config-all.json' run this with npm:
```shell
npm start
//outputs to ./dist/modernizr-build.js
```
## Testing Modernizr
To execute the tests on the console run:
```shell
npm test
```
## License
[MIT License](https://opensource.org/licenses/MIT)

View File

@@ -1,21 +1,16 @@
environment:
matrix:
- nodejs_version: 6
npm_version: 'latest'
- nodejs_version: 8
npm_version: 'latest'
- nodejs_version: 10
# Get the latest stable version of Node 0.STABLE.latest
install:
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)
- npm install -g npm@%npm_version%
- set PATH=%APPDATA%\npm;%PATH%
- ps: Install-Product node $env:nodejs_version
- npm install
build: off
before_test:
- npm install grunt-cli -g
- npm install -g gulp-cli
test_script:
- node --version

132
gulpfile.babel.js Normal file
View File

@@ -0,0 +1,132 @@
'use strict';
import gulp from 'gulp';
import gplugins from 'gulp-load-plugins';
import del from 'del';
import fs from 'fs-extra';
import globby from 'globby';
import Mocha from 'mocha';
import Mochaheadless from 'mocha-headless-chrome';
import modernizr from './lib/cli';
import config from './lib/config-all';
const directories = {
browserTests: globby.sync([
'test/universal/**/*.js',
'test/browser/**/*.js',
'!test/browser/setup.js',
'!test/browser/integration/*.js'
]),
integrationTests: globby.sync([
'test/browser/integration/*.js'
]),
nodeTests: globby.sync([
'test/universal/**/*.js',
'test/node/**/*.js'
]),
mochaTests: [
'test/unit.html',
'test/integration.html'
]
};
const plugins = gplugins();
gulp.task('clean', () => {
return del([
'dist',
'test/coverage',
'test/*.html',
'gh-pages'
]);
});
gulp.task('copy:gh-pages', () => {
return gulp.src([
'./**/*',
'!./test/coverage/**',
'!./node_modules/**/node_modules/**'
])
.pipe(gulp.dest('gh-pages/'))
});
gulp.task('eslint', () => {
return gulp.src([
...directories.browserTests,
...directories.integrationTests,
...directories.nodeTests,
'feature-detects/**/*.js',
'lib/*.js',
'src/*.js',
'test/**/*.js',
'!src/html5shiv.js',
'!src/html5printshiv.js',
'!test/coverage/**/*.js'
])
.pipe(plugins.eslint({
configFile: '.eslintrc'
}))
.pipe(plugins.eslint.failOnError());
});
gulp.task('generate', (done) => {
modernizr.build(config, function(output) {
fs.outputFile('dist/modernizr-build.js', output).then(() => {
done();
})
});
});
gulp.task('mocha:browser', (done) => {
const options = {
reporter: 'dot',
timeout: 5000,
args: ['disable-web-security']
};
Mochaheadless.runner({
...options,
file: 'test/integration.html',
})
.then(result => {
return Mochaheadless.runner({
...options,
file: 'test/unit.html'
});
})
.then(result => {
done();
});
});
gulp.task('mocha:node', (done) => {
const mocha = new Mocha({
reporter: 'dot',
timeout: 5000
});
directories.nodeTests.forEach(file => {
mocha.addFile(file);
});
// Run the tests.
mocha.run(failures => {
process.exitCode = failures ? 1 : 0; // exit with non-zero status if there were failures
done();
});
});
gulp.task('pug', () => {
return gulp.src('test/browser/*.pug')
.pipe(plugins.pug({
data: {
browserTests: directories.browserTests,
integrationTests: directories.integrationTests
}
}))
.pipe(gulp.dest('test/'))
});
gulp.task('test', gulp.series('clean', 'eslint', 'generate', 'pug', 'mocha:node', 'mocha:browser'));
gulp.task('default', gulp.series('clean', 'eslint', 'generate'));

6678
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -16,36 +16,36 @@
},
"devDependencies": {
"@alrra/travis-scripts": "^3.0.1",
"@babel/core": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/register": "^7.4.4",
"auto-changelog": "^1.13.0",
"del": "^4.1.1",
"eslint": "^5.16.0",
"eslint-plugin-jsdoc": "^4.8.3",
"expect.js": "^0.3.1",
"find-parent-dir": "^0.3.0",
"grunt": "^1.0.4",
"grunt-contrib-clean": "^2.0.0",
"grunt-contrib-connect": "^2.0.0",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-pug": "^2.0.0",
"grunt-coveralls": "^2.0.0",
"grunt-env": "^0.4.4",
"grunt-eslint": "^21.0.0",
"grunt-istanbul": "^0.8.0",
"grunt-mocha": "0.4.15",
"grunt-mocha-test": "^0.13.3",
"grunt-saucelabs": "^9.0.1",
"fs-extra": "^7.0.1",
"globby": "^9.2.0",
"gulp": "^4.0.2",
"gulp-eslint": "^5.0.0",
"gulp-load-plugins": "^1.5.0",
"gulp-pug": "^4.0.1",
"joi": "^14.3.1",
"jquery": "3.2.1",
"json3": "^3.3.2",
"load-grunt-tasks": "^4.0.0",
"mocha": "^6.1.4",
"mocha-headless-chrome": "^2.0.2",
"proxyquire": "^2.1.0",
"serve-static": "^1.13.2",
"sinon": "2.4.1",
"ua-parser-js": "^0.7.19"
},
"scripts": {
"start": "grunt default",
"test": "grunt test --stack",
"--- DEFAULT SCRIPTS ---": "",
"start": "gulp default",
"test": "gulp test",
"--- MODERNIZR SCRIPTS ---": "",
"changelog": "auto-changelog --commit-limit false --package",
"version": "node lib/generate-license.js && git add LICENSE"
},

View File

@@ -1,13 +1,16 @@
/* global UAParser */
window.caniusecb = function(caniuse) {
// So Phantom doesn't kill the caniuse.com matching exit out as it's useless anyway within PhantomJS
if (window._phantom) {
var ua = new UAParser(navigator.userAgent).getResult();
if (ua.browser.name === 'Chrome Headless') {
// TODO We could test against the caniuse data of the standard Chrome browser but there are currently three
// errors already present (focuswithin siblinggeneral htmlimports) which need to be fixed first. For now
// just return like back with phantomjs
//ua.browser.name = 'Chrome';
return;
}
describe('caniuse', function() {
var ua = new UAParser(navigator.userAgent).getResult();
var unusedModernizr = [];
var unusedCaniuse = _.keys(caniuse.data);
var map = {

View File

@@ -16,7 +16,7 @@ html
script(src='../node_modules/mocha/mocha.js')
script.
mocha.setup('bdd').timeout(20000);
each test in unitTests
each test in browserTests
script(src='../'+test)
script(src='../node_modules/expect.js/index.js')
script(src="../test/browser/setup.js")