mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
build: 缩短构建组件时CLI提示长度
- 之前展示的是完整路径 当路径过长时会导致提示信息过长 选取体验很差 - 做统一截取处理 只展示能够区分当前组件的部分
This commit is contained in:
parent
9576cfc7df
commit
bd3b452631
@ -1,17 +1,23 @@
|
|||||||
|
import path from 'path'
|
||||||
import glob from 'glob'
|
import glob from 'glob'
|
||||||
import { buildByEntry } from './config'
|
import { buildByEntry } from './config'
|
||||||
|
|
||||||
|
const shorten = (p: string) => path.dirname(p).replace('./registry/lib/', '')
|
||||||
|
|
||||||
export const builders = Object.fromEntries(
|
export const builders = Object.fromEntries(
|
||||||
['component', 'plugin', 'doc'].map(type => {
|
['component', 'plugin', 'doc'].map(type => {
|
||||||
const src = `./registry/lib/${type}s/`
|
const src = `./registry/lib/${type}s/`
|
||||||
return [
|
return [
|
||||||
type,
|
type,
|
||||||
async ({ buildAll = false } = {}) => {
|
async ({ buildAll = false } = {}) => {
|
||||||
const entries = glob.sync(`${src}**/index.ts`)
|
const entries = glob.sync(`${src}**/index.ts`).map(entry => ({
|
||||||
|
name: shorten(entry),
|
||||||
|
value: entry,
|
||||||
|
}))
|
||||||
|
|
||||||
if (buildAll) {
|
if (buildAll) {
|
||||||
console.log(`[build all] discovered ${entries.length} ${type}s`)
|
console.log(`[build all] discovered ${entries.length} ${type}s`)
|
||||||
return entries.map(entry => buildByEntry({ src, type, entry }))
|
return entries.map(({ value }) => buildByEntry({ src, type, entry: value }))
|
||||||
}
|
}
|
||||||
|
|
||||||
let entry: string
|
let entry: string
|
||||||
@ -25,9 +31,9 @@ export const builders = Object.fromEntries(
|
|||||||
})
|
})
|
||||||
entry = await prompt.run()
|
entry = await prompt.run()
|
||||||
} else {
|
} else {
|
||||||
;[entry] = entries
|
;[{ value: entry }] = entries
|
||||||
console.log(`Build target · ${entry}`)
|
|
||||||
}
|
}
|
||||||
|
console.log(`Build target · ${entry}`)
|
||||||
return [buildByEntry({ src, type, entry })]
|
return [buildByEntry({ src, type, entry })]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user