nolebase / integrations

A collection of diverse documentation engineering tools | 多元化的文档工程工具合集
https://nolebase-integrations.ayaka.io
MIT License
66 stars 9 forks source link

feat(git-changelog): support git submodule #189

Closed northword closed 4 weeks ago

northword commented 1 month ago

closes: #185

变更描述

改变了插件工作的方式,原有的是通过 simple-git 整个仓库的 git log,然后从 git log 的每一次 commit 中解析贡献者和历史信息以及涉及的文件。但 simple-git 无法将子模块的 git log 合并输出。

此 pr 中:

  1. 通过 globby 遍历仓库中的 md 文件(['**/*.md', '!node_modules']
  2. 对每一个 md 文件
    1. git log (由于每次执行都是在 cwd 中,因此可以支持 submodule)
    2. 获取提交信息
    3. 将获取到的信息以 [path: string]: Commit[] 的格式存储,而不是先前的在每一个 commit 里包含 paths 恢复原有的在每个commit里包含path(但不是paths),这是为了把commit.path传递给getRepoUrl等helper
  3. 从 vitepress useDate 获取文件的路径,而不是从路由推断文件路径
  4. 根据 md 文件的路径获取该文件的所有 commits

breaking changes

导致了一些破坏性更改:

由于引入了破坏性更改,我不确定是否有可能合并,如果您也同意这种修改方式,我将继续 clean code 以及修改 test。


迁移指南

  1. includeDirs 和 includeExtensions 已弃用,二者合并为 include,include 为一个 glob 模式列表,支持 ! 否定。
  2. 如果 include 中的文件在 vitepress 项目根路径之外,需要设置 cwd 为能够读取到该文件的目录。(例如,在一个monorepo中,如果需要读取 docs/ 以外的文件,需要将 cwd 设置为 monorepo 的 root 而不是 vitepress 的 root)
  3. RewritePaths 已弃用
  4. 原 RewritePaths 中配置重写 srcDir 的现在不需要再这样配置
  5. RewritePaths 模式现在应将目标路径设置为 相对于 srcDir 的文件系统路径,而不是路由(一般情况下,如果没有在 vitepress 中设置 rewrite ,文件系统路径就是路由)

Migration Guide

  1. includeDirs and includeExtensions have been deprecated and merged into include, which is a list of glob modes with ! negation.
  2. If a file is outside the vitepress project root path, set cwd to the directory where the file can be read. (For example, in a monorepo, if you need to read a file outside of docs/, you need to set cwd to the root of the monorepo instead of the root of vitepress.)
  3. Original RewritePaths is now deprecated.
  4. Configuring RewritePaths to rewrite srcDir is no longer needed.
  5. RewritePaths pattern should now set the destination path to the filesystem path relative to srcDir instead of the route (normally, if no rewrite is set in vitepress, the filesystem path is the route)
github-actions[bot] commented 1 month ago

✅ Successfully deployed to Netlify

Platform Status URL
Ubuntu Success https://66351db0783c732676f72dc5--nolebase-integrations.netlify.app
Windows Success https://66351dbc4567252067a1a728--nolebase-integrations.netlify.app
nekomeowww commented 1 month ago

其他的部分我觉得 almost LGTM,谢谢你的贡献 🤗

nekomeowww commented 1 month ago

好像 ref 错位了?(rc9 变成了 rc10)

是我之前写的 bug 嘛

现在的预览构建:https://66335922fffe609f43d25db9--nolebase-integrations.netlify.app/pages/en/integrations/

image

现在的 Prod docs:https://nolebase-integrations.ayaka.io/pages/en/integrations/

image

northword commented 1 month ago

好像 ref 错位了?(rc9 变成了 rc10)

是我之前写的 bug 嘛

现在的预览构建:https://66335922fffe609f43d25db9--nolebase-integrations.netlify.app/pages/en/integrations/

docs/pages/en/integrations/index.md 这个文件,在提交 release: pre-release v2.0.0-rc10 中是修改了的,所以 ref 到 tag: v2.0.0-rc10 似乎是对着的。

而 rc9 这个提交没有隐藏掉似乎是因为 rc9 这个 tag 在 chore(ci): update to pnpm 9 这次提交上而不是 release: pre-release v2.0.0-rc9

nekomeowww commented 4 weeks ago

其他的部分 LGTM