You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.1 KiB
56 lines
1.1 KiB
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.indexOf('script') === -1 && value.indexOf('template') === -1) {
|
|
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: name,
|
|
template: data.blocks.includes('template'),
|
|
script: data.blocks.includes('script'),
|
|
style: data.blocks.includes('style')
|
|
}
|
|
}]
|
|
|
|
return actions
|
|
}
|
|
}
|