Skip to content

Commit b7d6238

Browse files
committed
fix: 修复@142vip/utils模块相互调用异常
1 parent 3d2ce7e commit b7d6238

File tree

6 files changed

+18
-27
lines changed

6 files changed

+18
-27
lines changed

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export default defineVipEslintConfig({
66
],
77
rules: {
88
// 用于在模块构建后基于dist导出时找不到文件,忽略校验
9-
'antfu/no-import-dist': 1,
9+
'antfu/no-import-dist': 0,
1010
},
1111
})

packages/changelog/src/git.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
import { execSync } from 'node:child_process'
2-
3-
/**
4-
* todo 迁移到@142vip/utils模块中
5-
*/
6-
7-
export function execCommand(cmd: string, cwd?: string): string {
8-
return execSync(cmd, { encoding: 'utf8', cwd }).trim()
9-
}
1+
import { VipExecutor } from '@142vip/utils'
102

113
export interface GitCommitAuthor {
124
name: string
@@ -59,7 +51,7 @@ export async function getGitDiff(params: {
5951
}
6052

6153
// 获取commit记录
62-
const commitStr = execCommand(`git --no-pager log "${params.from}${params.to}" --pretty="----%n%s|%h|%an|%ae%n%b" --name-status`)
54+
const commitStr = VipExecutor.execCommandSync(`git --no-pager log "${params.from}${params.to}" --pretty="----%n%s|%h|%an|%ae%n%b" --name-status`)
6355

6456
return commitStr
6557
.split('----\n')

packages/release-version/src/core/git.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { execShell } from '@142vip/utils'
1+
import { VipExecutor } from '@142vip/utils'
22
import { ProgressEvent } from '../types'
33
import type { Operation } from './operation'
44

@@ -31,7 +31,7 @@ export async function gitCommit(operation: Operation): Promise<Operation> {
3131
if (!all)
3232
args = args.concat(updatedFiles)
3333

34-
await execShell({ command: `git commit ${args.join(' ')}`, description: '提交git commit信息' })
34+
await VipExecutor.execShell({ command: `git commit ${args.join(' ')}`, description: '提交git commit信息' })
3535

3636
return operation.update({ event: ProgressEvent.GitCommit, commitMessage })
3737
}
@@ -61,7 +61,7 @@ export async function gitTag(operation: Operation): Promise<Operation> {
6161
const tagName = formatVersionString(tag.name, newVersion)
6262
args.push(tagName)
6363

64-
await execShell({ command: `git tag ${args.join(' ')}`, description: '创建Tag标签' })
64+
await VipExecutor.execShell({ command: `git tag ${args.join(' ')}`, description: '创建Tag标签' })
6565

6666
return operation.update({ event: ProgressEvent.GitTag, tagName })
6767
}
@@ -74,11 +74,11 @@ export async function gitPush(operation: Operation): Promise<Operation> {
7474
return operation
7575

7676
// Push the commit
77-
await execShell({ command: 'git push', description: '推送变更' })
77+
await VipExecutor.execShell({ command: 'git push', description: '推送变更' })
7878

7979
if (operation.options.tag) {
8080
// Push the tag
81-
await execShell({ command: 'git push --tags', description: '推送所有标签' })
81+
await VipExecutor.execShell({ command: 'git push --tags', description: '推送所有标签' })
8282
}
8383

8484
return operation.update({ event: ProgressEvent.GitPush })

packages/release-version/src/core/npm-script.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { execShell } from '@142vip/utils'
1+
import { VipExecutor } from '@142vip/utils'
22
import type { NpmScript } from '../types'
33
import { ProgressEvent } from '../types'
44
import { readJsonFile } from './fs'
@@ -18,7 +18,7 @@ export async function runScript(script: NpmScript, operation: Operation): Promis
1818
const { data: manifest } = await readJsonFile('package.json', cwd)
1919

2020
if (isManifest(manifest) && hasScript(manifest, script)) {
21-
await execShell({ command: `npm run ${script} --silent`, description: '运行脚本命令' })
21+
await VipExecutor.execShell({ command: `npm run ${script} --silent`, description: '运行脚本命令' })
2222
operation.update({ event: ProgressEvent.NpmScript, script })
2323
}
2424
}

scripts/bundle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
*/
99

1010
import { createRequire } from 'node:module'
11-
import process from 'node:process'
1211
import {
1312
OPEN_SOURCE_ADDRESS,
1413
VipGit,
1514
VipDocker,
15+
VipNodeJS
1616
} from '@142vip/utils'
1717

1818
(async () => {
@@ -24,14 +24,14 @@ import {
2424
const imageName = `${OPEN_SOURCE_ADDRESS.DOCKER_ALIYUNCS_VIP}/docs:${pkg.name.split('/')[1]}-${pkg.version}`
2525

2626
// 最近一次提交信息
27-
const { hash: gitHash } = await VipGit.getRecentGitCommit()
27+
const gitHash = VipGit.getFirstCommitHash()
2828

2929
// 构建镜像
3030
await VipDocker.buildImage({
3131
imageName,
3232
buildArgs: [
3333
// 参数中是否包含 --proxy
34-
['NEED_PROXY', process.argv.includes('--proxy')],
34+
['NEED_PROXY', VipNodeJS.getProcessArgv().includes('--proxy')],
3535
['APP_NAME', pkg.name],
3636
['APP_VERSION', pkg.version],
3737
['APP_DESCRIPTION', pkg.description],

verify-commit.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import process from 'node:process'
2-
import { VipColor } from '@142vip/utils'
1+
import { VipColor, VipNodeJS } from '@142vip/utils'
32
import {
43
getReleasePkgJSON,
54
verifyCommit,
@@ -23,7 +22,7 @@ if (!isSuccess) {
2322
)}\n\n${
2423
VipColor.red(` See .github/commit-convention.md for more details.\n`)}`,
2524
)
26-
process.exit(1)
25+
VipNodeJS.exitProcess(1)
2726
}
2827

2928
const typeList = [
@@ -47,7 +46,7 @@ if (type == null || !typeList.includes(type)) {
4746
`invalid commit type , support ${typeList.join('|')}`,
4847
)}`,
4948
)
50-
process.exit(1)
49+
VipNodeJS.exitProcess(1)
5150
}
5251

5352
// 获取packages目录下所有的模块名
@@ -66,7 +65,7 @@ if (scope != null && !scopeList.includes(scope)) {
6665
`invalid commit scope name , Examples:\n${scopeList.join('\n')}`,
6766
)}`,
6867
)
69-
process.exit(1)
68+
VipNodeJS.exitProcess(1)
7069
}
7170

7271
// 判断message长度
@@ -76,7 +75,7 @@ if (message == null || message.length > 80) {
7675
`invalid commit message length , max length is 80`,
7776
)}`,
7877
)
79-
process.exit(1)
78+
VipNodeJS.exitProcess(1)
8079
}
8180

8281
// 提交符合规范,打印相关信息

0 commit comments

Comments
 (0)