UNPKG

express-api-cli

Version:

Cli tool for generating an express project. Instead of wasting extra time creating your project structure, start building right away

121 lines (113 loc) 2.5 kB
#!/usr/bin/env node const yargs = require('yargs'); const chalk = require('chalk'); const newProject = require('./new-project'); const newEmailConfig = require('./email-config'); const run = require('./generators'); const result = yargs .version() .command('create', 'Create a new Express API Project', (value) => { const args = value.argv._; if (args[1]) { newProject(args[1]); } else { console.log( chalk.red(` Please provide a project name. Example: exp-api create AwesomeProject `) ); } }) .command('config', 'Setup a new config', (value) => { const args = value.argv._; if (args[1] === 'email') { newEmailConfig(); } else { console.log( chalk.red(` Please provide a configuration type eg 'email'. Example: exp-api config email `) ); } }) .usage( ` Usage: Speed up your application development with express-api-cli ` ) .option('v', { alias: 'version', describe: 'Get express-api-cli version', type: 'string' }) .option('m', { alias: 'model', describe: 'Create new model', type: 'string' }) .option('c', { alias: 'controller', describe: 'Create new controller', type: 'string' }) .option('s', { alias: 'service', describe: 'Create new service', type: 'string' }) .option('r', { alias: 'route', describe: 'Create new route', type: 'string' }) .option('R', { alias: 'resource', describe: 'Create new resource', type: 'string' }) .option('u', { alias: 'util', describe: 'Create new utility file', type: 'string' }) .option('M', { alias: 'middleware', describe: 'Create new middleware', type: 'string' }) .option('V', { alias: 'validator', describe: 'Create new validator', type: 'string' }) .option('i', { alias: 'interface', describe: 'Create new interface', type: 'string' }) .option('T', { alias: 'test', describe: 'Create new unit and integration test', type: 'string' }) .option('U', { alias: 'unittest', describe: 'Create new unit test', type: 'string' }) .option('I', { alias: 'integrationtest', describe: 'Create new integration test', type: 'string' }) .option('C', { alias: 'config', describe: 'Create new config file', type: 'string' }) .help().argv; run(result);