Skip to content

Instantly share code, notes, and snippets.

@digitalbase
Created March 4, 2021 11:11
Show Gist options
  • Save digitalbase/118ef9fbd941cb3d554331a358e6e39b to your computer and use it in GitHub Desktop.
Save digitalbase/118ef9fbd941cb3d554331a358e6e39b to your computer and use it in GitHub Desktop.
const lighthouse = require('lighthouse');
const chromeLauncher = require('chrome-launcher');
const AirtablePlus = require('airtable-plus');
const airtable = new AirtablePlus({
baseID: 'app6ttxB70e3TjmCL',
apiKey: '[API_KEY]',
tableName: 'Themes',
});
let lighthouseAccesibilityScore = {
extends: 'lighthouse:default',
settings: {
onlyCategories: ['performance', 'seo']
},
};
(async () => {
const chrome = await chromeLauncher.launch({chromeFlags: ['--headless']});
lighthouseAccesibilityScore.port = chrome.port;
try {
const themes = await airtable.read({ view: 'Newsroom', filterByFormula: `({Lighthouse Accesibility Score} = '')`});
for (let theme of themes) {
console.log(`Running report for ${theme.fields.Url}`);
try {
const runnerResultDesktop = await lighthouse(theme.fields.Url, lighthouseAccesibilityScore);
const data = {
'Lighthouse Accesibility Score' : runnerResultDesktop.lhr.categories.accessibility.score,
'Lighthouse SEO Score' : runnerResultDesktop.lhr.categories.seo.score,
}
await airtable.update(theme.id, data);
} catch (Error) {
console.log(Error);
}
}
} catch (Error) {
console.log(Error);
}
await chrome.kill();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment