LetTTGACO / elog

Markdown 批量导出工具、开放式跨平台博客解决方案,随意组合写作平台(语雀/Notion/FlowUs/飞书/我来Wolai)和博客平台(Hexo/Vitepress/Halo/Confluence/WordPress等)
https://elog.1874.cool
MIT License
1.46k stars 81 forks source link

同步飞书知识库时 “执行TypeScript脚本 下载出错: Cannot read properties of undefined (reading 'elements')” #85

Closed zh-d-d closed 2 months ago

zh-d-d commented 5 months ago

你当前使用的Elog版本

0.14.1

Elog配置文件

module.exports = {
  write: {
    platform: 'feishu',
    yuque: {
      token: process.env.YUQUE_TOKEN,
      login: process.env.YUQUE_LOGIN,
      repo: process.env.YUQUE_REPO,
      onlyPublic: false,
      onlyPublished: true,
    },
    'yuque-pwd': {
      username: process.env.YUQUE_USERNAME,
      password: process.env.YUQUE_PASSWORD,
      login: process.env.YUQUE_LOGIN,
      repo: process.env.YUQUE_REPO,
      onlyPublic: false,
      onlyPublished: true,
    },
    notion: {
      token: process.env.NOTION_TOKEN,
      databaseId: process.env.NOTION_DATABASE_ID,
      filter: false, // {property: 'status', select: {equals: '已发布'}}
    },
    feishu: {
      type: 'wiki',
      wikiId: process.env.FEISHU_WIKI_ID,
      folderToken: process.env.FEISHU_FOLDER_TOKEN,
      appId: process.env.FEISHU_APP_ID,
      appSecret: process.env.FEISHU_APP_SECRET,
      disableParentDoc:true
    },
    flowus: {
      tablePageId: process.env.FLOWUS_TABLE_PAGE_ID,
      filter: false, // {property: 'status',value: '已发布'}
    },
    wolai: {
      token: process.env.WOLAI_TOKEN,
      pageId: process.env.WOLAI_PAGE_ID,
    }
  },
  deploy: {
    platform: 'local',
    local: {
      outputDir: './docs',
      filename: 'title',
      format: 'markdown',
    },
    halo: {
      endpoint: process.env.HALO_ENDPOINT,
      token: process.env.HALO_TOKEN,
      policyName: process.env.HALO_POLICY_NAME,
      rowType: 'html',
      needUploadImage: true,
    },
    confluence: {
      user: process.env.CONFLUENCE_USER,
      password: process.env.WORDPRESS_PASSWORD,
      endpoint: process.env.WORDPRESS_ENDPOINT,
      spaceKey: process.env.CONFLUENCE_SPACE_KEY,
      rootPageId: process.env.CONFLUENCE_ROOT_PAGE_ID, // 可选
    },
    wordpress: {
      username: process.env.WORDPRESS_USERNAME,
      password: process.env.WORDPRESS_PASSWORD,
      endpoint: process.env.WORDPRESS_ENDPOINT,
    }
  },
  image: {
    enable: true,
    platform: 'local',
    local: {
      outputDir: './docs/images',
      prefixKey: '/images',
      pathFollowDoc: true,
    },
    oss: {
      secretId: process.env.OSS_SECRET_ID,
      secretKey: process.env.OSS_SECRET_KEY,
      bucket: process.env.OSS_BUCKET,
      region: process.env.OSS_REGION,
      host: process.env.OSS_HOST,
      prefixKey: '',
    },
    cos: {
      secretId: process.env.COS_SECRET_ID,
      secretKey: process.env.COS_SECRET_KEY,
      bucket: process.env.COS_BUCKET,
      region: process.env.COS_REGION,
      host: process.env.COS_HOST,
      prefixKey: '',
    },
    qiniu: {
      secretId: process.env.QINIU_SECRET_ID,
      secretKey: process.env.QINIU_SECRET_KEY,
      bucket: process.env.QINIU_BUCKET,
      region: process.env.QINIU_REGION,
      host: process.env.QINIU_HOST,
      prefixKey: '',
    },
    upyun: {
      user: process.env.UPYUN_USER,
      password: process.env.UPYUN_PASSWORD,
      bucket: process.env.UPYUN_BUCKET,
      host: process.env.UPYUN_HOST,
      prefixKey: '',
    },
    github: {
      token: process.env.GITHUB_TOKEN,
      user: process.env.ELOG_GITHUB_USER,
      repo: process.env.ELOG_GITHUB_REPO,
      prefixKey: '',
    }
  }
}

发生了什么?

使用以下命令 执行同步时 ,报错 npx @elog/cli sync --config elog.config.js --env .elog.env --disable-cache

