mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
feat: The command "config show" does not display the "region" field, but displays all fields in the "config.json" file
This commit is contained in:
@@ -19,25 +19,21 @@ export default defineCommand({
|
||||
const format = detectOutputFormat(config.output);
|
||||
|
||||
const result: Record<string, unknown> = {
|
||||
region: config.region,
|
||||
...file,
|
||||
base_url: config.baseUrl,
|
||||
output: config.output,
|
||||
timeout: config.timeout,
|
||||
config_file: getConfigPath(),
|
||||
};
|
||||
|
||||
// Mask API key if present
|
||||
if (file.api_key) {
|
||||
result.api_key = maskToken(file.api_key);
|
||||
if (typeof result.api_key === "string") result.api_key = maskToken(result.api_key);
|
||||
if (typeof result.access_token === "string")
|
||||
result.access_token = maskToken(result.access_token);
|
||||
if (typeof result.access_key_id === "string")
|
||||
result.access_key_id = maskToken(result.access_key_id);
|
||||
if (typeof result.access_key_secret === "string") {
|
||||
result.access_key_secret = maskToken(result.access_key_secret);
|
||||
}
|
||||
if (file.access_token) {
|
||||
result.access_token = maskToken(file.access_token);
|
||||
}
|
||||
|
||||
// Default models
|
||||
if (file.default_text_model) result.default_text_model = file.default_text_model;
|
||||
if (file.default_video_model) result.default_video_model = file.default_video_model;
|
||||
if (file.default_image_model) result.default_image_model = file.default_image_model;
|
||||
|
||||
emitResult(result, format);
|
||||
},
|
||||
|
||||
@@ -5,7 +5,6 @@ const reset = "\x1b[0m";
|
||||
const dim = "\x1b[2m";
|
||||
const bold = "\x1b[1m";
|
||||
const mmBlue = "\x1b[38;2;43;82;255m";
|
||||
const mmCyan = "\x1b[38;2;6;184;212m";
|
||||
const mmPink = "\x1b[38;2;236;72;153m";
|
||||
|
||||
function tildePath(p: string): string {
|
||||
@@ -20,7 +19,6 @@ export function maybeShowStatusBar(
|
||||
if (config.quiet || !process.stderr.isTTY) return;
|
||||
|
||||
const filePath = config.configPath ? tildePath(config.configPath) : "~/.bailian/config.json";
|
||||
const regionSrc = config.fileRegion ? `${config.fileRegion} (file)` : "cn (default)";
|
||||
const authTag = resolved
|
||||
? `${resolved.source} · ${resolved.method}`
|
||||
: config.apiKey
|
||||
@@ -32,8 +30,6 @@ export function maybeShowStatusBar(
|
||||
`${bold}${mmBlue}BAILIAN${reset} ` +
|
||||
`${dim}${filePath}${reset} ` +
|
||||
`${dim}|${reset} ` +
|
||||
`${dim}Region:${reset} ${mmCyan}${regionSrc}${reset} ` +
|
||||
`${dim}|${reset} ` +
|
||||
`${dim}Auth:${reset} ${mmPink}${maskedKey}${reset} ${dim}${authTag}${reset}\n`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -41,12 +41,10 @@ describe("e2e: config", () => {
|
||||
]);
|
||||
expect(exitCode, stderr).toBe(0);
|
||||
const data = parseStdoutJson<{
|
||||
region?: string;
|
||||
config_file?: string;
|
||||
base_url?: string;
|
||||
timeout?: number;
|
||||
}>(stdout);
|
||||
expect(data.region).toBeDefined();
|
||||
expect(data.config_file).toBeDefined();
|
||||
expect(data.base_url).toBeDefined();
|
||||
expect(data.timeout).toBeDefined();
|
||||
@@ -62,7 +60,7 @@ describe("e2e: config", () => {
|
||||
"--no-color",
|
||||
]);
|
||||
expect(exitCode, stderr).toBe(0);
|
||||
expect(stdout).toMatch(/region|config_file|timeout|base_url/i);
|
||||
expect(stdout).toMatch(/config_file|timeout|base_url/i);
|
||||
});
|
||||
|
||||
test("config set 缺少 --key / --value 时退出为用法错误 (2)", async () => {
|
||||
@@ -85,20 +83,6 @@ describe("e2e: config", () => {
|
||||
expect(stderr).toMatch(/Invalid config key|not-a-real-key/i);
|
||||
});
|
||||
|
||||
test("config set 非法 region", async () => {
|
||||
const { stderr, exitCode } = await runCli([
|
||||
"config",
|
||||
"set",
|
||||
"--non-interactive",
|
||||
"--key",
|
||||
"region",
|
||||
"--value",
|
||||
"invalid-region",
|
||||
]);
|
||||
expect(exitCode).toBe(2);
|
||||
expect(stderr).toMatch(/Invalid region|cn, us, intl/i);
|
||||
});
|
||||
|
||||
test("config set 非法 output", async () => {
|
||||
const { stderr, exitCode } = await runCli([
|
||||
"config",
|
||||
|
||||
Generated
+4
@@ -28,6 +28,10 @@ catalogs:
|
||||
specifier: ^2.8.3
|
||||
version: 2.8.3
|
||||
|
||||
overrides:
|
||||
vite: npm:@voidzero-dev/vite-plus-core@latest
|
||||
vitest: npm:@voidzero-dev/vite-plus-test@latest
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
|
||||
Reference in New Issue
Block a user