Remove Grunt and switch to npm scripts.

This commit is contained in:
XhmikosR 2017-08-09 15:22:38 +03:00
Родитель 16f427b6ef
Коммит 4fab68f589
14 изменённых файлов: 2467 добавлений и 4793 удалений

8
.eslintignore Normal file
Просмотреть файл

@ -0,0 +1,8 @@
/.git/
/bootstrap/
/coverage/
/dist/
/node_modules/
/src-cov/
/test/lib/
/vendor/

9
.gitignore поставляемый
Просмотреть файл

@ -7,14 +7,9 @@ pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov/
.nyc_output/
coverage/
*-cov
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
src-cov
node_modules/
/bootstrap/

Просмотреть файл

@ -9,19 +9,18 @@ node_js:
before_install:
- if [[ `npm -v` != 5* ]]; then npm install -g npm@5; fi
install:
- npm install -g grunt-cli
- npm install
before_script:
- git clone --depth 1 https://github.com/twbs/bootstrap.git --branch v3-dev
- bundle install --deployment --path "$(pwd)/vendor/bundle" --gemfile bootstrap/Gemfile --jobs=3 --retry=3
- pushd bootstrap && bundle exec jekyll build && popd
script:
- npm test
- npm run travis
- node ./src/cli-main.js --disable W003,W005 "bootstrap/_gh_pages/**/index.html"
- node ./src/cli-main.js --disable W003,E001 test/fixtures/doctype/missing.html test/fixtures/viewport/missing.html
- node ./src/cli-main.js test/fixtures/x-ua-compatible/missing.html &> x-ua-compatible-missing.output.actual.txt || true
- diff test/fixtures/cli/x-ua-compatible-missing.output.txt x-ua-compatible-missing.output.actual.txt
after_script:
after_success:
- npm run coveralls
matrix:
fast_finish: true

Просмотреть файл

