.hygen.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. const config = require('./lib.config.js')
  3. module.exports = {
  4. helpers: {
  5. componentLibrary: (directoryScope, path = true) => {
  6. if (directoryScope === 'Desktop') return path ? 'apps/desktop' : 'desktop'
  7. if (directoryScope === 'Mobile') return path ? 'apps/mobile' : 'mobile'
  8. if (directoryScope === 'Shared') return 'shared'
  9. throw new Error('Directory scope not found')
  10. },
  11. getPath(type, options) {
  12. switch (type) {
  13. case 'genericComponent':
  14. return `../../app/frontend/${this.componentLibrary(options.directoryScope)}/components/${options.suffix}`
  15. case 'composable':
  16. return `../../app/frontend/${this.componentLibrary(options.directoryScope)}/composables/${options.suffix}`
  17. case 'store':
  18. return `../../app/frontend/${this.componentLibrary(options.directoryScope)}/stores/${options.suffix}`
  19. default:
  20. return type
  21. }
  22. },
  23. zammadCopyright: () => {
  24. return `Copyright (C) 2012-${new Date().getFullYear()} Zammad Foundation, https://zammad-foundation.org/`
  25. },
  26. usePrefix(name, type = 'use') {
  27. if (type === 'use') {
  28. const nameWithGenericPrefix = name.replace(
  29. new RegExp(`${config.convention.vue.use}`, 'i'),
  30. '',
  31. )
  32. return this.changeCase.camel(
  33. `${config.convention.vue.use}${this.changeCase.pascal(nameWithGenericPrefix)}`,
  34. )
  35. }
  36. if (type === 'generic') {
  37. const nameWithGenericPrefix = name.replace(
  38. new RegExp(`${config.generic.prefix}`, 'i'),
  39. '',
  40. )
  41. return this.changeCase.pascal(
  42. `${config.generic.prefix}${this.changeCase.pascal(nameWithGenericPrefix)}`,
  43. )
  44. }
  45. },
  46. },
  47. }