lighthouse-badges 1.4.5 → 1.5.0
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/package.json +5 -6
- package/src/calculations.d.ts.map +1 -1
- package/src/calculations.js +21 -65
- package/src/calculations.js.map +1 -1
- package/src/index.js +2 -2
- package/src/index.js.map +1 -1
- package/src/lighthouse-badges.d.ts +3 -3
- package/src/lighthouse-badges.d.ts.map +1 -1
- package/src/lighthouse-badges.js +40 -137
- package/src/lighthouse-badges.js.map +1 -1
- package/src/main.d.ts.map +1 -1
- package/src/main.js +9 -21
- package/src/main.js.map +1 -1
- package/src/types.d.ts +6 -12
- package/src/types.d.ts.map +1 -1
- package/src/util.d.ts +0 -2
- package/src/util.d.ts.map +1 -1
- package/src/util.js +4 -17
- package/src/util.js.map +1 -1
- package/src/ramda.d.ts +0 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lighthouse-badges",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "🚦Generate gh-badges (shields.io) based on Lighthouse performance.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -52,14 +52,13 @@
|
|
|
52
52
|
"badge-maker": "^5.0.2",
|
|
53
53
|
"chrome-launcher": "1.2.1",
|
|
54
54
|
"clui": "^0.3.6",
|
|
55
|
-
"lighthouse": "^13.1.0"
|
|
56
|
-
"ramda": "^0.32.0"
|
|
55
|
+
"lighthouse": "^13.1.0"
|
|
57
56
|
},
|
|
58
57
|
"devDependencies": {
|
|
59
58
|
"@eslint/js": "^10.0.1",
|
|
60
|
-
"@types/node": "^25.
|
|
61
|
-
"@typescript-eslint/eslint-plugin": "^8.58.
|
|
62
|
-
"@typescript-eslint/parser": "^8.58.
|
|
59
|
+
"@types/node": "^25.6.0",
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^8.58.1",
|
|
61
|
+
"@typescript-eslint/parser": "^8.58.1",
|
|
63
62
|
"eslint": "^10.2.0",
|
|
64
63
|
"globals": "^17.4.0",
|
|
65
64
|
"husky": "^9.1.7",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculations.d.ts","sourceRoot":"","sources":["../../src/calculations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"calculations.d.ts","sourceRoot":"","sources":["../../src/calculations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAYpD,eAAO,MAAM,iBAAiB,GAAI,YAAY,MAAM,KAAG,MAC6B,CAAC;AAOrF,eAAO,MAAM,eAAe,GAAI,SAAS,iBAAiB,EAAE,KAAG,iBAO9D,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,SAAS,iBAAiB,EAAE,KAAG,iBAY/D,CAAC"}
|
package/src/calculations.js
CHANGED
|
@@ -1,73 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
AVERAGE: 'yellow',
|
|
14
|
-
BELOW_AVERAGE: 'orange',
|
|
15
|
-
POOR: 'red',
|
|
16
|
-
};
|
|
17
|
-
export const percentageToColor = (percentage) => {
|
|
18
|
-
if (percentage >= PERCENTAGE_THRESHOLDS.EXCELLENT)
|
|
19
|
-
return COLOR_MAP.EXCELLENT;
|
|
20
|
-
if (percentage >= PERCENTAGE_THRESHOLDS.GOOD)
|
|
21
|
-
return COLOR_MAP.GOOD;
|
|
22
|
-
if (percentage >= PERCENTAGE_THRESHOLDS.ABOVE_AVERAGE)
|
|
23
|
-
return COLOR_MAP.ABOVE_AVERAGE;
|
|
24
|
-
if (percentage >= PERCENTAGE_THRESHOLDS.AVERAGE)
|
|
25
|
-
return COLOR_MAP.AVERAGE;
|
|
26
|
-
if (percentage >= PERCENTAGE_THRESHOLDS.BELOW_AVERAGE)
|
|
27
|
-
return COLOR_MAP.BELOW_AVERAGE;
|
|
28
|
-
return COLOR_MAP.POOR;
|
|
29
|
-
};
|
|
30
|
-
const calculateCategoryAverage = (category, metrics) => {
|
|
31
|
-
const categoryScores = R.pluck(category, metrics);
|
|
32
|
-
const sum = R.sum(categoryScores);
|
|
33
|
-
const count = R.length(metrics);
|
|
34
|
-
return Math.round(sum / count);
|
|
1
|
+
const COLOR_THRESHOLDS = [
|
|
2
|
+
[95, 'brightgreen'],
|
|
3
|
+
[90, 'green'],
|
|
4
|
+
[75, 'yellowgreen'],
|
|
5
|
+
[60, 'yellow'],
|
|
6
|
+
[40, 'orange'],
|
|
7
|
+
];
|
|
8
|
+
const POOR_COLOR = 'red';
|
|
9
|
+
export const percentageToColor = (percentage) => COLOR_THRESHOLDS.find(([threshold]) => percentage >= threshold)?.[1] ?? POOR_COLOR;
|
|
10
|
+
const averageByCategory = (category, metrics) => {
|
|
11
|
+
const sum = metrics.reduce((total, metric) => total + (metric[category] ?? 0), 0);
|
|
12
|
+
return Math.round(sum / metrics.length);
|
|
35
13
|
};
|
|
36
14
|
export const getAverageScore = (metrics) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
const headMetric = R.head(metrics);
|
|
41
|
-
if (!headMetric) {
|
|
15
|
+
const [head] = metrics;
|
|
16
|
+
if (!head)
|
|
42
17
|
return {};
|
|
43
|
-
|
|
44
|
-
const categories = R.keys(headMetric);
|
|
45
|
-
const scoreObjects = categories.map((category) => ({
|
|
46
|
-
[category]: calculateCategoryAverage(category, metrics),
|
|
47
|
-
}));
|
|
48
|
-
return R.mergeAll(scoreObjects);
|
|
49
|
-
};
|
|
50
|
-
const calculateTotalScore = (metrics) => {
|
|
51
|
-
const sumOfAllScores = R.pipe(R.map((metric) => R.sum(R.values(metric))), R.sum)(metrics);
|
|
52
|
-
return sumOfAllScores;
|
|
53
|
-
};
|
|
54
|
-
const calculateTotalCategories = (headMetric) => {
|
|
55
|
-
return R.length(R.keys(headMetric));
|
|
18
|
+
return Object.fromEntries(Object.keys(head).map((category) => [category, averageByCategory(category, metrics)]));
|
|
56
19
|
};
|
|
57
20
|
export const getSquashedScore = (metrics) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
const headMetric = R.head(metrics);
|
|
62
|
-
if (!headMetric) {
|
|
21
|
+
const [head] = metrics;
|
|
22
|
+
if (!head)
|
|
63
23
|
return { lighthouse: 0 };
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
const averageScore = totalScore / (totalMetrics * totalCategories);
|
|
69
|
-
return {
|
|
70
|
-
lighthouse: Math.round(averageScore),
|
|
71
|
-
};
|
|
24
|
+
const totalScore = metrics.reduce((sum, metric) => sum + Object.values(metric).reduce((a, b) => a + b, 0), 0);
|
|
25
|
+
const totalCategories = Object.keys(head).length;
|
|
26
|
+
const averageScore = totalScore / (metrics.length * totalCategories);
|
|
27
|
+
return { lighthouse: Math.round(averageScore) };
|
|
72
28
|
};
|
|
73
29
|
//# sourceMappingURL=calculations.js.map
|
package/src/calculations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculations.js","sourceRoot":"","sources":["../../src/calculations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"calculations.js","sourceRoot":"","sources":["../../src/calculations.ts"],"names":[],"mappings":"AAEA,MAAM,gBAAgB,GAA6C;IACjE,CAAC,EAAE,EAAE,aAAa,CAAC;IACnB,CAAC,EAAE,EAAE,OAAO,CAAC;IACb,CAAC,EAAE,EAAE,aAAa,CAAC;IACnB,CAAC,EAAE,EAAE,QAAQ,CAAC;IACd,CAAC,EAAE,EAAE,QAAQ,CAAC;CACf,CAAC;AAEF,MAAM,UAAU,GAAG,KAAK,CAAC;AAEzB,MAAM,CAAC,MAAM,iB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AAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EACvE,CAAC,CACF,CAAC;IACF,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IACjD,MAAM,YAAY,GAAG,UAAU,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,eAAe,CAAC,CAAC;IAErE,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC;AAClD,CAAC,CAAC"}
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import handleUserInput from './main.js';
|
|
3
3
|
import CLI from 'clui';
|
|
4
|
-
const
|
|
5
|
-
handleUserInput(
|
|
4
|
+
const spinner = new CLI.Spinner('Running Lighthouse, please wait...', ['◜', '◠', '◝', '◞', '◡', '◟']);
|
|
5
|
+
await handleUserInput(spinner);
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,eAAe,MAAM,WAAW,CAAC;AACxC,OAAO,GAAG,MAAM,MAAM,CAAC;AAEvB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,eAAe,MAAM,WAAW,CAAC;AACxC,OAAO,GAAG,MAAM,MAAM,CAAC;AAEvB,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,oCAAoC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AACtG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { LighthouseMetrics, LighthouseReport, ProcessedLighthouseResult, LighthouseConfig, LighthouseLHR, ParsedArgs, BadgeStyle } from './types.js';
|
|
2
2
|
export declare const metricsToSvg: (lighthouseMetrics: LighthouseMetrics, badgeStyle: BadgeStyle, outputPath: string) => Promise<void>;
|
|
3
3
|
export declare const htmlReportsToFile: (htmlReports: LighthouseReport[], outputPath: string) => Promise<void>;
|
|
4
|
-
export declare const processRawLighthouseResult: (data: LighthouseLHR, html: string, url: string, shouldSaveReport: boolean) =>
|
|
4
|
+
export declare const processRawLighthouseResult: (data: LighthouseLHR, html: string, url: string, shouldSaveReport: boolean) => ProcessedLighthouseResult;
|
|
5
5
|
type CalculateLighthouseMetricsFn = (url: string, shouldSaveReport: boolean, lighthouseParameters?: LighthouseConfig) => Promise<ProcessedLighthouseResult>;
|
|
6
|
-
export declare const calculateLighthouseMetrics:
|
|
7
|
-
export declare const processParameters: (parserArgs: ParsedArgs,
|
|
6
|
+
export declare const calculateLighthouseMetrics: CalculateLighthouseMetricsFn;
|
|
7
|
+
export declare const processParameters: (parserArgs: ParsedArgs, calculateFn: CalculateLighthouseMetricsFn, lighthouseParameters?: LighthouseConfig) => Promise<void>;
|
|
8
8
|
export {};
|
|
9
9
|
//# sourceMappingURL=lighthouse-badges.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lighthouse-badges.d.ts","sourceRoot":"","sources":["../../src/lighthouse-badges.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lighthouse-badges.d.ts","sourceRoot":"","sources":["../../src/lighthouse-badges.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,UAAU,EACX,MAAM,YAAY,CAAC;AAkCpB,eAAO,MAAM,YAAY,GACvB,mBAAmB,iBAAiB,EACpC,YAAY,UAAU,EACtB,YAAY,MAAM,KACjB,OAAO,CAAC,IAAI,CAMd,CAAC;AAYF,eAAO,MAAM,iBAAiB,GAC5B,aAAa,gBAAgB,EAAE,EAC/B,YAAY,MAAM,KACjB,OAAO,CAAC,IAAI,CAOd,CAAC;AAUF,eAAO,MAAM,0BAA0B,GACrC,MAAM,aAAa,EACnB,MAAM,MAAM,EACZ,KAAK,MAAM,EACX,kBAAkB,OAAO,KACxB,yBAGD,CAAC;AAEH,KAAK,4BAA4B,GAAG,CAClC,GAAG,EAAE,MAAM,EACX,gBAAgB,EAAE,OAAO,EACzB,oBAAoB,CAAC,EAAE,gBAAgB,KACpC,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAExC,eAAO,MAAM,0BAA0B,EAAE,4BAkBxC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,YAAY,UAAU,EACtB,aAAa,4BAA4B,EACzC,uBAAsB,gBAAqB,KAC1C,OAAO,CAAC,IAAI,CAkBd,CAAC"}
|
package/src/lighthouse-badges.js
CHANGED
|
@@ -1,34 +1,9 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import fs from 'fs';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
3
|
import { makeBadge } from 'badge-maker';
|
|
4
|
-
import * as R from 'ramda';
|
|
5
4
|
import lighthouse from 'lighthouse/core/index.cjs';
|
|
6
|
-
import {
|
|
5
|
+
import { urlEscaper } from './util.js';
|
|
7
6
|
import { getAverageScore, getSquashedScore, percentageToColor } from './calculations.js';
|
|
8
|
-
const writeFileAsync = (filepath, content) => {
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
fs.writeFile(filepath, content, (error) => {
|
|
11
|
-
if (error) {
|
|
12
|
-
reject(error);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
resolve();
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
const mkdirAsync = (dirPath) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
fs.mkdir(dirPath, { recursive: true }, (error) => {
|
|
23
|
-
if (error) {
|
|
24
|
-
reject(error);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
resolve();
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
7
|
const CHROME_FLAGS = [
|
|
33
8
|
'--headless',
|
|
34
9
|
'--no-sandbox',
|
|
@@ -38,133 +13,61 @@ const CHROME_FLAGS = [
|
|
|
38
13
|
'--no-first-run',
|
|
39
14
|
'--disable-default-apps',
|
|
40
15
|
];
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
label: metricKey,
|
|
49
|
-
message: `${score}%`,
|
|
50
|
-
color,
|
|
51
|
-
style: badgeStyle,
|
|
52
|
-
});
|
|
53
|
-
};
|
|
16
|
+
const badgeFilePath = (outputPath, metricKey) => path.join(outputPath, `${metricKey.replace(/ /g, '_')}.svg`);
|
|
17
|
+
const buildBadgeSvg = (metricKey, score, badgeStyle) => makeBadge({
|
|
18
|
+
label: metricKey,
|
|
19
|
+
message: `${score}%`,
|
|
20
|
+
color: percentageToColor(score),
|
|
21
|
+
style: badgeStyle,
|
|
22
|
+
});
|
|
54
23
|
const saveBadge = async (outputPath, metricKey, score, badgeStyle) => {
|
|
55
|
-
const filepath =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
await writeFileAsync(filepath, svg);
|
|
59
|
-
statusMessage(`Saved svg to ${filepath}\n`, `Failed to save svg to ${outputPath}`, null);
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
statusMessage(`Saved svg to ${filepath}\n`, `Failed to save svg to ${outputPath}`, error);
|
|
63
|
-
}
|
|
24
|
+
const filepath = badgeFilePath(outputPath, metricKey);
|
|
25
|
+
await fs.writeFile(filepath, buildBadgeSvg(metricKey, score, badgeStyle));
|
|
26
|
+
process.stdout.write(`Saved svg to ${filepath}\n`);
|
|
64
27
|
};
|
|
65
28
|
export const metricsToSvg = async (lighthouseMetrics, badgeStyle, outputPath) => {
|
|
66
|
-
|
|
67
|
-
await Promise.all(savePromises);
|
|
68
|
-
};
|
|
69
|
-
const extractUrlFromReport = (report) => {
|
|
70
|
-
const urls = R.keys(report);
|
|
71
|
-
return R.head(urls) || null;
|
|
29
|
+
await Promise.all(Object.entries(lighthouseMetrics).map(([metricKey, score]) => saveBadge(outputPath, metricKey, score, badgeStyle)));
|
|
72
30
|
};
|
|
73
31
|
const saveHtmlReport = async (outputPath, url, htmlContent) => {
|
|
74
32
|
const filepath = path.join(outputPath, `${urlEscaper(url)}.html`);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
statusMessage(`Saved report to ${filepath}\n`, `Failed to save report to ${outputPath}`, null);
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
statusMessage(`Saved report to ${filepath}\n`, `Failed to save report to ${outputPath}`, error);
|
|
81
|
-
}
|
|
33
|
+
await fs.writeFile(filepath, htmlContent);
|
|
34
|
+
process.stdout.write(`Saved report to ${filepath}\n`);
|
|
82
35
|
};
|
|
83
36
|
export const htmlReportsToFile = async (htmlReports, outputPath) => {
|
|
84
|
-
const savePromises = htmlReports
|
|
85
|
-
.
|
|
86
|
-
|
|
87
|
-
if (!url) {
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
const reportContent = report[url];
|
|
91
|
-
if (typeof reportContent === 'string') {
|
|
92
|
-
return saveHtmlReport(outputPath, url, reportContent);
|
|
93
|
-
}
|
|
94
|
-
return null;
|
|
95
|
-
})
|
|
96
|
-
.filter((promise) => promise !== null);
|
|
37
|
+
const savePromises = htmlReports.flatMap((report) => Object.entries(report)
|
|
38
|
+
.filter((entry) => typeof entry[1] === 'string')
|
|
39
|
+
.map(([url, content]) => saveHtmlReport(outputPath, url, content)));
|
|
97
40
|
await Promise.all(savePromises);
|
|
98
41
|
};
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
[`lighthouse ${category.toLowerCase()}`]: categories[category].score * 100,
|
|
108
|
-
}));
|
|
109
|
-
return Object.assign({}, ...scores);
|
|
110
|
-
};
|
|
111
|
-
export const processRawLighthouseResult = async (data, html, url, shouldSaveReport) => {
|
|
112
|
-
const htmlReport = shouldSaveReport ? html : false;
|
|
113
|
-
const lighthouseMetrics = extractLighthouseMetrics(data.categories);
|
|
114
|
-
return {
|
|
115
|
-
metrics: lighthouseMetrics,
|
|
116
|
-
report: { [url]: htmlReport },
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
const launchChrome = async () => {
|
|
120
|
-
const chromeLauncher = await import('chrome-launcher');
|
|
121
|
-
return chromeLauncher.launch({ chromeFlags: [...CHROME_FLAGS] });
|
|
122
|
-
};
|
|
123
|
-
const runLighthouse = async (url, chromePort, lighthouseParameters) => {
|
|
124
|
-
const options = {
|
|
125
|
-
logLevel: 'silent',
|
|
126
|
-
output: 'html',
|
|
127
|
-
port: chromePort,
|
|
128
|
-
};
|
|
129
|
-
return lighthouse(url, options, lighthouseParameters);
|
|
130
|
-
};
|
|
42
|
+
const extractLighthouseMetrics = (categories) => Object.fromEntries(Object.entries(categories).map(([category, { score }]) => [
|
|
43
|
+
`lighthouse ${category.toLowerCase()}`,
|
|
44
|
+
score * 100,
|
|
45
|
+
]));
|
|
46
|
+
export const processRawLighthouseResult = (data, html, url, shouldSaveReport) => ({
|
|
47
|
+
metrics: extractLighthouseMetrics(data.categories),
|
|
48
|
+
report: { [url]: shouldSaveReport ? html : false },
|
|
49
|
+
});
|
|
131
50
|
export const calculateLighthouseMetrics = async (url, shouldSaveReport, lighthouseParameters = {}) => {
|
|
132
|
-
const
|
|
51
|
+
const { launch } = await import('chrome-launcher');
|
|
52
|
+
const chrome = await launch({ chromeFlags: CHROME_FLAGS });
|
|
133
53
|
try {
|
|
134
|
-
const
|
|
135
|
-
return processRawLighthouseResult(
|
|
54
|
+
const { lhr, report } = await lighthouse(url, { logLevel: 'silent', output: 'html', port: chrome.port }, lighthouseParameters);
|
|
55
|
+
return processRawLighthouseResult(lhr, report, url, shouldSaveReport);
|
|
136
56
|
}
|
|
137
57
|
finally {
|
|
138
58
|
await chrome.kill();
|
|
139
59
|
}
|
|
140
60
|
};
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
};
|
|
152
|
-
const calculateMetricsResults = async (metrics, useSingleBadge) => {
|
|
153
|
-
return useSingleBadge ? getSquashedScore(metrics) : getAverageScore(metrics);
|
|
154
|
-
};
|
|
155
|
-
export const processParameters = async (parserArgs, func, lighthouseParameters = {}) => {
|
|
156
|
-
const outputPath = parserArgs.output_path || process.cwd();
|
|
157
|
-
await ensureOutputDirectory(outputPath);
|
|
158
|
-
const results = await Promise.all([
|
|
159
|
-
processUrl(parserArgs.url, parserArgs.save_report, lighthouseParameters, func),
|
|
61
|
+
export const processParameters = async (parserArgs, calculateFn, lighthouseParameters = {}) => {
|
|
62
|
+
const outputPath = parserArgs.output_path ?? process.cwd();
|
|
63
|
+
await fs.mkdir(outputPath, { recursive: true });
|
|
64
|
+
const { metrics, report } = await calculateFn(parserArgs.url, parserArgs.save_report, lighthouseParameters);
|
|
65
|
+
const scoreResults = parserArgs.single_badge
|
|
66
|
+
? getSquashedScore([metrics])
|
|
67
|
+
: getAverageScore([metrics]);
|
|
68
|
+
await Promise.all([
|
|
69
|
+
htmlReportsToFile([report], outputPath),
|
|
70
|
+
metricsToSvg(scoreResults, parserArgs.badge_style, outputPath),
|
|
160
71
|
]);
|
|
161
|
-
const metrics = R.pluck('metrics', results);
|
|
162
|
-
const reports = R.pluck('report', results);
|
|
163
|
-
const metricsResults = await calculateMetricsResults(metrics, parserArgs.single_badge);
|
|
164
|
-
await generateArtifacts({
|
|
165
|
-
reports,
|
|
166
|
-
svg: { results: metricsResults, style: parserArgs.badge_style },
|
|
167
|
-
outputPath,
|
|
168
|
-
});
|
|
169
72
|
};
|
|
170
73
|
//# sourceMappingURL=lighthouse-badges.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lighthouse-badges.js","sourceRoot":"","sources":["../../src/lighthouse-badges.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"lighthouse-badges.js","sourceRoot":"","sources":["../../src/lighthouse-badges.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,UAAU,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAWzF,MAAM,YAAY,GAAG;IACnB,YAAY;IACZ,cAAc;IACd,eAAe;IACf,yBAAyB;IACzB,4BAA4B;IAC5B,gBAAgB;IAChB,wBAAwB;CACzB,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,UAAkB,EAAE,SAAiB,EAAU,EAAE,CACtE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;AAE/D,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,KAAa,EAAE,UAAsB,EAAU,EAAE,CACzF,SAAS,CAAC;IACR,KAAK,EAAE,SAAS;IAChB,OAAO,EAAE,GAAG,KAAK,GAAG;IACpB,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAC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main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,YAAY,CAAC;AAqB5D,UAAU,YAAY;IACpB,iBAAiB,CAAC,EAAE,OAAO,iBAAiB,CAAC;IAC7C,0BAA0B,CAAC,EAAE,OAAO,0BAA0B,CAAC;IAC/D,SAAS,CAAC,EAAE,OAAO,MAAM,CAAC,UAAU,CAAC;CACtC;AAED,QAAA,MAAM,eAAe,GAAU,SAAS,OAAO,EAAE,OAAM,YAAiB,KAAG,OAAO,CAAC,IAAI,CAmBtF,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
package/src/main.js
CHANGED
|
@@ -1,51 +1,39 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
2
|
import { calculateLighthouseMetrics, processParameters } from './lighthouse-badges.js';
|
|
3
3
|
import parser from './argparser.js';
|
|
4
|
-
const readFileAsync = (filePath) => {
|
|
5
|
-
return new Promise((resolve, reject) => {
|
|
6
|
-
fs.readFile(filePath, 'utf8', (error, data) => {
|
|
7
|
-
if (error) {
|
|
8
|
-
reject(error);
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
resolve(data);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
4
|
const DEFAULT_LIGHTHOUSE_CONFIG = {
|
|
17
5
|
extends: 'lighthouse:default',
|
|
18
6
|
};
|
|
19
7
|
const loadLighthouseConfig = async () => {
|
|
20
8
|
const configPath = process.env.LIGHTHOUSE_BADGES_CONFIGURATION_PATH;
|
|
21
|
-
if (!configPath)
|
|
9
|
+
if (!configPath)
|
|
22
10
|
return DEFAULT_LIGHTHOUSE_CONFIG;
|
|
23
|
-
}
|
|
24
11
|
process.stdout.write(` LIGHTHOUSE_BADGES_CONFIGURATION_PATH: ${configPath}\n`);
|
|
25
12
|
try {
|
|
26
|
-
const fileContent = await
|
|
13
|
+
const fileContent = await fs.readFile(configPath, 'utf8');
|
|
27
14
|
return JSON.parse(fileContent);
|
|
28
15
|
}
|
|
29
16
|
catch (error) {
|
|
30
|
-
const
|
|
31
|
-
throw new Error(`Failed to load Lighthouse configuration from ${configPath}: ${
|
|
17
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
18
|
+
throw new Error(`Failed to load Lighthouse configuration from ${configPath}: ${message}`, { cause: error });
|
|
32
19
|
}
|
|
33
20
|
};
|
|
34
21
|
const handleUserInput = async (spinner, deps = {}) => {
|
|
35
22
|
const { processParameters: processParametersFn = processParameters, calculateLighthouseMetrics: calculateLighthouseMetricsFn = calculateLighthouseMetrics, parseArgs = parser.parse_args, } = deps;
|
|
23
|
+
spinner.start();
|
|
36
24
|
try {
|
|
37
|
-
spinner.start();
|
|
38
25
|
const parsedArgs = await parseArgs();
|
|
39
26
|
const lighthouseParameters = await loadLighthouseConfig();
|
|
40
27
|
await processParametersFn(parsedArgs, calculateLighthouseMetricsFn, lighthouseParameters);
|
|
41
|
-
spinner.stop();
|
|
42
28
|
}
|
|
43
29
|
catch (err) {
|
|
44
|
-
spinner.stop();
|
|
45
30
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
46
31
|
process.stderr.write(`${error}\n`);
|
|
47
32
|
process.exit(1);
|
|
48
33
|
}
|
|
34
|
+
finally {
|
|
35
|
+
spinner.stop();
|
|
36
|
+
}
|
|
49
37
|
};
|
|
50
38
|
export default handleUserInput;
|
|
51
39
|
//# sourceMappingURL=main.js.map
|
package/src/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,MAAM,MAAM,gBAAgB,CAAC;AAGpC,MAAM,yBAAyB,GAAqB;IAClD,OAAO,EAAE,oBAAoB;CAC9B,CAAC;AAEF,MAAM,oBAAoB,GAAG,KAAK,IAA+B,EAAE;IACjE,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC;IACpE,IAAI,CAAC,UAAU;QAAE,OAAO,yBAAyB,CAAC;IAElD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0CAA0C,UAAU,IAAI,CAAC,CAAC;IAE/E,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAqB,CAAC;IACrD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,gDAAgD,UAAU,KAAK,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9G,CAAC;AACH,CAAC,CAAC;AAQF,MAAM,eAAe,GAAG,KAAK,EAAE,OAAgB,EAAE,OAAqB,EAAE,EAAiB,EAAE;IACzF,MAAM,EACJ,iBAAiB,EAAE,mBAAmB,GAAG,iBAAiB,EAC1D,0BAA0B,EAAE,4BAA4B,GAAG,0BAA0B,EACrF,SAAS,GAAG,MAAM,CAAC,UAAU,GAC9B,GAAG,IAAI,CAAC;IAET,OAAO,CAAC,KAAK,EAAE,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,SAAS,EAAE,CAAC;QACrC,MAAM,oBAAoB,GAAG,MAAM,oBAAoB,EAAE,CAAC;QAC1D,MAAM,mBAAmB,CAAC,UAAU,EAAE,4BAA4B,EAAE,oBAAoB,CAAC,CAAC;IAC5F,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAClE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
package/src/types.d.ts
CHANGED
|
@@ -6,12 +6,8 @@ export interface ParsedArgs {
|
|
|
6
6
|
save_report: boolean;
|
|
7
7
|
url: string;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
export interface LighthouseReport {
|
|
13
|
-
[url: string]: string | false;
|
|
14
|
-
}
|
|
9
|
+
export type LighthouseMetrics = Record<string, number>;
|
|
10
|
+
export type LighthouseReport = Record<string, string | false>;
|
|
15
11
|
export interface ProcessedLighthouseResult {
|
|
16
12
|
metrics: LighthouseMetrics;
|
|
17
13
|
report: LighthouseReport;
|
|
@@ -26,12 +22,10 @@ export interface LighthouseConfig {
|
|
|
26
22
|
};
|
|
27
23
|
[key: string]: unknown;
|
|
28
24
|
}
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
}
|
|
25
|
+
export type LighthouseCategories = Record<string, {
|
|
26
|
+
score: number;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}>;
|
|
35
29
|
export interface LighthouseLHR {
|
|
36
30
|
categories: LighthouseCategories;
|
|
37
31
|
[key: string]: unknown;
|
package/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,aAAa,GAAG,SAAS,GAAG,eAAe,GAAG,QAAQ,CAAC;AAEzF,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,UAAU,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,aAAa,GAAG,SAAS,GAAG,eAAe,GAAG,QAAQ,CAAC;AAEzF,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,UAAU,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEvD,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC;AAE9D,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE;QACT,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,CAAC;AAE7F,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,oBAAoB,CAAC;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,aAAa,CAAC;CACpB;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB"}
|
package/src/util.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
export declare const urlEscaper: (url: string) => string;
|
|
2
|
-
export declare const zip: <T>(rows: T[][]) => T[][];
|
|
3
|
-
export declare const statusMessage: (successMessage: string, errorMessage: string, error: Error | null | undefined) => void;
|
|
4
2
|
//# sourceMappingURL=util.d.ts.map
|
package/src/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,MAIV,CAAC"}
|
package/src/util.js
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
export const urlEscaper = (url) =>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
export const zip = (rows) => {
|
|
7
|
-
if (rows.length === 0 || rows[0].length === 0) {
|
|
8
|
-
return [];
|
|
9
|
-
}
|
|
10
|
-
return rows[0].map((_, columnIndex) => rows.map((row) => row[columnIndex]));
|
|
11
|
-
};
|
|
12
|
-
export const statusMessage = (successMessage, errorMessage, error) => {
|
|
13
|
-
if (error) {
|
|
14
|
-
throw new Error(errorMessage);
|
|
15
|
-
}
|
|
16
|
-
process.stdout.write(successMessage);
|
|
17
|
-
};
|
|
1
|
+
export const urlEscaper = (url) => url
|
|
2
|
+
.toLowerCase()
|
|
3
|
+
.replace(/(^\w+:|^)\/\//, '')
|
|
4
|
+
.replace(/[^a-z0-9]/g, '_');
|
|
18
5
|
//# sourceMappingURL=util.js.map
|
package/src/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAU,EAAE
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAU,EAAE,CAChD,GAAG;KACA,WAAW,EAAE;KACb,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;KAC5B,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC"}
|
package/src/ramda.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
declare module 'ramda' {
|
|
2
|
-
export function head<T>(list: T[]): T | undefined;
|
|
3
|
-
export function keys<T extends Record<string, unknown>>(obj: T): string[];
|
|
4
|
-
export function map<T, U>(fn: (item: T) => U, list: T[]): U[];
|
|
5
|
-
export function map<T, U>(fn: (item: T) => U): (list: T[]) => U[];
|
|
6
|
-
export function pluck<K extends string, T extends Record<K, unknown>>(key: K, list: T[]): T[K][];
|
|
7
|
-
export function pluck<K extends string>(key: K): <T extends Record<K, unknown>>(list: T[]) => T[K][];
|
|
8
|
-
export function sum(list: number[]): number;
|
|
9
|
-
export function length<T>(list: T[]): number;
|
|
10
|
-
export function mergeAll<T extends Record<string, unknown>>(list: T[]): T;
|
|
11
|
-
export function values<T extends Record<string, unknown>>(obj: T): T[keyof T][];
|
|
12
|
-
export function pipe<T1, T2, T3, T4, T5>(
|
|
13
|
-
fn1: (x: T1) => T2,
|
|
14
|
-
fn2: (x: T2) => T3,
|
|
15
|
-
fn3: (x: T3) => T4,
|
|
16
|
-
fn4: (x: T4) => T5
|
|
17
|
-
): (x: T1) => T5;
|
|
18
|
-
export function pipe<T1, T2, T3, T4>(
|
|
19
|
-
fn1: (x: T1) => T2,
|
|
20
|
-
fn2: (x: T2) => T3,
|
|
21
|
-
fn3: (x: T3) => T4
|
|
22
|
-
): (x: T1) => T4;
|
|
23
|
-
export function pipe<T1, T2, T3>(
|
|
24
|
-
fn1: (x: T1) => T2,
|
|
25
|
-
fn2: (x: T2) => T3
|
|
26
|
-
): (x: T1) => T3;
|
|
27
|
-
export function pipe<T1, T2>(
|
|
28
|
-
fn1: (x: T1) => T2
|
|
29
|
-
): (x: T1) => T2;
|
|
30
|
-
export function curry<T extends (...args: unknown[]) => unknown>(fn: T): T;
|
|
31
|
-
}
|
|
32
|
-
|