@hile/cli 3.0.2 → 3.0.4
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.
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { InvalidArgumentError } from 'commander';
|
|
2
|
+
function parsePositiveInteger(value) {
|
|
3
|
+
const parsed = Number(value);
|
|
4
|
+
if (!Number.isFinite(parsed) || parsed !== Math.trunc(parsed) || parsed <= 0) {
|
|
5
|
+
throw new InvalidArgumentError('must be a positive integer');
|
|
6
|
+
}
|
|
7
|
+
return parsed;
|
|
8
|
+
}
|
|
9
|
+
function parsePort(value) {
|
|
10
|
+
const parsed = Number(value);
|
|
11
|
+
if (!Number.isFinite(parsed) || parsed !== Math.trunc(parsed) || parsed < 1 || parsed > 65535) {
|
|
12
|
+
throw new InvalidArgumentError('must be an integer between 1 and 65535');
|
|
13
|
+
}
|
|
14
|
+
return parsed;
|
|
15
|
+
}
|
|
16
|
+
function parseScale(value) {
|
|
17
|
+
if (value !== 'compact' && value !== 'normal' && value !== 'large') {
|
|
18
|
+
throw new InvalidArgumentError('must be compact, normal, or large');
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
export function registerRegistryMonitorCommand(registryCmd) {
|
|
23
|
+
registryCmd
|
|
24
|
+
.command('monitor')
|
|
25
|
+
.option('--host <host>', '注册中心主机', '127.0.0.1')
|
|
26
|
+
.option('--port <port>', '注册中心端口', parsePort, 9876)
|
|
27
|
+
.option('--interval <ms>', '刷新间隔,单位毫秒', parsePositiveInteger, 1000)
|
|
28
|
+
.option('--scale <mode>', '界面缩放:compact、normal、large', parseScale, 'normal')
|
|
29
|
+
.description('实时监控已有 Hile 注册中心')
|
|
30
|
+
.action(async (options) => {
|
|
31
|
+
const { runRegistryMonitor } = await import('@hile/registry-monitor');
|
|
32
|
+
await runRegistryMonitor({
|
|
33
|
+
host: options.host,
|
|
34
|
+
port: options.port,
|
|
35
|
+
interval: options.interval,
|
|
36
|
+
scale: options.scale,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hile/cli",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@hile/bootstrap": "^3.0.0",
|
|
32
32
|
"@hile/logger": "^3.0.0",
|
|
33
|
-
"@hile/micro": "^3.0.
|
|
33
|
+
"@hile/micro": "^3.0.6",
|
|
34
34
|
"commander": "^14.0.3",
|
|
35
35
|
"pino-pretty": "^13.1.3",
|
|
36
36
|
"yaml": "^2.9.0"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "f0ca6e772602138dd50bf5acd2f9d940b4fe505e"
|
|
39
39
|
}
|