UNPKG

@carlosbajo/roket-micro

Version:

framework para microservicios con google/pubsub

33 lines (32 loc) 956 B
module.exports = function plopFunction(plop) { return { description: 'roket-micro model generator', prompts: [ { type: 'input', name: 'model', message: 'name of the model?', validate: (value) => { if (!(/^$|-/).test(value)) { return true; } return 'invalid format'; } }, ], actions: function res(answer) { const set = []; answer.strModel = answer.model; answer.strModel = answer.strModel.substr(0, 0) + answer.strModel.charAt(0).toUpperCase() + answer.strModel.substr(0 + 1); set.push({ type: 'add', path: `${plop.getPlopfilePath()}/api/models/${answer.model}.js`, templateFile: `${__dirname}/models.hbs` }); set.push({ type: 'add', path: `${plop.getPlopfilePath()}/api/schemas/${answer.model}.js`, templateFile: `${__dirname}/schemas.hbs` }); return set; } }; };