port-doctor-cli 1.0.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 (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +266 -0
  3. package/bin/port-doctor.js +8 -0
  4. package/dist/cli/commands/free.d.ts +3 -0
  5. package/dist/cli/commands/free.d.ts.map +1 -0
  6. package/dist/cli/commands/free.js +120 -0
  7. package/dist/cli/commands/free.js.map +1 -0
  8. package/dist/cli/commands/overview.d.ts +3 -0
  9. package/dist/cli/commands/overview.d.ts.map +1 -0
  10. package/dist/cli/commands/overview.js +19 -0
  11. package/dist/cli/commands/overview.js.map +1 -0
  12. package/dist/cli/commands/run.d.ts +4 -0
  13. package/dist/cli/commands/run.d.ts.map +1 -0
  14. package/dist/cli/commands/run.js +133 -0
  15. package/dist/cli/commands/run.js.map +1 -0
  16. package/dist/cli/commands/why.d.ts +3 -0
  17. package/dist/cli/commands/why.d.ts.map +1 -0
  18. package/dist/cli/commands/why.js +24 -0
  19. package/dist/cli/commands/why.js.map +1 -0
  20. package/dist/cli/index.d.ts +3 -0
  21. package/dist/cli/index.d.ts.map +1 -0
  22. package/dist/cli/index.js +200 -0
  23. package/dist/cli/index.js.map +1 -0
  24. package/dist/cli/output/formatter.d.ts +6 -0
  25. package/dist/cli/output/formatter.d.ts.map +1 -0
  26. package/dist/cli/output/formatter.js +177 -0
  27. package/dist/cli/output/formatter.js.map +1 -0
  28. package/dist/cli/output/json.d.ts +2 -0
  29. package/dist/cli/output/json.d.ts.map +1 -0
  30. package/dist/cli/output/json.js +6 -0
  31. package/dist/cli/output/json.js.map +1 -0
  32. package/dist/cli/output/tree.d.ts +3 -0
  33. package/dist/cli/output/tree.d.ts.map +1 -0
  34. package/dist/cli/output/tree.js +19 -0
  35. package/dist/cli/output/tree.js.map +1 -0
  36. package/dist/cli/prompts/confirm.d.ts +3 -0
  37. package/dist/cli/prompts/confirm.d.ts.map +1 -0
  38. package/dist/cli/prompts/confirm.js +53 -0
  39. package/dist/cli/prompts/confirm.js.map +1 -0
  40. package/dist/core/diagnosis/index.d.ts +4 -0
  41. package/dist/core/diagnosis/index.d.ts.map +1 -0
  42. package/dist/core/diagnosis/index.js +109 -0
  43. package/dist/core/diagnosis/index.js.map +1 -0
  44. package/dist/core/framework/index.d.ts +5 -0
  45. package/dist/core/framework/index.d.ts.map +1 -0
  46. package/dist/core/framework/index.js +211 -0
  47. package/dist/core/framework/index.js.map +1 -0
  48. package/dist/core/git/index.d.ts +3 -0
  49. package/dist/core/git/index.d.ts.map +1 -0
  50. package/dist/core/git/index.js +56 -0
  51. package/dist/core/git/index.js.map +1 -0
  52. package/dist/core/lifecycle/index.d.ts +8 -0
  53. package/dist/core/lifecycle/index.d.ts.map +1 -0
  54. package/dist/core/lifecycle/index.js +175 -0
  55. package/dist/core/lifecycle/index.js.map +1 -0
  56. package/dist/core/process/index.d.ts +9 -0
  57. package/dist/core/process/index.d.ts.map +1 -0
  58. package/dist/core/process/index.js +94 -0
  59. package/dist/core/process/index.js.map +1 -0
  60. package/dist/core/project/index.d.ts +3 -0
  61. package/dist/core/project/index.d.ts.map +1 -0
  62. package/dist/core/project/index.js +84 -0
  63. package/dist/core/project/index.js.map +1 -0
  64. package/dist/core/scanner/index.d.ts +5 -0
  65. package/dist/core/scanner/index.d.ts.map +1 -0
  66. package/dist/core/scanner/index.js +71 -0
  67. package/dist/core/scanner/index.js.map +1 -0
  68. package/dist/index.d.ts +11 -0
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.js +11 -0
  71. package/dist/index.js.map +1 -0
  72. package/dist/platform/darwin.d.ts +27 -0
  73. package/dist/platform/darwin.d.ts.map +1 -0
  74. package/dist/platform/darwin.js +268 -0
  75. package/dist/platform/darwin.js.map +1 -0
  76. package/dist/platform/index.d.ts +4 -0
  77. package/dist/platform/index.d.ts.map +1 -0
  78. package/dist/platform/index.js +26 -0
  79. package/dist/platform/index.js.map +1 -0
  80. package/dist/platform/linux.d.ts +22 -0
  81. package/dist/platform/linux.d.ts.map +1 -0
  82. package/dist/platform/linux.js +217 -0
  83. package/dist/platform/linux.js.map +1 -0
  84. package/dist/platform/types.d.ts +40 -0
  85. package/dist/platform/types.d.ts.map +1 -0
  86. package/dist/platform/types.js +2 -0
  87. package/dist/platform/types.js.map +1 -0
  88. package/dist/platform/windows.d.ts +17 -0
  89. package/dist/platform/windows.d.ts.map +1 -0
  90. package/dist/platform/windows.js +138 -0
  91. package/dist/platform/windows.js.map +1 -0
  92. package/dist/types/index.d.ts +101 -0
  93. package/dist/types/index.d.ts.map +1 -0
  94. package/dist/types/index.js +2 -0
  95. package/dist/types/index.js.map +1 -0
  96. package/dist/utils/exec.d.ts +16 -0
  97. package/dist/utils/exec.d.ts.map +1 -0
  98. package/dist/utils/exec.js +51 -0
  99. package/dist/utils/exec.js.map +1 -0
  100. package/dist/utils/formatting.d.ts +10 -0
  101. package/dist/utils/formatting.d.ts.map +1 -0
  102. package/dist/utils/formatting.js +60 -0
  103. package/dist/utils/formatting.js.map +1 -0
  104. package/dist/utils/redaction.d.ts +5 -0
  105. package/dist/utils/redaction.d.ts.map +1 -0
  106. package/dist/utils/redaction.js +31 -0
  107. package/dist/utils/redaction.js.map +1 -0
  108. package/package.json +56 -0
@@ -0,0 +1,16 @@
1
+ export interface ExecResult {
2
+ stdout: string;
3
+ stderr: string;
4
+ exitCode: number;
5
+ }
6
+ export declare function safeExec(command: string, options?: {
7
+ timeout?: number;
8
+ cwd?: string;
9
+ maxBuffer?: number;
10
+ }): Promise<ExecResult>;
11
+ export declare function safeExecFile(file: string, args: string[], options?: {
12
+ timeout?: number;
13
+ cwd?: string;
14
+ maxBuffer?: number;
15
+ }): Promise<ExecResult>;
16
+ //# sourceMappingURL=exec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACnE,OAAO,CAAC,UAAU,CAAC,CAqBrB;AAED,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACnE,OAAO,CAAC,UAAU,CAAC,CAqBrB"}
@@ -0,0 +1,51 @@
1
+ import { exec, execFile } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ const execAsync = promisify(exec);
4
+ const execFileAsync = promisify(execFile);
5
+ export async function safeExec(command, options = {}) {
6
+ const { timeout = 5000, cwd, maxBuffer = 10 * 1024 * 1024 } = options;
7
+ try {
8
+ const { stdout, stderr } = await execAsync(command, {
9
+ timeout,
10
+ cwd,
11
+ maxBuffer,
12
+ windowsHide: true,
13
+ });
14
+ return {
15
+ stdout: stdout.trim(),
16
+ stderr: stderr.trim(),
17
+ exitCode: 0,
18
+ };
19
+ }
20
+ catch (err) {
21
+ return {
22
+ stdout: (err.stdout || '').toString().trim(),
23
+ stderr: (err.stderr || err.message || '').toString().trim(),
24
+ exitCode: typeof err.code === 'number' ? err.code : 1,
25
+ };
26
+ }
27
+ }
28
+ export async function safeExecFile(file, args, options = {}) {
29
+ const { timeout = 5000, cwd, maxBuffer = 10 * 1024 * 1024 } = options;
30
+ try {
31
+ const { stdout, stderr } = await execFileAsync(file, args, {
32
+ timeout,
33
+ cwd,
34
+ maxBuffer,
35
+ windowsHide: true,
36
+ });
37
+ return {
38
+ stdout: stdout.trim(),
39
+ stderr: stderr.trim(),
40
+ exitCode: 0,
41
+ };
42
+ }
43
+ catch (err) {
44
+ return {
45
+ stdout: (err.stdout || '').toString().trim(),
46
+ stderr: (err.stderr || err.message || '').toString().trim(),
47
+ exitCode: typeof err.code === 'number' ? err.code : 1,
48
+ };
49
+ }
50
+ }
51
+ //# sourceMappingURL=exec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAClC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAQ1C,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,OAAe,EACf,UAAkE,EAAE;IAEpE,MAAM,EAAE,OAAO,GAAG,IAAI,EAAE,GAAG,EAAE,SAAS,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACtE,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE;YAClD,OAAO;YACP,GAAG;YACH,SAAS;YACT,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;QACH,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE;YACrB,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE;YACrB,QAAQ,EAAE,CAAC;SACZ,CAAC;IACJ,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,OAAO;YACL,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE;YAC5C,MAAM,EAAE,CAAC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and text formatting helpers
3
+ */
4
+ export declare function formatDuration(seconds: number): string;
5
+ export declare function formatBytes(bytes: number): string;
6
+ export declare function shortenPath(fullPath: string, maxLength?: number): string;
7
+ export declare function stripAnsi(str: string): string;
8
+ export declare function visibleWidth(str: string): number;
9
+ export declare function pad(str: string, length: number, align?: 'left' | 'right'): string;
10
+ //# sourceMappingURL=formatting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../src/utils/formatting.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAgBtD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKjD;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,SAAK,GAAG,MAAM,CAapE;AAKD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,MAAM,GAAG,OAAgB,GAAG,MAAM,CAKzF"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Time, size, and text formatting helpers
3
+ */
4
+ export function formatDuration(seconds) {
5
+ if (seconds < 0)
6
+ return 'unknown';
7
+ if (seconds < 60)
8
+ return `${Math.floor(seconds)}s`;
9
+ const minutes = Math.floor(seconds / 60);
10
+ if (minutes < 60) {
11
+ const sec = Math.floor(seconds % 60);
12
+ return sec > 0 ? `${minutes}m ${sec}s` : `${minutes}m`;
13
+ }
14
+ const hours = Math.floor(minutes / 60);
15
+ const remainingMins = minutes % 60;
16
+ if (hours < 24) {
17
+ return remainingMins > 0 ? `${hours}h ${remainingMins}m` : `${hours}h`;
18
+ }
19
+ const days = Math.floor(hours / 24);
20
+ const remainingHours = hours % 24;
21
+ return remainingHours > 0 ? `${days}d ${remainingHours}h` : `${days}d`;
22
+ }
23
+ export function formatBytes(bytes) {
24
+ if (bytes <= 0)
25
+ return '0 B';
26
+ const units = ['B', 'KB', 'MB', 'GB', 'TB'];
27
+ const i = Math.floor(Math.log(bytes) / Math.log(1024));
28
+ return `${(bytes / Math.pow(1024, i)).toFixed(1)} ${units[i]}`;
29
+ }
30
+ export function shortenPath(fullPath, maxLength = 35) {
31
+ if (!fullPath)
32
+ return '';
33
+ const home = process.env.HOME || process.env.USERPROFILE || '';
34
+ let p = fullPath;
35
+ if (home && p.startsWith(home)) {
36
+ p = '~' + p.slice(home.length);
37
+ }
38
+ if (p.length <= maxLength)
39
+ return p;
40
+ const parts = p.split('/');
41
+ if (parts.length <= 3)
42
+ return p;
43
+ return `${parts[0]}/${parts[1]}/.../${parts[parts.length - 1]}`;
44
+ }
45
+ // ANSI escape code regular expression
46
+ const ANSI_REGEX = /\x1b\[[0-9;]*m/g;
47
+ export function stripAnsi(str) {
48
+ return str.replace(ANSI_REGEX, '');
49
+ }
50
+ export function visibleWidth(str) {
51
+ return stripAnsi(str).length;
52
+ }
53
+ export function pad(str, length, align = 'left') {
54
+ const visible = visibleWidth(str);
55
+ if (visible >= length)
56
+ return str;
57
+ const padding = ' '.repeat(length - visible);
58
+ return align === 'left' ? str + padding : padding + str;
59
+ }
60
+ //# sourceMappingURL=formatting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting.js","sourceRoot":"","sources":["../../src/utils/formatting.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,IAAI,OAAO,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IAClC,IAAI,OAAO,GAAG,EAAE;QAAE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;IACnD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,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O,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,OAAO,IAAI,MAAM;QAAE,OAAO,GAAG,CAAC;IAClC,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;IAC7C,OAAO,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Sensitive token and credential redaction utilities
3
+ */
4
+ export declare function redactSensitiveData(input: string): string;
5
+ //# sourceMappingURL=redaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction.d.ts","sourceRoot":"","sources":["../../src/utils/redaction.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAoBzD"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Sensitive token and credential redaction utilities
3
+ */
4
+ const SENSITIVE_PATTERNS = [
5
+ /(?:password|passwd|secret|token|api[_-]?key|apikey|auth[_-]?token|access[_-]?token|bearer|private[_-]?key|client[_-]?secret)[=\s]+([^\s&"']+)/gi,
6
+ /(?:--password|--token|--secret|--key|--api-key|--auth-token|--client-secret)[=\s]+([^\s"']+)/gi,
7
+ /(?:mongodb(?:\+srv)?|postgres(?:ql)?|mysql|redis|amqp(?:s)?):\/\/(?:[^:@\s"']+):([^@\s"']+)@/gi,
8
+ /Bearer\s+([a-zA-Z0-9_\-\.]{15,})/gi,
9
+ /eyJ[a-zA-Z0-9_-]{10,}\.[a-zA-Z0-9_-]{10,}\.[a-zA-Z0-9_-]{10,}/g, // JWTs
10
+ ];
11
+ export function redactSensitiveData(input) {
12
+ if (!input)
13
+ return input;
14
+ let redacted = input;
15
+ for (const pattern of SENSITIVE_PATTERNS) {
16
+ redacted = redacted.replace(pattern, (match, ...groups) => {
17
+ // Find the secret group if captured
18
+ if (groups.length > 0 && typeof groups[0] === 'string') {
19
+ const secret = groups[0];
20
+ if (secret.length <= 4) {
21
+ return match.replace(secret, '***');
22
+ }
23
+ const masked = `${secret.slice(0, 2)}***${secret.slice(-2)}`;
24
+ return match.replace(secret, masked);
25
+ }
26
+ return '[REDACTED]';
27
+ });
28
+ }
29
+ return redacted;
30
+ }
31
+ //# sourceMappingURL=redaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction.js","sourceRoot":"","sources":["../../src/utils/redaction.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,kBAAkB,GAAG;IACzB,iJAAiJ;IACjJ,gGAAgG;IAChG,gGAAgG;IAChG,oCAAoC;IACpC,gEAAgE,EAAE,OAAO;CAC1E,CAAC;AAEF,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,KAAK,MAAM,OAAO,IAAI,kBAAkB,EAAE,CAAC;QACzC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,MAAM,EAAE,EAAE;YACxD,oCAAoC;YACpC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;gBACvD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;gBACzB,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;oBACvB,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;gBACtC,CAAC;gBACD,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7D,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACvC,CAAC;YACD,OAAO,YAAY,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "port-doctor-cli",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "Developer-first diagnostic, troubleshooting, and forensic CLI for local development ports",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "bin": {
15
+ "port-doctor": "./bin/port-doctor.js"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "bin",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "engines": {
24
+ "node": ">=18.0.0"
25
+ },
26
+ "scripts": {
27
+ "build": "tsc",
28
+ "watch": "tsc --watch",
29
+ "test": "vitest run",
30
+ "test:watch": "vitest",
31
+ "prepack": "npm run build"
32
+ },
33
+ "keywords": [
34
+ "port",
35
+ "port-doctor",
36
+ "port-doctor-cli",
37
+ "port-killer",
38
+ "diagnostics",
39
+ "developer-tools",
40
+ "eaddrinuse",
41
+ "troubleshooting",
42
+ "process",
43
+ "git",
44
+ "cli"
45
+ ],
46
+ "author": "Gaurav Singh Negi",
47
+ "license": "MIT",
48
+ "dependencies": {
49
+ "picocolors": "^1.1.1"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "^20.17.0",
53
+ "typescript": "^5.6.3",
54
+ "vitest": "^2.1.8"
55
+ }
56
+ }