port-detective 1.1.0-bootstrap.0 → 1.1.1

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 (3) hide show
  1. package/README.md +12 -1
  2. package/cli.js +30 -0
  3. package/package.json +57 -53
package/README.md CHANGED
@@ -5,7 +5,7 @@ TypeScript APIs. Published releases install a matching platform CLI package auto
5
5
 
6
6
  ## Install
7
7
 
8
- Install the package from npm when a release is available:
8
+ Install the published package from npm:
9
9
 
10
10
  ```bash
11
11
  npm install port-detective
@@ -16,6 +16,17 @@ checkouts omit generated platform packages; build the CLI locally or set
16
16
  `PORT_DETECTIVE_BIN` when developing from this directory. `binaryPath` always overrides
17
17
  automatic resolution, and unsupported platforms can use a CLI on `PATH`.
18
18
 
19
+ The published package also exposes the CLI command through npm:
20
+
21
+ ```bash
22
+ npx --no-install port-detective check 3000
23
+ npx --no-install port-detective scan --ports 3000,8080
24
+ ```
25
+
26
+ After installation, `port-detective` is available from npm scripts and
27
+ `node_modules/.bin`. The wrapper uses the matching bundled platform binary and falls
28
+ back to `PORT_DETECTIVE_BIN` or a CLI on `PATH`.
29
+
19
30
  ## Use
20
31
 
21
32
  ```js
package/cli.js ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const { spawnSync } = require("node:child_process");
6
+ const { binaryRelativePath, platformPackageName } = require("./platform");
7
+
8
+ function resolveCli() {
9
+ if (process.env.PORT_DETECTIVE_BIN) return process.env.PORT_DETECTIVE_BIN;
10
+ const packageName = platformPackageName();
11
+ if (packageName) {
12
+ try {
13
+ return require.resolve(`${packageName}/${binaryRelativePath()}`);
14
+ } catch {
15
+ // Fall back to a separately installed CLI or PATH.
16
+ }
17
+ }
18
+ return process.platform === "win32" ? "port-detective.exe" : "port-detective";
19
+ }
20
+
21
+ const result = spawnSync(resolveCli(), process.argv.slice(2), {
22
+ stdio: "inherit",
23
+ windowsHide: true,
24
+ });
25
+
26
+ if (result.error) {
27
+ console.error(`failed to execute port-detective: ${result.error.message}`);
28
+ process.exit(1);
29
+ }
30
+ process.exit(result.status === null ? 1 : result.status);
package/package.json CHANGED
@@ -1,53 +1,57 @@
1
- {
2
- "name": "port-detective",
3
- "version": "1.1.0-bootstrap.0",
4
- "description": "Minimal-dependency Node.js client for the port-detective CLI.",
5
- "license": "MIT",
6
- "main": "index.js",
7
- "types": "index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./index.d.ts",
11
- "require": "./index.js",
12
- "default": "./index.js"
13
- }
14
- },
15
- "files": [
16
- "index.js",
17
- "platform.js",
18
- "index.d.ts",
19
- "README.md",
20
- "LICENSE"
21
- ],
22
- "scripts": {
23
- "test": "node --experimental-test-coverage --test-coverage-lines=45 --test-coverage-branches=65 --test-coverage-functions=55 --test"
24
- },
25
- "engines": {
26
- "node": ">=22"
27
- },
28
- "keywords": [
29
- "port",
30
- "process",
31
- "cli",
32
- "networking",
33
- "developer-tools"
34
- ],
35
- "repository": {
36
- "type": "git",
37
- "url": "https://github.com/EquityQ/port-detective.git",
38
- "directory": "npm/port-detective"
39
- },
40
- "homepage": "https://github.com/EquityQ/port-detective/tree/main/npm/port-detective",
41
- "sideEffects": false,
42
- "publishConfig": {
43
- "access": "public"
44
- },
45
- "optionalDependencies": {
46
- "port-detective-cli-win32-x64": "1.1.0-bootstrap.0",
47
- "port-detective-cli-win32-arm64": "1.1.0-bootstrap.0",
48
- "port-detective-cli-darwin-x64": "1.1.0-bootstrap.0",
49
- "port-detective-cli-darwin-arm64": "1.1.0-bootstrap.0",
50
- "port-detective-cli-linux-x64": "1.1.0-bootstrap.0",
51
- "port-detective-cli-linux-arm64": "1.1.0-bootstrap.0"
52
- }
53
- }
1
+ {
2
+ "name": "port-detective",
3
+ "version": "1.1.1",
4
+ "description": "Minimal-dependency Node.js client for the port-detective CLI.",
5
+ "license": "MIT",
6
+ "main": "index.js",
7
+ "bin": {
8
+ "port-detective": "cli.js"
9
+ },
10
+ "types": "index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./index.d.ts",
14
+ "require": "./index.js",
15
+ "default": "./index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "index.js",
20
+ "cli.js",
21
+ "platform.js",
22
+ "index.d.ts",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "scripts": {
27
+ "test": "node --experimental-test-coverage --test-coverage-lines=45 --test-coverage-branches=65 --test-coverage-functions=55 --test"
28
+ },
29
+ "engines": {
30
+ "node": ">=22"
31
+ },
32
+ "keywords": [
33
+ "port",
34
+ "process",
35
+ "cli",
36
+ "networking",
37
+ "developer-tools"
38
+ ],
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/EquityQ/port-detective.git",
42
+ "directory": "npm/port-detective"
43
+ },
44
+ "homepage": "https://github.com/EquityQ/port-detective/tree/main/npm/port-detective",
45
+ "sideEffects": false,
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "optionalDependencies": {
50
+ "port-detective-cli-win32-x64": "1.1.1",
51
+ "port-detective-cli-win32-arm64": "1.1.1",
52
+ "port-detective-cli-darwin-x64": "1.1.1",
53
+ "port-detective-cli-darwin-arm64": "1.1.1",
54
+ "port-detective-cli-linux-x64": "1.1.1",
55
+ "port-detective-cli-linux-arm64": "1.1.1"
56
+ }
57
+ }