Switch from Grunt to Make

This commit is contained in:
Rowan Manning
2016-04-25 21:08:10 +01:00
parent 7ea14497d9
commit d766029bbb
20 changed files with 232 additions and 233 deletions

89
.jscsrc Normal file
View File

@@ -0,0 +1,89 @@
{
"disallowEmptyBlocks": true,
"disallowImplicitTypeConversion": [
"binary",
"numeric",
"string"
],
"disallowKeywordsOnNewLine": [
"catch",
"else"
],
"disallowMixedSpacesAndTabs": true,
"disallowMultipleSpaces": true,
"disallowMultipleVarDecl": true,
"disallowNewlineBeforeBlockStatements": true,
"disallowQuotedKeysInObjects": true,
"disallowSpaceAfterObjectKeys": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowSpaceBeforeComma": true,
"disallowSpaceBeforeSemicolon": true,
"disallowSpacesInCallExpression": true,
"disallowSpacesInFunction": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInsideArrayBrackets": true,
"disallowSpacesInsideBrackets": true,
"disallowSpacesInsideObjectBrackets": true,
"disallowSpacesInsideParentheses": true,
"disallowTrailingComma": true,
"disallowTrailingWhitespace": true,
"disallowYodaConditions": true,
"maximumLineLength": 200,
"requireBlocksOnNewline": true,
"requireCapitalizedConstructors": true,
"requireCommaBeforeLineBreak": true,
"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"switch",
"try",
"catch"
],
"requireDotNotation": true,
"requireLineBreakAfterVariableAssignment": true,
"requireLineFeedAtFileEnd": true,
"requireObjectKeysOnNewLine": true,
"requireParenthesesAroundIIFE": true,
"requireSemicolons": true,
"requireSpaceAfterBinaryOperators": true,
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"try",
"catch"
],
"requireSpaceAfterLineComment": {
"allExcept": [
"="
]
},
"requireSpaceBeforeBinaryOperators": true,
"requireSpaceBeforeBlockStatements": true,
"requireSpaceBeforeObjectValues": true,
"requireSpaceBetweenArguments": true,
"requireSpacesInConditionalExpression": true,
"requireSpacesInForStatement": true,
"requireSpacesInFunction": {
"beforeOpeningCurlyBrace": true
},
"validateIndentation": "\t",
"validateLineBreaks": "LF",
"validateNewlineAfterArrayElements": true,
"validateParameterSeparator": ", ",
"validateQuoteMarks": "'",
"excludeFiles": [
"coverage",
"node_modules",
"public/js/site.min.js",
"public/js/vendor"
]
}

4
.jshintignore Normal file
View File

@@ -0,0 +1,4 @@
coverage
node_modules
public/js/site.min.js
public/js/vendor

29
.jshintrc Normal file
View File

@@ -0,0 +1,29 @@
{
"browser": true,
"curly": true,
"eqeqeq": true,
"forin": true,
"globals": {
"after": true,
"afterEach": true,
"before": true,
"beforeEach": true,
"describe": true,
"it": true
},
"latedef": "nofunc",
"maxcomplexity": 6,
"maxdepth": 2,
"maxparams": 4,
"noarg": true,
"node": true,
"nonew": true,
"nonstandard": true,
"regexp": true,
"shadow": true,
"strict": true,
"sub": true,
"trailing": true,
"undef": true,
"unused": true
}

View File

@@ -1,8 +1,18 @@
# Language/versions
language: node_js
node_js:
- "0.10"
matrix:
include:
# Run tests in Node.js 0.10 (unsupported)
- node_js: '0.10'
# Run tests in Node.js 0.12
- node_js: '0.12'
# Allow Node.js 0.10 to fail it's unsupported
allow_failures:
- node_js: '0.10'
# Build only master (and pull-requests)
branches:
@@ -15,15 +25,7 @@ services:
# Build script
before_script:
- npm install -g grunt-cli
- cp config/test.sample.json config/test.json
- grunt start-test &
- NODE_ENV=test node index.js &
- sleep 5 # give server time to start
script: 'grunt ci'
# Notifications
notifications:
email:
- j.robinson@nature.com
- perry.harlock@nature.com
- rowan.manning@nature.com
script: 'make ci'

