Skip to content

Commit 7fe3574

Browse files
wardpeetbrendankenny
authored andcommitted
Include version and commit in lighthouse-background.js bundle (#2236)
1 parent 7097d5c commit 7fe3574

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

lighthouse-extension/app/src/popup.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ function getLighthouseVersion() {
4040
return chrome.runtime.getManifest().version;
4141
}
4242

43+
function getLighthouseCommitHash() {
44+
return '__COMMITHASH__';
45+
}
46+
4347
function getChromeVersion() {
4448
return /Chrome\/([0-9.]+)/.exec(navigator.userAgent)[1];
4549
}
@@ -55,6 +59,7 @@ function hideRunningSubpage() {
5559
function buildReportErrorLink(err) {
5660
const issueBody = `
5761
**Lighthouse Version**: ${getLighthouseVersion()}
62+
**Lighthouse Commit**: ${getLighthouseCommitHash()}
5863
**Chrome Version**: ${getChromeVersion()}
5964
**Initial URL**: ${siteURL}
6065
**Error Message**: ${err.message}

lighthouse-extension/gulpfile.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,20 @@ const livereload = require('gulp-livereload');
1515
const babel = require('babel-core');
1616
const tap = require('gulp-tap');
1717
const zip = require('gulp-zip');
18+
const gulpReplace = require('gulp-replace');
19+
const header = require('gulp-header');
1820
const LighthouseRunner = require('../lighthouse-core/runner');
21+
const pkg = require('../package.json');
1922

2023
const distDir = 'dist';
2124

25+
const VERSION = pkg.version;
26+
const COMMIT_HASH = require('child_process')
27+
.execSync('git rev-parse HEAD')
28+
.toString().trim();
29+
30+
const BANNER = `// lighthouse, browserified. ${VERSION} (${COMMIT_HASH})\n`;
31+
2232
const audits = LighthouseRunner.getAuditList()
2333
.map(f => '../lighthouse-core/audits/' + f.replace(/\.js$/, ''));
2434

@@ -144,9 +154,11 @@ gulp.task('browserify-other', () => {
144154
.pipe(tap(file => {
145155
let bundle = browserify(file.path); // , {debug: true}); // for sourcemaps
146156
bundle = applyBrowserifyTransforms(bundle);
157+
147158
// Inject the new browserified contents back into our gulp pipeline
148159
file.contents = bundle.bundle();
149160
}))
161+
.pipe(gulpReplace('__COMMITHASH__', COMMIT_HASH))
150162
.pipe(gulp.dest('app/scripts'))
151163
.pipe(gulp.dest(`${distDir}/scripts`));
152164
});
@@ -170,6 +182,7 @@ gulp.task('compilejs', () => {
170182
file.contents = new Buffer(minified);
171183
return file;
172184
}))
185+
.pipe(header(BANNER))
173186
.pipe(gulp.dest('dist/scripts'));
174187
});
175188

lighthouse-extension/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"gulp-chrome-manifest": "0.0.13",
1717
"gulp-debug": "^2.1.2",
1818
"gulp-eslint": "^3.0.1",
19+
"gulp-header": "^1.8.9",
1920
"gulp-livereload": "^3.8.1",
2021
"gulp-tap": "^0.1.3",
2122
"gulp-util": "^3.0.7",

lighthouse-extension/yarn.lock

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,12 @@ concat-stream@~1.4.5:
504504
readable-stream "~1.1.9"
505505
typedarray "~0.0.5"
506506

507+
concat-with-sourcemaps@*:
508+
version "1.0.4"
509+
resolved "https://registry.yarnpkg.com/concat-with-sourcemaps/-/concat-with-sourcemaps-1.0.4.tgz#f55b3be2aeb47601b10a2d5259ccfb70fd2f1dd6"
510+
dependencies:
511+
source-map "^0.5.1"
512+
507513
console-browserify@^1.1.0:
508514
version "1.1.0"
509515
resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10"
@@ -1279,6 +1285,15 @@ gulp-eslint@^3.0.1:
12791285
eslint "^3.0.0"
12801286
gulp-util "^3.0.6"
12811287

1288+
gulp-header@^1.8.9:
1289+
version "1.8.9"
1290+
resolved "https://registry.yarnpkg.com/gulp-header/-/gulp-header-1.8.9.tgz#c9f10fee0632d81e939789c6ecf45a151bf3098b"
1291+
dependencies:
1292+
concat-with-sourcemaps "*"
1293+
gulp-util "*"
1294+
object-assign "*"
1295+
through2 "^2.0.0"
1296+
12821297
gulp-livereload@^3.8.1:
12831298
version "3.8.1"
12841299
resolved "https://registry.yarnpkg.com/gulp-livereload/-/gulp-livereload-3.8.1.tgz#00f744b2d749d3e9e3746589c8a44acac779b50f"
@@ -2093,14 +2108,14 @@ number-is-nan@^1.0.0:
20932108
version "1.0.1"
20942109
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
20952110

2111+
object-assign@*, object-assign@^4.0.1, object-assign@^4.1.0:
2112+
version "4.1.1"
2113+
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
2114+
20962115
object-assign@^3.0.0:
20972116
version "3.0.0"
20982117
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-3.0.0.tgz#9bedd5ca0897949bca47e7ff408062d549f587f2"
20992118

2100-
object-assign@^4.0.1, object-assign@^4.1.0:
2101-
version "4.1.1"
2102-
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
2103-
21042119
object-inspect@~0.4.0:
21052120
version "0.4.0"
21062121
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-0.4.0.tgz#f5157c116c1455b243b06ee97703392c5ad89fec"
@@ -2630,7 +2645,7 @@ sort-json@^1.2.0:
26302645
dependencies:
26312646
detect-indent "^4.0.0"
26322647

2633-
"source-map@>= 0.1.2", source-map@~0.5.3:
2648+
"source-map@>= 0.1.2", source-map@^0.5.1, source-map@~0.5.3:
26342649
version "0.5.6"
26352650
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412"
26362651

0 commit comments

Comments
 (0)