Skip to content

Commit ac8cee2

Browse files
committed
fix: fixed e2e error about import
1 parent a1fbc1f commit ac8cee2

11 files changed

Lines changed: 18 additions & 14 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ monorepo 多包结构:
1515
### E2E 测试分布
1616

1717
- 契约 e2e(help / dry-run / 真实集成): `packages/commands/tests/e2e/`
18-
- e2e 基建(`createCliRunner` 等): `packages/commands/tests/e2e/core/`(export `bailian-cli-commands/e2e`)
18+
- e2e 基建(`createCliRunner` 等): `packages/commands/tests/e2e/core/`cli/rag 以相对路径引用)
1919
- 产品 smoke: `packages/cli/tests/e2e/smoke.e2e.test.ts``packages/rag/tests/e2e/smoke.e2e.test.ts`
2020
- 一次跑全量 e2e: 根目录 `pnpm test:e2e`
2121

docs/agents/cli-e2e-tests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ E2E 按包分层,与命令实现 / 产品入口解耦:
2222
## 文件与工具
2323

2424
- **契约 e2e 路径**`packages/commands/tests/e2e/<kebab-topic>.e2e.test.ts`
25-
- **框架**`vite-plus/test`;契约测试 `runCli` from `./setup.ts`;cli/rag smoke from `./setup.ts`(内部 `import from "bailian-cli-commands/e2e"`
25+
- **框架**`vite-plus/test`;契约测试 `runCli` from `./setup.ts`;cli/rag smoke 通过相对路径引用 `packages/commands/tests/e2e/core/`
2626
- **解析 JSON stdout**`parseStdoutJson`;输出目录:`makeE2eOutputDir(e2eLabelFromMetaUrl(import.meta.url))`
2727
- **长任务**`cliTimeoutPrefix()`;视频用例加 `test(..., 3_600_000)` 等显式超时
2828

packages/cli/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createCli } from "bailian-cli-runtime";
22
import { commands } from "./commands.ts";
33
import pkg from "../package.json" with { type: "json" };
44

5-
createCli(commands, {
5+
void createCli(commands, {
66
binName: "bl",
77
version: pkg.version,
88
clientName: "bailian-cli",

packages/cli/tests/e2e/setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { join } from "path";
22
import { fileURLToPath } from "url";
3-
import { createCliRunner } from "bailian-cli-commands/e2e";
3+
import { createCliRunner, type RunCliFn } from "../../../commands/tests/e2e/core/index.ts";
44

55
const cliRoot = join(fileURLToPath(new URL(".", import.meta.url)), "..", "..");
66
const mainTs = join(cliRoot, "src", "main.ts");
@@ -11,4 +11,4 @@ const runner = createCliRunner({
1111
binName: "bl",
1212
});
1313

14-
export const runCli = runner.runCli;
14+
export const runCli: RunCliFn = runner.runCli;

packages/commands/tests/e2e/core/cli-runner.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ export interface RunCliResult {
1616
exitCode: number;
1717
}
1818

19+
export type RunCliFn = (args: string[], envOverrides?: NodeJS.ProcessEnv) => Promise<RunCliResult>;
20+
1921
/**
2022
* 工厂:绑定 CLI 入口后返回 `runCli`。
2123
* request_id 等诊断信息在 stderr;`--output json` 时 JSON 在 stdout。
2224
*/
2325
export function createCliRunner(target: CliTarget): {
24-
runCli: (args: string[], envOverrides?: NodeJS.ProcessEnv) => Promise<RunCliResult>;
26+
runCli: RunCliFn;
2527
binName: string;
2628
} {
2729
const { entry, cwd, binName } = target;

packages/commands/tests/e2e/core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { createCliRunner, type CliTarget, type RunCliResult } from "./cli-runner.ts";
1+
export { createCliRunner, type CliTarget, type RunCliFn, type RunCliResult } from "./cli-runner.ts";
22
export {
33
cliTimeoutPrefix,
44
cliTimeoutSeconds,

packages/commands/tests/e2e/setup.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { join } from "path";
22
import { fileURLToPath } from "url";
3-
import { createCliRunner } from "./core/cli-runner.ts";
3+
import { createCliRunner, type RunCliFn } from "./core/cli-runner.ts";
44

55
export {
66
cliTimeoutPrefix,
@@ -17,6 +17,7 @@ export {
1717
isKnowledgeAkSkReady,
1818
isKnowledgeE2EReady,
1919
createCliRunner,
20+
type RunCliFn,
2021
} from "./core/index.ts";
2122

2223
const commandsRoot = join(fileURLToPath(new URL(".", import.meta.url)), "..", "..");
@@ -28,4 +29,4 @@ const runner = createCliRunner({
2829
binName: "bl",
2930
});
3031

31-
export const runCli = runner.runCli;
32+
export const runCli: RunCliFn = runner.runCli;

packages/commands/tests/fixtures/test-cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createCli } from "bailian-cli-runtime";
2-
import { commands } from "../../src/index.ts";
2+
import { commands } from "../../../cli/src/commands.ts";
33

44
// 契约 e2e 专用 canonical 入口:全量 commands,与 bl 命令面一致。
55
void createCli(commands, {

packages/core/src/console/gateway.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ export async function callConsoleGateway(
142142

143143
const innerData = json.data as Record<string, unknown> | undefined;
144144
if (innerData?.success === false && innerData.errorCode) {
145-
const errorCode = String(innerData.errorCode);
145+
const raw = innerData.errorCode;
146+
const errorCode = typeof raw === "string" ? raw : JSON.stringify(raw);
146147
const notLogined = errorCode.includes("NotLogined");
147148
const errorMsg = typeof innerData.errorMsg === "string" ? innerData.errorMsg : undefined;
148149
throw new BailianError(

packages/rag/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const commands: Record<string, Command> = {
4242
retrieve: knowledgeRetrieve,
4343
};
4444

45-
createCli(commands, {
45+
void createCli(commands, {
4646
binName: "rag",
4747
version: pkg.version,
4848
clientName: "rag-cli",

0 commit comments

Comments
 (0)