@harryisfish/gitt 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/clean.js +46 -24
- package/package.json +3 -2
package/dist/commands/clean.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cleanDeletedBranches = cleanDeletedBranches;
|
|
4
4
|
const simple_git_1 = require("simple-git");
|
|
5
|
+
const listr2_1 = require("listr2");
|
|
5
6
|
const errors_1 = require("../errors");
|
|
6
7
|
const errors_2 = require("../errors");
|
|
7
8
|
const git = (0, simple_git_1.simpleGit)();
|
|
@@ -11,30 +12,51 @@ const git = (0, simple_git_1.simpleGit)();
|
|
|
11
12
|
*/
|
|
12
13
|
async function cleanDeletedBranches() {
|
|
13
14
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
15
|
+
const tasks = new listr2_1.Listr([
|
|
16
|
+
{
|
|
17
|
+
title: 'Switch to main branch',
|
|
18
|
+
task: async () => {
|
|
19
|
+
await git.checkout('main');
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
title: 'Pull latest code',
|
|
24
|
+
task: async () => {
|
|
25
|
+
await git.pull();
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
title: 'Fetch and prune remote branches',
|
|
30
|
+
task: async (ctx) => {
|
|
31
|
+
await git.fetch(['--prune']);
|
|
32
|
+
const branchSummary = await git.branch(['-vv']);
|
|
33
|
+
const deletedBranches = branchSummary.all.filter(branch => {
|
|
34
|
+
const branchInfo = branchSummary.branches[branch];
|
|
35
|
+
return branchInfo.label && branchInfo.label.includes(': gone]');
|
|
36
|
+
});
|
|
37
|
+
ctx.deletedBranches = deletedBranches;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
title: 'Delete branches removed on remote',
|
|
42
|
+
enabled: (ctx) => Array.isArray(ctx.deletedBranches),
|
|
43
|
+
skip: (ctx) => {
|
|
44
|
+
if (!ctx.deletedBranches || ctx.deletedBranches.length === 0) {
|
|
45
|
+
return 'No branches need to be cleaned up';
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
},
|
|
49
|
+
task: (ctx) => {
|
|
50
|
+
return new listr2_1.Listr((ctx.deletedBranches || []).map(branch => ({
|
|
51
|
+
title: `Delete ${branch}`,
|
|
52
|
+
task: async () => {
|
|
53
|
+
await git.branch(['-D', branch]);
|
|
54
|
+
}
|
|
55
|
+
})), { concurrent: false });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]);
|
|
59
|
+
await tasks.run();
|
|
38
60
|
(0, errors_2.printSuccess)('Branch cleanup completed');
|
|
39
61
|
}
|
|
40
62
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harryisfish/gitt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A command-line tool to help you manage Git repositories and remote repositories, such as keeping in sync, pushing, pulling, etc.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@inquirer/prompts": "^3.3.0",
|
|
41
|
-
"simple-git": "^3.22.0"
|
|
41
|
+
"simple-git": "^3.22.0",
|
|
42
|
+
"listr2": "^8.0.0"
|
|
42
43
|
},
|
|
43
44
|
"engines": {
|
|
44
45
|
"node": ">=14.0.0"
|