|
|
@ -1,15 +1,13 @@ |
|
|
|
'use strict' |
|
|
|
const Lws = require('lws') |
|
|
|
const Serve = require('lws/lib/command/serve/serve') |
|
|
|
|
|
|
|
/** |
|
|
|
* @module local-web-server |
|
|
|
*/ |
|
|
|
|
|
|
|
/** |
|
|
|
* @alias module:local-web-server |
|
|
|
*/ |
|
|
|
class LocalWebServer extends Lws { |
|
|
|
constructor (options) { |
|
|
|
class WsServe extends Serve { |
|
|
|
execute (options, argv) { |
|
|
|
const path = require('path') |
|
|
|
let stack = [ |
|
|
|
'lws-log', |
|
|
@ -27,11 +25,47 @@ class LocalWebServer extends Lws { |
|
|
|
'lws-index' |
|
|
|
] |
|
|
|
const moduleDir = path.resolve(__dirname, `../node_modules`) |
|
|
|
options = Object.assign({ stack, 'module-dir': moduleDir, 'module-prefix': 'lws-' }, options) |
|
|
|
super(options) |
|
|
|
options = { |
|
|
|
stack, |
|
|
|
'module-dir': moduleDir, |
|
|
|
'module-prefix': 'lws-' |
|
|
|
} |
|
|
|
super.execute(options, argv) |
|
|
|
} |
|
|
|
|
|
|
|
/* add command */ |
|
|
|
this.commands.set('feature-list', require('./feature-list')) |
|
|
|
usage () { |
|
|
|
const sections = super.usage() |
|
|
|
sections.shift() |
|
|
|
sections.shift() |
|
|
|
sections.pop() |
|
|
|
sections.unshift( |
|
|
|
{ |
|
|
|
header: 'local-web-server', |
|
|
|
content: 'A convenient local web server to support productive, full-stack Javascript development.' |
|
|
|
}, |
|
|
|
{ |
|
|
|
header: 'Synopsis', |
|
|
|
content: [ |
|
|
|
'$ ws <options>', |
|
|
|
'$ ws [underline]{command} <options>' |
|
|
|
] |
|
|
|
} |
|
|
|
) |
|
|
|
sections.push({ |
|
|
|
content: 'Project home: [underline]{https://github.com/lwsjs/local-web-server}' |
|
|
|
}) |
|
|
|
return sections |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @alias module:local-web-server |
|
|
|
*/ |
|
|
|
class LocalWebServer extends Lws { |
|
|
|
constructor (options) { |
|
|
|
super (options) |
|
|
|
this.commands.add(null, WsServe) |
|
|
|
this.commands.add('feature-list', require('./feature-list')) |
|
|
|
} |
|
|
|
|
|
|
|
getVersion () { |
|
|
@ -39,19 +73,6 @@ class LocalWebServer extends Lws { |
|
|
|
const pkg = require(path.resolve(__dirname, '..', 'package.json')) |
|
|
|
return pkg.version |
|
|
|
} |
|
|
|
|
|
|
|
getUsageHeader () { |
|
|
|
return { |
|
|
|
header: 'local-web-server', |
|
|
|
content: 'A convenient local web server to support productive, full-stack Javascript development.' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
getUsageFooter () { |
|
|
|
return { |
|
|
|
content: 'Project home: [underline]{https://github.com/lwsjs/local-web-server}' |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
module.exports = LocalWebServer |