Skip to content

Commit

Permalink
chore: add script to rebuild npm-cli-repos.txt (#6383)
Browse files Browse the repository at this point in the history
  • Loading branch information
nlf authored Apr 19, 2023
1 parent f7762e5 commit adddd7a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
"tap": "^16.3.4"
},
"scripts": {
"dependencies": "node scripts/bundle-and-gitignore-deps.js && node scripts/dependency-graph.js",
"dependencies": "node scripts/bundle-and-gitignore-deps.js && node scripts/update-cli-repos.js && node scripts/dependency-graph.js",
"dumpconf": "env | grep npm | sort | uniq",
"licenses": "licensee --production --errors-only",
"test": "tap",
Expand Down
10 changes: 2 additions & 8 deletions scripts/npm-cli-repos.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ bin-links
cacache
cli
cmd-shim
config
create-oss
disparity-colors
doctornpm
documentation
eslint-config
exec
fs
fs-minipass
gauge
Expand All @@ -29,13 +26,11 @@ map-workspaces
metavuln-calculator
minify-registry-metadata
minipass-fetch
move-file
mute-stream
name-from-folder
nock-registry
node
node-gyp
node-semver
node-tar
node-which
nopt
normalize-package-data
Expand All @@ -50,7 +45,6 @@ npm-packlist
npm-pick-manifest
npm-profile
npm-registry-fetch
npm-registry-mock
npm-user-validate
npmlog
package-json
Expand All @@ -65,7 +59,7 @@ read
read-cmd-shim
read-package-json
read-package-json-fast
readdir-scoped-modules
release-please
rfcs
run-script
ssri
Expand Down
5 changes: 4 additions & 1 deletion scripts/resetdeps.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

const { join } = require('path')
const { CWD, run, pkg, fs, git, npm } = require('./util.js')
const ciInfo = require('ci-info')

const checkout = () => git('checkout', 'node_modules/')

Expand All @@ -13,7 +14,9 @@ const main = async ({ packageLock }) => {
await checkout()
await npm('i', '--ignore-scripts', '--no-audit', '--no-fund', packageLock && '--package-lock')
await npm('rebuild', '--ignore-scripts')
await npm('run', 'dependencies', '--ignore-scripts')
if (!ciInfo.isCI) {
await npm('run', 'dependencies', '--ignore-scripts')
}
}

run(main).catch(checkout)
28 changes: 28 additions & 0 deletions scripts/update-cli-repos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { join } = require('path')
const { fs, gh, run } = require('./util.js')

const query = `
query {
search (query: "org:npm topic:npm-cli fork:true archived:false", type: REPOSITORY, first: 100) {
nodes {
... on Repository {
name
}
}
}
}
`

const main = async () => {
const result = await gh('api', 'graphql', '-f', `query=${query}`, { stdio: 'pipe' })
if (result.code !== 0) {
throw new Error(result.stderr)
}

const repoList = JSON.parse(result.stdout)
const sortedRepoList = repoList.data.search.nodes.map((node) => node.name).sort()

return fs.writeFile(join(__dirname, 'npm-cli-repos.txt'), sortedRepoList.join('\n'))
}

run(main)

0 comments on commit adddd7a

Please sign in to comment.