forked from gatsbyjs/gatsby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plugin checker initial commit (gatsbyjs#7062)
Initial plugin checker for issue gatsbyjs#5211 It reports found plugins to "plugins.json". Blacklist property can be manually set to avoid processing again. Notifying => see issue
- Loading branch information
Showing
3 changed files
with
243 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
"use strict" | ||
|
||
const fs = require(`fs`) | ||
const got = require(`got`) | ||
const path = require(`path`) | ||
|
||
const keywords = [`gatsby-plugin`, `gatsby-source`, `gatsby-transformer`] | ||
const pluginsFile = path.join(__dirname, `plugins.json`) | ||
|
||
const loadPlugins = async () => { | ||
try { | ||
return require(pluginsFile) | ||
} catch (err) { | ||
throw err | ||
} | ||
} | ||
|
||
const savePlugins = plugins => | ||
new Promise((resolve, reject) => { | ||
let output = `[\n\t` | ||
output += plugins | ||
.sort((a, b) => { | ||
if (a.name < b.name) { | ||
return -1 | ||
} | ||
if (a.name > b.name) { | ||
return 1 | ||
} | ||
return 0 | ||
}) | ||
.map(p => JSON.stringify(p)) | ||
.join(`,\n\t`) | ||
output += `\n]\n` | ||
fs.writeFile(pluginsFile, output, err => { | ||
if (err) reject(err) | ||
resolve() | ||
}) | ||
}) | ||
|
||
const searchNPM = () => { | ||
const promises = keywords.map(keyword => { | ||
const url = `https://api.npms.io/v2/search?q=${keyword}+keywords:-gatsby-plugin+not:deprecated&size=250` | ||
return got(url).then(response => JSON.parse(response.body)) | ||
}) | ||
return Promise.all(promises) | ||
} | ||
|
||
const transformResults = results => { | ||
const merged = results.reduce((t, r) => t.concat(r.results), []) | ||
const deduped = merged.reduce((t, r) => { | ||
t[r.package.name] = t[r.package.name] || r.package | ||
return t | ||
}, {}) | ||
return Object.keys(deduped).map(d => deduped[d]) | ||
} | ||
|
||
const filterNotBlacklisted = (packages, plugins) => { | ||
const blacklisted = plugins.filter(p => p.blacklist).map(p => p.name) | ||
return packages.filter(pkg => blacklisted.indexOf(pkg.name) < 0) | ||
} | ||
|
||
const filterNotNotified = (packages, plugins) => { | ||
const notified = plugins.filter(p => p.notified).map(p => p.name) | ||
return packages.filter(pkg => notified.indexOf(pkg.name) < 0) | ||
} | ||
|
||
const updatePlugins = (updates, plugins) => { | ||
let res = plugins.map(p => Object.assign({}, p)) | ||
updates.forEach(u => { | ||
const idx = res.findIndex(r => r.name === u.name) | ||
if (idx >= 0) { | ||
res[idx] = Object.assign({}, res[idx], u) | ||
} else { | ||
res.push(u) | ||
} | ||
}) | ||
return updates | ||
} | ||
|
||
const main = () => { | ||
loadPlugins() | ||
.then(plugins => | ||
searchNPM() | ||
.then(transformResults) | ||
.then(packages => filterNotBlacklisted(packages, plugins)) | ||
.then(packages => filterNotNotified(packages, plugins)) | ||
.then(packages => | ||
packages.map(p => { | ||
// TODO: notify / comment on github | ||
console.info(`Notify package "${p.name}"`) | ||
// return update status | ||
return { name: p.name, blacklist: false, notified: false } | ||
}) | ||
) | ||
.then(updates => updatePlugins(updates, plugins)) | ||
.then(savePlugins) | ||
) | ||
.catch(err => { | ||
console.error(err) | ||
}) | ||
} | ||
|
||
main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "gatsby-plugin-checker", | ||
"version": "1.0.0", | ||
"description": "Checks for Gatsby plugins on NPM without the gatsby-plugin keyword.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"start": "node index" | ||
}, | ||
"author": "Osmond van Hemert <osmond@vanhemert.nu>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"got": "^9.0.0" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
[ | ||
{"name":"@alxandr/gatsby-plugin-feed","blacklist":false,"notified":false}, | ||
{"name":"@alxandr/gatsby-plugin-google-analytics","blacklist":false,"notified":false}, | ||
{"name":"@alxandr/gatsby-transformer-blog-post","blacklist":false,"notified":false}, | ||
{"name":"@alxandr/gatsby-transformer-unified","blacklist":false,"notified":false}, | ||
{"name":"@dylanvann/gatsby-cloudinary","blacklist":false,"notified":false}, | ||
{"name":"@entr/gatsby-source-google-analytics-reporting-api","blacklist":false,"notified":false}, | ||
{"name":"@jacobmischka/gatsby-plugin-copy-files","blacklist":false,"notified":false}, | ||
{"name":"@jacobmischka/gatsby-plugin-react-svg","blacklist":false,"notified":false}, | ||
{"name":"@jacobmischka/gatsby-plugin-styled-jsx","blacklist":false,"notified":false}, | ||
{"name":"@oliverturner/gatsby-source-trello","blacklist":false,"notified":false}, | ||
{"name":"@porch/gatsby-source-gitlab-files","blacklist":false,"notified":false}, | ||
{"name":"@porch/gatsby-source-gitlab-projects","blacklist":false,"notified":false}, | ||
{"name":"@porch/gatsby-source-newrelic-apps","blacklist":false,"notified":false}, | ||
{"name":"@ptb/gatsby-1-config-css-modules","blacklist":false,"notified":false}, | ||
{"name":"@ptb/gatsby-plugin-pug","blacklist":false,"notified":false}, | ||
{"name":"@ptb/gatsby-plugin-react-helmet","blacklist":false,"notified":false}, | ||
{"name":"@sb-konzept/gatsby-source-storyblok","blacklist":false,"notified":false}, | ||
{"name":"@scion-scxml/sciblog","blacklist":false,"notified":false}, | ||
{"name":"@spraoi/gatsby-plugin","blacklist":false,"notified":false}, | ||
{"name":"@theplayerstribune/gatsby-source-wordpress-plus","blacklist":false,"notified":false}, | ||
{"name":"@uptimeventures/gatsby-source-rss","blacklist":false,"notified":false}, | ||
{"name":"@wyze/preact-testing-library","blacklist":false,"notified":false}, | ||
{"name":"development-dashboards-docs","blacklist":false,"notified":false}, | ||
{"name":"gatsby-1-config-css-modules","blacklist":true,"notified":false}, | ||
{"name":"gatsby-1-config-extract-plugin","blacklist":true,"notified":false}, | ||
{"name":"gatsby-directus","blacklist":false,"notified":false}, | ||
{"name":"gatsby-matsuri","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-adroll","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-canner-schema","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-channel","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-compression","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-compression-v2","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-copy-files","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-core-js","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-countly","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-default-layout","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-drip","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-escalade-stock","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-facebook","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-facebook-sdk","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-favicon-mperkh","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-favicons","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-github-pages","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-google-fonts","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-graphql","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-iamport","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-landr","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-linkedin","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-module-local-ident-name","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-mparticle","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-mui","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-netlify-lambda","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-ngrok-tunneling","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-page-tree","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-product-markdown-pages","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-production","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-protoculture","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-purify-css","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-react-webfont-loader","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-remote-images","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-remove-serviceworker","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-retabulate","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-sass-bulk-import","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-size-analyzer","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-snowplow","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-source-john-deere","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-styled-jsx-webpack-loader","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-typescript-css-modules","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-typescript-scss-modules","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-typescript-scss-modules-cjs","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-well-known","blacklist":false,"notified":false}, | ||
{"name":"gatsby-plugin-zygote","blacklist":false,"notified":false}, | ||
{"name":"gatsby-remark-curlie","blacklist":false,"notified":false}, | ||
{"name":"gatsby-remark-frontmatter-defaults","blacklist":false,"notified":false}, | ||
{"name":"gatsby-remark-github","blacklist":false,"notified":false}, | ||
{"name":"gatsby-remark-grid-tables","blacklist":false,"notified":false}, | ||
{"name":"gatsby-remark-jsx","blacklist":false,"notified":false}, | ||
{"name":"gatsby-remark-prettypaper","blacklist":false,"notified":false}, | ||
{"name":"gatsby-remark-visualdocs","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-aem","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-airtable-linked","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-anilist","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-datocms-graphql-example","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-docgen-requirements","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-feliks","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-gcloud-object","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-gdrive-tree","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-git","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-github-api","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-github-gql","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-github-projects","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-google-drive","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-google-sheet","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-jira","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-kerckhoff","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-mongo","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-nba","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-newsapi","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-pexels","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-product-markdown","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-published-google-sheets","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-remote","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-sapcc","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-slack","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-soundcloud","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-steam","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-steem","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-twitch","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-utopian","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-woocommerce","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-wordpress-bcgdv","blacklist":false,"notified":false}, | ||
{"name":"gatsby-source-wordpress-plus","blacklist":false,"notified":false}, | ||
{"name":"gatsby-teamtailor-users","blacklist":false,"notified":false}, | ||
{"name":"gatsby-transformer-blog-post","blacklist":false,"notified":false}, | ||
{"name":"gatsby-transformer-ipynb","blacklist":false,"notified":false}, | ||
{"name":"gatsby-transformer-nimbl","blacklist":false,"notified":false}, | ||
{"name":"gatsby-transformer-whoa","blacklist":false,"notified":false}, | ||
{"name":"happo-plugin-gatsby","blacklist":false,"notified":false}, | ||
{"name":"js-gatsby-plugin-react-next","blacklist":false,"notified":false}, | ||
{"name":"mericsson-gatsby-source-contentful","blacklist":false,"notified":false}, | ||
{"name":"react-snipcart","blacklist":false,"notified":false}, | ||
{"name":"smooth-doc","blacklist":false,"notified":false}, | ||
{"name":"syncano-gatsby","blacklist":false,"notified":false} | ||
] |