diff --git a/CHANGELOG.md b/CHANGELOG.md index 968f9d5..e8ec33b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.8.0 + +### Removed + +- **`init` 命令**:移除 `larkDocx2md init` 凭证初始化入口;`download` / `get-titles` 不再读取已存储凭证(macOS Keychain 或 `~/.lark-docx2md/auth.json`),仅支持命令行参数与环境变量 + ## 0.7.0 ### Features diff --git a/README.md b/README.md index cf860bb..072f3d4 100644 --- a/README.md +++ b/README.md @@ -34,15 +34,7 @@ export LARK_DOCX2MD_APP_SECRET= npx -y lark-docx2md@latest download --url ``` -或使用 `init` 命令一键配置并持久化凭证(macOS 存入系统 Keychain,其他系统存入 `~/.lark-docx2md/auth.json`): - -```bash -npx -y lark-docx2md@latest init -``` - -完成后即可直接使用 `download` / `get-titles`,无需每次传入 `--app-id` / `--app-secret` 或设置环境变量。 - -> **凭证优先级**:命令行参数 > 已存储凭证(macOS: Keychain;其他: auth.json)> 环境变量 +> **凭证优先级**:命令行参数 > 环境变量 ## 参数 @@ -71,21 +63,6 @@ npx -y lark-docx2md@latest init > - `--max-output-lines`:仅在未指定 `--filter-title` / `--filter-title-block-id` 时生效;纯 Markdown 阶段先检查一次,图片、画板、表格等解析完成后再检查一次。超过限制时直接报错,提示先用 `get-titles` 获取标题,再补充标题过滤参数重试。 > - **命中深层标题时自动注入父级标题(仅 heading 块本身)**:两个过滤参数均会按文档顺序补齐包含路径上的顶层→该标题的所有祖先标题,以保留章节层级上下文;不会引入旁支兄弟或伪造跳级。 -## 子命令:`init` - -交互式配置飞书应用凭证。通过飞书一键应用流程注册并验证凭证,macOS 保存至系统 Keychain,其他系统保存至 `~/.lark-docx2md/auth.json`。 - -```bash -npx -y lark-docx2md@latest init -``` - -| 参数 | 说明 | 默认值 | -|------|------|--------| -| `--no-probe` | 跳过凭证验证步骤 | `false` | -| `--timeout ` | 请求超时(毫秒) | `30000` | - -已配置时再次运行可替换或移除现有凭证。 - ## 子命令:`get-titles` 列出 docx/wiki 文档全部标题(不支持 sheets),配合 `--filter-title-block-id` 使用可避开同名歧义。 diff --git a/package.json b/package.json index a92ac92..d04984e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lark-docx2md", - "version": "0.7.0", + "version": "0.8.0", "description": "Convert Lark/Feishu documents to Markdown", "type": "module", "main": "./dist/converter.js", diff --git a/src/cli/program.ts b/src/cli/program.ts index 3288171..4f4a1fc 100644 --- a/src/cli/program.ts +++ b/src/cli/program.ts @@ -1,6 +1,5 @@ import { Command } from 'commander'; import { handleDownloadCommand, handleGetTitlesCommand } from './handlers.js'; -import { handleInitCommand, type InitRawOptions } from './init-handler.js'; import type { DownloadRawOptions, GetTitlesRawOptions } from './options.js'; export function createProgram (): Command { @@ -43,15 +42,6 @@ export function createProgram (): Command { handleGetTitlesCommand(positionalUrl, opts, message => program.error(message)) )); - program - .command('init') - .description('管理应用凭证:新增、替换或移除已存储的飞书应用凭证') - .option('--no-probe', '注册后跳过 tenant_access_token 验证') - .option('--timeout ', '每次请求超时时间(毫秒,默认 30000)') - .action((opts: InitRawOptions) => ( - handleInitCommand(opts, message => program.error(message)) - )); - return program; } diff --git a/src/lib/client.ts b/src/lib/client.ts index c17cb4e..8579a4d 100644 --- a/src/lib/client.ts +++ b/src/lib/client.ts @@ -2,8 +2,6 @@ import * as lark from '@larksuiteoapi/node-sdk'; import { LoggerLevel } from '@larksuiteoapi/node-sdk'; import * as fs from 'node:fs'; import * as path from 'node:path'; -import { platform } from 'node:os'; -import { getStoredCredentials } from './auth-store.js'; import type { DocInfo, DocxBlock, WhiteboardNode } from './types.js'; const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)); @@ -12,29 +10,15 @@ const RATE_LIMIT_RETRY_DELAY = 500; /** * 创建飞书 API 客户端。 - * 凭证优先级:传入参数(CLI)> 已存储凭证(macOS: Keychain; 其他: auth.json 明文)> 环境变量。 + * 凭证优先级:传入参数(CLI)> 环境变量。 */ export async function createClient (cliAppId?: string, cliAppSecret?: string, loggerLevel: LoggerLevel = LoggerLevel.warn) { - let appId = cliAppId; - let appSecret = cliAppSecret; + const appId = cliAppId || process.env.LARK_DOCX2MD_APP_ID; + const appSecret = cliAppSecret || process.env.LARK_DOCX2MD_APP_SECRET; if (!appId || !appSecret) { - const stored = await getStoredCredentials(); - appId = appId || stored.appId; - appSecret = appSecret || stored.appSecret; - } - - if (!appId || !appSecret) { - appId = appId || process.env.LARK_DOCX2MD_APP_ID; - appSecret = appSecret || process.env.LARK_DOCX2MD_APP_SECRET; - } - - if (!appId || !appSecret) { - const initHint = platform() === 'darwin' - ? ', run "lark-docx2md init" to store in macOS Keychain,' - : ', run "lark-docx2md init" to store in auth.json,'; throw new Error( - `Missing credentials: pass --app-id/--app-secret${initHint} or set LARK_DOCX2MD_APP_ID/LARK_DOCX2MD_APP_SECRET`, + 'Missing credentials: pass --app-id/--app-secret or set LARK_DOCX2MD_APP_ID/LARK_DOCX2MD_APP_SECRET', ); }