From f3cfe612f66633ee0b1af1e10708ae31a91d4414 Mon Sep 17 00:00:00 2001 From: Brad Garropy Date: Thu, 2 Jan 2020 09:34:35 -0600 Subject: [PATCH 1/3] bump version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ff0a31c..a493451 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "labman", - "version": "0.5.0", + "version": "0.6.0", "description": "👨🏼‍🔬 github label manager cli", "keywords": [ "github", From dc5a859336e687a84aa62665f9b34458dc14a0f1 Mon Sep 17 00:00:00 2001 From: Brad Garropy Date: Thu, 2 Jan 2020 09:38:19 -0600 Subject: [PATCH 2/3] remove error case. --- src/github/labels.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/github/labels.js b/src/github/labels.js index 22c4821..66b8927 100644 --- a/src/github/labels.js +++ b/src/github/labels.js @@ -54,18 +54,7 @@ const createLabels = async (labels, repo) => { await octokit.issues.createLabel(parameters) console.log(` ${chalk.bold.greenBright("+")} ${name}`) } catch (error) { - const {status} = error - - switch (status) { - case 404: - errorRepoNotFound(repo) - process.exit() - break - - case 422: - errorLabelExists(name) - break - } + errorLabelExists(name) } }) } From 0c35e2ab8d8bb92dd3e28838ff13fe5e5bbdf69f Mon Sep 17 00:00:00 2001 From: Brad Garropy Date: Thu, 2 Jan 2020 09:56:49 -0600 Subject: [PATCH 3/3] assume owner. closes #28. --- src/cli/default.js | 6 +++++- src/utils.js | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/cli/default.js b/src/cli/default.js index 4b90d64..2a2055a 100644 --- a/src/cli/default.js +++ b/src/cli/default.js @@ -1,4 +1,5 @@ const conf = require("conf") +const {repoAutocomplete} = require("../utils") const { errorTokenNotFound, errorInvalidToken, @@ -28,7 +29,6 @@ const builder = { } const handler = async argv => { - const {source, destination, labels, clobber} = argv const token = config.get("token") // validate token @@ -45,6 +45,9 @@ const handler = async argv => { return } + const source = repoAutocomplete(argv.source) + const destination = repoAutocomplete(argv.destination) + const isValidSource = await validRepo(source) // validate source @@ -62,6 +65,7 @@ const handler = async argv => { } createOctokit(token) + const {labels, clobber} = argv // delete existing labels if (clobber) { diff --git a/src/utils.js b/src/utils.js index 71343ec..96eb113 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,3 +1,5 @@ +const conf = require("conf") + const repoPath = object => { const {owner, repo} = object const path = `${owner}/${repo}` @@ -16,4 +18,16 @@ const repoObject = string => { return object } -module.exports = {repoPath, repoObject} +const repoAutocomplete = repo => { + if (repo.includes("/")) { + return repo + } + + const config = new conf() + const owner = config.get("username") + + const autocompleted = `${owner}/${repo}` + return autocompleted +} + +module.exports = {repoPath, repoObject, repoAutocomplete}