发布 v2.12.0
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
*
|
||||
* @param {string} text
|
||||
* @returns
|
||||
*/
|
||||
export const parseChangelog = async(text) => {
|
||||
const versions = []
|
||||
const lines = text.split(/\r\n|\r|\n/)
|
||||
let currentVersion = null
|
||||
let currentDate = null
|
||||
let currentDesc = ''
|
||||
|
||||
for (const line of lines) {
|
||||
const versionMatch = line.match(/^\s*##\s+\[?(\d+\.\d+\.\d+)\]?.*?-\s+(\d{4}-\d{2}-\d{2})$/)
|
||||
if (versionMatch) {
|
||||
if (currentVersion) {
|
||||
versions.push({
|
||||
version: currentVersion,
|
||||
date: currentDate,
|
||||
desc: currentDesc.trim(),
|
||||
})
|
||||
}
|
||||
currentVersion = versionMatch[1]
|
||||
currentDate = versionMatch[3]
|
||||
currentDesc = ''
|
||||
} else {
|
||||
currentDesc += `${line}\n`
|
||||
}
|
||||
}
|
||||
|
||||
if (currentVersion) {
|
||||
versions.push({
|
||||
version: currentVersion,
|
||||
date: currentDate,
|
||||
desc: currentDesc.trim(),
|
||||
})
|
||||
}
|
||||
|
||||
return versions
|
||||
}
|
||||
@@ -6,8 +6,8 @@ const version = require('../version.json')
|
||||
const chalk = require('chalk')
|
||||
const pkg_bak = JSON.stringify(pkg, null, 2)
|
||||
const version_bak = JSON.stringify(version, null, 2)
|
||||
const parseChangelog = require('changelog-parser')
|
||||
const changelogPath = jp('../../CHANGELOG.md')
|
||||
const { parseChangelog } = require('./parseChangelog')
|
||||
|
||||
// const md_renderer = markdownStr => new (require('markdown-it'))({
|
||||
// html: true,
|
||||
@@ -16,9 +16,9 @@ const changelogPath = jp('../../CHANGELOG.md')
|
||||
// breaks: true,
|
||||
// }).render(markdownStr)
|
||||
|
||||
const getPrevVer = () => parseChangelog(changelogPath).then(res => {
|
||||
if (!res.versions.length) throw new Error('CHANGELOG 无法解析到版本号')
|
||||
return res.versions[0].version
|
||||
const getPrevVer = () => parseChangelog(fs.readFileSync(changelogPath, 'utf-8').toString()).then(versions => {
|
||||
if (!versions.length) throw new Error('CHANGELOG 无法解析到版本号')
|
||||
return versions[0].version
|
||||
})
|
||||
|
||||
const updateChangeLog = async(newVerNum, newChangeLog) => {
|
||||
@@ -32,11 +32,7 @@ const updateChangeLog = async(newVerNum, newChangeLog) => {
|
||||
|
||||
|
||||
module.exports = async newVerNum => {
|
||||
if (!newVerNum) {
|
||||
let verArr = pkg.version.split('.')
|
||||
verArr[verArr.length - 1] = parseInt(verArr[verArr.length - 1]) + 1
|
||||
newVerNum = verArr.join('.')
|
||||
}
|
||||
if (!newVerNum) newVerNum = pkg.version
|
||||
const newMDChangeLog = fs.readFileSync(jp('../changeLog.md'), 'utf-8')
|
||||
// const newChangeLog = renderChangeLog(newMDChangeLog)
|
||||
version.history.unshift({
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user