Skip to content

Adds a check for the 'installable-manifest' audit score #476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ const formatResults = ({ results, thresholds }) => {

const formattedReport = makeReplacements(results.report);

// Pull some additional details to pass to App
const { formFactor, locale } = results.lhr.configSettings;
const installable =
results.lhr.audits['installable-manifest'].score === 1 &&
results.lhr.audits['service-worker'].score === 1;
const details = { installable, formFactor, locale };

const report = minify(formattedReport, {
removeAttributeQuotes: true,
collapseWhitespace: true,
Expand All @@ -114,7 +121,7 @@ const formatResults = ({ results, thresholds }) => {
minifyJS: true,
});

return { summary, shortSummary, report, errors };
return { summary, shortSummary, details, report, errors };
};

const persistResults = async ({ report, path }) => {
Expand Down Expand Up @@ -161,7 +168,7 @@ const runAudit = async ({ path, url, thresholds, output_path, settings }) => {
if (error) {
return { error };
} else {
const { summary, shortSummary, report, errors } = formatResults({
const { summary, shortSummary, details, report, errors } = formatResults({
results,
thresholds,
});
Expand All @@ -173,6 +180,7 @@ const runAudit = async ({ path, url, thresholds, output_path, settings }) => {
return {
summary,
shortSummary,
details,
report,
errors,
};
Expand Down Expand Up @@ -226,8 +234,8 @@ const processResults = ({ data, errors }) => {
const reports = [];
return {
summary: data
.map(({ path, url, summary, shortSummary, report }) => {
const obj = { report };
.map(({ path, url, summary, shortSummary, details, report }) => {
const obj = { report, details };

if (summary) {
obj.summary = summary.reduce((acc, item) => {
Expand Down Expand Up @@ -271,13 +279,14 @@ module.exports = {
const allErrors = [];
const data = [];
for (const { path, url, thresholds, output_path } of audits) {
const { errors, summary, shortSummary, report } = await runAudit({
path,
url,
thresholds,
output_path,
settings,
});
const { errors, summary, shortSummary, details, report } =
await runAudit({
path,
url,
thresholds,
output_path,
settings,
});
if (summary) {
console.log({ results: summary });
}
Expand All @@ -299,6 +308,7 @@ module.exports = {
url,
summary,
shortSummary,
details,
report,
});
}
Expand Down