Skip to content

Commit 22c35af

Browse files
authored
Merge pull request #313 from 142vip/feat/vip-color
feat(@142vip/utils): `vipColor`、`vipSymbols`重命名,大驼峰格式
2 parents bc3ed95 + a0d22ea commit 22c35af

File tree

14 files changed

+73
-73
lines changed

14 files changed

+73
-73
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,14 +438,14 @@ All notable changes to this project will be documented in this file. See [commit
438438

439439
- 使用`VipProjectTable`组件,优化首页显示效果,`首页-趋势`支持暗夜模式 &nbsp;-&nbsp; by **chufan** [<samp>(4e1b0)</samp>](https://github.com/142vip/core-x/commit/4e1b0d6)
440440
- 使用`VipTeam`组件,优化首页展示 &nbsp;-&nbsp; by **chufan** [<samp>(f2e9f)</samp>](https://github.com/142vip/core-x/commit/f2e9f7a)
441-
- 移除全局`chalk`模块,使用`vipColor`变量处理日志格式 &nbsp;-&nbsp; by **chufan** [<samp>(51156)</samp>](https://github.com/142vip/core-x/commit/5115623)
441+
- 移除全局`chalk`模块,使用`VipColor`变量处理日志格式 &nbsp;-&nbsp; by **chufan** [<samp>(51156)</samp>](https://github.com/142vip/core-x/commit/5115623)
442442
- **@142vip/fairy-cli**:
443443
- 移除`log-symbols`模块,优化`check`命令的日志输出 &nbsp;-&nbsp; by **chufan** [<samp>(47635)</samp>](https://github.com/142vip/core-x/commit/4763593)
444444
- `release`发布命令增加`--filter`可选参数,支持多次调用,用于指定模块路径 &nbsp;-&nbsp; by **chufan** [<samp>(d0cc1)</samp>](https://github.com/142vip/core-x/commit/d0cc1e7)
445445
- **@142vip/release-version**:
446-
- 移除`log-symbols`模块,替换为`vipSymbols`变量 &nbsp;-&nbsp; by **chufan** [<samp>(6347b)</samp>](https://github.com/142vip/core-x/commit/6347bc5)
446+
- 移除`log-symbols`模块,替换为`VipSymbols`变量 &nbsp;-&nbsp; by **chufan** [<samp>(6347b)</samp>](https://github.com/142vip/core-x/commit/6347bc5)
447447
- **@142vip/utils**:
448-
- 移除`chalk`,使用`ansi-colors`模块,新增`vipColor``vipSymbols`常用终端日志输出变量 &nbsp;-&nbsp; by **chufan** [<samp>(55ae6)</samp>](https://github.com/142vip/core-x/commit/55ae636)
448+
- 移除`chalk`,使用`ansi-colors`模块,新增`VipColor``VipSymbols`常用终端日志输出变量 &nbsp;-&nbsp; by **chufan** [<samp>(55ae6)</samp>](https://github.com/142vip/core-x/commit/55ae636)
449449
- **@142vip/vitepress**:
450450
- 封装`VipBackTop`组件,优化`VipProjectTable`组件显示样式 &nbsp;-&nbsp; by **chufan** [<samp>(0392e)</samp>](https://github.com/142vip/core-x/commit/0392e18)
451451
- 拓展项目表格和团队介绍组件封装,优化使用 &nbsp;-&nbsp; by **chufan** [<samp>(854ab)</samp>](https://github.com/142vip/core-x/commit/854ab43)

packages/changelog/src/core/changelog.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import process from 'node:process'
22
import { getGitDiff, parseGitCommit } from 'changelogen'
3-
import { VipCommander, VipJSON, vipColor } from '@142vip/utils'
3+
import { VipColor, VipCommander, VipJSON } from '@142vip/utils'
44
import { name as packageName, version as packageVersion } from '../../package.json'
55
import {
66
generateMarkdown,
@@ -105,20 +105,20 @@ async function dealChangelog(args: ChangelogOptions): Promise<void> {
105105

106106
try {
107107
console.log()
108-
console.log(vipColor.dim(`${vipColor.bold(packageName)} `) + vipColor.dim(`v${packageVersion}`))
108+
console.log(VipColor.dim(`${VipColor.bold(packageName)} `) + VipColor.dim(`v${packageVersion}`))
109109

110110
const { config, markdown, commits } = await generate(args)
111111
webUrl = generateWebUrl(config, markdown)
112112

113-
console.log(vipColor.cyan(config.from) + vipColor.dim(' -> ') + vipColor.blue(config.to) + vipColor.dim(` (${commits.length} commits)`))
114-
console.log(vipColor.dim('--------------'))
113+
console.log(VipColor.cyan(config.from) + VipColor.dim(' -> ') + VipColor.blue(config.to) + VipColor.dim(` (${commits.length} commits)`))
114+
console.log(VipColor.dim('--------------'))
115115
console.log()
116116
console.log(markdown.replace(/&nbsp;/g, ''))
117117
console.log()
118-
console.log(vipColor.dim('--------------'))
118+
console.log(VipColor.dim('--------------'))
119119

120120
if (config.dry) {
121-
console.log(vipColor.yellow('试运行。已跳过版本发布。'))
121+
console.log(VipColor.yellow('试运行。已跳过版本发布。'))
122122
printUrl(webUrl)
123123
return
124124
}
@@ -131,14 +131,14 @@ async function dealChangelog(args: ChangelogOptions): Promise<void> {
131131

132132
// 带token上传
133133
if (!config.tokens) {
134-
console.error(vipColor.red('未找到 GitHub 令牌,请通过 GITHUB_TOKEN 环境变量指定。已跳过版本发布。'))
134+
console.error(VipColor.red('未找到 GitHub 令牌,请通过 GITHUB_TOKEN 环境变量指定。已跳过版本发布。'))
135135
printUrl(webUrl)
136136
process.exitCode = 1
137137
return
138138
}
139139

140140
if (!commits.length && await isRepoShallow()) {
141-
console.error(vipColor.yellow('存储库似乎克隆得很浅,这使得更改日志无法生成。您可能希望在 CI 配置中指定 \'fetch-depth: 0\'。'))
141+
console.error(VipColor.yellow('存储库似乎克隆得很浅,这使得更改日志无法生成。您可能希望在 CI 配置中指定 \'fetch-depth: 0\'。'))
142142
printUrl(webUrl)
143143
process.exitCode = 1
144144
return
@@ -148,9 +148,9 @@ async function dealChangelog(args: ChangelogOptions): Promise<void> {
148148
await sendRelease(config, markdown)
149149
}
150150
catch (e: any) {
151-
console.error(vipColor.red(String(e)))
151+
console.error(VipColor.red(String(e)))
152152
if (e?.stack)
153-
console.error(vipColor.dim(e.stack?.split('\n').slice(1).join('\n')))
153+
console.error(VipColor.dim(e.stack?.split('\n').slice(1).join('\n')))
154154

155155
// 手动执行,创建release
156156
if (webUrl) {

packages/changelog/src/utils/github.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { $fetch } from 'ofetch'
2-
import { vipColor, vipQs } from '@142vip/utils'
2+
import { VipColor, vipQs } from '@142vip/utils'
33
import type {
44
AuthorInfo,
55
ChangelogOptions,
@@ -32,7 +32,7 @@ export async function sendRelease(options: ChangelogOptions, content: string): P
3232
prerelease: options.prerelease,
3333
tag_name: options.to,
3434
}
35-
console.log(vipColor.cyan(method === 'POST'
35+
console.log(VipColor.cyan(method === 'POST'
3636
? 'Creating release notes...'
3737
: 'Updating release notes...'),
3838
)
@@ -41,7 +41,7 @@ export async function sendRelease(options: ChangelogOptions, content: string): P
4141
body: JSON.stringify(body),
4242
headers,
4343
})
44-
console.log(vipColor.green(`Released on ${res.html_url}`))
44+
console.log(VipColor.green(`Released on ${res.html_url}`))
4545
}
4646

4747
function getHeaders(options: ChangelogOptions) {
@@ -162,8 +162,8 @@ export function generateWebUrl(config: any, markdown: string): string {
162162
*/
163163
export function printUrl(webUrl: string, success: boolean = true): void {
164164
const errMsg = success
165-
? `\n${vipColor.yellow('使用以下链接手动发布新的版本:')}\n`
166-
: `\n${vipColor.red('无法创建发布。使用以下链接手动创建:')}\n`
165+
? `\n${VipColor.yellow('使用以下链接手动发布新的版本:')}\n`
166+
: `\n${VipColor.red('无法创建发布。使用以下链接手动创建:')}\n`
167167

168-
console.error(`${errMsg}${vipColor.yellow(webUrl)}\n`)
168+
console.error(`${errMsg}${VipColor.yellow(webUrl)}\n`)
169169
}

packages/fairy-cli/src/commands/release.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import process from 'node:process'
22
import type { VersionBumpOptions } from '@142vip/release-version'
33
import { versionBump } from '@142vip/release-version'
44
import type { VipCommander } from '@142vip/utils'
5-
import { promptConfirm, promptList, vipColor } from '@142vip/utils'
5+
import { VipColor, promptConfirm, promptList } from '@142vip/utils'
66
import {
77
CliCommandEnum,
88
getBranchName,
@@ -87,13 +87,13 @@ function execVipRelease(args: VipReleaseExtraOptions) {
8787
defaultRepoName,
8888
...packageNames,
8989
]
90-
promptList(choices, `选择需要使用${vipColor.red('Release')}命令发布的模块名称:`)
90+
promptList(choices, `选择需要使用${VipColor.red('Release')}命令发布的模块名称:`)
9191
.then(async (packageName) => {
9292
// 确认框
93-
const isRelease = await promptConfirm(`将对模块${vipColor.green(packageName)}进行版本迭代,是否继续操作?`)
93+
const isRelease = await promptConfirm(`将对模块${VipColor.green(packageName)}进行版本迭代,是否继续操作?`)
9494

9595
if (!isRelease) {
96-
console.log(vipColor.yellow('用户取消发布操作!!'))
96+
console.log(VipColor.yellow('用户取消发布操作!!'))
9797
process.exit(0)
9898
}
9999

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { execSync } from 'node:child_process'
22
import process from 'node:process'
33
import { versionBump } from '@142vip/release-version'
4-
import { vipColor, vipSymbols } from '@142vip/utils'
4+
import { VipColor, VipSymbols } from '@142vip/utils'
55
import { getCommitLogs, getLatestTagName } from './git'
66

77
interface PackageJSON {
@@ -68,18 +68,18 @@ export function printPreCheckRelease(packageNames: string[]) {
6868
console.log('\n对仓库各模块进行版本变更校验,结果如下:\n')
6969
for (const pkg of packages) {
7070
if (pkg.release) {
71-
console.log(vipColor.red(`${vipSymbols.error} ${pkg.name}`))
71+
console.log(VipColor.red(`${VipSymbols.error} ${pkg.name}`))
7272
}
7373
else {
74-
console.log(vipColor.green(`${vipSymbols.success} ${pkg.name}`))
74+
console.log(VipColor.green(`${VipSymbols.success} ${pkg.name}`))
7575
}
7676
}
7777

7878
// 输出空行
7979
console.log()
8080

8181
if (!isRootRelease) {
82-
console.log(`${vipColor.yellow(`${vipSymbols.warning} 存在未发布的模块,请先进行模块的版本变更,再更新仓库版本!!!`)}`)
82+
console.log(`${VipColor.yellow(`${VipSymbols.warning} 存在未发布的模块,请先进行模块的版本变更,再更新仓库版本!!!`)}`)
8383
}
8484
}
8585

packages/release-version/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file. See [commit
66

77
### ✨ Features
88

9-
- 移除`log-symbols`模块,替换为`vipSymbols`变量 &nbsp;-&nbsp; by **chufan** [<samp>(6347b)</samp>](https://github.com/142vip/core-x/commit/6347bc5)
9+
- 移除`log-symbols`模块,替换为`VipSymbols`变量 &nbsp;-&nbsp; by **chufan** [<samp>(6347b)</samp>](https://github.com/142vip/core-x/commit/6347bc5)
1010

1111
**Release New Version v0.0.1-alpha.9 [👉 View New Package On NPM](https://www.npmjs.com/package/@142vip/release-version)**
1212

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import process from 'node:process'
22
import path from 'node:path'
33
import prompts from 'prompts'
44
import { bold, cyan, green } from 'kolorist'
5-
import { execShell, vipSymbols } from '@142vip/utils'
5+
import { VipSymbols, execShell } from '@142vip/utils'
66
import type { VersionBumpOptions, VersionBumpResults } from '../types'
77
import { NpmScript } from '../types'
88
import { getNewVersion } from './get-new-version'
@@ -46,7 +46,7 @@ export async function versionBump(arg: (VersionBumpOptions) | string = {}): Prom
4646
await updateFiles(operation)
4747

4848
if (operation.options.changelog) {
49-
console.log(vipSymbols.info, 'Generate CHANGELOG.md By @142vip/changelog', operation.options.execute)
49+
console.log(VipSymbols.info, 'Generate CHANGELOG.md By @142vip/changelog', operation.options.execute)
5050
try {
5151
const filePath = path.join(operation.options.cwd, 'CHANGELOG.md')
5252
const baseCommand = `changelog --output "${filePath}" --name v${operation.state.newVersion}`
@@ -56,18 +56,18 @@ export async function versionBump(arg: (VersionBumpOptions) | string = {}): Prom
5656
: { command: baseCommand, description: '普通模式,生成CHANGELOG文档' })
5757
}
5858
catch (e) {
59-
console.log(vipSymbols.error, 'Happen Error In Generate CHANGELOG!!!')
59+
console.log(VipSymbols.error, 'Happen Error In Generate CHANGELOG!!!')
6060
console.log(e)
6161
process.exit(1)
6262
}
63-
console.log(vipSymbols.success, 'Generate CHANGELOG.md Finished')
63+
console.log(VipSymbols.success, 'Generate CHANGELOG.md Finished')
6464
}
6565

6666
// 执行命令
6767
if (operation.options.execute) {
68-
console.log(vipSymbols.info, 'Executing Script', operation.options.execute)
68+
console.log(VipSymbols.info, 'Executing Script', operation.options.execute)
6969
await execShell({ command: operation.options.execute, description: '执行execute提供的命令' })
70-
console.log(vipSymbols.success, 'Script Finished')
70+
console.log(VipSymbols.success, 'Script Finished')
7171
}
7272

7373
// 运行version钩子函数
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { vipSymbols } from '@142vip/utils'
1+
import { VipSymbols } from '@142vip/utils'
22
import type { VersionBumpProgress } from '../types'
33
import { ProgressEvent } from '../types'
44

@@ -9,27 +9,27 @@ import { ProgressEvent } from '../types'
99
export function showProgress(progress: VersionBumpProgress) {
1010
switch (progress.event) {
1111
case ProgressEvent.FileUpdated:
12-
console.log(vipSymbols.success, `Updated ${progress.updatedFiles.pop()} to ${progress.newVersion}`)
12+
console.log(VipSymbols.success, `Updated ${progress.updatedFiles.pop()} to ${progress.newVersion}`)
1313
break
1414

1515
case ProgressEvent.FileSkipped:
16-
console.log(vipSymbols.info, `${progress.skippedFiles.pop()} did not need to be updated`)
16+
console.log(VipSymbols.info, `${progress.skippedFiles.pop()} did not need to be updated`)
1717
break
1818

1919
case ProgressEvent.GitCommit:
20-
console.log(vipSymbols.success, 'Git commit')
20+
console.log(VipSymbols.success, 'Git commit')
2121
break
2222

2323
case ProgressEvent.GitTag:
24-
console.log(vipSymbols.success, 'Git tag')
24+
console.log(VipSymbols.success, 'Git tag')
2525
break
2626

2727
case ProgressEvent.GitPush:
28-
console.log(vipSymbols.success, 'Git push')
28+
console.log(VipSymbols.success, 'Git push')
2929
break
3030

3131
case ProgressEvent.NpmScript:
32-
console.log(vipSymbols.success, `Npm run ${progress.script}`)
32+
console.log(VipSymbols.success, `Npm run ${progress.script}`)
3333
break
3434
}
3535
}

packages/utils/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ All notable changes to this project will be documented in this file. See [commit
111111

112112
### ✨ Features
113113

114-
- 移除`chalk`,使用`ansi-colors`模块,新增`vipColor``vipSymbols`常用终端日志输出变量 &nbsp;-&nbsp; by **chufan** [<samp>(55ae6)</samp>](https://github.com/142vip/core-x/commit/55ae636)
114+
- 移除`chalk`,使用`ansi-colors`模块,新增`VipColor``VipSymbols`常用终端日志输出变量 &nbsp;-&nbsp; by **chufan** [<samp>(55ae6)</samp>](https://github.com/142vip/core-x/commit/55ae636)
115115

116116
**Release New Version v0.0.1-alpha.2 [👉 View New Package On NPM](https://www.npmjs.com/package/@142vip/utils)**
117117

packages/utils/src/core/color.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ import { create } from 'ansi-colors'
77
/**
88
* 终端修改颜色
99
*/
10-
export const vipColor = create()
10+
export const VipColor = create()
1111

1212
/**
1313
* 终端标记
1414
*/
15-
export const vipSymbols = {
16-
success: vipColor.symbols.check,
17-
error: vipColor.symbols.cross,
18-
warning: vipColor.symbols.warning,
19-
info: vipColor.symbols.info,
20-
question: vipColor.symbols.question,
21-
heart: vipColor.symbols.heart,
22-
mark: vipColor.symbols.mark,
15+
export const VipSymbols = {
16+
success: VipColor.symbols.check,
17+
error: VipColor.symbols.cross,
18+
warning: VipColor.symbols.warning,
19+
info: VipColor.symbols.info,
20+
question: VipColor.symbols.question,
21+
heart: VipColor.symbols.heart,
22+
mark: VipColor.symbols.mark,
2323
}

0 commit comments

Comments
 (0)