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.

67 lines
1.5 KiB

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