vue-pro/yudao-ui-admin-vue3/plop/view/prompt.js
2022-07-18 19:06:37 +08:00

38 lines
791 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const toUpperCase = (str) => str.charAt(0).toUpperCase() + str.slice(1)
module.exports = {
description: 'Create vue view',
prompts: [
{
type: 'input',
name: 'path',
message: '请输入路径Please enter a path',
default: 'views'
},
{
type: 'input',
name: 'name',
message: '请输入模块名称Please enter module name'
}
],
actions: (data) => {
const { name, path } = data
const upperFirstName = toUpperCase(name)
const actions = []
if (name) {
actions.push({
type: 'add',
path: `./src/${path}/${upperFirstName}.vue`,
templateFile: './plop/view/view.hbs',
data: {
name,
upperFirstName
}
})
}
return actions
}
}