@ -2,34 +2,28 @@
## Important notes
Please don't edit files in the `dist` subdirectory as they are generated via Grunt. You'll find source code in the `src` subdirectory!
Please don't edit files in the `dist` subdirectory as they are generated via `npm run dist`. You'll find source code in the `src` subdirectory!
### Code style
The project's coding style is laid out in the ESLint configuration.
### PhantomJS
Grunt can run the included unit tests via [PhantomJS](http://phantomjs.org/).
## Modifying the code
First, ensure that you have the latest [Node.js](https://nodejs.org/en/) and [npm](https://www.npmjs.com/) installed.
Test that Grunt's CLI is installed by running `grunt --version`. If the command isn't found, run `npm install -g grunt-cli`. For more information about installing Grunt, see the [getting started with Grunt guide](http://gruntjs.com/getting-started).
1. Fork and clone the repo.
2. Run `npm install` to install all build dependencies (including Grunt).
3. Run `grunt` to grunt this project.
2. Run `npm install` to install all build dependencies.
3. Run `npm test` to build and test things.
Assuming that you don't see any red, you're ready to go. Just be sure to run `grunt` after making any changes, to ensure that nothing is broken.
Assuming that you don't see any red, you're ready to go. Just be sure to run `npm test` after making any changes, to ensure that nothing is broken.
## Submitting pull requests
1. Create a new branch, please don't work in your `master` branch directly.
2. Add failing tests for the change you want to make. [See the test suite's README for instructions on how to do this.](https://github.com/twbs/bootlint/blob/master/test/README.md) Run `grunt` to see the tests fail.
2. Add failing tests for the change you want to make. [See the test suite's README for instructions on how to do this.](https://github.com/twbs/bootlint/blob/master/test/README.md) Run `npm test` to see the tests fail.
3. Fix stuff.
4. Run `grunt` to see if the tests pass. Repeat steps 2-4 until done.
4. Run `npm test` to see if the tests pass. Repeat steps 2-4 until done.
5. Update the documentation to reflect any changes.
6. Push to your fork and submit a pull request.

Просмотреть файл

@ -1,95 +0,0 @@
/*!
* Bootlint's Gruntfile
* https://github.com/twbs/bootlint
* Copyright 2014-2017 The Bootlint Authors
* Portions Copyright 2013-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootlint/blob/master/LICENSE)
*/
/* eslint-env node */
/* eslint indent: [2, 2] */
'use strict';
module.exports = function (grunt) {
// Force use of Unix newlines
grunt.util.linefeed = '\n';
// Load all grunt tasks
require('load-grunt-tasks')(grunt);
// Show elapsed time at the end.
require('time-grunt')(grunt);
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*!\n * Bootlint v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
' * <%= pkg.description %>\n' +
' * Copyright (c) 2014-2016 The Bootlint Authors\n' +
' * Licensed under the MIT License (https://github.com/twbs/bootlint/blob/master/LICENSE).\n' +
' */\n',
// Task configuration.
browserify: {
dist: {
src: 'src/bootlint.js',
dest: 'dist/browser/<%= pkg.name %>.js'
}
},
usebanner: {
options: {
banner: '<%= banner %>'
},
dist: {
src: ['dist/**/*.js']
}
},
nodeunit: {
files: ['test/**/*_test.js']
},
qunit: {
options: {
timeout: 10000
},
files: ['test/fixtures/**/*.html', '!test/fixtures/jquery/missing.html', '!test/fixtures/jquery/and_bs_js_both_missing.html', '!test/fixtures/charset/not-utf8.html']
},
eslint: {
options: {
config: '.eslintrc'
},
web: {
src: ['app.js', 'bin/www']
},
gruntfile: {
src: 'Gruntfile.js'
},
lib: {
src: ['src/**/*.js']
},
test: {
src: ['test/**/*.js', '!test/lib/**/*.js']
}
},
watch: {
gruntfile: {
files: '<%= eslint.gruntfile.src %>',
tasks: ['eslint:gruntfile']
},
lib: {
files: '<%= eslint.lib.src %>',
tasks: ['eslint:lib', 'nodeunit']
},
test: {
files: '<%= eslint.test.src %>',
tasks: ['eslint:test', 'nodeunit']
}
}
});
// Tasks
grunt.registerTask('lint', 'eslint');
grunt.registerTask('dist', ['browserify', 'usebanner']);
grunt.registerTask('test', ['lint', 'dist', 'nodeunit', 'qunit']);
grunt.registerTask('default', ['test']);
};

Просмотреть файл

@ -215,9 +215,9 @@ Response:
## Contributing
The project's coding style is laid out in the ESLint configuration. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
The project's coding style is laid out in the ESLint configuration. Add unit tests for any new or changed functionality. Lint and test your code using the npm scripts..
_Also, please don't edit files in the "dist" subdirectory as they are generated via Grunt. You'll find source code in the "src" subdirectory!_
_Also, please don't edit files in the "dist" subdirectory as they are generated via `npm run dist`. You'll find the source code in the "src" subdirectory!_
## Release History

32
build/phantom.js Normal file
Просмотреть файл

@ -0,0 +1,32 @@
/* eslint-env node */
'use strict';
var os = require('os');
var glob = require('glob');
var async = require('async');
var qunit = require('node-qunit-phantomjs');
var THREADS = os.cpus().length <= 2 ? 1 : os.cpus().length / 2;
var ignores = [
'test/fixtures/jquery/missing.html',
'test/fixtures/jquery/and_bs_js_both_missing.html',
'test/fixtures/charset/not-utf8.html'
];
glob('test/fixtures/**/*.html', {ignore: ignores}, function (err, files) {
if (err) {
throw err;
}
async.eachLimit(files,
THREADS,
function (file, callback) {
qunit(file, {timeout: 10}, callback);
}, function (er) {
if (er) {
throw er;
}
});
});

28
build/stamp.js Normal file
Просмотреть файл

@ -0,0 +1,28 @@
/* This file is taken from <https://github.com/twbs/bootstrap/blob/v4-dev/build/stamp.js>
and adapted for Bootlint.
*/
/* eslint-env node */
'use strict';
var fs = require('fs');
fs.readFile('package.json', function (err, data) {
if (err) {
throw err;
}
var pkg = JSON.parse(data);
var year = new Date().getFullYear();
var stampTop = '/*!\n * Bootlint v' + pkg.version + ' (' + pkg.homepage + ')\n' +
' * ' + pkg.description + '\n' +
' * Copyright (c) 2014-' + year + ' The Bootlint Authors\n' +
' * Licensed under the MIT License (https://github.com/twbs/bootlint/blob/master/LICENSE).\n' +
' */\n';
process.stdout.write(stampTop);
process.stdin.pipe(process.stdout);
});

6985
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -33,37 +33,44 @@
"url": "https://github.com/twbs/bootlint.git"
},
"license": "MIT",
"scripts": {
"browserify": "browserify src/bootlint.js | node build/stamp.js > dist/browser/bootlint.js",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"dist": "npm run browserify",
"eslint": "eslint \"**/*.js\"",
"lint": "npm run eslint",
"nodeunit": "nodeunit test",
"qunit": "node build/phantom.js",
"start": "node ./bin/www",
"test": "npm run eslint && npm run dist && npm run nodeunit && npm run qunit",
"travis": "nyc npm test"
},
"dependencies": {
"binary-search": "^1.3.2",
"bluebird": "^3.5.0",
"body-parser": "^1.17.2",
"chalk": "^2.1.0",
"bluebird": "^3.5.1",
"body-parser": "^1.18.2",
"chalk": "^2.3.0",
"cheerio": "^0.22.0",
"commander": "^2.11.0",
"debug": "^3.0.0",
"express": "^4.15.4",
"debug": "^3.1.0",
"express": "^4.16.2",
"glob": "^7.1.2",
"morgan": "^1.8.2",
"morgan": "^1.9.0",
"semver": "^5.4.1",
"void-elements": "^3.1.0"
},
"devDependencies": {
"coveralls": "^2.13.1",
"grunt": "^1.0.1",
"grunt-banner": "^0.6.0",
"grunt-browserify": "^5.0.0",
"grunt-contrib-clean": "^1.1.0",
"grunt-contrib-nodeunit": "^1.0.0",
"grunt-contrib-qunit": "^2.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-eslint": "^20.0.0",
"async": "^2.6.0",
"browserify": "^14.5.0",
"coveralls": "^3.0.0",
"eslint": "^4.11.0",
"jquery": "^3.2.1",
"jscoverage": "^0.6.0",
"load-grunt-tasks": "^3.5.2",
"nodeunit": "^0.11.1",
"rewire": "^2.5.2",
"sinon": "^3.1.0",
"time-grunt": "^1.4.0"
"node-qunit-phantomjs": "^1.6.1",
"nodeunit": "^0.11.2",
"nyc": "^11.3.0",
"qunitjs": "^2.4.1",
"rewire": "^3.0.2",
"sinon": "^4.1.2"
},
"main": "./src/bootlint.js",
"bin": {
@ -77,6 +84,11 @@
"./src/cli-main.js": false,
"./src/location.js": false
},
"nyc": {
"include": [
"src/**/*.js"
]
},
"engines": {
"node": ">=6"
},
@ -84,12 +96,6 @@
"bin",
"dist",
"src",
"app.js",
"LICENSE"
],
"scripts": {
"test": "grunt test",
"coveralls": "jscoverage src && BOOTLINT_COV=1 nodeunit --reporter=lcov test | coveralls",
"start": "node ./bin/www"
}
"app.js"
]
}

