|
|
@ -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,30 +25,53 @@ 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) |
|
|
|
|
|
|
|
/* add command */ |
|
|
|
this.commands.set('feature-list', require('./feature-list')) |
|
|
|
options = { |
|
|
|
stack, |
|
|
|
'module-dir': moduleDir, |
|
|
|
'module-prefix': 'lws-' |
|
|
|
} |
|
|
|
|
|
|
|
getVersion () { |
|
|
|
const path = require('path') |
|
|
|
const pkg = require(path.resolve(__dirname, '..', 'package.json')) |
|
|
|
return pkg.version |
|
|
|
super.execute(options, argv) |
|
|
|
} |
|
|
|
|
|
|
|
getUsageHeader () { |
|
|
|
return { |
|
|
|
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 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
getUsageFooter () { |
|
|
|
return { |
|
|
|
content: 'Project home: [underline]{https://github.com/lwsjs/local-web-server}' |
|
|
|
/** |
|
|
|
* @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 () { |
|
|
|
const path = require('path') |
|
|
|
const pkg = require(path.resolve(__dirname, '..', 'package.json')) |
|
|
|
return pkg.version |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|