From 3ee48bd992074df9d35646ff7c0c1a4ca81128e7 Mon Sep 17 00:00:00 2001 From: Harrison Muskat Date: Wed, 8 Jul 2020 12:29:42 -0400 Subject: [PATCH 1/3] fix: make help and arguments actually useful --- bin/github-default-branch | 19 +++++++++- package-lock.json | 74 +++++++++++++++++++++++++++++++++------ package.json | 6 +++- 3 files changed, 86 insertions(+), 13 deletions(-) diff --git a/bin/github-default-branch b/bin/github-default-branch index 7caf016..4295508 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..be8a63a 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" } @@ -131,6 +140,21 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.13.tgz", "integrity": "sha512-rouEWBImiRaSJsVA+ITTFM6ZxibuAlTuNOCyxVbwreu6k6+ujs7DfnU9o+PShFhET78pMBl3eH+AGSI5eOTkPA==" }, + "@types/yargs": { + "version": "15.0.5", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", + "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", + "dev": true, + "requires": { + "@types/yargs-parser": "*" + } + }, + "@types/yargs-parser": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-15.0.0.tgz", + "integrity": "sha512-FA/BWv8t8ZWJ+gEOnLLd8ygxH/2UFbAvgEonyfN6yWGLKc7zVjbpl2Y4CTjid9h2RfgPP6SEt6uHwEOply00yw==", + "dev": true + }, "ansi-bgblack": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-bgblack/-/ansi-bgblack-0.1.1.tgz", @@ -523,6 +547,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 +573,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 +1346,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 +1691,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 +1719,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 +1729,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..f690884 100644 --- a/package.json +++ b/package.json @@ -20,9 +20,13 @@ "@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" + }, + "devDependencies": { + "@octokit/types": "^5.0.1", + "@types/yargs": "^15.0.5" } } From 7362a23250716f337a3c155f81c9421ef8028156 Mon Sep 17 00:00:00 2001 From: Harrison Muskat Date: Wed, 8 Jul 2020 12:50:54 -0400 Subject: [PATCH 2/3] fix: remove unused dev dependencies --- package-lock.json | 15 --------------- package.json | 4 ---- 2 files changed, 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index be8a63a..5645349 100644 --- a/package-lock.json +++ b/package-lock.json @@ -140,21 +140,6 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.13.tgz", "integrity": "sha512-rouEWBImiRaSJsVA+ITTFM6ZxibuAlTuNOCyxVbwreu6k6+ujs7DfnU9o+PShFhET78pMBl3eH+AGSI5eOTkPA==" }, - "@types/yargs": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", - "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", - "dev": true, - "requires": { - "@types/yargs-parser": "*" - } - }, - "@types/yargs-parser": { - "version": "15.0.0", - "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-15.0.0.tgz", - "integrity": "sha512-FA/BWv8t8ZWJ+gEOnLLd8ygxH/2UFbAvgEonyfN6yWGLKc7zVjbpl2Y4CTjid9h2RfgPP6SEt6uHwEOply00yw==", - "dev": true - }, "ansi-bgblack": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-bgblack/-/ansi-bgblack-0.1.1.tgz", diff --git a/package.json b/package.json index f690884..ee992d9 100644 --- a/package.json +++ b/package.json @@ -24,9 +24,5 @@ }, "bin": { "github-default-branch": "./bin/github-default-branch" - }, - "devDependencies": { - "@octokit/types": "^5.0.1", - "@types/yargs": "^15.0.5" } } From 0a260d231997b7a23e40e2d40f3694d73c49aec9 Mon Sep 17 00:00:00 2001 From: Harrison Muskat Date: Wed, 8 Jul 2020 12:53:29 -0400 Subject: [PATCH 3/3] fix: double quotes --- bin/github-default-branch | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/bin/github-default-branch b/bin/github-default-branch index 4295508..e5184a1 100755 --- a/bin/github-default-branch +++ b/bin/github-default-branch @@ -1,22 +1,22 @@ #!/usr/bin/env node (async function () { 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'}, + 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'], + ["$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;