| 21 | }); |
| 22 | |
| 23 | async function scrapeThemeAvailableKeys() { |
| 24 | const data = await get(THEME_COLOR_REFERENCE_URL); |
| 25 | |
| 26 | const matches = data.match(new RegExp('<code>.+?</code>', 'g')); |
| 27 | |
| 28 | if (!matches) { |
| 29 | throw new Error( |
| 30 | "Couldn't find any matches with <code>...</code>, maybe docs have changed?" |
| 31 | ); |
| 32 | } |
| 33 | |
| 34 | return [...matches] |
| 35 | .map(key => key.replace('<code>', '').replace('</code>', '')) |
| 36 | .filter(key => !/ /.test(key)) // Remove if contains spaces |
| 37 | .filter(key => !/#.../.test(key)) // Remove if is a hex color |
| 38 | .filter(key => !/"/.test(key)) // Remove if contains quotes |
| 39 | .filter(key => key.length > 4) // Remove if it's very small |
| 40 | .filter(key => !NOT_THEME_KEYS.includes(key)) // Remove if its in the blacklist |
| 41 | .sort(); |
| 42 | } |
| 43 | |
| 44 | (async () => { |
| 45 | const availableKeys = await scrapeThemeAvailableKeys(); |