Skip to content

Commit 37ddec7

Browse files
authored
feat: adds reporting around installable status and config settings (#476)
1 parent 909cdc7 commit 37ddec7

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

src/index.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ const formatResults = ({ results, thresholds }) => {
104104

105105
const formattedReport = makeReplacements(results.report);
106106

107+
// Pull some additional details to pass to App
108+
const { formFactor, locale } = results.lhr.configSettings;
109+
const installable =
110+
results.lhr.audits['installable-manifest'].score === 1 &&
111+
results.lhr.audits['service-worker'].score === 1;
112+
const details = { installable, formFactor, locale };
113+
107114
const report = minify(formattedReport, {
108115
removeAttributeQuotes: true,
109116
collapseWhitespace: true,
@@ -114,7 +121,7 @@ const formatResults = ({ results, thresholds }) => {
114121
minifyJS: true,
115122
});
116123

117-
return { summary, shortSummary, report, errors };
124+
return { summary, shortSummary, details, report, errors };
118125
};
119126

120127
const persistResults = async ({ report, path }) => {
@@ -161,7 +168,7 @@ const runAudit = async ({ path, url, thresholds, output_path, settings }) => {
161168
if (error) {
162169
return { error };
163170
} else {
164-
const { summary, shortSummary, report, errors } = formatResults({
171+
const { summary, shortSummary, details, report, errors } = formatResults({
165172
results,
166173
thresholds,
167174
});
@@ -173,6 +180,7 @@ const runAudit = async ({ path, url, thresholds, output_path, settings }) => {
173180
return {
174181
summary,
175182
shortSummary,
183+
details,
176184
report,
177185
errors,
178186
};
@@ -226,8 +234,8 @@ const processResults = ({ data, errors }) => {
226234
const reports = [];
227235
return {
228236
summary: data
229-
.map(({ path, url, summary, shortSummary, report }) => {
230-
const obj = { report };
237+
.map(({ path, url, summary, shortSummary, details, report }) => {
238+
const obj = { report, details };
231239

232240
if (summary) {
233241
obj.summary = summary.reduce((acc, item) => {
@@ -271,13 +279,14 @@ module.exports = {
271279
const allErrors = [];
272280
const data = [];
273281
for (const { path, url, thresholds, output_path } of audits) {
274-
const { errors, summary, shortSummary, report } = await runAudit({
275-
path,
276-
url,
277-
thresholds,
278-
output_path,
279-
settings,
280-
});
282+
const { errors, summary, shortSummary, details, report } =
283+
await runAudit({
284+
path,
285+
url,
286+
thresholds,
287+
output_path,
288+
settings,
289+
});
281290
if (summary) {
282291
console.log({ results: summary });
283292
}
@@ -299,6 +308,7 @@ module.exports = {
299308
url,
300309
summary,
301310
shortSummary,
311+
details,
302312
report,
303313
});
304314
}

0 commit comments

Comments
 (0)