diff options
| author | Jan Tuomi <jan.tuomi@eficode.com> | 2018-07-13 11:00:47 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan.tuomi@eficode.com> | 2018-07-13 11:01:24 +0300 |
| commit | a79413824414d1cda8341900becec1ea2b9d8617 (patch) | |
| tree | 39fc261ed71824961007b2ecfc87a559a68522b7 | |
| parent | 9615718012ee798f58834572cfe69c468a05027f (diff) | |
Allow user to dequeue a package installation and list packages
| -rw-r--r-- | README.md | 7 | ||||
| -rwxr-xr-x | cli.js | 55 | ||||
| -rw-r--r-- | package.json | 2 |
3 files changed, 62 insertions, 2 deletions
@@ -9,6 +9,11 @@ Small Function as a Service (FaaS) server built with Node.js and MongoDB. Useful ## Server Clone the repository to your server. + +``` +git clone https://github.com/jantuomi/faaslift.git +``` + Create a file called `.env` in the project directory and add the following fields: ``` @@ -61,6 +66,8 @@ To `require` 3rd party libraries, they have to be installed on the host server w # Security +`faaslift` relies on MongoDB for user authentication. Please use secure Mongo instance with a username and password set. + The functions are *NOT* containerized in any way! This means that code running at an endpoint is e.g. able to crash the server or manipulate other endpoints, among other evil deeds, with a little bit of tinkering. That's why this project is solely meant for prototyping purposes. # Author @@ -279,7 +279,7 @@ vorpal }); vorpal - .command('package install <package>', `Install an NPM package on the host.`) + .command('package add <package>', `Enqueue an NPM package installation on the host.`) .action(async function (args, callback) { try { await checkConnection(mongoURL, this); @@ -298,6 +298,7 @@ vorpal name: args.package }); this.log(chalk.green(`Package "${args.package}" added successfully to list of packages to install.`)); + this.log(`NOTE: Packages might take a while to be installed. The default refresh period for fetching new packages is 1 minute.`); } catch (err) { this.log(chalk.red(`Failed to add package ${args.package} to list of packages to install!`)); this.log(chalk.red(String(err))); @@ -306,6 +307,58 @@ vorpal }); vorpal + .command('package remove <package>', `Dequeue an NPM package installation on the host. NOTE: Does not uninstall already installed packages.`) + .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.remove({ + name: args.package + }); + const cmd = chalk.yellow(`npm uninstall ${args.package}`); + this.log(chalk.green(`Package "${args.package}" removed successfully from the list of packages to install.`)); + this.log(`NOTE: Packages already installed are not uninstalled by this command.`); + this.log(`To completely uninstall this package from the host, run ${cmd} in the project directory on the host server.`); + } catch (err) { + this.log(chalk.red(`Failed to remove package ${args.package} from the list of packages to install!`)); + this.log(chalk.red(String(err))); + } + callback(); + }); + +vorpal + .command('package list', `List NPM packages in the installation queue.`) + .action(async function (args, callback) { + try { + await checkConnection(mongoURL, this); + } catch (err) { + showMongoNotSetError(vorpal); + return callback(); + } + + try { + const packages = await models.packages.find({}); + packages.forEach(pkg => { + this.log(pkg.name); + }); + } catch (err) { + this.log(chalk.red(`Failed to get a list of packages.`)); + this.log(chalk.red(String(err))); + } + callback(); + }); + +vorpal .command('info', 'Show information about the session') .action(async function (args, callback) { this.log('Mongo URL: ' + chalk.yellow(mongoURL)); diff --git a/package.json b/package.json index 64855ca..e11c0ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "faaslift", - "version": "1.0.6", + "version": "1.0.7", "description": "", "main": "index.js", "scripts": { |
