Skip to content

Commit d15fd08

Browse files
authored
Publish NPM package (#4)
Change name from `git-removed-branches` to `git-branch-cleanup` and publish 1.0.0 to NPM
1 parent 853082c commit d15fd08

File tree

13 files changed

+443
-345
lines changed

13 files changed

+443
-345
lines changed

.github/workflows/lint-and-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
node-version: [20.x, 22.x]
18+
node-version: [18.x, 20.x, 22.x]
1919
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2020

2121
steps:
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish to NPM
2+
3+
on:
4+
push:
5+
tags:
6+
# Only publish on version tags like v1.2.3
7+
# git tag v1.2.3 && git push origin v1.2.3
8+
- 'v*.*.*'
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Use Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
registry-url: 'https://registry.npmjs.org/'
23+
24+
- name: Install pnpm
25+
run: npm install -g pnpm
26+
27+
- name: Install dependencies
28+
run: pnpm install
29+
30+
- name: Build
31+
run: pnpm run ci
32+
33+
- name: Publish to NPM
34+
run: npm publish --access public --no-git-checks
35+
env:
36+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.npmignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
test.js
2-
usage.gif
3-
usage.cast
1+
src/test.ts
42
.nvmrc

LICENSE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Copyright (c) 2025 Craig Patik
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8+
9+
---
10+
11+
Copyright for portions of project "git-branch-cleanup" are held by Maks Nemisj as part of project "git-removed-branches". All other copyright for project "git-branch-cleanup" are held by Craig Patik.

README.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
List or remove local tracked branches, which are deleted from the remote.
22

3-
It's a fork of [git-removed-branches](https://github.com/nemisj/git-removed-branches) with an interactive prompt
3+
It's a fork of [git-branch-cleanup](https://github.com/nemisj/git-branch-cleanup) with an interactive prompt
44

55
https://github.com/user-attachments/assets/e4502861-bd7d-47b7-aee7-e39154bc769c
66

@@ -9,16 +9,15 @@ Addresses questions, like:
99
- [Remove tracking branches no longer on remote](https://stackoverflow.com/questions/7726949/remove-tracking-branches-no-longer-on-remote)
1010
- [How to prune local tracking branches that do not exist on remote anymore?](https://stackoverflow.com/questions/13064613/how-to-prune-local-tracking-branches-that-do-not-exist-on-remote-anymore/30494276#30494276)
1111

12-
![](https://github.com/patik/git-removed-branches/blob/master/usage.gif)
13-
12+
![](https://github.com/patik/git-branch-cleanup/blob/master/usage.gif)
1413

1514
## Why?
1615

17-
Because I'm tired of doing every time `git fetch -p`, `git branch -r`, `git branch` and keep comparing which branches are gone from the GitHub, but still available locally and doing `git branch -D ${branch_name}` on one by one of them.
16+
Because I'm tired of doing every time `git fetch -p`, `git branch -r`, `git branch` and keep comparing which branches are gone from the GitHub, but still available locally and doing `git branch -D ${branch_name}` on each of them, one by one.
1817

1918
## What does it do?
2019

21-
This command will compare your local branches with remote and show you branches that are no longer available on remote but are still presented in your local repository. You can use it to view and delete all (remotely) removed branches in one go using `--prune` flag.
20+
This command will compare your local branches with remote and show you branches that are no longer available on remote but are still presented in your local repository. You can use it to view and delete all (remotely) removed branches in one go using `--prune-all` flag.
2221

2322
This command works without the need to run `git fetch -p`, but a working network connection to your remote is required. If no connection can be established with the remote repository, then local information about your remote will be used instead. If your local repository is not in sync with the remote repository, it will warn you about it.
2423

@@ -27,50 +26,52 @@ This command works without the need to run `git fetch -p`, but a working network
2726
### NPM
2827

2928
```bash
30-
$ npm install -g git-removed-branches
29+
npm install -g git-branch-cleanup
3130
```
3231

3332
Please install a package globally with -g flag so that you can use it directly as a sub command of git, like this:
3433

3534
```bash
36-
$ git removed-branches
35+
git branch-cleanup
3736
```
3837

3938
### NPX
4039

41-
It's also possible to use package through npx directly. Execute inside any git folder:
40+
It's also possible to use package through `npx` without installing:
4241

4342
```bash
44-
$ npx git-removed-branches
43+
npx git-branch-cleanup
4544
```
4645

4746
## Usage
4847

4948
```bash
50-
$ git removed-branches
49+
git branch-cleanup
5150
```
5251

5352
This command will look through the branches that are no longer available on the remote and display them.
5453
In case you haven't run `git fetch -p`, it will warn you to do so.
5554

56-
This command is safe to run and it will not alter your repository.
55+
<img width="609" alt="Prompt with list of branches, allowing arbitrary selection" src="https://github.com/user-attachments/assets/6a0530a7-c13c-42da-a983-ab365dd51f74" />
56+
57+
<img width="1192" alt="Confirmation prompt" src="https://github.com/user-attachments/assets/2c620b7f-6b79-4a9c-a0fe-ff0b55539f1d" />
5758

58-
### Removing
59+
### Auto-removal
5960

60-
To delete local branches use `--prune` or `-p` flag
61+
To delete all local branches without choosing which ones, and without confirmation, use `--prune-all` or `-p` flag
6162

6263
```bash
63-
$ git removed-branches --prune
64+
git branch-cleanup --prune-all
6465
```
6566

6667
This command will compare your local branches to the remote ones and remove, those which do not exist anymore on the remote side.
6768

68-
### Different remote
69+
### Custom remote
6970

7071
If you have configured remote alias to something different than **'origin'**, you can use `--remote` or `-r` flag to specify the name of the remote. e.g., to specify remote to be `upstream`, you can use:
7172

7273
```bash
73-
$ git removed-branches --remote upstream
74+
git branch-cleanup --remote upstream
7475
```
7576

7677
## Forcing removal
@@ -84,27 +85,27 @@ The branch {branch_name} is not fully merged.
8485
you can force deletion by using `--force` flag or use `-f` alias
8586

8687
```bash
87-
$ git removed-branches --prune --force
88+
git branch-cleanup --prune-all --force
8889
```
8990

9091
## Version
9192

92-
To find out, which version you use ( since 2.3.0 )
93+
To print the version:
9394

94-
```
95-
git removed-branches --version
95+
```bash
96+
git branch-cleanup --version
9697
```
9798

9899
## Troubleshooting:
99100

100-
If you encounter error `ERR_CHILD_PROCESS_STDIO_MAXBUFFER` it is possible that your repository contains too much branches, more then 3382. ( see [discussion](https://github.com/patik/git-removed-branches/issues/11) )
101+
If you encounter error `ERR_CHILD_PROCESS_STDIO_MAXBUFFER` it is possible that your repository contains too many branches (more then 3382see [discussion](https://github.com/patik/git-branch-cleanup/issues/11)).
101102

102-
You can fix this, by specifying NODE_MAX_BUFFER environment variable, like:
103+
You can fix this by specifying NODE_MAX_BUFFER environment variable. For example:
103104

104-
```
105-
NODE_MAX_BUFFER=1048576 git removed-branches
105+
```bash
106+
NODE_MAX_BUFFER=1048576 git branch-cleanup
106107
```
107108

108109
## Credit
109110

110-
Forked from [git-removed-branches](https://github.com/nemisj/git-removed-branches) by [Maks Nemisj](https://github.com/nemisj) @nemisj
111+
Forked from [git-branch-cleanup](https://github.com/nemisj/git-branch-cleanup) by [Maks Nemisj](https://github.com/nemisj) @nemisj

eslint.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @ts-check
2+
13
import pluginJs from '@eslint/js'
24
import tseslint from 'typescript-eslint'
35
import eslintPluginPrettier from 'eslint-plugin-prettier/recommended'

package.json

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,55 @@
11
{
2-
"name": "git-removed-branches",
3-
"version": "2.3.1",
2+
"name": "git-branch-cleanup",
3+
"version": "1.0.0",
44
"engines": {
55
"node": ">=18"
66
},
7-
"description": "Git: Remove local branches which are no longer available on the remote",
7+
"description": "Delete local git branches that have been merged and removed on the remote",
88
"main": "dist/index.js",
99
"type": "module",
1010
"preferGlobal": true,
1111
"bin": {
12-
"git-removed-branches": "dis/index.js"
12+
"git-branch-cleanup": "dist/index.js"
1313
},
1414
"scripts": {
1515
"build": "tsc",
1616
"start": "tsx ./src/index.ts",
1717
"test": "pnpm run build && tsx ./src/test.ts",
1818
"lint": "tsc --noEmit && pnpm run format && eslint .",
1919
"format": "prettier --write --list-different .",
20-
"check-format": "prettier --check --list-different ."
20+
"check-format": "prettier --check --list-different .",
21+
"check-exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm",
22+
"ci": "pnpm build && pnpm check-format && pnpm check-exports",
23+
"prepublishOnly": "pnpm run ci"
2124
},
2225
"repository": {
2326
"type": "git",
24-
"url": "https://github.com/patik/git-removed-branches.git"
27+
"url": "https://github.com/patik/git-branch-cleanup.git"
2528
},
2629
"author": "Craig Patik",
2730
"license": "MIT",
2831
"bugs": {
29-
"url": "https://github.com/patik/git-removed-branches/issues"
32+
"url": "https://github.com/patik/git-branch-cleanup/issues"
3033
},
31-
"homepage": "https://github.com/patik/git-removed-branches",
34+
"homepage": "https://github.com/patik/git-branch-cleanup",
35+
"keywords": [
36+
"git",
37+
"branch",
38+
"cleanup",
39+
"prune",
40+
"remove",
41+
"delete",
42+
"interactive",
43+
"confirmation",
44+
"cli",
45+
"command",
46+
"tool"
47+
],
3248
"dependencies": {
3349
"minimist": "^1.2.8"
3450
},
3551
"devDependencies": {
52+
"@arethetypeswrong/cli": "^0.18.1",
3653
"@eslint/js": "^9.27.0",
3754
"@inquirer/prompts": "^7.5.1",
3855
"@types/minimist": "^1.2.5",

0 commit comments

Comments
 (0)