UNPKG

@carlosbajo/roket-micro

Version:

framework para microservicios con google/pubsub

78 lines (76 loc) 2.06 kB
const fs = require('fs'); module.exports = function plopFunction(plop) { return { description: 'gilab ci generator', prompts: [ { type: 'input', name: 'deployment', message: 'name of the deployment?', validate: (value) => { if (!(/^$|-/).test(value)) { return true; } return 'invalid format'; } }, { type: 'input', name: 'image', message: 'name of the image?', validate: (value) => { if (!(/^$|-/).test(value)) { return true; } return 'invalid format'; } }, { type: 'input', name: 'container', message: 'name of the container?', validate: (value) => { if (!(/^$|-/).test(value)) { return true; } return 'invalid format'; } }, { type: 'input', name: 'devNamespace', message: 'name of the development namespace?', validate: (value) => { if (!(/^$|-/).test(value)) { return true; } return 'invalid format'; } }, { type: 'input', name: 'stagingNamespace', message: 'name of the staging namespace?', validate: (value) => { if (!(/^$|-/).test(value)) { return true; } return 'invalid format'; } }, ], actions: function res() { const set = []; if (fs.existsSync('.gitlab-ci.yml')) { fs.unlink('.gitlab-ci.yml'); set.push({ type: 'add', path: `${plop.getPlopfilePath()}/.gitlab-ci.yml`, templateFile: `${__dirname}/gitlab-ci.hbs` }); } else { set.push({ type: 'add', path: `${plop.getPlopfilePath()}/.gitlab-ci.yml`, templateFile: `${__dirname}/gitlab-ci.hbs` }); set.push({ type: 'add', path: `${plop.getPlopfilePath()}/cloudbuild.yml`, templateFile: `${__dirname}/cloudbuild.hbs` }); } return set; } }; };