Skip to content

Commit

Permalink
Resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
addyosmani committed Mar 14, 2017
2 parents 6f3cd08 + f1d0e62 commit 2723f2c
Show file tree
Hide file tree
Showing 163 changed files with 3,288 additions and 3,132 deletions.
4 changes: 1 addition & 3 deletions appveyor.yml → .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ before_test:
- set "PATH=C:\MinGW\msys\1.0\bin;%PATH%"
- set "LIGHTHOUSE_CHROMIUM_PATH=%CD%\chrome-win32\chrome.exe"
- bash ./lighthouse-core/scripts/download-chrome.sh
- npm run build-cli
- npm run build-extension
- npm run build-viewer
- npm run build-all

test_script:
- node --version
Expand Down
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ coverage/**
lighthouse-cli/*.js
lighthouse-cli/commands/*.js
lighthouse-cli/types/*.js

# Handlebar-templates
lighthouse-core/report/templates/report-templates.js
lighthouse-core/report/partials/templates/report-partials.js
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ lighthouse-core/third_party/src
coverage

lighthouse-cli/results
lighthouse-cli/performance-experiment/experiment-database/experiment-data*
results
results.html
last-run-results.html
Expand All @@ -17,6 +18,8 @@ last-run-results.html
*.devtoolslog.json
*.screenshots.html
*.report.html
*.report.json
*.report.pretty
*.artifacts.log

closure-error.log
Expand All @@ -34,3 +37,6 @@ lighthouse-cli/types/*.map
/chrome-linux/
/chrome-win32/
/chrome.zip

lighthouse-core/report/partials/templates/
lighthouse-core/report/templates/*.js
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ lighthouse-core/test
lighthouse-viewer
lighthouse-extension

.appveyor.yml
.travis.yml
appveyor.yml

4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ before_script:
- export LIGHTHOUSE_CHROMIUM_PATH="$(pwd)/chrome-linux/chrome"
- sh -e /etc/init.d/xvfb start
- ./lighthouse-core/scripts/download-chrome.sh
- npm run build-cli
- npm run build-extension
- npm run build-viewer
- npm run build-all
script:
- npm run lint
- npm run unit
Expand Down
47 changes: 47 additions & 0 deletions gulp/compile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright 2017 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.
*/
'use strict';
const gulp = require('gulp');
const handlebars = require('gulp-handlebars');
const declare = require('gulp-declare');
const concat = require('gulp-concat');
const config = require('./config');

module.exports = {
compilePartials,
compileReport
};

function compilePartials() {
compile(config.partials, config.partialsDist, 'partials');
}

function compileReport() {
compile(config.report, config.reportDist, 'templates');
}

function compile(location, dist, type) {
return gulp.src(location)
.pipe(handlebars({
handlebars: require('handlebars')
}))
.pipe(declare({
namespace: `report.${type}`,
noRedeclare: true, // Avoid duplicate declarations
}))
.pipe(concat(`report-${type}.js`))
.pipe(gulp.dest(dist));
}
29 changes: 8 additions & 21 deletions lighthouse-core/formatters/null-formatter.js → gulp/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @license
* Copyright 2016 Google Inc. All rights reserved.
* Copyright 2017 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.
Expand All @@ -14,24 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

const Formatter = require('./formatter');

class NullFormatter extends Formatter {
static getFormatter(type) {
switch (type) {
case 'pretty':
return _ => '';

case 'html':
return '';

default:
throw new Error('Unknown formatter type');
}
}
}

module.exports = NullFormatter;
module.exports = {
report: 'lighthouse-core/**/templates/*.html',
reportDist: 'lighthouse-core/report/templates/',
partials: 'lighthouse-core/report/partials/*.html',
partialsDist: 'lighthouse-core/report/partials/templates/',
dist: 'dist'
};
37 changes: 37 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright 2017 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.
*/
'use strict';

const gulp = require('gulp');
const compile = require('./gulp/compile');
const config = require('./gulp/config');

gulp.task('compileReport', compile.compileReport);
gulp.task('compilePartials', compile.compilePartials);

