mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Update the AIO scripts that use Lighthouse (i.e. `audit-web-app.js` and `test-aio-a11y.js`) to ES modules. This allows consuming `lighthouse/lighthouse-cli` [v8.5.0+][1], which also switched to ES modules. NOTE: Switching the `test-aio-a11y.js` script to ES modules is not strictly necessary, since it invokes `audit-web-app.mjs` via a shell command, but it was done for consistency. [1]: https://github.com/GoogleChrome/lighthouse/releases/tag/v8.5.0 PR Close #43607
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
#!/bin/env node
|
|
|
|
/**
|
|
* Usage:
|
|
* ```sh
|
|
* node scripts/test-aio-a11y.mjs <origin>
|
|
* ```
|
|
*
|
|
* Runs accessibility audits on several (pre-defined) pages on the specified origin. It fails, if
|
|
* the score for any page is below the minimum (see `MIN_SCORES_PER_PAGE` below).
|
|
*
|
|
* `<origin>` is the origin (scheme + hostname + port) of an angular.io deployment. It can be remote
|
|
* (e.g. `https://next.angular.io`) or local (e.g. `http://localhost:4200`).
|
|
*/
|
|
|
|
// Imports
|
|
import {dirname} from 'path';
|
|
import sh from 'shelljs';
|
|
import {fileURLToPath} from 'url';
|
|
|
|
sh.set('-e');
|
|
|
|
// Constants
|
|
const MIN_SCORES_PER_PAGE = {
|
|
'': 100,
|
|
'api': 100,
|
|
'api/core/Directive': 98,
|
|
'cli': 100,
|
|
'cli/add': 100,
|
|
'docs': 100,
|
|
'guide/docs-style-guide': 96,
|
|
'start/start-routing': 98,
|
|
'tutorial': 98,
|
|
};
|
|
|
|
// Run
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const auditWebAppCmd = `"${process.execPath}" "${__dirname}/audit-web-app.mjs"`;
|
|
const origin = process.argv[2];
|
|
for (const [page, minScore] of Object.entries(MIN_SCORES_PER_PAGE)) {
|
|
sh.exec(`${auditWebAppCmd} ${origin}/${page} accessibility:${minScore}`);
|
|
}
|