lighthouse-badges 1.2.2 → 1.2.4
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/README.md +1 -9
- package/dist/README.md +1 -9
- package/dist/package.json +3 -2
- package/dist/src/index.js +9 -12
- package/dist/src/lighthouse-badges.js +23 -32
- package/package.json +3 -2
- package/src/index.js +0 -3
- package/src/lighthouse-badges.js +2 -7
package/README.md
CHANGED
|
@@ -54,17 +54,9 @@ Required arguments:
|
|
|
54
54
|
average score(s) of all the urls supplied, combined
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
Additionally, you can pass parameters to the lighthouse process directly via environment variable:
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
# This will pass '--preset=desktop' to the lighthouse process
|
|
61
|
-
export LIGHTHOUSE_BADGES_PARAMS="--preset=desktop"
|
|
62
|
-
lighthouse-badges --urls https://www.youtube.com/
|
|
63
|
-
```
|
|
64
|
-
|
|
65
57
|
### Run
|
|
66
58
|
|
|
67
|
-
|
|
59
|
+
node >= 16 is required.
|
|
68
60
|
|
|
69
61
|
#### Option 1: npm
|
|
70
62
|
```bash
|
package/dist/README.md
CHANGED
|
@@ -54,17 +54,9 @@ Required arguments:
|
|
|
54
54
|
average score(s) of all the urls supplied, combined
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
Additionally, you can pass parameters to the lighthouse process directly via environment variable:
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
# This will pass '--preset=desktop' to the lighthouse process
|
|
61
|
-
export LIGHTHOUSE_BADGES_PARAMS="--preset=desktop"
|
|
62
|
-
lighthouse-badges --urls https://www.youtube.com/
|
|
63
|
-
```
|
|
64
|
-
|
|
65
57
|
### Run
|
|
66
58
|
|
|
67
|
-
|
|
59
|
+
node >= 16 is required.
|
|
68
60
|
|
|
69
61
|
#### Option 1: npm
|
|
70
62
|
```bash
|
package/dist/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lighthouse-badges",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "🚦Generate gh-badges (shields.io) based on Lighthouse performance.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"lighthouse-badges": "src/index.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"app:install": "cd dist && npm i -g .",
|
|
10
|
+
"app:install": "npm run build && cd dist && npm i -g .",
|
|
11
11
|
"app:reinstall": "npm-run-all app:uninstall app:install",
|
|
12
12
|
"app:uninstall": "npm uninstall -g @emazzotta/lighthouse-badges; npm uninstall -g .; npm uninstall -g lighthouse-badges",
|
|
13
13
|
"build": "npm run clean && babel src --out-dir dist/src && sed 's#\"dist/src/index.js\"#\"src/index.js\"#' package.json > ./dist/package.json && cp README.md dist && cp LICENSE.md dist && cp -r node_modules dist",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"url": "https://github.com/emazzotta/lighthouse-badges.git"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
+
"@babel/runtime": "^7.20.13",
|
|
46
47
|
"argparse": "2.0.1",
|
|
47
48
|
"badge-maker": "^3.3.1",
|
|
48
49
|
"chrome-launcher": "^0.15.1",
|
package/dist/src/index.js
CHANGED
|
@@ -17,32 +17,29 @@ var handleUserInput = /*#__PURE__*/function () {
|
|
|
17
17
|
while (1) switch (_context.prev = _context.next) {
|
|
18
18
|
case 0:
|
|
19
19
|
_context.prev = 0;
|
|
20
|
-
if (process.env.LIGHTHOUSE_BADGES_PARAMS) {
|
|
21
|
-
process.stdout.write("LIGHTHOUSE_BADGES_PARAMS: ".concat(process.env.LIGHTHOUSE_BADGES_PARAMS, "\n"));
|
|
22
|
-
}
|
|
23
20
|
spinner.start();
|
|
24
21
|
_context.t0 = _lighthouseBadges.processParameters;
|
|
25
|
-
_context.next =
|
|
22
|
+
_context.next = 5;
|
|
26
23
|
return _argparser["default"].parse_args();
|
|
27
|
-
case
|
|
24
|
+
case 5:
|
|
28
25
|
_context.t1 = _context.sent;
|
|
29
26
|
_context.t2 = _lighthouseBadges.calculateLighthouseMetrics;
|
|
30
|
-
_context.next =
|
|
27
|
+
_context.next = 9;
|
|
31
28
|
return (0, _context.t0)(_context.t1, _context.t2);
|
|
32
|
-
case
|
|
29
|
+
case 9:
|
|
33
30
|
spinner.stop();
|
|
34
|
-
_context.next =
|
|
31
|
+
_context.next = 16;
|
|
35
32
|
break;
|
|
36
|
-
case
|
|
37
|
-
_context.prev =
|
|
33
|
+
case 12:
|
|
34
|
+
_context.prev = 12;
|
|
38
35
|
_context.t3 = _context["catch"](0);
|
|
39
36
|
process.stderr.write("".concat(_context.t3, "\n"));
|
|
40
37
|
process.exit(1);
|
|
41
|
-
case
|
|
38
|
+
case 16:
|
|
42
39
|
case "end":
|
|
43
40
|
return _context.stop();
|
|
44
41
|
}
|
|
45
|
-
}, _callee, null, [[0,
|
|
42
|
+
}, _callee, null, [[0, 12]]);
|
|
46
43
|
}));
|
|
47
44
|
return function handleUserInput(_x) {
|
|
48
45
|
return _ref.apply(this, arguments);
|
|
@@ -124,41 +124,33 @@ var processRawLighthouseResult = /*#__PURE__*/function () {
|
|
|
124
124
|
exports.processRawLighthouseResult = processRawLighthouseResult;
|
|
125
125
|
var calculateLighthouseMetrics = /*#__PURE__*/function () {
|
|
126
126
|
var _ref7 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(url, shouldSaveReport) {
|
|
127
|
-
var
|
|
128
|
-
chromeParameters,
|
|
129
|
-
chrome,
|
|
130
|
-
options,
|
|
131
|
-
runnerResult,
|
|
132
|
-
reportHtml,
|
|
133
|
-
reportJson,
|
|
134
|
-
_args5 = arguments;
|
|
127
|
+
var chromeParameters, chrome, options, runnerResult, reportHtml, reportJson;
|
|
135
128
|
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
136
129
|
while (1) switch (_context5.prev = _context5.next) {
|
|
137
130
|
case 0:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
_context5.next = 4;
|
|
131
|
+
chromeParameters = ['--headless', '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage', '--no-default-browser-check', '--no-first-run', '--disable-default-apps'];
|
|
132
|
+
_context5.next = 3;
|
|
141
133
|
return chromeLauncher.launch({
|
|
142
134
|
chromeFlags: chromeParameters
|
|
143
135
|
});
|
|
144
|
-
case
|
|
136
|
+
case 3:
|
|
145
137
|
chrome = _context5.sent;
|
|
146
138
|
options = {
|
|
147
139
|
logLevel: 'silent',
|
|
148
140
|
output: 'html',
|
|
149
141
|
port: chrome.port
|
|
150
142
|
};
|
|
151
|
-
_context5.next =
|
|
143
|
+
_context5.next = 7;
|
|
152
144
|
return (0, _index["default"])(url, options);
|
|
153
|
-
case
|
|
145
|
+
case 7:
|
|
154
146
|
runnerResult = _context5.sent;
|
|
155
147
|
reportHtml = runnerResult.report;
|
|
156
148
|
reportJson = runnerResult.lhr;
|
|
157
|
-
_context5.next =
|
|
149
|
+
_context5.next = 12;
|
|
158
150
|
return chrome.kill();
|
|
159
|
-
case
|
|
151
|
+
case 12:
|
|
160
152
|
return _context5.abrupt("return", processRawLighthouseResult(reportJson, reportHtml, url, shouldSaveReport));
|
|
161
|
-
case
|
|
153
|
+
case 13:
|
|
162
154
|
case "end":
|
|
163
155
|
return _context5.stop();
|
|
164
156
|
}
|
|
@@ -171,7 +163,7 @@ var calculateLighthouseMetrics = /*#__PURE__*/function () {
|
|
|
171
163
|
exports.calculateLighthouseMetrics = calculateLighthouseMetrics;
|
|
172
164
|
var processParameters = /*#__PURE__*/function () {
|
|
173
165
|
var _ref8 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(args, func) {
|
|
174
|
-
var outputPath,
|
|
166
|
+
var outputPath, results, metrics, reports, metricsResults;
|
|
175
167
|
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
176
168
|
while (1) switch (_context6.prev = _context6.next) {
|
|
177
169
|
case 0:
|
|
@@ -181,33 +173,32 @@ var processParameters = /*#__PURE__*/function () {
|
|
|
181
173
|
}, function (err) {
|
|
182
174
|
if (err) throw err;
|
|
183
175
|
});
|
|
184
|
-
|
|
185
|
-
_context6.next = 5;
|
|
176
|
+
_context6.next = 4;
|
|
186
177
|
return Promise.all(args.urls.map(function (url) {
|
|
187
|
-
return func(url, args.save_report
|
|
178
|
+
return func(url, args.save_report);
|
|
188
179
|
}));
|
|
189
|
-
case
|
|
180
|
+
case 4:
|
|
190
181
|
results = _context6.sent;
|
|
191
182
|
metrics = R.pluck('metrics', results);
|
|
192
183
|
reports = R.pluck('report', results);
|
|
193
184
|
if (!args.single_badge) {
|
|
194
|
-
_context6.next =
|
|
185
|
+
_context6.next = 13;
|
|
195
186
|
break;
|
|
196
187
|
}
|
|
197
|
-
_context6.next =
|
|
188
|
+
_context6.next = 10;
|
|
198
189
|
return (0, _calculations.getSquashedScore)(metrics);
|
|
199
|
-
case
|
|
190
|
+
case 10:
|
|
200
191
|
_context6.t0 = _context6.sent;
|
|
201
|
-
_context6.next = 17;
|
|
202
|
-
break;
|
|
203
|
-
case 14:
|
|
204
192
|
_context6.next = 16;
|
|
193
|
+
break;
|
|
194
|
+
case 13:
|
|
195
|
+
_context6.next = 15;
|
|
205
196
|
return (0, _calculations.getAverageScore)(metrics);
|
|
206
|
-
case
|
|
197
|
+
case 15:
|
|
207
198
|
_context6.t0 = _context6.sent;
|
|
208
|
-
case
|
|
199
|
+
case 16:
|
|
209
200
|
metricsResults = _context6.t0;
|
|
210
|
-
_context6.next =
|
|
201
|
+
_context6.next = 19;
|
|
211
202
|
return generateArtifacts({
|
|
212
203
|
reports: reports,
|
|
213
204
|
svg: {
|
|
@@ -216,7 +207,7 @@ var processParameters = /*#__PURE__*/function () {
|
|
|
216
207
|
},
|
|
217
208
|
outputPath: outputPath
|
|
218
209
|
});
|
|
219
|
-
case
|
|
210
|
+
case 19:
|
|
220
211
|
case "end":
|
|
221
212
|
return _context6.stop();
|
|
222
213
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lighthouse-badges",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "🚦Generate gh-badges (shields.io) based on Lighthouse performance.",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"lighthouse-badges": "dist/src/index.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"app:install": "cd dist && npm i -g .",
|
|
10
|
+
"app:install": "npm run build && cd dist && npm i -g .",
|
|
11
11
|
"app:reinstall": "npm-run-all app:uninstall app:install",
|
|
12
12
|
"app:uninstall": "npm uninstall -g @emazzotta/lighthouse-badges; npm uninstall -g .; npm uninstall -g lighthouse-badges",
|
|
13
13
|
"build": "npm run clean && babel src --out-dir dist/src && sed 's#\"dist/src/index.js\"#\"src/index.js\"#' package.json > ./dist/package.json && cp README.md dist && cp LICENSE.md dist && cp -r node_modules dist",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"url": "https://github.com/emazzotta/lighthouse-badges.git"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
+
"@babel/runtime": "^7.20.13",
|
|
46
47
|
"argparse": "2.0.1",
|
|
47
48
|
"badge-maker": "^3.3.1",
|
|
48
49
|
"chrome-launcher": "^0.15.1",
|
package/src/index.js
CHANGED
|
@@ -6,9 +6,6 @@ import parser from './argparser';
|
|
|
6
6
|
|
|
7
7
|
const handleUserInput = async (spinner) => {
|
|
8
8
|
try {
|
|
9
|
-
if (process.env.LIGHTHOUSE_BADGES_PARAMS) {
|
|
10
|
-
process.stdout.write(`LIGHTHOUSE_BADGES_PARAMS: ${process.env.LIGHTHOUSE_BADGES_PARAMS}\n`);
|
|
11
|
-
}
|
|
12
9
|
spinner.start();
|
|
13
10
|
await processParameters(await parser.parse_args(), calculateLighthouseMetrics);
|
|
14
11
|
spinner.stop();
|
package/src/lighthouse-badges.js
CHANGED
|
@@ -59,7 +59,7 @@ export const processRawLighthouseResult = async (data, html, url, shouldSaveRepo
|
|
|
59
59
|
return { metrics: lighthouseMetrics, report: { [url]: htmlReport } };
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
export const calculateLighthouseMetrics = async (url, shouldSaveReport
|
|
62
|
+
export const calculateLighthouseMetrics = async (url, shouldSaveReport) => {
|
|
63
63
|
const chromeParameters = [
|
|
64
64
|
'--headless',
|
|
65
65
|
'--no-sandbox',
|
|
@@ -68,10 +68,6 @@ export const calculateLighthouseMetrics = async (url, shouldSaveReport, addition
|
|
|
68
68
|
'--no-default-browser-check',
|
|
69
69
|
'--no-first-run',
|
|
70
70
|
'--disable-default-apps',
|
|
71
|
-
'--output=json',
|
|
72
|
-
'--output-path=stdout',
|
|
73
|
-
'--quiet',
|
|
74
|
-
additionalParams,
|
|
75
71
|
];
|
|
76
72
|
const chrome = await chromeLauncher.launch({ chromeFlags: chromeParameters });
|
|
77
73
|
const options = { logLevel: 'silent', output: 'html', port: chrome.port };
|
|
@@ -90,9 +86,8 @@ export const processParameters = async (args, func) => {
|
|
|
90
86
|
if (err) throw err;
|
|
91
87
|
});
|
|
92
88
|
|
|
93
|
-
const additionalParams = process.env.LIGHTHOUSE_BADGES_PARAMS || '';
|
|
94
89
|
const results = await Promise.all(args.urls.map(
|
|
95
|
-
(url) => func(url, args.save_report
|
|
90
|
+
(url) => func(url, args.save_report),
|
|
96
91
|
));
|
|
97
92
|
|
|
98
93
|
const metrics = R.pluck('metrics', results);
|