@lionad/port-key 0.1.6 → 0.2.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 +31 -5
- package/package.json +7 -6
- package/src/port-key.js +4 -23
package/README.md
CHANGED
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
<strong>PortKey:A Simple, Practical Port Naming Strategy</strong>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
+
<p align="center">
|
|
12
|
+
<!-- LANGUAGES=("cn" "es" "fr" "de" "ja" "ko" "ru" "ar" "pt" "it") -->
|
|
13
|
+
<a href="./docs/README.cn.md">中文</a> | <a href="./docs/README.es.md">Español</a> | <a href="./docs/README.fr.md">Français</a> | <a href="./docs/README.de.md">Deutsch</a> | <a href="./docs/README.ja.md">日本語</a> | <a href="./docs/README.ko.md">한국어</a> | <a href="./docs/README.ru.md">Русский</a> | <a href="./docs/README.ar.md">العربية</a> | <a href="./docs/README.pt.md">Português</a> | <a href="./docs/README.it.md">Italiano</a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
11
16
|
## Brief
|
|
12
17
|
|
|
13
18
|
Generate ports with a letter-to-number keyboard mapping
|
|
@@ -25,7 +30,7 @@ For example, I have more than ten Nuxt apps on my machine. If they all default t
|
|
|
25
30
|
|
|
26
31
|
Instead of picking random numbers, map the **project name to numbers based on the keyboard**, so the port is *readable* and *memorable*.
|
|
27
32
|
|
|
28
|
-
As long as the result is within the valid port range (**
|
|
33
|
+
As long as the result is within the valid port range (**1024–65535**) and doesn’t hit reserved/system ports, you can just use it.
|
|
29
34
|
|
|
30
35
|
More specifically: using a standard QWERTY keyboard, map each letter to a single digit based on its **row/column position**.
|
|
31
36
|
|
|
@@ -53,18 +58,39 @@ If a project needs multiple ports (frontend, backend, database, etc.), pick **on
|
|
|
53
58
|
|
|
54
59
|
### Valid port range
|
|
55
60
|
|
|
56
|
-
- Ports must be within **
|
|
57
|
-
-
|
|
58
|
-
-
|
|
61
|
+
- Ports must be within **1024–65535** (System ports 0-1023 are blocked).
|
|
62
|
+
- **System Ports (0-1023)**: Assigned by IETF. Strictly blocked.
|
|
63
|
+
- **User Ports (1024-49151)**: Assigned by IANA. Use with caution as they might conflict with registered services.
|
|
64
|
+
- **Dynamic/Private Ports (49152-65535)**: Not assigned. Safest for private or dynamic use.
|
|
59
65
|
|
|
60
66
|
---
|
|
61
67
|
|
|
62
68
|
## How to use
|
|
63
69
|
|
|
70
|
+
Simple command:
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
npx -y @lionad/port-key <your-project-name>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Or you want a stdio MCP server:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
npx -y @lionad/port-key-mcp
|
|
64
80
|
```
|
|
65
|
-
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"mcpServers": {
|
|
85
|
+
"port-key": {
|
|
86
|
+
"command": "npx",
|
|
87
|
+
"args": ["@lionad/port-key-mcp"]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
66
91
|
```
|
|
67
92
|
|
|
93
|
+
|
|
68
94
|
### CLI options
|
|
69
95
|
|
|
70
96
|
- `-m, --map <object>`: custom mapping (JSON or JS-like object literal)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lionad/port-key",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A simple, practical port naming strategy",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./src/port-key.d.ts",
|
|
@@ -30,10 +30,6 @@
|
|
|
30
30
|
"README.md",
|
|
31
31
|
"LICENSE"
|
|
32
32
|
],
|
|
33
|
-
"scripts": {
|
|
34
|
-
"test": "vitest run",
|
|
35
|
-
"test:watch": "vitest"
|
|
36
|
-
},
|
|
37
33
|
"author": "Lionad",
|
|
38
34
|
"license": "ISC",
|
|
39
35
|
"repository": {
|
|
@@ -53,5 +49,10 @@
|
|
|
53
49
|
"dependencies": {},
|
|
54
50
|
"publishConfig": {
|
|
55
51
|
"registry": "https://registry.npmjs.org/"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "echo 'skip build steps in packages/core'",
|
|
55
|
+
"test": "vitest run",
|
|
56
|
+
"test:watch": "vitest"
|
|
56
57
|
}
|
|
57
|
-
}
|
|
58
|
+
}
|
package/src/port-key.js
CHANGED
|
@@ -14,30 +14,8 @@ const DEFAULT_MAP = Object.freeze({
|
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
const DEFAULT_BLOCKED_PORTS = Object.freeze(
|
|
17
|
+
// well-known application ports
|
|
17
18
|
new Set([
|
|
18
|
-
0,
|
|
19
|
-
20,
|
|
20
|
-
21,
|
|
21
|
-
22,
|
|
22
|
-
23,
|
|
23
|
-
25,
|
|
24
|
-
53,
|
|
25
|
-
67,
|
|
26
|
-
68,
|
|
27
|
-
80,
|
|
28
|
-
110,
|
|
29
|
-
123,
|
|
30
|
-
143,
|
|
31
|
-
161,
|
|
32
|
-
162,
|
|
33
|
-
389,
|
|
34
|
-
443,
|
|
35
|
-
445,
|
|
36
|
-
465,
|
|
37
|
-
587,
|
|
38
|
-
636,
|
|
39
|
-
993,
|
|
40
|
-
995,
|
|
41
19
|
3000,
|
|
42
20
|
3001,
|
|
43
21
|
5000,
|
|
@@ -105,6 +83,8 @@ function isValidPort(port) {
|
|
|
105
83
|
}
|
|
106
84
|
|
|
107
85
|
function isPortBlocked(port, blockedPorts) {
|
|
86
|
+
// System Ports (0-1023) are assigned by IETF and should not be used.
|
|
87
|
+
if (port < 1024) return true;
|
|
108
88
|
if (blockedPorts && typeof blockedPorts.has === 'function') {
|
|
109
89
|
return blockedPorts.has(port);
|
|
110
90
|
}
|
|
@@ -219,6 +199,7 @@ export {
|
|
|
219
199
|
normalizeInput,
|
|
220
200
|
mapToDigits,
|
|
221
201
|
isValidPort,
|
|
202
|
+
isPortBlocked,
|
|
222
203
|
pickPortFromDigits,
|
|
223
204
|
mapToPort,
|
|
224
205
|
parseUserMap,
|