@powerhousedao/codegen 5.1.0-dev.9 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/error.esm.t +3 -3
  2. package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.js +3 -1
  3. package/dist/src/codegen/__tests__/config.d.ts +0 -1
  4. package/dist/src/codegen/__tests__/config.d.ts.map +1 -1
  5. package/dist/src/codegen/__tests__/config.js +0 -1
  6. package/dist/src/codegen/__tests__/config.js.map +1 -1
  7. package/dist/src/codegen/__tests__/generate-doc-model.test.js +14 -39
  8. package/dist/src/codegen/__tests__/generate-doc-model.test.js.map +1 -1
  9. package/dist/src/codegen/__tests__/generate-drive-editor.test.js +3 -6
  10. package/dist/src/codegen/__tests__/generate-drive-editor.test.js.map +1 -1
  11. package/dist/src/codegen/__tests__/generate-editor.test.js +7 -8
  12. package/dist/src/codegen/__tests__/generate-editor.test.js.map +1 -1
  13. package/dist/src/codegen/generate.d.ts +6 -26
  14. package/dist/src/codegen/generate.d.ts.map +1 -1
  15. package/dist/src/codegen/generate.js +40 -139
  16. package/dist/src/codegen/generate.js.map +1 -1
  17. package/dist/src/codegen/hygen.d.ts +8 -1
  18. package/dist/src/codegen/hygen.d.ts.map +1 -1
  19. package/dist/src/codegen/hygen.js +67 -11
  20. package/dist/src/codegen/hygen.js.map +1 -1
  21. package/dist/src/index.d.ts +1 -0
  22. package/dist/src/index.d.ts.map +1 -1
  23. package/dist/src/index.js +1 -0
  24. package/dist/src/index.js.map +1 -1
  25. package/dist/src/ts-morph-utils.d.ts +48 -0
  26. package/dist/src/ts-morph-utils.d.ts.map +1 -0
  27. package/dist/src/ts-morph-utils.js +207 -0
  28. package/dist/src/ts-morph-utils.js.map +1 -0
  29. package/dist/tsconfig.tsbuildinfo +1 -1
  30. package/package.json +8 -11
  31. package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/lib.esm.t +0 -9
  32. package/dist/src/ts-morph-utils/constants.d.ts +0 -18
  33. package/dist/src/ts-morph-utils/constants.d.ts.map +0 -1
  34. package/dist/src/ts-morph-utils/constants.js +0 -18
  35. package/dist/src/ts-morph-utils/constants.js.map +0 -1
  36. package/dist/src/ts-morph-utils/file-builders/document-editor.d.ts +0 -28
  37. package/dist/src/ts-morph-utils/file-builders/document-editor.d.ts.map +0 -1
  38. package/dist/src/ts-morph-utils/file-builders/document-editor.js +0 -305
  39. package/dist/src/ts-morph-utils/file-builders/document-editor.js.map +0 -1
  40. package/dist/src/ts-morph-utils/file-builders/document-model/gen-dir.d.ts +0 -3
  41. package/dist/src/ts-morph-utils/file-builders/document-model/gen-dir.d.ts.map +0 -1
  42. package/dist/src/ts-morph-utils/file-builders/document-model/gen-dir.js +0 -207
  43. package/dist/src/ts-morph-utils/file-builders/document-model/gen-dir.js.map +0 -1
  44. package/dist/src/ts-morph-utils/file-builders/document-model/root-dir.d.ts +0 -3
  45. package/dist/src/ts-morph-utils/file-builders/document-model/root-dir.d.ts.map +0 -1
  46. package/dist/src/ts-morph-utils/file-builders/document-model/root-dir.js +0 -58
  47. package/dist/src/ts-morph-utils/file-builders/document-model/root-dir.js.map +0 -1
  48. package/dist/src/ts-morph-utils/file-builders/document-model/src-dir.d.ts +0 -3
  49. package/dist/src/ts-morph-utils/file-builders/document-model/src-dir.d.ts.map +0 -1
  50. package/dist/src/ts-morph-utils/file-builders/document-model/src-dir.js +0 -64
  51. package/dist/src/ts-morph-utils/file-builders/document-model/src-dir.js.map +0 -1
  52. package/dist/src/ts-morph-utils/file-builders/document-model/types.d.ts +0 -12
  53. package/dist/src/ts-morph-utils/file-builders/document-model/types.d.ts.map +0 -1
  54. package/dist/src/ts-morph-utils/file-builders/document-model/types.js +0 -2
  55. package/dist/src/ts-morph-utils/file-builders/document-model/types.js.map +0 -1
  56. package/dist/src/ts-morph-utils/file-builders/document-model.d.ts +0 -8
  57. package/dist/src/ts-morph-utils/file-builders/document-model.d.ts.map +0 -1
  58. package/dist/src/ts-morph-utils/file-builders/document-model.js +0 -68
  59. package/dist/src/ts-morph-utils/file-builders/document-model.js.map +0 -1
  60. package/dist/src/ts-morph-utils/file-builders/drive-editor.d.ts +0 -56
  61. package/dist/src/ts-morph-utils/file-builders/drive-editor.d.ts.map +0 -1
  62. package/dist/src/ts-morph-utils/file-builders/drive-editor.js +0 -341
  63. package/dist/src/ts-morph-utils/file-builders/drive-editor.js.map +0 -1
  64. package/dist/src/ts-morph-utils/file-builders/editor-common.d.ts +0 -3
  65. package/dist/src/ts-morph-utils/file-builders/editor-common.d.ts.map +0 -1
  66. package/dist/src/ts-morph-utils/file-builders/editor-common.js +0 -15
  67. package/dist/src/ts-morph-utils/file-builders/editor-common.js.map +0 -1
  68. package/dist/src/ts-morph-utils/file-builders/index-files.d.ts +0 -17
  69. package/dist/src/ts-morph-utils/file-builders/index-files.d.ts.map +0 -1
  70. package/dist/src/ts-morph-utils/file-builders/index-files.js +0 -21
  71. package/dist/src/ts-morph-utils/file-builders/index-files.js.map +0 -1
  72. package/dist/src/ts-morph-utils/file-builders/module-files.d.ts +0 -25
  73. package/dist/src/ts-morph-utils/file-builders/module-files.d.ts.map +0 -1
  74. package/dist/src/ts-morph-utils/file-builders/module-files.js +0 -92
  75. package/dist/src/ts-morph-utils/file-builders/module-files.js.map +0 -1
  76. package/dist/src/ts-morph-utils/file-builders/subgraphs.d.ts +0 -6
  77. package/dist/src/ts-morph-utils/file-builders/subgraphs.d.ts.map +0 -1
  78. package/dist/src/ts-morph-utils/file-builders/subgraphs.js +0 -53
  79. package/dist/src/ts-morph-utils/file-builders/subgraphs.js.map +0 -1
  80. package/dist/src/ts-morph-utils/file-builders/types.d.ts +0 -13
  81. package/dist/src/ts-morph-utils/file-builders/types.d.ts.map +0 -1
  82. package/dist/src/ts-morph-utils/file-builders/types.js +0 -2
  83. package/dist/src/ts-morph-utils/file-builders/types.js.map +0 -1
  84. package/dist/src/ts-morph-utils/file-utils.d.ts +0 -28
  85. package/dist/src/ts-morph-utils/file-utils.d.ts.map +0 -1
  86. package/dist/src/ts-morph-utils/file-utils.js +0 -102
  87. package/dist/src/ts-morph-utils/file-utils.js.map +0 -1
  88. package/dist/src/ts-morph-utils/name-builders/common-files.d.ts +0 -5
  89. package/dist/src/ts-morph-utils/name-builders/common-files.d.ts.map +0 -1
  90. package/dist/src/ts-morph-utils/name-builders/common-files.js +0 -15
  91. package/dist/src/ts-morph-utils/name-builders/common-files.js.map +0 -1
  92. package/dist/src/ts-morph-utils/name-builders/document-model-files.d.ts +0 -4
  93. package/dist/src/ts-morph-utils/name-builders/document-model-files.d.ts.map +0 -1
  94. package/dist/src/ts-morph-utils/name-builders/document-model-files.js +0 -12
  95. package/dist/src/ts-morph-utils/name-builders/document-model-files.js.map +0 -1
  96. package/dist/src/ts-morph-utils/name-builders/editor-files.d.ts +0 -10
  97. package/dist/src/ts-morph-utils/name-builders/editor-files.d.ts.map +0 -1
  98. package/dist/src/ts-morph-utils/name-builders/editor-files.js +0 -37
  99. package/dist/src/ts-morph-utils/name-builders/editor-files.js.map +0 -1
  100. package/dist/src/ts-morph-utils/name-builders/get-file-paths.d.ts +0 -4
  101. package/dist/src/ts-morph-utils/name-builders/get-file-paths.d.ts.map +0 -1
  102. package/dist/src/ts-morph-utils/name-builders/get-file-paths.js +0 -21
  103. package/dist/src/ts-morph-utils/name-builders/get-file-paths.js.map +0 -1
  104. package/dist/src/ts-morph-utils/name-builders/get-variable-names.d.ts +0 -55
  105. package/dist/src/ts-morph-utils/name-builders/get-variable-names.d.ts.map +0 -1
  106. package/dist/src/ts-morph-utils/name-builders/get-variable-names.js +0 -153
  107. package/dist/src/ts-morph-utils/name-builders/get-variable-names.js.map +0 -1
  108. package/dist/src/ts-morph-utils/name-builders/types.d.ts +0 -14
  109. package/dist/src/ts-morph-utils/name-builders/types.d.ts.map +0 -1
  110. package/dist/src/ts-morph-utils/name-builders/types.js +0 -2
  111. package/dist/src/ts-morph-utils/name-builders/types.js.map +0 -1
  112. package/dist/src/ts-morph-utils/name-builders/variables.d.ts +0 -12
  113. package/dist/src/ts-morph-utils/name-builders/variables.d.ts.map +0 -1
  114. package/dist/src/ts-morph-utils/name-builders/variables.js +0 -35
  115. package/dist/src/ts-morph-utils/name-builders/variables.js.map +0 -1
  116. package/dist/src/ts-morph-utils/syntax-builders.d.ts +0 -72
  117. package/dist/src/ts-morph-utils/syntax-builders.d.ts.map +0 -1
  118. package/dist/src/ts-morph-utils/syntax-builders.js +0 -201
  119. package/dist/src/ts-morph-utils/syntax-builders.js.map +0 -1
  120. package/dist/src/ts-morph-utils/syntax-getters.d.ts +0 -10
  121. package/dist/src/ts-morph-utils/syntax-getters.d.ts.map +0 -1
  122. package/dist/src/ts-morph-utils/syntax-getters.js +0 -39
  123. package/dist/src/ts-morph-utils/syntax-getters.js.map +0 -1
  124. package/dist/src/ts-morph-utils/templates/document-model/actions.d.ts +0 -3
  125. package/dist/src/ts-morph-utils/templates/document-model/actions.d.ts.map +0 -1
  126. package/dist/src/ts-morph-utils/templates/document-model/actions.js +0 -28
  127. package/dist/src/ts-morph-utils/templates/document-model/actions.js.map +0 -1
  128. package/dist/src/ts-morph-utils/templates/document-model/gen/actions.d.ts +0 -3
  129. package/dist/src/ts-morph-utils/templates/document-model/gen/actions.d.ts.map +0 -1
  130. package/dist/src/ts-morph-utils/templates/document-model/gen/actions.js +0 -40
  131. package/dist/src/ts-morph-utils/templates/document-model/gen/actions.js.map +0 -1
  132. package/dist/src/ts-morph-utils/templates/document-model/gen/creators.d.ts +0 -3
  133. package/dist/src/ts-morph-utils/templates/document-model/gen/creators.d.ts.map +0 -1
  134. package/dist/src/ts-morph-utils/templates/document-model/gen/creators.js +0 -16
  135. package/dist/src/ts-morph-utils/templates/document-model/gen/creators.js.map +0 -1
  136. package/dist/src/ts-morph-utils/templates/document-model/gen/document-schema.d.ts +0 -3
  137. package/dist/src/ts-morph-utils/templates/document-model/gen/document-schema.d.ts.map +0 -1
  138. package/dist/src/ts-morph-utils/templates/document-model/gen/document-schema.js +0 -56
  139. package/dist/src/ts-morph-utils/templates/document-model/gen/document-schema.js.map +0 -1
  140. package/dist/src/ts-morph-utils/templates/document-model/gen/document-type.d.ts +0 -3
  141. package/dist/src/ts-morph-utils/templates/document-model/gen/document-type.d.ts.map +0 -1
  142. package/dist/src/ts-morph-utils/templates/document-model/gen/document-type.js +0 -5
  143. package/dist/src/ts-morph-utils/templates/document-model/gen/document-type.js.map +0 -1
  144. package/dist/src/ts-morph-utils/templates/document-model/gen/index.d.ts +0 -3
  145. package/dist/src/ts-morph-utils/templates/document-model/gen/index.d.ts.map +0 -1
  146. package/dist/src/ts-morph-utils/templates/document-model/gen/index.js +0 -29
  147. package/dist/src/ts-morph-utils/templates/document-model/gen/index.js.map +0 -1
  148. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/actions.d.ts +0 -8
  149. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/actions.d.ts.map +0 -1
  150. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/actions.js +0 -39
  151. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/actions.js.map +0 -1
  152. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/creators.d.ts +0 -3
  153. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/creators.d.ts.map +0 -1
  154. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/creators.js +0 -94
  155. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/creators.js.map +0 -1
  156. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/error.d.ts +0 -3
  157. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/error.d.ts.map +0 -1
  158. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/error.js +0 -73
  159. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/error.js.map +0 -1
  160. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/operations.d.ts +0 -3
  161. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/operations.d.ts.map +0 -1
  162. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/operations.js +0 -61
  163. package/dist/src/ts-morph-utils/templates/document-model/gen/modules/operations.js.map +0 -1
  164. package/dist/src/ts-morph-utils/templates/document-model/gen/ph-factories.d.ts +0 -3
  165. package/dist/src/ts-morph-utils/templates/document-model/gen/ph-factories.d.ts.map +0 -1
  166. package/dist/src/ts-morph-utils/templates/document-model/gen/ph-factories.js +0 -93
  167. package/dist/src/ts-morph-utils/templates/document-model/gen/ph-factories.js.map +0 -1
  168. package/dist/src/ts-morph-utils/templates/document-model/gen/reducer.d.ts +0 -3
  169. package/dist/src/ts-morph-utils/templates/document-model/gen/reducer.d.ts.map +0 -1
  170. package/dist/src/ts-morph-utils/templates/document-model/gen/reducer.js +0 -106
  171. package/dist/src/ts-morph-utils/templates/document-model/gen/reducer.js.map +0 -1
  172. package/dist/src/ts-morph-utils/templates/document-model/gen/schema/index.d.ts +0 -2
  173. package/dist/src/ts-morph-utils/templates/document-model/gen/schema/index.d.ts.map +0 -1
  174. package/dist/src/ts-morph-utils/templates/document-model/gen/schema/index.js +0 -6
  175. package/dist/src/ts-morph-utils/templates/document-model/gen/schema/index.js.map +0 -1
  176. package/dist/src/ts-morph-utils/templates/document-model/gen/types.d.ts +0 -3
  177. package/dist/src/ts-morph-utils/templates/document-model/gen/types.d.ts.map +0 -1
  178. package/dist/src/ts-morph-utils/templates/document-model/gen/types.js +0 -38
  179. package/dist/src/ts-morph-utils/templates/document-model/gen/types.js.map +0 -1
  180. package/dist/src/ts-morph-utils/templates/document-model/gen/utils.d.ts +0 -3
  181. package/dist/src/ts-morph-utils/templates/document-model/gen/utils.d.ts.map +0 -1
  182. package/dist/src/ts-morph-utils/templates/document-model/gen/utils.js +0 -77
  183. package/dist/src/ts-morph-utils/templates/document-model/gen/utils.js.map +0 -1
  184. package/dist/src/ts-morph-utils/templates/document-model/hooks.d.ts +0 -3
  185. package/dist/src/ts-morph-utils/templates/document-model/hooks.d.ts.map +0 -1
  186. package/dist/src/ts-morph-utils/templates/document-model/hooks.js +0 -49
  187. package/dist/src/ts-morph-utils/templates/document-model/hooks.js.map +0 -1
  188. package/dist/src/ts-morph-utils/templates/document-model/index.d.ts +0 -2
  189. package/dist/src/ts-morph-utils/templates/document-model/index.d.ts.map +0 -1
  190. package/dist/src/ts-morph-utils/templates/document-model/index.js +0 -9
  191. package/dist/src/ts-morph-utils/templates/document-model/index.js.map +0 -1
  192. package/dist/src/ts-morph-utils/templates/document-model/module.d.ts +0 -8
  193. package/dist/src/ts-morph-utils/templates/document-model/module.d.ts.map +0 -1
  194. package/dist/src/ts-morph-utils/templates/document-model/module.js +0 -25
  195. package/dist/src/ts-morph-utils/templates/document-model/module.js.map +0 -1
  196. package/dist/src/ts-morph-utils/templates/document-model/src/index.d.ts +0 -2
  197. package/dist/src/ts-morph-utils/templates/document-model/src/index.d.ts.map +0 -1
  198. package/dist/src/ts-morph-utils/templates/document-model/src/index.js +0 -5
  199. package/dist/src/ts-morph-utils/templates/document-model/src/index.js.map +0 -1
  200. package/dist/src/ts-morph-utils/templates/document-model/src/tests/document-model.test.d.ts +0 -3
  201. package/dist/src/ts-morph-utils/templates/document-model/src/tests/document-model.test.d.ts.map +0 -1
  202. package/dist/src/ts-morph-utils/templates/document-model/src/tests/document-model.test.js +0 -121
  203. package/dist/src/ts-morph-utils/templates/document-model/src/tests/document-model.test.js.map +0 -1
  204. package/dist/src/ts-morph-utils/templates/document-model/src/tests/module.test.d.ts +0 -3
  205. package/dist/src/ts-morph-utils/templates/document-model/src/tests/module.test.d.ts.map +0 -1
  206. package/dist/src/ts-morph-utils/templates/document-model/src/tests/module.test.js +0 -67
  207. package/dist/src/ts-morph-utils/templates/document-model/src/tests/module.test.js.map +0 -1
  208. package/dist/src/ts-morph-utils/templates/document-model/src/utils.d.ts +0 -2
  209. package/dist/src/ts-morph-utils/templates/document-model/src/utils.d.ts.map +0 -1
  210. package/dist/src/ts-morph-utils/templates/document-model/src/utils.js +0 -5
  211. package/dist/src/ts-morph-utils/templates/document-model/src/utils.js.map +0 -1
  212. package/dist/src/ts-morph-utils/templates/document-model/utils.d.ts +0 -3
  213. package/dist/src/ts-morph-utils/templates/document-model/utils.d.ts.map +0 -1
  214. package/dist/src/ts-morph-utils/templates/document-model/utils.js +0 -11
  215. package/dist/src/ts-morph-utils/templates/document-model/utils.js.map +0 -1
  216. package/dist/src/ts-morph-utils/templates/drive-editor.d.ts +0 -5
  217. package/dist/src/ts-morph-utils/templates/drive-editor.d.ts.map +0 -1
  218. package/dist/src/ts-morph-utils/templates/drive-editor.js +0 -211
  219. package/dist/src/ts-morph-utils/templates/drive-editor.js.map +0 -1
  220. package/dist/src/ts-morph-utils/templates/unsafe-utils.d.ts +0 -8
  221. package/dist/src/ts-morph-utils/templates/unsafe-utils.d.ts.map +0 -1
  222. package/dist/src/ts-morph-utils/templates/unsafe-utils.js +0 -23
  223. package/dist/src/ts-morph-utils/templates/unsafe-utils.js.map +0 -1
  224. package/dist/src/ts-morph-utils/templates/utils.d.ts +0 -6
  225. package/dist/src/ts-morph-utils/templates/utils.d.ts.map +0 -1
  226. package/dist/src/ts-morph-utils/templates/utils.js +0 -16
  227. package/dist/src/ts-morph-utils/templates/utils.js.map +0 -1
  228. package/dist/src/ts-morph-utils/ts-morph-project.d.ts +0 -3
  229. package/dist/src/ts-morph-utils/ts-morph-project.d.ts.map +0 -1
  230. package/dist/src/ts-morph-utils/ts-morph-project.js +0 -9
  231. package/dist/src/ts-morph-utils/ts-morph-project.js.map +0 -1
  232. package/dist/src/ts-morph-utils/types.d.ts +0 -34
  233. package/dist/src/ts-morph-utils/types.d.ts.map +0 -1
  234. package/dist/src/ts-morph-utils/types.js +0 -2
  235. package/dist/src/ts-morph-utils/types.js.map +0 -1
