From babc891fab6b142accf5df38a211fff1a910a82c Mon Sep 17 00:00:00 2001 From: nlf Date: Wed, 19 Apr 2023 10:51:28 -0700 Subject: [PATCH] chore: add script to rebuild npm-cli-repos.txt --- package.json | 2 +- scripts/npm-cli-repos.txt | 10 ++-------- scripts/resetdeps.js | 5 ++++- scripts/update-cli-repos.js | 28 ++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 scripts/update-cli-repos.js diff --git a/package.json b/package.json index 918392785a757..fbd9c3e893393 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/npm-cli-repos.txt b/scripts/npm-cli-repos.txt index bc26d82b7c192..118f1c2addc58 100644 --- a/scripts/npm-cli-repos.txt +++ b/scripts/npm-cli-repos.txt @@ -6,13 +6,10 @@ bin-links cacache cli cmd-shim -config create-oss disparity-colors -doctornpm documentation eslint-config -exec fs fs-minipass gauge @@ -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 @@ -50,7 +45,6 @@ npm-packlist npm-pick-manifest npm-profile npm-registry-fetch -npm-registry-mock npm-user-validate npmlog package-json @@ -65,7 +59,7 @@ read read-cmd-shim read-package-json read-package-json-fast -readdir-scoped-modules +release-please rfcs run-script ssri diff --git a/scripts/resetdeps.js b/scripts/resetdeps.js index 95899ff2a2c45..083c57e11a693 100644 --- a/scripts/resetdeps.js +++ b/scripts/resetdeps.js @@ -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/') @@ -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) diff --git a/scripts/update-cli-repos.js b/scripts/update-cli-repos.js new file mode 100644 index 0000000000000..69949a4e351ec --- /dev/null +++ b/scripts/update-cli-repos.js @@ -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)