Common front-end components for Web using the Tesseract design system, written for React. https://make.modal.sh/tesseract/web/react/common
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

69 řádky
1.9 KiB

  1. #!/usr/bin/env node
  2. const { promises } = require('fs')
  3. const path = require('path')
  4. const childProcess = require('child_process')
  5. const docgen = require('react-docgen-typescript')
  6. const main = async () => {
  7. const configFilePath = path.resolve(process.cwd(), 'docs.config.json')
  8. const docsConfigBuffer = await promises.readFile(configFilePath)
  9. const docsConfigString = docsConfigBuffer.toString('utf-8')
  10. const docsConfig = JSON.parse(docsConfigString)
  11. try {
  12. //await promises.mkdir('.docs')
  13. //await childProcess.exec('npx create-next-app dummy-docs --ts')
  14. //await promises.rmdir('.docs')
  15. //await promises.rename('dummy-docs', '.docs')
  16. } catch {
  17. }
  18. const getSources = (nav) => nav.reduce(
  19. (sourcesToParse, navItem) => {
  20. if (navItem?.source?.endsWith('.tsx')) {
  21. return [
  22. ...sourcesToParse,
  23. navItem,
  24. ...(Array.isArray(navItem?.children) ? getSources(navItem.children) : []),
  25. ]
  26. }
  27. return [
  28. ...sourcesToParse,
  29. ...(Array.isArray(navItem?.children) ? getSources(navItem.children) : []),
  30. ]
  31. },
  32. []
  33. )
  34. const sources = getSources(docsConfig.nav)
  35. const docgenInfo = docgen.parse(
  36. sources.map(s => path.resolve(process.cwd(), s.source)),
  37. {
  38. shouldExtractLiteralValuesFromEnum: true,
  39. shouldRemoveUndefinedFromOptional: true,
  40. propFilter: (prop) => {
  41. if (prop.declarations !== undefined && prop.declarations.length > 0) {
  42. const hasPropAdditionalDescription = prop.declarations.find((declaration) => {
  43. return !declaration.fileName.includes("node_modules");
  44. });
  45. return Boolean(hasPropAdditionalDescription);
  46. }
  47. return true;
  48. },
  49. }
  50. )
  51. const sourcesWithDocgenInfo = sources.map((s, i) => ({
  52. ...s,
  53. docgen: docgenInfo[i],
  54. }))
  55. console.log(JSON.stringify(sourcesWithDocgenInfo, null, 2))
  56. }
  57. void main()