Skip to content

Commit d67f9f0

Browse files
dmarkiewiczsidharthachatterjee
authored andcommitted
feat(gatsby-plugin-checker): filter archived repositories (#14037)
1 parent 8418356 commit d67f9f0

File tree

5 files changed

+47
-76
lines changed

5 files changed

+47
-76
lines changed

scripts/gatsby-plugin-checker/.env

Whitespace-only changes.
+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
# gatsby-plugin-checker
22

33
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`.
4+
5+
To run this script you need to:
6+
7+
1. Create a `.env` file in this directory (You shouldn't commit this file)
8+
1. Add a variable called `GITHUB_API_TOKEN` and set it to your Personal Access token (Find instructions for generating this [here](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line))

scripts/gatsby-plugin-checker/index.js

+31
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const fs = require(`fs`)
44
const got = require(`got`)
55
const path = require(`path`)
6+
require(`dotenv`).config()
67

78
const keywords = [`gatsby-plugin`, `gatsby-source`, `gatsby-transformer`]
89
const pluginsFile = path.join(__dirname, `plugins.json`)
@@ -108,6 +109,35 @@ const updatePlugins = (updates, plugins) => {
108109
return updates
109110
}
110111

112+
const filterArchived = plugins => {
113+
if (!process.env.GITHUB_API_TOKEN) {
114+
throw `Please use instructions in README.md to setup GITHUB_API_TOKEN`
115+
}
116+
117+
const promises = plugins.map(plugin => {
118+
const [username, packageName] = plugin.links.repository.split(`/`).slice(-2)
119+
const url = `https://api.github.com/repos/${username}/${packageName}`
120+
return got(url, {
121+
headers: {
122+
Authorization: `token ${process.env.GITHUB_API_TOKEN}`,
123+
},
124+
})
125+
.then(response => JSON.parse(response.body))
126+
.then(repo => {
127+
return { [packageName]: repo.archived }
128+
})
129+
.catch(_ => {
130+
return { [packageName]: false }
131+
})
132+
})
133+
134+
return Promise.all(promises)
135+
.then(resultsArray =>
136+
resultsArray.reduce((obj, result) => Object.assign(obj, result))
137+
)
138+
.then(result => plugins.filter(plugin => !result[plugin.name]))
139+
}
140+
111141
const main = () => {
112142
loadPlugins()
113143
.then(plugins =>
@@ -118,6 +148,7 @@ const main = () => {
118148
.then(packages => removePackagesWithoutRepository(packages))
119149
.then(packages => removeBadNameFormats(packages))
120150
.then(packages => removePackagesWithoutReadme(packages))
151+
.then(packages => filterArchived(packages))
121152
.then(packages =>
122153
packages.map(p => {
123154
// TODO: notify / comment on github

scripts/gatsby-plugin-checker/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"author": "Osmond van Hemert <[email protected]>",
1111
"license": "MIT",
1212
"dependencies": {
13+
"dotenv": "^8.0.0",
1314
"got": "^9.0.0"
1415
}
1516
}
+10-76
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,59 @@
11
[
2-
{"name":"@alxandr/gatsby-plugin-feed","blacklist":false,"notified":false},
3-
{"name":"@alxandr/gatsby-plugin-google-analytics","blacklist":false,"notified":false},
4-
{"name":"@alxandr/gatsby-transformer-blog-post","blacklist":false,"notified":false},
5-
{"name":"@alxandr/gatsby-transformer-unified","blacklist":false,"notified":false},
6-
{"name":"@dylanvann/gatsby-cloudinary","blacklist":false,"notified":false},
7-
{"name":"@entr/gatsby-source-google-analytics-reporting-api","blacklist":false,"notified":false},
8-
{"name":"@jacobmischka/gatsby-plugin-copy-files","blacklist":false,"notified":false},
9-
{"name":"@jacobmischka/gatsby-plugin-react-svg","blacklist":false,"notified":false},
10-
{"name":"@jacobmischka/gatsby-plugin-styled-jsx","blacklist":false,"notified":false},
11-
{"name":"@oliverturner/gatsby-source-trello","blacklist":false,"notified":false},
12-
{"name":"@porch/gatsby-source-gitlab-files","blacklist":false,"notified":false},
13-
{"name":"@porch/gatsby-source-gitlab-projects","blacklist":false,"notified":false},
14-
{"name":"@porch/gatsby-source-newrelic-apps","blacklist":false,"notified":false},
15-
{"name":"@ptb/gatsby-1-config-css-modules","blacklist":false,"notified":false},
16-
{"name":"@ptb/gatsby-plugin-pug","blacklist":false,"notified":false},
17-
{"name":"@ptb/gatsby-plugin-react-helmet","blacklist":false,"notified":false},
18-
{"name":"@storyblok/gatsby-source-storyblok","blacklist":false,"notified":false},
19-
{"name":"@scion-scxml/sciblog","blacklist":false,"notified":false},
20-
{"name":"@spraoi/gatsby-plugin","blacklist":false,"notified":false},
21-
{"name":"@theplayerstribune/gatsby-source-wordpress-plus","blacklist":false,"notified":false},
22-
{"name":"@uptimeventures/gatsby-source-rss","blacklist":false,"notified":false},
23-
{"name":"@wyze/preact-testing-library","blacklist":false,"notified":false},
24-
{"name":"development-dashboards-docs","blacklist":false,"notified":false},
25-
{"name":"gatsby-1-config-css-modules","blacklist":true,"notified":false},
26-
{"name":"gatsby-1-config-extract-plugin","blacklist":true,"notified":false},
27-
{"name":"gatsby-directus","blacklist":false,"notified":false},
28-
{"name":"gatsby-matsuri","blacklist":false,"notified":false},
29-
{"name":"gatsby-plugin-adroll","blacklist":false,"notified":false},
30-
{"name":"gatsby-plugin-canner-schema","blacklist":false,"notified":false},
312
{"name":"gatsby-plugin-channel","blacklist":false,"notified":false},
32-
{"name":"gatsby-plugin-compression","blacklist":false,"notified":false},
33-
{"name":"gatsby-plugin-compression-v2","blacklist":false,"notified":false},
343
{"name":"gatsby-plugin-copy-files","blacklist":false,"notified":false},
354
{"name":"gatsby-plugin-core-js","blacklist":false,"notified":false},
36-
{"name":"gatsby-plugin-countly","blacklist":false,"notified":false},
37-
{"name":"gatsby-plugin-default-layout","blacklist":false,"notified":false},
385
{"name":"gatsby-plugin-drip","blacklist":false,"notified":false},
396
{"name":"gatsby-plugin-escalade-stock","blacklist":false,"notified":false},
40-
{"name":"gatsby-plugin-facebook","blacklist":false,"notified":false},
417
{"name":"gatsby-plugin-facebook-sdk","blacklist":false,"notified":false},
428
{"name":"gatsby-plugin-favicon-mperkh","blacklist":false,"notified":false},
439
{"name":"gatsby-plugin-favicons","blacklist":false,"notified":false},
4410
{"name":"gatsby-plugin-github-pages","blacklist":false,"notified":false},
4511
{"name":"gatsby-plugin-google-fonts","blacklist":false,"notified":false},
4612
{"name":"gatsby-plugin-graphql","blacklist":false,"notified":false},
13+
{"name":"gatsby-plugin-i18n-extension","blacklist":false,"notified":false},
4714
{"name":"gatsby-plugin-iamport","blacklist":false,"notified":false},
4815
{"name":"gatsby-plugin-landr","blacklist":false,"notified":false},
49-
{"name":"gatsby-plugin-linkedin","blacklist":false,"notified":false},
5016
{"name":"gatsby-plugin-module-local-ident-name","blacklist":false,"notified":false},
51-
{"name":"gatsby-plugin-mparticle","blacklist":false,"notified":false},
5217
{"name":"gatsby-plugin-mui","blacklist":false,"notified":false},
5318
{"name":"gatsby-plugin-netlify-lambda","blacklist":false,"notified":false},
5419
{"name":"gatsby-plugin-ngrok-tunneling","blacklist":false,"notified":false},
55-
{"name":"gatsby-plugin-page-tree","blacklist":false,"notified":false},
20+
{"name":"gatsby-plugin-polyfill-cdn","blacklist":false,"notified":false},
5621
{"name":"gatsby-plugin-product-markdown-pages","blacklist":false,"notified":false},
5722
{"name":"gatsby-plugin-production","blacklist":false,"notified":false},
5823
{"name":"gatsby-plugin-protoculture","blacklist":false,"notified":false},
5924
{"name":"gatsby-plugin-purify-css","blacklist":false,"notified":false},
6025
{"name":"gatsby-plugin-react-webfont-loader","blacklist":false,"notified":false},
61-
{"name":"gatsby-plugin-remote-images","blacklist":false,"notified":false},
62-
{"name":"gatsby-plugin-remove-serviceworker","blacklist":false,"notified":false},
63-
{"name":"gatsby-plugin-retabulate","blacklist":false,"notified":false},
6426
{"name":"gatsby-plugin-sass-bulk-import","blacklist":false,"notified":false},
6527
{"name":"gatsby-plugin-size-analyzer","blacklist":false,"notified":false},
6628
{"name":"gatsby-plugin-snowplow","blacklist":false,"notified":false},
6729
{"name":"gatsby-plugin-source-john-deere","blacklist":false,"notified":false},
68-
{"name":"gatsby-plugin-styled-jsx-webpack-loader","blacklist":false,"notified":false},
69-
{"name":"gatsby-plugin-typescript-css-modules","blacklist":false,"notified":false},
70-
{"name":"gatsby-plugin-typescript-scss-modules","blacklist":false,"notified":false},
71-
{"name":"gatsby-plugin-typescript-scss-modules-cjs","blacklist":false,"notified":false},
72-
{"name":"gatsby-plugin-well-known","blacklist":false,"notified":false},
7330
{"name":"gatsby-plugin-zygote","blacklist":false,"notified":false},
74-
{"name":"gatsby-remark-curlie","blacklist":false,"notified":false},
75-
{"name":"gatsby-remark-frontmatter-defaults","blacklist":false,"notified":false},
76-
{"name":"gatsby-remark-github","blacklist":false,"notified":false},
77-
{"name":"gatsby-remark-grid-tables","blacklist":false,"notified":false},
78-
{"name":"gatsby-remark-jsx","blacklist":false,"notified":false},
79-
{"name":"gatsby-remark-prettypaper","blacklist":false,"notified":false},
80-
{"name":"gatsby-remark-visualdocs","blacklist":false,"notified":false},
81-
{"name":"gatsby-source-aem","blacklist":false,"notified":false},
8231
{"name":"gatsby-source-airtable-linked","blacklist":false,"notified":false},
8332
{"name":"gatsby-source-anilist","blacklist":false,"notified":false},
84-
{"name":"gatsby-source-datocms-graphql-example","blacklist":false,"notified":false},
85-
{"name":"gatsby-source-docgen-requirements","blacklist":false,"notified":false},
86-
{"name":"gatsby-source-feliks","blacklist":false,"notified":false},
8733
{"name":"gatsby-source-gcloud-object","blacklist":false,"notified":false},
8834
{"name":"gatsby-source-gdrive-tree","blacklist":false,"notified":false},
89-
{"name":"gatsby-source-git","blacklist":false,"notified":false},
9035
{"name":"gatsby-source-github-api","blacklist":false,"notified":false},
91-
{"name":"gatsby-source-github-gql","blacklist":false,"notified":false},
92-
{"name":"gatsby-source-github-projects","blacklist":false,"notified":false},
93-
{"name":"gatsby-source-google-drive","blacklist":false,"notified":false},
36+
{"name":"gatsby-source-google-calendar","blacklist":false,"notified":false},
9437
{"name":"gatsby-source-google-sheet","blacklist":false,"notified":false},
38+
{"name":"gatsby-source-itchio","blacklist":false,"notified":false},
9539
{"name":"gatsby-source-jira","blacklist":false,"notified":false},
96-
{"name":"gatsby-source-kerckhoff","blacklist":false,"notified":false},
40+
{"name":"gatsby-source-jsonapi","blacklist":false,"notified":false},
41+
{"name":"gatsby-source-medium-posts","blacklist":false,"notified":false},
9742
{"name":"gatsby-source-mongo","blacklist":false,"notified":false},
9843
{"name":"gatsby-source-nba","blacklist":false,"notified":false},
9944
{"name":"gatsby-source-newsapi","blacklist":false,"notified":false},
100-
{"name":"gatsby-source-pexels","blacklist":false,"notified":false},
10145
{"name":"gatsby-source-product-markdown","blacklist":false,"notified":false},
10246
{"name":"gatsby-source-published-google-sheets","blacklist":false,"notified":false},
103-
{"name":"gatsby-source-remote","blacklist":false,"notified":false},
10447
{"name":"gatsby-source-sapcc","blacklist":false,"notified":false},
105-
{"name":"gatsby-source-slack","blacklist":false,"notified":false},
10648
{"name":"gatsby-source-soundcloud","blacklist":false,"notified":false},
10749
{"name":"gatsby-source-steam","blacklist":false,"notified":false},
108-
{"name":"gatsby-source-steem","blacklist":false,"notified":false},
10950
{"name":"gatsby-source-twitch","blacklist":false,"notified":false},
51+
{"name":"gatsby-source-twitter-users","blacklist":false,"notified":false},
11052
{"name":"gatsby-source-utopian","blacklist":false,"notified":false},
111-
{"name":"gatsby-source-woocommerce","blacklist":false,"notified":false},
11253
{"name":"gatsby-source-wordpress-bcgdv","blacklist":false,"notified":false},
113-
{"name":"gatsby-source-wordpress-plus","blacklist":false,"notified":false},
114-
{"name":"gatsby-teamtailor-users","blacklist":false,"notified":false},
115-
{"name":"gatsby-transformer-blog-post","blacklist":false,"notified":false},
54+
{"name":"gatsby-transformer-exif","blacklist":false,"notified":false},
55+
{"name":"gatsby-transformer-geojson","blacklist":false,"notified":false},
11656
{"name":"gatsby-transformer-ipynb","blacklist":false,"notified":false},
11757
{"name":"gatsby-transformer-nimbl","blacklist":false,"notified":false},
118-
{"name":"gatsby-transformer-whoa","blacklist":false,"notified":false},
119-
{"name":"happo-plugin-gatsby","blacklist":false,"notified":false},
120-
{"name":"js-gatsby-plugin-react-next","blacklist":false,"notified":false},
121-
{"name":"mericsson-gatsby-source-contentful","blacklist":false,"notified":false},
122-
{"name":"react-snipcart","blacklist":false,"notified":false},
123-
{"name":"smooth-doc","blacklist":false,"notified":false},
124-
{"name":"syncano-gatsby","blacklist":false,"notified":false}
58+
{"name":"gatsby-transformer-whoa","blacklist":false,"notified":false}
12559
]

0 commit comments

Comments
 (0)