diff --git a/cli/commands/make/component.mjs b/cli/commands/make/component.mjs index 1c9704e0..f668fe8a 100644 --- a/cli/commands/make/component.mjs +++ b/cli/commands/make/component.mjs @@ -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) diff --git a/cli/templates.mjs b/cli/templates.mjs index d0bdac36..1348ee9d 100644 --- a/cli/templates.mjs +++ b/cli/templates.mjs @@ -163,15 +163,18 @@ describe('${upperName}', () => { } } -const doc = ({ name, pro }) => { +const docs = ({ name, pro, primitive }) => { const kebabName = kebabCase(name) const upperName = splitByCase(name).map(p => upperFirst(p)).join('') return { - filename: `docs/content/${pro ? 'pro' : '3.components'}/${kebabName}.md`, + filename: `docs/content/3.components/${kebabName}.md`, contents: `--- -description: -links: ${pro +description: ''${pro + ? ` +module: ui-pro` + : ''} +links: ${primitive ? '' : ` - label: ${upperName} @@ -190,19 +193,19 @@ links: ${pro ### Props -:component-props +:component-props${pro ? '{pro}' : ''} ### Slots -:component-slots +:component-slots${pro ? '{pro}' : ''} ### Emits -:component-emits +:component-emits${pro ? '{pro}' : ''} ## Theme -:component-theme +:component-theme${pro ? '{pro}' : ''} ` } } @@ -212,5 +215,5 @@ export default { component, theme, test, - doc + docs }