@jakubmazanec/carson 0.1.0-a500263 → 0.1.0-c2efc51

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 (318) hide show
  1. package/README.md +181 -14
  2. package/dist/commands/create-project/CreateProject.js +2 -2
  3. package/dist/commands/create-project/CreateProject.js.map +1 -1
  4. package/dist/commands/create-project/CreateProjectInput.js +1 -1
  5. package/dist/commands/create-project/CreateProjectInput.js.map +1 -1
  6. package/dist/commands/create-project/createProjectCommand.js +3 -4
  7. package/dist/commands/create-project/createProjectCommand.js.map +1 -1
  8. package/dist/commands/create-project/runCreateProject.js +4 -14
  9. package/dist/commands/create-project/runCreateProject.js.map +1 -1
  10. package/dist/commands/create-workspace/CreateWorkspace.d.ts +1 -2
  11. package/dist/commands/create-workspace/CreateWorkspace.js +7 -5
  12. package/dist/commands/create-workspace/CreateWorkspace.js.map +1 -1
  13. package/dist/commands/create-workspace/CreateWorkspaceInput.js.map +1 -1
  14. package/dist/commands/create-workspace/createWorkspaceCommand.js +1 -11
  15. package/dist/commands/create-workspace/createWorkspaceCommand.js.map +1 -1
  16. package/dist/commands/create-workspace/runCreateWorkspace.js +4 -13
  17. package/dist/commands/create-workspace/runCreateWorkspace.js.map +1 -1
  18. package/dist/commands/internals/CommandStatus.d.ts +1 -0
  19. package/dist/commands/internals/CommandStatus.js +3 -0
  20. package/dist/commands/internals/CommandStatus.js.map +1 -0
  21. package/dist/commands/internals/packageNameToDirectory.js.map +1 -1
  22. package/dist/commands/internals.d.ts +1 -0
  23. package/dist/commands/internals.js +1 -0
  24. package/dist/commands/internals.js.map +1 -1
  25. package/dist/commands/update-workspace/UpdateWorkspace.js +3 -3
  26. package/dist/commands/update-workspace/UpdateWorkspace.js.map +1 -1
  27. package/dist/commands/update-workspace/runUpdateWorkspace.js +1 -1
  28. package/dist/commands/update-workspace/runUpdateWorkspace.js.map +1 -1
  29. package/dist/commands/update-workspace/updateWorkspaceCommand.js +3 -4
  30. package/dist/commands/update-workspace/updateWorkspaceCommand.js.map +1 -1
  31. package/dist/constants.js +0 -4
  32. package/dist/constants.js.map +1 -1
  33. package/dist/run.js.map +1 -1
  34. package/dist/template/CarsonTemplate.d.ts +6 -0
  35. package/dist/template/CarsonTemplate.js.map +1 -1
  36. package/dist/template/CarsonTemplateConfig.d.ts +3 -0
  37. package/dist/template/CarsonTemplateConfig.js.map +1 -1
  38. package/dist/template/CarsonTemplateError.d.ts +8 -0
  39. package/dist/template/CarsonTemplateError.js +13 -0
  40. package/dist/template/CarsonTemplateError.js.map +1 -0
  41. package/dist/template/TemplateAttributes.d.ts +3 -3
  42. package/dist/template/TemplateAttributes.js +13 -11
  43. package/dist/template/TemplateAttributes.js.map +1 -1
  44. package/dist/template/TemplateData.d.ts +0 -18
  45. package/dist/template/TemplateData.js +1 -3
  46. package/dist/template/TemplateData.js.map +1 -1
  47. package/dist/template/TemplateRender.d.ts +8 -1
  48. package/dist/template/TemplateRender.js.map +1 -1
  49. package/dist/template/TemplateRenders.d.ts +3 -0
  50. package/dist/template/TemplateRenders.js.map +1 -1
  51. package/dist/template/applyTemplateRenders.d.ts +5 -3
  52. package/dist/template/applyTemplateRenders.js +51 -21
  53. package/dist/template/applyTemplateRenders.js.map +1 -1
  54. package/dist/template/internals/TemplateRenderSnapshot.d.ts +40 -0
  55. package/dist/template/{TemplateRenderSnapshot.js → internals/TemplateRenderSnapshot.js} +5 -2
  56. package/dist/template/internals/TemplateRenderSnapshot.js.map +1 -0
  57. package/dist/template/internals/TemplateRenderSnapshots.d.ts +40 -0
  58. package/dist/template/internals/TemplateRenderSnapshots.js.map +1 -0
  59. package/dist/template/internals/createUsingTemplateRender.d.ts +3 -0
  60. package/dist/template/internals/createUsingTemplateRender.js +12 -0
  61. package/dist/template/internals/createUsingTemplateRender.js.map +1 -0
  62. package/dist/template/internals/deleteUsingTemplateRender.d.ts +6 -0
  63. package/dist/template/internals/deleteUsingTemplateRender.js +23 -0
  64. package/dist/template/internals/deleteUsingTemplateRender.js.map +1 -0
  65. package/dist/template/internals/importCarsonTemplate.js +8 -0
  66. package/dist/template/internals/importCarsonTemplate.js.map +1 -0
  67. package/dist/template/internals/insertUsingTemplateRender.d.ts +3 -0
  68. package/dist/template/internals/insertUsingTemplateRender.js +41 -0
  69. package/dist/template/internals/insertUsingTemplateRender.js.map +1 -0
  70. package/dist/template/internals/loadTemplateRenderSnapshots.d.ts +10 -0
  71. package/dist/template/internals/loadTemplateRenderSnapshots.js.map +1 -0
  72. package/dist/template/internals/merge.js.map +1 -1
  73. package/dist/template/internals/mergeUsingTemplateRender.d.ts +3 -0
  74. package/dist/template/{mergeFileUsingTemplateRender.js → internals/mergeUsingTemplateRender.js} +18 -7
  75. package/dist/template/internals/mergeUsingTemplateRender.js.map +1 -0
  76. package/dist/template/internals/overwriteUsingTemplateRender.d.ts +3 -0
  77. package/dist/template/internals/overwriteUsingTemplateRender.js +12 -0
  78. package/dist/template/internals/overwriteUsingTemplateRender.js.map +1 -0
  79. package/dist/template/internals/parseCarsonTemplateId.d.ts +1 -0
  80. package/dist/template/internals/parseCarsonTemplateId.js +17 -0
  81. package/dist/template/internals/parseCarsonTemplateId.js.map +1 -0
  82. package/dist/template/internals/prettify.js.map +1 -1
  83. package/dist/template/{readCarsonTemplate.d.ts → internals/readCarsonTemplate.d.ts} +1 -1
  84. package/dist/template/{readCarsonTemplate.js → internals/readCarsonTemplate.js} +14 -8
  85. package/dist/template/internals/readCarsonTemplate.js.map +1 -0
  86. package/dist/template/internals/resolveModule.d.ts +1 -0
  87. package/dist/template/{resolveTemplateModule.js → internals/resolveModule.js} +2 -2
  88. package/dist/template/internals/resolveModule.js.map +1 -0
  89. package/dist/template/{saveTemplateRenderSnapshots.d.ts → internals/saveTemplateRenderSnapshots.d.ts} +1 -1
  90. package/dist/template/{saveTemplateRenderSnapshots.js → internals/saveTemplateRenderSnapshots.js} +4 -4
  91. package/dist/template/internals/saveTemplateRenderSnapshots.js.map +1 -0
  92. package/dist/template/internals/uninsertUsingTemplateRender.d.ts +3 -0
  93. package/dist/template/internals/uninsertUsingTemplateRender.js +41 -0
  94. package/dist/template/internals/uninsertUsingTemplateRender.js.map +1 -0
  95. package/dist/template/internals/unmerge.d.ts +1 -1
  96. package/dist/template/internals/unmerge.js +1 -1
  97. package/dist/template/internals/unmerge.js.map +1 -1
  98. package/dist/template/internals/unmergeUsingTemplateRender.d.ts +3 -0
  99. package/dist/template/{unmergeFileUsingTemplateRender.js → internals/unmergeUsingTemplateRender.js} +18 -7
  100. package/dist/template/internals/unmergeUsingTemplateRender.js.map +1 -0
  101. package/dist/template/internals.d.ts +16 -1
  102. package/dist/template/internals.js +16 -1
  103. package/dist/template/internals.js.map +1 -1
  104. package/dist/template/renderCarsonTemplate.d.ts +10 -0
  105. package/dist/template/renderCarsonTemplate.js +34 -0
  106. package/dist/template/renderCarsonTemplate.js.map +1 -0
  107. package/dist/template.d.ts +2 -13
  108. package/dist/template.js +2 -13
  109. package/dist/template.js.map +1 -1
  110. package/dist/workspace/Project.d.ts +2 -2
  111. package/dist/workspace/Project.js +31 -14
  112. package/dist/workspace/Project.js.map +1 -1
  113. package/dist/workspace/ProjectConfig.d.ts +3 -0
  114. package/dist/workspace/ProjectConfig.js.map +1 -1
  115. package/dist/workspace/ProjectCreateOptions.d.ts +3 -0
  116. package/dist/workspace/ProjectCreateOptions.js.map +1 -1
  117. package/dist/workspace/ProjectError.d.ts +5 -2
  118. package/dist/workspace/ProjectError.js +6 -2
  119. package/dist/workspace/ProjectError.js.map +1 -1
  120. package/dist/workspace/ProjectOptions.d.ts +1 -1
  121. package/dist/workspace/ProjectOptions.js.map +1 -1
  122. package/dist/workspace/ProjectUpdateOptions.d.ts +3 -0
  123. package/dist/workspace/ProjectUpdateOptions.js +3 -1
  124. package/dist/workspace/ProjectUpdateOptions.js.map +1 -1
  125. package/dist/workspace/Workspace.d.ts +8 -6
  126. package/dist/workspace/Workspace.js +114 -46
  127. package/dist/workspace/Workspace.js.map +1 -1
  128. package/dist/workspace/WorkspaceConfig.d.ts +3 -0
  129. package/dist/workspace/WorkspaceConfig.js.map +1 -1
  130. package/dist/workspace/WorkspaceCreateOptions.d.ts +3 -0
  131. package/dist/workspace/WorkspaceCreateOptions.js +3 -1
  132. package/dist/workspace/WorkspaceCreateOptions.js.map +1 -1
  133. package/dist/workspace/WorkspaceCreateProjectOptions.d.ts +3 -0
  134. package/dist/workspace/WorkspaceCreateProjectOptions.js +3 -1
  135. package/dist/workspace/WorkspaceCreateProjectOptions.js.map +1 -1
  136. package/dist/workspace/WorkspaceDependencies.d.ts +26 -22
  137. package/dist/workspace/WorkspaceDependencies.js +34 -13
  138. package/dist/workspace/WorkspaceDependencies.js.map +1 -1
  139. package/dist/workspace/WorkspaceDependenciesFromWorkspaceOptions.d.ts +8 -0
  140. package/dist/workspace/WorkspaceDependenciesFromWorkspaceOptions.js +5 -0
  141. package/dist/workspace/WorkspaceDependenciesFromWorkspaceOptions.js.map +1 -0
  142. package/dist/workspace/WorkspaceDependenciesGetVersionsOptions.d.ts +6 -0
  143. package/dist/workspace/WorkspaceDependenciesGetVersionsOptions.js +5 -0
  144. package/dist/workspace/WorkspaceDependenciesGetVersionsOptions.js.map +1 -0
  145. package/dist/workspace/WorkspaceDependency.d.ts +14 -0
  146. package/dist/workspace/WorkspaceDependency.js +3 -0
  147. package/dist/workspace/WorkspaceDependency.js.map +1 -0
  148. package/dist/workspace/WorkspaceDependencyProject.d.ts +11 -0
  149. package/dist/workspace/WorkspaceDependencyProject.js +5 -0
  150. package/dist/workspace/WorkspaceDependencyProject.js.map +1 -0
  151. package/dist/workspace/WorkspaceError.d.ts +5 -2
  152. package/dist/workspace/WorkspaceError.js +10 -3
  153. package/dist/workspace/WorkspaceError.js.map +1 -1
  154. package/dist/workspace/WorkspaceFindAndReadOptions.d.ts +6 -0
  155. package/dist/workspace/WorkspaceFindAndReadOptions.js +5 -0
  156. package/dist/workspace/WorkspaceFindAndReadOptions.js.map +1 -0
  157. package/dist/workspace/WorkspaceOptions.d.ts +4 -4
  158. package/dist/workspace/WorkspaceOptions.js.map +1 -1
  159. package/dist/workspace/{WorkspaceOptionsProjectOptions.d.ts → WorkspaceOptionsProject.d.ts} +4 -1
  160. package/dist/workspace/WorkspaceOptionsProject.js +3 -0
  161. package/dist/workspace/WorkspaceOptionsProject.js.map +1 -0
  162. package/dist/workspace/WorkspacePackageJson.d.ts +3 -0
  163. package/dist/workspace/WorkspacePackageJson.js.map +1 -1
  164. package/dist/workspace/WorkspaceProjectGlobs.d.ts +3 -0
  165. package/dist/workspace/WorkspaceProjectGlobs.js +3 -1
  166. package/dist/workspace/WorkspaceProjectGlobs.js.map +1 -1
  167. package/dist/workspace/WorkspaceProjects.d.ts +3 -0
  168. package/dist/workspace/WorkspaceProjects.js.map +1 -1
  169. package/dist/workspace/WorkspaceRepository.d.ts +3 -0
  170. package/dist/workspace/WorkspaceRepository.js +3 -1
  171. package/dist/workspace/WorkspaceRepository.js.map +1 -1
  172. package/dist/workspace/WorkspaceUpdateOptions.d.ts +3 -0
  173. package/dist/workspace/WorkspaceUpdateOptions.js +3 -1
  174. package/dist/workspace/WorkspaceUpdateOptions.js.map +1 -1
  175. package/dist/workspace/internals/compareProjectPath.d.ts +2 -0
  176. package/dist/workspace/internals/compareProjectPath.js +10 -0
  177. package/dist/workspace/internals/compareProjectPath.js.map +1 -0
  178. package/dist/workspace/internals/compareSemver.js.map +1 -1
  179. package/dist/workspace/internals/compareWorkspaceDependencyProjectName.d.ts +2 -0
  180. package/dist/workspace/internals/compareWorkspaceDependencyProjectName.js +10 -0
  181. package/dist/workspace/internals/compareWorkspaceDependencyProjectName.js.map +1 -0
  182. package/dist/workspace/internals/getPackageJsonWorkspaces.js.map +1 -1
  183. package/dist/workspace/internals/getRepositoryBranches.js.map +1 -1
  184. package/dist/workspace/internals/getRepositoryUrl.js +1 -2
  185. package/dist/workspace/internals/getRepositoryUrl.js.map +1 -1
  186. package/dist/workspace/internals.d.ts +2 -0
  187. package/dist/workspace/internals.js +2 -0
  188. package/dist/workspace/internals.js.map +1 -1
  189. package/dist/workspace/saveProjectConfig.d.ts +8 -0
  190. package/dist/workspace/saveProjectConfig.js +5 -1
  191. package/dist/workspace/saveProjectConfig.js.map +1 -1
  192. package/dist/workspace/saveWorkspaceConfig.d.ts +8 -0
  193. package/dist/workspace/saveWorkspaceConfig.js +5 -1
  194. package/dist/workspace/saveWorkspaceConfig.js.map +1 -1
  195. package/dist/workspace.d.ts +12 -0
  196. package/dist/workspace.js +12 -0
  197. package/dist/workspace.js.map +1 -1
  198. package/package.json +11 -12
  199. package/src/commands/create-project/CreateProject.tsx +2 -2
  200. package/src/commands/create-project/CreateProjectInput.ts +1 -1
  201. package/src/commands/create-project/createProjectCommand.tsx +1 -5
  202. package/src/commands/create-project/runCreateProject.ts +4 -17
  203. package/src/commands/create-workspace/CreateWorkspace.tsx +7 -5
  204. package/src/commands/create-workspace/createWorkspaceCommand.tsx +1 -14
  205. package/src/commands/create-workspace/runCreateWorkspace.ts +4 -16
  206. package/src/commands/internals/CommandStatus.ts +1 -0
  207. package/src/commands/internals.ts +1 -0
  208. package/src/commands/update-workspace/UpdateWorkspace.tsx +1 -1
  209. package/src/commands/update-workspace/updateWorkspaceCommand.tsx +1 -5
  210. package/src/constants.ts +0 -8
  211. package/src/template/CarsonTemplate.ts +8 -0
  212. package/src/template/CarsonTemplateConfig.ts +3 -0
  213. package/src/template/CarsonTemplateError.ts +19 -0
  214. package/src/template/TemplateAttributes.ts +11 -8
  215. package/src/template/TemplateData.ts +0 -2
  216. package/src/template/TemplateRender.ts +8 -1
  217. package/src/template/TemplateRenders.ts +3 -0
  218. package/src/template/applyTemplateRenders.ts +77 -23
  219. package/src/template/{TemplateRenderSnapshot.ts → internals/TemplateRenderSnapshot.ts} +6 -1
  220. package/src/template/internals/createUsingTemplateRender.ts +16 -0
  221. package/src/template/internals/deleteUsingTemplateRender.ts +35 -0
  222. package/src/template/{importCarsonTemplate.ts → internals/importCarsonTemplate.ts} +2 -2
  223. package/src/template/internals/insertUsingTemplateRender.ts +49 -0
  224. package/src/template/internals/mergeUsingTemplateRender.ts +54 -0
  225. package/src/template/internals/overwriteUsingTemplateRender.ts +16 -0
  226. package/src/template/internals/parseCarsonTemplateId.ts +13 -0
  227. package/src/template/{readCarsonTemplate.ts → internals/readCarsonTemplate.ts} +12 -9
  228. package/src/template/{resolveTemplateModule.ts → internals/resolveModule.ts} +1 -1
  229. package/src/template/{saveTemplateRenderSnapshots.ts → internals/saveTemplateRenderSnapshots.ts} +4 -3
  230. package/src/template/internals/uninsertUsingTemplateRender.ts +49 -0
  231. package/src/template/internals/unmerge.ts +1 -1
  232. package/src/template/{unmergeFileUsingTemplateRender.ts → internals/unmergeUsingTemplateRender.ts} +19 -7
  233. package/src/template/internals.ts +16 -1
  234. package/src/template/renderCarsonTemplate.ts +59 -0
  235. package/src/template.ts +2 -13
  236. package/src/workspace/Project.ts +21 -11
  237. package/src/workspace/ProjectConfig.ts +3 -0
  238. package/src/workspace/ProjectCreateOptions.ts +3 -0
  239. package/src/workspace/ProjectError.ts +5 -0
  240. package/src/workspace/ProjectOptions.ts +1 -1
  241. package/src/workspace/ProjectUpdateOptions.ts +3 -0
  242. package/src/workspace/Workspace.ts +122 -49
  243. package/src/workspace/WorkspaceConfig.ts +3 -0
  244. package/src/workspace/WorkspaceCreateOptions.ts +3 -0
  245. package/src/workspace/WorkspaceCreateProjectOptions.ts +3 -0
  246. package/src/workspace/WorkspaceDependencies.ts +30 -31
  247. package/src/workspace/WorkspaceDependenciesFromWorkspaceOptions.ts +8 -0
  248. package/src/workspace/WorkspaceDependenciesGetVersionsOptions.ts +6 -0
  249. package/src/workspace/WorkspaceDependency.ts +18 -0
  250. package/src/workspace/WorkspaceDependencyProject.ts +13 -0
  251. package/src/workspace/WorkspaceError.ts +10 -1
  252. package/src/workspace/WorkspaceFindAndReadOptions.ts +6 -0
  253. package/src/workspace/WorkspaceOptions.ts +4 -4
  254. package/src/workspace/{WorkspaceOptionsProjectOptions.ts → WorkspaceOptionsProject.ts} +4 -1
  255. package/src/workspace/WorkspacePackageJson.ts +3 -0
  256. package/src/workspace/WorkspaceProjectGlobs.ts +3 -0
  257. package/src/workspace/WorkspaceProjects.ts +3 -0
  258. package/src/workspace/WorkspaceRepository.ts +3 -0
  259. package/src/workspace/WorkspaceUpdateOptions.ts +3 -0
  260. package/src/workspace/internals/compareProjectPath.ts +14 -0
  261. package/src/workspace/internals/compareWorkspaceDependencyProjectName.ts +14 -0
  262. package/src/workspace/internals/getRepositoryUrl.ts +0 -1
  263. package/src/workspace/internals.ts +2 -0
  264. package/src/workspace/saveProjectConfig.ts +8 -0
  265. package/src/workspace/saveWorkspaceConfig.ts +8 -0
  266. package/src/workspace.ts +12 -0
  267. package/dist/template/TemplateRenderSnapshot.d.ts +0 -27
  268. package/dist/template/TemplateRenderSnapshot.js.map +0 -1
  269. package/dist/template/TemplateRenderSnapshots.d.ts +0 -27
  270. package/dist/template/TemplateRenderSnapshots.js.map +0 -1
  271. package/dist/template/createFileUsingTemplateRender.d.ts +0 -2
  272. package/dist/template/createFileUsingTemplateRender.js +0 -12
  273. package/dist/template/createFileUsingTemplateRender.js.map +0 -1
  274. package/dist/template/deleteFileUsingTemplateRender.d.ts +0 -2
  275. package/dist/template/deleteFileUsingTemplateRender.js +0 -10
  276. package/dist/template/deleteFileUsingTemplateRender.js.map +0 -1
  277. package/dist/template/importCarsonTemplate.js +0 -8
  278. package/dist/template/importCarsonTemplate.js.map +0 -1
  279. package/dist/template/insertUsingTemplateRender.d.ts +0 -2
  280. package/dist/template/insertUsingTemplateRender.js +0 -29
  281. package/dist/template/insertUsingTemplateRender.js.map +0 -1
  282. package/dist/template/loadTemplateRenderSnapshots.d.ts +0 -7
  283. package/dist/template/loadTemplateRenderSnapshots.js.map +0 -1
  284. package/dist/template/mergeFileUsingTemplateRender.d.ts +0 -2
  285. package/dist/template/mergeFileUsingTemplateRender.js.map +0 -1
  286. package/dist/template/overwriteFileUsingTemplateRender.d.ts +0 -2
  287. package/dist/template/overwriteFileUsingTemplateRender.js +0 -12
  288. package/dist/template/overwriteFileUsingTemplateRender.js.map +0 -1
  289. package/dist/template/parseTemplateId.d.ts +0 -1
  290. package/dist/template/parseTemplateId.js +0 -12
  291. package/dist/template/parseTemplateId.js.map +0 -1
  292. package/dist/template/readCarsonTemplate.js.map +0 -1
  293. package/dist/template/renderTemplate.d.ts +0 -7
  294. package/dist/template/renderTemplate.js +0 -19
  295. package/dist/template/renderTemplate.js.map +0 -1
  296. package/dist/template/resolveTemplateModule.d.ts +0 -1
  297. package/dist/template/resolveTemplateModule.js.map +0 -1
  298. package/dist/template/saveTemplateRenderSnapshots.js.map +0 -1
  299. package/dist/template/uninsertUsingTemplateRender.d.ts +0 -2
  300. package/dist/template/uninsertUsingTemplateRender.js +0 -29
  301. package/dist/template/uninsertUsingTemplateRender.js.map +0 -1
  302. package/dist/template/unmergeFileUsingTemplateRender.d.ts +0 -2
  303. package/dist/template/unmergeFileUsingTemplateRender.js.map +0 -1
  304. package/dist/workspace/WorkspaceOptionsProjectOptions.js +0 -3
  305. package/dist/workspace/WorkspaceOptionsProjectOptions.js.map +0 -1
  306. package/src/template/createFileUsingTemplateRender.ts +0 -12
  307. package/src/template/deleteFileUsingTemplateRender.ts +0 -15
  308. package/src/template/insertUsingTemplateRender.ts +0 -33
  309. package/src/template/mergeFileUsingTemplateRender.ts +0 -39
  310. package/src/template/overwriteFileUsingTemplateRender.ts +0 -12
  311. package/src/template/parseTemplateId.ts +0 -9
  312. package/src/template/renderTemplate.ts +0 -30
  313. package/src/template/uninsertUsingTemplateRender.ts +0 -36
  314. /package/dist/template/{TemplateRenderSnapshots.js → internals/TemplateRenderSnapshots.js} +0 -0
  315. /package/dist/template/{importCarsonTemplate.d.ts → internals/importCarsonTemplate.d.ts} +0 -0
  316. /package/dist/template/{loadTemplateRenderSnapshots.js → internals/loadTemplateRenderSnapshots.js} +0 -0
  317. /package/src/template/{TemplateRenderSnapshots.ts → internals/TemplateRenderSnapshots.ts} +0 -0
  318. /package/src/template/{loadTemplateRenderSnapshots.ts → internals/loadTemplateRenderSnapshots.ts} +0 -0