Elog错误日志

执行TypeScript脚本 下载出错: Cannot read properties of undefined (reading 'elements')
初始化一个TypeScript的Hello World项目 下载出错: Cannot read properties of undefined (reading 'elements')

附加信息

No response

LetTTGACO commented 5 months ago

在运行 npx @elog/cli sync --config elog.config.js --env .elog.env --disable-cache 时加上 debug 命令看下详细日志

npx @elog/cli sync --config elog.config.js --env .elog.env --disable-cache --debug

zh-d-d commented 5 months ago

在运行 npx @elog/cli sync --config elog.config.js --env .elog.env --disable-cache 时加上 debug 命令看下详细日志

npx @elog/cli sync --config elog.config.js --env .elog.env --disable-cache --debug

初始化一个TypeScript的Hello World项目 下载出错: Cannot read properties of undefined (reading 'elements') TypeError: Cannot read properties of undefined (reading 'elements') at getBaseTextValue (/Users/zhangdongdong/Desktop/elog/node_modules/.pnpm/@feishux+doc-to-md@0.3.1/node_modules/@feishux/doc-to-md/dist/utils/feishu.js:16:20) at /Users/zhangdongdong/Desktop/elog/node_modules/.pnpm/@feishux+doc-to-md@0.3.1/node_modules/@feishux/doc-to-md/dist/utils/feishu.js:149:31 at Array.map () at Object.getQuoteValue (/Users/zhangdongdong/Desktop/elog/node_modules/.pnpm/@feishux+doc-to-md@0.3.1/node_modules/@feishux/doc-to-md/dist/utils/feishu.js:146:83) at /Users/zhangdongdong/Desktop/elog/node_modules/.pnpm/@feishux+doc-to-md@0.3.1/node_modules/@feishux/doc-to-md/dist/client.js:54:54 at Array.forEach () at FeiShuToMarkdown.toMarkdownString (/Users/zhangdongdong/Desktop/elog/node_modules/.pnpm/@feishux+doc-to-md@0.3.1/node_modules/@feishux/doc-to-md/dist/client.js:39:80) at FeiShuClient. (/Users/zhangdongdong/Desktop/elog/node_modules/.pnpm/@elog+sdk-feishu@0.14.1/node_modules/@elog/sdk-feishu/dist/index.js:195:25) at Generator.next () at fulfilled (/Users/zhangdongdong/Desktop/elog/node_modules/.pnpm/@elog+sdk-feishu@0.14.1/node_modules/@elog/sdk-feishu/dist/index.js:24:24)

LetTTGACO commented 5 months ago

感谢您指出的问题,我可能需要花点时间看看

zh-d-d commented 5 months ago

好的,麻烦了 如果需要其他信息及时沟通

LetTTGACO commented 5 months ago

已经找到问题了,麻烦尝试升级到最新 beta 版本,0.14.2-beta.0 确认没问题的话,我就把他升级到正式版

zh-d-d commented 5 months ago

The latest release of @elog/cli is "0.14.1".

Other releases are:

LetTTGACO commented 5 months ago

你用的应该是淘宝镜像吧,淘宝镜像同步的慢,建议换成 npm 官方源

LetTTGACO commented 5 months ago

我正在尝试同步到https://registry.npmmirror.com中,可以晚点试试

zh-d-d commented 5 months ago

已经找到问题了,麻烦尝试升级到最新 beta 版本,0.14.2-beta.0 确认没问题的话,我就把他升级到正式版

已经升级到了beta版本,正常了

LetTTGACO commented 5 months ago

文档内容都正常吗?还有什么其他问题没?

zh-d-d commented 5 months ago

现在下载图片文字看起来是正常的,但是文档内容好像还是有些问题。

这是在飞书文档里的内容

image

这是打开本地md文档后,下载到本地后 quote块内容不见了

image
LetTTGACO commented 5 months ago

这种引用里面的序号列表我应该是没考虑到,我得适配一下才行。Elog 飞书模式目前用的人少,需要逐渐迭代。你先不要用引用包裹,我这两天适配一下

zh-d-d commented 5 months ago

嗯,感谢。这个工具挺好的

LetTTGACO commented 3 months ago

已修复引用块下添加其他块,例如有序列表无法展示的问题

由于本次改动只涉及 elog 依赖的feishu 相关包,并未改动到 elog 本体。更新办法

  1. 如果你是使用 package.json 进行安装和并使用 npm script 运行 elog 命令,请删除 node_modules 和 package-lock.json 重新安装 elog 即可
  2. 如果你是将 elog 安装到全局环境(npm i @elog/cli -g) 请卸载elog(npm uninstall -g @elog/cli) 后重新安装elog 即可