Commit 7b2760e1 authored by Aral Balkan's avatar Aral Balkan

Document latest changes and implement rename of --global to --staging

parent dbb5cee3
......@@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## Changed
- (Breaking) Options that are not boolean flags now require an equals sign. This means that boolean flags like --live and --global can now be used before or after the path to be served whereas previously the path would not be registered if a boolean flag was used before it.
- (Breaking) The `--global` flag is now called `--staging`.
## [6.4.0] - 2019-03-31
......
......@@ -22,18 +22,34 @@ npm i -g @ind.ie/web-server
### Command-line
Start serving the current directory at https://localhost:
#### Development
Start serving the current directory at https://localhost using locally-trusted certificates:
```shell
$ web-server
```
Start serving the _site_ directory at your hostname:
#### Staging
Start serving the _site_ directory at your _hostname_ using globally-trusted Let’s Encrypt certificates:
```shell
$ web-server site --global
$ web-server --staging site
```
For example, use [ngrok](https://ngrok.com/) (Pro+) with a custom domain name that you set in your `hostname` file (e.g., in `/etc/hostname` or via `hostnamectl set-hostname <hostname>` or the equivalent for your platform). The first time you hit your staging server via your hosname it will take a little longer to load as your Let’s Encrypt certificates are being automatically provisioned by ACME TLS.
#### Live
Start serving the _site_ directory at your _hostname_ as a daemon that will run at startup and be restarted if it crashes, etc.:
```shell
$ web-server --live site
```
The `--live` option uses the [pm2](https://pm2.io/runtime/) process manager and sets up your server to (re)start automatically when you server (re)starts (requires `sudo`) and/or crashes, etc.
For example, if you run the command on a connected server that has the ar.al domain pointing to it and `ar.al` set in _/etc/hostname_ (on Unix/Linux/macOS), you will be able to access the site at https://ar.al. The first time you hit it, it will take a little longer to load as your Let’s Encrypt certificates are being automatically provisioned by ACME TLS.
## Build and test from source
......
......@@ -12,18 +12,20 @@ const arguments = require('minimist')(process.argv.slice(2), {boolean: true})
if (arguments._.length > 2 || arguments.help === true) {
const usageFolderToServe = clr('folder-to-serve', 'green')
const usagePortOption = `${clr('--port', 'yellow')} ${clr('N', 'cyan')}`
const usageGlobalOption = `${clr('--global', 'yellow')}`
const usagePortOption = `${clr('--port', 'yellow')}=${clr('N', 'cyan')}`
const usageStagingOption = `${clr('--staging', 'yellow')}`
const usageLiveOption = `${clr('--live', 'yellow')}`
const usageVersionOption = `${clr('--version', 'yellow')}`
const usage = `
${clr('Usage:', 'underline')}
${clr('web-server', 'bold')} [${usageFolderToServe}] [${usagePortOption}] [${usageGlobalOption}] [${usageVersionOption}]
${clr('web-server', 'bold')} [${usageFolderToServe}] [${usagePortOption}] [${usageStagingOption}] [${usageVersionOption}]
${usageFolderToServe}\t\tPath to the folder to serve (defaults to current folder).
${usagePortOption}\t\t\tThe port to start the server on (defaults to 443).
${usageGlobalOption}\tUse globally-trusted certificates.
${usageStagingOption}\tRun as regular process with globally-trusted certificates.
${usageLiveOption}\tRun as launch-time daemon with globally-trusted certificates.
${usageVersionOption}\t\t\tDisplay the version.
`.replace(/\n$/, '').replace(/^\n/, '')
......@@ -49,10 +51,10 @@ if (arguments.port !== undefined) {
port = parseInt(arguments.port)
}
// If global is specified, use it.
// If staging is specified, use it.
let global = false
if (arguments.global !== undefined) {
global = arguments.global === true
if (arguments.staging !== undefined) {
global = true
}
if (!fs.existsSync(pathToServe)) {
......
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