{"id":15290435,"url":"https://github.com/npm/stafftools","last_synced_at":"2025-10-20T03:30:44.932Z","repository":{"id":37078696,"uuid":"487356584","full_name":"npm/stafftools","owner":"npm","description":"npm CLI Team's Internal Tools","archived":false,"fork":false,"pushed_at":"2024-10-02T17:20:03.000Z","size":277,"stargazers_count":10,"open_issues_count":6,"forks_count":4,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-10-29T19:37:40.380Z","etag":null,"topics":["npm-cli"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/npm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-30T18:48:40.000Z","updated_at":"2024-10-02T16:39:04.000Z","dependencies_parsed_at":"2023-12-06T20:40:39.449Z","dependency_job_id":"0949f325-cdb8-4d08-83fc-627c2668092a","html_url":"https://github.com/npm/stafftools","commit_stats":{"total_commits":136,"total_committers":6,"mean_commits":"22.666666666666668","dds":0.5147058823529411,"last_synced_commit":"4528d49e38952fa870efc26b04b0a497d92ee479"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fstafftools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fstafftools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fstafftools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fstafftools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npm","download_url":"https://codeload.github.com/npm/stafftools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237253998,"owners_count":19279965,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["npm-cli"],"created_at":"2024-09-30T16:08:10.423Z","updated_at":"2025-10-20T03:30:39.592Z","avatar_url":"https://github.com/npm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @npmcli/stafftools\n\nThe npm CLI Team's Internal Tools\n\n## Usage\n\n`npx -p @npmcli/stafftools \u003ccommand\u003e [...args]`\n\n## Commands\n\n### `gh`\n\nRun commands across all `npm-cli` repos on your local machine using working threads.\n\n`npx -p @npmcli/stafftools@latest gh \u003csubcommand\u003e [...args]`\n\n- **Note:** The [`gh`](https://cli.github.com/manual/) cli needs to be installed and authenticated.\n\n### Examples\n\n#### Merge and publish all pending minor and patch release pull requests\n\n```sh\nnpx -p @npmcli/stafftools@latest gh pending-release publish-release \\\n  --reject 'title: /\\d+\\.0\\.0/' \\ # Filter out PR titles matching \\d.0.0 (major releases)\n  --reject 'id: npm/cli' \\ # Filter out npm itself\n  --merge-strategy=rebase \\ # Merge all PRs with rebase\n  --otp=OP # Use the 1Password `op` cli to get one time passwords\n  # OR specify an otp with --otp=XXXXXX\n```\n\n### Queries\n\nAll the `.mjs` files in [the `queries` dir](./lib/gh/queries/) return some sort of data from the GitHub api.\n\nEach query is responsible for exporting:\n\n- `default`: a function that will return data of some shape\n- `args`: an object that will be passed to `yargs` to set the options\n- `type`: the type of data that this query returns. should be value or array of values from [`types.mjs`](./lib/gh/types.mjs)\n\nAny query can be run directly by name, or a custom query file can be passed in by path.\n\nWithout any other arguments, a query will print its data. A query `--template` option can be provided to change how the data is displayed. For example:\n\n```sh\n# Will return the result of the `repos` query\nnpx -p @npmcli/stafftools@latest gh repos\n\n# Add --help to see what subcommands are available\nnpx -p @npmcli/stafftools@latest gh repos --help\n# Commands:\n#   npx -p @npmcli/stafftools@latest gh repos clone          Clone repos into a directory\n#   npx -p @npmcli/stafftools@latest gh repos publish-repo   Publish repos from their default branch\n#   npx -p @npmcli/stafftools@latest gh repos pull           Checkout and pull default branch of repos\n#   npx -p @npmcli/stafftools@latest gh repos repo-settings  Set common settings on all repos\n```\n\n### Workers\n\nAll the `.mjs` files in [the `workers` dir](./lib/gh/workers/) operate on data returned from a query.\n\nEach worker is reponsible for exporting:\n\n- `default`: an array of commands to run on the data\n- `args`: an object that will be passed to `yargs` to set the options\n- `type`: the type of data that this worker operates. should be a value or array of values from [`types.mjs`](./lib/gh/types.mjs) or a string that is the name of a query or path to a query\n- `success`: a function that will display the success message for each item from the query. can be useful for displaying the url to a pull request, name of a repo, etc\n\nNote that for `type` if a worker specifies an exact query by name, then the worker can be run as it's own top level command. For example:\n\n```sh\n# This worker exports `type = 'template-oss'` so it can\n# be run as a single positional command\nnpx -p @npmcli/stafftools@latest gh template-oss-fix\n\n# The above is equivalent to\nnpx -p @npmcli/stafftools@latest gh template-oss template-oss-fix\n```\n\n### Options\n\n#### `cwd`\n\nThe base directory in which all commands will be run. Defaults to `$HOME/projects`.\n\n#### `limit`\n\nNumber of worker threads to spawn. Defaults to one less than the number of cores avaialble.\n\n#### `filter[]`\n\nAn array of [relaxed JSON](http://www.relaxedjson.org) strings to filter the returned data.\n\nFor example: `npx -p @npmcli/stafftools@latest gh merge pull-requests --filter 'title: SOME TITLE'.\n\n### Example commands\n\nThese commands will all do something on your local machine.\n\nRun `npx -p @npmcli/stafftools@latest gh --help` to see a full list of commands.\n\n#### `npx -p @npmcli/stafftools@latest gh repos clone`\n\nClone all repos returned from the query.\n\n#### `npx -p @npmcli/stafftools@latest gh pending-release merge`\n\nMerge all pending release pull requests.\n\n#### `npx -p @npmcli/stafftools@latest gh publish`\n\nMerge pending release PRs and publish the resulting release.\n\n#### `npx -p @npmcli/stafftools@latest gh template-oss-fix`\n\nFix failing template-oss pull requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Fstafftools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpm%2Fstafftools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Fstafftools/lists"}