gulp.task('compile-templates', ['compileReport', 'compilePartials']);

gulp.task('watch', ['compileReport', 'compilePartials'], () => {
gulp.watch([
config.report
], ['compileReport']);

gulp.watch([
config.partials
], ['compilePartials']);
});

gulp.task('default', ['compile-templates']);
18 changes: 10 additions & 8 deletions jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@

"compilerOptions": {
"target": "ES6",
"outDir": "./dist",
"noEmit": true,
"diagnostics": true
},
"exclude": [
"**/node_modules",
"**/third_party",
"**/dist",
"lighthouse-cli",
"node_modules",
"coverage",

"lighthouse-core/closure",
"**/node_modules/*",
"**/third_party/*",
"**/dist/*",
"**/app/scripts/*",

"lighthouse-extension",
"lighthouse-cli",
"lighthouse-viewer"
"lighthouse-core/report/templates/*.js",
"lighthouse-core/closure"
]
}
44 changes: 30 additions & 14 deletions lighthouse-cli/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ const cliFlags = yargs
'view'
], 'Output:')
.describe({
'output': 'Reporter for the results',
'output-path': `The file path to output the results
'output': `Reporter for the results, supports multiple values`,
'output-path': `The file path to output the results. Use 'stdout' to write to stdout.
If using JSON output, default is stdout.
If using HTML output, default is a file in the working directory with a name based on the test URL and date.
If using multiple outputs, --output-path is ignored.
Example: --output-path=./lighthouse-results.html`,
'view': 'Open HTML report in your browser'
})
Expand Down Expand Up @@ -168,6 +171,10 @@ if (cliFlags.verbose) {
}
log.setLevel(cliFlags.logLevel);

if (cliFlags.output === Printer.OutputMode[Printer.OutputMode.json] && !cliFlags.outputPath) {
cliFlags.outputPath = 'stdout';
}

/**
* If the requested port is 0, set it to a random, unused port.
*/
Expand Down Expand Up @@ -277,18 +284,27 @@ function saveResults(results: Results,
promise = promise.then(_ => assetSaver.saveAssets(artifacts, results.audits, resolvedPath));
}

if (flags.output === Printer.OutputMode[Printer.OutputMode.none]) {
promise = promise
.then(_ => Printer.write(results, 'html', `${resolvedPath}.report.html`))
.then(_ => {
if (flags.view) return opn(`${resolvedPath}.report.html`, {wait: false});

log.warn('CLI', 'Report output no longer defaults to stdout. Use `--output=pretty` to re-enable.');
log.log('CLI', 'Protip: Run lighthouse with `--view` to immediately open the HTML report in your browser');
});
}

return promise.then(_ => Printer.write(results, flags.output, flags.outputPath));
return promise.then(_ => {
if (Array.isArray(flags.output)) {
return flags.output.reduce((innerPromise, outputType) => {
const outputPath = `${resolvedPath}.report.${outputType}`;
return innerPromise.then((_: Results) => Printer.write(results, outputType, outputPath));
}, Promise.resolve(results));
} else {
const outputPath = flags.outputPath || `${resolvedPath}.report.${flags.output}`;
return Printer.write(results, flags.output, outputPath).then(results => {
if (flags.output === Printer.OutputMode[Printer.OutputMode.html]) {
if (flags.view) {
opn(`${resolvedPath}.report.html`, {wait: false});
} else {
log.log('CLI', 'Protip: Run lighthouse with `--view` to immediately open the HTML report in your browser');
}
}

return results;
});
}
});
}

export async function runLighthouse(url: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class PerfXReportGenerator extends ReportGenerator {
return scriptArr;
}

_registerFormatters(audits) {
super._registerFormatters(audits);
_registerPartials(audits) {
super._registerPartials(audits);
const configPanelTemplate = Handlebars.compile(configPanelPartial);
const criticalRequestChains = audits['critical-request-chains'].extendedInfo.value;
Handlebars.registerPartial('config-panel', configPanelTemplate(criticalRequestChains));
Expand Down
Loading

0 comments on commit 2723f2c

Please sign in to comment.