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.5 KiB

8 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: 'The modular web server for productive full-stack development.'
  37. },
  38. {
  39. header: 'Synopsis',
  40. content: [
  41. '$ ws <options>',
  42. '$ ws {underline command} <options>'
  43. ]
  44. }
  45. )
  46. sections.push({
  47. content: 'Project home: {underline https://github.com/lwsjs/local-web-server}'
  48. })
  49. return sections
  50. }
  51. showVersion () {
  52. const pkg = require(path.resolve(__dirname, '..', 'package.json'))
  53. this.log(pkg.version)
  54. }
  55. }
  56. module.exports = WsCli