Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing & Maintaining

Maintainer notes for [port-kill-cli](README.md) (`pk` / `kp`): repository protection, releasing, development and branding. This file is not part of the npm package. See also [TESTING.md](TESTING.md) and [SECURITY.md](SECURITY.md).
Maintainer notes for [cross-port-kill](README.md) (`pk` / `kp`): repository protection, releasing, development and branding. This file is not part of the npm package. See also [TESTING.md](TESTING.md) and [SECURITY.md](SECURITY.md).

## Branch protection

Expand All @@ -27,6 +27,20 @@ npm version patch # bumps package.json and creates the vX.Y.Z tag
git push --follow-tags # triggers the publish workflow
```

### The rename to `cross-port-kill` (2.0.0)

The package was published as `@majidev-org/port-kill-cli` up to 1.2.0. npm cannot rename a package, so `cross-port-kill` is a new package that continues at 2.0.0. A token limited to the old package cannot create a new one, so the first release needs a token that can:

1. On npmjs.com (*Access Tokens β†’ Generate New Token β†’ Granular Access Token*), create a token with **read and write** on **all packages** and a **1-day expiry**. Store it as the `NPM_TOKEN` repository secret.
2. Push the 2.0.0 commit to `main`, wait for CI to pass, then push the tag: `git tag v2.0.0 && git push origin v2.0.0`. The workflow publishes `cross-port-kill` with provenance.
3. Replace `NPM_TOKEN` with a token limited to `cross-port-kill` (read and write), and delete the 1-day token and the old package's token.
4. Deprecate the old package so its users are told where to go:
```bash
npm deprecate @majidev-org/port-kill-cli "Renamed to cross-port-kill: npm i -g cross-port-kill (or npx cross-port-kill)"
```

From 2.0.1 on, releases go through the workflow as above.

## Development

```bash
Expand All @@ -38,3 +52,5 @@ See [TESTING.md](TESTING.md) for linking the CLI locally and manual test scenari
## Branding

Logo and icons live in [assets/](assets/): [logo.svg](assets/logo.svg), [icon.svg](assets/icon.svg) (plus [icon-512.png](assets/icon-512.png) and [logo.png](assets/logo.png)) and [social-preview.png](assets/social-preview.png) (1280Γ—640, for the GitHub social card). They are not part of the npm package. The SVGs are hand-drawn shapes with no font dependency; regenerate the PNGs with headless Chrome, e.g. `google-chrome --headless --window-size=512,512 --default-background-color=00000000 --screenshot=assets/icon-512.png assets/icon.svg`.

The animated terminal demo at the top of the README, [demo.svg](assets/demo.svg), is generated by [scripts/make-demo.mjs](scripts/make-demo.mjs) from the CLI's own table and color code, so it matches the real output. Run `node scripts/make-demo.mjs` after changing how the picker, `--info` or the result lines look. The picker layout is copied from `pickCheckboxes()` in [src/interactive.js](src/interactive.js), so update the script if that changes. The static screenshots (`screenshot-*.png`) are real terminal captures and need retaking by hand.
2 changes: 1 addition & 1 deletion PRIVACY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Privacy Policy

`pk` (`@majidev-org/port-kill-cli`) is a local command-line tool. **It collects no data.**
`pk` (`cross-port-kill`) is a local command-line tool. **It collects no data.**

## What it does and does not do

