a11y
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -23,2 +23,7 @@ /** | ||
webpage.viewportSize = { | ||
width: opts.width, | ||
height: opts.height | ||
}; | ||
webpage.onResourceTimeout = function (err) { | ||
@@ -25,0 +30,0 @@ console.log('Error code:' + err.errorCode + ' ' + err.errorString + ' for ' + err.url); |
36
cli.js
@@ -6,8 +6,9 @@ #!/usr/bin/env node | ||
var updateNotifier = require('update-notifier'); | ||
var chalk = require('chalk'); | ||
var eachAsync = require('each-async'); | ||
var indentString = require('indent-string'); | ||
var arrayUniq = require('array-uniq'); | ||
var protocolify = require('protocolify'); | ||
var a11y = require('./'); | ||
var chalk = require('chalk'); | ||
var each = require('each-async'); | ||
var indent = require('indent-string'); | ||
var cli = meow({ | ||
@@ -19,8 +20,9 @@ help: [ | ||
'Example', | ||
' a11y http://todomvc.com', | ||
' a11y http://todomvc.com http://chrome.com', | ||
' a11y todomvc.com', | ||
' a11y http://todomvc.com https://google.com', | ||
' a11y index.html', | ||
'', | ||
'Options', | ||
' --verbose Displays more information' | ||
' --verbose Displays more information', | ||
' --viewport-size=1024x768 Sets the viewport size' | ||
].join('\n') | ||
@@ -34,3 +36,7 @@ }); | ||
each(cli.input, function (url) { | ||
var urls = arrayUniq(cli.input.map(function (el) { | ||
return protocolify(el); | ||
})); | ||
eachAsync(urls, function (url, i, next) { | ||
a11y(url, cli.flags, function (err, reports) { | ||
@@ -50,3 +56,8 @@ if (err) { | ||
console.log(chalk.underline(chalk.cyan('\nReport for ' + url + '\n'))); | ||
console.log(''); | ||
if (!process.stdout.isTTY || urls.length > 1) { | ||
console.log(chalk.underline(chalk.cyan(url.replace(/^http:\/\//, '') + '\n'))); | ||
} | ||
reports.audit.forEach(function (el) { | ||
@@ -61,8 +72,9 @@ if (el.result === 'PASS') { | ||
} | ||
}); | ||
console.log(indent(failures, ' ', 2)); | ||
console.log(indent(passes, ' ', 2)); | ||
console.log(indentString(failures, ' ', 2)); | ||
console.log(indentString(passes, ' ', 2)); | ||
next(); | ||
}); | ||
}); |
14
index.js
@@ -14,2 +14,4 @@ 'use strict'; | ||
opts = opts || {}; | ||
if (typeof cb !== 'function') { | ||
@@ -19,9 +21,15 @@ throw new Error('Callback required'); | ||
if (!url || !url.length > 0) { | ||
if (!(url && url.length > 0)) { | ||
throw new Error('Please supply a valid URL'); | ||
} | ||
url = protocolify(url); | ||
opts = objectAssign({}, opts, {url: url}); | ||
var viewportSize = (opts.viewportSize || '').split('x'); | ||
delete opts.viewportSize; | ||
opts = objectAssign({}, opts, { | ||
url: protocolify(url), | ||
width: viewportSize[0] || 1024, | ||
height: viewportSize[1] || 768 | ||
}); | ||
execFile(phantomjs.path, [ | ||
@@ -28,0 +36,0 @@ path.join(__dirname, 'audits.js'), |
{ | ||
"name": "a11y", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Runs an accessibility audit against a URL", | ||
"license": "Apache-2", | ||
"license": "Apache-2.0", | ||
"repository": "addyosmani/a11y", | ||
"author": "Addy Osmani", | ||
"maintainers": [ | ||
{ | ||
"name": "Addy Osmani", | ||
"email": "addyosmani@gmail.com", | ||
"url": "addyosmani.com" | ||
}, | ||
{ | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
} | ||
], | ||
"bin": { | ||
@@ -16,3 +27,3 @@ "a11y": "cli.js" | ||
"test": "node test/test.js", | ||
"demo": "node cli.js http://theverge.com" | ||
"demo": "node cli.js theverge.com" | ||
}, | ||
@@ -26,17 +37,27 @@ "files": [ | ||
"cli-app", | ||
"a11y", | ||
"audit", | ||
"test", | ||
"accessibility", | ||
"a11y" | ||
"wai", | ||
"aria", | ||
"dev", | ||
"developer", | ||
"tool", | ||
"report", | ||
"web", | ||
"website" | ||
], | ||
"dependencies": { | ||
"accessibility-developer-tools": "^2.6.0", | ||
"array-uniq": "^1.0.2", | ||
"chalk": "^0.5.1", | ||
"each-async": "^1.1.0", | ||
"indent-string": "^1.2.0", | ||
"log-symbols": "^1.0.1", | ||
"meow": "^2.0.0", | ||
"object-assign": "^1.0.0", | ||
"object-assign": "^2.0.0", | ||
"phantomjs": "^1.9.10", | ||
"protocolify": "^1.0.0", | ||
"update-notifier": "^0.2.2", | ||
"chalk": "^0.5.1", | ||
"indent-string": "^1.2.0", | ||
"each-async": "^1.1.0" | ||
"update-notifier": "^0.2.2" | ||
}, | ||
@@ -43,0 +64,0 @@ "devDependencies": { |
@@ -1,2 +0,2 @@ | ||
<img width="400px" src="https://cloud.githubusercontent.com/assets/110953/4694241/3ddba98e-57c1-11e4-852a-dc0940345a89.png"/> | ||
<img width="400px" src="https://cloud.githubusercontent.com/assets/110953/4694241/3ddba98e-57c1-11e4-852a-dc0940345a89.png"> | ||
@@ -7,3 +7,3 @@ [![Build Status](http://img.shields.io/travis/addyosmani/a11y/master.svg?style=flat)](https://travis-ci.org/addyosmani/a11y?style=flat) ![](http://img.shields.io/badge/unicorn-approved-ff69b4.svg?style=flat) | ||
![](http://i.imgur.com/4BljBqv.png) | ||
![](http://i.imgur.com/Mt751vA.png) | ||
@@ -25,3 +25,3 @@ | ||
```sh | ||
$ a11y <url> | ||
$ a11y todomvc.com | ||
``` | ||
@@ -32,8 +32,9 @@ | ||
```sh | ||
$ a11y http://todomvc.com http://chrome.com | ||
$ a11y http://todomvc.com https://google.com | ||
``` | ||
## Example | ||
![](http://i.imgur.com/NBaz6qe.png) | ||
![](http://i.imgur.com/3xg3Fsf.png) | ||
@@ -43,3 +44,3 @@ Also works fine against localhost: | ||
```sh | ||
$ a11y http://localhost:9000 | ||
$ a11y localhost:9000 | ||
``` | ||
@@ -53,4 +54,6 @@ | ||
![](http://i.imgur.com/1m3pi78.png) | ||
![](http://i.imgur.com/Ffkrr9D.png) | ||
## Options | ||
Query help: | ||
@@ -62,2 +65,8 @@ | ||
Customise viewport size: | ||
```sh | ||
$ a11y --viewport-size=800x600 | ||
``` | ||
Verbose mode: | ||
@@ -75,2 +84,3 @@ | ||
## Module usage | ||
@@ -83,3 +93,3 @@ | ||
a11y('http://twitter.com', function (err, reports) { | ||
a11y('twitter.com', function (err, reports) { | ||
var output = JSON.parse(reports); | ||
@@ -96,3 +106,3 @@ var audit = output.audit; // a11y Formatted report | ||
a11y('http://twitter.com', function (err, reports) { | ||
a11y('twitter.com', function (err, reports) { | ||
reports.audit.forEach(function (el) { | ||
@@ -109,13 +119,16 @@ // result will be PASS, FAIL or NA | ||
## Interpreting results | ||
Per the Accessibility Developer Tools, the results in an audit may be one of three | ||
constants: | ||
To interpret how to fix individual issues in an audit, see the [Audit Rules](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules) section of the Accessibility Developer Tools project. | ||
* PASS - implies that there were elements on the page that may potentially have failed this audit rule, but they passed. Congratulations! | ||
* FAIL - This implies that there were elements on the page that did not pass this audit rule. This is the only result you will probably be interested in. | ||
* NA - This implies that there were no elements on the page that may potentially have failed this audit rule. For example, an audit rule that checks video elements for subtitles would return this result if there were no video elements on the page. | ||
Per the Accessibility Developer Tools, the results in an audit may be one of three types: | ||
* `PASS` - implies that there were elements on the page that may potentially have failed this audit rule, but they passed. Congratulations! | ||
* `FAIL` - This implies that there were elements on the page that did not pass this audit rule. This is the only result you will probably be interested in. | ||
* `NA` - This implies that there were no elements on the page that may potentially have failed this audit rule. For example, an audit rule that checks video elements for subtitles would return this result if there were no video elements on the page. | ||
## License | ||
Apache-2. | ||
Apache-2.0 |
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
10105
178
125
11
2
+ Addedarray-uniq@^1.0.2
+ Addedarray-uniq@1.0.3(transitive)
- Removedobject-assign@1.0.0(transitive)
Updatedobject-assign@^2.0.0