Common front-end components for Web using the Tesseract design system, written for React. https://make.modal.sh/tesseract/web/react/common
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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()