| 10 | const config = require('../config.js'); |
| 11 | |
| 12 | class InitCommand extends Command { |
| 13 | |
| 14 | constructor() { |
| 15 | |
| 16 | super('init'); |
| 17 | |
| 18 | } |
| 19 | |
| 20 | help() { |
| 21 | |
| 22 | return { |
| 23 | description: 'Initializes Autocode workspace', |
| 24 | args: [ |
| 25 | 'environment' |
| 26 | ], |
| 27 | flags: { |
| 28 | f: 'Force command to overwrite existing workspace', |
| 29 | n: 'No login - don\'t require an internet connection' |
| 30 | }, |
| 31 | vflags: { |
| 32 | 'force': 'Force command to overwrite existing workspace', |
| 33 | 'no-login': 'No login - don\'t require an internet connection' |
| 34 | } |
| 35 | }; |
| 36 | |
| 37 | } |
| 38 | |
| 39 | async run (params, callback) { |
| 40 | |
| 41 | let host = params.flags.h ? params.flags.h[0] : 'https://api.autocode.com'; |
| 42 | let port = params.flags.p && params.flags.p[0]; |
| 43 | |
| 44 | let force = params.flags.hasOwnProperty('f') || params.vflags.hasOwnProperty('force'); |
| 45 | let nologin = params.flags.hasOwnProperty('n') || params.vflags.hasOwnProperty('no-login'); |
| 46 | |
| 47 | if (!force && config.workspace()) { |
| 48 | console.log(); |
| 49 | console.log(chalk.bold.red('Oops!')); |
| 50 | console.log(); |
| 51 | console.log(`An Autocode workspace has already been set.`); |
| 52 | console.log(`The path of the Autocode workspace is:`) |
| 53 | console.log(` ${chalk.bold(config.workspace())}`); |
| 54 | console.log(); |
| 55 | console.log(`Use ${chalk.bold('lib init --force')} to override and set a new workspace.`); |
| 56 | console.log(); |
| 57 | return callback(null); |
| 58 | } |
| 59 | |
| 60 | config.initialize(process.cwd()); |
| 61 | |
| 62 | let cb = (err) => { |
| 63 | if (err) { |
| 64 | return callback(err); |
| 65 | } |
| 66 | console.log(); |
| 67 | console.log(chalk.bold.green(`Congratulations!`)); |
| 68 | console.log(`Your Autocode development environment has been initialized.`); |
| 69 | console.log(); |
nothing calls this directly
no outgoing calls
no test coverage detected