Skip to content

Commit

Permalink
colors everywhere!
Browse files Browse the repository at this point in the history
  • Loading branch information
bradgarropy committed Dec 21, 2019
1 parent 6bf8cdc commit 2de0610
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
17 changes: 6 additions & 11 deletions src/github.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
const chalk = require("chalk")
const {createOctokit, getOctokit} = require("./octokit")

const getRateLimit = async () => {
const octokit = getOctokit()
const response = await octokit.rateLimit.get()
const {limit, remaining} = response.data.resources.core

console.log(`${remaining}/${limit} remaining`)
}

const validToken = async token => {
const octokit = createOctokit(token)

Expand All @@ -35,7 +27,9 @@ const getLabels = async (owner, repo) => {
}

const deleteLabels = async (labels, owner, repo) => {
console.log(`\nDeleting labels from ${owner}/${repo}\n`)
console.log(
`\nDeleting labels from ${chalk.cyanBright(`${owner}/${repo}`)}\n`,
)

const octokit = getOctokit()

Expand All @@ -53,7 +47,9 @@ const deleteLabels = async (labels, owner, repo) => {
}

const createLabels = async (labels, owner, repo) => {
console.log(`\nCreating labels in ${owner}/${repo}\n`)
console.log(
`\nCreating labels in ${chalk.cyanBright(`${owner}/${repo}`)}\n`,
)

const octokit = getOctokit()

Expand All @@ -73,7 +69,6 @@ const createLabels = async (labels, owner, repo) => {
}

module.exports = {
getRateLimit,
validToken,
getLabels,
deleteLabels,
Expand Down
21 changes: 14 additions & 7 deletions src/handlers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const conf = require("conf")
const chalk = require("chalk")
const clone = require("./clone")
const {validToken} = require("./github")
const {createOctokit} = require("./octokit")
Expand All @@ -10,19 +11,19 @@ const loginHandler = async argv => {
const storedToken = config.get("token")

if (!force && storedToken) {
console.log("\nYou are already logged in!")
console.log("\nYou are already logged in!\n")
return
}

const valid = await validToken(token)

if (!valid) {
console.log("Login failed! Please try again.")
console.log(`\n${chalk.redBright("Login failed!")} Please try again.\n`)
return
}

config.set({username, token})
console.log("Login successful!")
console.log(chalk.greenBright("\nLogin successful!\n"))

return
}
Expand All @@ -37,10 +38,12 @@ const cloneHandler = async argv => {

if (!token) {
console.log(
"\nYou are not logged in! Please run the 'login' command.\n",
`\nYou are not logged in, please run the ${chalk.cyanBright(
"login",
)} command.\n`,
)

console.log("labman login <username> <token>\n")
console.log(chalk.cyanBright("labman login <username> <token>\n"))
return
}

Expand All @@ -49,8 +52,12 @@ const cloneHandler = async argv => {
try {
await clone(source, destination)
} catch (error) {
console.log("\nInvalid token! Please run the 'login' command again.\n")
console.log("labman login <username> <token>\n")
console.log(
`\n${chalk.redBright(
"Invalid token!",
)} Please run the ${chalk.cyanBright("login")} command again.\n`,
)
console.log(chalk.cyanBright("labman login <username> <token>\n"))
}
}

Expand Down

0 comments on commit 2de0610

Please sign in to comment.