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.
45 lines
1.1 KiB
45 lines
1.1 KiB
// npm run plop user user page |
|
/* eslint-disable func-names */ |
|
module.exports = function (plop) { |
|
// controller generator |
|
plop.setGenerator('view', { |
|
description: 'application views', |
|
prompts: [ |
|
{ |
|
type: 'input', |
|
name: 'path', |
|
message: 'path:', |
|
}, |
|
{ |
|
type: 'input', |
|
name: 'name', |
|
message: 'name:', |
|
}, |
|
{ |
|
type: 'input', |
|
name: 'type', |
|
message: 'type:', |
|
}, |
|
], |
|
actions: (data) => { |
|
const actions = []; |
|
actions.push({ |
|
type: 'add', |
|
path: 'src/views/{{kebabCase path}}/{{pascalCase name}}Form.vue', |
|
templateFile: 'plop-templates/view_form.hbs', |
|
}); |
|
actions.push({ |
|
type: 'add', |
|
path: 'src/views/{{kebabCase path}}/{{pascalCase name}}List.vue', |
|
templateFile: `plop-templates/view_${data.type}.hbs`, |
|
}); |
|
actions.push({ |
|
type: 'append', |
|
path: 'src/api/{{kebabCase path}}.ts', |
|
templateFile: 'plop-templates/api.hbs', |
|
data: { isList: data.type === 'list' }, |
|
}); |
|
return actions; |
|
}, |
|
}); |
|
};
|
|
|