|
@@ -6,31 +6,66 @@ export default plop => {
|
|
|
type: 'input',
|
|
|
name: 'name',
|
|
|
message: '领域名称: '
|
|
|
- }
|
|
|
- ],
|
|
|
- actions: [
|
|
|
- {
|
|
|
- type: 'add',
|
|
|
- path: 'src/views/{{name}}/{{properCase name}}.vue',
|
|
|
- templateFile: 'plop-template/view.hbs'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'add',
|
|
|
- path: 'src/domain/{{name}}/api.ts',
|
|
|
- templateFile: 'plop-template/api.hbs'
|
|
|
},
|
|
|
{
|
|
|
- type: 'add',
|
|
|
- path: 'src/domain/{{name}}/service.ts',
|
|
|
- templateFile: 'plop-template/service.hbs'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'append',
|
|
|
- pattern: /(?=(\/\/ -- APPEND HERE --))/gi,
|
|
|
- path: 'src/router/asyncRouter.ts',
|
|
|
- templateFile: 'plop-template/router.hbs'
|
|
|
+ type: 'checkbox',
|
|
|
+ name: 'type',
|
|
|
+ message: '勾选需要生成的模板: ',
|
|
|
+ choices: [
|
|
|
+ {
|
|
|
+ name: 'api',
|
|
|
+ value: 'api',
|
|
|
+ checked: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'entity',
|
|
|
+ value: 'entity',
|
|
|
+ checked: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'service',
|
|
|
+ value: 'service',
|
|
|
+ checked: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'view',
|
|
|
+ value: 'view',
|
|
|
+ checked: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'router',
|
|
|
+ value: 'router',
|
|
|
+ checked: true
|
|
|
+ }
|
|
|
+ ]
|
|
|
}
|
|
|
- ]
|
|
|
+ ],
|
|
|
+ actions: data => {
|
|
|
+ const actions = []
|
|
|
+ data.type.forEach(type => {
|
|
|
+ if (type === 'router') {
|
|
|
+ actions.push({
|
|
|
+ type: 'append',
|
|
|
+ pattern: /(?=(\/\/ -- APPEND HERE --))/gi,
|
|
|
+ path: 'src/router/asyncRouter.ts',
|
|
|
+ templateFile: 'plop-template/router.hbs'
|
|
|
+ })
|
|
|
+ } else if (type === 'view') {
|
|
|
+ actions.push({
|
|
|
+ type: 'add',
|
|
|
+ path: 'src/views/{{camelCase name}}/{{pascalCase name}}.vue',
|
|
|
+ templateFile: `plop-template/${type}.hbs`
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ actions.push({
|
|
|
+ type: 'add',
|
|
|
+ path: `src/domain/{{camelCase name}}/${type}.ts`,
|
|
|
+ templateFile: `plop-template/${type}.hbs`
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return actions
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
plop.setGenerator('micro', {
|
|
@@ -45,7 +80,7 @@ export default plop => {
|
|
|
actions: [
|
|
|
{
|
|
|
type: 'add',
|
|
|
- path: 'src/views/micro/{{properCase name}}.vue',
|
|
|
+ path: 'src/views/micro/{{pascalCase name}}.vue',
|
|
|
templateFile: 'plop-template/micro.hbs'
|
|
|
},
|
|
|
{
|