lighthouse 8.4.0-dev.20210913 → 8.4.0-dev.20210917
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/flow-report/assets/styles.css +46 -4
- package/flow-report/src/app.tsx +6 -2
- package/flow-report/src/icons.tsx +11 -0
- package/flow-report/src/topbar.tsx +60 -0
- package/flow-report/tsconfig.json +6 -22
- package/lighthouse-cli/.eslintrc.cjs +27 -0
- package/lighthouse-cli/bin.js +31 -21
- package/lighthouse-cli/cli-flags.js +12 -7
- package/lighthouse-cli/commands/commands.js +2 -7
- package/lighthouse-cli/commands/list-audits.js +2 -2
- package/lighthouse-cli/commands/list-trace-categories.js +2 -2
- package/lighthouse-cli/index.js +3 -1
- package/lighthouse-cli/{test/smokehouse/package.json → package.json} +0 -0
- package/lighthouse-cli/printer.js +4 -3
- package/lighthouse-cli/run.js +14 -15
- package/lighthouse-cli/sentry-prompt.js +5 -6
- package/lighthouse-cli/test/smokehouse/frontends/back-compat-util.js +1 -1
- package/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +54 -1
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/bundle.js +1 -1
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js +1 -1
- package/lighthouse-cli/test/smokehouse/smokehouse.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/uses-responsive-images-snapshot.js +6 -1
- package/lighthouse-core/audits/dobetterweb/js-libraries.js +5 -0
- package/lighthouse-core/audits/dobetterweb/uses-http2.js +1 -0
- package/lighthouse-core/audits/lcp-lazy-loaded.js +1 -0
- package/lighthouse-core/audits/oopif-iframe-test-audit.js +1 -0
- package/lighthouse-core/fraggle-rock/config/validation.js +2 -1
- package/lighthouse-core/fraggle-rock/gather/timespan-runner.js +2 -0
- package/lighthouse-core/gather/driver/prepare.js +43 -17
- package/lighthouse-core/gather/gatherers/trace.js +4 -3
- package/lighthouse-core/index.js +4 -0
- package/lighthouse-core/lib/i18n/locales/en-US.json +6 -0
- package/lighthouse-core/lib/i18n/locales/en-XL.json +6 -0
- package/lighthouse-core/lib/proto-preprocessor.js +5 -10
- package/package.json +7 -6
- package/readme.md +2 -0
- package/report/generator/tsconfig.json +5 -16
- package/report/renderer/report-ui-features.js +1 -4
- package/report/tsconfig.json +6 -21
- package/root.js +3 -1
- package/tsconfig-all.json +15 -0
- package/tsconfig-base.json +24 -0
- package/tsconfig.json +8 -19
- package/types/lhr/lhr.d.ts +5 -1
- package/types/lhr/tsconfig.json +4 -14
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
--category-summary-font-size: 18px;
|
|
11
11
|
--gather-mode-icon-size: 16px;
|
|
12
12
|
--half-base-spacing: calc(var(--base-spacing) / 2);
|
|
13
|
+
--separator-color: var(--color-gray-300);
|
|
13
14
|
--sidebar-flow-step-navigation-font-size: 14px;
|
|
14
15
|
--sidebar-selected-bg-color: #DDEEFF;
|
|
15
16
|
--sidebar-summary-font-size: 14px;
|
|
@@ -17,18 +18,58 @@
|
|
|
17
18
|
--summary-flow-step-label-font-size: 16px;
|
|
18
19
|
--summary-subtitle-font-size: 16px;
|
|
19
20
|
--summary-title-font-size: 32px;
|
|
21
|
+
--topbar-title-font-size: 14px;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
.App {
|
|
23
25
|
display: grid;
|
|
24
|
-
grid-template-areas:
|
|
26
|
+
grid-template-areas:
|
|
27
|
+
"topbar topbar"
|
|
28
|
+
"sidebar content";
|
|
25
29
|
grid-template-columns: min-content auto;
|
|
30
|
+
grid-template-rows: min-content auto;
|
|
26
31
|
height: 100vh;
|
|
27
32
|
max-width: 100vw;
|
|
28
33
|
font-size: var(--app-font-size);
|
|
29
34
|
}
|
|
35
|
+
.App--collapsed {
|
|
36
|
+
grid-template-columns: 0px auto;
|
|
37
|
+
}
|
|
38
|
+
.App--collapsed .Sidebar {
|
|
39
|
+
display: none;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.Topbar {
|
|
43
|
+
grid-area: topbar;
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
border-bottom: 1px solid var(--separator-color);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.Topbar__menu {
|
|
50
|
+
padding: var(--base-spacing);
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
display: flex;
|
|
53
|
+
-webkit-touch-callout: none;
|
|
54
|
+
-webkit-user-select: none;
|
|
55
|
+
-khtml-user-select: none;
|
|
56
|
+
-moz-user-select: none;
|
|
57
|
+
-ms-user-select: none;
|
|
58
|
+
user-select: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.Topbar__logo {
|
|
62
|
+
display: flex;
|
|
63
|
+
margin-right: var(--half-base-spacing);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.Topbar__title {
|
|
67
|
+
font-size: var(--topbar-title-font-size);
|
|
68
|
+
font-weight: bold;
|
|
69
|
+
}
|
|
30
70
|
|
|
31
71
|
.Content {
|
|
72
|
+
grid-area: content;
|
|
32
73
|
overflow-y: auto;
|
|
33
74
|
}
|
|
34
75
|
|
|
@@ -51,11 +92,12 @@
|
|
|
51
92
|
.Separator {
|
|
52
93
|
height: 1px;
|
|
53
94
|
width: 100%;
|
|
54
|
-
background-color: var(--color
|
|
95
|
+
background-color: var(--separator-color);
|
|
55
96
|
}
|
|
56
97
|
|
|
57
98
|
.Sidebar {
|
|
58
|
-
|
|
99
|
+
grid-area: sidebar;
|
|
100
|
+
border-right: 1px solid var(--separator-color);
|
|
59
101
|
}
|
|
60
102
|
.Sidebar a {
|
|
61
103
|
color: var(--color-gray-800);
|
|
@@ -256,7 +298,7 @@
|
|
|
256
298
|
.SummaryFlowStep__divider--line {
|
|
257
299
|
grid-column-end: span 5;
|
|
258
300
|
height: 1px;
|
|
259
|
-
background-color: var(--color
|
|
301
|
+
background-color: var(--separator-color);
|
|
260
302
|
}
|
|
261
303
|
|
|
262
304
|
.SummaryCategory__null {
|
package/flow-report/src/app.tsx
CHANGED
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {FunctionComponent} from 'preact';
|
|
8
|
+
import {useState} from 'preact/hooks';
|
|
8
9
|
|
|
9
10
|
import {ReportRendererProvider} from './wrappers/report-renderer';
|
|
10
11
|
import {Sidebar} from './sidebar/sidebar';
|
|
11
12
|
import {Summary} from './summary/summary';
|
|
12
|
-
import {FlowResultContext, useCurrentLhr} from './util';
|
|
13
|
+
import {classNames, FlowResultContext, useCurrentLhr} from './util';
|
|
13
14
|
import {Report} from './wrappers/report';
|
|
15
|
+
import {Topbar} from './topbar';
|
|
14
16
|
|
|
15
17
|
const Content: FunctionComponent = () => {
|
|
16
18
|
const currentLhr = useCurrentLhr();
|
|
@@ -27,10 +29,12 @@ const Content: FunctionComponent = () => {
|
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
export const App: FunctionComponent<{flowResult: LH.FlowResult}> = ({flowResult}) => {
|
|
32
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
30
33
|
return (
|
|
31
34
|
<FlowResultContext.Provider value={flowResult}>
|
|
32
35
|
<ReportRendererProvider>
|
|
33
|
-
<div className=
|
|
36
|
+
<div className={classNames('App', {'App--collapsed': collapsed})}>
|
|
37
|
+
<Topbar onMenuClick={() => setCollapsed(c => !c)} />
|
|
34
38
|
<Sidebar/>
|
|
35
39
|
<Content/>
|
|
36
40
|
</div>
|
|
@@ -94,3 +94,14 @@ export const CpuIcon: FunctionComponent = () => {
|
|
|
94
94
|
</svg>
|
|
95
95
|
);
|
|
96
96
|
};
|
|
97
|
+
|
|
98
|
+
export const HamburgerIcon: FunctionComponent = () => {
|
|
99
|
+
return (
|
|
100
|
+
<svg viewBox="0 0 18 12" width="18" height="12" role="img">
|
|
101
|
+
<rect width="18" height="2"></rect>
|
|
102
|
+
<rect y="5" width="18" height="2"></rect>
|
|
103
|
+
<rect y="10" width="18" height="2"></rect>
|
|
104
|
+
</svg>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
+
* 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
|
|
4
|
+
* 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.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {FunctionComponent, JSX} from 'preact';
|
|
8
|
+
|
|
9
|
+
import {HamburgerIcon} from './icons';
|
|
10
|
+
|
|
11
|
+
/* eslint-disable max-len */
|
|
12
|
+
const Logo: FunctionComponent = () => {
|
|
13
|
+
return (
|
|
14
|
+
<svg height="24" width="24" viewBox="0 0 24 24" role="img">
|
|
15
|
+
<defs>
|
|
16
|
+
<linearGradient x1="57.456%" y1="13.086%" x2="18.259%" y2="72.322%" id="Topbar__logo--a">
|
|
17
|
+
<stop stop-color="#262626" stop-opacity=".1" offset="0%"/>
|
|
18
|
+
<stop stop-color="#262626" stop-opacity="0" offset="100%"/>
|
|
19
|
+
</linearGradient>
|
|
20
|
+
<linearGradient x1="100%" y1="50%" x2="0%" y2="50%" id="Topbar__logo--b">
|
|
21
|
+
<stop stop-color="#262626" stop-opacity=".1" offset="0%"/>
|
|
22
|
+
<stop stop-color="#262626" stop-opacity="0" offset="100%"/>
|
|
23
|
+
</linearGradient>
|
|
24
|
+
<linearGradient x1="58.764%" y1="65.756%" x2="36.939%" y2="50.14%" id="Topbar__logo--c">
|
|
25
|
+
<stop stop-color="#262626" stop-opacity=".1" offset="0%"/>
|
|
26
|
+
<stop stop-color="#262626" stop-opacity="0" offset="100%"/>
|
|
27
|
+
</linearGradient>
|
|
28
|
+
<linearGradient x1="41.635%" y1="20.358%" x2="72.863%" y2="85.424%" id="Topbar__logo--d">
|
|
29
|
+
<stop stop-color="#FFF" stop-opacity=".1" offset="0%"/>
|
|
30
|
+
<stop stop-color="#FFF" stop-opacity="0" offset="100%"/>
|
|
31
|
+
</linearGradient>
|
|
32
|
+
</defs>
|
|
33
|
+
<g fill="none" fill-rule="evenodd">
|
|
34
|
+
<path d="M12 3l4.125 2.625v3.75H18v2.25h-1.688l1.5 9.375H6.188l1.5-9.375H6v-2.25h1.875V5.648L12 3zm2.201 9.938L9.54 14.633 9 18.028l5.625-2.062-.424-3.028zM12.005 5.67l-1.88 1.207v2.498h3.75V6.86l-1.87-1.19z" fill="#F44B21"/>
|
|
35
|
+
<path fill="#FFF" d="M14.201 12.938L9.54 14.633 9 18.028l5.625-2.062z"/>
|
|
36
|
+
<path d="M6 18c-2.042 0-3.95-.01-5.813 0l1.5-9.375h4.326L6 18z" fill="url(#Topbar__logo--a)" fill-rule="nonzero" transform="translate(6 3)"/>
|
|
37
|
+
<path fill="#FFF176" fill-rule="nonzero" d="M13.875 9.375v-2.56l-1.87-1.19-1.88 1.207v2.543z"/>
|
|
38
|
+
<path fill="url(#Topbar__logo--b)" fill-rule="nonzero" d="M0 6.375h6v2.25H0z" transform="translate(6 3)"/>
|
|
39
|
+
<path fill="url(#Topbar__logo--c)" fill-rule="nonzero" d="M6 6.375H1.875v-3.75L6 0z" transform="translate(6 3)"/>
|
|
40
|
+
<path fill="url(#Topbar__logo--d)" fill-rule="nonzero" d="M6 0l4.125 2.625v3.75H12v2.25h-1.688l1.5 9.375H.188l1.5-9.375H0v-2.25h1.875V2.648z" transform="translate(6 3)"/>
|
|
41
|
+
</g>
|
|
42
|
+
</svg>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
/* eslint-enable max-len */
|
|
46
|
+
|
|
47
|
+
export const Topbar: FunctionComponent<{onMenuClick: JSX.MouseEventHandler<HTMLDivElement>}> =
|
|
48
|
+
({onMenuClick}) => {
|
|
49
|
+
return (
|
|
50
|
+
<div className="Topbar">
|
|
51
|
+
<div className="Topbar__menu" onClick={onMenuClick} role="button">
|
|
52
|
+
<HamburgerIcon/>
|
|
53
|
+
</div>
|
|
54
|
+
<div className="Topbar__logo">
|
|
55
|
+
<Logo/>
|
|
56
|
+
</div>
|
|
57
|
+
<div className="Topbar__title">Lighthouse User Flow Report</div>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
@@ -1,39 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": "../tsconfig-base.json",
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
"composite": true,
|
|
4
4
|
"outDir": "../.tmp/tsbuildinfo/flow-report",
|
|
5
|
-
"emitDeclarationOnly": false,
|
|
6
|
-
"declarationMap": true,
|
|
7
5
|
|
|
8
6
|
// Limit to base JS and DOM defs.
|
|
9
7
|
"lib": ["es2020", "dom", "dom.iterable"],
|
|
10
|
-
// Selectively include types from node_modules
|
|
8
|
+
// Selectively include types from node_modules/.
|
|
11
9
|
"types": ["node", "jest"],
|
|
12
|
-
"target": "es2020",
|
|
13
|
-
"module": "es2020",
|
|
14
|
-
"moduleResolution": "node",
|
|
15
|
-
"esModuleInterop": true,
|
|
16
|
-
|
|
17
|
-
"allowJs": true,
|
|
18
|
-
"checkJs": true,
|
|
19
|
-
"strict": true,
|
|
20
|
-
// TODO: remove the next line to be fully `strict`.
|
|
21
|
-
"useUnknownInCatchVariables": false,
|
|
22
|
-
|
|
23
|
-
// "listFiles": true,
|
|
24
|
-
// "noErrorTruncation": true,
|
|
25
|
-
"extendedDiagnostics": true,
|
|
26
10
|
|
|
27
11
|
"jsx": "react-jsx",
|
|
28
12
|
"jsxImportSource": "preact",
|
|
29
13
|
},
|
|
14
|
+
"references": [
|
|
15
|
+
{"path": "../types/lhr/"},
|
|
16
|
+
{"path": "../report"},
|
|
17
|
+
],
|
|
30
18
|
"include": [
|
|
31
19
|
"**/*.ts",
|
|
32
20
|
"**/*.tsx",
|
|
33
21
|
"./types",
|
|
34
22
|
],
|
|
35
|
-
"references": [
|
|
36
|
-
{"path": "../types/lhr/"},
|
|
37
|
-
{"path": "../report"},
|
|
38
|
-
],
|
|
39
23
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
+
* 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
|
|
4
|
+
* 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.
|
|
5
|
+
*/
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
env: {
|
|
10
|
+
browser: true,
|
|
11
|
+
},
|
|
12
|
+
rules: {
|
|
13
|
+
// TODO(esmodules): move to root eslint when all code is ESM
|
|
14
|
+
// or when this is resolved: https://github.com/import-js/eslint-plugin-import/issues/2214
|
|
15
|
+
'import/order': [2, {
|
|
16
|
+
'groups': [
|
|
17
|
+
'builtin',
|
|
18
|
+
'external',
|
|
19
|
+
['sibling', 'parent'],
|
|
20
|
+
'index',
|
|
21
|
+
'object',
|
|
22
|
+
'type',
|
|
23
|
+
],
|
|
24
|
+
'newlines-between': 'always',
|
|
25
|
+
}],
|
|
26
|
+
},
|
|
27
|
+
};
|
package/lighthouse-cli/bin.js
CHANGED
|
@@ -18,19 +18,23 @@
|
|
|
18
18
|
* cli-flags lh-core/index
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
import fs from 'fs';
|
|
22
|
+
import path from 'path';
|
|
23
|
+
import url from 'url';
|
|
24
|
+
|
|
25
|
+
import log from 'lighthouse-logger';
|
|
26
|
+
import updateNotifier from 'update-notifier';
|
|
27
|
+
|
|
28
|
+
import * as commands from './commands/commands.js';
|
|
29
|
+
import * as Printer from './printer.js';
|
|
30
|
+
import {getFlags} from './cli-flags.js';
|
|
31
|
+
import {runLighthouse} from './run.js';
|
|
32
|
+
import lighthouse from '../lighthouse-core/index.js';
|
|
33
|
+
import * as Sentry from '../lighthouse-core/lib/sentry.js';
|
|
34
|
+
import {askPermission} from './sentry-prompt.js';
|
|
35
|
+
import {LH_ROOT} from '../root.js';
|
|
36
|
+
|
|
37
|
+
const pkg = JSON.parse(fs.readFileSync(LH_ROOT + '/package.json', 'utf-8'));
|
|
34
38
|
|
|
35
39
|
/**
|
|
36
40
|
* @return {boolean}
|
|
@@ -58,16 +62,22 @@ async function begin() {
|
|
|
58
62
|
commands.listTraceCategories();
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
const
|
|
65
|
+
const urlUnderTest = cliFlags._[0];
|
|
62
66
|
|
|
63
67
|
/** @type {LH.Config.Json|undefined} */
|
|
64
68
|
let configJson;
|
|
65
69
|
if (cliFlags.configPath) {
|
|
66
70
|
// Resolve the config file path relative to where cli was called.
|
|
67
71
|
cliFlags.configPath = path.resolve(process.cwd(), cliFlags.configPath);
|
|
68
|
-
|
|
72
|
+
|
|
73
|
+
if (cliFlags.configPath.endsWith('.json')) {
|
|
74
|
+
configJson = JSON.parse(fs.readFileSync(cliFlags.configPath, 'utf-8'));
|
|
75
|
+
} else {
|
|
76
|
+
const configModuleUrl = url.pathToFileURL(cliFlags.configPath).href;
|
|
77
|
+
configJson = (await import(configModuleUrl)).default;
|
|
78
|
+
}
|
|
69
79
|
} else if (cliFlags.preset) {
|
|
70
|
-
configJson =
|
|
80
|
+
configJson = (await import(`../lighthouse-core/config/${cliFlags.preset}-config.js`)).default;
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
if (cliFlags.budgetPath) {
|
|
@@ -88,7 +98,7 @@ async function begin() {
|
|
|
88
98
|
|
|
89
99
|
if (
|
|
90
100
|
cliFlags.output.length === 1 &&
|
|
91
|
-
cliFlags.output[0] ===
|
|
101
|
+
cliFlags.output[0] === Printer.OutputMode.json &&
|
|
92
102
|
!cliFlags.outputPath
|
|
93
103
|
) {
|
|
94
104
|
cliFlags.outputPath = 'stdout';
|
|
@@ -106,7 +116,7 @@ async function begin() {
|
|
|
106
116
|
}
|
|
107
117
|
|
|
108
118
|
if (cliFlags.printConfig) {
|
|
109
|
-
const config = generateConfig(configJson, cliFlags);
|
|
119
|
+
const config = lighthouse.generateConfig(configJson, cliFlags);
|
|
110
120
|
process.stdout.write(config.getPrintString());
|
|
111
121
|
return;
|
|
112
122
|
}
|
|
@@ -119,7 +129,7 @@ async function begin() {
|
|
|
119
129
|
}
|
|
120
130
|
if (cliFlags.enableErrorReporting) {
|
|
121
131
|
Sentry.init({
|
|
122
|
-
url,
|
|
132
|
+
url: urlUnderTest,
|
|
123
133
|
flags: cliFlags,
|
|
124
134
|
environmentData: {
|
|
125
135
|
name: 'redacted', // prevent sentry from using hostname
|
|
@@ -132,9 +142,9 @@ async function begin() {
|
|
|
132
142
|
});
|
|
133
143
|
}
|
|
134
144
|
|
|
135
|
-
return runLighthouse(
|
|
145
|
+
return runLighthouse(urlUnderTest, cliFlags, configJson);
|
|
136
146
|
}
|
|
137
147
|
|
|
138
|
-
|
|
148
|
+
export {
|
|
139
149
|
begin,
|
|
140
150
|
};
|
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
/* eslint-disable max-len */
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
import fs from 'fs';
|
|
11
|
+
|
|
12
|
+
import yargs from 'yargs';
|
|
13
|
+
import * as yargsHelpers from 'yargs/helpers';
|
|
14
|
+
|
|
15
|
+
import {isObjectOfUnknownValues} from '../lighthouse-core/lib/type-verifiers.js';
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* @param {string=} manualArgv
|
|
@@ -17,8 +20,10 @@ const {isObjectOfUnknownValues} = require('../lighthouse-core/lib/type-verifiers
|
|
|
17
20
|
* @return {LH.CliFlags}
|
|
18
21
|
*/
|
|
19
22
|
function getFlags(manualArgv, options = {}) {
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
const y = manualArgv ?
|
|
24
|
+
// @ts-expect-error - undocumented, but yargs() supports parsing a single `string`.
|
|
25
|
+
yargs(manualArgv) :
|
|
26
|
+
yargs(yargsHelpers.hideBin(process.argv));
|
|
22
27
|
|
|
23
28
|
let parser = y.help('help')
|
|
24
29
|
.showHelpOnFail(false, 'Specify --help for available options')
|
|
@@ -318,7 +323,7 @@ function getFlags(manualArgv, options = {}) {
|
|
|
318
323
|
throw new Error('Please provide a url');
|
|
319
324
|
})
|
|
320
325
|
.epilogue('For more information on Lighthouse, see https://developers.google.com/web/tools/lighthouse/.')
|
|
321
|
-
.wrap(
|
|
326
|
+
.wrap(y.terminalWidth());
|
|
322
327
|
|
|
323
328
|
if (options.noExitOnFailure) {
|
|
324
329
|
// Silence console.error() logging and don't process.exit().
|
|
@@ -499,6 +504,6 @@ function coerceScreenEmulation(value) {
|
|
|
499
504
|
return screenEmulationSettings;
|
|
500
505
|
}
|
|
501
506
|
|
|
502
|
-
|
|
507
|
+
export {
|
|
503
508
|
getFlags,
|
|
504
509
|
};
|
|
@@ -5,10 +5,5 @@
|
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
listAudits,
|
|
13
|
-
listTraceCategories,
|
|
14
|
-
};
|
|
8
|
+
export {listAudits} from './list-audits.js';
|
|
9
|
+
export {listTraceCategories} from './list-trace-categories.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import lighthouse from '../../lighthouse-core/index.js';
|
|
9
9
|
|
|
10
10
|
function listAudits() {
|
|
11
11
|
const audits = lighthouse.getAuditList().map((i) => i.replace(/\.js$/, ''));
|
|
@@ -13,4 +13,4 @@ function listAudits() {
|
|
|
13
13
|
process.exit(0);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
export {listAudits};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import lighthouse from '../../lighthouse-core/index.js';
|
|
9
9
|
|
|
10
10
|
function listTraceCategories() {
|
|
11
11
|
const traceCategories = lighthouse.traceCategories;
|
|
@@ -13,4 +13,4 @@ function listTraceCategories() {
|
|
|
13
13
|
process.exit(0);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
export {listTraceCategories};
|
package/lighthouse-cli/index.js
CHANGED
|
File without changes
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
|
|
10
|
+
import log from 'lighthouse-logger';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* An enumeration of acceptable output modes:
|
|
@@ -91,7 +92,7 @@ function getValidOutputOptions() {
|
|
|
91
92
|
return Object.keys(OutputMode);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
export {
|
|
95
96
|
checkOutputPath,
|
|
96
97
|
write,
|
|
97
98
|
OutputMode,
|
package/lighthouse-cli/run.js
CHANGED
|
@@ -7,20 +7,19 @@
|
|
|
7
7
|
|
|
8
8
|
/* eslint-disable no-console */
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
const psList = require('ps-list');
|
|
10
|
+
import path from 'path';
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
import psList from 'ps-list';
|
|
13
|
+
import * as ChromeLauncher from 'chrome-launcher';
|
|
14
|
+
import yargsParser from 'yargs-parser';
|
|
15
|
+
import log from 'lighthouse-logger';
|
|
16
|
+
import open from 'open';
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const URL = require('../lighthouse-core/lib/url-shim.js');
|
|
22
|
-
|
|
23
|
-
const open = require('open');
|
|
18
|
+
import * as Printer from './printer.js';
|
|
19
|
+
import lighthouse from '../lighthouse-core/index.js';
|
|
20
|
+
import {getFilenamePrefix} from '../report/generator/file-namer.js';
|
|
21
|
+
import * as assetSaver from '../lighthouse-core/lib/asset-saver.js';
|
|
22
|
+
import URL from '../lighthouse-core/lib/url-shim.js';
|
|
24
23
|
|
|
25
24
|
/** @typedef {Error & {code: string, friendlyMessage?: string}} ExitError */
|
|
26
25
|
|
|
@@ -203,8 +202,8 @@ async function potentiallyKillChrome(launchedChrome) {
|
|
|
203
202
|
* @return {Promise<LH.RunnerResult|undefined>}
|
|
204
203
|
*/
|
|
205
204
|
async function runLighthouseWithFraggleRock(url, flags, config, launchedChrome) {
|
|
206
|
-
const fraggleRock =
|
|
207
|
-
const puppeteer =
|
|
205
|
+
const fraggleRock = (await import('../lighthouse-core/fraggle-rock/api.js')).default;
|
|
206
|
+
const puppeteer = (await import('puppeteer')).default;
|
|
208
207
|
const browser = await puppeteer.connect({browserURL: `http://localhost:${launchedChrome.port}`});
|
|
209
208
|
const page = await browser.newPage();
|
|
210
209
|
flags.channel = 'fraggle-rock-cli';
|
|
@@ -272,7 +271,7 @@ async function runLighthouse(url, flags, config) {
|
|
|
272
271
|
}
|
|
273
272
|
}
|
|
274
273
|
|
|
275
|
-
|
|
274
|
+
export {
|
|
276
275
|
parseChromeFlags,
|
|
277
276
|
saveResults,
|
|
278
277
|
runLighthouse,
|
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const log = require('lighthouse-logger');
|
|
8
|
+
import Configstore from 'configstore';
|
|
9
|
+
import Confirm from 'enquirer';
|
|
10
|
+
import log from 'lighthouse-logger';
|
|
12
11
|
|
|
13
12
|
const MAXIMUM_WAIT_TIME = 20 * 1000;
|
|
14
13
|
|
|
@@ -29,7 +28,7 @@ function prompt() {
|
|
|
29
28
|
/** @type {NodeJS.Timer|undefined} */
|
|
30
29
|
let timeout;
|
|
31
30
|
|
|
32
|
-
const prompt = new Confirm({
|
|
31
|
+
const prompt = new Confirm.Confirm({
|
|
33
32
|
name: 'isErrorReportingEnabled',
|
|
34
33
|
initial: false,
|
|
35
34
|
message: MESSAGE,
|
|
@@ -75,6 +74,6 @@ function askPermission() {
|
|
|
75
74
|
}).catch(_ => false);
|
|
76
75
|
}
|
|
77
76
|
|
|
78
|
-
|
|
77
|
+
export {
|
|
79
78
|
askPermission,
|
|
80
79
|
};
|