package/README.md CHANGED
@@ -1,20 +1,36 @@
1
+ <!-- header -->
1
2
  <div align="center">
2
3
 
3
4
  # @jakubmazanec/carson
4
5
 
5
- <!-- description -->Tool for managing workspace and project configuration.<!-- description -->
6
+ Tool for managing workspace and project configuration.
6
7
 
7
8
  </div>
9
+ <!-- header -->
8
10
 
9
11
  ## Installation
10
12
 
11
13
  ```sh
12
- npm install @jakubmazanec/carson -g
14
+ npm install @jakubmazanec/carson
13
15
  ```
14
16
 
15
17
  ⚠️ This is an [ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) package!
16
18
  It cannot be required from a CommonJS module.
17
19
 
20
+ Usually you also need a package containing Carson templates. Until you
21
+ [create your own](#carson-templates), you can use mine:
22
+
23
+ ```sh
24
+ npm install @jakubmazanec/carson-templates
25
+ ```
26
+
27
+ ⚠️ If you want to create new workspaces, you need to install both Carson and your template package
28
+ globally:
29
+
30
+ ```sh
31
+ npm install @jakubmazanec/carson @jakubmazanec/carson-templates -g
32
+ ```
33
+
18
34
  #### Prerequisites
19
35
 
20
36
  - Node.js 16 or later
@@ -47,7 +63,7 @@ See [CLI documentation](#cli) for the complete overview.
47
63
  ### How it works
48
64
 
49
65
  Carson assumes your codebase is organized in a workspace, which is simply a directory, and also
50
- usually a git repository, that contains one or multiple projects. A project is a self-contained
66
+ usually a Git repository, that contains one or multiple projects. A project is a self-contained
51
67
  piece of code, e.g. a package, or an app.
52
68
 
53
69
  > ⚠️ Currently only Node.js projects are supported.
@@ -100,8 +116,9 @@ YAML front matter. Please read [`@jakubmazanec/template` documentation](../templ
100
116
  find out in more detail how they work. Simply, they're for generating content using JavaScript as a
101
117
  templating language.
102
118
 
103
- > Yes, each "Carson template" is composed of multiple "EJS templates". Hopefully, the existence of
104
- > these two different template "types" isn't very confusing.
119
+ > Yes, each "Carson template" is composed of multiple template files, and each of these files
120
+ > contains an "EJS template". Hopefully, the existence of these two different templates "types"
121
+ > isn't very confusing.
105
122
 
106
123
  Take a look at this simplified example of `carson-templates` with two templates named `workspace`
107
124
  and `project`:
@@ -146,13 +163,13 @@ strategy: merge
146
163
  When Carson performs a workspace update, `carson-templates:project` template is rendered for each
147
164
  project that uses it, and `foo`, and `bar` have their files changed accordingly. In this example
148
165
  that means `foo/package.json` and `bar/package.json` are recursively merged with the JSONs obtained
149
- from the EJS template above (so SWC is added to development dependencies, or field
150
- `repository.directory` is set to always be the value of a variable `project.relativePath`, i.e.
151
- `'packages/foo'` or `'packages/bar'`). Updating the workspace works the same way (although using a
152
- different Carson template, e.g. `carson-templates:workspace`).
166
+ from the EJS template above (SWC is added to development dependencies, field `repository.directory`
167
+ is set to always be the value of a variable `project.relativePath`, i.e. `'packages/foo'` or
168
+ `'packages/bar'`, and so on). Updating the workspace works the same way (although using a different
169
+ Carson template, e.g. `carson-templates:workspace`).
153
170
 
154
171
  When you install a newer version of `carson-templates` that e.g. replaces SWC with another tool,
155
- before Carson does fresh update, it first uses saved (and committed to git) snapshots from the
172
+ before Carson does a fresh update, it first uses saved (and committed to Git) snapshots from the
156
173
  previous update to revert all its changes. This way you don't need to keep the previous version of
157
174
  `carson-templates` around and the updates can be always done automatically from the current state of
158
175
  the workspace.
@@ -173,9 +190,9 @@ See [API reference](./docs) for auto-generated documentation.
173
190
 
174
191
  ### Configuration
175
192
 
176
- Carson configuration files are located in a directory named `.carson` directory. Files named
177
- `workspace.json` and `project.json` are used to configure workspace and project respectively (in
178
- case of single-project workspace they're both in the same `.carson` directory).
193
+ Carson configuration files are located in a directory named `.carson`. Files named `workspace.json`
194
+ and `project.json` are used to configure the workspace and project respectively (in the case of
195
+ single-project workspace they're both in the same `.carson` directory).
179
196
 
180
197
  You can add arbitrary data to these JSONs in addition to the options described below. Because
181
198
  workspace and project configurations are available as JavaScript variables during the rendering of
@@ -200,6 +217,8 @@ configuration.
200
217
 
201
218
  Updates workspace and all projects using the configured Carson templates.
202
219
 
220
+ > ⚠️ Make sure to have committed all changes to Git, in case the update doesn't work as you expect.
221
+
203
222
  | Option | Description |
204
223
  | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
205
224
  | --path | Path to the workspace. A relative path is appended to the current working directory. The file system is traversed up to the root when looking for a workspace. |
@@ -225,7 +244,155 @@ Creates new workspace.
225
244
 
226
245
  ### Carson templates
227
246
 
228
- 🚧 This section is under development. Please check back later for updates.
247
+ Carson template is just a directory containing `*.ejs` files and `config.json` file. The purpose of
248
+ a Carson template is to describe what files with what content should exist in a project or workspace
249
+ the template is applied to.
250
+
251
+ Carson templates are identified using a template ID consisting of two colon-separated parts: a bare
252
+ module specifier and a template name, e.g. `@jakubmazanec/carson-templates:projects/library`.
253
+
254
+ Because of this, you should organize your Carson templates by putting all of them into a single
255
+ package that has to look like this:
256
+
257
+ ```
258
+ carson-templates@1.0.0/
259
+ ├── src/
260
+ │ └── main.js
261
+ ├── templates/
262
+ │ ├── projects/
263
+ │ │ ├── app/
264
+ │ │ │ ├── config.json
265
+ │ │ │ └── package.json.ejs
266
+ │ │ └── library/
267
+ │ │ ├── config.json
268
+ │ │ └── package.json.ejs
269
+ │ └── workspace/
270
+ │ ├── config.json
271
+ │ └── package.json.ejs
272
+ └── package.json
273
+ ```
274
+
275
+ This package must export `package.json` and right next to it contain a directory named `templates`
276
+ in which each template is located (under a path that corresponds to its name). In the example above,
277
+ there are 3 templates (for simplicity, each contains only one `*.ejs` file and a config file):
278
+
279
+ 1. `carson-templates:projects/app` located in `templates/projects/app`.
280
+ 2. `carson-templates:projects/library` located in `templates/projects/library`.
281
+ 3. `carson-templates:workspace` located in `templates/workspace`.
282
+
283
+ The package can also export some JavaScript code (defined in the `package.json` as usual); all named
284
+ export are available as global variables during the rendering of the template files.
285
+
286
+ > ⚠️ Do NOT use asynchronous functions in the template files. Templates are rendered synchronously.
287
+
288
+ #### Template files
289
+
290
+ All those `*.ejs` files are parsed and rendered via `@jakubmazanec/template` package; they are
291
+ actually [EJS](https://ejs.co/) templates with YAML front matter. Please read
292
+ [`@jakubmazanec/template` documentation](../template/README.md) to find out in more detail how they
293
+ work. Simply, they're for generating content using JavaScript as a templating language.
294
+
295
+ For a quick overview, look at the file `templates/projects/library/package.json.ejs`:
296
+
297
+ ```
298
+ ---
299
+ to: 'package.json'
300
+ strategy: merge
301
+ ---
302
+ {
303
+ "repository": {
304
+ "directory": "<%- project.relativePath %>"
305
+ },
306
+ "type": "module",
307
+ "exports": "./dist/main.js",
308
+ "files": [
309
+ "dist",
310
+ "src"
311
+ ],
312
+ "scripts": {
313
+ "build": "swc src -d dist"
314
+ },
315
+ "devDependencies": {
316
+ "@swc/cli": "^0.1.62",
317
+ "@swc/core": "^1.3.56"
318
+ }
319
+ }
320
+ ```
321
+
322
+ The YAML front matter contains metadata describing what to do with the content generated during the
323
+ rendering of the EJS template.
324
+
325
+ Attribute `to` is the path of the target file the resulting template render is supposed to be
326
+ written into. The path is appended to the project or workspace path. The extension is also used for
327
+ file format detection by Prettier.
328
+
329
+ Attribute `strategy` describes how exactly should the template render be written, or whether it
330
+ should be written at all.
331
+
332
+ | Strategy name | Example `strategy` value | Description |
333
+ | ------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
334
+ | Create | `'create'` | The template render is written to the target file, but only when the Carson template is used to create a new workspace or project; when Carson performs an update, the template files with this strategy are not even rendered. |
335
+ | Ensure | `'ensure'` | The template render is written to the target file, but only when the target file doesn't exist; if it does, it is left unchanged. |
336
+ | Overwrite | `'overwrite'` | The template render is written to the target file, overwriting its existing content. |
337
+ | Merge | `'merge'` | The template render is merged with the target file's existing content. Only simple objects, not arrays, are merged recursively. The only supported file formats are JSON and YAML. |
338
+ | Check | `'check'` | Only the target file's existence is checked, the template render is discarded; when Carson doesn't perform an update, the template files with this strategy are not even rendered. |
339
+ | Insert | `['insert', <string>]` | The template render is inserted between the first and last occurrence of an HTML comment containing configured string, e.g. `<!-- foobar -->`. The only supported file format is Markdown. |
340
+
341
+ The rest of the template file after the front matter is the actual EJS template. Please read
342
+ [`ejs` documentation](https://ejs.co/#docs) to find out in more detail how they work.
343
+
344
+ > ⚠️ Because EJS templates can contain arbitrary JavaScript code which Carson will run, you
345
+ > shouldn't use Carson templates from untrusted sources! Only use templates that you've written or
346
+ > extensively reviewed.
347
+
348
+ Global variables available during the rendering:
349
+
350
+ | Variable name | Description |
351
+ | ------------- | ------------------------------------------------------------------------------------- |
352
+ | `workspace` | The workspace Carson is being run in. |
353
+ | `project` | The project Carson is creating or updating; is undefined when working on a workspace. |
354
+ | `args` | Parsed command line arguments that were used to execute Carson. |
355
+
356
+ #### Carson template config
357
+
358
+ Currently, the config isn't used for anything yet.
359
+
360
+ ### Carson philosophy
361
+
362
+ The fact that Carson templates are just JavaScript gives you a lot of freedom, but it may lead you
363
+ to use Carson just as a simple config generator. Because you can add arbitrary data to the workspace
364
+ and project configs, it is tempting to use them as a source of values for "parameters" of
365
+ configurations of various tools.
366
+
367
+ For example, you can add `"useSwc": true` or `"useSwc": false` to a project config and then use this
368
+ value in a template that generates build configuration for either SWC, or Babel. But this makes
369
+ updates little bit harder, because if you later remove Babel support, you have to remember to remove
370
+ now useless setting from the project config. It also makes the logic of the Carson template more
371
+ complex; it is better to have separate templates for projects that use Babel and for project that
372
+ use SWC.
373
+
374
+ Another approach that is not recommended is using project config to specify "overrides" for various
375
+ config files:
376
+
377
+ ```json
378
+ {
379
+ "template": "@jakubmazanec/carson-templates:projects/library",
380
+
381
+ "tsconfig": {
382
+ "compilerOptions": {
383
+ "strict": false
384
+ }
385
+ }
386
+ }
387
+ ```
388
+
389
+ The `tsconfig` object is then recursively merged with the defaults during the template rendering of
390
+ the resulting `tsconfig.json`, thus allowing you to change TypeScript configuration per project.
391
+ This is not ideal, because now the Carson template isn't the only thing that defines the project
392
+ configuration, which makes updates more unpredictable.
393
+
394
+ Generally, do not push the data onto the templates, let the templates pull the data they need. Since
395
+ you create your own templates, it should be easy to do.
229
396
 
230
397
  ## Contributing
231
398
 
@@ -8,7 +8,7 @@ import { CreateProjectInput } from './CreateProjectInput.js';
8
8
  import { runCreateProject } from './runCreateProject.js';
9
9
  import { packageNameToDirectory } from '../internals.js';
10
10
  const ONLY_ONE_STAR_REGEXP = /^(?!(.*?\*){2,}|.*? |\*$).*?\*.*$/;
11
- export function CreateProject({ args , workspace }) {
11
+ export function CreateProject({ args, workspace }) {
12
12
  let [status, setStatus] = useState('not-started');
13
13
  let [subscription, setSubscription] = useState(null);
14
14
  let [jobs, setJobs] = useState([]);
@@ -26,7 +26,7 @@ export function CreateProject({ args , workspace }) {
26
26
  isComplete: !!args.options.template
27
27
  }
28
28
  }));
29
- let { exit } = useProgram();
29
+ let { exit } = useProgram();
30
30
  useEffect(()=>{
31
31
  if (Object.entries(createProjectInputResult).every(([, result])=>result.isComplete)) {
32
32
  setStatus('in-progress');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/create-project/CreateProject.tsx"],"sourcesContent":["import {Header, icons, colors, type CommandArguments, useProgram} from '@jakubmazanec/cli';\nimport chalk from 'chalk';\nimport {Box, Text} from 'ink';\nimport path from 'node:path';\nimport {useEffect, useState} from 'react';\n\nimport {type createProjectCommand} from './createProjectCommand.js';\nimport {CreateProjectInput, type CreateProjectInputResult} from './CreateProjectInput.js';\nimport {runCreateProject} from './runCreateProject.js';\nimport {type Workspace} from '../../workspace.js';\nimport {packageNameToDirectory} from '../internals.js';\n\nconst ONLY_ONE_STAR_REGEXP = /^(?!(.*?\\*){2,}|.*? |\\*$).*?\\*.*$/;\n\nexport type CreateProjectProps = {\n args: CommandArguments<typeof createProjectCommand>;\n workspace: Workspace | Workspace<false>;\n};\n\nexport function CreateProject({args, workspace}: CreateProjectProps) {\n let [status, setStatus] = useState<'finished' | 'in-progress' | 'not-started'>('not-started');\n let [subscription, setSubscription] = useState<ZenObservable.Subscription | null>(null);\n let [jobs, setJobs] = useState<string[]>([]);\n let [createProjectInputResult, setCreateProjectInputResult] = useState<CreateProjectInputResult>(\n () => ({\n projectName: {value: args.options.name ?? '', isComplete: !!args.options.name},\n projectPath: {value: '', isComplete: false},\n templateId: {value: args.options.template ?? '', isComplete: !!args.options.template},\n }),\n );\n let {exit} = useProgram();\n\n useEffect(() => {\n if (Object.entries(createProjectInputResult).every(([, result]) => result.isComplete)) {\n setStatus('in-progress');\n }\n }, [createProjectInputResult]);\n\n useEffect(() => {\n if (status === 'in-progress' && !subscription) {\n let newSubscription = runCreateProject({\n projectPath: createProjectInputResult.projectPath.value,\n templateId: createProjectInputResult.templateId.value,\n projectName: createProjectInputResult.projectName.value,\n workspace,\n args,\n }).subscribe({\n next(value) {\n setJobs((previousJobs) => [...previousJobs, value]);\n },\n error(error) {\n exit(error);\n },\n complete() {\n newSubscription.unsubscribe();\n setStatus('finished');\n },\n });\n setSubscription(newSubscription);\n }\n\n return () => {\n if (subscription) {\n subscription.unsubscribe();\n }\n };\n }, [args, createProjectInputResult, exit, status, subscription, workspace]);\n\n let possiblePaths: Array<{value: string; label: string}> = [];\n\n if (createProjectInputResult.projectName.value) {\n let destinationDirectory = packageNameToDirectory(createProjectInputResult.projectName.value);\n\n if (workspace.projectGlobs) {\n possiblePaths = workspace.projectGlobs\n .filter((projectGlob) => ONLY_ONE_STAR_REGEXP.test(projectGlob))\n .map((projectGlob) => projectGlob.replace(/\\*/, destinationDirectory))\n .map((projectGlob) => path.join(workspace.path, projectGlob))\n .map((projectPath) => ({\n value: projectPath,\n label: path.relative(workspace.path, projectPath).replace('\\\\', '/'),\n }));\n } else {\n possiblePaths = [\n {\n value: workspace.path,\n label: workspace.path,\n },\n ];\n }\n }\n\n return (\n <Box flexDirection=\"column\">\n <Text color={colors.body}>\n {`Creating project in the workspace at ${chalk[colors.info](workspace.path)}.`}\n </Text>\n\n <CreateProjectInput\n rows={{\n projectPath: {\n choices: possiblePaths,\n },\n }}\n values={createProjectInputResult}\n marginTop={1}\n onChange={setCreateProjectInputResult}\n onComplete={setCreateProjectInputResult}\n />\n\n {status === 'in-progress' || status === 'finished' ? (\n <Box marginTop={1} flexDirection=\"column\">\n <Header showSpinner={status === 'in-progress'} icon={icons.success} marginBottom={1}>\n <Text>Creating project...</Text>\n </Header>\n\n {jobs.map((job) => (\n <Text key={job}>{`${icons.info} ${job}`}</Text>\n ))}\n </Box>\n ) : null}\n\n {status === 'finished' ? (\n <Header marginTop={1} icon={icons.success}>\n <Text>Done.</Text>\n </Header>\n ) : null}\n </Box>\n );\n}\n"],"names":["Header","icons","colors","useProgram","chalk","Box","Text","path","useEffect","useState","CreateProjectInput","runCreateProject","packageNameToDirectory","ONLY_ONE_STAR_REGEXP","CreateProject","args","workspace","status","setStatus","subscription","setSubscription","jobs","setJobs","createProjectInputResult","setCreateProjectInputResult","projectName","value","options","name","isComplete","projectPath","templateId","template","exit","Object","entries","every","result","newSubscription","subscribe","next","previousJobs","error","complete","unsubscribe","possiblePaths","destinationDirectory","projectGlobs","filter","projectGlob","test","map","replace","join","label","relative","flexDirection","color","body","info","rows","choices","values","marginTop","onChange","onComplete","showSpinner","icon","success","marginBottom","job"],"mappings":"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"}
1
+ {"version":3,"sources":["../../../src/commands/create-project/CreateProject.tsx"],"sourcesContent":["import {Header, icons, colors, type CommandArguments, useProgram} from '@jakubmazanec/cli';\nimport chalk from 'chalk';\nimport {Box, Text} from 'ink';\nimport path from 'node:path';\nimport {useEffect, useState} from 'react';\n\nimport {type createProjectCommand} from './createProjectCommand.js';\nimport {CreateProjectInput, type CreateProjectInputResult} from './CreateProjectInput.js';\nimport {runCreateProject} from './runCreateProject.js';\nimport {type Workspace} from '../../workspace.js';\nimport {packageNameToDirectory, type CommandStatus} from '../internals.js';\n\nconst ONLY_ONE_STAR_REGEXP = /^(?!(.*?\\*){2,}|.*? |\\*$).*?\\*.*$/;\n\nexport type CreateProjectProps = {\n args: CommandArguments<typeof createProjectCommand>;\n workspace: Workspace | Workspace<false>;\n};\n\nexport function CreateProject({args, workspace}: CreateProjectProps) {\n let [status, setStatus] = useState<CommandStatus>('not-started');\n let [subscription, setSubscription] = useState<ZenObservable.Subscription | null>(null);\n let [jobs, setJobs] = useState<string[]>([]);\n let [createProjectInputResult, setCreateProjectInputResult] = useState<CreateProjectInputResult>(\n () => ({\n projectName: {value: args.options.name ?? '', isComplete: !!args.options.name},\n projectPath: {value: '', isComplete: false},\n templateId: {value: args.options.template ?? '', isComplete: !!args.options.template},\n }),\n );\n let {exit} = useProgram();\n\n useEffect(() => {\n if (Object.entries(createProjectInputResult).every(([, result]) => result.isComplete)) {\n setStatus('in-progress');\n }\n }, [createProjectInputResult]);\n\n useEffect(() => {\n if (status === 'in-progress' && !subscription) {\n let newSubscription = runCreateProject({\n projectPath: createProjectInputResult.projectPath.value,\n templateId: createProjectInputResult.templateId.value,\n projectName: createProjectInputResult.projectName.value,\n workspace,\n args,\n }).subscribe({\n next(value) {\n setJobs((previousJobs) => [...previousJobs, value]);\n },\n error(error) {\n exit(error);\n },\n complete() {\n newSubscription.unsubscribe();\n setStatus('finished');\n },\n });\n setSubscription(newSubscription);\n }\n\n return () => {\n if (subscription) {\n subscription.unsubscribe();\n }\n };\n }, [args, createProjectInputResult, exit, status, subscription, workspace]);\n\n let possiblePaths: Array<{value: string; label: string}> = [];\n\n if (createProjectInputResult.projectName.value) {\n let destinationDirectory = packageNameToDirectory(createProjectInputResult.projectName.value);\n\n if (workspace.projectGlobs) {\n possiblePaths = workspace.projectGlobs\n .filter((projectGlob) => ONLY_ONE_STAR_REGEXP.test(projectGlob))\n .map((projectGlob) => projectGlob.replace(/\\*/, destinationDirectory))\n .map((projectGlob) => path.join(workspace.path, projectGlob))\n .map((projectPath) => ({\n value: projectPath,\n label: path.relative(workspace.path, projectPath).replace('\\\\', '/'),\n }));\n } else {\n possiblePaths = [\n {\n value: workspace.path,\n label: workspace.path,\n },\n ];\n }\n }\n\n return (\n <Box flexDirection=\"column\">\n <Text color={colors.body}>\n {`Creating project in the workspace at ${chalk[colors.info](workspace.path)}.`}\n </Text>\n\n <CreateProjectInput\n rows={{\n projectPath: {\n choices: possiblePaths,\n },\n }}\n values={createProjectInputResult}\n marginTop={1}\n onChange={setCreateProjectInputResult}\n onComplete={setCreateProjectInputResult}\n />\n\n {status === 'in-progress' || status === 'finished' ? (\n <Box marginTop={1} flexDirection=\"column\">\n <Header showSpinner={status === 'in-progress'} icon={icons.success} marginBottom={1}>\n <Text>Creating project...</Text>\n </Header>\n\n {jobs.map((job) => (\n <Text key={job}>{`${icons.info} ${job}`}</Text>\n ))}\n </Box>\n ) : null}\n\n {status === 'finished' ? (\n <Header marginTop={1} icon={icons.success}>\n <Text>Done.</Text>\n </Header>\n ) : null}\n </Box>\n );\n}\n"],"names":["Header","icons","colors","useProgram","chalk","Box","Text","path","useEffect","useState","CreateProjectInput","runCreateProject","packageNameToDirectory","ONLY_ONE_STAR_REGEXP","CreateProject","args","workspace","status","setStatus","subscription","setSubscription","jobs","setJobs","createProjectInputResult","setCreateProjectInputResult","projectName","value","options","name","isComplete","projectPath","templateId","template","exit","Object","entries","every","result","newSubscription","subscribe","next","previousJobs","error","complete","unsubscribe","possiblePaths","destinationDirectory","projectGlobs","filter","projectGlob","test","map","replace","join","label","relative","flexDirection","color","body","info","rows","choices","values","marginTop","onChange","onComplete","showSpinner","icon","success","marginBottom","job"],"mappings":"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"}
@@ -17,7 +17,7 @@ export const CreateProjectInput = createForm({
17
17
  label: 'What is the project name?',
18
18
  validate: (value)=>{
19
19
  if (!PROJECT_NAME_ID_REGEXP.test(value)) {
20
- throw new Error('Project name can containg only lowercase letters, numbers, hyphen, @, dot or /.');
20
+ throw new Error('Project name can contain only lowercase letters, numbers, hyphen, @, dot or /.');
21
21
  }
22
22
  }
23
23
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/create-project/CreateProjectInput.ts"],"sourcesContent":["import {type FormResult, createForm} from '@jakubmazanec/cli';\n\nconst TEMPLATE_ID_REGEXP = /^.+:.+$/;\nconst PROJECT_NAME_ID_REGEXP = /^[\\d./@a-z-]+$/;\n\nexport const CreateProjectInput = createForm({\n rows: {\n templateId: {\n type: 'text',\n label: 'What template do you want to use?',\n validate: (value: string) => {\n if (!TEMPLATE_ID_REGEXP.test(value)) {\n throw new Error(\n 'Template ID must consist of a module ID and a template name separated by a colon.',\n );\n }\n },\n },\n projectName: {\n type: 'text',\n label: 'What is the project name?',\n validate: (value: string) => {\n if (!PROJECT_NAME_ID_REGEXP.test(value)) {\n throw new Error(\n 'Project name can containg only lowercase letters, numbers, hyphen, @, dot or /.',\n );\n }\n },\n },\n projectPath: {\n type: 'select',\n label: 'What is the project location?',\n },\n },\n});\n\nexport type CreateProjectInputResult = FormResult<typeof CreateProjectInput>;\n"],"names":["createForm","TEMPLATE_ID_REGEXP","PROJECT_NAME_ID_REGEXP","CreateProjectInput","rows","templateId","type","label","validate","value","test","Error","projectName","projectPath"],"mappings":"AAAA,SAAyBA,UAAU,QAAO,oBAAoB;AAE9D,MAAMC,qBAAqB;AAC3B,MAAMC,yBAAyB;AAE/B,OAAO,MAAMC,qBAAqBH,WAAW;IAC3CI,MAAM;QACJC,YAAY;YACVC,MAAM;YACNC,OAAO;YACPC,UAAU,CAACC;gBACT,IAAI,CAACR,mBAAmBS,KAAKD,QAAQ;oBACnC,MAAM,IAAIE,MACR;gBAEJ;YACF;QACF;QACAC,aAAa;YACXN,MAAM;YACNC,OAAO;YACPC,UAAU,CAACC;gBACT,IAAI,CAACP,uBAAuBQ,KAAKD,QAAQ;oBACvC,MAAM,IAAIE,MACR;gBAEJ;YACF;QACF;QACAE,aAAa;YACXP,MAAM;YACNC,OAAO;QACT;IACF;AACF,GAAG"}
1
+ {"version":3,"sources":["../../../src/commands/create-project/CreateProjectInput.ts"],"sourcesContent":["import {type FormResult, createForm} from '@jakubmazanec/cli';\n\nconst TEMPLATE_ID_REGEXP = /^.+:.+$/;\nconst PROJECT_NAME_ID_REGEXP = /^[\\d./@a-z-]+$/;\n\nexport const CreateProjectInput = createForm({\n rows: {\n templateId: {\n type: 'text',\n label: 'What template do you want to use?',\n validate: (value: string) => {\n if (!TEMPLATE_ID_REGEXP.test(value)) {\n throw new Error(\n 'Template ID must consist of a module ID and a template name separated by a colon.',\n );\n }\n },\n },\n projectName: {\n type: 'text',\n label: 'What is the project name?',\n validate: (value: string) => {\n if (!PROJECT_NAME_ID_REGEXP.test(value)) {\n throw new Error(\n 'Project name can contain only lowercase letters, numbers, hyphen, @, dot or /.',\n );\n }\n },\n },\n projectPath: {\n type: 'select',\n label: 'What is the project location?',\n },\n },\n});\n\nexport type CreateProjectInputResult = FormResult<typeof CreateProjectInput>;\n"],"names":["createForm","TEMPLATE_ID_REGEXP","PROJECT_NAME_ID_REGEXP","CreateProjectInput","rows","templateId","type","label","validate","value","test","Error","projectName","projectPath"],"mappings":"AAAA,SAAyBA,UAAU,QAAO,oBAAoB;AAE9D,MAAMC,qBAAqB;AAC3B,MAAMC,yBAAyB;AAE/B,OAAO,MAAMC,qBAAqBH,WAAW;IAC3CI,MAAM;QACJC,YAAY;YACVC,MAAM;YACNC,OAAO;YACPC,UAAU,CAACC;gBACT,IAAI,CAACR,mBAAmBS,IAAI,CAACD,QAAQ;oBACnC,MAAM,IAAIE,MACR;gBAEJ;YACF;QACF;QACAC,aAAa;YACXN,MAAM;YACNC,OAAO;YACPC,UAAU,CAACC;gBACT,IAAI,CAACP,uBAAuBQ,IAAI,CAACD,QAAQ;oBACvC,MAAM,IAAIE,MACR;gBAEJ;YACF;QACF;QACAE,aAAa;YACXP,MAAM;YACNC,OAAO;QACT;IACF;AACF,GAAG"}
@@ -5,10 +5,9 @@ import { CreateProject } from './CreateProject.js';
5
5
  import { Workspace } from '../../workspace.js';
6
6
  export const createProjectCommand = new Command('create project', async (args, program)=>{
7
7
  let targetPath = path.resolve(process.cwd(), args.options.path ?? '');
8
- let workspace = await Workspace.findAndRead(targetPath);
9
- if (!workspace) {
10
- throw new Error(`No workspace found at "${targetPath}"!`);
11
- }
8
+ let workspace = await Workspace.findAndRead(targetPath, {
9
+ throwIfNotFound: true
10
+ });
12
11
  await program.renderElement(/*#__PURE__*/ _jsx(CreateProject, {
13
12
  args: args,
14
13
  workspace: workspace
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/create-project/createProjectCommand.tsx"],"sourcesContent":["import {Command} from '@jakubmazanec/cli';\nimport path from 'node:path';\n\nimport {CreateProject} from './CreateProject.js';\nimport {Workspace} from '../../workspace.js';\n\nexport const createProjectCommand = new Command(\n 'create project',\n async (args, program) => {\n let targetPath = path.resolve(process.cwd(), args.options.path ?? '');\n let workspace = await Workspace.findAndRead(targetPath);\n\n if (!workspace) {\n throw new Error(`No workspace found at \"${targetPath}\"!`);\n }\n\n await program.renderElement(<CreateProject args={args} workspace={workspace} />);\n },\n {\n description: 'Creates a new project in an existing workspace.',\n options: {\n path: {\n type: 'string',\n },\n template: {\n type: 'string',\n },\n name: {\n type: 'string',\n },\n },\n },\n);\n"],"names":["Command","path","CreateProject","Workspace","createProjectCommand","args","program","targetPath","resolve","process","cwd","options","workspace","findAndRead","Error","renderElement","description","type","template","name"],"mappings":";AAAA,SAAQA,OAAO,QAAO,oBAAoB;AAC1C,OAAOC,UAAU,YAAY;AAE7B,SAAQC,aAAa,QAAO,qBAAqB;AACjD,SAAQC,SAAS,QAAO,qBAAqB;AAE7C,OAAO,MAAMC,uBAAuB,IAAIJ,QACtC,kBACA,OAAOK,MAAMC;IACX,IAAIC,aAAaN,KAAKO,QAAQC,QAAQC,OAAOL,KAAKM,QAAQV,QAAQ;IAClE,IAAIW,YAAY,MAAMT,UAAUU,YAAYN;IAE5C,IAAI,CAACK,WAAW;QACd,MAAM,IAAIE,MAAM,CAAC,uBAAuB,EAAEP,WAAW,EAAE,CAAC;IAC1D;IAEA,MAAMD,QAAQS,4BAAc,KAACb;QAAcG,MAAMA;QAAMO,WAAWA;;AACpE,GACA;IACEI,aAAa;IACbL,SAAS;QACPV,MAAM;YACJgB,MAAM;QACR;QACAC,UAAU;YACRD,MAAM;QACR;QACAE,MAAM;YACJF,MAAM;QACR;IACF;AACF,GACA"}
1
+ {"version":3,"sources":["../../../src/commands/create-project/createProjectCommand.tsx"],"sourcesContent":["import {Command} from '@jakubmazanec/cli';\nimport path from 'node:path';\n\nimport {CreateProject} from './CreateProject.js';\nimport {Workspace} from '../../workspace.js';\n\nexport const createProjectCommand = new Command(\n 'create project',\n async (args, program) => {\n let targetPath = path.resolve(process.cwd(), args.options.path ?? '');\n let workspace = await Workspace.findAndRead(targetPath, {throwIfNotFound: true});\n\n await program.renderElement(<CreateProject args={args} workspace={workspace} />);\n },\n {\n description: 'Creates a new project in an existing workspace.',\n options: {\n path: {\n type: 'string',\n },\n template: {\n type: 'string',\n },\n name: {\n type: 'string',\n },\n },\n },\n);\n"],"names":["Command","path","CreateProject","Workspace","createProjectCommand","args","program","targetPath","resolve","process","cwd","options","workspace","findAndRead","throwIfNotFound","renderElement","description","type","template","name"],"mappings":";AAAA,SAAQA,OAAO,QAAO,oBAAoB;AAC1C,OAAOC,UAAU,YAAY;AAE7B,SAAQC,aAAa,QAAO,qBAAqB;AACjD,SAAQC,SAAS,QAAO,qBAAqB;AAE7C,OAAO,MAAMC,uBAAuB,IAAIJ,QACtC,kBACA,OAAOK,MAAMC;IACX,IAAIC,aAAaN,KAAKO,OAAO,CAACC,QAAQC,GAAG,IAAIL,KAAKM,OAAO,CAACV,IAAI,IAAI;IAClE,IAAIW,YAAY,MAAMT,UAAUU,WAAW,CAACN,YAAY;QAACO,iBAAiB;IAAI;IAE9E,MAAMR,QAAQS,aAAa,eAAC,KAACb;QAAcG,MAAMA;QAAMO,WAAWA;;AACpE,GACA;IACEI,aAAa;IACbL,SAAS;QACPV,MAAM;YACJgB,MAAM;QACR;QACAC,UAAU;YACRD,MAAM;QACR;QACAE,MAAM;YACJF,MAAM;QACR;IACF;AACF,GACA"}
@@ -1,25 +1,15 @@
1
- import { isEmptyDirectory } from '@jakubmazanec/fs-utils';
2
- import fs from 'fs-extra';
3
- import path from 'node:path';
4
1
  import Observable from 'zen-observable';
5
- export function runCreateProject({ projectPath , templateId , projectName , workspace , args }) {
2
+ export function runCreateProject({ projectPath, templateId, projectName, workspace, args }) {
6
3
  return new Observable((observer)=>{
7
4
  (async ()=>{
8
- observer.next('TODO');
9
- let resolvedProjectPath = path.resolve(projectPath);
10
- // check if path is ok
11
- await fs.ensureDir(resolvedProjectPath);
12
- let isProjectPathEmpty = await isEmptyDirectory(resolvedProjectPath);
13
- if (!isProjectPathEmpty) {
14
- throw new Error(`Directory "${resolvedProjectPath}" must be empty`);
15
- }
16
- // create new project
5
+ observer.next('Creating files');
17
6
  let project = await workspace.createProject({
18
- projectPath: resolvedProjectPath,
7
+ projectPath,
19
8
  projectName,
20
9
  templateId,
21
10
  args
22
11
  });
12
+ observer.next('Updating the new project');
23
13
  await project.update({
24
14
  args
25
15
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/create-project/runCreateProject.ts"],"sourcesContent":["import {type CommandArguments} from '@jakubmazanec/cli';\nimport {isEmptyDirectory} from '@jakubmazanec/fs-utils';\nimport fs from 'fs-extra';\nimport path from 'node:path';\nimport Observable from 'zen-observable';\n\nimport {type createProjectCommand} from './createProjectCommand.js';\nimport {type Workspace} from '../../workspace.js';\n\nexport type CreateProjectOptions = {\n projectPath: string;\n projectName: string;\n templateId: string;\n workspace: Workspace | Workspace<false>;\n args: CommandArguments<typeof createProjectCommand>;\n};\n\nexport type CreateProjectStatus = string;\n\nexport function runCreateProject({\n projectPath,\n templateId,\n projectName,\n workspace,\n args,\n}: CreateProjectOptions) {\n return new Observable<CreateProjectStatus>((observer) => {\n (async () => {\n observer.next('TODO');\n\n let resolvedProjectPath = path.resolve(projectPath);\n\n // check if path is ok\n await fs.ensureDir(resolvedProjectPath);\n\n let isProjectPathEmpty = await isEmptyDirectory(resolvedProjectPath);\n\n if (!isProjectPathEmpty) {\n throw new Error(`Directory \"${resolvedProjectPath}\" must be empty`);\n }\n\n // create new project\n let project = await workspace.createProject({\n projectPath: resolvedProjectPath,\n projectName,\n templateId,\n args,\n });\n\n await project.update({args});\n })()\n .then(() => {\n observer.complete();\n })\n .catch((error) => {\n observer.error(error);\n });\n });\n}\n"],"names":["isEmptyDirectory","fs","path","Observable","runCreateProject","projectPath","templateId","projectName","workspace","args","observer","next","resolvedProjectPath","resolve","ensureDir","isProjectPathEmpty","Error","project","createProject","update","then","complete","catch","error"],"mappings":"AACA,SAAQA,gBAAgB,QAAO,yBAAyB;AACxD,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,UAAU,YAAY;AAC7B,OAAOC,gBAAgB,iBAAiB;AAexC,OAAO,SAASC,iBAAiB,EAC/BC,YAAW,EACXC,WAAU,EACVC,YAAW,EACXC,UAAS,EACTC,KAAI,EACiB;IACrB,OAAO,IAAIN,WAAgC,CAACO;QACzC,CAAA;YACCA,SAASC,KAAK;YAEd,IAAIC,sBAAsBV,KAAKW,QAAQR;YAEvC,sBAAsB;YACtB,MAAMJ,GAAGa,UAAUF;YAEnB,IAAIG,qBAAqB,MAAMf,iBAAiBY;YAEhD,IAAI,CAACG,oBAAoB;gBACvB,MAAM,IAAIC,MAAM,CAAC,WAAW,EAAEJ,oBAAoB,eAAe,CAAC;YACpE;YAEA,qBAAqB;YACrB,IAAIK,UAAU,MAAMT,UAAUU,cAAc;gBAC1Cb,aAAaO;gBACbL;gBACAD;gBACAG;YACF;YAEA,MAAMQ,QAAQE,OAAO;gBAACV;YAAI;QAC5B,CAAA,IACGW,KAAK;YACJV,SAASW;QACX,GACCC,MAAM,CAACC;YACNb,SAASa,MAAMA;QACjB;IACJ;AACF"}
1
+ {"version":3,"sources":["../../../src/commands/create-project/runCreateProject.ts"],"sourcesContent":["import {type CommandArguments} from '@jakubmazanec/cli';\nimport Observable from 'zen-observable';\n\nimport {type createProjectCommand} from './createProjectCommand.js';\nimport {type Workspace} from '../../workspace.js';\n\nexport type CreateProjectOptions = {\n projectPath: string;\n projectName: string;\n templateId: string;\n workspace: Workspace | Workspace<false>;\n args: CommandArguments<typeof createProjectCommand>;\n};\n\nexport type CreateProjectStatus = string;\n\nexport function runCreateProject({\n projectPath,\n templateId,\n projectName,\n workspace,\n args,\n}: CreateProjectOptions) {\n return new Observable<CreateProjectStatus>((observer) => {\n (async () => {\n observer.next('Creating files');\n\n let project = await workspace.createProject({\n projectPath,\n projectName,\n templateId,\n args,\n });\n\n observer.next('Updating the new project');\n\n await project.update({args});\n })()\n .then(() => {\n observer.complete();\n })\n .catch((error) => {\n observer.error(error);\n });\n });\n}\n"],"names":["Observable","runCreateProject","projectPath","templateId","projectName","workspace","args","observer","next","project","createProject","update","then","complete","catch","error"],"mappings":"AACA,OAAOA,gBAAgB,iBAAiB;AAexC,OAAO,SAASC,iBAAiB,EAC/BC,WAAW,EACXC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,IAAI,EACiB;IACrB,OAAO,IAAIN,WAAgC,CAACO;QACzC,CAAA;YACCA,SAASC,IAAI,CAAC;YAEd,IAAIC,UAAU,MAAMJ,UAAUK,aAAa,CAAC;gBAC1CR;gBACAE;gBACAD;gBACAG;YACF;YAEAC,SAASC,IAAI,CAAC;YAEd,MAAMC,QAAQE,MAAM,CAAC;gBAACL;YAAI;QAC5B,CAAA,IACGM,IAAI,CAAC;YACJL,SAASM,QAAQ;QACnB,GACCC,KAAK,CAAC,CAACC;YACNR,SAASQ,KAAK,CAACA;QACjB;IACJ;AACF"}
@@ -2,6 +2,5 @@ import { type CommandArguments } from '@jakubmazanec/cli';
2
2
  import { type createWorkspaceCommand } from './createWorkspaceCommand.js';
3
3
  export type CreateWorkspaceProps = {
4
4
  args: CommandArguments<typeof createWorkspaceCommand>;
5
- path: string;
6
5
  };
7
- export declare function CreateWorkspace({ args, path }: CreateWorkspaceProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function CreateWorkspace({ args }: CreateWorkspaceProps): import("react/jsx-runtime").JSX.Element;
@@ -2,10 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Header, icons, colors, useProgram } from '@jakubmazanec/cli';
3
3
  import chalk from 'chalk';
4
4
  import { Box, Text } from 'ink';
5
+ import path from 'node:path';
5
6
  import { useEffect, useState } from 'react';
6
7
  import { CreateWorkspaceInput } from './CreateWorkspaceInput.js';
7
8
  import { runCreateWorkspace } from './runCreateWorkspace.js';
8
- export function CreateWorkspace({ args , path }) {
9
+ export function CreateWorkspace({ args }) {
9
10
  let [status, setStatus] = useState('not-started');
10
11
  let [subscription, setSubscription] = useState(null);
11
12
  let [jobs, setJobs] = useState([]);
@@ -15,7 +16,8 @@ export function CreateWorkspace({ args , path }) {
15
16
  isComplete: !!args.options.template
16
17
  }
17
18
  }));
18
- let { exit } = useProgram();
19
+ let { exit } = useProgram();
20
+ let workspacePath = path.resolve(process.cwd(), args.options.path ?? '');
19
21
  useEffect(()=>{
20
22
  if (Object.entries(createWorkspaceInputResult).every(([, result])=>result.isComplete)) {
21
23
  setStatus('in-progress');
@@ -26,7 +28,7 @@ export function CreateWorkspace({ args , path }) {
26
28
  useEffect(()=>{
27
29
  if (status === 'in-progress' && !subscription) {
28
30
  let newSubscription = runCreateWorkspace({
29
- workspacePath: path,
31
+ workspacePath,
30
32
  templateId: createWorkspaceInputResult.templateId.value,
31
33
  args
32
34
  }).subscribe({
@@ -53,11 +55,11 @@ export function CreateWorkspace({ args , path }) {
53
55
  };
54
56
  }, [
55
57
  createWorkspaceInputResult,
56
- path,
57
58
  status,
58
59
  subscription,
59
60
  args,
60
- exit
61
+ exit,
62
+ workspacePath
61
63
  ]);
62
64
  return /*#__PURE__*/ _jsxs(Box, {
63
65
  flexDirection: "column",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/create-workspace/CreateWorkspace.tsx"],"sourcesContent":["import {Header, icons, colors, type CommandArguments, useProgram} from '@jakubmazanec/cli';\nimport chalk from 'chalk';\nimport {Box, Text} from 'ink';\nimport {useEffect, useState} from 'react';\n\nimport {type createWorkspaceCommand} from './createWorkspaceCommand.js';\nimport {CreateWorkspaceInput, type CreateWorkspaceInputResult} from './CreateWorkspaceInput.js';\nimport {runCreateWorkspace} from './runCreateWorkspace.js';\n\nexport type CreateWorkspaceProps = {\n args: CommandArguments<typeof createWorkspaceCommand>;\n path: string;\n};\n\nexport function CreateWorkspace({args, path}: CreateWorkspaceProps) {\n let [status, setStatus] = useState<'finished' | 'in-progress' | 'not-started'>('not-started');\n let [subscription, setSubscription] = useState<ZenObservable.Subscription | null>(null);\n let [jobs, setJobs] = useState<string[]>([]);\n let [createWorkspaceInputResult, setCreateWorkspaceInputResult] =\n useState<CreateWorkspaceInputResult>(() => ({\n templateId: {value: args.options.template ?? '', isComplete: !!args.options.template},\n }));\n let {exit} = useProgram();\n\n useEffect(() => {\n if (Object.entries(createWorkspaceInputResult).every(([, result]) => result.isComplete)) {\n setStatus('in-progress');\n }\n }, [createWorkspaceInputResult]);\n\n useEffect(() => {\n if (status === 'in-progress' && !subscription) {\n let newSubscription = runCreateWorkspace({\n workspacePath: path,\n templateId: createWorkspaceInputResult.templateId.value,\n args,\n }).subscribe({\n next(value) {\n setJobs((previousJobs) => [...previousJobs, value]);\n },\n error(error) {\n exit(error);\n },\n complete() {\n newSubscription.unsubscribe();\n setStatus('finished');\n },\n });\n\n setSubscription(newSubscription);\n }\n\n return () => {\n if (subscription) {\n subscription.unsubscribe();\n }\n };\n }, [createWorkspaceInputResult, path, status, subscription, args, exit]);\n\n return (\n <Box flexDirection=\"column\">\n <Text>{`Creating workspace at ${chalk[colors.highlighted](path)}.`}</Text>\n\n <CreateWorkspaceInput\n values={createWorkspaceInputResult}\n marginTop={1}\n onChange={setCreateWorkspaceInputResult}\n onComplete={setCreateWorkspaceInputResult}\n />\n\n {status === 'in-progress' || status === 'finished' ? (\n <Box marginTop={1} flexDirection=\"column\">\n <Header showSpinner={status === 'in-progress'} icon={icons.success} marginBottom={1}>\n <Text>Creating workspace...</Text>\n </Header>\n\n {jobs.map((job) => (\n <Text key={job}>{`${icons.info} ${job}`}</Text>\n ))}\n </Box>\n ) : null}\n\n {status === 'finished' ? (\n <Header marginTop={1} icon={icons.success}>\n <Text>Done.</Text>\n </Header>\n ) : null}\n </Box>\n );\n}\n"],"names":["Header","icons","colors","useProgram","chalk","Box","Text","useEffect","useState","CreateWorkspaceInput","runCreateWorkspace","CreateWorkspace","args","path","status","setStatus","subscription","setSubscription","jobs","setJobs","createWorkspaceInputResult","setCreateWorkspaceInputResult","templateId","value","options","template","isComplete","exit","Object","entries","every","result","newSubscription","workspacePath","subscribe","next","previousJobs","error","complete","unsubscribe","flexDirection","highlighted","values","marginTop","onChange","onComplete","showSpinner","icon","success","marginBottom","map","job","info"],"mappings":";AAAA,SAAQA,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAyBC,UAAU,QAAO,oBAAoB;AAC3F,OAAOC,WAAW,QAAQ;AAC1B,SAAQC,GAAG,EAAEC,IAAI,QAAO,MAAM;AAC9B,SAAQC,SAAS,EAAEC,QAAQ,QAAO,QAAQ;AAG1C,SAAQC,oBAAoB,QAAwC,4BAA4B;AAChG,SAAQC,kBAAkB,QAAO,0BAA0B;AAO3D,OAAO,SAASC,gBAAgB,EAACC,KAAI,EAAEC,KAAI,EAAuB;IAChE,IAAI,CAACC,QAAQC,UAAU,GAAGP,SAAqD;IAC/E,IAAI,CAACQ,cAAcC,gBAAgB,GAAGT,SAA4C;IAClF,IAAI,CAACU,MAAMC,QAAQ,GAAGX,SAAmB,EAAE;IAC3C,IAAI,CAACY,4BAA4BC,8BAA8B,GAC7Db,SAAqC,IAAO,CAAA;YAC1Cc,YAAY;gBAACC,OAAOX,KAAKY,QAAQC,YAAY;gBAAIC,YAAY,CAAC,CAACd,KAAKY,QAAQC;YAAQ;QACtF,CAAA;IACF,IAAI,EAACE,KAAI,EAAC,GAAGxB;IAEbI,UAAU;QACR,IAAIqB,OAAOC,QAAQT,4BAA4BU,MAAM,CAAC,GAAGC,OAAO,GAAKA,OAAOL,aAAa;YACvFX,UAAU;QACZ;IACF,GAAG;QAACK;KAA2B;IAE/Bb,UAAU;QACR,IAAIO,WAAW,iBAAiB,CAACE,cAAc;YAC7C,IAAIgB,kBAAkBtB,mBAAmB;gBACvCuB,eAAepB;gBACfS,YAAYF,2BAA2BE,WAAWC;gBAClDX;YACF,GAAGsB,UAAU;gBACXC,MAAKZ,KAAK;oBACRJ,QAAQ,CAACiB,eAAiB;+BAAIA;4BAAcb;yBAAM;gBACpD;gBACAc,OAAMA,KAAK;oBACTV,KAAKU;gBACP;gBACAC;oBACEN,gBAAgBO;oBAChBxB,UAAU;gBACZ;YACF;YAEAE,gBAAgBe;QAClB;QAEA,OAAO;YACL,IAAIhB,cAAc;gBAChBA,aAAauB;YACf;QACF;IACF,GAAG;QAACnB;QAA4BP;QAAMC;QAAQE;QAAcJ;QAAMe;KAAK;IAEvE,qBACE,MAACtB;QAAImC,eAAc;;0BACjB,KAAClC;0BAAM,CAAC,sBAAsB,EAAEF,KAAK,CAACF,OAAOuC,YAAY,CAAC5B,MAAM,CAAC,CAAC;;0BAElE,KAACJ;gBACCiC,QAAQtB;gBACRuB,WAAW;gBACXC,UAAUvB;gBACVwB,YAAYxB;;YAGbP,WAAW,iBAAiBA,WAAW,2BACtC,MAACT;gBAAIsC,WAAW;gBAAGH,eAAc;;kCAC/B,KAACxC;wBAAO8C,aAAahC,WAAW;wBAAeiC,MAAM9C,MAAM+C;wBAASC,cAAc;kCAChF,cAAA,KAAC3C;sCAAK;;;oBAGPY,KAAKgC,IAAI,CAACC,oBACT,KAAC7C;sCAAgB,CAAC,EAAEL,MAAMmD,KAAK,CAAC,EAAED,IAAI,CAAC;2BAA5BA;;iBAGb;YAEHrC,WAAW,2BACV,KAACd;gBAAO2C,WAAW;gBAAGI,MAAM9C,MAAM+C;0BAChC,cAAA,KAAC1C;8BAAK;;iBAEN;;;AAGV"}
1
+ {"version":3,"sources":["../../../src/commands/create-workspace/CreateWorkspace.tsx"],"sourcesContent":["import {Header, icons, colors, type CommandArguments, useProgram} from '@jakubmazanec/cli';\nimport chalk from 'chalk';\nimport {Box, Text} from 'ink';\nimport path from 'node:path';\nimport {useEffect, useState} from 'react';\n\nimport {type createWorkspaceCommand} from './createWorkspaceCommand.js';\nimport {CreateWorkspaceInput, type CreateWorkspaceInputResult} from './CreateWorkspaceInput.js';\nimport {runCreateWorkspace} from './runCreateWorkspace.js';\nimport {type CommandStatus} from '../internals.js';\n\nexport type CreateWorkspaceProps = {\n args: CommandArguments<typeof createWorkspaceCommand>;\n};\n\nexport function CreateWorkspace({args}: CreateWorkspaceProps) {\n let [status, setStatus] = useState<CommandStatus>('not-started');\n let [subscription, setSubscription] = useState<ZenObservable.Subscription | null>(null);\n let [jobs, setJobs] = useState<string[]>([]);\n let [createWorkspaceInputResult, setCreateWorkspaceInputResult] =\n useState<CreateWorkspaceInputResult>(() => ({\n templateId: {value: args.options.template ?? '', isComplete: !!args.options.template},\n }));\n let {exit} = useProgram();\n let workspacePath = path.resolve(process.cwd(), args.options.path ?? '');\n\n useEffect(() => {\n if (Object.entries(createWorkspaceInputResult).every(([, result]) => result.isComplete)) {\n setStatus('in-progress');\n }\n }, [createWorkspaceInputResult]);\n\n useEffect(() => {\n if (status === 'in-progress' && !subscription) {\n let newSubscription = runCreateWorkspace({\n workspacePath,\n templateId: createWorkspaceInputResult.templateId.value,\n args,\n }).subscribe({\n next(value) {\n setJobs((previousJobs) => [...previousJobs, value]);\n },\n error(error) {\n exit(error);\n },\n complete() {\n newSubscription.unsubscribe();\n setStatus('finished');\n },\n });\n\n setSubscription(newSubscription);\n }\n\n return () => {\n if (subscription) {\n subscription.unsubscribe();\n }\n };\n }, [createWorkspaceInputResult, status, subscription, args, exit, workspacePath]);\n\n return (\n <Box flexDirection=\"column\">\n <Text>{`Creating workspace at ${chalk[colors.highlighted](path)}.`}</Text>\n\n <CreateWorkspaceInput\n values={createWorkspaceInputResult}\n marginTop={1}\n onChange={setCreateWorkspaceInputResult}\n onComplete={setCreateWorkspaceInputResult}\n />\n\n {status === 'in-progress' || status === 'finished' ? (\n <Box marginTop={1} flexDirection=\"column\">\n <Header showSpinner={status === 'in-progress'} icon={icons.success} marginBottom={1}>\n <Text>Creating workspace...</Text>\n </Header>\n\n {jobs.map((job) => (\n <Text key={job}>{`${icons.info} ${job}`}</Text>\n ))}\n </Box>\n ) : null}\n\n {status === 'finished' ? (\n <Header marginTop={1} icon={icons.success}>\n <Text>Done.</Text>\n </Header>\n ) : null}\n </Box>\n );\n}\n"],"names":["Header","icons","colors","useProgram","chalk","Box","Text","path","useEffect","useState","CreateWorkspaceInput","runCreateWorkspace","CreateWorkspace","args","status","setStatus","subscription","setSubscription","jobs","setJobs","createWorkspaceInputResult","setCreateWorkspaceInputResult","templateId","value","options","template","isComplete","exit","workspacePath","resolve","process","cwd","Object","entries","every","result","newSubscription","subscribe","next","previousJobs","error","complete","unsubscribe","flexDirection","highlighted","values","marginTop","onChange","onComplete","showSpinner","icon","success","marginBottom","map","job","info"],"mappings":";AAAA,SAAQA,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAyBC,UAAU,QAAO,oBAAoB;AAC3F,OAAOC,WAAW,QAAQ;AAC1B,SAAQC,GAAG,EAAEC,IAAI,QAAO,MAAM;AAC9B,OAAOC,UAAU,YAAY;AAC7B,SAAQC,SAAS,EAAEC,QAAQ,QAAO,QAAQ;AAG1C,SAAQC,oBAAoB,QAAwC,4BAA4B;AAChG,SAAQC,kBAAkB,QAAO,0BAA0B;AAO3D,OAAO,SAASC,gBAAgB,EAACC,IAAI,EAAuB;IAC1D,IAAI,CAACC,QAAQC,UAAU,GAAGN,SAAwB;IAClD,IAAI,CAACO,cAAcC,gBAAgB,GAAGR,SAA4C;IAClF,IAAI,CAACS,MAAMC,QAAQ,GAAGV,SAAmB,EAAE;IAC3C,IAAI,CAACW,4BAA4BC,8BAA8B,GAC7DZ,SAAqC,IAAO,CAAA;YAC1Ca,YAAY;gBAACC,OAAOV,KAAKW,OAAO,CAACC,QAAQ,IAAI;gBAAIC,YAAY,CAAC,CAACb,KAAKW,OAAO,CAACC,QAAQ;YAAA;QACtF,CAAA;IACF,IAAI,EAACE,IAAI,EAAC,GAAGxB;IACb,IAAIyB,gBAAgBrB,KAAKsB,OAAO,CAACC,QAAQC,GAAG,IAAIlB,KAAKW,OAAO,CAACjB,IAAI,IAAI;IAErEC,UAAU;QACR,IAAIwB,OAAOC,OAAO,CAACb,4BAA4Bc,KAAK,CAAC,CAAC,GAAGC,OAAO,GAAKA,OAAOT,UAAU,GAAG;YACvFX,UAAU;QACZ;IACF,GAAG;QAACK;KAA2B;IAE/BZ,UAAU;QACR,IAAIM,WAAW,iBAAiB,CAACE,cAAc;YAC7C,IAAIoB,kBAAkBzB,mBAAmB;gBACvCiB;gBACAN,YAAYF,2BAA2BE,UAAU,CAACC,KAAK;gBACvDV;YACF,GAAGwB,SAAS,CAAC;gBACXC,MAAKf,KAAK;oBACRJ,QAAQ,CAACoB,eAAiB;+BAAIA;4BAAchB;yBAAM;gBACpD;gBACAiB,OAAMA,KAAK;oBACTb,KAAKa;gBACP;gBACAC;oBACEL,gBAAgBM,WAAW;oBAC3B3B,UAAU;gBACZ;YACF;YAEAE,gBAAgBmB;QAClB;QAEA,OAAO;YACL,IAAIpB,cAAc;gBAChBA,aAAa0B,WAAW;YAC1B;QACF;IACF,GAAG;QAACtB;QAA4BN;QAAQE;QAAcH;QAAMc;QAAMC;KAAc;IAEhF,qBACE,MAACvB;QAAIsC,eAAc;;0BACjB,KAACrC;0BAAM,CAAC,sBAAsB,EAAEF,KAAK,CAACF,OAAO0C,WAAW,CAAC,CAACrC,MAAM,CAAC,CAAC;;0BAElE,KAACG;gBACCmC,QAAQzB;gBACR0B,WAAW;gBACXC,UAAU1B;gBACV2B,YAAY3B;;YAGbP,WAAW,iBAAiBA,WAAW,2BACtC,MAACT;gBAAIyC,WAAW;gBAAGH,eAAc;;kCAC/B,KAAC3C;wBAAOiD,aAAanC,WAAW;wBAAeoC,MAAMjD,MAAMkD,OAAO;wBAAEC,cAAc;kCAChF,cAAA,KAAC9C;sCAAK;;;oBAGPY,KAAKmC,GAAG,CAAC,CAACC,oBACT,KAAChD;sCAAgB,CAAC,EAAEL,MAAMsD,IAAI,CAAC,CAAC,EAAED,IAAI,CAAC;2BAA5BA;;iBAGb;YAEHxC,WAAW,2BACV,KAACd;gBAAO8C,WAAW;gBAAGI,MAAMjD,MAAMkD,OAAO;0BACvC,cAAA,KAAC7C;8BAAK;;iBAEN;;;AAGV"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/create-workspace/CreateWorkspaceInput.ts"],"sourcesContent":["import {type FormResult, createForm} from '@jakubmazanec/cli';\n\nconst TEMPLATE_ID_REGEXP = /^.+:.+$/;\n\nexport const CreateWorkspaceInput = createForm({\n rows: {\n templateId: {\n type: 'text',\n label: 'Enter template ID:',\n validate: (value: string) => {\n if (!TEMPLATE_ID_REGEXP.test(value)) {\n throw new Error(\n 'Template ID must consist of a module ID and a template name separated by a colon.',\n );\n }\n },\n },\n },\n});\n\nexport type CreateWorkspaceInputResult = FormResult<typeof CreateWorkspaceInput>;\n"],"names":["createForm","TEMPLATE_ID_REGEXP","CreateWorkspaceInput","rows","templateId","type","label","validate","value","test","Error"],"mappings":"AAAA,SAAyBA,UAAU,QAAO,oBAAoB;AAE9D,MAAMC,qBAAqB;AAE3B,OAAO,MAAMC,uBAAuBF,WAAW;IAC7CG,MAAM;QACJC,YAAY;YACVC,MAAM;YACNC,OAAO;YACPC,UAAU,CAACC;gBACT,IAAI,CAACP,mBAAmBQ,KAAKD,QAAQ;oBACnC,MAAM,IAAIE,MACR;gBAEJ;YACF;QACF;IACF;AACF,GAAG"}
1
+ {"version":3,"sources":["../../../src/commands/create-workspace/CreateWorkspaceInput.ts"],"sourcesContent":["import {type FormResult, createForm} from '@jakubmazanec/cli';\n\nconst TEMPLATE_ID_REGEXP = /^.+:.+$/;\n\nexport const CreateWorkspaceInput = createForm({\n rows: {\n templateId: {\n type: 'text',\n label: 'Enter template ID:',\n validate: (value: string) => {\n if (!TEMPLATE_ID_REGEXP.test(value)) {\n throw new Error(\n 'Template ID must consist of a module ID and a template name separated by a colon.',\n );\n }\n },\n },\n },\n});\n\nexport type CreateWorkspaceInputResult = FormResult<typeof CreateWorkspaceInput>;\n"],"names":["createForm","TEMPLATE_ID_REGEXP","CreateWorkspaceInput","rows","templateId","type","label","validate","value","test","Error"],"mappings":"AAAA,SAAyBA,UAAU,QAAO,oBAAoB;AAE9D,MAAMC,qBAAqB;AAE3B,OAAO,MAAMC,uBAAuBF,WAAW;IAC7CG,MAAM;QACJC,YAAY;YACVC,MAAM;YACNC,OAAO;YACPC,UAAU,CAACC;gBACT,IAAI,CAACP,mBAAmBQ,IAAI,CAACD,QAAQ;oBACnC,MAAM,IAAIE,MACR;gBAEJ;YACF;QACF;IACF;AACF,GAAG"}
@@ -1,19 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Command } from '@jakubmazanec/cli';
3
- import { isEmptyDirectory } from '@jakubmazanec/fs-utils';
4
- import fs from 'fs-extra';
5
- import path from 'node:path';
6
3
  import { CreateWorkspace } from './CreateWorkspace.js';
7
4
  export const createWorkspaceCommand = new Command('create workspace', async (args, program)=>{
8
- let workspacePath = path.resolve(process.cwd(), args.options.path ?? '');
9
- await fs.ensureDir(workspacePath);
10
- let isWorkspacePathEmpty = await isEmptyDirectory(workspacePath);
11
- if (!isWorkspacePathEmpty) {
12
- throw new Error(`Directory "${workspacePath}" must be empty`);
13
- }
14
5
  await program.renderElement(/*#__PURE__*/ _jsx(CreateWorkspace, {
15
- args: args,
16
- path: workspacePath
6
+ args: args
17
7
  }));
18
8
  }, {
19
9
  description: 'Creates a new workspacee.',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/create-workspace/createWorkspaceCommand.tsx"],"sourcesContent":["import {Command} from '@jakubmazanec/cli';\nimport {isEmptyDirectory} from '@jakubmazanec/fs-utils';\nimport fs from 'fs-extra';\nimport path from 'node:path';\n\nimport {CreateWorkspace} from './CreateWorkspace.js';\n\nexport const createWorkspaceCommand = new Command(\n 'create workspace',\n async (args, program) => {\n let workspacePath = path.resolve(process.cwd(), args.options.path ?? '');\n\n await fs.ensureDir(workspacePath);\n\n let isWorkspacePathEmpty = await isEmptyDirectory(workspacePath);\n\n if (!isWorkspacePathEmpty) {\n throw new Error(`Directory \"${workspacePath}\" must be empty`);\n }\n\n await program.renderElement(<CreateWorkspace args={args} path={workspacePath} />);\n },\n {\n description: 'Creates a new workspacee.',\n options: {\n path: {\n type: 'string',\n },\n template: {\n type: 'string',\n },\n },\n },\n);\n"],"names":["Command","isEmptyDirectory","fs","path","CreateWorkspace","createWorkspaceCommand","args","program","workspacePath","resolve","process","cwd","options","ensureDir","isWorkspacePathEmpty","Error","renderElement","description","type","template"],"mappings":";AAAA,SAAQA,OAAO,QAAO,oBAAoB;AAC1C,SAAQC,gBAAgB,QAAO,yBAAyB;AACxD,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,UAAU,YAAY;AAE7B,SAAQC,eAAe,QAAO,uBAAuB;AAErD,OAAO,MAAMC,yBAAyB,IAAIL,QACxC,oBACA,OAAOM,MAAMC;IACX,IAAIC,gBAAgBL,KAAKM,QAAQC,QAAQC,OAAOL,KAAKM,QAAQT,QAAQ;IAErE,MAAMD,GAAGW,UAAUL;IAEnB,IAAIM,uBAAuB,MAAMb,iBAAiBO;IAElD,IAAI,CAACM,sBAAsB;QACzB,MAAM,IAAIC,MAAM,CAAC,WAAW,EAAEP,cAAc,eAAe,CAAC;IAC9D;IAEA,MAAMD,QAAQS,4BAAc,KAACZ;QAAgBE,MAAMA;QAAMH,MAAMK;;AACjE,GACA;IACES,aAAa;IACbL,SAAS;QACPT,MAAM;YACJe,MAAM;QACR;QACAC,UAAU;YACRD,MAAM;QACR;IACF;AACF,GACA"}
1
+ {"version":3,"sources":["../../../src/commands/create-workspace/createWorkspaceCommand.tsx"],"sourcesContent":["import {Command} from '@jakubmazanec/cli';\n\nimport {CreateWorkspace} from './CreateWorkspace.js';\n\nexport const createWorkspaceCommand = new Command(\n 'create workspace',\n async (args, program) => {\n await program.renderElement(<CreateWorkspace args={args} />);\n },\n {\n description: 'Creates a new workspacee.',\n options: {\n path: {\n type: 'string',\n },\n template: {\n type: 'string',\n },\n },\n },\n);\n"],"names":["Command","CreateWorkspace","createWorkspaceCommand","args","program","renderElement","description","options","path","type","template"],"mappings":";AAAA,SAAQA,OAAO,QAAO,oBAAoB;AAE1C,SAAQC,eAAe,QAAO,uBAAuB;AAErD,OAAO,MAAMC,yBAAyB,IAAIF,QACxC,oBACA,OAAOG,MAAMC;IACX,MAAMA,QAAQC,aAAa,eAAC,KAACJ;QAAgBE,MAAMA;;AACrD,GACA;IACEG,aAAa;IACbC,SAAS;QACPC,MAAM;YACJC,MAAM;QACR;QACAC,UAAU;YACRD,MAAM;QACR;IACF;AACF,GACA"}
@@ -1,24 +1,15 @@
1
- import { isEmptyDirectory } from '@jakubmazanec/fs-utils';
2
- import fs from 'fs-extra';
3
- import path from 'node:path';
4
1
  import Observable from 'zen-observable';
5
2
  import { Workspace } from '../../workspace.js';
6
- export function runCreateWorkspace({ workspacePath , templateId , args }) {
3
+ export function runCreateWorkspace({ workspacePath, templateId, args }) {
7
4
  return new Observable((observer)=>{
8
5
  (async ()=>{
9
- observer.next('TODO');
10
- let resolvedWorkspacePath = path.resolve(workspacePath);
11
- await fs.ensureDir(resolvedWorkspacePath);
12
- let isWorkspacePathEmpty = await isEmptyDirectory(resolvedWorkspacePath);
13
- if (!isWorkspacePathEmpty) {
14
- throw new Error(`Directory "${resolvedWorkspacePath}" must be empty`);
15
- }
16
- // create new workspace
6
+ observer.next('Creating files');
17
7
  let workspace = await Workspace.create({
18
8
  args,
19
- path: resolvedWorkspacePath,
9
+ path: workspacePath,
20
10
  templateId
21
11
  });
12
+ observer.next('Updating the new workspace');
22
13
  await workspace.update({
23
14
  args
24
15
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/create-workspace/runCreateWorkspace.ts"],"sourcesContent":["import {type CommandArguments} from '@jakubmazanec/cli';\nimport {isEmptyDirectory} from '@jakubmazanec/fs-utils';\nimport fs from 'fs-extra';\nimport path from 'node:path';\nimport Observable from 'zen-observable';\n\nimport {type createWorkspaceCommand} from './createWorkspaceCommand.js';\nimport {Workspace} from '../../workspace.js';\n\nexport type CreateWorkspaceOptions = {\n workspacePath: string;\n templateId: string;\n args: CommandArguments<typeof createWorkspaceCommand>;\n};\n\nexport type CreateWorkspaceStatus = string;\n\nexport function runCreateWorkspace({workspacePath, templateId, args}: CreateWorkspaceOptions) {\n return new Observable<CreateWorkspaceStatus>((observer) => {\n (async () => {\n observer.next('TODO');\n\n let resolvedWorkspacePath = path.resolve(workspacePath);\n\n await fs.ensureDir(resolvedWorkspacePath);\n\n let isWorkspacePathEmpty = await isEmptyDirectory(resolvedWorkspacePath);\n\n if (!isWorkspacePathEmpty) {\n throw new Error(`Directory \"${resolvedWorkspacePath}\" must be empty`);\n }\n\n // create new workspace\n let workspace = await Workspace.create({\n args,\n path: resolvedWorkspacePath,\n templateId,\n });\n\n await workspace.update({args});\n })()\n .then(() => {\n observer.complete();\n })\n .catch((error) => {\n observer.error(error);\n });\n });\n}\n"],"names":["isEmptyDirectory","fs","path","Observable","Workspace","runCreateWorkspace","workspacePath","templateId","args","observer","next","resolvedWorkspacePath","resolve","ensureDir","isWorkspacePathEmpty","Error","workspace","create","update","then","complete","catch","error"],"mappings":"AACA,SAAQA,gBAAgB,QAAO,yBAAyB;AACxD,OAAOC,QAAQ,WAAW;AAC1B,OAAOC,UAAU,YAAY;AAC7B,OAAOC,gBAAgB,iBAAiB;AAGxC,SAAQC,SAAS,QAAO,qBAAqB;AAU7C,OAAO,SAASC,mBAAmB,EAACC,cAAa,EAAEC,WAAU,EAAEC,KAAI,EAAyB;IAC1F,OAAO,IAAIL,WAAkC,CAACM;QAC3C,CAAA;YACCA,SAASC,KAAK;YAEd,IAAIC,wBAAwBT,KAAKU,QAAQN;YAEzC,MAAML,GAAGY,UAAUF;YAEnB,IAAIG,uBAAuB,MAAMd,iBAAiBW;YAElD,IAAI,CAACG,sBAAsB;gBACzB,MAAM,IAAIC,MAAM,CAAC,WAAW,EAAEJ,sBAAsB,eAAe,CAAC;YACtE;YAEA,uBAAuB;YACvB,IAAIK,YAAY,MAAMZ,UAAUa,OAAO;gBACrCT;gBACAN,MAAMS;gBACNJ;YACF;YAEA,MAAMS,UAAUE,OAAO;gBAACV;YAAI;QAC9B,CAAA,IACGW,KAAK;YACJV,SAASW;QACX,GACCC,MAAM,CAACC;YACNb,SAASa,MAAMA;QACjB;IACJ;AACF"}
1
+ {"version":3,"sources":["../../../src/commands/create-workspace/runCreateWorkspace.ts"],"sourcesContent":["import {type CommandArguments} from '@jakubmazanec/cli';\nimport Observable from 'zen-observable';\n\nimport {type createWorkspaceCommand} from './createWorkspaceCommand.js';\nimport {Workspace} from '../../workspace.js';\n\nexport type CreateWorkspaceOptions = {\n workspacePath: string;\n templateId: string;\n args: CommandArguments<typeof createWorkspaceCommand>;\n};\n\nexport type CreateWorkspaceStatus = string;\n\nexport function runCreateWorkspace({workspacePath, templateId, args}: CreateWorkspaceOptions) {\n return new Observable<CreateWorkspaceStatus>((observer) => {\n (async () => {\n observer.next('Creating files');\n\n let workspace = await Workspace.create({\n args,\n path: workspacePath,\n templateId,\n });\n\n observer.next('Updating the new workspace');\n\n await workspace.update({args});\n })()\n .then(() => {\n observer.complete();\n })\n .catch((error) => {\n observer.error(error);\n });\n });\n}\n"],"names":["Observable","Workspace","runCreateWorkspace","workspacePath","templateId","args","observer","next","workspace","create","path","update","then","complete","catch","error"],"mappings":"AACA,OAAOA,gBAAgB,iBAAiB;AAGxC,SAAQC,SAAS,QAAO,qBAAqB;AAU7C,OAAO,SAASC,mBAAmB,EAACC,aAAa,EAAEC,UAAU,EAAEC,IAAI,EAAyB;IAC1F,OAAO,IAAIL,WAAkC,CAACM;QAC3C,CAAA;YACCA,SAASC,IAAI,CAAC;YAEd,IAAIC,YAAY,MAAMP,UAAUQ,MAAM,CAAC;gBACrCJ;gBACAK,MAAMP;gBACNC;YACF;YAEAE,SAASC,IAAI,CAAC;YAEd,MAAMC,UAAUG,MAAM,CAAC;gBAACN;YAAI;QAC9B,CAAA,IACGO,IAAI,CAAC;YACJN,SAASO,QAAQ;QACnB,GACCC,KAAK,CAAC,CAACC;YACNT,SAASS,KAAK,CAACA;QACjB;IACJ;AACF"}
@@ -0,0 +1 @@
1
+ export type CommandStatus = 'finished' | 'in-progress' | 'not-started';
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=CommandStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/commands/internals/CommandStatus.ts"],"sourcesContent":["export type CommandStatus = 'finished' | 'in-progress' | 'not-started';\n"],"names":[],"mappings":"AAAA,WAAuE"}