Expand Down
395 changes: 271 additions & 124 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Please do **not** open a public issue for security problems. Use GitHub's privat
[majidev.netlify.app](https://majidev.netlify.app) and ask for a private channel.

Only the latest published version is supported; fixes ship as a new patch release on
[npm](https://www.npmjs.com/package/@majidev-org/port-kill-cli).
[npm](https://www.npmjs.com/package/cross-port-kill).

## What `pk` does to stay safe

Expand Down
2 changes: 1 addition & 1 deletion TERMS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Terms of Use

By installing or running `pk` / `port-kill` (`@majidev-org/port-kill-cli`) you agree to these terms. They sit alongside the [MIT License](LICENSE), which governs copying and modification of the code; if the two conflict, the license wins.
By installing or running `cross-port-kill` under any of its command names (`pk`, `kp`, `cpk`, `ckp`, `port-kill`, `kill-port`, `cross-port-kill`, `cross-kill-port`, `pk-udp`, `pk-tcp`) you agree to these terms. They sit alongside the [MIT License](LICENSE), which governs copying and modification of the code; if the two conflict, the license wins.

## 1. What the tool does

Expand Down
40 changes: 34 additions & 6 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Local Development & Testing Guide

Follow these steps to link, run, and test `port-kill-cli` (`pk` / `kp`) locally before publishing to npm. See the [README](README.md) for usage and [SECURITY.md](SECURITY.md) for the safety checks these tests exercise.
Follow these steps to link, run, and test `cross-port-kill` (`pk` / `kp`) locally before publishing to npm. See the [README](README.md) for usage and [SECURITY.md](SECURITY.md) for the safety checks these tests exercise.

**Requirements:** [Node.js](https://nodejs.org) 18+; `lsof` (or `ss` on Linux); optionally [Docker](https://docs.docker.com/get-docker/) for Test E.

Expand All @@ -14,11 +14,19 @@ chmod +x bin/cli.js
npm link
```

This creates a global symlink so you can run `pk`, `kp` and `port-kill` from any directory. Verify it works:
This creates a global symlink so you can run all ten commands (`pk`, `kp`, `cpk`, `ckp`, `port-kill`, `kill-port`, `cross-port-kill`, `cross-kill-port`, `pk-udp`, `pk-tcp`) from any directory. Verify it works:

```bash
pk --help
kp --version
cpk --version
ckp --version
port-kill --version
kill-port --version
cross-port-kill --version
cross-kill-port --version
pk-udp --version
pk-tcp --version # all ten print the same version
```

---
Expand Down Expand Up @@ -80,13 +88,33 @@ Each scenario starts a throwaway server with `node -e "require('http').createSer

### Test D: Invalid Input & Edge Cases
```bash
pk 99999 # (or kp 99999) βœ– Invalid port or range: "99999" (expected 1–65535, e.g. 3000 or 3000-3005)
pk abc # (or kp abc) βœ– Invalid port or range: "abc" (expected 1–65535, e.g. 3000 or 3000-3005)
pk 99999 # (or kp 99999) βœ– Invalid port or range: "99999" (expected 1–65535, e.g. 3000, 3000-3005, :3000, localhost:3000 or 5353/udp)
pk abc # (or kp abc) βœ– Invalid port or range: "abc" (expected 1–65535, e.g. 3000, 3000-3005, :3000, localhost:3000 or 5353/udp)
pk 3005-3000 # (or kp 3005-3000) βœ– Invalid port or range … (end before start)
pk --nope # (or kp --nope) βœ– Unknown option: "--nope"
pk --nope # (or kp --nope) βœ– Unknown option: "--nope". Run pk --help to see the options.
pk --forse # (or kp --forse) βœ– Unknown option: "--forse". Did you mean "--force"?
pk < /dev/null # (or kp < /dev/null) prints the help menu (no interactive prompt without a TTY)
pk 3000/sctp # (or kp 3000/sctp) βœ– Invalid port or range: "3000/sctp" (only /tcp and /udp)
```

### Test D1: Words
Start a dummy server on `4001` (as in Test A), then:
1. `pk port 4001`, `pk what is on 4001` and `pk is 4001 free`. *Expected:* each shows the server and ends with `To free it: pk 4001`. The server keeps running.
2. `pk kil 4001`. *Expected:* `βœ– Unknown word: "kil". Did you mean "kill"?`, nothing is stopped.
3. `pk kill 4001`. *Expected:* `βœ” Freed port 4001 …`.
4. `pk localhost:4001` and `pk http://localhost:4001/` work the same as `pk 4001` (restart the server between runs).

### Test D2: UDP Ports
1. Bind a UDP socket in a separate terminal:
```bash
node -e "require('dgram').createSocket('udp4').bind(5454, () => console.log('bound 5454/udp'))"
```
2. Run `pk 5454`. *Expected:* `β€’ Port 5454 is already free.` and the socket keeps running (TCP is the default).
3. Run `pk 5454 --udp --info` (or `pk 5454/udp --info`). *Expected:* a row for `:5454/udp` with the node PID.
4. Run `pk 5454/udp`. *Expected:* `βœ” Freed port 5454/udp … via SIGTERM (graceful)` and the first terminal returns to the prompt.
5. Run `pk --udp`. *Expected:* the picker lists UDP ports only, each shown as `:<port>/udp`.
6. Docker: `docker run -d --rm --name pk-udp -p 5455:53/udp alpine sleep 600`, then `pk 5455` says already free and `pk 5455/udp` stops the container via `docker stop`.

### Test E: Docker Containers
1. Start a container that publishes a port:
```bash
Expand Down Expand Up @@ -131,5 +159,5 @@ pk 4002 --info # or: kp 4002 --info
To test the published package instead of your local checkout:

```bash
npm unlink -g @majidev-org/port-kill-cli
npm unlink -g cross-port-kill
```
Loading
Loading