View File

@@ -1,53 +0,0 @@
How To Contribute
=================
pa11y-dashboard accepts contributions from anyone, as long as you follow the guidelines below. If you'd like to contribute but aren't sure what there is for you to do, check the issue tracker for [things ready to be worked on][ready] and [known bugs][bugs].
It might be an idea to focus efforts on the goal of the [next milestone][milestones] before jumping onto anything too far ahead on the roadmap.
Features
--------
We won't accept features without prior discussion in the [issue tracker][issues]. Two heads are always better than one this blanket rule stops you from spending your valuable time on features which may not make it back into pa11y-dashboard.
If you want to fork the project and build on it by yourself, of course that's absolutely fine! Just don't expect your code to me merged back upstream :)
Refactoring/Rewriting
---------------------
We will accept refactors where it makes an improvement to the maintainability of the code-base or makes code more readable/understandable. If there's an argument about what's readable or not, chat about it in a pull-request.
Coding Guidelines
-----------------
* No trailing whitespace please (except in Markdown)
* Generally follow the style that is currently present in the code consistency is important
* Keep indentation consistent (tabs)
* Don't commit code with lint errors (run `grunt lint` to run JSHint with the correct configurations)
* Don't commit code without passing tests (run `grunt test`).
Versioning
----------
We use [Semantic Versioning][semver] in this project. The process for releasing a new version is as follows; this should only be done by core contributors you don't need to include a tagged version in your pull-requests.
* Switch to `master` and merge the `develop` branch into it
* Update the version number in `package.json` and `README.md`
* Commit the changes with the message: "Version x.x.x" (x.x.x being the new version number)
* Tag the commit with the version number (just the numbers, no "version" or "v"): `git tag x.x.x`
* Push with tags: `git push && git push --tags`
* Check out the `develop` branch, merge `master` into it, and push
* On GitHub, add [release notes][release-notes] for the new version. The title should be "Version x.x.x", and the description should be a list of new features/fixes
[bugs]: https://github.com/springernature/pa11y-dashboard/issues?labels=bug&state=open
[ready]: https://github.com/springernature/pa11y-dashboard/issues?labels=ready&state=open
[issues]: https://github.com/springernature/pa11y-dashboard/issues
[milestones]: https://github.com/springernature/pa11y-dashboard/issues/milestones
[release-notes]: https://github.com/springernature/pa11y-dashboard/releases
[semver]: http://semver.org/

View File

