You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.4 KiB

7 years ago
  1. const ServeCommand = require('lws/lib/command/serve')
  2. const path = require('path')
  3. /**
  4. * @module local-web-server
  5. */
  6. class WsServe extends ServeCommand {
  7. execute (options, argv) {
  8. options = {
  9. stack: [
  10. 'lws-log',
  11. 'lws-cors',
  12. 'lws-json',
  13. 'lws-rewrite',
  14. 'lws-body-parser',
  15. 'lws-blacklist',
  16. 'lws-conditional-get',
  17. 'lws-mime',
  18. 'lws-compress',
  19. 'lws-mock-response',
  20. 'lws-spa',
  21. 'lws-static',
  22. 'lws-index'
  23. ],
  24. moduleDir: path.resolve(__dirname, `../../node_modules`),
  25. modulePrefix: 'lws-'
  26. }
  27. super.execute(options, argv)
  28. }
  29. usage () {
  30. const sections = super.usage()
  31. sections.shift()
  32. sections.shift()
  33. sections.pop()
  34. sections.unshift(
  35. {
  36. header: 'local-web-server',
  37. content: 'A convenient local web server to support productive, full-stack Javascript development.'
  38. },
  39. {
  40. header: 'Synopsis',
  41. content: [
  42. '$ ws <options>',
  43. '$ ws [underline]{command} <options>'
  44. ]
  45. }
  46. )
  47. sections.push({
  48. content: 'Project home: [underline]{https://github.com/lwsjs/local-web-server}'
  49. })
  50. return sections
  51. }
  52. showVersion () {
  53. const pkg = require(path.resolve(__dirname, '..', 'package.json'))
  54. console.log(pkg.version)
  55. }
  56. }
  57. module.exports = WsServe