|
1 | 1 | import { execSync } from 'node:child_process'
|
2 | 2 | import process from 'node:process'
|
3 | 3 | import { versionBump } from '@142vip/release-version'
|
4 |
| -import { VipColor, VipConsole, VipSymbols } from '@142vip/utils' |
5 |
| -import { getCommitLogs, getLatestTagName } from './git' |
| 4 | +import { |
| 5 | + VipColor, |
| 6 | + VipConsole, |
| 7 | + VipGit, |
| 8 | + VipNodeJS, |
| 9 | + VipPackageJSON, |
| 10 | + VipSymbols, |
| 11 | +} from '@142vip/utils' |
6 | 12 |
|
7 | 13 | interface PackageJSON {
|
8 | 14 | name: string
|
@@ -52,12 +58,12 @@ export function getReleasePkgJSON(filter?: string | string[]): PackageJSON[] {
|
52 | 58 | /**
|
53 | 59 | * 打印模块预检信息
|
54 | 60 | */
|
55 |
| -export function printPreCheckRelease(packageNames: string[]): void { |
| 61 | +export async function printPreCheckRelease(packageNames: string[]): Promise<void> { |
56 | 62 | // 标记是否能够发布主仓库,前提是所有子模块都进行版本更新
|
57 | 63 | let isRootRelease = true
|
58 | 64 | const packages: ValidatePkgJSON[] = []
|
59 | 65 | for (const packageName of packageNames) {
|
60 |
| - const isNeedRelease = validatePackage(packageName) |
| 66 | + const isNeedRelease = await validatePackage(packageName) |
61 | 67 | // 子模块没有进行版本更新
|
62 | 68 | if (isNeedRelease) {
|
63 | 69 | isRootRelease = false
|
@@ -87,9 +93,13 @@ export function printPreCheckRelease(packageNames: string[]): void {
|
87 | 93 | * 提交git当前节点到上个tag的所有提交记录
|
88 | 94 | * 分析、判断是否有公共模块,提醒及时对公共模块发布新的版本号
|
89 | 95 | */
|
90 |
| -function validatePackage(packageNameInCommitScope: string, template?: string): boolean { |
91 |
| - const latestTag = getLatestTagName() |
92 |
| - const commitLogs = getCommitLogs(latestTag) |
| 96 | +async function validatePackage(packageNameInCommitScope: string, template?: string): Promise<boolean> { |
| 97 | + const latestTag = await VipPackageJSON.getVersionGitTag() |
| 98 | + if (latestTag == null) { |
| 99 | + VipConsole.log(`仓库没有tag标签,请先打tag标签或配置version字段!!!`) |
| 100 | + VipNodeJS.exitProcess(1) |
| 101 | + } |
| 102 | + const commitLogs = VipGit.getCommitLogs(latestTag!) |
93 | 103 |
|
94 | 104 | // 整理出git提交日志
|
95 | 105 | const logsByPackage = commitLogs.filter(commit => commit.includes(`(${packageNameInCommitScope})`))
|
|
0 commit comments