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.

65 lines
1.5 KiB

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