portzap 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.
Files changed (2) hide show
  1. package/bin.js +51 -0
  2. package/package.json +30 -0
package/bin.js ADDED
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execFileSync } = require("child_process");
4
+ const path = require("path");
5
+ const os = require("os");
6
+
7
+ const PLATFORMS = {
8
+ "darwin-arm64": "@portzap/darwin-arm64",
9
+ "darwin-x64": "@portzap/darwin-x64",
10
+ "linux-x64": "@portzap/linux-x64",
11
+ "linux-arm64": "@portzap/linux-arm64",
12
+ };
13
+
14
+ function getBinaryPath() {
15
+ const platform = os.platform();
16
+ const arch = os.arch();
17
+ const key = `${platform}-${arch}`;
18
+ const pkg = PLATFORMS[key];
19
+
20
+ if (!pkg) {
21
+ console.error(
22
+ `portzap: unsupported platform ${platform}-${arch}\n` +
23
+ `Supported: ${Object.keys(PLATFORMS).join(", ")}`
24
+ );
25
+ process.exit(1);
26
+ }
27
+
28
+ try {
29
+ const pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
30
+ const binName = platform === "win32" ? "portzap.exe" : "portzap";
31
+ return path.join(pkgDir, binName);
32
+ } catch {
33
+ console.error(
34
+ `portzap: failed to find binary package ${pkg}\n` +
35
+ `Try reinstalling: npm install portzap`
36
+ );
37
+ process.exit(1);
38
+ }
39
+ }
40
+
41
+ const binPath = getBinaryPath();
42
+ const args = process.argv.slice(2);
43
+
44
+ try {
45
+ execFileSync(binPath, args, { stdio: "inherit" });
46
+ } catch (err) {
47
+ if (err.status !== null) {
48
+ process.exit(err.status);
49
+ }
50
+ throw err;
51
+ }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "portzap",
3
+ "version": "0.1.0",
4
+ "description": "A fast, cross-platform port management tool. Kill, list, and watch processes on network ports.",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "portzap": "bin.js"
8
+ },
9
+ "files": [
10
+ "bin.js"
11
+ ],
12
+ "optionalDependencies": {
13
+ "@portzap/darwin-arm64": "0.1.0",
14
+ "@portzap/darwin-x64": "0.1.0",
15
+ "@portzap/linux-x64": "0.1.0",
16
+ "@portzap/linux-arm64": "0.1.0"
17
+ },
18
+ "keywords": [
19
+ "port",
20
+ "kill",
21
+ "process",
22
+ "network",
23
+ "cli",
24
+ "devtools"
25
+ ],
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/justinkarso/portzap"
29
+ }
30
+ }