mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-03 17:11:08 -05:00
workflow: only generate changelog for the latest release and concat with the old
so that the old manually edited parts won't be overwritten.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 3.4 KiB |
@@ -1,26 +1,42 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const execa = require('execa')
|
||||
const cc = require('conventional-changelog')
|
||||
const config = require('@vue/conventional-changelog')
|
||||
|
||||
const gen = module.exports = version => {
|
||||
const fileStream = require('fs').createWriteStream(`CHANGELOG.md`)
|
||||
|
||||
cc({
|
||||
config,
|
||||
releaseCount: 0,
|
||||
pkg: {
|
||||
transform (pkg) {
|
||||
pkg.version = `v${version}`
|
||||
return pkg
|
||||
function genNewRelease (version) {
|
||||
return new Promise(resolve => {
|
||||
const newReleaseStream = cc({
|
||||
config,
|
||||
releaseCount: 1,
|
||||
pkg: {
|
||||
transform (pkg) {
|
||||
pkg.version = `v${version}`
|
||||
return pkg
|
||||
}
|
||||
}
|
||||
}
|
||||
}).pipe(fileStream).on('close', async () => {
|
||||
delete process.env.PREFIX
|
||||
await execa('git', ['add', '-A'], { stdio: 'inherit' })
|
||||
await execa('git', ['commit', '-m', `chore: ${version} changelog [ci skip]`], { stdio: 'inherit' })
|
||||
})
|
||||
|
||||
let output = ''
|
||||
newReleaseStream.on('data', buf => {
|
||||
output += buf
|
||||
})
|
||||
newReleaseStream.on('end', () => resolve(output))
|
||||
})
|
||||
}
|
||||
|
||||
const gen = (module.exports = async version => {
|
||||
const newRelease = await genNewRelease(version)
|
||||
const changelogPath = path.resolve(__dirname, '../CHANGELOG.md')
|
||||
|
||||
const newChangelog = newRelease + fs.readFileSync(changelogPath, { encoding: 'utf8' })
|
||||
fs.writeFileSync(changelogPath, newChangelog)
|
||||
|
||||
delete process.env.PREFIX
|
||||
await execa('git', ['add', '-A'], { stdio: 'inherit' })
|
||||
await execa('git', ['commit', '-m', `chore: ${version} changelog [ci skip]`], { stdio: 'inherit' })
|
||||
})
|
||||
|
||||
if (process.argv[2] === 'run') {
|
||||
const version = require('../lerna.json').version
|
||||
gen(version)
|
||||
|
||||
@@ -103,7 +103,7 @@ const release = async () => {
|
||||
}
|
||||
await execa(require.resolve('lerna/cli'), lernaArgs, { stdio: 'inherit' })
|
||||
|
||||
require('./genChangelog')(version)
|
||||
await require('./genChangelog')(version)
|
||||
|
||||
const packages = JSON.parse(
|
||||
(await execa(require.resolve('lerna/cli'), ['list', '--json'])).stdout
|
||||
|
||||
Reference in New Issue
Block a user