Comparing version 0.0.3 to 0.1.0
@@ -1,2 +0,2 @@ | ||
import { green, red } from "colorette"; | ||
import { cyan, red } from "colorette"; | ||
import inquirer from "inquirer"; | ||
@@ -15,5 +15,5 @@ export const colorCodeBranches = (branches, mergedBranches) => { | ||
} | ||
return { name: green(branch), value: branch }; | ||
return { name: cyan(branch), value: branch }; | ||
}); | ||
}; | ||
//# sourceMappingURL=color_code_branches.js.map |
@@ -15,2 +15,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const { stderr, stdout } = yield exec("git branch"); | ||
const { stdout: currentBranch } = yield exec("git rev-parse --abbrev-ref HEAD"); | ||
if (stderr) { | ||
@@ -23,3 +24,2 @@ throw new GetAllBranchesException(stderr); | ||
.filter((branch) => branch); | ||
const currentBranch = branches.find((branch) => branch.includes("*")); | ||
const otherBranches = branches.filter((branch) => !branch.includes("*")); | ||
@@ -26,0 +26,0 @@ return { |
@@ -14,3 +14,4 @@ #!/usr/bin/env node | ||
import { getAllBranches, getMergedBranches, sortBranches, colorCodeBranches, deleteBranch, } from "./branch-operations/index.js"; | ||
import { logResults } from "./logging/index.js"; | ||
import { logResults, MESSAGES, log } from "./logging/index.js"; | ||
console.clear(); | ||
const run = () => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -20,15 +21,17 @@ const { currentBranch, otherBranches } = yield getAllBranches(); | ||
const sortedBranches = sortBranches(otherBranches, mergedBranches); | ||
const currentBranchMessage = `Current branch: ${color.green(currentBranch.replace("*", ""))}`; | ||
log(MESSAGES.currentBranchMessage(currentBranch)); | ||
if (otherBranches.length === 0) { | ||
console.log(currentBranchMessage); | ||
console.log(color.yellow("\n⚠ No branches other than the currently checked out branch found.")); | ||
log(MESSAGES.noBranchesFound); | ||
process.exit(0); | ||
} | ||
log(MESSAGES.colorCodeHelper); | ||
const answers = yield inquirer.prompt([ | ||
{ | ||
type: "checkbox", | ||
message: currentBranchMessage, | ||
message: `Which branches would you like to delete?`, | ||
name: "toDelete", | ||
choices: colorCodeBranches(sortedBranches, mergedBranches), | ||
default: mergedBranches, | ||
pageSize: 20, | ||
loop: false, | ||
}, | ||
@@ -38,6 +41,13 @@ { | ||
name: "confirm", | ||
when: (answers) => { | ||
return answers.toDelete.some((branch) => !mergedBranches.includes(branch)); | ||
message: ({ toDelete }) => { | ||
const colorCodedBranches = colorCodeBranches(toDelete, mergedBranches).map((branch) => { | ||
if (branch instanceof inquirer.Separator) | ||
return null; | ||
return color.reset(branch.name); | ||
}); | ||
const formattedBranches = colorCodedBranches | ||
.map(MESSAGES.formattedConfirmationBranches) | ||
.join(""); | ||
return `The following branches were selected to be deleted. Are you sure you want to proceed? ${formattedBranches}?`; | ||
}, | ||
message: "Are you sure you want to delete non-merged branches?", | ||
}, | ||
@@ -52,3 +62,3 @@ ]); | ||
else { | ||
console.log(color.yellow("\n⚠ No branches were deleted")); | ||
log(MESSAGES.noBranchesDeleted); | ||
} | ||
@@ -55,0 +65,0 @@ }); |
export { logResults } from "./log_results.js"; | ||
export { MESSAGES } from "./messages.js"; | ||
export declare const log: { | ||
(...data: any[]): void; | ||
(message?: any, ...optionalParams: any[]): void; | ||
}; |
export { logResults } from "./log_results.js"; | ||
export { MESSAGES } from "./messages.js"; | ||
export const log = console.log; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "git-away", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "", |
@@ -7,3 +7,3 @@ # Git Away | ||
### Run via npx | ||
### Run immediately | ||
@@ -15,1 +15,15 @@ The simplest way is via `npx` if you have NodeJS installed on your machine. Simply open a terminal and type: | ||
``` | ||
### Install | ||
You can also install globally | ||
``` | ||
npm install -g git-away | ||
``` | ||
and then use it without npx: | ||
``` | ||
git-away | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19732
35
237
28