Skip to content

Commit 4f64519

Browse files
authored
feat(@142vip/fairy-cli): 移除getLatestTagNamegetCommitLogs函数,功能逻辑简化 (#457)
1 parent 1ade998 commit 4f64519

File tree

3 files changed

+17
-49
lines changed

3 files changed

+17
-49
lines changed

packages/fairy-cli/src/shared/git.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export * from './cli-command.enum'
2-
export * from './git'
32
export * from './monorepo'
43
export * from './release-package'

packages/fairy-cli/src/shared/release-package.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import { execSync } from 'node:child_process'
22
import process from 'node:process'
33
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'
612

713
interface PackageJSON {
814
name: string
@@ -52,12 +58,12 @@ export function getReleasePkgJSON(filter?: string | string[]): PackageJSON[] {
5258
/**
5359
* 打印模块预检信息
5460
*/
55-
export function printPreCheckRelease(packageNames: string[]): void {
61+
export async function printPreCheckRelease(packageNames: string[]): Promise<void> {
5662
// 标记是否能够发布主仓库,前提是所有子模块都进行版本更新
5763
let isRootRelease = true
5864
const packages: ValidatePkgJSON[] = []
5965
for (const packageName of packageNames) {
60-
const isNeedRelease = validatePackage(packageName)
66+
const isNeedRelease = await validatePackage(packageName)
6167
// 子模块没有进行版本更新
6268
if (isNeedRelease) {
6369
isRootRelease = false
@@ -87,9 +93,13 @@ export function printPreCheckRelease(packageNames: string[]): void {
8793
* 提交git当前节点到上个tag的所有提交记录
8894
* 分析、判断是否有公共模块,提醒及时对公共模块发布新的版本号
8995
*/
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!)
93103

94104
// 整理出git提交日志
95105
const logsByPackage = commitLogs.filter(commit => commit.includes(`(${packageNameInCommitScope})`))

0 commit comments

Comments
 (0)