|
1 | 1 | #!/usr/bin/env node
|
2 | 2 | (async function () {
|
3 |
| - const { argv } = require("yargs").options({ |
4 |
| - pat: {type: "string", description: "GitHub API Token"}, |
5 |
| - repo: {type: "string", description: "The repo to update (format: user/repo"}, |
6 |
| - user: {type: "string", description: "Update all repos owned by the provided user (example: my-user)"}, |
7 |
| - org: {type: "string", description: "Update all repos in the provided org (example: my-org-name)"}, |
8 |
| - keepOld: {type: "boolean", default: false, description: "Keep the old branch rather than deleting it"}, |
9 |
| - dryRun: {type: "boolean", default: false, description: "Output log messages only. Do not make any changes"}, |
10 |
| - listReposOnly: {type: "boolean", default: false, description: "List repos that would be affected, then exit"}, |
11 |
| - skipForks: {type: "boolean", default: false, description: "Skips forked repositories"}, |
12 |
| - old: {type: "string", default: "master", description: "The name of the branch to rename"}, |
13 |
| - new: {type: "string", default: "main", description: "The new branch name"}, |
14 |
| - confirm: {type: "boolean", default: false, description: "Run without prompting for confirmation"}, |
15 |
| - }).example([ |
16 |
| - ["$0 --pat <token> --repo user/repo", "Rename master to main"], |
17 |
| - ["$0 --pat <token> --repo user/repo --old dev --new develop", "Rename dev to develop"], |
18 |
| - ["$0 --pat <token> --org my-org-name", "Rename all repos owned by an org"], |
19 |
| - ["$0 --pat <token> --user my-user", "Rename all repos owned by a user"], |
20 |
| - ]); |
| 3 | + const { argv } = require("yargs") |
| 4 | + .options({ |
| 5 | + pat: { type: "string", description: "GitHub API Token" }, |
| 6 | + repo: { |
| 7 | + type: "string", |
| 8 | + description: "The repo to update (format: user/repo)", |
| 9 | + }, |
| 10 | + user: { |
| 11 | + type: "string", |
| 12 | + description: |
| 13 | + "Update all repos owned by the provided user (example: my-user)", |
| 14 | + }, |
| 15 | + org: { |
| 16 | + type: "string", |
| 17 | + description: |
| 18 | + "Update all repos in the provided org (example: my-org-name)", |
| 19 | + }, |
| 20 | + "keep-old": { |
| 21 | + type: "boolean", |
| 22 | + default: false, |
| 23 | + description: "Keep the old branch rather than deleting it", |
| 24 | + }, |
| 25 | + "dry-run": { |
| 26 | + type: "boolean", |
| 27 | + default: false, |
| 28 | + description: "Output log messages only. Do not make any changes", |
| 29 | + }, |
| 30 | + "list-repos-only": { |
| 31 | + type: "boolean", |
| 32 | + default: false, |
| 33 | + description: "List repos that would be affected, then exit", |
| 34 | + }, |
| 35 | + "skip-forks": { |
| 36 | + type: "boolean", |
| 37 | + default: false, |
| 38 | + description: "Skips forked repositories", |
| 39 | + }, |
| 40 | + old: { |
| 41 | + type: "string", |
| 42 | + default: "master", |
| 43 | + description: "The name of the branch to rename", |
| 44 | + }, |
| 45 | + new: { |
| 46 | + type: "string", |
| 47 | + default: "main", |
| 48 | + description: "The new branch name", |
| 49 | + }, |
| 50 | + confirm: { |
| 51 | + type: "boolean", |
| 52 | + default: false, |
| 53 | + description: "Run without prompting for confirmation", |
| 54 | + }, |
| 55 | + }) |
| 56 | + .example([ |
| 57 | + ["$0 --pat <token> --repo user/repo", "Rename master to main"], |
| 58 | + [ |
| 59 | + "$0 --pat <token> --repo user/repo --old dev --new develop", |
| 60 | + "Rename dev to develop", |
| 61 | + ], |
| 62 | + [ |
| 63 | + "$0 --pat <token> --org my-org-name", |
| 64 | + "Rename all repos owned by an org", |
| 65 | + ], |
| 66 | + ["$0 --pat <token> --user my-user", "Rename all repos owned by a user"], |
| 67 | + ]); |
21 | 68 |
|
22 | 69 | const isDryRun = !!argv.dryRun;
|
23 | 70 |
|
|
0 commit comments