Skip to content

Commit 9c3af91

Browse files
committed
feat(info): remove --all
1 parent afe1d26 commit 9c3af91

File tree

8 files changed

+121
-68
lines changed

8 files changed

+121
-68
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ npx @create-uni/info@latest
5858
| UI | ui | u |[组件列表](#组件列表) |
5959
| Eslint | eslint | e | —— |
6060
| gui | gui | —— | —— |
61-
| info | info | —— | all |
61+
| info | info | —— | —— |
6262

6363
#### 📦模板列表
6464

Diff for: packages/core/src/command/actions/info.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { sync } from 'cross-spawn'
22
import { composeCommand } from '../composeCommand'
33

4-
export function actionInfoCLI(argv: any) {
4+
export function actionInfoCLI() {
55
// #if CREATE_UNI_DEV
66
// @ts-expect-error compile
77
const fullCustomCommand = 'pnpm create-uni-info'
@@ -14,7 +14,7 @@ export function actionInfoCLI(argv: any) {
1414
// #endif
1515

1616
const [command, ..._args] = fullCustomCommand.split(' ')
17-
const { error } = sync(command, [..._args, argv ?? ''], {
17+
const { error } = sync(command, [..._args], {
1818
stdio: 'inherit',
1919
})
2020

Diff for: packages/core/src/command/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const actions = {
88
console.log(helpMessage)
99
process.exit(0)
1010
},
11-
info: (argv?: any) => {
12-
actionInfoCLI(argv)
11+
info: () => {
12+
actionInfoCLI()
1313
process.exit(0)
1414
},
1515
gui: () => {
@@ -22,7 +22,7 @@ export function commandAction(argv: any) {
2222
actions.help()
2323
}
2424
else if (argv.info) {
25-
actions.info(argv)
25+
actions.info()
2626
}
2727
else if (argv.gui) {
2828
return actions.gui()

Diff for: packages/info/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"typecheck": "tsc --noEmit"
3939
},
4040
"devDependencies": {
41-
"@clack/prompts": "^0.9.0",
4241
"@create-uni/shared": "workspace:*",
4342
"@types/envinfo": "^7.8.4",
4443
"@types/minimist": "^1.2.5",

Diff for: packages/info/src/index.ts

+20-17
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@
22

33
import type { UniPresetEnvInfo } from './types'
44
import process from 'node:process'
5-
import { intro, outro, spinner } from '@clack/prompts'
6-
import { generateBanner } from '@create-uni/shared'
5+
import { generateBanner, ora } from '@create-uni/shared'
76
import envinfo from 'envinfo'
87
import { gray, italic, link, red, yellow } from 'kolorist'
98
import { uniDependenciesMap } from './constants'
10-
import { getBaseDependencies, getErrorDependencies, getUniHelperDependencies } from './utils/dependencies'
11-
import { getErrorExtensions, getUniHelperExtensions, getVolarExtensions, getVSCodeExtensions, paserExtensionList } from './utils/extensions'
9+
import { getBaseDependencies, getUniHelperDependencies } from './utils/dependencies'
10+
import { getUniHelperExtensions, getVolarExtensions, getVSCodeExtensions, paserExtensionList } from './utils/extensions'
1211
import { whichPm } from './utils/whichPm'
1312

1413
export async function getBaseEnvInfo() {
15-
const s = spinner()
16-
s.start('正在获取环境信息...')
1714
const loadingStopInfo = {
18-
message: '获取环境信息完成',
15+
message: '',
1916
code: 0,
2017
}
2118

@@ -44,7 +41,7 @@ export async function getBaseEnvInfo() {
4441
baseDependencies = getBaseDependencies(packageInfo)
4542
}
4643
else {
47-
loadingStopInfo.message = red('当前目录未安装uni-app,请在uni-app项目根目录下执行, 以获取依赖信息!!!')
44+
loadingStopInfo.message = red('当前目录未安装uni-app,请在uni-app项目根目录下执行, 以获取依赖信息!!!')
4845
loadingStopInfo.code = 1
4946
}
5047

@@ -58,17 +55,16 @@ export async function getBaseEnvInfo() {
5855
}
5956
else {
6057
if (loadingStopInfo.code === 1) {
61-
loadingStopInfo.message += `\n ${yellow('未找到vscode, 无法获取插件信息, 请自行补充vscode插件信息')}`
58+
loadingStopInfo.message += `\n${yellow('⚠️ 未找到vscode, 无法获取插件信息, 请自行补充vscode插件信息')}`
6259
}
6360
else {
64-
loadingStopInfo.message += `${yellow('未找到vscode, 无法获取插件信息, 请自行补充vscode插件信息')}`
65-
loadingStopInfo.code = 2
61+
loadingStopInfo.message += `${yellow('⚠️ 未找到vscode, 无法获取插件信息, 请自行补充vscode插件信息')}`
62+
loadingStopInfo.code = 1
6663
}
6764
}
6865

6966
const pm = await whichPm()
7067

71-
s.stop(loadingStopInfo.message, loadingStopInfo.code)
7268
return {
7369
os,
7470
node,
@@ -79,18 +75,25 @@ export async function getBaseEnvInfo() {
7975
packageInfo,
8076
uniHelperDependencies,
8177
packageManager: pm?.name,
78+
loadingStopInfo,
8279
}
8380
}
8481

8582
export async function getUniAppInfo() {
86-
const argv = process.argv?.[2]
83+
console.log(generateBanner('@uni-create/info - 快速检测 uni-app 环境信息'))
84+
console.log()
85+
const loading = ora('正在获取环境信息...').start()
8786

88-
intro(generateBanner('@uni-create/info - 快速检测 uni-app 环境信息'))
8987
// 获取环境信息
9088
const baseEnvInfo = await getBaseEnvInfo()
91-
const errorDependencies = await getErrorDependencies(argv, baseEnvInfo.uniHelperDependencies!)
92-
const errorExtensions = await getErrorExtensions(argv, baseEnvInfo.uniHelperExtensions!)
93-
outro('🎉 检测完成')
89+
const errorDependencies = baseEnvInfo.uniHelperDependencies || []
90+
const errorExtensions = baseEnvInfo.uniHelperExtensions || []
91+
loading.succeed('获取环境信息完成')
92+
93+
if (baseEnvInfo.loadingStopInfo.code !== 0) {
94+
console.log()
95+
console.log(baseEnvInfo.loadingStopInfo.message)
96+
}
9497

9598
const splitter = '----------------------------------------------'
9699
console.log()

Diff for: packages/info/src/utils/dependencies.ts

+19-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { UniPresetEnvInfo } from '../types'
2-
import question from '../question'
32

43
export function getBaseDependencies(packageInfo: UniPresetEnvInfo['npmPackages']) {
54
const baseDependenciesName = ['vue', 'vite', '@dcloudio/uni-app']
@@ -21,23 +20,23 @@ export function getUniHelperDependencies(packageInfo: UniPresetEnvInfo['npmPacka
2120
return uniHelperDependencies
2221
}
2322

24-
export async function getErrorDependencies(
25-
argv: string,
26-
uniHelperDependencies: Record<string, string>,
27-
) {
28-
if (!uniHelperDependencies)
29-
return {}
30-
let errorDependencies: Record<string, string> = {}
31-
if (argv === 'all') {
32-
errorDependencies = uniHelperDependencies
33-
}
34-
else {
35-
const uniHelperDependenciesName = Object.keys(uniHelperDependencies)
36-
const errorIndexList = await question(uniHelperDependenciesName, '请选择需要反馈的依赖')
23+
// export async function getErrorDependencies(
24+
// argv: string,
25+
// uniHelperDependencies: Record<string, string>,
26+
// ) {
27+
// if (!uniHelperDependencies)
28+
// return {}
29+
// let errorDependencies: Record<string, string> = {}
30+
// if (argv === 'all') {
31+
// errorDependencies = uniHelperDependencies
32+
// }
33+
// else {
34+
// const uniHelperDependenciesName = Object.keys(uniHelperDependencies)
35+
// const errorIndexList = await question(uniHelperDependenciesName, '请选择需要反馈的依赖')
3736

38-
errorIndexList.forEach((item) => {
39-
errorDependencies[item] = uniHelperDependencies[item]
40-
})
41-
}
42-
return errorDependencies
43-
}
37+
// errorIndexList.forEach((item) => {
38+
// errorDependencies[item] = uniHelperDependencies[item]
39+
// })
40+
// }
41+
// return errorDependencies
42+
// }

Diff for: packages/info/src/utils/extensions.ts

+22-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { execSync } from 'node:child_process'
2-
import question from '../question'
32

43
export function getVSCodeExtensions() {
54
try {
@@ -34,25 +33,25 @@ export function paserExtensionList(list: string[]) {
3433
})
3534
}
3635

37-
export async function getErrorExtensions(
38-
argv: string,
39-
uniHelperExtensions: ReturnType<typeof paserExtensionList>,
40-
) {
41-
if (!uniHelperExtensions)
42-
return []
43-
44-
const choices = uniHelperExtensions.map(item => item.name)
45-
46-
let errorExtensions: typeof uniHelperExtensions = []
47-
if (argv === 'all') {
48-
errorExtensions = uniHelperExtensions
49-
}
50-
else {
51-
const errorIndexList = await question(choices, '请选择需要反馈的vscode插件')
52-
53-
errorIndexList.forEach((item) => {
54-
errorExtensions.push(uniHelperExtensions.find(i => i.name === item)!)
55-
})
56-
}
57-
return errorExtensions
58-
}
36+
// export async function getErrorExtensions(
37+
// argv: string,
38+
// uniHelperExtensions: ReturnType<typeof paserExtensionList>,
39+
// ) {
40+
// if (!uniHelperExtensions)
41+
// return []
42+
43+
// const choices = uniHelperExtensions.map(item => item.name)
44+
45+
// let errorExtensions: typeof uniHelperExtensions = []
46+
// if (argv === 'all') {
47+
// errorExtensions = uniHelperExtensions
48+
// }
49+
// else {
50+
// const errorIndexList = await question(choices, '请选择需要反馈的vscode插件')
51+
52+
// errorIndexList.forEach((item) => {
53+
// errorExtensions.push(uniHelperExtensions.find(i => i.name === item)!)
54+
// })
55+
// }
56+
// return errorExtensions
57+
// }

Diff for: packages/shared/src/index.ts

+54-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import process from 'node:process'
2-
import { bgLightGreen, bold } from 'kolorist'
2+
3+
import { bgLightGreen, bold, green, red } from 'kolorist'
34

45
export function generateBanner(text: string) {
56
console.log()
@@ -30,3 +31,55 @@ export function generateBanner(text: string) {
3031

3132
return colorText
3233
}
34+
35+
class Ora {
36+
private message: string
37+
private interval: NodeJS.Timeout | null
38+
private frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
39+
private cross = '✖'
40+
private tick = '✔'
41+
42+
constructor(message: string) {
43+
this.message = message
44+
this.interval = null
45+
}
46+
47+
private setFinishMessage(newMessage: string): string {
48+
return newMessage + ' '.repeat(this.message.length - newMessage.length)
49+
}
50+
51+
start(): Ora {
52+
let i = 0
53+
process.stdout.write('\r' + `${green(this.frames[i % 9])} ${this.message}`)
54+
this.interval = setInterval(() => {
55+
process.stdout.write('\r' + `${green(this.frames[i % 9])} ${this.message}`)
56+
i++
57+
}, 100)
58+
return this
59+
}
60+
61+
fail(message: string): void {
62+
if (!this.interval)
63+
return
64+
clearInterval(this.interval)
65+
process.stdout.write('\r' + `${red(this.cross)} ${this.setFinishMessage(message)}\n`)
66+
}
67+
68+
succeed(message: string): void {
69+
if (!this.interval)
70+
return
71+
clearInterval(this.interval)
72+
process.stdout.write('\r' + `${green(this.tick)} ${this.setFinishMessage(message)}\n`)
73+
}
74+
75+
finish(): void {
76+
if (!this.interval)
77+
return
78+
clearInterval(this.interval)
79+
process.stdout.write('')
80+
}
81+
}
82+
83+
export function ora(message: string) {
84+
return new Ora(message)
85+
}

0 commit comments

Comments
 (0)