diff --git a/aio/package.json b/aio/package.json index 41b3d778628..6dfc9edbdc1 100644 --- a/aio/package.json +++ b/aio/package.json @@ -35,7 +35,7 @@ "set-opensearch-url": "node --eval \"const sh = require('shelljs'); sh.set('-e'); sh.sed('-i', /PLACEHOLDER_URL/g, process.argv[1], 'dist/assets/opensearch.xml');\"", "presmoke-tests": "yarn update-webdriver", "smoke-tests": "protractor tests/deployment/e2e/protractor.conf.js --suite smoke --baseUrl", - "test-a11y-score": "node scripts/test-aio-a11y", + "test-a11y-score": "node scripts/test-aio-a11y.mjs", "test-a11y-score-localhost": "run-p --race \"~~light-server -s dist -p 4200 --quiet\" \"test-a11y-score http://localhost:4200\" --", "test-pwa-score": "run-s \"~~audit-web-app {1} all:0,pwa:{2} {3}\" --", "test-pwa-score-localhost": "run-p --race \"~~light-server -s dist -p 4200 --quiet\" \"test-pwa-score http://localhost:4200 {1} {2}\" --", @@ -69,7 +69,7 @@ "build-404-page": "node scripts/build-404-page", "update-webdriver": "node ../scripts/webdriver-manager-update.js", "security-lint": "tsec -p tsconfig.app.json", - "~~audit-web-app": "node scripts/audit-web-app", + "~~audit-web-app": "node scripts/audit-web-app.mjs", "~~check-env": "node scripts/check-environment", "~~clean-generated": "node --eval \"require('shelljs').rm('-rf', 'src/generated')\"", "pre~~build": "yarn ~~build-ce-es5-polyfills && yarn ~~build-ngsw-config", @@ -162,8 +162,8 @@ "karma-jasmine": "~4.0.0", "karma-jasmine-html-reporter": "^1.5.0", "light-server": "^2.9.1", - "lighthouse": "^8.1.0", - "lighthouse-logger": "^1.2.0", + "lighthouse": "^8.5.1", + "lighthouse-logger": "^1.3.0", "lodash": "^4.17.21", "lunr": "^2.3.9", "npm-run-all": "^4.1.5", diff --git a/aio/scripts/audit-web-app.js b/aio/scripts/audit-web-app.mjs similarity index 95% rename from aio/scripts/audit-web-app.js rename to aio/scripts/audit-web-app.mjs index a2651948134..c7e5ad708ed 100644 --- a/aio/scripts/audit-web-app.js +++ b/aio/scripts/audit-web-app.mjs @@ -1,10 +1,9 @@ #!/bin/env node -'use strict'; /** * Usage: * ```sh - * node scripts/audit-web-app [] + * node scripts/audit-web-app.mjs [] * ``` * * Runs audits against the specified URL on specific categories (accessibility, best practices, performance, PWA, SEO). @@ -27,10 +26,10 @@ */ // Imports -const lighthouse = require('lighthouse'); -const printer = require('lighthouse/lighthouse-cli/printer'); -const logger = require('lighthouse-logger'); -const puppeteer = require('puppeteer'); +import lighthouse from 'lighthouse'; +import * as printer from 'lighthouse/lighthouse-cli/printer.js'; +import logger from 'lighthouse-logger'; +import puppeteer from 'puppeteer'; // Constants const AUDIT_CATEGORIES = ['accessibility', 'best-practices', 'performance', 'pwa', 'seo']; diff --git a/aio/scripts/test-aio-a11y.js b/aio/scripts/test-aio-a11y.mjs similarity index 81% rename from aio/scripts/test-aio-a11y.js rename to aio/scripts/test-aio-a11y.mjs index 3afe1739029..126cf035e7b 100644 --- a/aio/scripts/test-aio-a11y.js +++ b/aio/scripts/test-aio-a11y.mjs @@ -1,10 +1,9 @@ #!/bin/env node -'use strict'; /** * Usage: * ```sh - * node scripts/test-aio-a11y + * node scripts/test-aio-a11y.mjs * ``` * * Runs accessibility audits on several (pre-defined) pages on the specified origin. It fails, if @@ -15,7 +14,10 @@ */ // Imports -const sh = require('shelljs'); +import {dirname} from 'path'; +import sh from 'shelljs'; +import {fileURLToPath} from 'url'; + sh.set('-e'); // Constants @@ -32,7 +34,8 @@ const MIN_SCORES_PER_PAGE = { }; // Run -const auditWebAppCmd = `"${process.execPath}" "${__dirname}/audit-web-app"`; +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}`); diff --git a/aio/yarn.lock b/aio/yarn.lock index f3574576ecd..ad0167ed933 100644 --- a/aio/yarn.lock +++ b/aio/yarn.lock @@ -7487,7 +7487,7 @@ light-server@^2.9.1: strip-json-comments "^3.1.1" ws "^7.3.1" -lighthouse-logger@^1.0.0, lighthouse-logger@^1.2.0, lighthouse-logger@^1.3.0: +lighthouse-logger@^1.0.0, lighthouse-logger@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/lighthouse-logger/-/lighthouse-logger-1.3.0.tgz#ba6303e739307c4eee18f08249524e7dafd510db" integrity sha512-BbqAKApLb9ywUli+0a+PcV04SyJ/N1q/8qgCNe6U97KbPCS1BTksEuHFLYdvc8DltuhfxIUBqDZsC0bBGtl3lA== @@ -7500,7 +7500,7 @@ lighthouse-stack-packs@^1.5.0: resolved "https://registry.yarnpkg.com/lighthouse-stack-packs/-/lighthouse-stack-packs-1.5.0.tgz#c191f2b94db21602254baaebfb0bb90307a00ffa" integrity sha512-ntVOqFsrrTQYrNf+W+sNE9GjddW+ab5QN0WrrCikjMFsUvEQ28CvT0SXcHPZXFtcsb1lMSuVaNCmEuj7oXtYGQ== -lighthouse@^8.1.0: +lighthouse@^8.5.1: version "8.5.1" resolved "https://registry.yarnpkg.com/lighthouse/-/lighthouse-8.5.1.tgz#0cf4f2d3ebf67e40cd14fcbb027c9d5fb3cfa912" integrity sha512-phe3g77N5AE5pf5TARUBb9uHLvvzwpd2z/S0G+6KrC5ShEe2laSxkiiTLo/jYxsrmy5kL7qohVztdOuafy4HGQ==