### Start Documentation Development Server Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/doc/dev/environment.md Run this command to start the VitePress development server for editing documentation. ```shell pnpm docs:dev ``` -------------------------------- ### Install Dependencies Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/README.md Commands to install the required pnpm version and project dependencies. ```shell npm install --global pnpm@11.5.0 pnpm install ``` -------------------------------- ### Build and Verify Documentation Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/doc/dev/environment.md Execute these commands to perform a production build, verify the generated site, and preview the output locally before submission. ```shell pnpm docs:build pnpm docs:check pnpm docs:preview ``` -------------------------------- ### Build Root Project Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/doc/dev/maintenance.md Perform a full build of the root project. ```shell pnpm build ``` -------------------------------- ### Common Development Commands Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/README.md Standard commands for building, watching, and running the application. ```shell pnpm build pnpm watch pnpm startgui pnpm start pnpm buildgui pnpm zhihuhelp --help ``` -------------------------------- ### Verify Documentation or Frontend Changes Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/doc/dev/maintenance.md Run TypeScript checks and build the client application to verify changes. ```shell cd client pnpm exec tsc --noEmit pnpm build ``` -------------------------------- ### Documentation Site Development Commands Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/README.md Commands for developing, building, and previewing the documentation site locally. ```shell pnpm docs:dev pnpm docs:build pnpm docs:check pnpm docs:preview ``` -------------------------------- ### Run CLI Debugging Workflow Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/doc/dev/environment.md Build the project and execute the CLI with a specified configuration file. ```shell pnpm build pnpm zhihuhelp run --config config.json ``` -------------------------------- ### 定义CLI工作流闭环 Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/doc/项目文档/架构规范化改造方案.md 描述了命令行工具执行的推荐顺序。 ```text init -> fetch -> persist -> generate -> output ``` -------------------------------- ### Update Electron Static Assets Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/doc/dev/maintenance.md Build the GUI components for Electron. ```shell pnpm buildgui ``` -------------------------------- ### 执行 TSLint 代码检查与自动修复 Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/doc/项目文档/ts学习笔记.md 使用项目本地的 TSLint 二进制文件对 src 目录下的所有文件进行检查并尝试自动修复。 ```bash ./node_modules/.bin/tslint -c tslint.json src/**/* --fix ``` -------------------------------- ### Fetch and Persistence Workflow Diagram Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/doc/dev/workflows.md A Mermaid flowchart illustrating the task processing pipeline from configuration to terminal state. ```mermaid flowchart TD Config["TaskConfig.tasks"] --> Skip{"skipFetch?"} Skip -->|是| SkipEvent["fetch.skip"] Skip -->|否| Merge["按 taskType 分组并按 id 去重"] Merge --> Router{"createBatchFetcher(taskType)"} Router -->|不支持| Unsupported["记录 fetch.skip"] Router -->|支持| Batch["Batch Fetcher"] Batch --> Meta["读取作者/容器/单条元信息"] Batch --> Page["按 offset、时间段或 next 分页"] Page --> Queue["受并发与超时约束的任务队列"] Queue --> Single["Single API"] Meta --> Single Single --> HTTP["HTTP + js-rpc 签名"] HTTP --> Zhihu["知乎 API"] Single --> Persist["Model 持久化"] Persist --> DB[("SQLite")] Page --> Relation["写入关系表并收集子实体 id"] Relation --> Child["扩展 Answer / Article / Question / Pin 子任务"] Child --> Batch DB --> Summary["成功数、失败数、失败实体"] Summary --> Terminal{"阶段终态"} Terminal --> Success["fetch.success"] Terminal --> Partial["fetch.partial_success"] Terminal --> Failure["fetch.failure"] ``` -------------------------------- ### RunTaskWorkflow 时序图 Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/doc/dev/workflows.md 展示了 GUI 和 CLI 调用 RunTaskWorkflow 的执行流程,包括初始化、抓取和生成阶段的交互逻辑。 ```mermaid sequenceDiagram participant Caller as GUI IPC / CLI participant Workflow as RunTaskWorkflow participant Context as RunContext participant Config as TaskConfig Parser participant Init as InitWorkflow participant Fetch as FetchWorkflow participant Generate as GenerateWorkflow participant Log as Structured Logger Caller->>Workflow: init / fetch / generate / run(options) Workflow->>Context: createRunContext(options) Context->>Log: config.context.created Workflow->>Log: workflow.start alt run Workflow->>Config: ensureTaskConfigFile Workflow->>Init: execute(rebase, context) Workflow->>Config: readTaskConfig Workflow->>Fetch: execute(config, context) Workflow->>Generate: execute(config, context) else init Workflow->>Config: ensureTaskConfigFile Workflow->>Init: execute(rebase, context) else fetch Workflow->>Config: readTaskConfig Workflow->>Fetch: execute(config, context) else generate Workflow->>Config: readTaskConfig Workflow->>Generate: execute(config, context) end alt 全部成功 Workflow->>Log: workflow.success Workflow-->>Caller: RunContext / success else 存在可恢复的局部失败 Workflow->>Log: workflow.partial_success Workflow-->>Caller: 结果与失败摘要 else 不可恢复错误 Workflow->>Log: workflow.failure Workflow-->>Caller: throw error / 非零退出 end ``` -------------------------------- ### 测试执行命令 Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/doc/task/问题描述-6/问题6.md 项目根目录提供的测试执行命令,涵盖了从单元测试到在线冒烟测试的完整流程。 ```bash pnpm test ``` ```bash pnpm test:unit ``` ```bash pnpm test:client ``` ```bash pnpm test:integration ``` ```bash pnpm test:online ``` ```bash pnpm fixtures:refresh ``` -------------------------------- ### 配置CLI命令示例 Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/doc/项目文档/架构规范化改造方案.md 展示了推荐的命令行调用方式,强调直接进入应用工作流。 ```shell pnpm zhihuhelp init pnpm zhihuhelp run --config config.json pnpm zhihuhelp fetch --config config.json pnpm zhihuhelp generate --config config.json ``` -------------------------------- ### Run root project type check and build Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/doc/dev/environment.md Executes TypeScript type checking and production build for the root project. ```shell pnpm exec tsc --noEmit pnpm build ``` -------------------------------- ### Run Tests Source: https://github.com/yaozeyuan/zhihuhelp/blob/master/doc/dev/maintenance.md Execute tests to verify behavior, logging, or data changes. ```shell pnpm test ```