mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 12:14:41 +01:00
chore(cli): improve
This commit is contained in:
@@ -32,6 +32,10 @@ export default defineCommand({
|
||||
content: {
|
||||
type: 'boolean',
|
||||
description: 'Create a content component (with --pro).'
|
||||
},
|
||||
template: {
|
||||
type: 'string',
|
||||
description: 'Only generate template.'
|
||||
}
|
||||
},
|
||||
async setup({ args }) {
|
||||
@@ -53,6 +57,10 @@ export default defineCommand({
|
||||
const path = resolve('.')
|
||||
|
||||
for (const template of Object.keys(templates)) {
|
||||
if (args.template && template !== args.template) {
|
||||
continue
|
||||
}
|
||||
|
||||
const { filename, contents } = templates[template](args)
|
||||
if (!contents) {
|
||||
continue
|
||||
@@ -70,6 +78,10 @@ export default defineCommand({
|
||||
consola.success(`🪄 Generated ${filePath}!`)
|
||||
}
|
||||
|
||||
if (args.template) {
|
||||
return
|
||||
}
|
||||
|
||||
const themePath = resolve(path, `src/theme/${args.prose ? 'prose/' : ''}${args.content ? 'content/' : ''}index.ts`)
|
||||
await appendFile(themePath, `export { default as ${camelCase(name)} } from './${kebabCase(name)}'`)
|
||||
await sortFile(themePath)
|
||||
|
||||
Reference in New Issue
Block a user