Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby-plugin-checker): filter archived repositories #14037

Merged
merged 6 commits into from
May 17, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
2 changes: 2 additions & 0 deletions scripts/gatsby-plugin-checker/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# gatsby-plugin-checker

This script searches the npm API for plugins that start with either "gatsby-source", "gatsby-plugin", or "gatsby-transformer" but don't have the "gatsby-plugin" keyword in their `package.json` and thus are not included in Gatsby's keyword search. The script will then notify those repositories by creating an issue notifying them to add the keyword to their `package.json` (This functionality will be included in the next commit). Once a repo has been notified, its `notified` attribute will be changed to `true` in `plugins.json` and won't be notified. Similarly, if a repo is a false positive or doesn't want to be notified, it can be `blacklisted`.

To run this script you have to create a `.env` file in this directory and create there a variable `GITHUB_PERSONAL_ACCESS_TOKEN` and assign there your personal access token. You can find an instruction for generating it [here](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line). You shouldn't commit `.env` file.
dmarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
27 changes: 27 additions & 0 deletions scripts/gatsby-plugin-checker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const fs = require(`fs`)
const got = require(`got`)
const path = require(`path`)
require(`dotenv`).config()

const keywords = [`gatsby-plugin`, `gatsby-source`, `gatsby-transformer`]
const pluginsFile = path.join(__dirname, `plugins.json`)
Expand Down Expand Up @@ -108,6 +109,31 @@ const updatePlugins = (updates, plugins) => {
return updates
}

const filterArchived = plugins => {
const promises = plugins.map(plugin => {
const [username, packageName] = plugin.links.repository.split(`/`).slice(-2)
const url = `https://api.github.com/repos/${username}/${packageName}`
return got(url, {
headers: {
Authorization: `token ${process.env.GITHUB_PERSONAL_ACCESS_TOKEN}`,
dmarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
},
})
.then(response => JSON.parse(response.body))
.then(repo => {
return { [packageName]: repo.archived }
})
.catch(_ => {
return { [packageName]: false }
})
})

return Promise.all(promises)
.then(resultsArray =>
resultsArray.reduce((obj, result) => Object.assign(obj, result))
)
.then(result => plugins.filter(plugin => !result[plugin.name]))
}

const main = () => {
loadPlugins()
.then(plugins =>
Expand All @@ -118,6 +144,7 @@ const main = () => {
.then(packages => removePackagesWithoutRepository(packages))
.then(packages => removeBadNameFormats(packages))
.then(packages => removePackagesWithoutReadme(packages))
.then(packages => filterArchived(packages))
.then(packages =>
packages.map(p => {
// TODO: notify / comment on github
Expand Down
1 change: 1 addition & 0 deletions scripts/gatsby-plugin-checker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"author": "Osmond van Hemert <osmond@vanhemert.nu>",
"license": "MIT",
"dependencies": {
"dotenv": "^8.0.0",
"got": "^9.0.0"
}
}
86 changes: 10 additions & 76 deletions scripts/gatsby-plugin-checker/plugins.json
Original file line number Diff line number Diff line change
@@ -1,125 +1,59 @@
[
{"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":"@storyblok/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-i18n-extension","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-polyfill-cdn","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-calendar","blacklist":false,"notified":false},
{"name":"gatsby-source-google-sheet","blacklist":false,"notified":false},
{"name":"gatsby-source-itchio","blacklist":false,"notified":false},
{"name":"gatsby-source-jira","blacklist":false,"notified":false},
{"name":"gatsby-source-kerckhoff","blacklist":false,"notified":false},
{"name":"gatsby-source-jsonapi","blacklist":false,"notified":false},
{"name":"gatsby-source-medium-posts","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-twitter-users","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-exif","blacklist":false,"notified":false},
{"name":"gatsby-transformer-geojson","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}
{"name":"gatsby-transformer-whoa","blacklist":false,"notified":false}
]