@@ -1,135 +0,0 @@
// This file is part of pa11y-dashboard.
//
// pa11y-dashboard is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// pa11y-dashboard is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with pa11y-dashboard. If not, see <http://www.gnu.org/licenses/>.
module.exports = function (grunt) {
grunt.initConfig({
jshint: {
all: [
'**/*.js',
'!node_modules/**/*.js',
'!public/js/vendor/**/*.js',
'!public/js/site.min.js'
],
options: {
es3: false,
indent: 4,
latedef: false,
maxcomplexity: 6,
maxdepth: 2,
maxlen: 100,
maxparams: 4,
maxstatements: false,
node: true,
quotmark: 'single'
}
},
less: {
all: {
options: {
cleancss: true
},
files: {
'public/css/site.min.css': 'public/less/main.less'
}
}
},
mochaTest: {
functional: {
src: ['test/functional/**/*.js'],
options: {
reporter: 'spec',
timeout: 4000
}
}
},
nodemon: {
development: {
options: {
cwd: __dirname,
file: 'index.js',
env: {
NODE_ENV: 'development'
}
}
},
test: {
options: {
cwd: __dirname,
file: 'index.js',
env: {
NODE_ENV: 'test'
}
}
}
},
uglify: {
options: {
mangle: false
},
all: {
files: {
'public/js/site.min.js': [
'public/js/vendor/jquery/jquery.min.js',
'public/js/vendor/bootstrap/js/alert.js',
'public/js/vendor/bootstrap/js/dropdown.js',
'public/js/vendor/bootstrap/js/tooltip.js',
'public/js/vendor/bootstrap/js/transition.js',
'public/js/vendor/bootstrap/js/collapse.js',
'public/js/vendor/flot/jquery.flot.js',
'public/js/vendor/flot/jquery.flot.dashes.js',
'public/js/vendor/flot/jquery.flot.time.js',
'public/js/vendor/flot/jquery.flot.selection.js',
'public/js/vendor/flot/jquery.flot.resize.js',
'public/js/site.js'
]
}
}
},
watch: {
less: {
files: ['public/less/**/*.less'],
tasks: ['less']
},
js: {
files: ['public/js/**/*.js', '!public/js/site.min.js'],
tasks: ['uglify']
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-nodemon');
grunt.registerTask('lint', ['jshint']);
grunt.registerTask('test', ['mochaTest']);
grunt.registerTask('compile', ['less', 'uglify']);
grunt.registerTask('start', ['nodemon:development']);
grunt.registerTask('start-test', ['nodemon:test']);
grunt.registerTask('default', ['compile', 'lint', 'test']);
grunt.registerTask('ci', ['lint', 'test']);
};

64
Makefile Normal file
View File

@@ -0,0 +1,64 @@
# Color helpers
C_CYAN=\x1b[34;01m
C_RESET=\x1b[0m
# Group targets
all: deps lint test
ci: lint test
# Install dependencies
deps:
@echo "$(C_CYAN)> installing dependencies$(C_RESET)"
@npm install
# Lint JavaScript
lint: jshint jscs
# Run JSHint
jshint:
@echo "$(C_CYAN)> linting javascript$(C_RESET)"
@./node_modules/.bin/jshint .
# Run JavaScript Code Style
jscs:
@echo "$(C_CYAN)> checking javascript code style$(C_RESET)"
@./node_modules/.bin/jscs .
# Run all tests
test: test-integration
# Run integration tests
test-integration:
@echo "$(C_CYAN)> running integration tests$(C_RESET)"
@./node_modules/.bin/mocha ./test/integration --reporter spec --recursive --timeout 5000 --slow 50
# Add fixtures
fixtures:
@echo "$(C_CYAN)> adding fixtures$(C_RESET)"
@node ./script/fixtures.js
# Compile LESS
less:
@echo "$(C_CYAN)> compiling less$(C_RESET)"
@./node_modules/.bin/lessc -x ./public/less/main.less ./public/css/site.min.css
# Compile client-side JavaScript
uglify:
@echo "$(C_CYAN)> compiling client-side JavaScript$(C_RESET)"
@./node_modules/.bin/uglifyjs \
public/js/vendor/jquery/jquery.min.js \
public/js/vendor/bootstrap/js/alert.js \
public/js/vendor/bootstrap/js/dropdown.js \
public/js/vendor/bootstrap/js/tooltip.js \
public/js/vendor/bootstrap/js/transition.js \
public/js/vendor/bootstrap/js/collapse.js \
public/js/vendor/flot/jquery.flot.js \
public/js/vendor/flot/jquery.flot.dashes.js \
public/js/vendor/flot/jquery.flot.time.js \
public/js/vendor/flot/jquery.flot.selection.js \
public/js/vendor/flot/jquery.flot.resize.js \
public/js/site.js \
-o ./public/js/site.min.js
.PHONY: test

View File

@@ -22,9 +22,9 @@ You'll then need to clone this repo locally and install dependencies with `npm i
Once you have a local clone, you'll need to copy some sample configuration files in order to run the application. From within the repo, run the following commands:
```sh
$ cp config/development.sample.json config/development.json
$ cp config/production.sample.json config/production.json
$ cp config/test.sample.json config/test.json
cp config/development.sample.json config/development.json
cp config/production.sample.json config/production.json
cp config/test.sample.json config/test.json
```
Each of these files defines configurations for a different environment. If you're just running the application locally, then you should be OK with just development configurations. The [available configurations are documented here](#configurations).
@@ -32,9 +32,9 @@ Each of these files defines configurations for a different environment. If you'r
Now that you've got your application configured, you can run in each mode with the following commands:
```sh
$ NODE_ENV=production node . # Run in production
$ NODE_ENV=development node . # Run in development
$ NODE_ENV=test node . # Run in test
NODE_ENV=production node index.js # Run in production
NODE_ENV=development node index.js # Run in development
NODE_ENV=test node index.js # Run in test
```
Check the [development instructions](#development) for more information about running locally (and restarting automatically when files change).
@@ -64,29 +64,30 @@ This can either be an object containing [pa11y-webservice configurations][pa11y-
Development
-----------
To develop pa11y-dashboard, you'll need to clone the repo and get set up as outlined in the [setup guide](#setup). You'll also need [Grunt][grunt] to be installed globally in order to run tests, you can do this with `npm install -g grunt-cli`.
To develop pa11y-dashboard, you'll need to clone the repo and get set up as outlined in the [setup guide](#setup).
Once you've done this, you'll need to start the application in test mode with:
You'll need to start the application in test mode with:
```sh
$ grunt start-test
NODE_ENV=test node index.js
```
Now you'll be able to run the following commands:
```sh
$ grunt # Run the lint and test tasks together
$ grunt lint # Run JSHint with the correct config
$ grunt compile # Compile front-end assets
$ grunt start # Run app in development mode, restarting if files change
$ grunt start-test # Run app in test mode, restarting if files change
$ grunt test # Run functional tests
$ grunt watch # Watch for file changes and compile assets
make # Run the lint and test tasks together
make lint # Run linters with the correct config
make test # Run integration tests
```
Code with lint errors or failing tests will not be accepted, please use the build tools outlined above.
For users with push-access, don't commit to the master branch. Code should be in `develop` until it's ready to be released.
To compile the client-side JavaScript and CSS, you'll need the following commands. Compiled code is committed to the repository.
```sh
make css # Compile the site CSS from LESS files
make uglify # Compile and uglify the client-side JavaScript
```
License
@@ -98,7 +99,6 @@ pa11y-dashboard is licensed under the [GNU General Public License 3.0][gpl].
[gpl]: http://www.gnu.org/licenses/gpl-3.0.html
[grunt]: http://gruntjs.com/
[mongo]: http://www.mongodb.org/
[node]: http://nodejs.org/
[pa11y]: https://github.com/springernature/pa11y

View File

@@ -31,19 +31,18 @@
},
"devDependencies": {
"bower": "~1.2",
"grunt": "~0.4",
"grunt-contrib-jshint": "~0.7",
"grunt-contrib-less": "~0.8",
"grunt-contrib-uglify": "~0.2",
"grunt-contrib-watch": "~0.5",
"grunt-mocha-test": "~0.7",
"grunt-nodemon": "~0.1",
"jsdom": "~0.8",
"proclaim": "~2.0",
"request": "~2.27"
"jscs": "^2",
"jsdom": "^3",
"jshint": "^2",
"less": "~1.5",
"mocha": "^2",
"proclaim": "^3",
"request": "~2.27",
"uglify-js": "~2.4"
},
"scripts": {
"start": "node ."
"start": "node index.js",
"test": "make ci"
}
}

View File

@@ -43,7 +43,7 @@ afterEach(function (done) {
function assertTestAppIsRunning (url, done) {
request(url, function (err) {
if (err) {
console.error('Error: Test app not started; run with `grunt start-test`');
console.error('Error: Test app not started; run with `NODE_ENV=test node index.js`');
process.exit(1);
}
done();