| 31 | }; |
| 32 | |
| 33 | class GetCommand extends Command { |
| 34 | |
| 35 | constructor() { |
| 36 | |
| 37 | super('download'); |
| 38 | |
| 39 | } |
| 40 | |
| 41 | help() { |
| 42 | |
| 43 | return { |
| 44 | description: 'Retrieves and extracts Autocode package', |
| 45 | args: [ |
| 46 | 'username/name OR username/name@env OR username/name@version' |
| 47 | ], |
| 48 | flags: { |
| 49 | w: 'Write over - overwrite the target directory contents' |
| 50 | }, |
| 51 | vflags: { |
| 52 | 'write-over': 'Write over - overwrite the target directory contents' |
| 53 | } |
| 54 | }; |
| 55 | |
| 56 | } |
| 57 | |
| 58 | run(params, callback) { |
| 59 | |
| 60 | let service = params.args[0] || ''; |
| 61 | if (!service) { |
| 62 | console.log(); |
| 63 | console.log(chalk.bold.red('Oops!')); |
| 64 | console.log(); |
| 65 | console.log(`Please specify a service name`); |
| 66 | console.log(`Use ${chalk.bold('username/name')} for latest release,`); |
| 67 | console.log(`Or ${chalk.bold('username/name@env')} or ${chalk.bold('username/name@version')} for specific environments and versions`); |
| 68 | console.log(); |
| 69 | return callback(null); |
| 70 | } |
| 71 | |
| 72 | let outputPath = params.flags.o || params.vflags.output || []; |
| 73 | outputPath = outputPath[0] || '.'; |
| 74 | |
| 75 | let write = params.flags.hasOwnProperty('w') || params.vflags.hasOwnProperty('write-over'); |
| 76 | |
| 77 | let pathname = path.join(outputPath, service); |
| 78 | pathname = outputPath[0] !== '/' ? path.join(process.cwd(), pathname) : pathname; |
| 79 | |
| 80 | if (!config.location(0)) { |
| 81 | console.log(); |
| 82 | console.log(chalk.bold.red('Oops!')); |
| 83 | console.log(); |
| 84 | console.log(`You're trying to retrieve a package,`); |
| 85 | console.log(`But you're not in your root Autocode project directory.`); |
| 86 | console.log(); |
| 87 | if (!config.workspace()) { |
| 88 | console.log(`Initialize a workspace first with:`); |
| 89 | console.log(`\t${chalk.bold('lib init')}`); |
| 90 | } else { |
nothing calls this directly
no outgoing calls
no test coverage detected