github.com/e154/smart-home@v0.17.2-0.20240311175135-e530a6e5cd45/static_source/admin/plop/component/prompt.js (about)

     1  const toUpperCase = (str) => str.charAt(0).toUpperCase() + str.slice(1)
     2  
     3  module.exports = {
     4    description: 'Create vue component',
     5    prompts: [
     6      {
     7        type: 'input',
     8        name: 'name',
     9        message: '请输入组件名称(Please enter the component name)'
    10      }
    11    ],
    12    actions: (data) => {
    13      const { name } = data
    14      const upperFirstName = toUpperCase(name)
    15  
    16      const actions = []
    17      if (name) {
    18        actions.push({
    19          type: 'add',
    20          path: `./src/components/${upperFirstName}/src/${upperFirstName}.vue`,
    21          templateFile: './plop/component/component.hbs',
    22          data: {
    23            name,
    24            upperFirstName
    25          }
    26        }, {
    27          type: 'add',
    28          path: `./src/components/${upperFirstName}/index.ts`,
    29          templateFile: './plop/component/index.hbs',
    30          data: {
    31            upperFirstName
    32          }
    33        })
    34      }
    35  
    36      return actions
    37    }
    38  }