-
-
Save digitalbase/118ef9fbd941cb3d554331a358e6e39b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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