From 99f5b19d27328ea9cc09fe7c7196e82a711ba602 Mon Sep 17 00:00:00 2001 From: Lloyd Brookes Date: Sat, 25 Jun 2016 15:24:30 +0100 Subject: [PATCH] update stack examples and deps --- .../custom/cache-control/.local-web-server.json | 3 --- example/custom/cache-control/server.js | 18 ------------- example/custom/live-reload-optional/server.js | 19 ------------- example/custom/live-reload/server.js | 9 ------- example/stack/cache-control.js | 24 ++++++++++------- .../live-reload-optional}/index.html | 2 +- example/stack/live-reload-optional/stack.js | 24 +++++++++++++++++ .../live-reload}/index.html | 0 example/stack/live-reload/stack.js | 14 ++++++++++ lib/local-web-server.js | 3 +-- package.json | 31 +++++----------------- 11 files changed, 60 insertions(+), 87 deletions(-) delete mode 100644 example/custom/cache-control/.local-web-server.json delete mode 100644 example/custom/cache-control/server.js delete mode 100644 example/custom/live-reload-optional/server.js delete mode 100644 example/custom/live-reload/server.js rename example/{custom/live-reload => stack/live-reload-optional}/index.html (73%) create mode 100644 example/stack/live-reload-optional/stack.js rename example/{custom/live-reload-optional => stack/live-reload}/index.html (100%) create mode 100644 example/stack/live-reload/stack.js diff --git a/example/custom/cache-control/.local-web-server.json b/example/custom/cache-control/.local-web-server.json deleted file mode 100644 index 89cb0a2..0000000 --- a/example/custom/cache-control/.local-web-server.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "maxage": 2000 -} diff --git a/example/custom/cache-control/server.js b/example/custom/cache-control/server.js deleted file mode 100644 index f72e532..0000000 --- a/example/custom/cache-control/server.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict' -const LocalWebServer = require('../../') -const cacheControl = require('koa-cache-control') - -const ws = new LocalWebServer() -ws.addLogging('dev') - .add({ - optionDefinitions: { - name: 'maxage', type: Number, - description: 'The maxage to set on each response.' - }, - middleware: function (options) { - return cacheControl({ maxAge: options.maxage }) - } - }) - .addStatic() - .addIndex() - .listen() diff --git a/example/custom/live-reload-optional/server.js b/example/custom/live-reload-optional/server.js deleted file mode 100644 index 7c48b99..0000000 --- a/example/custom/live-reload-optional/server.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict' -const Cli = require('../../') -const liveReload = require('koa-livereload') - -const ws = new Cli() -ws.addLogging('dev') - .add({ - optionDefinitions: { - name: 'live-reload', type: Boolean, - description: 'Add live reload.' - }, - middleware: function (options) { - if (options['live-reload']) { - return liveReload() - } - } - }) - .addStatic() - .listen() diff --git a/example/custom/live-reload/server.js b/example/custom/live-reload/server.js deleted file mode 100644 index 9f2a00e..0000000 --- a/example/custom/live-reload/server.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict' -const Cli = require('../../') -const liveReload = require('koa-livereload') - -const ws = new Cli() -ws.addLogging('dev') - .add({ middleware: liveReload }) - .addStatic() - .listen() diff --git a/example/stack/cache-control.js b/example/stack/cache-control.js index 52863aa..074a52e 100644 --- a/example/stack/cache-control.js +++ b/example/stack/cache-control.js @@ -5,19 +5,23 @@ const DefaultStack = require('local-web-server-default-stack') class CacheControl extends DefaultStack { addAll () { - this.addLogging('dev') - .add({ - optionDefinitions: { - name: 'maxage', type: Number, - description: 'The maxage to set on each response.' - }, - middleware: function (options) { - return cacheControl({ maxAge: options.maxage }) - } - }) + return this.addLogging('dev') + .addCacheControl() .addStatic() .addIndex() } + addCacheControl () { + this.add({ + optionDefinitions: { + name: 'maxage', type: Number, + description: 'The maxage to set on each response.' + }, + middleware: function (options) { + return cacheControl({ maxAge: options.maxage }) + } + }) + return this + } } module.exports = CacheControl diff --git a/example/custom/live-reload/index.html b/example/stack/live-reload-optional/index.html similarity index 73% rename from example/custom/live-reload/index.html rename to example/stack/live-reload-optional/index.html index 0cc6591..f467990 100644 --- a/example/custom/live-reload/index.html +++ b/example/stack/live-reload-optional/index.html @@ -5,6 +5,6 @@ live-reload demo -

