je-cd 0.1.0 → 0.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.
|
@@ -11,7 +11,7 @@ var WinProcessManager = class {
|
|
|
11
11
|
name: "",
|
|
12
12
|
cpu: 0,
|
|
13
13
|
memory: 0,
|
|
14
|
-
port: c.localPort,
|
|
14
|
+
port: Number(c.localPort) || void 0,
|
|
15
15
|
state: c.state
|
|
16
16
|
}));
|
|
17
17
|
}
|
|
@@ -88,12 +88,16 @@ var WinProcessManager = class {
|
|
|
88
88
|
return list.slice(0, limit);
|
|
89
89
|
}
|
|
90
90
|
async getProcessStats() {
|
|
91
|
-
const processes = await
|
|
91
|
+
const [processes, load, mem] = await Promise.all([
|
|
92
|
+
si.processes(),
|
|
93
|
+
si.currentLoad(),
|
|
94
|
+
si.mem()
|
|
95
|
+
]);
|
|
92
96
|
return {
|
|
93
97
|
total: processes.all,
|
|
94
98
|
running: processes.running || processes.all,
|
|
95
|
-
cpuPercent: Math.round((
|
|
96
|
-
memoryGB: Math.round((
|
|
99
|
+
cpuPercent: Math.round((load.currentLoad ?? 0) * 10) / 10,
|
|
100
|
+
memoryGB: Math.round((mem.used ?? 0) / (1024 * 1024 * 1024) * 10) / 10
|
|
97
101
|
};
|
|
98
102
|
}
|
|
99
103
|
async listProcesses(nameFilter) {
|
|
@@ -148,9 +152,31 @@ var SystemNetworkManager = class {
|
|
|
148
152
|
};
|
|
149
153
|
}
|
|
150
154
|
async getDnsServers() {
|
|
155
|
+
if (process.platform === "win32") {
|
|
156
|
+
try {
|
|
157
|
+
const output = execSync2("ipconfig /all", { encoding: "utf8" });
|
|
158
|
+
const servers = [];
|
|
159
|
+
const re = /DNS Servers\s*\.+\s*:\s*([0-9.]+)/;
|
|
160
|
+
const lines = output.split("\n");
|
|
161
|
+
for (let i = 0; i < lines.length; i++) {
|
|
162
|
+
const m = lines[i].match(re);
|
|
163
|
+
if (m) {
|
|
164
|
+
servers.push(m[1].trim());
|
|
165
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
166
|
+
const cont = lines[j].trim();
|
|
167
|
+
if (/^[0-9.]+$/.test(cont)) servers.push(cont);
|
|
168
|
+
else break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return servers;
|
|
173
|
+
} catch {
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
151
177
|
try {
|
|
152
|
-
const
|
|
153
|
-
return
|
|
178
|
+
const output = execSync2("cat /etc/resolv.conf 2>/dev/null || true", { encoding: "utf8" });
|
|
179
|
+
return output.split("\n").map((l) => l.match(/^nameserver\s+(\S+)/i)).filter((m) => !!m).map((m) => m[1]);
|
|
154
180
|
} catch {
|
|
155
181
|
return [];
|
|
156
182
|
}
|
|
@@ -160,9 +186,9 @@ var SystemNetworkManager = class {
|
|
|
160
186
|
const networks = await si2.wifiConnections();
|
|
161
187
|
return (networks || []).map((n) => ({
|
|
162
188
|
ssid: n.ssid || "",
|
|
163
|
-
signal: n.
|
|
164
|
-
frequency: n.frequency
|
|
165
|
-
channel: n.channel
|
|
189
|
+
signal: n.signalLevel ?? 0,
|
|
190
|
+
frequency: n.frequency != null ? String(n.frequency) : "",
|
|
191
|
+
channel: n.channel ?? 0,
|
|
166
192
|
security: n.security || ""
|
|
167
193
|
}));
|
|
168
194
|
} catch {
|
|
@@ -216,8 +242,8 @@ var SystemNetworkManager = class {
|
|
|
216
242
|
async getConnections() {
|
|
217
243
|
const data = await si2.networkConnections();
|
|
218
244
|
return (data || []).map((c) => ({
|
|
219
|
-
localPort: c.localPort,
|
|
220
|
-
remotePort: c.
|
|
245
|
+
localPort: Number(c.localPort) || 0,
|
|
246
|
+
remotePort: Number(c.peerPort) || 0,
|
|
221
247
|
state: c.state,
|
|
222
248
|
pid: c.pid
|
|
223
249
|
}));
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
getNetworkManager,
|
|
8
8
|
getOsManager,
|
|
9
9
|
getProcessManager
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-U5O4CKS2.js";
|
|
11
11
|
|
|
12
12
|
// src/cli/router.ts
|
|
13
13
|
import chalk2 from "chalk";
|
|
@@ -406,7 +406,7 @@ var commandDef17 = {
|
|
|
406
406
|
|
|
407
407
|
// src/groups/w/proc/mem.ts
|
|
408
408
|
async function handler18(args) {
|
|
409
|
-
const { getProcessManager: getProcessManager2 } = await import("./adapter-
|
|
409
|
+
const { getProcessManager: getProcessManager2 } = await import("./adapter-EOCZ5CH4.js");
|
|
410
410
|
const pm = getProcessManager2();
|
|
411
411
|
const limit = parseInt(args[0], 10) || 20;
|
|
412
412
|
const procs = await pm.getTopProcesses("memory", limit);
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "je-cd",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "j 命令套件 — 跨平台系统快捷命令集",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"jc": "dist/index.js"
|
|
8
8
|
},
|
|
9
|
-
"files": [
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
10
12
|
"scripts": {
|
|
11
13
|
"build": "tsup",
|
|
12
14
|
"dev": "tsup --watch",
|
|
@@ -26,5 +28,9 @@
|
|
|
26
28
|
"vitest": "^2.1.0"
|
|
27
29
|
},
|
|
28
30
|
"author": "joke-lx",
|
|
29
|
-
"license": "MIT"
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/joke-lx/jc.git"
|
|
35
|
+
}
|
|
30
36
|
}
|