From b8558ffb77092eb30e1e03c8a3e96b9202890c26 Mon Sep 17 00:00:00 2001 From: Harrison Muskat Date: Wed, 8 Jul 2020 13:25:31 -0400 Subject: [PATCH] fix: add options to yargs along with examples (#27) --- bin/github-default-branch | 19 ++++++++++++- package-lock.json | 59 +++++++++++++++++++++++++++++++-------- package.json | 2 +- 3 files changed, 67 insertions(+), 13 deletions(-) diff --git a/bin/github-default-branch b/bin/github-default-branch index 7caf016..e5184a1 100755 --- a/bin/github-default-branch +++ b/bin/github-default-branch @@ -1,6 +1,23 @@ #!/usr/bin/env node (async function () { - const { argv } = require("yargs"); + const { argv } = require("yargs").options({ + pat: {type: "string", description: "GitHub API Token"}, + repo: {type: "string", description: "The repo to update (format: user/repo"}, + user: {type: "string", description: "Update all repos owned by the provided user (example: my-user)"}, + org: {type: "string", description: "Update all repos in the provided org (example: my-org-name)"}, + keepOld: {type: "boolean", default: false, description: "Keep the old branch rather than deleting it"}, + dryRun: {type: "boolean", default: false, description: "Output log messages only. Do not make any changes"}, + listReposOnly: {type: "boolean", default: false, description: "List repos that would be affected, then exit"}, + skipForks: {type: "boolean", default: false, description: "Skips forked repositories"}, + old: {type: "string", default: "master", description: "The name of the branch to rename"}, + new: {type: "string", default: "main", description: "The new branch name"}, + confirm: {type: "boolean", default: false, description: "Run without prompting for confirmation"}, + }).example([ + ["$0 --pat --repo user/repo", "Rename master to main"], + ["$0 --pat --repo user/repo --old dev --new develop", "Rename dev to develop"], + ["$0 --pat --org my-org-name", "Rename all repos owned by an org"], + ["$0 --pat --user my-user", "Rename all repos owned by a user"], + ]); const isDryRun = !!argv.dryRun; diff --git a/package-lock.json b/package-lock.json index 7518c5e..5645349 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,15 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@babel/runtime-corejs3": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.10.4.tgz", + "integrity": "sha512-BFlgP2SoLO9HJX9WBwN67gHWMBhDX/eDz64Jajd6mR/UAUzqrNMm99d4qHnVaKscAElZoFiPv+JpR/Siud5lXw==", + "requires": { + "core-js-pure": "^3.0.0", + "regenerator-runtime": "^0.13.4" + } + }, "@octokit/auth-token": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.4.2.tgz", @@ -114,9 +123,9 @@ } }, "@octokit/types": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-5.0.0.tgz", - "integrity": "sha512-3LVS+MbeqwSd5G4KS8123cZz+hWomsiGeMnQ/QJIBFDwL/YHX8kkr0FZXrgWEMO7Fgi2/VOrhbiFnk9sZ+s4qA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-5.0.1.tgz", + "integrity": "sha512-GorvORVwp244fGKEt3cgt/P+M0MGy4xEDbckw+K5ojEezxyMDgCaYPKVct+/eWQfZXOT7uq0xRpmrl/+hliabA==", "requires": { "@types/node": ">= 8" } @@ -523,6 +532,11 @@ "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=" }, + "core-js-pure": { + "version": "3.6.5", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.6.5.tgz", + "integrity": "sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA==" + }, "cross-spawn": { "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", @@ -544,9 +558,12 @@ } }, "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-3.2.0.tgz", + "integrity": "sha512-4TgkVUsmmu7oCSyGBm5FvfMoACuoh9EOidm7V5/J2X2djAwwt57qb3F2KMP2ITqODTCSwb+YRV+0Zqrv18k/hw==", + "requires": { + "xregexp": "^4.2.4" + } }, "define-properties": { "version": "1.1.3", @@ -1314,6 +1331,11 @@ } } }, + "regenerator-runtime": { + "version": "0.13.5", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz", + "integrity": "sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==" + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -1654,18 +1676,26 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, + "xregexp": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.3.0.tgz", + "integrity": "sha512-7jXDIFXh5yJ/orPn4SXjuVrWWoi4Cr8jfV1eHv9CixKSbU+jY4mxfrBwAuDvupPNKpMUY+FeIqsVw/JLT9+B8g==", + "requires": { + "@babel/runtime-corejs3": "^7.8.3" + } + }, "y18n": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==" }, "yargs": { - "version": "15.3.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.3.1.tgz", - "integrity": "sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA==", + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.0.tgz", + "integrity": "sha512-D3fRFnZwLWp8jVAAhPZBsmeIHY8tTsb8ItV9KaAaopmC6wde2u6Yw29JBIZHXw14kgkRnYmDgmQU4FVMDlIsWw==", "requires": { "cliui": "^6.0.0", - "decamelize": "^1.2.0", + "decamelize": "^3.2.0", "find-up": "^4.1.0", "get-caller-file": "^2.0.1", "require-directory": "^2.1.1", @@ -1674,7 +1704,7 @@ "string-width": "^4.2.0", "which-module": "^2.0.0", "y18n": "^4.0.0", - "yargs-parser": "^18.1.1" + "yargs-parser": "^18.1.2" } }, "yargs-parser": { @@ -1684,6 +1714,13 @@ "requires": { "camelcase": "^5.0.0", "decamelize": "^1.2.0" + }, + "dependencies": { + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" + } } } } diff --git a/package.json b/package.json index 9bf6d51..ee992d9 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@octokit/rest": "^18.0.0", "prompt-confirm": "^2.0.4", "string.prototype.replaceall": "^1.0.3", - "yargs": "^15.3.1" + "yargs": "^15.4.0" }, "bin": { "github-default-branch": "./bin/github-default-branch"