Live reloaded attached

+

Live reloaded potentially attached

diff --git a/example/stack/live-reload-optional/stack.js b/example/stack/live-reload-optional/stack.js new file mode 100644 index 0000000..aa4f4ce --- /dev/null +++ b/example/stack/live-reload-optional/stack.js @@ -0,0 +1,24 @@ +'use strict' +const LocalWebServer = require('../../../') +const liveReload = require('koa-livereload') +const DefaultStack = require('local-web-server-default-stack') + +class LiveReloadStack extends DefaultStack { + addAll () { + return this.addLogging('dev') + .add({ + optionDefinitions: { + name: 'live-reload', type: Boolean, + description: 'Add live reload.' + }, + middleware: function (options) { + if (options['live-reload']) { + return liveReload() + } + } + }) + .addStatic() + } +} + +module.exports = LiveReloadStack diff --git a/example/custom/live-reload-optional/index.html b/example/stack/live-reload/index.html similarity index 100% rename from example/custom/live-reload-optional/index.html rename to example/stack/live-reload/index.html diff --git a/example/stack/live-reload/stack.js b/example/stack/live-reload/stack.js new file mode 100644 index 0000000..217a428 --- /dev/null +++ b/example/stack/live-reload/stack.js @@ -0,0 +1,14 @@ +'use strict' +const LocalWebServer = require('../../../') +const liveReload = require('koa-livereload') +const DefaultStack = require('local-web-server-default-stack') + +class LiveReloadStack extends DefaultStack { + addAll () { + return this.addLogging('dev') + .add({ middleware: liveReload }) + .addStatic() + } +} + +module.exports = LiveReloadStack diff --git a/lib/local-web-server.js b/lib/local-web-server.js index dd84681..1857cbe 100644 --- a/lib/local-web-server.js +++ b/lib/local-web-server.js @@ -5,7 +5,6 @@ const path = require('path') const arrayify = require('array-back') const t = require('typical') const CommandLineTool = require('command-line-tool') -const DefaultStack = require('local-web-server-default-stack') /** * @module local-web-server @@ -30,7 +29,7 @@ class LocalWebServer { if (/^-/.test(stackPath)) stackPath = null } - const stackModule = loadStack(stackPath) || DefaultStack + const stackModule = loadStack(stackPath) || require('local-web-server-default-stack') this.stack = new stackModule() this.stack.addAll() const middlewareOptionDefinitions = this.stack.getOptionDefinitions() diff --git a/package.json b/package.json index ff5a604..f097539 100644 --- a/package.json +++ b/package.json @@ -34,38 +34,19 @@ "dependencies": { "ansi-escape-sequences": "^2.2.2", "array-back": "^1.0.3", - "command-line-tool": "~0.3.0", - "config-master": "^2.0.2", - "http-proxy": "^1.13.3", - "kcors": "^1.2.1", + "command-line-tool": "~0.3.1", + "config-master": "^2.0.3", "koa": "^2.0.0", - "koa-bodyparser": "^3.0.0", - "koa-compose": "^3.1.0", - "koa-compress": "^1.0.9", - "koa-conditional-get": "^1.0.3", - "koa-convert": "^1.2.0", - "koa-etag": "^2.1.1", - "koa-json": "^1.1.3", - "koa-mock-response": "0.0.2", - "koa-morgan": "^1.0.1", - "koa-rewrite": "^2.1.0", - "koa-route": "^3.0.0", - "koa-send": "^3.2.0", - "koa-serve-index": "^1.1.1", - "koa-static": "^2.0.0", - "local-web-server-stack": "github:75lb/local-web-server-stack", - "path-to-regexp": "^1.5.0", - "reduce-flatten": "^1.0.0", - "stream-log-stats": "^1.1.3", - "test-value": "^2.0.0", + "local-web-server-default-stack": "github:local-web-server/default-stack", + "reduce-flatten": "^1.0.1", "typical": "^2.4.2", "walk-back": "^2.0.1" }, "devDependencies": { "jsdoc-to-markdown": "^1.3.6", "koa-cache-control": "^1.0.0", - "koa-livereload": "^0.1.23", + "koa-livereload": "~0.2.0", "req-then": "~0.2.4", - "tape": "^4.5.1" + "tape": "^4.6.0" } }