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.

61 lines
1.4 KiB

8 years ago
6 years ago
8 years ago
  1. const LwsCli = require('lws/lib/cli-app')
  2. const path = require('path')
  3. class WsCli extends LwsCli {
  4. execute (options) {
  5. if (options.defaultStack) {
  6. const list = require('./default-stack')
  7. this.log(list)
  8. } else {
  9. return super.execute(options)
  10. }
  11. }
  12. getDefaultOptions () {
  13. return Object.assign(super.getDefaultOptions(), {
  14. stack: require('./default-stack').slice(),
  15. moduleDir: [ '.', path.resolve(__dirname, '..') ]
  16. })
  17. }
  18. partialDefinitions () {
  19. return super.partialDefinitions().concat([
  20. {
  21. name: 'default-stack',
  22. type: Boolean,
  23. description: 'Print the default middleware stack. Any of these built-in middlewares are available to use in a custom stack.',
  24. section: 'core'
  25. }
  26. ])
  27. }
  28. usage () {
  29. const sections = super.usage()
  30. sections.shift()
  31. sections.shift()
  32. sections.pop()
  33. sections.unshift(
  34. {
  35. header: 'local-web-server',
  36. content: 'A lean, modular web server for rapid full-stack development.'
  37. },
  38. {
  39. header: 'Synopsis',
  40. content: [
  41. '$ ws <options>'
  42. ]
  43. }
  44. )
  45. sections.push({
  46. content: 'Project home: {underline https://github.com/lwsjs/local-web-server}'
  47. })
  48. return sections
  49. }
  50. showVersion () {
  51. const pkg = require(path.resolve(__dirname, '..', 'package.json'))
  52. this.log(pkg.version)
  53. }
  54. }
  55. module.exports = WsCli