Verified Commit 4415264e authored by Aral Balkan's avatar Aral Balkan
Browse files

Initial command-line interface work on uninstall feature

parent 056aadf7
......@@ -6,7 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [Unreleased]
Nothing yet.
## Added
- Uninstall command.
## [10.0.1] - 2019-05-12
......
......@@ -22,16 +22,24 @@ Copy and paste the following commands into your terminal:
__Before you pipe any script into your computer, always [view the source code](https://ind.ie/web-server/install.sh) and make sure you understand what it does.__
```
```shell
wget -qO- https://ind.ie/web-server/install.sh | bash
```
### Node.js
```sh
```shell
npm i -g @ind.ie/web-server
```
## Uninstall
To uninstall the native binary (and any created artifacts, like TLS certificates, systemd services, etc.):
```shell
web-server uninstall
```
## Use
### Local
......
......@@ -27,6 +27,7 @@ function help () {
const commandVersion = command('version')
const commandHelp = command('help')
const commandUninstall = command('uninstall')
const commandLocal = command('local')
const commandGlobal = command('global')
const commandProxy = command('proxy')
......@@ -63,6 +64,7 @@ function help () {
${commandVersion}\tDisplay version and exit.
${commandHelp}\tDisplay this help screen and exit.
${commandUninstall}\tUninstall Indie Web Server.
${commandLocal}\tStart server as regular process with locally-trusted certificates.
${commandGlobal}\tStart server as regular process with globally-trusted certificates.
......
//////////////////////////////////////////////////////////////////////
//
// Command: uninstall
//
// Uninstalls Indie Web Server after prompting for confirmation.
//
//////////////////////////////////////////////////////////////////////
const webServer = require('../../index')
const clr = require('../../lib/clr')
const prompts = require('prompts')
const Graceful = require('node-graceful')
async function uninstall (options) {
console.log(webServer.version())
console.log(' 🔔 ╔═══════════════════════════════════════════════╗ ')
console.log(` ║ ${clr('WARNING!', 'yellow')} ${clr('About to uninstall Indie Web Server.', 'green')} ║`)
console.log(' ╚═══════════════════════════════════════════════╝\n')
const response = await prompts({
type: 'confirm',
name: 'confirmed',
message: 'Are you sure you want to proceed?',
initial: false,
style: 'invisible',
symbol: () => (done, aborted) => aborted ? '' : done ? ' 😉' : ' 🧐',
})
if (!response.confirmed) {
console.log('\n ❌ Aborting…\n')
Graceful.exit()
} else {
console.log('\n 👋 Uninstalling…\n')
// TODO
}
}
module.exports = uninstall
......@@ -37,8 +37,9 @@ class CommandLineInterface {
// a proxy command but web-server sync … --proxy=localhost:1313 specifies the proxy host to use
// for a sync command).
const command = {
isHelp: (commandLineOptions.h === true || commandLineOptions.help === true || positionalCommand === 'help'),
isVersion: (commandLineOptions.version === true || commandLineOptions.v === true || positionalCommand === 'version'),
isUninstall: (commandLineOptions.uninstall === true || positionalCommand === 'uninstall'),
isHelp: (commandLineOptions.h === true || commandLineOptions.help === true || positionalCommand === 'help'),
isGlobal: (commandLineOptions.global === true || positionalCommand === 'global'),
isProxy: (commandLineOptions.proxy === true || positionalCommand === 'proxy'),
// Note: --sync is a valid flag for the enable command.
......@@ -60,7 +61,7 @@ class CommandLineInterface {
this.throwError('Unknown command.')
}
const positionalCommandDidMatchCommand = ['version', 'help', 'local', 'global', 'proxy', 'sync', 'enable', 'disable', 'logs', 'status'].reduce((p, n) => p || (positionalCommand === n), false)
const positionalCommandDidMatchCommand = ['version', 'uninstall', 'help', 'local', 'global', 'proxy', 'sync', 'enable', 'disable', 'logs', 'status'].reduce((p, n) => p || (positionalCommand === n), false)
// Save the commands arguments.
command.positionalArguments = positionalCommandDidMatchCommand ? commandLineOptions._.slice(1) : commandLineOptions._
......
{
"name": "@ind.ie/web-server",
"version": "9.2.0",
"version": "10.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -3405,6 +3405,11 @@
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
"integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA=="
},
"kleur": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
"integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w=="
},
"lcid": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz",
......@@ -4409,6 +4414,14 @@
"asap": "~2.0.3"
}
},
"prompts": {
"version": "github:aral/prompts#ab2dd7452dd78bcff7720fba932ff88c2ecf7a25",
"from": "github:aral/prompts#custom-symbols-for-confirm",
"requires": {
"kleur": "^3.0.2",
"sisteransi": "^1.0.0"
}
},
"proto-list": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz",
......@@ -4865,6 +4878,11 @@
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=",
"dev": true
},
"sisteransi": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.0.tgz",
"integrity": "sha512-N+z4pHB4AmUv0SjveWRd6q1Nj5w62m5jodv+GD8lvmbY/83T/rpbJGZOnK5T149OldDj4Db07BSv9xY4K6NTPQ=="
},
"slash": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment