go-view/plop/store-template/prompt.js
2022-01-19 21:29:04 +08:00

41 lines
1.1 KiB
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.

module.exports = {
description: 'create a store',
prompts: [
{
type: 'input',
name: 'name',
message: 'Please enter store namesuch as "newStoreName" :',
validate (value) {
if (!value || value.trim === '') {
return 'name is required';
}
return true;
},
}
],
actions: (data) => {
const dataName = data.name
// 首字母大写
const upperDataName = dataName.slice(0, 1).toUpperCase() + dataName.slice(1)
const actions = [
{
type: 'add',
path: `${process.cwd()}/src/store/modules/${dataName}Store/${dataName}Store}.ts`, // 这里的name就是上面定义的键
templateFile: './store-template/index.hbs',
data: {
name: data.name,
upperDataName,
}
},
{
type: 'add',
path: `${process.cwd()}/src/store/modules/${dataName}Store/${dataName}Store.d.ts`, // 这里的name就是上面定义的键
templateFile: './store-template/index.d.hbs'
},
]
return actions
}
}