@@ -1,341 +0,0 @@
1
- import { tsx } from "@tmpl/core";
2
- import path from "path";
3
- import { VariableDeclarationKind } from "ts-morph";
4
- import { buildNodePrinter, formatSourceFileWithPrettier, getOrCreateSourceFile, } from "../file-utils.js";
5
- import { getDocumentModelFilePaths, getEditorFilePaths, } from "../name-builders/get-file-paths.js";
6
- import { buildArrayLiteralWithStringElements, buildClassNameAttribute, buildFunctionCall, buildJsxElement, buildJsxSpreadAttribute, buildReturn, buildSelfClosingJsxElement, } from "../syntax-builders.js";
7
- import { getObjectLiteral } from "../syntax-getters.js";
8
- import { createDocumentFileTemplate, driveExplorerFileTemplate, emptyStateFileTemplate, folderTreeFileTemplate, } from "../templates/drive-editor.js";
9
- import { buildTsMorphProject } from "../ts-morph-project.js";
10
- import { makeEditorModuleFile } from "./document-editor.js";
11
- import { makeEditorsModulesFile } from "./editor-common.js";
12
- export function tsMorphGenerateDriveEditor({ projectDir, editorDir, editorName, editorId, allowedDocumentModelIds, isDragAndDropEnabled, }) {
13
- const { documentModelsSourceFilesPath } = getDocumentModelFilePaths(projectDir);
14
- const { editorSourceFilesPath, ...editorFilePaths } = getEditorFilePaths(projectDir, editorDir);
15
- const project = buildTsMorphProject(projectDir);
16
- project.addSourceFilesAtPaths(documentModelsSourceFilesPath);
17
- project.addSourceFilesAtPaths(editorSourceFilesPath);
18
- makeNavigationBreadcrumbsFile({
19
- project,
20
- ...editorFilePaths,
21
- });
22
- makeCreateDocumentFile({
23
- project,
24
- ...editorFilePaths,
25
- });
26
- makeEmptyStateFile({
27
- project,
28
- ...editorFilePaths,
29
- });
30
- makeFoldersFile({
31
- project,
32
- ...editorFilePaths,
33
- });
34
- makeFolderTreeFile({
35
- project,
36
- ...editorFilePaths,
37
- });
38
- makeFilesFile({
39
- project,
40
- ...editorFilePaths,
41
- });
42
- makeDriveExplorerFile({
43
- project,
44
- ...editorFilePaths,
45
- });
46
- makeDriveContentsFile({
47
- project,
48
- ...editorFilePaths,
49
- });
50
- makeDriveEditorComponent({
51
- project,
52
- ...editorFilePaths,
53
- });
54
- makeDriveEditorConfigFile({
55
- project,
56
- allowedDocumentModelIds,
57
- isDragAndDropEnabled,
58
- ...editorFilePaths,
59
- });
60
- makeEditorModuleFile({
61
- project,
62
- editorName,
63
- editorId,
64
- documentModelId: "powerhouse/document-drive",
65
- ...editorFilePaths,
66
- });
67
- makeEditorsModulesFile(project, projectDir);
68
- project.saveSync();
69
- }
70
- export function makeDriveEditorComponent({ project, editorFilePath, }) {
71
- const { alreadyExists, sourceFile: driveEditorComponentSourceFile } = getOrCreateSourceFile(project, editorFilePath);
72
- if (alreadyExists) {
73
- const editorFunction = driveEditorComponentSourceFile.getFunction("Editor");
74
- if (editorFunction) {
75
- if (!editorFunction.isDefaultExport()) {
76
- editorFunction.setIsDefaultExport(true);
77
- }
78
- return;
79
- }
80
- }
81
- driveEditorComponentSourceFile.replaceWithText("");
82
- const printNode = buildNodePrinter(driveEditorComponentSourceFile);
83
- const importDeclarations = [
84
- {
85
- namedImports: ["useSetPHDriveEditorConfig"],
86
- moduleSpecifier: "@powerhousedao/reactor-browser",
87
- },
88
- {
89
- namedImports: ["EditorProps"],
90
- moduleSpecifier: "document-model",
91
- isTypeOnly: true,
92
- },
93
- {
94
- namedImports: ["DriveExplorer"],
95
- moduleSpecifier: "./components/DriveExplorer.js",
96
- },
97
- {
98
- namedImports: ["editorConfig"],
99
- moduleSpecifier: "./config.js",
100
- },
101
- ];
102
- driveEditorComponentSourceFile.addImportDeclarations(importDeclarations);
103
- const useSetPHDriveEditorConfigHookCall = buildFunctionCall({
104
- functionName: "useSetPHDriveEditorConfig",
105
- argumentsArray: ["editorConfig"],
106
- });
107
- const driveExplorerComponent = buildSelfClosingJsxElement("DriveExplorer", [
108
- buildJsxSpreadAttribute("props"),
109
- ]);
110
- const returnStatement = buildReturn(driveExplorerComponent);
111
- const statements = [useSetPHDriveEditorConfigHookCall, returnStatement].map(printNode);
112
- driveEditorComponentSourceFile.addFunction({
113
- name: "Editor",
114
- isDefaultExport: true,
115
- parameters: [{ name: "props", type: "EditorProps" }],
116
- statements,
117
- docs: ["Implement your drive explorer behavior here"],
118
- });
119
- formatSourceFileWithPrettier(driveEditorComponentSourceFile);
120
- }
121
- export function makeDriveEditorConfigFile({ project, editorConfigFilePath, allowedDocumentModelIds, isDragAndDropEnabled, }) {
122
- const { sourceFile: driveEditorConfigSourceFile } = getOrCreateSourceFile(project, editorConfigFilePath);
123
- driveEditorConfigSourceFile.replaceWithText("");
124
- driveEditorConfigSourceFile.addImportDeclaration({
125
- moduleSpecifier: "@powerhousedao/reactor-browser",
126
- namedImports: ["PHDriveEditorConfig"],
127
- isTypeOnly: true,
128
- });
129
- const printNode = buildNodePrinter(driveEditorConfigSourceFile);
130
- const configObjectVariableStatement = driveEditorConfigSourceFile.addVariableStatement({
131
- docs: ["Editor config for the AtlasDriveExplorer"],
132
- declarationKind: VariableDeclarationKind.Const,
133
- isExported: true,
134
- declarations: [
135
- {
136
- name: "editorConfig",
137
- type: "PHDriveEditorConfig",
138
- initializer: "{}",
139
- },
140
- ],
141
- });
142
- const objectLiteral = getObjectLiteral(configObjectVariableStatement);
143
- if (!objectLiteral) {
144
- throw new Error("Object literal not found");
145
- }
146
- objectLiteral.addPropertyAssignment({
147
- name: "isDragAndDropEnabled",
148
- initializer: isDragAndDropEnabled ? "true" : "false",
149
- });
150
- objectLiteral.addPropertyAssignment({
151
- name: "allowedDocumentTypes",
152
- initializer: printNode(buildArrayLiteralWithStringElements(allowedDocumentModelIds)),
153
- });
154
- }
155
- export function makeDriveContentsFile({ project, driveContentsFilePath, }) {
156
- const { alreadyExists, sourceFile: driveContentsSourceFile } = getOrCreateSourceFile(project, driveContentsFilePath);
157
- if (alreadyExists)
158
- return;
159
- const printNode = buildNodePrinter(driveContentsSourceFile);
160
- const importDeclarations = [
161
- {
162
- namedImports: ["CreateDocument"],
163
- moduleSpecifier: "./CreateDocument.js",
164
- },
165
- {
166
- namedImports: ["EmptyState"],
167
- moduleSpecifier: "./EmptyState.js",
168
- },
169
- {
170
- namedImports: ["Files"],
171
- moduleSpecifier: "./Files.js",
172
- },
173
- {
174
- namedImports: ["Folders"],
175
- moduleSpecifier: "./Folders.js",
176
- },
177
- {
178
- namedImports: ["NavigationBreadcrumbs"],
179
- moduleSpecifier: "./NavigationBreadcrumbs.js",
180
- },
181
- ];
182
- driveContentsSourceFile.addImportDeclarations(importDeclarations);
183
- const navigationBreadcrumbs = buildSelfClosingJsxElement("NavigationBreadcrumbs");
184
- const folders = buildSelfClosingJsxElement("Folders");
185
- const files = buildSelfClosingJsxElement("Files");
186
- const emptyState = buildSelfClosingJsxElement("EmptyState");
187
- const createDocument = buildSelfClosingJsxElement("CreateDocument");
188
- const wrapperDiv = buildJsxElement("div", [navigationBreadcrumbs, folders, files, emptyState, createDocument], [buildClassNameAttribute("space-y-6 px-6")]);
189
- const returnStatement = buildReturn(wrapperDiv);
190
- const statements = [returnStatement].map(printNode);
191
- driveContentsSourceFile.addFunction({
192
- name: "DriveContents",
193
- isExported: true,
194
- docs: ["Shows the documents and folders in the selected drive"],
195
- parameters: [],
196
- statements,
197
- });
198
- formatSourceFileWithPrettier(driveContentsSourceFile);
199
- }
200
- export function makeNavigationBreadcrumbsFile({ project, editorComponentsDirPath, }) {
201
- const navigationBreadcrumbsFilePath = path.join(editorComponentsDirPath, "NavigationBreadcrumbs.tsx");
202
- const { alreadyExists, sourceFile: navigationBreadcrumbsSourceFile } = getOrCreateSourceFile(project, navigationBreadcrumbsFilePath);
203
- if (alreadyExists)
204
- return;
205
- const printNode = buildNodePrinter(navigationBreadcrumbsSourceFile);
206
- const importDeclarations = [
207
- {
208
- namedImports: ["Breadcrumbs"],
209
- moduleSpecifier: "@powerhousedao/design-system/connect",
210
- },
211
- ];
212
- navigationBreadcrumbsSourceFile.addImportDeclarations(importDeclarations);
213
- const breadcrumbs = buildSelfClosingJsxElement("Breadcrumbs");
214
- const wrapperDiv = buildJsxElement("div", [breadcrumbs], [buildClassNameAttribute("border-b border-gray-200 pb-3 space-y-3")]);
215
- const returnStatement = buildReturn(wrapperDiv);
216
- const statements = [returnStatement].map(printNode);
217
- navigationBreadcrumbsSourceFile.addFunction({
218
- name: "NavigationBreadcrumbs",
219
- isExported: true,
220
- docs: ["Shows the navigation breadcrumbs for the selected drive or folder"],
221
- parameters: [],
222
- statements,
223
- });
224
- formatSourceFileWithPrettier(navigationBreadcrumbsSourceFile);
225
- }
226
- export function makeFoldersFile({ project, editorComponentsDirPath, }) {
227
- const foldersFilePath = path.join(editorComponentsDirPath, "Folders.tsx");
228
- const { alreadyExists, sourceFile: foldersSourceFile } = getOrCreateSourceFile(project, foldersFilePath);
229
- if (alreadyExists)
230
- return;
231
- const importDeclarations = [
232
- {
233
- namedImports: ["FolderItem"],
234
- moduleSpecifier: "@powerhousedao/design-system/connect",
235
- },
236
- {
237
- namedImports: ["useNodesInSelectedDriveOrFolder", "isFolderNodeKind"],
238
- moduleSpecifier: "@powerhousedao/reactor-browser",
239
- },
240
- ];
241
- foldersSourceFile.addImportDeclarations(importDeclarations);
242
- foldersSourceFile.addFunction({
243
- name: "Folders",
244
- isExported: true,
245
- docs: ["Shows the folders in the selected drive or folder"],
246
- parameters: [],
247
- statements: [
248
- tsx `
249
- const nodes = useNodesInSelectedDriveOrFolder();
250
- const folderNodes = nodes.filter((n) => isFolderNodeKind(n));
251
- const hasFolders = folderNodes.length > 0;
252
- if (!hasFolders) return null;
253
-
254
- return (
255
- <div>
256
- <h3 className="mb-2 text-sm font-bold text-gray-600">Folders</h3>
257
- <div className="flex flex-wrap gap-4">
258
- {folderNodes.map((folderNode) => (
259
- <FolderItem key={folderNode.id} folderNode={folderNode} />
260
- ))}
261
- </div>
262
- </div>
263
- );`.raw,
264
- ],
265
- });
266
- formatSourceFileWithPrettier(foldersSourceFile);
267
- }
268
- export function makeFilesFile({ project, editorComponentsDirPath, }) {
269
- const filesFilePath = path.join(editorComponentsDirPath, "Files.tsx");
270
- const { alreadyExists, sourceFile: filesSourceFile } = getOrCreateSourceFile(project, filesFilePath);
271
- if (alreadyExists)
272
- return;
273
- const importDeclarations = [
274
- {
275
- namedImports: ["FileItem"],
276
- moduleSpecifier: "@powerhousedao/design-system/connect",
277
- },
278
- {
279
- namedImports: ["useNodesInSelectedDriveOrFolder", "isFileNodeKind"],
280
- moduleSpecifier: "@powerhousedao/reactor-browser",
281
- },
282
- ];
283
- filesSourceFile.addImportDeclarations(importDeclarations);
284
- const statements = [
285
- tsx `const nodes = useNodesInSelectedDriveOrFolder();`.raw,
286
- tsx `const fileNodes = nodes.filter((n) => isFileNodeKind(n));`.raw,
287
- tsx `const hasFiles = fileNodes.length > 0;`.raw,
288
- tsx `if (!hasFiles) return null;`.raw,
289
- tsx `return (
290
- <div>
291
- <h3 className="mb-2 text-sm font-semibold text-gray-600">Documents</h3>
292
- <div className="flex flex-wrap gap-4">
293
- {fileNodes.map((fileNode) => (
294
- <FileItem key={fileNode.id} fileNode={fileNode} />
295
- ))}
296
- </div>
297
- </div>
298
- );`.raw,
299
- ];
300
- filesSourceFile.addFunction({
301
- name: "Files",
302
- isExported: true,
303
- docs: ["Shows the files in the selected drive or folder"],
304
- parameters: [],
305
- statements,
306
- });
307
- formatSourceFileWithPrettier(filesSourceFile);
308
- }
309
- function makeDriveExplorerFile({ project, editorComponentsDirPath, }) {
310
- const driveExplorerFilePath = path.join(editorComponentsDirPath, "DriveExplorer.tsx");
311
- const { alreadyExists, sourceFile: driveExplorerSourceFile } = getOrCreateSourceFile(project, driveExplorerFilePath);
312
- if (alreadyExists)
313
- return;
314
- driveExplorerSourceFile.replaceWithText(driveExplorerFileTemplate);
315
- formatSourceFileWithPrettier(driveExplorerSourceFile);
316
- }
317
- export function makeFolderTreeFile({ project, editorComponentsDirPath, }) {
318
- const folderTreeFilePath = path.join(editorComponentsDirPath, "FolderTree.tsx");
319
- const { alreadyExists, sourceFile: folderTreeSourceFile } = getOrCreateSourceFile(project, folderTreeFilePath);
320
- if (alreadyExists)
321
- return;
322
- folderTreeSourceFile.replaceWithText(folderTreeFileTemplate);
323
- formatSourceFileWithPrettier(folderTreeSourceFile);
324
- }
325
- export function makeEmptyStateFile({ project, editorComponentsDirPath, }) {
326
- const emptyStateFilePath = path.join(editorComponentsDirPath, "EmptyState.tsx");
327
- const { alreadyExists, sourceFile: emptyStateSourceFile } = getOrCreateSourceFile(project, emptyStateFilePath);
328
- if (alreadyExists)
329
- return;
330
- emptyStateSourceFile.replaceWithText(emptyStateFileTemplate);
331
- formatSourceFileWithPrettier(emptyStateSourceFile);
332
- }
333
- export function makeCreateDocumentFile({ project, editorComponentsDirPath, }) {
334
- const createDocumentFilePath = path.join(editorComponentsDirPath, "CreateDocument.tsx");
335
- const { alreadyExists, sourceFile: createDocumentSourceFile } = getOrCreateSourceFile(project, createDocumentFilePath);
336
- if (alreadyExists)
337
- return;
338
- createDocumentSourceFile.replaceWithText(createDocumentFileTemplate);
339
- formatSourceFileWithPrettier(createDocumentSourceFile);
340
- }
341
- //# sourceMappingURL=drive-editor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"drive-editor.js","sourceRoot":"","sources":["../../../../src/ts-morph-utils/file-builders/drive-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAgB,MAAM,UAAU,CAAC;AACjE,OAAO,EACL,gBAAgB,EAChB,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,mCAAmC,EACnC,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,uBAAuB,EACvB,WAAW,EACX,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,C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E7D,4BAA4B,CAAC,oBAAoB,CAAC,CAAC;AACrD,CAAC;AAMD,MAAM,UAAU,sBAAsB,CAAC,EACrC,OAAO,EACP,uBAAuB,GACI;IAC3B,MAAM,sBAAsB,GAAG,IAAI,CAAC,IAAI,CACtC,uBAAuB,EACvB,oBAAoB,CACrB,CAAC;IACF,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,wBAAwB,EAAE,GAC3D,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;IAEzD,IAAI,aAAa;QAAE,OAAO;IAE1B,wBAAwB,CAAC,eAAe,CAAC,0BAA0B,CAAC,CAAC;IAErE,4BAA4B,CAAC,wBAAwB,CAAC,CAAC;AACzD,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { Project } from "ts-morph";
2
- export declare function makeEditorsModulesFile(project: Project, projectDir: string): void;
3
- //# sourceMappingURL=editor-common.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"editor-common.d.ts","sourceRoot":"","sources":["../../../../src/ts-morph-utils/file-builders/editor-common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAaxC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,QAU1E"}
@@ -1,15 +0,0 @@
1
- import { editorModuleOutputFileName, editorModuleTypeName, editorModuleVariableName, editorModuleVariableType, } from "../constants.js";
2
- import { buildEditorsDirPath, buildEditorSourceFilesPath, } from "../name-builders/editor-files.js";
3
- import { makeModulesFile } from "./module-files.js";
4
- export function makeEditorsModulesFile(project, projectDir) {
5
- makeModulesFile({
6
- project,
7
- modulesDirPath: buildEditorsDirPath(projectDir),
8
- modulesSourceFilesPath: buildEditorSourceFilesPath(projectDir),
9
- outputFileName: editorModuleOutputFileName,
10
- typeName: editorModuleTypeName,
11
- variableName: editorModuleVariableName,
12
- variableType: editorModuleVariableType,
13
- });
14
- }
15
- //# sourceMappingURL=editor-common.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"editor-common.js","sourceRoot":"","sources":["../../../../src/ts-morph-utils/file-builders/editor-common.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,UAAU,sBAAsB,CAAC,OAAgB,EAAE,UAAkB;IACzE,eAAe,CAAC;QACd,OAAO;QACP,cAAc,EAAE,mBAAmB,CAAC,UAAU,CAAC;QAC/C,sBAAsB,EAAE,0BAA0B,CAAC,UAAU,CAAC;QAC9D,cAAc,EAAE,0BAA0B;QAC1C,QAAQ,EAAE,oBAAoB;QAC9B,YAAY,EAAE,wBAAwB;QACtC,YAAY,EAAE,wBAAwB;KACvC,CAAC,CAAC;AACL,CAAC"}
@@ -1,17 +0,0 @@
1
- import type { Project } from "ts-morph";
2
- type MakeLegacyIndexFileArgs = {
3
- /** The project to make the legacy index file for */
4
- project: Project;
5
- /** The directory containing the module.ts files to generate from */
6
- modulesDirPath: string;
7
- modules: {
8
- name: string;
9
- moduleSpecifier: string;
10
- }[];
11
- };
12
- /**
13
- * Makes a legacy index.ts file for the modules file which exports the modules as individual exports instead of an array of named exports.
14
- */
15
- export declare function makeLegacyIndexFile({ project, modulesDirPath, modules, }: MakeLegacyIndexFileArgs): void;
16
- export {};
17
- //# sourceMappingURL=index-files.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-files.d.ts","sourceRoot":"","sources":["../../../../src/ts-morph-utils/file-builders/index-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC,KAAK,uBAAuB,GAAG;IAC7B,oDAAoD;IACpD,OAAO,EAAE,OAAO,CAAC;IACjB,oEAAoE;IACpE,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,MAAM,CAAC;KACzB,EAAE,CAAC;CACL,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,cAAc,EACd,OAAO,GACR,EAAE,uBAAuB,QAqBzB"}
@@ -1,21 +0,0 @@
1
- import { buildModulesOutputFilePath } from "../name-builders/common-files.js";
2
- /**
3
- * Makes a legacy index.ts file for the modules file which exports the modules as individual exports instead of an array of named exports.
4
- */
5
- export function makeLegacyIndexFile({ project, modulesDirPath, modules, }) {
6
- const indexSourceFilePath = buildModulesOutputFilePath(modulesDirPath, "index.ts");
7
- // get the source file for the index.ts file if it exists
8
- let indexSourceFile = project.getSourceFile(indexSourceFilePath);
9
- // if the index.ts file doesn't exist, create it
10
- if (!indexSourceFile) {
11
- indexSourceFile = project.createSourceFile(indexSourceFilePath, "");
12
- }
13
- else {
14
- indexSourceFile.replaceWithText("");
15
- }
16
- indexSourceFile.addExportDeclarations(modules.map(({ name, moduleSpecifier }) => ({
17
- namedExports: [name],
18
- moduleSpecifier,
19
- })));
20
- }
21
- //# sourceMappingURL=index-files.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-files.js","sourceRoot":"","sources":["../../../../src/ts-morph-utils/file-builders/index-files.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAa9E;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,OAAO,EACP,cAAc,EACd,OAAO,GACiB;IACxB,MAAM,mBAAmB,GAAG,0BAA0B,CACpD,cAAc,EACd,UAAU,CACX,CAAC;IAEF,yDAAyD;IACzD,IAAI,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC;IACjE,gDAAgD;IAChD,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;IACtE,CAAC;SAAM,CAAC;QACN,eAAe,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,eAAe,CAAC,qBAAqB,CACnC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1C,YAAY,EAAE,CAAC,IAAI,CAAC;QACpB,eAAe;KAChB,CAAC,CAAC,CACJ,CAAC;AACJ,CAAC"}
@@ -1,25 +0,0 @@
1
- import type { Project } from "ts-morph";
2
- type MakeModuleFileArgs = {
3
- /** The project to make the modules file for */
4
- project: Project;
5
- /** The directory containing the module.ts files to generate from */
6
- modulesDirPath: string;
7
- /** The path to the module.ts files to generate from */
8
- modulesSourceFilesPath: string;
9
- /** The name of the output file which exports the modules, e.g. 'document-models.ts' or 'editors.ts' */
10
- outputFileName: string;
11
- /** The type name of the modules exported by the module.ts files, e.g. 'DocumentModelModule' or 'EditorModule' */
12
- typeName: string;
13
- /** The name of the variable that exports the modules, e.g. 'documentModels' or 'editors' */
14
- variableName: string;
15
- /** The type of the variable that exports the modules, e.g. 'DocumentModelModule<any>[]' or 'EditorModule[]' */
16
- variableType: string;
17
- /** Whether to make a legacy index.ts file for the modules, to be removed in the future */
18
- shouldMakeLegacyIndexFile?: boolean;
19
- };
20
- /**
21
- * Makes a file which exports the modules from the module.ts files in the given directory as a variable declaration.
22
- */
23
- export declare function makeModulesFile({ project, modulesDirPath, modulesSourceFilesPath, outputFileName, typeName, variableName, variableType, shouldMakeLegacyIndexFile, }: MakeModuleFileArgs): void;
24
- export {};
25
- //# sourceMappingURL=module-files.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"module-files.d.ts","sourceRoot":"","sources":["../../../../src/ts-morph-utils/file-builders/module-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAMxC,KAAK,kBAAkB,GAAG;IACxB,+CAA+C;IAC/C,OAAO,EAAE,OAAO,CAAC;IACjB,oEAAoE;IACpE,cAAc,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,sBAAsB,EAAE,MAAM,CAAC;IAC/B,uGAAuG;IACvG,cAAc,EAAE,MAAM,CAAC;IACvB,iHAAiH;IACjH,QAAQ,EAAE,MAAM,CAAC;IACjB,4FAA4F;IAC5F,YAAY,EAAE,MAAM,CAAC;IACrB,+GAA+G;IAC/G,YAAY,EAAE,MAAM,CAAC;IACrB,0FAA0F;IAC1F,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,yBAAgC,GACjC,EAAE,kBAAkB,QAyGpB"}
@@ -1,92 +0,0 @@
1
- import { SyntaxKind, VariableDeclarationKind } from "ts-morph";
2
- import { buildModulesOutputFilePath } from "../name-builders/common-files.js";
3
- import { getVariableDeclarationByTypeName } from "../syntax-getters.js";
4
- import { makeLegacyIndexFile } from "./index-files.js";
5
- /**
6
- * Makes a file which exports the modules from the module.ts files in the given directory as a variable declaration.
7
- */
8
- export function makeModulesFile({ project, modulesDirPath, modulesSourceFilesPath, outputFileName, typeName, variableName, variableType, shouldMakeLegacyIndexFile = true, }) {
9
- // we only need the files in the directory we're creating the modules file from
10
- project.addSourceFilesAtPaths(modulesSourceFilesPath);
11
- let modulesDir = project.getDirectory(modulesDirPath);
12
- if (!modulesDir) {
13
- modulesDir = project.addDirectoryAtPath(modulesDirPath);
14
- }
15
- const moduleFiles = modulesDir
16
- .getDescendantSourceFiles()
17
- .filter((file) => file.getFilePath().includes(`module.ts`));
18
- // get the variable declaration for the module object exported by each module.ts file by the given type name
19
- const moduleDeclarations = moduleFiles.map((file) => getVariableDeclarationByTypeName(file, typeName));
20
- const modules = moduleDeclarations
21
- .filter((module) => module !== undefined)
22
- .map((module) => {
23
- const name = module.getName();
24
- const sourceFile = module.getSourceFile();
25
- const parentDir = sourceFile.getDirectory();
26
- const parentDirName = parentDir.getBaseName();
27
- const moduleSpecifier = `./${parentDirName}/module.js`;
28
- return { name, moduleSpecifier };
29
- });
30
- const moduleExportsFilePath = buildModulesOutputFilePath(modulesDirPath, outputFileName);
31
- // get the source file for the modules file if it exists
32
- let moduleExportsSourceFile = project.getSourceFile(moduleExportsFilePath);
33
- // if the modules file doesn't exist, create it
34
- if (!moduleExportsSourceFile) {
35
- moduleExportsSourceFile = project.createSourceFile(moduleExportsFilePath, "");
36
- }
37
- else {
38
- moduleExportsSourceFile.replaceWithText("");
39
- }
40
- const typeImport = {
41
- namedImports: [typeName],
42
- moduleSpecifier: "document-model",
43
- isTypeOnly: true,
44
- };
45
- const moduleImports = modules.map(({ name, moduleSpecifier }) => ({
46
- namedImports: [name],
47
- moduleSpecifier,
48
- }));
49
- const imports = [typeImport, ...moduleImports];
50
- moduleExportsSourceFile.addImportDeclarations(imports);
51
- // create the variable statement for the modules file
52
- // start as an empty array
53
- const moduleExportsVariableStatementInput = {
54
- isExported: true,
55
- declarationKind: VariableDeclarationKind.Const,
56
- declarations: [
57
- {
58
- name: variableName,
59
- type: variableType,
60
- initializer: `[]`,
61
- },
62
- ],
63
- };
64
- // get the variable statement for the modules file if it exists
65
- let moduleExportsVariableStatement = moduleExportsSourceFile.getVariableStatement(variableName);
66
- // if the variable statement doesn't exist, create it
67
- if (!moduleExportsVariableStatement) {
68
- moduleExportsVariableStatement =
69
- moduleExportsSourceFile.addVariableStatement(moduleExportsVariableStatementInput);
70
- }
71
- else {
72
- // if the variable statement exists, set it to the new variable statement
73
- moduleExportsVariableStatement.set(moduleExportsVariableStatementInput);
74
- }
75
- // get the array literal expression for the variable statement
76
- const arrayLiteral = moduleExportsVariableStatement
77
- .getDeclarations()
78
- .at(0)
79
- ?.getInitializerIfKind(SyntaxKind.ArrayLiteralExpression);
80
- // add the module declaration names to the array literal expression
81
- arrayLiteral?.addElements(modules.map((module) => module.name), { useNewLines: true });
82
- // we also need to export each module from the index.ts file for backwards compatibility
83
- if (shouldMakeLegacyIndexFile) {
84
- makeLegacyIndexFile({
85
- project,
86
- modulesDirPath,
87
- modules,
88
- });
89
- }
90
- project.saveSync();
91
- }
92
- //# sourceMappingURL=module-files.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"module-files.js","sourceRoot":"","sources":["../../../../src/ts-morph-utils/file-builders/module-files.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAqBvD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,OAAO,EACP,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,yBAAyB,GAAG,IAAI,GACb;IACnB,+EAA+E;IAC/E,OAAO,CAAC,qBAAqB,CAAC,sBAAsB,CAAC,CAAC;IAEtD,IAAI,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IACtD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,UAAU,GAAG,OAAO,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,WAAW,GAAG,UAAU;SAC3B,wBAAwB,EAAE;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;IAE9D,4GAA4G;IAC5G,MAAM,kBAAkB,GAAG,WAAW,CAAC,GAA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type MakeSubgraphsIndexFileArgs = {
2
- projectDir: string;
3
- };
4
- export declare function makeSubgraphsIndexFile({ projectDir, }: MakeSubgraphsIndexFileArgs): void;
5
- export {};
6
- //# sourceMappingURL=subgraphs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"subgraphs.d.ts","sourceRoot":"","sources":["../../../../src/ts-morph-utils/file-builders/subgraphs.ts"],"names":[],"mappings":"AAGA,KAAK,0BAA0B,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AACzD,wBAAgB,sBAAsB,CAAC,EACrC,UAAU,GACX,EAAE,0BAA0B,QA8D5B"}
@@ -1,53 +0,0 @@
1
- import path from "path";
2
- import { IndentationText, Project } from "ts-morph";
3
- export function makeSubgraphsIndexFile({ projectDir, }) {
4
- // use the local tsconfig.json file for a given project
5
- const tsConfigFilePath = path.join(projectDir, "tsconfig.json");
6
- const project = new Project({
7
- tsConfigFilePath,
8
- // don't add files from the tsconfig.json file, only use the ones we need
9
- skipAddingFilesFromTsConfig: true,
10
- // don't load library files, we only need the files we're adding
11
- skipLoadingLibFiles: true,
12
- // use formatting rules which match prettier
13
- manipulationSettings: {
14
- useTrailingCommas: true,
15
- indentationText: IndentationText.TwoSpaces,
16
- },
17
- });
18
- project.addSourceFilesAtPaths(`${projectDir}/subgraphs/**/*`);
19
- const subgraphsDir = project.getDirectory(path.join(projectDir, "subgraphs"));
20
- const subgraphsSubdirs = subgraphsDir?.getDirectories() ?? [];
21
- let subgraphsIndexSourceFile = project.getSourceFile(path.join(projectDir, "subgraphs/index.ts"));
22
- if (!subgraphsIndexSourceFile) {
23
- subgraphsIndexSourceFile = project.createSourceFile(path.join(projectDir, "subgraphs/index.js"), "");
24
- }
25
- for (const subgraphSubdir of subgraphsSubdirs) {
26
- const subgraphIndexSourceFilePath = `${subgraphSubdir.getPath()}/index.ts`;
27
- const subgraphIndexSourceFile = project.getSourceFile(subgraphIndexSourceFilePath);
28
- if (!subgraphIndexSourceFile) {
29
- continue;
30
- }
31
- const subgraphClassExport = subgraphIndexSourceFile
32
- .getClasses()
33
- .find((c) => c.getBaseClass()?.getText().includes("BaseSubgraph"));
34
- const subgraphClassName = subgraphClassExport?.getName();
35
- if (!subgraphClassName) {
36
- continue;
37
- }
38
- const indexFileExports = subgraphsIndexSourceFile
39
- .getExportDeclarations()
40
- .map((e) => e.getNamespaceExport()?.getText())
41
- .filter((e) => e !== undefined)
42
- .join();
43
- if (indexFileExports.includes(subgraphClassName)) {
44
- continue;
45
- }
46
- subgraphsIndexSourceFile.addExportDeclaration({
47
- namespaceExport: subgraphClassName,
48
- moduleSpecifier: `./${subgraphSubdir.getBaseName()}/index.js`,
49
- });
50
- }
51
- project.saveSync();
52
- }
53
- //# sourceMappingURL=subgraphs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"subgraphs.js","sourceRoot":"","sources":["../../../../src/ts-morph-utils/file-builders/subgraphs.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGpD,MAAM,UAAU,sBAAsB,CAAC,EACrC,UAAU,GACiB;IAC3B,uDAAuD;IACvD,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IAEhE,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;QAC1B,gBAAgB;QAChB,yEAAyE;QACzE,2BAA2B,EAAE,IAAI;QACjC,gEAAgE;QAChE,mBAAmB,EAAE,IAAI;QACzB,4CAA4C;QAC5C,oBAAoB,EAAE;YACpB,iBAAiB,EAAE,IAAI;YACvB,eAAe,EAAE,eAAe,CAAC,SAAS;SAC3C;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,qBAAqB,CAAC,GAAG,UAAU,iBAAiB,CAAC,CAAC;IAE9D,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC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