|
@@ -5,8 +5,8 @@ import semver from 'semver'
|
|
|
import { readFileSync, writeFileSync } from 'fs'
|
|
|
|
|
|
// 初始化数据
|
|
|
-const packageFile = './package.json'
|
|
|
-const versionFile = './public/version.json'
|
|
|
+// const packageFile = './package.json'
|
|
|
+// const versionFile = './public/version.json'
|
|
|
|
|
|
// 获取执行的参数
|
|
|
const args = process.argv.slice(2)
|
|
@@ -121,29 +121,37 @@ function revertTag(version) {
|
|
|
function autoTagVersion(type = 'patch') {
|
|
|
getLatestVersion().then((latestVersion) => {
|
|
|
const nextVersion = 'v' + suggestNextVersion(latestVersion, type)
|
|
|
- const content = readFileSync(packageFile, 'utf-8')
|
|
|
- const packageInfo = JSON.parse(content)
|
|
|
- packageInfo['version'] = nextVersion
|
|
|
- packageInfo['updateTime'] = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
|
- // 写入文件
|
|
|
- writeJson(packageInfo, packageFile)
|
|
|
- writeJson(
|
|
|
- {
|
|
|
- version: nextVersion,
|
|
|
- updateTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
- },
|
|
|
- versionFile
|
|
|
- )
|
|
|
- // 提交代码
|
|
|
- exec(`git add . && git commit -m "setTag ${nextVersion}" && git push`, (err, stdout, stderr) => {
|
|
|
- if (err) {
|
|
|
- console.error('代码提交失败')
|
|
|
- console.error(err)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- // 设置tag
|
|
|
- createNewTag(nextVersion)
|
|
|
- })
|
|
|
+ // 设置tag
|
|
|
+ createNewTag(nextVersion)
|
|
|
})
|
|
|
}
|
|
|
+// // 主函数
|
|
|
+// function autoTagVersion(type = 'patch') {
|
|
|
+// getLatestVersion().then((latestVersion) => {
|
|
|
+// const nextVersion = 'v' + suggestNextVersion(latestVersion, type)
|
|
|
+// const content = readFileSync(packageFile, 'utf-8')
|
|
|
+// const packageInfo = JSON.parse(content)
|
|
|
+// packageInfo['version'] = nextVersion
|
|
|
+// packageInfo['updateTime'] = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
|
+// // 写入文件
|
|
|
+// writeJson(packageInfo, packageFile)
|
|
|
+// writeJson(
|
|
|
+// {
|
|
|
+// version: nextVersion,
|
|
|
+// updateTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+// },
|
|
|
+// versionFile
|
|
|
+// )
|
|
|
+// // 提交代码
|
|
|
+// exec(`git add . && git commit -m "setTag ${nextVersion}" && git push`, (err, stdout, stderr) => {
|
|
|
+// if (err) {
|
|
|
+// console.error('代码提交失败')
|
|
|
+// console.error(err)
|
|
|
+// return
|
|
|
+// }
|
|
|
+
|
|
|
+// // 设置tag
|
|
|
+// createNewTag(nextVersion)
|
|
|
+// })
|
|
|
+// })
|
|
|
+// }
|