Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
buildId,
url,
version: STATISTIC_VERSION,
name,
value,
},
context
);
})
);
})
);
return {
statistics: statistics.reduce((a, b) => a.concat(b)),
representativeRuns: computeRepresentativeRuns(runsByUrl),
};
}
slug,
hash,
state,
context,
description,
targetUrl,
githubToken,
githubAppToken,
});
}
} else {
/** @type {Array} */
const lhrs = loadSavedLHRs().map(lhr => JSON.parse(lhr));
/** @type {Array>} */
const lhrsByUrl = _.groupBy(lhrs, lhr => lhr.finalUrl).map(lhrs => lhrs.map(lhr => [lhr, lhr]));
const representativeLhrs = computeRepresentativeRuns(lhrsByUrl);
if (!representativeLhrs.length) return print('No LHRs for status check, skipping.\n');
for (const lhr of representativeLhrs) {
const rawUrl = lhr.finalUrl;
const urlLabel = getUrlLabelForGithub(rawUrl, options);
const state = 'success';
const context = `lhci/url${urlLabel}`;
const categoriesDescription = Object.values(lhr.categories)
.map(category => `${category.title}: ${Math.round(category.score * 100)}`)
.join(', ');
const description = `${categoriesDescription}`;
const targetUrl = targetUrlMap.get(rawUrl) || rawUrl;
await postStatusToGitHub({
slug,
async function runTemporaryPublicStorageTarget(options) {
/** @type {Array} */
const lhrs = loadSavedLHRs().map(lhr => JSON.parse(lhr));
/** @type {Array>} */
const lhrsByUrl = _.groupBy(lhrs, lhr => lhr.finalUrl).map(lhrs => lhrs.map(lhr => [lhr, lhr]));
const representativeLhrs = computeRepresentativeRuns(lhrsByUrl);
const targetUrlMap = new Map();
for (const lhr of representativeLhrs) {
const urlAudited = lhr.finalUrl;
print(`Uploading median LHR of ${urlAudited}...`);
try {
const response = await fetch(TEMPORARY_PUBLIC_STORAGE_URL, {
method: 'POST',
headers: {'content-type': 'text/html'},
body: getHTMLReportForLHR(lhr),
});
const {success, url} = await response.json();
if (success && url) {
print(`success!\nOpen the report at ${url}\n`);
async function runCommand(options) {
/** @type {Array} */
const lhrs = loadSavedLHRs().map(lhr => JSON.parse(lhr));
/** @type {Array>} */
const groupedByUrl = _.groupBy(lhrs, lhr => lhr.finalUrl).map(lhrs =>
lhrs.map(lhr => [lhr, lhr])
);
const representativeLhrs = computeRepresentativeRuns(groupedByUrl);
if (!representativeLhrs.length) {
process.stdout.write('No available reports to open. ');
}
for (const lhr of representativeLhrs) {
if (options.url && lhr.finalUrl !== options.url) continue;
process.stdout.write(`Opening median report for ${lhr.finalUrl}...\n`);
const tmpFile = tmp.fileSync({postfix: '.html'});
fs.writeFileSync(tmpFile.name, getHTMLReportForLHR(lhr));
await open(tmpFile.name);
}
process.stdout.write('Done!\n');
}