Skip to content

Commit

Permalink
Update to Pa11y v7 and other dependency updates (#231)
Browse files Browse the repository at this point in the history
* Update kleur to v4.1.5

* Update async to v3.2.5

* Update commander to v11.1.0

* Update node-fetch to v2.7.0

* Update pa11y to v7.0.0 and puppeteer to v21.7.0

Tied together since in some cases pa11y-ci passes a
puppeteer browser instance to pa11y

* Update actions for latest Node, and match pa11y v7

* Update eslint to v8.56.0

* Update mocha to v10.2.0

* Update sinon to v17.0.1

* Update node engine to Node 18

* Populate package keywords

Taken from pa11y

* Update globby to v11.1.0

* Update cheerio to v1.0.0-rc.12

* Revert puppeteer to 20.9.0 to match pa11y

* Update glob processing to properly handle negating patterns

* Update exitCode to allow graceful exit

After upgrade to puppeteer 20/21 was seeing the message
`ERROR: The process "xxxx" not found`, which this resolved.

* Refresh lockfile to update all transitive dependencies

* Update mocha from 10.2.0 to 10.3.0

* In `.nvmrc`, set Node `18` in place of `14`

* In readme, mention Node `18` in place of `12`

* Increase timeout to 500ms from 100ms to attempt to fix test flakes, following lead of pa11y/pa11y#684

* Move options closer to point of use

Co-authored-by: Danyal Aytekin <[email protected]>

* Revert globby to 6.1.0 to avoid behavioral changes

---------

Co-authored-by: Danyal Aytekin <[email protected]>
  • Loading branch information
aarongoldenthal and danyalaytekin authored Mar 11, 2024
1 parent 76b1dc1 commit 79f3449
Show file tree
Hide file tree
Showing 15 changed files with 3,380 additions and 2,833 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ on:

jobs:
publish:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
registry-url: https://registry.npmjs.org
- run: npm ci

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 12
node-version: 18
- run: npm ci
- run: npm run lint

Expand All @@ -21,8 +21,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
node-version: [12, 14, 16, 18, 20]
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [18, 20]
steps:
- name: Normalise line-ending handling in Git
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14
18
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Use this tool to test against a list of URLs or a sitemap, and report on issues

## Requirements

This command line tool requires a stable (even-numbered) [Node.js] version of 12 or above.
This command line tool requires a stable (even-numbered) [Node.js] version of 18 or above.

### Pa11y CI 3 and Ubuntu

Expand Down
25 changes: 13 additions & 12 deletions bin/pa11y-ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,30 @@ const urls = globby.sync(commander.args, {
}).map(protocolify);

// Start the promise chain to actually run everything
const options = commander.opts();
Promise.resolve()
.then(() => {
// Load config based on the `--config` flag
return loadConfig(commander.config);
return loadConfig(options.config);
})
.then(config => {
// Load a sitemap based on the `--sitemap` flag
if (commander.sitemap) {
return loadSitemapIntoConfig(commander, config);
if (options.sitemap) {
return loadSitemapIntoConfig(options, config);
}
return config;
})
.then(config => {
// Override config reporters with CLI argument
if (commander.reporter) {
config.defaults.reporters = [commander.reporter];
if (options.reporter) {
config.defaults.reporters = [options.reporter];
}
// Actually run Pa11y CI
return pa11yCi(urls.concat(config.urls || []), config.defaults);
})
.then(report => {
// Output JSON if asked for it
if (commander.json) {
if (options.json) {
console.log(JSON.stringify(report, (key, value) => {
if (value instanceof Error) {
return {
Expand All @@ -98,16 +99,16 @@ Promise.resolve()
}
// Decide on an exit code based on whether
// errors are below threshold or everything passes
if (report.errors >= parseInt(commander.threshold, 10) && report.passes < report.total) {
process.exit(2);
if (report.errors >= parseInt(options.threshold, 10) && report.passes < report.total) {
process.exitCode = 2;
} else {
process.exit(0);
process.exitCode = 0;
}
})
.catch(error => {
// Handle any errors
console.error(error.message);
process.exit(1);
process.exitCode = 1;
});

// This function loads the JSON or JavaScript config
Expand All @@ -128,7 +129,7 @@ function loadConfig(configPath) {
if (!config) {
config = loadLocalConfigWithJson(configPath);
}
if (commander.config && !config) {
if (options.config && !config) {
return reject(new Error(`The config file "${configPath}" could not be loaded`));
}
} catch (error) {
Expand Down Expand Up @@ -200,7 +201,7 @@ function defaultConfig(config) {
config.defaults.log = config.defaults.log || console;
// Setting to undefined rather than 0 allows for a fallback to the default
config.defaults.wrapWidth = process.stdout.columns || undefined;
if (commander.json) {
if (options.json) {
delete config.defaults.log;
}
return config;
Expand Down
2 changes: 1 addition & 1 deletion lib/pa11y-ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function pa11yCi(urls, options) {

// Create a Pa11y test function and an async queue
const taskQueue = queue(testRunner, options.concurrency);
taskQueue.drain = testRunComplete;
taskQueue.drain(testRunComplete);

// Push the URLs on to the queue
taskQueue.push(urls);
Expand Down
Loading

0 comments on commit 79f3449

Please sign in to comment.