forked from natuka/web.puabadge.com
Initial commit
This commit is contained in:
commit
84061c9a18
243 files changed
+63148
No files matched your search
@@ -0,0 +1,16 @@
|
||||
{{#if template}}
|
||||
<template>
|
||||
<div></div>
|
||||
</template>
|
||||
{{/if}}
|
||||
|
||||
{{#if script}}
|
||||
<script setup lang="ts">
|
||||
</script>
|
||||
{{/if}}
|
||||
|
||||
{{#if style}}
|
||||
<style lang="less" scoped>
|
||||
</style>
|
||||
{{/if}}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
const { notEmpty } = require('../utils.js')
|
||||
|
||||
module.exports = {
|
||||
description: 'generate vue component',
|
||||
prompts: [{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'component name please',
|
||||
validate: notEmpty('name'),
|
||||
},
|
||||
{
|
||||
type: 'checkbox',
|
||||
name: 'blocks',
|
||||
message: 'Blocks:',
|
||||
choices: [{
|
||||
name: '<template>',
|
||||
value: 'template',
|
||||
checked: true,
|
||||
},
|
||||
{
|
||||
name: '<script>',
|
||||
value: 'script',
|
||||
checked: true,
|
||||
},
|
||||
{
|
||||
name: 'style',
|
||||
value: 'style',
|
||||
checked: true,
|
||||
},
|
||||
],
|
||||
validate(value) {
|
||||
if (!value.includes('script') && !value.includes('template'))
|
||||
return 'Components require at least a <script> or <template> tag.'
|
||||
|
||||
return true
|
||||
},
|
||||
},
|
||||
],
|
||||
actions: (data) => {
|
||||
const name = '{{properCase name}}'
|
||||
const actions = [{
|
||||
type: 'add',
|
||||
path: `src/components/${name}/index.vue`,
|
||||
templateFile: 'plop-templates/component/index.hbs',
|
||||
data: {
|
||||
name,
|
||||
template: data.blocks.includes('template'),
|
||||
script: data.blocks.includes('script'),
|
||||
style: data.blocks.includes('style'),
|
||||
},
|
||||
}]
|
||||
|
||||
return actions
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
exports.notEmpty = name => v => !v || v.trim() === '' ? `${name} is required` : true
|
||||
@@ -0,0 +1,16 @@
|
||||
{{#if template}}
|
||||
<template>
|
||||
<div></div>
|
||||
</template>
|
||||
{{/if}}
|
||||
|
||||
{{#if script}}
|
||||
<script setup lang="ts">
|
||||
</script>
|
||||
{{/if}}
|
||||
|
||||
{{#if style}}
|
||||
<style lang="less" scoped>
|
||||
</style>
|
||||
{{/if}}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
const { notEmpty } = require('../utils.js')
|
||||
|
||||
module.exports = {
|
||||
description: 'generate a view',
|
||||
prompts: [{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'view name please',
|
||||
validate: notEmpty('name'),
|
||||
},
|
||||
{
|
||||
type: 'checkbox',
|
||||
name: 'blocks',
|
||||
message: 'Blocks:',
|
||||
choices: [{
|
||||
name: '<template>',
|
||||
value: 'template',
|
||||
checked: true,
|
||||
},
|
||||
{
|
||||
name: '<script>',
|
||||
value: 'script',
|
||||
checked: true,
|
||||
},
|
||||
{
|
||||
name: 'style',
|
||||
value: 'style',
|
||||
checked: true,
|
||||
},
|
||||
],
|
||||
validate(value) {
|
||||
if (!value.includes('script') && !value.includes('template'))
|
||||
return 'View require at least a <script> or <template> tag.'
|
||||
|
||||
return true
|
||||
},
|
||||
},
|
||||
],
|
||||
actions: (data) => {
|
||||
const name = '{{name}}'
|
||||
const actions = [{
|
||||
type: 'add',
|
||||
path: `src/views/${name}/index.vue`,
|
||||
templateFile: 'plop-templates/view/index.hbs',
|
||||
data: {
|
||||
name,
|
||||
template: data.blocks.includes('template'),
|
||||
script: data.blocks.includes('script'),
|
||||
style: data.blocks.includes('style'),
|
||||
},
|
||||
}]
|
||||
|
||||
return actions
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user