Просмотреть файл

@ -3,9 +3,9 @@
* `/test/fixtures/` contains the HTML test case files.
* `/test/lib/` contains third-party testing-related code for the browser environment (jQuery and QUnit)
To test usage in a Node.js environment, [Nodeunit](https://github.com/caolan/nodeunit) tests are defined in `/test/bootlint_test.js`, and can be run via the `nodeunit` Grunt task.
To test usage in a Node.js environment, [Nodeunit](https://github.com/caolan/nodeunit) tests are defined in `/test/bootlint_test.js`, and can be run via the `npm run nodeunit` task.
To test usage in a browser environment, we use [QUnit](https://qunitjs.com/) along with some additional automation in `/test/fixtures/generic-qunit.js`. Basically, when PhantomJS runs each test case webpage, we automatically Bootlint the page and then assert that the list of lint messages equals the `data-lint` attributes of the `<li>`s under the `<ol id="bootlint">` within the page. The `qunit` Grunt task runs these tests in PhantomJS.
To test usage in a browser environment, we use [QUnit](https://qunitjs.com/) along with some additional automation in `/test/fixtures/generic-qunit.js`. Basically, when PhantomJS runs each test case webpage, we automatically Bootlint the page and then assert that the list of lint messages equals the `data-lint` attributes of the `<li>`s under the `<ol id="bootlint">` within the page. The `npm run qunit` task runs these tests in PhantomJS.
## How do I add a new test?
@ -14,4 +14,4 @@ To test usage in a browser environment, we use [QUnit](https://qunitjs.com/) alo
2. Add the HTML of your new testcase into the new file.
3. For each lint message you expect Bootlint to emit, add an `<li>` under the `<ol id="bootlint">` in the file, and add a `data-lint` attribute to the `<li>` with the lint message string as the value (see existing tests for examples).
4. In `/test/bootlint_test.js`, add a corresponding Nodeunit test that uses your new test case file. (Yes, this involves duplicating the expected lint messages.)
5. Run `grunt test` to see the results of your newly-added test.
5. Run `npm test` to see the results of your newly-added test.

Просмотреть файл

@ -1,6 +1,6 @@
'use strict';
var bootlint = process.env.BOOTLINT_COV === '1' ? require('../src-cov/bootlint.js') : require('../src/bootlint.js');
var bootlint = require('../src/bootlint.js');
var fs = require('fs');
var path = require('path');

Просмотреть файл

@ -2,7 +2,7 @@
var sinon = require('sinon');
var rewire = require('rewire');
var cli = process.env.BOOTLINT_COV === '1' ? rewire('../src-cov/cli.js') : rewire('../src/cli.js');
var cli = rewire('../src/cli.js');
/*
======== A Handy Little Nodeunit Reference ========

Просмотреть файл

@ -1,6 +1,6 @@
'use strict';
var _location = process.env.BOOTLINT_COV === '1' ? require('../src-cov/location.js') : require('../src/location.js');
var _location = require('../src/location.js');
var Location = _location.Location;
var LocationIndex = _location.LocationIndex;