| 31 | } |
| 32 | |
| 33 | class CreateCommand extends Command { |
| 34 | |
| 35 | constructor() { |
| 36 | |
| 37 | super('create'); |
| 38 | |
| 39 | } |
| 40 | |
| 41 | help() { |
| 42 | |
| 43 | return { |
| 44 | description: 'Creates a new (local) service', |
| 45 | args: [ |
| 46 | 'service' |
| 47 | ], |
| 48 | flags: { |
| 49 | n: 'No login - don\'t require an internet connection', |
| 50 | w: 'Write over - overwrite the current directory contents' |
| 51 | }, |
| 52 | vflags: { |
| 53 | 'no-login': 'No login - don\'t require an internet connection', |
| 54 | 'write-over': 'Write over - overwrite the current directory contents' |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | } |
| 59 | |
| 60 | run(params, callback) { |
| 61 | |
| 62 | let name = params.args[0]; |
| 63 | |
| 64 | let host = params.flags.h ? params.flags.h[0] : 'https://api.autocode.com'; |
| 65 | let port = params.flags.p && params.flags.p[0]; |
| 66 | |
| 67 | let nologin = params.flags.hasOwnProperty('n') || params.vflags.hasOwnProperty('no-login'); |
| 68 | |
| 69 | let write = params.flags.hasOwnProperty('w') || params.vflags.hasOwnProperty('write-over'); |
| 70 | |
| 71 | let build = DEFAULT_BUILD; |
| 72 | |
| 73 | if (!config.location(0)) { |
| 74 | console.log(); |
| 75 | console.log(chalk.bold.red('Oops!')); |
| 76 | console.log(); |
| 77 | console.log(`You're trying to create a new service in development,`); |
| 78 | console.log(`But you're not in your root Autocode project directory.`); |
| 79 | console.log(); |
| 80 | if (!config.workspace()) { |
| 81 | console.log(`Initialize a workspace first with:`); |
| 82 | console.log(`\t${chalk.bold('lib init')}`); |
| 83 | } else { |
| 84 | console.log('Visit your workspace directory with:'); |
| 85 | console.log(`\t${chalk.bold('cd ' + config.workspace())}`); |
| 86 | } |
| 87 | console.log(); |
| 88 | return callback(null); |
| 89 | } |
| 90 |
nothing calls this directly
no outgoing calls
no test coverage detected