diff --git a/.build-for-now.sh b/.build-for-now.sh deleted file mode 100644 index 07e7accd0791..000000000000 --- a/.build-for-now.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -## -# @license Copyright 2019 Google Inc. All Rights Reserved. -# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -## - -set -x - -# Manually install this one report dependency. Avoid installing all deps (for speed) -rm package.json -yarn add details-element-polyfill@2.2.0 - -# Create dist if it's not already there -mkdir -p dist - -# Generate the report and place as dist/index.html -node lighthouse-core/scripts/build-report-for-autodeployment.js diff --git a/lighthouse-core/runner.js b/lighthouse-core/runner.js index c96a9e6a55a9..a798eda2edd8 100644 --- a/lighthouse-core/runner.js +++ b/lighthouse-core/runner.js @@ -237,6 +237,7 @@ class Runner { gatherMode: undefined, auditMode: undefined, output: undefined, + channel: undefined, budgets: undefined, }; const normalizedGatherSettings = Object.assign({}, artifacts.settings, overrides); diff --git a/lighthouse-core/scripts/build-report-for-autodeployment.js b/lighthouse-core/scripts/build-report-for-autodeployment.js index f4534436ed3d..5bfab5d568d7 100644 --- a/lighthouse-core/scripts/build-report-for-autodeployment.js +++ b/lighthouse-core/scripts/build-report-for-autodeployment.js @@ -10,10 +10,14 @@ /* eslint-disable no-console */ const fs = require('fs'); const path = require('path'); +const mkdirp = require('mkdirp').sync; +const swapLocale = require('../lib/i18n/swap-locale.js'); const ReportGenerator = require('../../lighthouse-core/report/report-generator.js'); const lhr = /** @type {LH.Result} */ (require('../../lighthouse-core/test/results/sample_v2.json')); +const DIST = path.join(__dirname, `../../dist`); + // Add a plugin to demo plugin rendering. lhr.categories['lighthouse-plugin-someplugin'] = { id: 'lighthouse-plugin-someplugin', @@ -22,8 +26,26 @@ lhr.categories['lighthouse-plugin-someplugin'] = { auditRefs: [], }; -console.log('🕒 Generating report for sample_v2.json...'); -const html = ReportGenerator.generateReport(lhr, 'html'); -const filename = path.join(__dirname, '../../dist/index.html'); -fs.writeFileSync(filename, html, {encoding: 'utf-8'}); -console.log('✅', filename, 'written.'); +(async function() { + const filenameToLhr = { + 'english': lhr, + 'espanol': swapLocale(lhr, 'es').lhr, + 'arabic': swapLocale(lhr, 'ar').lhr, + }; + + mkdirp(DIST); + + // Generate and write reports + Object.entries(filenameToLhr).forEach(([filename, lhr]) => { + let html = ReportGenerator.generateReportHtml(lhr); + for (const variant of ['', '-devtools']) { + if (variant === '-devtools') { + html = html.replace(`"lh-root lh-vars"`, `"lh-root lh-vars lh-devtools"`); + } + const filepath = `${DIST}/${filename}${variant}/index.html`; + mkdirp(path.dirname(filepath)); + fs.writeFileSync(filepath, html, {encoding: 'utf-8'}); + console.log('✅', filepath, 'written.'); + } + }); +})(); diff --git a/now.json b/now.json index fd1f9ca74f51..02b220f9dada 100644 --- a/now.json +++ b/now.json @@ -2,7 +2,7 @@ "version": 2, "builds": [ { - "src": ".build-for-now.sh", + "src": "package.json", "use": "@now/static-build" } ], diff --git a/package.json b/package.json index b16ac4f42b4f..a0a085155290 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "chrome": "node lighthouse-core/scripts/manual-chrome-launcher.js", "fast": "yarn start --emulated-form-factor=none --throttlingMethod=provided", "deploy-viewer": "yarn build-viewer --deploy", + "now-build": "node lighthouse-core/scripts/build-report-for-autodeployment.js", "bundlesize": "bundlesize", "timing-trace": "node lighthouse-core/scripts/generate-timing-trace.js", "changelog": "conventional-changelog --config ./build/changelog-generator/index.js --infile changelog.md --same-file", @@ -122,7 +123,6 @@ "isomorphic-fetch": "^2.2.1", "jest": "^24.3.0", "jsdom": "^12.2.0", - "lodash.set": "^4.3.2", "make-dir": "^1.3.0", "npm-run-posix-or-windows": "^2.0.2", "nyc": "^13.3.0", @@ -152,6 +152,7 @@ "jsonlint-mod": "^1.7.4", "lighthouse-logger": "^1.2.0", "lodash.isequal": "^4.5.0", + "lodash.set": "^4.3.2", "lookup-closest-locale": "6.0.4", "metaviewport-parser": "0.2.0", "mkdirp": "0.5.1",