@hile/cli 1.1.12 → 1.1.14
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/dist/configs.d.ts +1 -0
- package/dist/configs.js +9 -1
- package/dist/index.js +3 -3
- package/package.json +3 -3
package/dist/configs.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function parseValue(raw: string): any;
|
|
1
2
|
export declare function listConfigs(): Promise<void>;
|
|
2
3
|
export declare function getConfig(namespace: string, json?: boolean): Promise<void>;
|
|
3
4
|
export declare function setConfig(namespace: string, keyvalue: string): Promise<void>;
|
package/dist/configs.js
CHANGED
|
@@ -2,7 +2,15 @@ import { getRegistryConfigsDir, namespaceToConfigFile, parseConfigFilename } fro
|
|
|
2
2
|
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, rmSync } from 'node:fs';
|
|
3
3
|
import { createInterface } from 'node:readline';
|
|
4
4
|
import YAML from 'yaml';
|
|
5
|
-
function parseValue(raw) {
|
|
5
|
+
export function parseValue(raw) {
|
|
6
|
+
// 以 { 或 [ 开头时尝试 JSON 解析
|
|
7
|
+
const first = raw.charCodeAt(0);
|
|
8
|
+
if (first === 0x7b /* { */ || first === 0x5b /* [ */) {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(raw);
|
|
11
|
+
}
|
|
12
|
+
catch { /* fall through — 不是合法 JSON 则当作字符串 */ }
|
|
13
|
+
}
|
|
6
14
|
if (raw === 'true')
|
|
7
15
|
return true;
|
|
8
16
|
if (raw === 'false')
|
package/dist/index.js
CHANGED
|
@@ -113,11 +113,11 @@ const registryCmd = program.command('registry');
|
|
|
113
113
|
registryCmd
|
|
114
114
|
.allowExcessArguments(true)
|
|
115
115
|
.option('--port <port>', '注册中心端口', '9876')
|
|
116
|
-
.option('--host <host>', '注册中心主机')
|
|
116
|
+
.option('--host <host>', '注册中心主机', '127.0.0.1')
|
|
117
117
|
.description('启动注册中心')
|
|
118
118
|
.action(async (options) => {
|
|
119
119
|
const port = options.port ? Number(options.port) : 9876;
|
|
120
|
-
const registry = new Registry({ advertiseHost: options.host
|
|
120
|
+
const registry = new Registry({ advertiseHost: options.host });
|
|
121
121
|
useExit(await registry.listen(port));
|
|
122
122
|
console.log(`+ [registry] started on port ${port}`);
|
|
123
123
|
});
|
|
@@ -135,7 +135,7 @@ configs.command('get <namespace>')
|
|
|
135
135
|
await getConfig(namespace, options.json);
|
|
136
136
|
});
|
|
137
137
|
configs.command('set <namespace> <keyvalue>')
|
|
138
|
-
.description('
|
|
138
|
+
.description('设置配置项。值以 { 或 [ 开头时自动 JSON 解析。示例: set my-svc port=8080 / set my-svc whitelist=\'["10.0.0.1","10.0.0.2"]\'')
|
|
139
139
|
.action(async (namespace, keyvalue) => {
|
|
140
140
|
await setConfig(namespace, keyvalue);
|
|
141
141
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hile/cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@hile/core": "^1.1.2",
|
|
32
|
-
"@hile/micro": "^1.0.
|
|
32
|
+
"@hile/micro": "^1.0.8",
|
|
33
33
|
"async-exit-hook": "^2.0.1",
|
|
34
34
|
"commander": "^14.0.3",
|
|
35
35
|
"glob": "^13.0.6",
|
|
36
36
|
"tsx": "^4.21.0",
|
|
37
37
|
"yaml": "^2.9.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "6c83f2e29de07a48e8467456b56351d304e45932"
|
|
40
40
|
}
|