├── .gitignore ├── package.json ├── README.md ├── LICENSE.md └── app.mjs /.gitignore: -------------------------------------------------------------------------------- 1 | npm-debug.log 2 | *.DS_Store 3 | *.npmignore 4 | node_modules 5 | config.js 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "alpha-beta-scanner", 3 | "version": "1.0.0", 4 | "description": "Scan your github for packages that are still marked as alpha or beta releases", 5 | "main": "app.mjs", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "bin": { 10 | "alpha-beta-scanner": "./app.mjs" 11 | }, 12 | "type": "module", 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/apostrophecms/alpha-beta-scanner.git" 16 | }, 17 | "author": "Apostrophe Technologies LLC", 18 | "license": "MIT", 19 | "bugs": { 20 | "url": "https://github.com/apostrophecms/alpha-beta-scanner/issues" 21 | }, 22 | "homepage": "https://github.com/apostrophecms/alpha-beta-scanner#readme", 23 | "dependencies": { 24 | "boring": "^1.1.1", 25 | "fetch": "^1.1.0", 26 | "node-fetch": "^3.3.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # alpha-beta-scanner 2 | 3 | Scans your github organization or personal account for projects whose current `package.json` file declares them to be of `alpha` or `beta` quality. Version numbers starting with `0.` are also reported. 4 | 5 | ## Why? 6 | 7 | We ship lots of open source packages at [ApostropheCMS](https://apostrophecms.com). Sometimes changes are needed before we declare it to be stable. Other times, a year will pass and nobody notices it's still considered "beta." This tool to the rescue. 8 | 9 | ## Install 10 | ```bash 11 | npm install -g alpha-beta-scanner 12 | ``` 13 | 14 | ## Use 15 | 16 | ```bash 17 | alpha-beta-scanner --user=myusername 18 | 19 | alpha-beta-scanner --org=myorgname 20 | 21 | # If you run out of API requests, or want to scan private repos, 22 | # use a github personal access token 23 | alpha-beta-scanner --org=myorgname --token=go-get-your-own 24 | ``` 25 | 26 | You can also use the `TOKEN` environment variable. 27 | 28 | Note: this tool wants your github.com username or organization name. It doesn't scan `npm` directly. 29 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023 Apostrophe Technologies, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /app.mjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import fetch from 'node-fetch'; 4 | import boring from 'boring'; 5 | 6 | const argv = boring(); 7 | const org = argv.org; 8 | const user = argv.user; 9 | 10 | if (!(org || user)) { 11 | console.error('You must specify --org or --user.'); 12 | process.exit(1); 13 | } 14 | 15 | const owner = org || user; 16 | 17 | const token = argv.token || process.env.TOKEN; 18 | 19 | const repos = org ? await getRepos('orgs', org) : await getRepos('users', argv.user); 20 | 21 | console.log('Scanning repos, this can take time...\n'); 22 | let irrelevant = 0; 23 | let stable = 0; 24 | let unstable = 0; 25 | for (const repo of repos) { 26 | const url = `https://api.github.com/repos/${owner}/${repo}/contents/package.json`; 27 | console.log(url); 28 | const headers = { 29 | 'User-Agent': 'alpha-beta-scanner' 30 | }; 31 | if (token) { 32 | headers.Authorization = `token ${token}`; 33 | } 34 | const response = await fetch(url, { headers }); 35 | if (response.status === 404) { 36 | // Not a relevant concept for all repos 37 | irrelevant++; 38 | continue; 39 | } 40 | if (response.status >= 400) { 41 | const error = await response.text(); 42 | console.error(error || respons.status); 43 | process.exit(1); 44 | } 45 | const content = await response.json(); 46 | const data = Buffer.from(content.content, 'base64').toString('utf8'); 47 | const json = JSON.parse(data); 48 | if ((typeof json.version) === 'string') { 49 | if (json.version.match(/alpha|beta|^0./)) { 50 | console.log(`${owner}/${repo}: ${json.version}`); 51 | unstable++; 52 | } else { 53 | stable++; 54 | } 55 | } 56 | } 57 | 58 | console.log(`\nStable packages: ${stable}`); 59 | console.log(`Unstable (alpha, beta, 0.x) packages: ${unstable}`); 60 | console.log(`Repos with no package.json: ${irrelevant}`); 61 | 62 | async function getRepos(type, owner) { 63 | console.log('Getting repo list, this can take time...'); 64 | let repos = []; 65 | let page = 1; 66 | while (true) { 67 | const url = `https://api.github.com/${type}/${owner}/repos?page=${page}`; 68 | console.log(url); 69 | const headers = { 70 | 'User-Agent': 'alpha-beta-scanner' 71 | }; 72 | if (token) { 73 | headers.Authorization = `token ${token}`; 74 | } 75 | const response = await fetch(url, { headers }); 76 | if (response.status === 404) { 77 | // They should handle it this way 78 | return repos; 79 | } else if (response.status >= 400) { 80 | const error = await response.text(); 81 | console.error(error || respons.status); 82 | process.exit(1); 83 | } 84 | const found = await response.json(); 85 | if (!found.length) { 86 | // But they actually handle it this way 87 | return repos; 88 | } 89 | repos = [...repos, ...(found.map(repo => repo.name))]; 90 | page++; 91 | } 92 | } 93 | 94 | --------------------------------------------------------------------------------