From 8b07446f67a5e68d00725fef37061bc87643beb6 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Thu, 12 Jul 2018 16:56:26 +0300 Subject: Implement installation of NPM packages on host --- cli.js | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'cli.js') diff --git a/cli.js b/cli.js index 04fca98..348c092 100755 --- a/cli.js +++ b/cli.js @@ -236,8 +236,8 @@ vorpal } if (!args.key || !args.value) { - this.log('Please provide both "key" and "value" arguments.'); - return callback(); + this.log('Please provide both "key" and "value" arguments.'); + return callback(); } try { @@ -248,7 +248,7 @@ vorpal this.log(chalk.green(`Secret "${args.key}" set successfully.`)); } catch (err) { this.log(chalk.red(`Failed to set secret ${args.key}!`)); - this.log(chalk.red(String(err))); + this.log(chalk.red(String(err))); } callback(); }); @@ -264,8 +264,8 @@ vorpal } if (!args.key) { - this.log('Please provide the "key" argument.'); - return callback(); + this.log('Please provide the "key" argument.'); + return callback(); } try { @@ -273,7 +273,34 @@ vorpal this.log(chalk.green(`Secret "${args.key}" removed successfully.`)); } catch (err) { this.log(chalk.red(`Failed to remove secret ${args.key}!`)); - this.log(chalk.red(String(err))); + this.log(chalk.red(String(err))); + } + callback(); + }); + +vorpal + .command('package install ', `Install an NPM package on the host.`) + .action(async function (args, callback) { + try { + await checkConnection(mongoURL, this); + } catch (err) { + showMongoNotSetError(vorpal); + return callback(); + } + + if (!args.package) { + this.log('Please provide the "package" argument.'); + return callback(); + } + + try { + await models.packages.insert({ + name: args.package + }); + this.log(chalk.green(`Package "${args.package}" added successfully to list of packages to install.`)); + } catch (err) { + this.log(chalk.red(`Failed to add package ${args.package} to list of packages to install!`)); + this.log(chalk.red(String(err))); } callback(); }); -- cgit v1.3