@noxlightman/winportkill 0.1.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/README.md +50 -0
- package/bin/winportkill.js +71 -0
- package/package.json +43 -0
- package/vendor/winportkill.exe +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# `@noxlightman/winportkill`
|
|
2
|
+
|
|
3
|
+
Windows x64 CLI launcher for WinPortKill.
|
|
4
|
+
|
|
5
|
+
## Current Behavior
|
|
6
|
+
|
|
7
|
+
This package is a thin Node wrapper around the Rust binary. Published tarballs are
|
|
8
|
+
expected to include `vendor/winportkill.exe`.
|
|
9
|
+
|
|
10
|
+
At runtime, it resolves `winportkill.exe` in the following order:
|
|
11
|
+
|
|
12
|
+
1. `WINPORTKILL_BIN`
|
|
13
|
+
2. `target/debug/winportkill.exe` in the workspace
|
|
14
|
+
3. `target/release/winportkill.exe` in the workspace
|
|
15
|
+
4. `.vscode-extension/bin/win32-x64/winportkill.exe` in the workspace
|
|
16
|
+
5. `vendor/winportkill.exe` inside this package
|
|
17
|
+
|
|
18
|
+
## Local Development
|
|
19
|
+
|
|
20
|
+
From the repository root:
|
|
21
|
+
|
|
22
|
+
```powershell
|
|
23
|
+
cargo build --release -p winportkill
|
|
24
|
+
node .\packages\npm-cli\bin\winportkill.js list --json
|
|
25
|
+
node .\packages\npm-cli\bin\winportkill.js who-uses 3000
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Or from this package directory:
|
|
29
|
+
|
|
30
|
+
```powershell
|
|
31
|
+
npm.cmd run test:local
|
|
32
|
+
npm.cmd pack
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Notes
|
|
36
|
+
|
|
37
|
+
- Supported platform: Windows x64 only
|
|
38
|
+
- The npm wrapper forwards all arguments directly to the Rust CLI
|
|
39
|
+
- `npm pack` / `npm publish` runs `prepack`, which copies a release binary into `vendor/`
|
|
40
|
+
- A later publishing step can replace the local binary copy with a GitHub Releases download flow
|
|
41
|
+
|
|
42
|
+
## Commands
|
|
43
|
+
|
|
44
|
+
```powershell
|
|
45
|
+
winportkill list --json
|
|
46
|
+
winportkill who-uses 3000
|
|
47
|
+
winportkill kill --pid 1234
|
|
48
|
+
winportkill kill --port 3000
|
|
49
|
+
winportkill --serve 3000
|
|
50
|
+
```
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { spawnSync } = require("node:child_process");
|
|
5
|
+
const fs = require("node:fs");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
|
|
8
|
+
if (process.platform !== "win32") {
|
|
9
|
+
fail(`WinPortKill currently supports only Windows x64. Detected platform: ${process.platform}`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (process.arch !== "x64") {
|
|
13
|
+
fail(`WinPortKill currently supports only Windows x64. Detected arch: ${process.arch}`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const binaryPath = resolveBinaryPath();
|
|
17
|
+
const result = spawnSync(binaryPath, process.argv.slice(2), {
|
|
18
|
+
stdio: "inherit",
|
|
19
|
+
windowsHide: true
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
if (result.error) {
|
|
23
|
+
fail(`Failed to start ${binaryPath}: ${result.error.message}`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (typeof result.status === "number") {
|
|
27
|
+
process.exit(result.status);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
fail(`WinPortKill terminated unexpectedly${result.signal ? ` with signal ${result.signal}` : ""}`);
|
|
31
|
+
|
|
32
|
+
function resolveBinaryPath() {
|
|
33
|
+
const packageRoot = path.resolve(__dirname, "..");
|
|
34
|
+
const repoRoot = path.resolve(packageRoot, "..", "..");
|
|
35
|
+
|
|
36
|
+
const candidates = [
|
|
37
|
+
process.env.WINPORTKILL_BIN,
|
|
38
|
+
path.join(repoRoot, "target", "debug", "winportkill.exe"),
|
|
39
|
+
path.join(repoRoot, "target", "release", "winportkill.exe"),
|
|
40
|
+
path.join(repoRoot, ".vscode-extension", "bin", "win32-x64", "winportkill.exe"),
|
|
41
|
+
path.join(packageRoot, "vendor", "winportkill.exe")
|
|
42
|
+
].filter(Boolean);
|
|
43
|
+
|
|
44
|
+
for (const candidate of candidates) {
|
|
45
|
+
if (isFile(candidate)) {
|
|
46
|
+
return candidate;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fail(
|
|
51
|
+
[
|
|
52
|
+
"Unable to locate winportkill.exe.",
|
|
53
|
+
"Checked:",
|
|
54
|
+
...candidates.map((candidate) => `- ${candidate}`),
|
|
55
|
+
"Set WINPORTKILL_BIN to an explicit binary path, or build the Rust workspace first."
|
|
56
|
+
].join("\n")
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function isFile(filePath) {
|
|
61
|
+
try {
|
|
62
|
+
return fs.statSync(filePath).isFile();
|
|
63
|
+
} catch {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function fail(message) {
|
|
69
|
+
console.error(`[winportkill] ${message}`);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@noxlightman/winportkill",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Windows x64 CLI launcher for WinPortKill.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/NoxLightman/winport-killer",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/NoxLightman/winport-killer.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/NoxLightman/winport-killer/issues"
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"winportkill": "./bin/winportkill.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"bin",
|
|
19
|
+
"vendor",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18"
|
|
24
|
+
},
|
|
25
|
+
"os": [
|
|
26
|
+
"win32"
|
|
27
|
+
],
|
|
28
|
+
"cpu": [
|
|
29
|
+
"x64"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"prepack": "node ./scripts/prepare-package.js",
|
|
33
|
+
"pretest:local": "node ./scripts/prepare-package.js",
|
|
34
|
+
"test:local": "node ./bin/winportkill.js list --json"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"port",
|
|
38
|
+
"windows",
|
|
39
|
+
"process",
|
|
40
|
+
"cli",
|
|
41
|
+
"rust"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
Binary file
|