Closed chillu closed 3 years ago
See commits for rationale.
Just for record keeping, here's the rough node script I've used to splice in the new data. It's probably a bit overkill but good way to refresh my memory on async/await :)
const fs = require('fs'); const fetch = require("node-fetch"); const TOKEN = '...'; const modules = JSON.parse(fs.readFileSync('./modules.json', 'utf8')); // https://github.com/silverstripe/github-issue-search-client/blob/master/src/repos.json#L5 const coreModules = [ "silverstripe/silverstripe-admin", "silverstripe/silverstripe-asset-admin", "silverstripe/silverstripe-assets", "silverstripe/silverstripe-campaign-admin", "silverstripe/silverstripe-cms", "silverstripe/silverstripe-config", "silverstripe/silverstripe-errorpage", "silverstripe/silverstripe-framework", "silverstripe/silverstripe-graphql", "silverstripe/silverstripe-installer", "silverstripe/recipe-cms", "silverstripe/recipe-core", "silverstripe/recipe-plugin", "silverstripe/silverstripe-reports", "silverstripe/silverstripe-siteconfig", "silverstripe/silverstripe-versioned", "silverstripe/silverstripe-versioned-admin", "silverstripe-themes/silverstripe-simple" ]; modules.reduce(async (carry, module) => { const url = 'https://api.github.com/repos/' + module.github; const response = await fetch(url, { headers: { 'Authorization': 'token ' + TOKEN } }); const id = await response.json(); return [ ...(await carry), id ]; }, Promise.resolve([])).then(ids => { const merged = modules.map(module => { // id match const idMatch = ids.find(id => id.full_name == module.github); module.githubId = idMatch ? idMatch.id : null; // core match const coreMatch = coreModules.find(coreModule => coreModule == module.github); module.isCore = !!coreMatch; return module; }); console.log(JSON.stringify(merged)); });
See commits for rationale.
Just for record keeping, here's the rough node script I've used to splice in the new data. It's probably a bit overkill but good way to refresh my memory on async/await :)