Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

又一个vscode扩展,生成CHANGELOG #186

Open
axetroy opened this issue Mar 11, 2019 · 1 comment
Open

又一个vscode扩展,生成CHANGELOG #186

axetroy opened this issue Mar 11, 2019 · 1 comment
Labels

Comments

@axetroy
Copy link
Owner

axetroy commented Mar 11, 2019

大多数时候, 写的一个小小的库,还得要专门写变更日志。

而遵循一定的 commit 格式,是可以生成标准的变更日志的。

这时候就需要像conventional-changelog

这我就不得不在我的项目中添加脚本

npx conventional-changelog-cli -p angular -i CHANGELOG.md -s -r 0

今天呢,就把它提取出来,独立成为一个 vscode 扩展

让你方便的生成 CHANGELOG

支持哪些特性

  • 从头开始生成更改日志。
  • 从最近 1 个版本生成更改日志。
  • 从最近 2 个版本生成更改日志。
  • 从最近的 N 版本生成更改日志。
  • 自动生成CHANGELOG.md
  • 将此版本更改附加到CHANGELOG.md

Screenshot

TODO

  • 完整迁移conventional-changelog-cli的参数设置
  • 适配多个项目集合,类似lerna
  • 在文件管理器添加生成更新日志菜单

说说踩的坑

conventional-changelog的包分有

  • conventional-changelog-cli
  • conventional-changelog
  • conventional-changelog-core

按理来说,代码更次的,应该引用conventional-changelog-coreconventional-changelog

然而,这两个包都有问题: 不能指定当前工作目录去解析 (其实它引用的git-raw-commits是有参数设置的conventional-changelog并没有用这个参数)

我又不想 Fork 一个自己改, 那就只能用 conventional-changelog-cli, 以命令行的方式去运行。

那么问题来了:

  1. vscode 的扩展安装不是通过npm install

vscode 直接把本地的node_modules依赖打包,并且忽略了一些目录和文件,包括.bin目录

所以扩展是找不到conventional-changelog-cli的可执行文件

  1. 平台不同,可执行文件也不同

Linux 和 OSX 下 是一个 link,自己执行 chmod +x 即可,而 windows 下是 exe 文件。

所以自制可执行文件不靠谱

解决办法:

  1. 我不要可执行文件了,直接用 node 执行 js 文件可不可以
node ./node_modules/conventional-changelog-cli/cli.js

可以是可以,不过这样的扩展就有局限行,需要用户安装nodejs,显然不是每个用户都安装

  1. 使用 Electron 内置的 NodeJS 执行

Electron 内置有的 NodeJS,我们就用它来执行这个 js 文件

process.execPath则是当前运行环境的可执行文件路径

execa(process.execPath, './node_modules/conventional-changelog-cli/cli.js');

最后完美解决

最后上项目: https://github.com/axetroy/vscode-changelog-generator

有什么意见或者功能需求,欢迎发issue给我!

@axetroy axetroy added the 分享 label Mar 11, 2019
@Fucntion
Copy link

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants