@contember/cli 2.1.0-alpha.9 → 2.1.0-beta.1

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 (479) hide show
  1. package/CLAUDE.md +39 -0
  2. package/dist/development/run.cjs.map +1 -1
  3. package/dist/development/run.js.map +1 -1
  4. package/dist/development/src/commands/actions/ActionsGetEventCommand.cjs +31 -0
  5. package/dist/development/src/commands/actions/ActionsGetEventCommand.cjs.map +1 -0
  6. package/dist/development/src/commands/actions/ActionsGetEventCommand.js +31 -0
  7. package/dist/development/src/commands/actions/ActionsGetEventCommand.js.map +1 -0
  8. package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.cjs +60 -0
  9. package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.cjs.map +1 -0
  10. package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.js +60 -0
  11. package/dist/development/src/commands/actions/ActionsListFailedEventsCommand.js.map +1 -0
  12. package/dist/development/src/commands/actions/ActionsListVariablesCommand.cjs +29 -0
  13. package/dist/development/src/commands/actions/ActionsListVariablesCommand.cjs.map +1 -0
  14. package/dist/development/src/commands/actions/ActionsListVariablesCommand.js +29 -0
  15. package/dist/development/src/commands/actions/ActionsListVariablesCommand.js.map +1 -0
  16. package/dist/development/src/commands/actions/ActionsRetryEventCommand.cjs +32 -0
  17. package/dist/development/src/commands/actions/ActionsRetryEventCommand.cjs.map +1 -0
  18. package/dist/development/src/commands/actions/ActionsRetryEventCommand.js +32 -0
  19. package/dist/development/src/commands/actions/ActionsRetryEventCommand.js.map +1 -0
  20. package/dist/development/src/commands/actions/ActionsSetVariablesCommand.cjs +43 -0
  21. package/dist/development/src/commands/actions/ActionsSetVariablesCommand.cjs.map +1 -0
  22. package/dist/development/src/commands/actions/ActionsSetVariablesCommand.js +43 -0
  23. package/dist/development/src/commands/actions/ActionsSetVariablesCommand.js.map +1 -0
  24. package/dist/development/src/commands/actions/ActionsStopEventCommand.cjs +32 -0
  25. package/dist/development/src/commands/actions/ActionsStopEventCommand.cjs.map +1 -0
  26. package/dist/development/src/commands/actions/ActionsStopEventCommand.js +32 -0
  27. package/dist/development/src/commands/actions/ActionsStopEventCommand.js.map +1 -0
  28. package/dist/development/src/commands/deploy/DeployCommand.cjs.map +1 -1
  29. package/dist/development/src/commands/deploy/DeployCommand.js.map +1 -1
  30. package/dist/development/src/commands/migrations/MigrationAmendCommand.cjs.map +1 -1
  31. package/dist/development/src/commands/migrations/MigrationAmendCommand.js.map +1 -1
  32. package/dist/development/src/commands/migrations/MigrationBlankCommand.cjs.map +1 -1
  33. package/dist/development/src/commands/migrations/MigrationBlankCommand.js.map +1 -1
  34. package/dist/development/src/commands/migrations/MigrationDescribeCommand.cjs.map +1 -1
  35. package/dist/development/src/commands/migrations/MigrationDescribeCommand.js.map +1 -1
  36. package/dist/development/src/commands/migrations/MigrationDiffCommand.cjs.map +1 -1
  37. package/dist/development/src/commands/migrations/MigrationDiffCommand.js.map +1 -1
  38. package/dist/development/src/commands/migrations/MigrationExecuteCommand.cjs.map +1 -1
  39. package/dist/development/src/commands/migrations/MigrationExecuteCommand.js.map +1 -1
  40. package/dist/development/src/commands/migrations/MigrationRebaseCommand.cjs.map +1 -1
  41. package/dist/development/src/commands/migrations/MigrationRebaseCommand.js.map +1 -1
  42. package/dist/development/src/commands/migrations/MigrationStatusCommand.cjs +1 -1
  43. package/dist/development/src/commands/migrations/MigrationStatusCommand.cjs.map +1 -1
  44. package/dist/development/src/commands/migrations/MigrationStatusCommand.js +1 -1
  45. package/dist/development/src/commands/migrations/MigrationStatusCommand.js.map +1 -1
  46. package/dist/development/src/commands/misc/VersionCommand.cjs.map +1 -1
  47. package/dist/development/src/commands/misc/VersionCommand.js.map +1 -1
  48. package/dist/development/src/commands/project/ProjectGenerateDocumentationCommand.cjs.map +1 -1
  49. package/dist/development/src/commands/project/ProjectGenerateDocumentationCommand.js.map +1 -1
  50. package/dist/development/src/commands/project/ProjectPrintSchemaCommand.cjs.map +1 -1
  51. package/dist/development/src/commands/project/ProjectPrintSchemaCommand.js.map +1 -1
  52. package/dist/development/src/commands/project/ProjectValidateCommand.cjs.map +1 -1
  53. package/dist/development/src/commands/project/ProjectValidateCommand.js.map +1 -1
  54. package/dist/development/src/commands/transfer/ExportCommand.cjs +7 -2
  55. package/dist/development/src/commands/transfer/ExportCommand.cjs.map +1 -1
  56. package/dist/development/src/commands/transfer/ExportCommand.js +8 -3
  57. package/dist/development/src/commands/transfer/ExportCommand.js.map +1 -1
  58. package/dist/development/src/commands/transfer/ImportCommand.cjs +7 -4
  59. package/dist/development/src/commands/transfer/ImportCommand.cjs.map +1 -1
  60. package/dist/development/src/commands/transfer/ImportCommand.js +5 -2
  61. package/dist/development/src/commands/transfer/ImportCommand.js.map +1 -1
  62. package/dist/development/src/commands/transfer/TransferCommand.cjs +4 -5
  63. package/dist/development/src/commands/transfer/TransferCommand.cjs.map +1 -1
  64. package/dist/development/src/commands/transfer/TransferCommand.js +4 -5
  65. package/dist/development/src/commands/transfer/TransferCommand.js.map +1 -1
  66. package/dist/development/src/commands/transfer/utils.cjs.map +1 -1
  67. package/dist/development/src/commands/transfer/utils.js.map +1 -1
  68. package/dist/development/src/commands/workspace/WorkspaceUpdateApiCommand.cjs +16 -14
  69. package/dist/development/src/commands/workspace/WorkspaceUpdateApiCommand.cjs.map +1 -1
  70. package/dist/development/src/commands/workspace/WorkspaceUpdateApiCommand.js +16 -14
  71. package/dist/development/src/commands/workspace/WorkspaceUpdateApiCommand.js.map +1 -1
  72. package/dist/development/src/consts.cjs.map +1 -1
  73. package/dist/development/src/dic.cjs +100 -4
  74. package/dist/development/src/dic.cjs.map +1 -1
  75. package/dist/development/src/dic.js +101 -5
  76. package/dist/development/src/dic.js.map +1 -1
  77. package/dist/development/src/lib/SystemClientProvider.cjs.map +1 -1
  78. package/dist/development/src/lib/SystemClientProvider.js.map +1 -1
  79. package/dist/development/src/lib/TenantClientProvider.cjs.map +1 -1
  80. package/dist/development/src/lib/TenantClientProvider.js.map +1 -1
  81. package/dist/development/src/lib/VersionChecker.cjs +7 -9
  82. package/dist/development/src/lib/VersionChecker.cjs.map +1 -1
  83. package/dist/development/src/lib/VersionChecker.js +7 -9
  84. package/dist/development/src/lib/VersionChecker.js.map +1 -1
  85. package/dist/development/src/lib/actions/ActionsClient.cjs +91 -0
  86. package/dist/development/src/lib/actions/ActionsClient.cjs.map +1 -0
  87. package/dist/development/src/lib/actions/ActionsClient.js +91 -0
  88. package/dist/development/src/lib/actions/ActionsClient.js.map +1 -0
  89. package/dist/development/src/lib/admin/AdminClient.cjs.map +1 -1
  90. package/dist/development/src/lib/admin/AdminClient.js.map +1 -1
  91. package/dist/development/src/lib/admin/AdminDeployer.cjs.map +1 -1
  92. package/dist/development/src/lib/admin/AdminDeployer.js.map +1 -1
  93. package/dist/development/src/lib/assertNever.cjs.map +1 -1
  94. package/dist/development/src/lib/assertNever.js.map +1 -1
  95. package/dist/development/src/lib/dsn.cjs.map +1 -1
  96. package/dist/development/src/lib/dsn.js.map +1 -1
  97. package/dist/development/src/lib/env.cjs.map +1 -1
  98. package/dist/development/src/lib/env.js.map +1 -1
  99. package/dist/development/src/lib/fs/DockerComposeManager.cjs.map +1 -1
  100. package/dist/development/src/lib/fs/DockerComposeManager.js.map +1 -1
  101. package/dist/development/src/lib/fs/FileSystem.cjs.map +1 -1
  102. package/dist/development/src/lib/fs/FileSystem.js.map +1 -1
  103. package/dist/development/src/lib/fs/YamlHandler.cjs.map +1 -1
  104. package/dist/development/src/lib/fs/YamlHandler.js.map +1 -1
  105. package/dist/development/src/lib/js/EsBuildBuilder.cjs.map +1 -1
  106. package/dist/development/src/lib/js/EsBuildBuilder.js.map +1 -1
  107. package/dist/development/src/lib/js/EvalExecutor.cjs.map +1 -1
  108. package/dist/development/src/lib/js/EvalExecutor.js.map +1 -1
  109. package/dist/development/src/lib/js/JsCodeRunner.cjs.map +1 -1
  110. package/dist/development/src/lib/js/JsCodeRunner.js.map +1 -1
  111. package/dist/development/src/lib/migrations/MigrationExecutionFacade.cjs.map +1 -1
  112. package/dist/development/src/lib/migrations/MigrationExecutionFacade.js.map +1 -1
  113. package/dist/development/src/lib/migrations/MigrationPrinter.cjs +7 -2
  114. package/dist/development/src/lib/migrations/MigrationPrinter.cjs.map +1 -1
  115. package/dist/development/src/lib/migrations/MigrationPrinter.js +7 -2
  116. package/dist/development/src/lib/migrations/MigrationPrinter.js.map +1 -1
  117. package/dist/development/src/lib/migrations/MigrationRebaseFacade.cjs.map +1 -1
  118. package/dist/development/src/lib/migrations/MigrationRebaseFacade.js.map +1 -1
  119. package/dist/development/src/lib/migrations/MigrationsStatusFacade.cjs +3 -3
  120. package/dist/development/src/lib/migrations/MigrationsStatusFacade.cjs.map +1 -1
  121. package/dist/development/src/lib/migrations/MigrationsStatusFacade.js +3 -3
  122. package/dist/development/src/lib/migrations/MigrationsStatusFacade.js.map +1 -1
  123. package/dist/development/src/lib/migrations/MigrationsValidator.cjs.map +1 -1
  124. package/dist/development/src/lib/migrations/MigrationsValidator.js.map +1 -1
  125. package/dist/development/src/lib/project/RemoteProject.cjs.map +1 -1
  126. package/dist/development/src/lib/project/RemoteProject.js.map +1 -1
  127. package/dist/development/src/lib/project/RemoteProjectProvider.cjs.map +1 -1
  128. package/dist/development/src/lib/project/RemoteProjectProvider.js.map +1 -1
  129. package/dist/development/src/lib/project/RemoteProjectResolver.cjs.map +1 -1
  130. package/dist/development/src/lib/project/RemoteProjectResolver.js.map +1 -1
  131. package/dist/development/src/lib/project/docs/components/EntityInfo.cjs +135 -177
  132. package/dist/development/src/lib/project/docs/components/EntityInfo.cjs.map +1 -1
  133. package/dist/development/src/lib/project/docs/components/EntityInfo.js +136 -178
  134. package/dist/development/src/lib/project/docs/components/EntityInfo.js.map +1 -1
  135. package/dist/development/src/lib/project/docs/components/EntityLink.cjs.map +1 -1
  136. package/dist/development/src/lib/project/docs/components/EntityLink.js.map +1 -1
  137. package/dist/development/src/lib/project/docs/components/FieldLink.cjs +5 -5
  138. package/dist/development/src/lib/project/docs/components/FieldLink.cjs.map +1 -1
  139. package/dist/development/src/lib/project/docs/components/FieldLink.js +5 -5
  140. package/dist/development/src/lib/project/docs/components/FieldLink.js.map +1 -1
  141. package/dist/development/src/lib/project/docs/components/FieldPermissions.cjs +8 -8
  142. package/dist/development/src/lib/project/docs/components/FieldPermissions.cjs.map +1 -1
  143. package/dist/development/src/lib/project/docs/components/FieldPermissions.js +8 -8
  144. package/dist/development/src/lib/project/docs/components/FieldPermissions.js.map +1 -1
  145. package/dist/development/src/lib/project/docs/components/FieldType.cjs +34 -36
  146. package/dist/development/src/lib/project/docs/components/FieldType.cjs.map +1 -1
  147. package/dist/development/src/lib/project/docs/components/FieldType.js +34 -36
  148. package/dist/development/src/lib/project/docs/components/FieldType.js.map +1 -1
  149. package/dist/development/src/lib/project/docs/components/OnDelete.cjs +22 -26
  150. package/dist/development/src/lib/project/docs/components/OnDelete.cjs.map +1 -1
  151. package/dist/development/src/lib/project/docs/components/OnDelete.js +22 -26
  152. package/dist/development/src/lib/project/docs/components/OnDelete.js.map +1 -1
  153. package/dist/development/src/lib/project/docs/components/ProjectInfo.cjs +16 -16
  154. package/dist/development/src/lib/project/docs/components/ProjectInfo.cjs.map +1 -1
  155. package/dist/development/src/lib/project/docs/components/ProjectInfo.js +16 -16
  156. package/dist/development/src/lib/project/docs/components/ProjectInfo.js.map +1 -1
  157. package/dist/development/src/lib/project/docs/components/SinglePermission.cjs.map +1 -1
  158. package/dist/development/src/lib/project/docs/components/SinglePermission.js.map +1 -1
  159. package/dist/development/src/lib/project/docs/components/utils.cjs.map +1 -1
  160. package/dist/development/src/lib/project/docs/components/utils.js.map +1 -1
  161. package/dist/development/src/lib/project/docs/projectDescribe.cjs.map +1 -1
  162. package/dist/development/src/lib/project/docs/projectDescribe.js.map +1 -1
  163. package/dist/development/src/lib/schema/SchemaLoader.cjs.map +1 -1
  164. package/dist/development/src/lib/schema/SchemaLoader.js.map +1 -1
  165. package/dist/development/src/lib/schema/SchemaValidationHelper.cjs.map +1 -1
  166. package/dist/development/src/lib/schema/SchemaValidationPrinter.cjs.map +1 -1
  167. package/dist/development/src/lib/schema/SchemaValidationPrinter.js.map +1 -1
  168. package/dist/development/src/lib/schema/collectReferences.cjs.map +1 -1
  169. package/dist/development/src/lib/schema/collectReferences.js.map +1 -1
  170. package/dist/development/src/lib/stream.cjs +0 -7
  171. package/dist/development/src/lib/stream.cjs.map +1 -1
  172. package/dist/development/src/lib/stream.js +1 -8
  173. package/dist/development/src/lib/stream.js.map +1 -1
  174. package/dist/development/src/lib/tenant/TenantClient.cjs.map +1 -1
  175. package/dist/development/src/lib/tenant/TenantClient.js.map +1 -1
  176. package/dist/development/src/lib/transfer/DataTransferClient.cjs +53 -61
  177. package/dist/development/src/lib/transfer/DataTransferClient.cjs.map +1 -1
  178. package/dist/development/src/lib/transfer/DataTransferClient.js +55 -63
  179. package/dist/development/src/lib/transfer/DataTransferClient.js.map +1 -1
  180. package/dist/development/src/lib/transfer/stdio.cjs.map +1 -1
  181. package/dist/development/src/lib/transfer/stdio.js.map +1 -1
  182. package/dist/development/src/lib/workspace/WorkspaceResolver.cjs +4 -4
  183. package/dist/development/src/lib/workspace/WorkspaceResolver.cjs.map +1 -1
  184. package/dist/development/src/lib/workspace/WorkspaceResolver.js +5 -5
  185. package/dist/development/src/lib/workspace/WorkspaceResolver.js.map +1 -1
  186. package/dist/production/run.cjs.map +1 -1
  187. package/dist/production/run.js.map +1 -1
  188. package/dist/production/src/commands/actions/ActionsGetEventCommand.cjs +31 -0
  189. package/dist/production/src/commands/actions/ActionsGetEventCommand.cjs.map +1 -0
  190. package/dist/production/src/commands/actions/ActionsGetEventCommand.js +31 -0
  191. package/dist/production/src/commands/actions/ActionsGetEventCommand.js.map +1 -0
  192. package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.cjs +60 -0
  193. package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.cjs.map +1 -0
  194. package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.js +60 -0
  195. package/dist/production/src/commands/actions/ActionsListFailedEventsCommand.js.map +1 -0
  196. package/dist/production/src/commands/actions/ActionsListVariablesCommand.cjs +29 -0
  197. package/dist/production/src/commands/actions/ActionsListVariablesCommand.cjs.map +1 -0
  198. package/dist/production/src/commands/actions/ActionsListVariablesCommand.js +29 -0
  199. package/dist/production/src/commands/actions/ActionsListVariablesCommand.js.map +1 -0
  200. package/dist/production/src/commands/actions/ActionsRetryEventCommand.cjs +32 -0
  201. package/dist/production/src/commands/actions/ActionsRetryEventCommand.cjs.map +1 -0
  202. package/dist/production/src/commands/actions/ActionsRetryEventCommand.js +32 -0
  203. package/dist/production/src/commands/actions/ActionsRetryEventCommand.js.map +1 -0
  204. package/dist/production/src/commands/actions/ActionsSetVariablesCommand.cjs +43 -0
  205. package/dist/production/src/commands/actions/ActionsSetVariablesCommand.cjs.map +1 -0
  206. package/dist/production/src/commands/actions/ActionsSetVariablesCommand.js +43 -0
  207. package/dist/production/src/commands/actions/ActionsSetVariablesCommand.js.map +1 -0
  208. package/dist/production/src/commands/actions/ActionsStopEventCommand.cjs +32 -0
  209. package/dist/production/src/commands/actions/ActionsStopEventCommand.cjs.map +1 -0
  210. package/dist/production/src/commands/actions/ActionsStopEventCommand.js +32 -0
  211. package/dist/production/src/commands/actions/ActionsStopEventCommand.js.map +1 -0
  212. package/dist/production/src/commands/deploy/DeployCommand.cjs.map +1 -1
  213. package/dist/production/src/commands/deploy/DeployCommand.js.map +1 -1
  214. package/dist/production/src/commands/migrations/MigrationAmendCommand.cjs.map +1 -1
  215. package/dist/production/src/commands/migrations/MigrationAmendCommand.js.map +1 -1
  216. package/dist/production/src/commands/migrations/MigrationBlankCommand.cjs.map +1 -1
  217. package/dist/production/src/commands/migrations/MigrationBlankCommand.js.map +1 -1
  218. package/dist/production/src/commands/migrations/MigrationDescribeCommand.cjs.map +1 -1
  219. package/dist/production/src/commands/migrations/MigrationDescribeCommand.js.map +1 -1
  220. package/dist/production/src/commands/migrations/MigrationDiffCommand.cjs.map +1 -1
  221. package/dist/production/src/commands/migrations/MigrationDiffCommand.js.map +1 -1
  222. package/dist/production/src/commands/migrations/MigrationExecuteCommand.cjs.map +1 -1
  223. package/dist/production/src/commands/migrations/MigrationExecuteCommand.js.map +1 -1
  224. package/dist/production/src/commands/migrations/MigrationRebaseCommand.cjs.map +1 -1
  225. package/dist/production/src/commands/migrations/MigrationRebaseCommand.js.map +1 -1
  226. package/dist/production/src/commands/migrations/MigrationStatusCommand.cjs +1 -1
  227. package/dist/production/src/commands/migrations/MigrationStatusCommand.cjs.map +1 -1
  228. package/dist/production/src/commands/migrations/MigrationStatusCommand.js +1 -1
  229. package/dist/production/src/commands/migrations/MigrationStatusCommand.js.map +1 -1
  230. package/dist/production/src/commands/misc/VersionCommand.cjs.map +1 -1
  231. package/dist/production/src/commands/misc/VersionCommand.js.map +1 -1
  232. package/dist/production/src/commands/project/ProjectGenerateDocumentationCommand.cjs.map +1 -1
  233. package/dist/production/src/commands/project/ProjectGenerateDocumentationCommand.js.map +1 -1
  234. package/dist/production/src/commands/project/ProjectPrintSchemaCommand.cjs.map +1 -1
  235. package/dist/production/src/commands/project/ProjectPrintSchemaCommand.js.map +1 -1
  236. package/dist/production/src/commands/project/ProjectValidateCommand.cjs.map +1 -1
  237. package/dist/production/src/commands/project/ProjectValidateCommand.js.map +1 -1
  238. package/dist/production/src/commands/transfer/ExportCommand.cjs +7 -2
  239. package/dist/production/src/commands/transfer/ExportCommand.cjs.map +1 -1
  240. package/dist/production/src/commands/transfer/ExportCommand.js +8 -3
  241. package/dist/production/src/commands/transfer/ExportCommand.js.map +1 -1
  242. package/dist/production/src/commands/transfer/ImportCommand.cjs +7 -4
  243. package/dist/production/src/commands/transfer/ImportCommand.cjs.map +1 -1
  244. package/dist/production/src/commands/transfer/ImportCommand.js +5 -2
  245. package/dist/production/src/commands/transfer/ImportCommand.js.map +1 -1
  246. package/dist/production/src/commands/transfer/TransferCommand.cjs +4 -5
  247. package/dist/production/src/commands/transfer/TransferCommand.cjs.map +1 -1
  248. package/dist/production/src/commands/transfer/TransferCommand.js +4 -5
  249. package/dist/production/src/commands/transfer/TransferCommand.js.map +1 -1
  250. package/dist/production/src/commands/transfer/utils.cjs.map +1 -1
  251. package/dist/production/src/commands/transfer/utils.js.map +1 -1
  252. package/dist/production/src/commands/workspace/WorkspaceUpdateApiCommand.cjs +16 -14
  253. package/dist/production/src/commands/workspace/WorkspaceUpdateApiCommand.cjs.map +1 -1
  254. package/dist/production/src/commands/workspace/WorkspaceUpdateApiCommand.js +16 -14
  255. package/dist/production/src/commands/workspace/WorkspaceUpdateApiCommand.js.map +1 -1
  256. package/dist/production/src/consts.cjs.map +1 -1
  257. package/dist/production/src/dic.cjs +100 -4
  258. package/dist/production/src/dic.cjs.map +1 -1
  259. package/dist/production/src/dic.js +101 -5
  260. package/dist/production/src/dic.js.map +1 -1
  261. package/dist/production/src/lib/SystemClientProvider.cjs.map +1 -1
  262. package/dist/production/src/lib/SystemClientProvider.js.map +1 -1
  263. package/dist/production/src/lib/TenantClientProvider.cjs.map +1 -1
  264. package/dist/production/src/lib/TenantClientProvider.js.map +1 -1
  265. package/dist/production/src/lib/VersionChecker.cjs +7 -9
  266. package/dist/production/src/lib/VersionChecker.cjs.map +1 -1
  267. package/dist/production/src/lib/VersionChecker.js +7 -9
  268. package/dist/production/src/lib/VersionChecker.js.map +1 -1
  269. package/dist/production/src/lib/actions/ActionsClient.cjs +91 -0
  270. package/dist/production/src/lib/actions/ActionsClient.cjs.map +1 -0
  271. package/dist/production/src/lib/actions/ActionsClient.js +91 -0
  272. package/dist/production/src/lib/actions/ActionsClient.js.map +1 -0
  273. package/dist/production/src/lib/admin/AdminClient.cjs.map +1 -1
  274. package/dist/production/src/lib/admin/AdminClient.js.map +1 -1
  275. package/dist/production/src/lib/admin/AdminDeployer.cjs.map +1 -1
  276. package/dist/production/src/lib/admin/AdminDeployer.js.map +1 -1
  277. package/dist/production/src/lib/assertNever.cjs.map +1 -1
  278. package/dist/production/src/lib/assertNever.js.map +1 -1
  279. package/dist/production/src/lib/dsn.cjs.map +1 -1
  280. package/dist/production/src/lib/dsn.js.map +1 -1
  281. package/dist/production/src/lib/env.cjs.map +1 -1
  282. package/dist/production/src/lib/env.js.map +1 -1
  283. package/dist/production/src/lib/fs/DockerComposeManager.cjs.map +1 -1
  284. package/dist/production/src/lib/fs/DockerComposeManager.js.map +1 -1
  285. package/dist/production/src/lib/fs/FileSystem.cjs.map +1 -1
  286. package/dist/production/src/lib/fs/FileSystem.js.map +1 -1
  287. package/dist/production/src/lib/fs/YamlHandler.cjs.map +1 -1
  288. package/dist/production/src/lib/fs/YamlHandler.js.map +1 -1
  289. package/dist/production/src/lib/js/EsBuildBuilder.cjs.map +1 -1
  290. package/dist/production/src/lib/js/EsBuildBuilder.js.map +1 -1
  291. package/dist/production/src/lib/js/EvalExecutor.cjs.map +1 -1
  292. package/dist/production/src/lib/js/EvalExecutor.js.map +1 -1
  293. package/dist/production/src/lib/js/JsCodeRunner.cjs.map +1 -1
  294. package/dist/production/src/lib/js/JsCodeRunner.js.map +1 -1
  295. package/dist/production/src/lib/migrations/MigrationExecutionFacade.cjs.map +1 -1
  296. package/dist/production/src/lib/migrations/MigrationExecutionFacade.js.map +1 -1
  297. package/dist/production/src/lib/migrations/MigrationPrinter.cjs +7 -2
  298. package/dist/production/src/lib/migrations/MigrationPrinter.cjs.map +1 -1
  299. package/dist/production/src/lib/migrations/MigrationPrinter.js +7 -2
  300. package/dist/production/src/lib/migrations/MigrationPrinter.js.map +1 -1
  301. package/dist/production/src/lib/migrations/MigrationRebaseFacade.cjs.map +1 -1
  302. package/dist/production/src/lib/migrations/MigrationRebaseFacade.js.map +1 -1
  303. package/dist/production/src/lib/migrations/MigrationsStatusFacade.cjs +3 -3
  304. package/dist/production/src/lib/migrations/MigrationsStatusFacade.cjs.map +1 -1
  305. package/dist/production/src/lib/migrations/MigrationsStatusFacade.js +3 -3
  306. package/dist/production/src/lib/migrations/MigrationsStatusFacade.js.map +1 -1
  307. package/dist/production/src/lib/migrations/MigrationsValidator.cjs.map +1 -1
  308. package/dist/production/src/lib/migrations/MigrationsValidator.js.map +1 -1
  309. package/dist/production/src/lib/project/RemoteProject.cjs.map +1 -1
  310. package/dist/production/src/lib/project/RemoteProject.js.map +1 -1
  311. package/dist/production/src/lib/project/RemoteProjectProvider.cjs.map +1 -1
  312. package/dist/production/src/lib/project/RemoteProjectProvider.js.map +1 -1
  313. package/dist/production/src/lib/project/RemoteProjectResolver.cjs.map +1 -1
  314. package/dist/production/src/lib/project/RemoteProjectResolver.js.map +1 -1
  315. package/dist/production/src/lib/project/docs/components/EntityInfo.cjs +39 -66
  316. package/dist/production/src/lib/project/docs/components/EntityInfo.cjs.map +1 -1
  317. package/dist/production/src/lib/project/docs/components/EntityInfo.js +40 -67
  318. package/dist/production/src/lib/project/docs/components/EntityInfo.js.map +1 -1
  319. package/dist/production/src/lib/project/docs/components/EntityLink.cjs.map +1 -1
  320. package/dist/production/src/lib/project/docs/components/EntityLink.js.map +1 -1
  321. package/dist/production/src/lib/project/docs/components/FieldLink.cjs.map +1 -1
  322. package/dist/production/src/lib/project/docs/components/FieldLink.js.map +1 -1
  323. package/dist/production/src/lib/project/docs/components/FieldPermissions.cjs.map +1 -1
  324. package/dist/production/src/lib/project/docs/components/FieldPermissions.js.map +1 -1
  325. package/dist/production/src/lib/project/docs/components/FieldType.cjs +3 -5
  326. package/dist/production/src/lib/project/docs/components/FieldType.cjs.map +1 -1
  327. package/dist/production/src/lib/project/docs/components/FieldType.js +3 -5
  328. package/dist/production/src/lib/project/docs/components/FieldType.js.map +1 -1
  329. package/dist/production/src/lib/project/docs/components/OnDelete.cjs +4 -8
  330. package/dist/production/src/lib/project/docs/components/OnDelete.cjs.map +1 -1
  331. package/dist/production/src/lib/project/docs/components/OnDelete.js +4 -8
  332. package/dist/production/src/lib/project/docs/components/OnDelete.js.map +1 -1
  333. package/dist/production/src/lib/project/docs/components/ProjectInfo.cjs.map +1 -1
  334. package/dist/production/src/lib/project/docs/components/ProjectInfo.js.map +1 -1
  335. package/dist/production/src/lib/project/docs/components/SinglePermission.cjs.map +1 -1
  336. package/dist/production/src/lib/project/docs/components/SinglePermission.js.map +1 -1
  337. package/dist/production/src/lib/project/docs/components/utils.cjs.map +1 -1
  338. package/dist/production/src/lib/project/docs/components/utils.js.map +1 -1
  339. package/dist/production/src/lib/project/docs/projectDescribe.cjs.map +1 -1
  340. package/dist/production/src/lib/project/docs/projectDescribe.js.map +1 -1
  341. package/dist/production/src/lib/schema/SchemaLoader.cjs.map +1 -1
  342. package/dist/production/src/lib/schema/SchemaLoader.js.map +1 -1
  343. package/dist/production/src/lib/schema/SchemaValidationHelper.cjs.map +1 -1
  344. package/dist/production/src/lib/schema/SchemaValidationPrinter.cjs.map +1 -1
  345. package/dist/production/src/lib/schema/SchemaValidationPrinter.js.map +1 -1
  346. package/dist/production/src/lib/schema/collectReferences.cjs.map +1 -1
  347. package/dist/production/src/lib/schema/collectReferences.js.map +1 -1
  348. package/dist/production/src/lib/stream.cjs +0 -7
  349. package/dist/production/src/lib/stream.cjs.map +1 -1
  350. package/dist/production/src/lib/stream.js +1 -8
  351. package/dist/production/src/lib/stream.js.map +1 -1
  352. package/dist/production/src/lib/tenant/TenantClient.cjs.map +1 -1
  353. package/dist/production/src/lib/tenant/TenantClient.js.map +1 -1
  354. package/dist/production/src/lib/transfer/DataTransferClient.cjs +53 -61
  355. package/dist/production/src/lib/transfer/DataTransferClient.cjs.map +1 -1
  356. package/dist/production/src/lib/transfer/DataTransferClient.js +55 -63
  357. package/dist/production/src/lib/transfer/DataTransferClient.js.map +1 -1
  358. package/dist/production/src/lib/transfer/stdio.cjs.map +1 -1
  359. package/dist/production/src/lib/transfer/stdio.js.map +1 -1
  360. package/dist/production/src/lib/workspace/WorkspaceResolver.cjs +4 -4
  361. package/dist/production/src/lib/workspace/WorkspaceResolver.cjs.map +1 -1
  362. package/dist/production/src/lib/workspace/WorkspaceResolver.js +5 -5
  363. package/dist/production/src/lib/workspace/WorkspaceResolver.js.map +1 -1
  364. package/dist/types/commands/actions/ActionsGetEventCommand.d.ts +16 -0
  365. package/dist/types/commands/actions/ActionsGetEventCommand.d.ts.map +1 -0
  366. package/dist/types/commands/actions/ActionsListFailedEventsCommand.d.ts +15 -0
  367. package/dist/types/commands/actions/ActionsListFailedEventsCommand.d.ts.map +1 -0
  368. package/dist/types/commands/actions/ActionsListVariablesCommand.d.ts +14 -0
  369. package/dist/types/commands/actions/ActionsListVariablesCommand.d.ts.map +1 -0
  370. package/dist/types/commands/actions/ActionsRetryEventCommand.d.ts +16 -0
  371. package/dist/types/commands/actions/ActionsRetryEventCommand.d.ts.map +1 -0
  372. package/dist/types/commands/actions/ActionsSetVariablesCommand.d.ts +19 -0
  373. package/dist/types/commands/actions/ActionsSetVariablesCommand.d.ts.map +1 -0
  374. package/dist/types/commands/actions/ActionsStopEventCommand.d.ts +16 -0
  375. package/dist/types/commands/actions/ActionsStopEventCommand.d.ts.map +1 -0
  376. package/dist/types/commands/deploy/DeployCommand.d.ts.map +1 -1
  377. package/dist/types/commands/migrations/MigrationAmendCommand.d.ts.map +1 -1
  378. package/dist/types/commands/migrations/MigrationBlankCommand.d.ts.map +1 -1
  379. package/dist/types/commands/migrations/MigrationDescribeCommand.d.ts.map +1 -1
  380. package/dist/types/commands/migrations/MigrationDiffCommand.d.ts.map +1 -1
  381. package/dist/types/commands/migrations/MigrationExecuteCommand.d.ts.map +1 -1
  382. package/dist/types/commands/migrations/MigrationRebaseCommand.d.ts.map +1 -1
  383. package/dist/types/commands/migrations/MigrationStatusCommand.d.ts.map +1 -1
  384. package/dist/types/commands/project/ProjectGenerateDocumentationCommand.d.ts.map +1 -1
  385. package/dist/types/commands/project/ProjectPrintSchemaCommand.d.ts.map +1 -1
  386. package/dist/types/commands/transfer/ExportCommand.d.ts.map +1 -1
  387. package/dist/types/commands/transfer/ImportCommand.d.ts.map +1 -1
  388. package/dist/types/commands/transfer/TransferCommand.d.ts.map +1 -1
  389. package/dist/types/commands/transfer/utils.d.ts.map +1 -1
  390. package/dist/types/commands/workspace/WorkspaceUpdateApiCommand.d.ts.map +1 -1
  391. package/dist/types/dic.d.ts +18 -0
  392. package/dist/types/dic.d.ts.map +1 -1
  393. package/dist/types/lib/VersionChecker.d.ts.map +1 -1
  394. package/dist/types/lib/actions/ActionsClient.d.ts +33 -0
  395. package/dist/types/lib/actions/ActionsClient.d.ts.map +1 -0
  396. package/dist/types/lib/admin/AdminClient.d.ts.map +1 -1
  397. package/dist/types/lib/admin/AdminDeployer.d.ts.map +1 -1
  398. package/dist/types/lib/fs/DockerComposeManager.d.ts.map +1 -1
  399. package/dist/types/lib/migrations/MigrationPrinter.d.ts +1 -1
  400. package/dist/types/lib/migrations/MigrationPrinter.d.ts.map +1 -1
  401. package/dist/types/lib/migrations/MigrationsStatusFacade.d.ts +3 -1
  402. package/dist/types/lib/migrations/MigrationsStatusFacade.d.ts.map +1 -1
  403. package/dist/types/lib/project/docs/components/EntityInfo.d.ts.map +1 -1
  404. package/dist/types/lib/project/docs/components/FieldLink.d.ts.map +1 -1
  405. package/dist/types/lib/project/docs/components/FieldPermissions.d.ts.map +1 -1
  406. package/dist/types/lib/project/docs/components/FieldType.d.ts.map +1 -1
  407. package/dist/types/lib/project/docs/components/OnDelete.d.ts.map +1 -1
  408. package/dist/types/lib/project/docs/components/ProjectInfo.d.ts.map +1 -1
  409. package/dist/types/lib/project/docs/projectDescribe.d.ts.map +1 -1
  410. package/dist/types/lib/schema/SchemaValidationPrinter.d.ts.map +1 -1
  411. package/dist/types/lib/stream.d.ts.map +1 -1
  412. package/dist/types/lib/tenant/TenantClient.d.ts.map +1 -1
  413. package/dist/types/lib/transfer/DataTransferClient.d.ts +2 -4
  414. package/dist/types/lib/transfer/DataTransferClient.d.ts.map +1 -1
  415. package/dist/types/tsconfig.tsbuildinfo +1 -1
  416. package/package.json +33 -29
  417. package/src/commands/actions/ActionsGetEventCommand.ts +41 -0
  418. package/src/commands/actions/ActionsListFailedEventsCommand.ts +68 -0
  419. package/src/commands/actions/ActionsListVariablesCommand.ts +36 -0
  420. package/src/commands/actions/ActionsRetryEventCommand.ts +42 -0
  421. package/src/commands/actions/ActionsSetVariablesCommand.ts +62 -0
  422. package/src/commands/actions/ActionsStopEventCommand.ts +42 -0
  423. package/src/commands/deploy/DeployCommand.ts +0 -3
  424. package/src/commands/migrations/MigrationAmendCommand.ts +2 -2
  425. package/src/commands/migrations/MigrationBlankCommand.ts +1 -3
  426. package/src/commands/migrations/MigrationDescribeCommand.ts +0 -1
  427. package/src/commands/migrations/MigrationDiffCommand.ts +0 -2
  428. package/src/commands/migrations/MigrationExecuteCommand.ts +1 -2
  429. package/src/commands/migrations/MigrationRebaseCommand.ts +0 -2
  430. package/src/commands/migrations/MigrationStatusCommand.ts +8 -13
  431. package/src/commands/project/ProjectGenerateDocumentationCommand.ts +1 -2
  432. package/src/commands/project/ProjectPrintSchemaCommand.ts +1 -3
  433. package/src/commands/transfer/ExportCommand.ts +9 -4
  434. package/src/commands/transfer/ImportCommand.ts +7 -3
  435. package/src/commands/transfer/TransferCommand.ts +6 -6
  436. package/src/commands/transfer/utils.ts +0 -1
  437. package/src/commands/workspace/WorkspaceUpdateApiCommand.ts +16 -14
  438. package/src/dic.ts +162 -103
  439. package/src/lib/VersionChecker.ts +11 -9
  440. package/src/lib/actions/ActionsClient.ts +111 -0
  441. package/src/lib/admin/AdminClient.ts +2 -2
  442. package/src/lib/admin/AdminDeployer.ts +0 -1
  443. package/src/lib/fs/DockerComposeManager.ts +0 -3
  444. package/src/lib/migrations/MigrationPrinter.ts +7 -4
  445. package/src/lib/migrations/MigrationsStatusFacade.ts +4 -4
  446. package/src/lib/project/RemoteProjectResolver.ts +2 -2
  447. package/src/lib/project/docs/components/EntityInfo.tsx +36 -31
  448. package/src/lib/project/docs/components/FieldLink.tsx +5 -1
  449. package/src/lib/project/docs/components/FieldPermissions.tsx +8 -6
  450. package/src/lib/project/docs/components/FieldType.tsx +31 -30
  451. package/src/lib/project/docs/components/OnDelete.tsx +15 -13
  452. package/src/lib/project/docs/components/ProjectInfo.tsx +1 -4
  453. package/src/lib/project/docs/components/SinglePermission.tsx +0 -1
  454. package/src/lib/project/docs/components/utils.ts +0 -1
  455. package/src/lib/project/docs/projectDescribe.tsx +0 -2
  456. package/src/lib/project/docs/resources/style.css +2 -3
  457. package/src/lib/schema/SchemaLoader.ts +1 -1
  458. package/src/lib/schema/SchemaValidationPrinter.ts +0 -1
  459. package/src/lib/stream.ts +7 -8
  460. package/src/lib/tenant/TenantClient.ts +0 -1
  461. package/src/lib/transfer/DataTransferClient.ts +56 -74
  462. package/src/lib/transfer/stdio.ts +0 -1
  463. package/src/lib/workspace/WorkspaceResolver.ts +5 -5
  464. package/src/run.ts +2 -5
  465. package/dist/development/src/lib/migrations/migrations.cjs +0 -43
  466. package/dist/development/src/lib/migrations/migrations.cjs.map +0 -1
  467. package/dist/development/src/lib/migrations/migrations.js +0 -43
  468. package/dist/development/src/lib/migrations/migrations.js.map +0 -1
  469. package/dist/production/src/lib/migrations/migrations.cjs +0 -43
  470. package/dist/production/src/lib/migrations/migrations.cjs.map +0 -1
  471. package/dist/production/src/lib/migrations/migrations.js +0 -43
  472. package/dist/production/src/lib/migrations/migrations.js.map +0 -1
  473. package/dist/types/lib/migrations/migrations.d.ts +0 -3
  474. package/dist/types/lib/migrations/migrations.d.ts.map +0 -1
  475. package/postcss.config.js +0 -6
  476. package/src/.eslintrc.cjs +0 -5
  477. package/src/lib/migrations/migrations.ts +0 -45
  478. package/src/lib/project/docs/.eslintrc.cjs +0 -5
  479. package/tailwind.config.js +0 -7
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationAmendCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationAmendCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { InvalidSchemaException, SchemaMigrator } from '@contember/schema-migrations'\nimport prompts from 'prompts'\nimport { emptySchema } from '@contember/schema-utils'\nimport { MigrationCreator, MigrationsResolver, SchemaVersionBuilder, SystemClient } from '@contember/migrations-client'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { MigrationsValidator } from '../../lib/migrations/MigrationsValidator'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { printValidationErrors } from '../../lib/schema/SchemaValidationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {\n\tmigration?: string\n}\n\ntype Options = {\n\tyes?: true\n\tforce: boolean\n}\n\nexport class MigrationAmendCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly systemApiClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t\tprivate readonly migrationsValidator: MigrationsValidator,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Amends latest migration')\n\t\tconfiguration.argument('migration').optional()\n\t\tconfiguration.option('force').description('Ignore migrations order and missing migrations (dev only)')\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migration')\n\t\tconst amendMigration = migrationName\n\t\t\t? await this.migrationsResolver.findSchemaMigrationByVersion(migrationName)\n\t\t\t: await this.migrationsResolver.findLatestSchemaMigration()\n\t\tif (!amendMigration) {\n\t\t\tthrow 'No migration to amend'\n\t\t}\n\t\tconst force = input.getOption('force')\n\t\tconst status = await this.migrationsStatusFacade.resolveMigrationsStatus({ force })\n\t\tif (status.migrationsToExecute.length > 0) {\n\t\t\tthrow `Some migrations are not executed. Unable to amend.`\n\t\t}\n\n\n\t\tconst schema = await this.schemaLoader.loadSchema()\n\t\ttry {\n\t\t\tconst initialSchema = await this.schemaVersionBuilder.buildSchema()\n\t\t\tconst intermediateResult = await this.migrationCreator.prepareMigration(initialSchema, schema, '')\n\t\t\tif (intermediateResult === null) {\n\t\t\t\tconsole.log('Nothing to do')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tif (amendMigration.formatVersion !== intermediateResult.migration.formatVersion) {\n\t\t\t\tthrow 'Incompatible migration format version'\n\t\t\t}\n\t\t\tconst prevSchema = await this.schemaVersionBuilder.buildSchemaAdvanced(\n\t\t\t\temptySchema,\n\t\t\t\tversion => version < amendMigration.version,\n\t\t\t)\n\t\t\tconst newSchema = await this.schemaMigrator.applyModifications(\n\t\t\t\tprevSchema,\n\t\t\t\t[...amendMigration.modifications, ...intermediateResult.migration.modifications],\n\t\t\t\tamendMigration.formatVersion,\n\t\t\t)\n\t\t\tconst newMigrationResult = await this.migrationCreator.prepareMigration(prevSchema, newSchema, '')\n\t\t\tconst followingMigrations = (await this.migrationsResolver.getSchemaMigrations()).filter(\n\t\t\t\tit => it.version > amendMigration.version,\n\t\t\t)\n\n\t\t\tconst valid = await this.migrationsValidator.validate(\n\t\t\t\tprevSchema,\n\t\t\t\t[...(newMigrationResult ? [newMigrationResult.migration] : []), ...followingMigrations],\n\t\t\t)\n\t\t\tif (!valid) {\n\t\t\t\tthrow `Cannot amend migration`\n\t\t\t}\n\n\t\t\tthis.migrationPrinter.printMigrationDescription(\n\t\t\t\tintermediateResult.initialSchema,\n\t\t\t\tintermediateResult.migration,\n\t\t\t\t{ noSql: true },\n\t\t\t)\n\t\t\tconsole.log(`Amending ${amendMigration.name}`)\n\t\t\tif (!(await this.shouldContinue(input))) {\n\t\t\t\tconsole.log('Aborting')\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\tconst systemClient = this.systemApiClientProvider.get()\n\t\t\tawait systemClient.migrate([intermediateResult.migration], force)\n\t\t\tawait systemClient.migrationDelete(intermediateResult.migration.version)\n\n\t\t\tif (!newMigrationResult && await this.shouldRemove()) {\n\t\t\t\tawait this.migrationCreator.removeMigration(amendMigration.name)\n\t\t\t\tawait systemClient.migrationDelete(amendMigration.version)\n\t\t\t\tconsole.log('Latest migration was removed')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tconst newMigration = {\n\t\t\t\tname: amendMigration.name,\n\t\t\t\tversion: amendMigration.version,\n\t\t\t\tformatVersion: newMigrationResult?.migration.formatVersion ?? amendMigration.formatVersion,\n\t\t\t\tmodifications: newMigrationResult?.migration.modifications ?? [],\n\t\t\t}\n\t\t\tawait this.migrationCreator.saveMigration(newMigration)\n\t\t\tawait systemClient.migrationModify(amendMigration.version, newMigration)\n\n\t\t\treturn 0\n\t\t} catch (e) {\n\t\t\tif (e instanceof InvalidSchemaException) {\n\t\t\t\tprintValidationErrors(e.validationErrors, e.message)\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n\n\tprivate async shouldContinue(input: Input<{}, { yes?: true }>): Promise<boolean> {\n\t\tconst yes = input.getOption('yes')\n\t\tif (yes) {\n\t\t\treturn true\n\t\t}\n\t\tconst { action } = await prompts({\n\t\t\ttype: 'select',\n\t\t\tname: 'action',\n\t\t\tmessage: 'Do you want to continue?',\n\t\t\tchoices: [\n\t\t\t\t{ value: 'yes', title: 'Yes' },\n\t\t\t\t{ value: 'no', title: 'Abort' },\n\t\t\t],\n\t\t})\n\t\treturn action === 'yes'\n\t}\n\n\tprivate async shouldRemove(): Promise<boolean> {\n\t\tconst { action } = await prompts({\n\t\t\ttype: 'select',\n\t\t\tname: 'action',\n\t\t\tmessage: 'The amendment results in a no-op migration because the changes introduced by the latest migration were reverted.\\nYou can choose to remove the latest migration or to modify it so it is empty.',\n\t\t\tchoices: [\n\t\t\t\t{ value: 'remove', title: 'Remove latest migration' },\n\t\t\t\t{ value: 'keep', title: 'Keep latest migration and make it empty' },\n\t\t\t],\n\t\t})\n\t\treturn action === 'remove'\n\t}\n}\n"],"names":["Command","emptySchema","InvalidSchemaException","printValidationErrors"],"mappings":";;;;;;;AAqBO,MAAM,8BAA8BA,UAAAA,QAAuB;AAAA,EACjE,YACkB,oBACA,yBACA,wBACA,cACA,sBACA,kBACA,qBACA,kBACA,gBAChB;AACK,UAAA;AAVW,SAAA,qBAAA;AACA,SAAA,0BAAA;AACA,SAAA,yBAAA;AACA,SAAA,eAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AACA,SAAA,sBAAA;AACA,SAAA,mBAAA;AACA,SAAA,iBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,yBAAyB;AACrC,kBAAA,SAAS,WAAW,EAAE,SAAS;AAC7C,kBAAc,OAAO,OAAO,EAAE,YAAY,2DAA2D;AACrG,kBACE,OAAO,KAAK,EACZ,UAAU,EACV,YAAY,8BAA8B;AAAA,EAAA;AAAA,EAG7C,MAAgB,QAAQ,OAA8C;AAC/D,UAAA,gBAAgB,MAAM,YAAY,WAAW;AAC7C,UAAA,iBAAiB,gBACpB,MAAM,KAAK,mBAAmB,6BAA6B,aAAa,IACxE,MAAM,KAAK,mBAAmB,0BAA0B;AAC3D,QAAI,CAAC,gBAAgB;AACd,YAAA;AAAA,IAAA;AAED,UAAA,QAAQ,MAAM,UAAU,OAAO;AACrC,UAAM,SAAS,MAAM,KAAK,uBAAuB,wBAAwB,EAAE,OAAO;AAC9E,QAAA,OAAO,oBAAoB,SAAS,GAAG;AACpC,YAAA;AAAA,IAAA;AAIP,UAAM,SAAS,MAAM,KAAK,aAAa,WAAW;AAC9C,QAAA;AACH,YAAM,gBAAgB,MAAM,KAAK,qBAAqB,YAAY;AAClE,YAAM,qBAAqB,M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
+ {"version":3,"file":"MigrationAmendCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationAmendCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { InvalidSchemaException, SchemaMigrator } from '@contember/schema-migrations'\nimport prompts from 'prompts'\nimport { emptySchema } from '@contember/schema-utils'\nimport { MigrationCreator, MigrationsResolver, SchemaVersionBuilder, SystemClient } from '@contember/migrations-client'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { MigrationsValidator } from '../../lib/migrations/MigrationsValidator'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { printValidationErrors } from '../../lib/schema/SchemaValidationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {\n\tmigration?: string\n}\n\ntype Options = {\n\tyes?: true\n\tforce: boolean\n}\n\nexport class MigrationAmendCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly systemApiClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t\tprivate readonly migrationsValidator: MigrationsValidator,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Amends latest migration')\n\t\tconfiguration.argument('migration').optional()\n\t\tconfiguration.option('force').description('Ignore migrations order and missing migrations (dev only)')\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migration')\n\t\tconst amendMigration = migrationName\n\t\t\t? await this.migrationsResolver.findSchemaMigrationByVersion(migrationName)\n\t\t\t: await this.migrationsResolver.findLatestSchemaMigration()\n\t\tif (!amendMigration) {\n\t\t\tthrow 'No migration to amend'\n\t\t}\n\t\tconst force = input.getOption('force')\n\t\tconst status = await this.migrationsStatusFacade.resolveMigrationsStatus({ force })\n\t\tif (status.migrationsToExecute.length > 0) {\n\t\t\tthrow `Some migrations are not executed. Unable to amend.`\n\t\t}\n\n\t\tconst schema = await this.schemaLoader.loadSchema()\n\t\ttry {\n\t\t\tconst initialSchema = await this.schemaVersionBuilder.buildSchema()\n\t\t\tconst intermediateResult = await this.migrationCreator.prepareMigration(initialSchema, schema, '')\n\t\t\tif (intermediateResult === null) {\n\t\t\t\tconsole.log('Nothing to do')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tif (amendMigration.formatVersion !== intermediateResult.migration.formatVersion) {\n\t\t\t\tthrow 'Incompatible migration format version'\n\t\t\t}\n\t\t\tconst prevSchema = await this.schemaVersionBuilder.buildSchemaAdvanced(\n\t\t\t\temptySchema,\n\t\t\t\tversion => version < amendMigration.version,\n\t\t\t)\n\t\t\tconst newSchema = await this.schemaMigrator.applyModifications(\n\t\t\t\tprevSchema,\n\t\t\t\t[...amendMigration.modifications, ...intermediateResult.migration.modifications],\n\t\t\t\tamendMigration.formatVersion,\n\t\t\t)\n\t\t\tconst newMigrationResult = await this.migrationCreator.prepareMigration(prevSchema, newSchema, '')\n\t\t\tconst followingMigrations = (await this.migrationsResolver.getSchemaMigrations()).filter(\n\t\t\t\tit => it.version > amendMigration.version,\n\t\t\t)\n\n\t\t\tconst valid = await this.migrationsValidator.validate(\n\t\t\t\tprevSchema,\n\t\t\t\t[...(newMigrationResult ? [newMigrationResult.migration] : []), ...followingMigrations],\n\t\t\t)\n\t\t\tif (!valid) {\n\t\t\t\tthrow `Cannot amend migration`\n\t\t\t}\n\n\t\t\tthis.migrationPrinter.printMigrationDescription(\n\t\t\t\tintermediateResult.initialSchema,\n\t\t\t\tintermediateResult.migration,\n\t\t\t\t{ noSql: true },\n\t\t\t)\n\t\t\tconsole.log(`Amending ${amendMigration.name}`)\n\t\t\tif (!(await this.shouldContinue(input))) {\n\t\t\t\tconsole.log('Aborting')\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\tconst systemClient = this.systemApiClientProvider.get()\n\t\t\tawait systemClient.migrate([intermediateResult.migration], force)\n\t\t\tawait systemClient.migrationDelete(intermediateResult.migration.version)\n\n\t\t\tif (!newMigrationResult && await this.shouldRemove()) {\n\t\t\t\tawait this.migrationCreator.removeMigration(amendMigration.name)\n\t\t\t\tawait systemClient.migrationDelete(amendMigration.version)\n\t\t\t\tconsole.log('Latest migration was removed')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tconst newMigration = {\n\t\t\t\tname: amendMigration.name,\n\t\t\t\tversion: amendMigration.version,\n\t\t\t\tformatVersion: newMigrationResult?.migration.formatVersion ?? amendMigration.formatVersion,\n\t\t\t\tmodifications: newMigrationResult?.migration.modifications ?? [],\n\t\t\t}\n\t\t\tawait this.migrationCreator.saveMigration(newMigration)\n\t\t\tawait systemClient.migrationModify(amendMigration.version, newMigration)\n\n\t\t\treturn 0\n\t\t} catch (e) {\n\t\t\tif (e instanceof InvalidSchemaException) {\n\t\t\t\tprintValidationErrors(e.validationErrors, e.message)\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n\n\tprivate async shouldContinue(input: Input<{}, { yes?: true }>): Promise<boolean> {\n\t\tconst yes = input.getOption('yes')\n\t\tif (yes) {\n\t\t\treturn true\n\t\t}\n\t\tconst { action } = await prompts({\n\t\t\ttype: 'select',\n\t\t\tname: 'action',\n\t\t\tmessage: 'Do you want to continue?',\n\t\t\tchoices: [\n\t\t\t\t{ value: 'yes', title: 'Yes' },\n\t\t\t\t{ value: 'no', title: 'Abort' },\n\t\t\t],\n\t\t})\n\t\treturn action === 'yes'\n\t}\n\n\tprivate async shouldRemove(): Promise<boolean> {\n\t\tconst { action } = await prompts({\n\t\t\ttype: 'select',\n\t\t\tname: 'action',\n\t\t\tmessage:\n\t\t\t\t'The amendment results in a no-op migration because the changes introduced by the latest migration were reverted.\\nYou can choose to remove the latest migration or to modify it so it is empty.',\n\t\t\tchoices: [\n\t\t\t\t{ value: 'remove', title: 'Remove latest migration' },\n\t\t\t\t{ value: 'keep', title: 'Keep latest migration and make it empty' },\n\t\t\t],\n\t\t})\n\t\treturn action === 'remove'\n\t}\n}\n"],"names":["Command","emptySchema","InvalidSchemaException","printValidationErrors"],"mappings":";;;;;;;AAqBO,MAAM,8BAA8BA,UAAAA,QAAuB;AAAA,EACjE,YACkB,oBACA,yBACA,wBACA,cACA,sBACA,kBACA,qBACA,kBACA,gBAChB;AACD,UAAA;AAViB,SAAA,qBAAA;AACA,SAAA,0BAAA;AACA,SAAA,yBAAA;AACA,SAAA,eAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AACA,SAAA,sBAAA;AACA,SAAA,mBAAA;AACA,SAAA,iBAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,yBAAyB;AACnD,kBAAc,SAAS,WAAW,EAAE,SAAA;AACpC,kBAAc,OAAO,OAAO,EAAE,YAAY,2DAA2D;AACrG,kBACE,OAAO,KAAK,EACZ,UAAA,EACA,YAAY,8BAA8B;AAAA,EAC7C;AAAA,EAEA,MAAgB,QAAQ,OAA8C;AACrE,UAAM,gBAAgB,MAAM,YAAY,WAAW;AACnD,UAAM,iBAAiB,gBACpB,MAAM,KAAK,mBAAmB,6BAA6B,aAAa,IACxE,MAAM,KAAK,mBAAmB,0BAAA;AACjC,QAAI,CAAC,gBAAgB;AACpB,YAAM;AAAA,IACP;AACA,UAAM,QAAQ,MAAM,UAAU,OAAO;AACrC,UAAM,SAAS,MAAM,KAAK,uBAAuB,wBAAwB,EAAE,OAAO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ACN,SACC;AAAA,MACD,SAAS;AAAA,QACR,EAAE,OAAO,UAAU,OAAO,0BAAA;AAAA,QAC1B,EAAE,OAAO,QAAQ,OAAO,0CAAA;AAAA,MAA0C;AAAA,IACnE,CACA;AACD,WAAO,WAAW;AAAA,EACnB;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationAmendCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationAmendCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { InvalidSchemaException, SchemaMigrator } from '@contember/schema-migrations'\nimport prompts from 'prompts'\nimport { emptySchema } from '@contember/schema-utils'\nimport { MigrationCreator, MigrationsResolver, SchemaVersionBuilder, SystemClient } from '@contember/migrations-client'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { MigrationsValidator } from '../../lib/migrations/MigrationsValidator'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { printValidationErrors } from '../../lib/schema/SchemaValidationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {\n\tmigration?: string\n}\n\ntype Options = {\n\tyes?: true\n\tforce: boolean\n}\n\nexport class MigrationAmendCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly systemApiClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t\tprivate readonly migrationsValidator: MigrationsValidator,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Amends latest migration')\n\t\tconfiguration.argument('migration').optional()\n\t\tconfiguration.option('force').description('Ignore migrations order and missing migrations (dev only)')\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migration')\n\t\tconst amendMigration = migrationName\n\t\t\t? await this.migrationsResolver.findSchemaMigrationByVersion(migrationName)\n\t\t\t: await this.migrationsResolver.findLatestSchemaMigration()\n\t\tif (!amendMigration) {\n\t\t\tthrow 'No migration to amend'\n\t\t}\n\t\tconst force = input.getOption('force')\n\t\tconst status = await this.migrationsStatusFacade.resolveMigrationsStatus({ force })\n\t\tif (status.migrationsToExecute.length > 0) {\n\t\t\tthrow `Some migrations are not executed. Unable to amend.`\n\t\t}\n\n\n\t\tconst schema = await this.schemaLoader.loadSchema()\n\t\ttry {\n\t\t\tconst initialSchema = await this.schemaVersionBuilder.buildSchema()\n\t\t\tconst intermediateResult = await this.migrationCreator.prepareMigration(initialSchema, schema, '')\n\t\t\tif (intermediateResult === null) {\n\t\t\t\tconsole.log('Nothing to do')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tif (amendMigration.formatVersion !== intermediateResult.migration.formatVersion) {\n\t\t\t\tthrow 'Incompatible migration format version'\n\t\t\t}\n\t\t\tconst prevSchema = await this.schemaVersionBuilder.buildSchemaAdvanced(\n\t\t\t\temptySchema,\n\t\t\t\tversion => version < amendMigration.version,\n\t\t\t)\n\t\t\tconst newSchema = await this.schemaMigrator.applyModifications(\n\t\t\t\tprevSchema,\n\t\t\t\t[...amendMigration.modifications, ...intermediateResult.migration.modifications],\n\t\t\t\tamendMigration.formatVersion,\n\t\t\t)\n\t\t\tconst newMigrationResult = await this.migrationCreator.prepareMigration(prevSchema, newSchema, '')\n\t\t\tconst followingMigrations = (await this.migrationsResolver.getSchemaMigrations()).filter(\n\t\t\t\tit => it.version > amendMigration.version,\n\t\t\t)\n\n\t\t\tconst valid = await this.migrationsValidator.validate(\n\t\t\t\tprevSchema,\n\t\t\t\t[...(newMigrationResult ? [newMigrationResult.migration] : []), ...followingMigrations],\n\t\t\t)\n\t\t\tif (!valid) {\n\t\t\t\tthrow `Cannot amend migration`\n\t\t\t}\n\n\t\t\tthis.migrationPrinter.printMigrationDescription(\n\t\t\t\tintermediateResult.initialSchema,\n\t\t\t\tintermediateResult.migration,\n\t\t\t\t{ noSql: true },\n\t\t\t)\n\t\t\tconsole.log(`Amending ${amendMigration.name}`)\n\t\t\tif (!(await this.shouldContinue(input))) {\n\t\t\t\tconsole.log('Aborting')\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\tconst systemClient = this.systemApiClientProvider.get()\n\t\t\tawait systemClient.migrate([intermediateResult.migration], force)\n\t\t\tawait systemClient.migrationDelete(intermediateResult.migration.version)\n\n\t\t\tif (!newMigrationResult && await this.shouldRemove()) {\n\t\t\t\tawait this.migrationCreator.removeMigration(amendMigration.name)\n\t\t\t\tawait systemClient.migrationDelete(amendMigration.version)\n\t\t\t\tconsole.log('Latest migration was removed')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tconst newMigration = {\n\t\t\t\tname: amendMigration.name,\n\t\t\t\tversion: amendMigration.version,\n\t\t\t\tformatVersion: newMigrationResult?.migration.formatVersion ?? amendMigration.formatVersion,\n\t\t\t\tmodifications: newMigrationResult?.migration.modifications ?? [],\n\t\t\t}\n\t\t\tawait this.migrationCreator.saveMigration(newMigration)\n\t\t\tawait systemClient.migrationModify(amendMigration.version, newMigration)\n\n\t\t\treturn 0\n\t\t} catch (e) {\n\t\t\tif (e instanceof InvalidSchemaException) {\n\t\t\t\tprintValidationErrors(e.validationErrors, e.message)\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n\n\tprivate async shouldContinue(input: Input<{}, { yes?: true }>): Promise<boolean> {\n\t\tconst yes = input.getOption('yes')\n\t\tif (yes) {\n\t\t\treturn true\n\t\t}\n\t\tconst { action } = await prompts({\n\t\t\ttype: 'select',\n\t\t\tname: 'action',\n\t\t\tmessage: 'Do you want to continue?',\n\t\t\tchoices: [\n\t\t\t\t{ value: 'yes', title: 'Yes' },\n\t\t\t\t{ value: 'no', title: 'Abort' },\n\t\t\t],\n\t\t})\n\t\treturn action === 'yes'\n\t}\n\n\tprivate async shouldRemove(): Promise<boolean> {\n\t\tconst { action } = await prompts({\n\t\t\ttype: 'select',\n\t\t\tname: 'action',\n\t\t\tmessage: 'The amendment results in a no-op migration because the changes introduced by the latest migration were reverted.\\nYou can choose to remove the latest migration or to modify it so it is empty.',\n\t\t\tchoices: [\n\t\t\t\t{ value: 'remove', title: 'Remove latest migration' },\n\t\t\t\t{ value: 'keep', title: 'Keep latest migration and make it empty' },\n\t\t\t],\n\t\t})\n\t\treturn action === 'remove'\n\t}\n}\n"],"names":[],"mappings":";;;;;AAqBO,MAAM,8BAA8B,QAAuB;AAAA,EACjE,YACkB,oBACA,yBACA,wBACA,cACA,sBACA,kBACA,qBACA,kBACA,gBAChB;AACK,UAAA;AAVW,SAAA,qBAAA;AACA,SAAA,0BAAA;AACA,SAAA,yBAAA;AACA,SAAA,eAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AACA,SAAA,sBAAA;AACA,SAAA,mBAAA;AACA,SAAA,iBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,yBAAyB;AACrC,kBAAA,SAAS,WAAW,EAAE,SAAS;AAC7C,kBAAc,OAAO,OAAO,EAAE,YAAY,2DAA2D;AACrG,kBACE,OAAO,KAAK,EACZ,UAAU,EACV,YAAY,8BAA8B;AAAA,EAAA;AAAA,EAG7C,MAAgB,QAAQ,OAA8C;AAC/D,UAAA,gBAAgB,MAAM,YAAY,WAAW;AAC7C,UAAA,iBAAiB,gBACpB,MAAM,KAAK,mBAAmB,6BAA6B,aAAa,IACxE,MAAM,KAAK,mBAAmB,0BAA0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W;AAAA,EAAA;AAAA,EAGnB,MAAc,eAAiC;AAC9C,UAAM,EAAE,WAAW,MAAM,QAAQ;AAAA,MAChC,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS;AAAA,QACR,EAAE,OAAO,UAAU,OAAO,0BAA0B;AAAA,QACpD,EAAE,OAAO,QAAQ,OAAO,0CAA0C;AAAA,MAAA;AAAA,IACnE,CACA;AACD,WAAO,WAAW;AAAA,EAAA;AAEpB;"}
1
+ {"version":3,"file":"MigrationAmendCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationAmendCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { InvalidSchemaException, SchemaMigrator } from '@contember/schema-migrations'\nimport prompts from 'prompts'\nimport { emptySchema } from '@contember/schema-utils'\nimport { MigrationCreator, MigrationsResolver, SchemaVersionBuilder, SystemClient } from '@contember/migrations-client'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { MigrationsValidator } from '../../lib/migrations/MigrationsValidator'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { printValidationErrors } from '../../lib/schema/SchemaValidationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {\n\tmigration?: string\n}\n\ntype Options = {\n\tyes?: true\n\tforce: boolean\n}\n\nexport class MigrationAmendCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly systemApiClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t\tprivate readonly migrationsValidator: MigrationsValidator,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Amends latest migration')\n\t\tconfiguration.argument('migration').optional()\n\t\tconfiguration.option('force').description('Ignore migrations order and missing migrations (dev only)')\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migration')\n\t\tconst amendMigration = migrationName\n\t\t\t? await this.migrationsResolver.findSchemaMigrationByVersion(migrationName)\n\t\t\t: await this.migrationsResolver.findLatestSchemaMigration()\n\t\tif (!amendMigration) {\n\t\t\tthrow 'No migration to amend'\n\t\t}\n\t\tconst force = input.getOption('force')\n\t\tconst status = await this.migrationsStatusFacade.resolveMigrationsStatus({ force })\n\t\tif (status.migrationsToExecute.length > 0) {\n\t\t\tthrow `Some migrations are not executed. Unable to amend.`\n\t\t}\n\n\t\tconst schema = await this.schemaLoader.loadSchema()\n\t\ttry {\n\t\t\tconst initialSchema = await this.schemaVersionBuilder.buildSchema()\n\t\t\tconst intermediateResult = await this.migrationCreator.prepareMigration(initialSchema, schema, '')\n\t\t\tif (intermediateResult === null) {\n\t\t\t\tconsole.log('Nothing to do')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tif (amendMigration.formatVersion !== intermediateResult.migration.formatVersion) {\n\t\t\t\tthrow 'Incompatible migration format version'\n\t\t\t}\n\t\t\tconst prevSchema = await this.schemaVersionBuilder.buildSchemaAdvanced(\n\t\t\t\temptySchema,\n\t\t\t\tversion => version < amendMigration.version,\n\t\t\t)\n\t\t\tconst newSchema = await this.schemaMigrator.applyModifications(\n\t\t\t\tprevSchema,\n\t\t\t\t[...amendMigration.modifications, ...intermediateResult.migration.modifications],\n\t\t\t\tamendMigration.formatVersion,\n\t\t\t)\n\t\t\tconst newMigrationResult = await this.migrationCreator.prepareMigration(prevSchema, newSchema, '')\n\t\t\tconst followingMigrations = (await this.migrationsResolver.getSchemaMigrations()).filter(\n\t\t\t\tit => it.version > amendMigration.version,\n\t\t\t)\n\n\t\t\tconst valid = await this.migrationsValidator.validate(\n\t\t\t\tprevSchema,\n\t\t\t\t[...(newMigrationResult ? [newMigrationResult.migration] : []), ...followingMigrations],\n\t\t\t)\n\t\t\tif (!valid) {\n\t\t\t\tthrow `Cannot amend migration`\n\t\t\t}\n\n\t\t\tthis.migrationPrinter.printMigrationDescription(\n\t\t\t\tintermediateResult.initialSchema,\n\t\t\t\tintermediateResult.migration,\n\t\t\t\t{ noSql: true },\n\t\t\t)\n\t\t\tconsole.log(`Amending ${amendMigration.name}`)\n\t\t\tif (!(await this.shouldContinue(input))) {\n\t\t\t\tconsole.log('Aborting')\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\tconst systemClient = this.systemApiClientProvider.get()\n\t\t\tawait systemClient.migrate([intermediateResult.migration], force)\n\t\t\tawait systemClient.migrationDelete(intermediateResult.migration.version)\n\n\t\t\tif (!newMigrationResult && await this.shouldRemove()) {\n\t\t\t\tawait this.migrationCreator.removeMigration(amendMigration.name)\n\t\t\t\tawait systemClient.migrationDelete(amendMigration.version)\n\t\t\t\tconsole.log('Latest migration was removed')\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tconst newMigration = {\n\t\t\t\tname: amendMigration.name,\n\t\t\t\tversion: amendMigration.version,\n\t\t\t\tformatVersion: newMigrationResult?.migration.formatVersion ?? amendMigration.formatVersion,\n\t\t\t\tmodifications: newMigrationResult?.migration.modifications ?? [],\n\t\t\t}\n\t\t\tawait this.migrationCreator.saveMigration(newMigration)\n\t\t\tawait systemClient.migrationModify(amendMigration.version, newMigration)\n\n\t\t\treturn 0\n\t\t} catch (e) {\n\t\t\tif (e instanceof InvalidSchemaException) {\n\t\t\t\tprintValidationErrors(e.validationErrors, e.message)\n\t\t\t\treturn 1\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n\n\tprivate async shouldContinue(input: Input<{}, { yes?: true }>): Promise<boolean> {\n\t\tconst yes = input.getOption('yes')\n\t\tif (yes) {\n\t\t\treturn true\n\t\t}\n\t\tconst { action } = await prompts({\n\t\t\ttype: 'select',\n\t\t\tname: 'action',\n\t\t\tmessage: 'Do you want to continue?',\n\t\t\tchoices: [\n\t\t\t\t{ value: 'yes', title: 'Yes' },\n\t\t\t\t{ value: 'no', title: 'Abort' },\n\t\t\t],\n\t\t})\n\t\treturn action === 'yes'\n\t}\n\n\tprivate async shouldRemove(): Promise<boolean> {\n\t\tconst { action } = await prompts({\n\t\t\ttype: 'select',\n\t\t\tname: 'action',\n\t\t\tmessage:\n\t\t\t\t'The amendment results in a no-op migration because the changes introduced by the latest migration were reverted.\\nYou can choose to remove the latest migration or to modify it so it is empty.',\n\t\t\tchoices: [\n\t\t\t\t{ value: 'remove', title: 'Remove latest migration' },\n\t\t\t\t{ value: 'keep', title: 'Keep latest migration and make it empty' },\n\t\t\t],\n\t\t})\n\t\treturn action === 'remove'\n\t}\n}\n"],"names":[],"mappings":";;;;;AAqBO,MAAM,8BAA8B,QAAuB;AAAA,EACjE,YACkB,oBACA,yBACA,wBACA,cACA,sBACA,kBACA,qBACA,kBACA,gBAChB;AACD,UAAA;AAViB,SAAA,qBAAA;AACA,SAAA,0BAAA;AACA,SAAA,yBAAA;AACA,SAAA,eAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AACA,SAAA,sBAAA;AACA,SAAA,mBAAA;AACA,SAAA,iBAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,yBAAyB;AACnD,kBAAc,SAAS,WAAW,EAAE,SAAA;AACpC,kBAAc,OAAO,OAAO,EAAE,YAAY,2DAA2D;AACrG,kBACE,OAAO,KAAK,EACZ,UAAA,EACA,YAAY,8BAA8B;AAAA,EAC7C;AAAA,EAEA,MAAgB,QAAQ,OAA8C;AACrE,UAAM,gBAA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OAAO,OAAO,OAAO,MAAA;AAAA,QACvB,EAAE,OAAO,MAAM,OAAO,QAAA;AAAA,MAAQ;AAAA,IAC/B,CACA;AACD,WAAO,WAAW;AAAA,EACnB;AAAA,EAEA,MAAc,eAAiC;AAC9C,UAAM,EAAE,WAAW,MAAM,QAAQ;AAAA,MAChC,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SACC;AAAA,MACD,SAAS;AAAA,QACR,EAAE,OAAO,UAAU,OAAO,0BAAA;AAAA,QAC1B,EAAE,OAAO,QAAQ,OAAO,0CAAA;AAAA,MAA0C;AAAA,IACnE,CACA;AACD,WAAO,WAAW;AAAA,EACnB;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationBlankCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationBlankCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationCreator } from '@contember/migrations-client'\n\ntype Args = {\n\tmigrationName: string\n\tformat?: string\n}\n\ntype Options = {\n}\n\nexport class MigrationBlankCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Creates new blank migration file')\n\t\tconfiguration.argument('migrationName')\n\t\tconfiguration.argument('format').optional().validator(it => !it || ['js', 'ts', 'json'].includes(it))\n\t\t\t.description('Migration file format (js, ts, json), default is ts.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migrationName')\n\t\tconst migrationFormat = input.getArgument('format') || 'ts'\n\t\tconst filename = await this.migrationCreator.createEmptyMigrationFile(migrationName, migrationFormat)\n\t\tconsole.log(`${filename} created`)\n\t\treturn 0\n\t}\n}\n\n"],"names":["Command"],"mappings":";;;AAWO,MAAM,8BAA8BA,UAAAA,QAAuB;AAAA,EACjE,YACkB,kBAChB;AACK,UAAA;AAFW,SAAA,mBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kCAAkC;AAC5D,kBAAc,SAAS,eAAe;AACtC,kBAAc,SAAS,QAAQ,EAAE,WAAW,UAAU,QAAM,CAAC,MAAM,CAAC,MAAM,MAAM,MAAM,EAAE,SAAS,EAAE,CAAC,EAClG,YAAY,sDAAsD;AAAA,EAAA;AAAA,EAGrE,MAAgB,QAAQ,OAA8C;AAC/D,UAAA,gBAAgB,MAAM,YAAY,eAAe;AACvD,UAAM,kBAAkB,MAAM,YAAY,QAAQ,KAAK;AACvD,UAAM,WAAW,MAAM,KAAK,iBAAiB,yBAAyB,eAAe,eAAe;AAC5F,YAAA,IAAI,GAAG,QAAQ,UAAU;AAC1B,WAAA;AAAA,EAAA;AAET;;"}
1
+ {"version":3,"file":"MigrationBlankCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationBlankCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationCreator } from '@contember/migrations-client'\n\ntype Args = {\n\tmigrationName: string\n\tformat?: string\n}\n\ntype Options = {}\n\nexport class MigrationBlankCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Creates new blank migration file')\n\t\tconfiguration.argument('migrationName')\n\t\tconfiguration.argument('format').optional().validator(it => !it || ['js', 'ts', 'json'].includes(it))\n\t\t\t.description('Migration file format (js, ts, json), default is ts.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migrationName')\n\t\tconst migrationFormat = input.getArgument('format') || 'ts'\n\t\tconst filename = await this.migrationCreator.createEmptyMigrationFile(migrationName, migrationFormat)\n\t\tconsole.log(`${filename} created`)\n\t\treturn 0\n\t}\n}\n"],"names":["Command"],"mappings":";;;AAUO,MAAM,8BAA8BA,UAAAA,QAAuB;AAAA,EACjE,YACkB,kBAChB;AACD,UAAA;AAFiB,SAAA,mBAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kCAAkC;AAC5D,kBAAc,SAAS,eAAe;AACtC,kBAAc,SAAS,QAAQ,EAAE,WAAW,UAAU,QAAM,CAAC,MAAM,CAAC,MAAM,MAAM,MAAM,EAAE,SAAS,EAAE,CAAC,EAClG,YAAY,sDAAsD;AAAA,EACrE;AAAA,EAEA,MAAgB,QAAQ,OAA8C;AACrE,UAAM,gBAAgB,MAAM,YAAY,eAAe;AACvD,UAAM,kBAAkB,MAAM,YAAY,QAAQ,KAAK;AACvD,UAAM,WAAW,MAAM,KAAK,iBAAiB,yBAAyB,eAAe,eAAe;AACpG,YAAQ,IAAI,GAAG,QAAQ,UAAU;AACjC,WAAO;AAAA,EACR;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationBlankCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationBlankCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationCreator } from '@contember/migrations-client'\n\ntype Args = {\n\tmigrationName: string\n\tformat?: string\n}\n\ntype Options = {\n}\n\nexport class MigrationBlankCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Creates new blank migration file')\n\t\tconfiguration.argument('migrationName')\n\t\tconfiguration.argument('format').optional().validator(it => !it || ['js', 'ts', 'json'].includes(it))\n\t\t\t.description('Migration file format (js, ts, json), default is ts.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migrationName')\n\t\tconst migrationFormat = input.getArgument('format') || 'ts'\n\t\tconst filename = await this.migrationCreator.createEmptyMigrationFile(migrationName, migrationFormat)\n\t\tconsole.log(`${filename} created`)\n\t\treturn 0\n\t}\n}\n\n"],"names":[],"mappings":";AAWO,MAAM,8BAA8B,QAAuB;AAAA,EACjE,YACkB,kBAChB;AACK,UAAA;AAFW,SAAA,mBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kCAAkC;AAC5D,kBAAc,SAAS,eAAe;AACtC,kBAAc,SAAS,QAAQ,EAAE,WAAW,UAAU,QAAM,CAAC,MAAM,CAAC,MAAM,MAAM,MAAM,EAAE,SAAS,EAAE,CAAC,EAClG,YAAY,sDAAsD;AAAA,EAAA;AAAA,EAGrE,MAAgB,QAAQ,OAA8C;AAC/D,UAAA,gBAAgB,MAAM,YAAY,eAAe;AACvD,UAAM,kBAAkB,MAAM,YAAY,QAAQ,KAAK;AACvD,UAAM,WAAW,MAAM,KAAK,iBAAiB,yBAAyB,eAAe,eAAe;AAC5F,YAAA,IAAI,GAAG,QAAQ,UAAU;AAC1B,WAAA;AAAA,EAAA;AAET;"}
1
+ {"version":3,"file":"MigrationBlankCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationBlankCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationCreator } from '@contember/migrations-client'\n\ntype Args = {\n\tmigrationName: string\n\tformat?: string\n}\n\ntype Options = {}\n\nexport class MigrationBlankCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Creates new blank migration file')\n\t\tconfiguration.argument('migrationName')\n\t\tconfiguration.argument('format').optional().validator(it => !it || ['js', 'ts', 'json'].includes(it))\n\t\t\t.description('Migration file format (js, ts, json), default is ts.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst migrationName = input.getArgument('migrationName')\n\t\tconst migrationFormat = input.getArgument('format') || 'ts'\n\t\tconst filename = await this.migrationCreator.createEmptyMigrationFile(migrationName, migrationFormat)\n\t\tconsole.log(`${filename} created`)\n\t\treturn 0\n\t}\n}\n"],"names":[],"mappings":";AAUO,MAAM,8BAA8B,QAAuB;AAAA,EACjE,YACkB,kBAChB;AACD,UAAA;AAFiB,SAAA,mBAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kCAAkC;AAC5D,kBAAc,SAAS,eAAe;AACtC,kBAAc,SAAS,QAAQ,EAAE,WAAW,UAAU,QAAM,CAAC,MAAM,CAAC,MAAM,MAAM,MAAM,EAAE,SAAS,EAAE,CAAC,EAClG,YAAY,sDAAsD;AAAA,EACrE;AAAA,EAEA,MAAgB,QAAQ,OAA8C;AACrE,UAAM,gBAAgB,MAAM,YAAY,eAAe;AACvD,UAAM,kBAAkB,MAAM,YAAY,QAAQ,KAAK;AACvD,UAAM,WAAW,MAAM,KAAK,iBAAiB,yBAAyB,eAAe,eAAe;AACpG,YAAQ,IAAI,GAAG,QAAQ,UAAU;AACjC,WAAO;AAAA,EACR;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationDescribeCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationDescribeCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { MigrationsResolver, SchemaVersionBuilder } from '@contember/migrations-client'\n\ntype Args = {\n\tmigration?: string\n}\n\ntype Options = {\n\t['sql-only']: boolean\n\t['no-sql']: boolean\n}\n\n\nexport class MigrationDescribeCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Describes a migration')\n\t\tconfiguration.argument('migration').optional()\n\t\tconfiguration.option('sql-only').valueNone()\n\t\tconfiguration.option('no-sql').valueNone()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst migrationArg = input.getArgument('migration')\n\t\tconst sqlOnly = input.getOption('sql-only')\n\t\tconst noSql = input.getOption('no-sql')\n\n\t\tconst migration = migrationArg\n\t\t\t? await this.migrationsResolver.findSchemaMigrationByVersion(migrationArg)\n\t\t\t: await this.migrationsResolver.findLatestSchemaMigration()\n\n\t\tif (!migration) {\n\t\t\tthrow 'Undefined migration'\n\t\t}\n\t\tconst schema = await this.schemaVersionBuilder.buildSchemaUntil(migration.version)\n\t\tthis.migrationPrinter.printMigrationDescription(schema, migration, { sqlOnly, noSql })\n\t}\n}\n"],"names":["Command"],"mappings":";;;AAcO,MAAM,iCAAiCA,UAAAA,QAAuB;AAAA,EACpE,YACkB,kBACA,sBACA,oBAChB;AACK,UAAA;AAJW,SAAA,mBAAA;AACA,SAAA,uBAAA;AACA,SAAA,qBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,uBAAuB;AACnC,kBAAA,SAAS,WAAW,EAAE,SAAS;AAC/B,kBAAA,OAAO,UAAU,EAAE,UAAU;AAC7B,kBAAA,OAAO,QAAQ,EAAE,UAAU;AAAA,EAAA;AAAA,EAG1C,MAAgB,QAAQ,OAA4C;AAC7D,UAAA,eAAe,MAAM,YAAY,WAAW;AAC5C,UAAA,UAAU,MAAM,UAAU,UAAU;AACpC,UAAA,QAAQ,MAAM,UAAU,QAAQ;AAEhC,UAAA,YAAY,eACf,MAAM,KAAK,mBAAmB,6BAA6B,YAAY,IACvE,MAAM,KAAK,mBAAmB,0BAA0B;AAE3D,QAAI,CAAC,WAAW;AACT,YAAA;AAAA,IAAA;AAEP,UAAM,SAAS,MAAM,KAAK,qBAAqB,iBAAiB,UAAU,OAAO;AACjF,SAAK,iBAAiB,0BAA0B,QAAQ,WAAW,EAAE,SAAS,OAAO;AAAA,EAAA;AAEvF;;"}
1
+ {"version":3,"file":"MigrationDescribeCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationDescribeCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { MigrationsResolver, SchemaVersionBuilder } from '@contember/migrations-client'\n\ntype Args = {\n\tmigration?: string\n}\n\ntype Options = {\n\t['sql-only']: boolean\n\t['no-sql']: boolean\n}\n\nexport class MigrationDescribeCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Describes a migration')\n\t\tconfiguration.argument('migration').optional()\n\t\tconfiguration.option('sql-only').valueNone()\n\t\tconfiguration.option('no-sql').valueNone()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst migrationArg = input.getArgument('migration')\n\t\tconst sqlOnly = input.getOption('sql-only')\n\t\tconst noSql = input.getOption('no-sql')\n\n\t\tconst migration = migrationArg\n\t\t\t? await this.migrationsResolver.findSchemaMigrationByVersion(migrationArg)\n\t\t\t: await this.migrationsResolver.findLatestSchemaMigration()\n\n\t\tif (!migration) {\n\t\t\tthrow 'Undefined migration'\n\t\t}\n\t\tconst schema = await this.schemaVersionBuilder.buildSchemaUntil(migration.version)\n\t\tthis.migrationPrinter.printMigrationDescription(schema, migration, { sqlOnly, noSql })\n\t}\n}\n"],"names":["Command"],"mappings":";;;AAaO,MAAM,iCAAiCA,UAAAA,QAAuB;AAAA,EACpE,YACkB,kBACA,sBACA,oBAChB;AACD,UAAA;AAJiB,SAAA,mBAAA;AACA,SAAA,uBAAA;AACA,SAAA,qBAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,uBAAuB;AACjD,kBAAc,SAAS,WAAW,EAAE,SAAA;AACpC,kBAAc,OAAO,UAAU,EAAE,UAAA;AACjC,kBAAc,OAAO,QAAQ,EAAE,UAAA;AAAA,EAChC;AAAA,EAEA,MAAgB,QAAQ,OAA4C;AACnE,UAAM,eAAe,MAAM,YAAY,WAAW;AAClD,UAAM,UAAU,MAAM,UAAU,UAAU;AAC1C,UAAM,QAAQ,MAAM,UAAU,QAAQ;AAEtC,UAAM,YAAY,eACf,MAAM,KAAK,mBAAmB,6BAA6B,YAAY,IACvE,MAAM,KAAK,mBAAmB,0BAAA;AAEjC,QAAI,CAAC,WAAW;AACf,YAAM;AAAA,IACP;AACA,UAAM,SAAS,MAAM,KAAK,qBAAqB,iBAAiB,UAAU,OAAO;AACjF,SAAK,iBAAiB,0BAA0B,QAAQ,WAAW,EAAE,SAAS,OAAO;AAAA,EACtF;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationDescribeCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationDescribeCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { MigrationsResolver, SchemaVersionBuilder } from '@contember/migrations-client'\n\ntype Args = {\n\tmigration?: string\n}\n\ntype Options = {\n\t['sql-only']: boolean\n\t['no-sql']: boolean\n}\n\n\nexport class MigrationDescribeCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Describes a migration')\n\t\tconfiguration.argument('migration').optional()\n\t\tconfiguration.option('sql-only').valueNone()\n\t\tconfiguration.option('no-sql').valueNone()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst migrationArg = input.getArgument('migration')\n\t\tconst sqlOnly = input.getOption('sql-only')\n\t\tconst noSql = input.getOption('no-sql')\n\n\t\tconst migration = migrationArg\n\t\t\t? await this.migrationsResolver.findSchemaMigrationByVersion(migrationArg)\n\t\t\t: await this.migrationsResolver.findLatestSchemaMigration()\n\n\t\tif (!migration) {\n\t\t\tthrow 'Undefined migration'\n\t\t}\n\t\tconst schema = await this.schemaVersionBuilder.buildSchemaUntil(migration.version)\n\t\tthis.migrationPrinter.printMigrationDescription(schema, migration, { sqlOnly, noSql })\n\t}\n}\n"],"names":[],"mappings":";AAcO,MAAM,iCAAiC,QAAuB;AAAA,EACpE,YACkB,kBACA,sBACA,oBAChB;AACK,UAAA;AAJW,SAAA,mBAAA;AACA,SAAA,uBAAA;AACA,SAAA,qBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,uBAAuB;AACnC,kBAAA,SAAS,WAAW,EAAE,SAAS;AAC/B,kBAAA,OAAO,UAAU,EAAE,UAAU;AAC7B,kBAAA,OAAO,QAAQ,EAAE,UAAU;AAAA,EAAA;AAAA,EAG1C,MAAgB,QAAQ,OAA4C;AAC7D,UAAA,eAAe,MAAM,YAAY,WAAW;AAC5C,UAAA,UAAU,MAAM,UAAU,UAAU;AACpC,UAAA,QAAQ,MAAM,UAAU,QAAQ;AAEhC,UAAA,YAAY,eACf,MAAM,KAAK,mBAAmB,6BAA6B,YAAY,IACvE,MAAM,KAAK,mBAAmB,0BAA0B;AAE3D,QAAI,CAAC,WAAW;AACT,YAAA;AAAA,IAAA;AAEP,UAAM,SAAS,MAAM,KAAK,qBAAqB,iBAAiB,UAAU,OAAO;AACjF,SAAK,iBAAiB,0BAA0B,QAAQ,WAAW,EAAE,SAAS,OAAO;AAAA,EAAA;AAEvF;"}
1
+ {"version":3,"file":"MigrationDescribeCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationDescribeCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { MigrationsResolver, SchemaVersionBuilder } from '@contember/migrations-client'\n\ntype Args = {\n\tmigration?: string\n}\n\ntype Options = {\n\t['sql-only']: boolean\n\t['no-sql']: boolean\n}\n\nexport class MigrationDescribeCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Describes a migration')\n\t\tconfiguration.argument('migration').optional()\n\t\tconfiguration.option('sql-only').valueNone()\n\t\tconfiguration.option('no-sql').valueNone()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst migrationArg = input.getArgument('migration')\n\t\tconst sqlOnly = input.getOption('sql-only')\n\t\tconst noSql = input.getOption('no-sql')\n\n\t\tconst migration = migrationArg\n\t\t\t? await this.migrationsResolver.findSchemaMigrationByVersion(migrationArg)\n\t\t\t: await this.migrationsResolver.findLatestSchemaMigration()\n\n\t\tif (!migration) {\n\t\t\tthrow 'Undefined migration'\n\t\t}\n\t\tconst schema = await this.schemaVersionBuilder.buildSchemaUntil(migration.version)\n\t\tthis.migrationPrinter.printMigrationDescription(schema, migration, { sqlOnly, noSql })\n\t}\n}\n"],"names":[],"mappings":";AAaO,MAAM,iCAAiC,QAAuB;AAAA,EACpE,YACkB,kBACA,sBACA,oBAChB;AACD,UAAA;AAJiB,SAAA,mBAAA;AACA,SAAA,uBAAA;AACA,SAAA,qBAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,uBAAuB;AACjD,kBAAc,SAAS,WAAW,EAAE,SAAA;AACpC,kBAAc,OAAO,UAAU,EAAE,UAAA;AACjC,kBAAc,OAAO,QAAQ,EAAE,UAAA;AAAA,EAChC;AAAA,EAEA,MAAgB,QAAQ,OAA4C;AACnE,UAAM,eAAe,MAAM,YAAY,WAAW;AAClD,UAAM,UAAU,MAAM,UAAU,UAAU;AAC1C,UAAM,QAAQ,MAAM,UAAU,QAAQ;AAEtC,UAAM,YAAY,eACf,MAAM,KAAK,mBAAmB,6BAA6B,YAAY,IACvE,MAAM,KAAK,mBAAmB,0BAAA;AAEjC,QAAI,CAAC,WAAW;AACf,YAAM;AAAA,IACP;AACA,UAAM,SAAS,MAAM,KAAK,qBAAqB,iBAAiB,UAAU,OAAO;AACjF,SAAK,iBAAiB,0BAA0B,QAAQ,WAAW,EAAE,SAAS,OAAO;AAAA,EACtF;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationDiffCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationDiffCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { InvalidSchemaException } from '@contember/schema-migrations'\nimport prompts from 'prompts'\nimport { MigrationCreator, SchemaVersionBuilder } from '@contember/migrations-client'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { MigrationExecutionFacade } from '../../lib/migrations/MigrationExecutionFacade'\nimport { printValidationErrors } from '../../lib/schema/SchemaValidationPrinter'\n\ntype Args = {\n\tmigrationName: string\n}\n\ntype Options = {\n\texecute?: true\n\tyes?: true\n\t'skip-initial-schema-validation'?: true\n}\n\nexport class MigrationDiffCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly migrationExecutorFacade: MigrationExecutionFacade,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Creates schema migration diff')\n\t\tconfiguration.argument('migrationName')\n\t\tconfiguration.option('execute').valueNone()\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\n\t\tconfiguration.option('skip-initial-schema-validation')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst migrationName = input.getArgument('migrationName')\n\t\tlet shouldExecute = input.getOption('execute')\n\t\tconst yes = input.getOption('yes')\n\t\tconst skipInitialSchemaValidation = input.getOption('skip-initial-schema-validation') === true\n\n\t\tconst schema = await this.schemaLoader.loadSchema()\n\t\ttry {\n\t\t\tconst initialSchema = await this.schemaVersionBuilder.buildSchema()\n\t\t\tconst result = await this.migrationCreator.prepareMigration(initialSchema, schema, migrationName, {\n\t\t\t\tskipInitialSchemaValidation: skipInitialSchemaValidation,\n\t\t\t})\n\t\t\tif (result === null) {\n\t\t\t\tconsole.log('Nothing to do')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.migrationPrinter.printMigrationDescription(result.initialSchema, result.migration, { noSql: true })\n\n\n\t\t\tif (!yes) {\n\t\t\t\tconst { action } = await prompts({\n\t\t\t\t\ttype: 'select',\n\t\t\t\t\tname: 'action',\n\t\t\t\t\tmessage: 'Do you want to continue?',\n\t\t\t\t\tchoices: [\n\t\t\t\t\t\t{ value: 'yes', title: 'Yes' },\n\t\t\t\t\t\t...(!shouldExecute ? [{ value: 'execute', title: 'Yes and execute immediately' }] : []),\n\t\t\t\t\t\t{ value: 'no', title: 'Abort' },\n\t\t\t\t\t],\n\t\t\t\t})\n\t\t\t\tif (!action || action === 'no') {\n\t\t\t\t\tconsole.log('Aborting')\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif (action === 'execute') {\n\t\t\t\t\tshouldExecute = true\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst filename = await this.migrationCreator.saveMigration(result.migration)\n\n\t\t\tconsole.log(`${filename} created`)\n\n\t\t} catch (e) {\n\t\t\tif (e instanceof InvalidSchemaException) {\n\t\t\t\tprintValidationErrors(e.validationErrors, e.message)\n\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\n\t\tif (shouldExecute) {\n\t\t\tawait this.migrationExecutorFacade.execute({\n\t\t\t\tforce: false,\n\t\t\t\trequireConfirmation: migrations => migrations.length !== 1 && !yes,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":["Command","InvalidSchemaException","printValidationErrors"],"mappings":";;;;;;AAmBO,MAAM,6BAA6BA,UAAAA,QAAuB;AAAA,EAChE,YACkB,cACA,sBACA,kBACA,kBACA,yBAChB;AACK,UAAA;AANW,SAAA,eAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AACA,SAAA,mBAAA;AACA,SAAA,0BAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,+BAA+B;AACzD,kBAAc,SAAS,eAAe;AACxB,kBAAA,OAAO,SAAS,EAAE,UAAU;AAC1C,kBACE,OAAO,KAAK,EACZ,UAAU,EACV,YAAY,8BAA8B;AAE5C,kBAAc,OAAO,gCAAgC;AAAA,EAAA;AAAA,EAGtD,MAAgB,QAAQ,OAA4C;AAC7D,UAAA,gBAAgB,MAAM,YAAY,eAAe;AACnD,QAAA,gBAAgB,MAAM,UAAU,SAAS;AACvC,UAAA,MAAM,MAAM,UAAU,KAAK;AACjC,UAAM,8BAA8B,MAAM,UAAU,gCAAgC,MAAM;AAE1F,UAAM,SAAS,MAAM,KAAK,aAAa,WAAW;AAC9C,QAAA;AACH,YAAM,gBAAgB,MAAM,KAAK,qBAAqB,YAAY;AAClE,YAAM,SAAS,MAAM,KAAK,iBAAiB,iBAAiB,eAAe,QAAQ,eAAe;AAAA,QACjG;AAAA,MAAA,CACA;AACD,UAAI,WAAW,MAAM;AACpB,gBAAQ,IAAI,eAAe;AAC3B;AAAA,MAAA;AAEI,WAAA,iBAAiB,0BAA0B,OAAO,eAAe,OAAO,WAAW,EAAE,OAAO,MAAM;AAGvG,UAAI,CAAC,KAAK;AACT,cAAM,EAAE,WAAW,MAAM,QAAQ;AAAA,UAChC,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,SAAS;AAAA,YACR,EAAE,OAAO,OAAO,OAAO,MAAM;AAAA,YAC7B,GAAI,CAAC,gBAAgB,CAAC,EAAE,OAAO,WAAW,OAAO,8BAA+B,CAAA,IAAI,CAAC;AAAA,YACrF,EAAE,OAAO,MAAM,OAAO,QAAQ;AAAA,UAAA;AAAA,QAC/B,CACA;AACG,YAAA,CAAC,UAAU,WAAW,MAAM;AAC/B,kBAAQ,IAAI,UAAU;AACtB;AAAA,QAAA;AAED,YAAI,WAAW,WAAW;AACT,0BAAA;AAAA,QAAA;AAAA,MACjB;AAGD,YAAM,WAAW,MAAM,KAAK,iBAAiB,cAAc,OAAO,SAAS;AAEnE,cAAA,IAAI,GAAG,QAAQ,UAAU;AAAA,aAEzB,GAAG;AACX,UAAI,aAAaC,iBAAAA,wBAAwB;AAClBC,gCAAAA,sBAAA,EAAE,kBAAkB,EAAE,OAAO;AAEnD;AAAA,MAAA;AAEK,YAAA;AAAA,IAAA;AAGP,QAAI,eAAe;AACZ,YAAA,KAAK,wBAAwB,QAAQ;AAAA,QAC1C,OAAO;AAAA,QACP,qBAAqB,CAAA,eAAc,WAAW,WAAW,KAAK,CAAC;AAAA,MAAA,CAC/D;AAAA,IAAA;AAAA,EACF;AAEF;;"}
1
+ {"version":3,"file":"MigrationDiffCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationDiffCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { InvalidSchemaException } from '@contember/schema-migrations'\nimport prompts from 'prompts'\nimport { MigrationCreator, SchemaVersionBuilder } from '@contember/migrations-client'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { MigrationExecutionFacade } from '../../lib/migrations/MigrationExecutionFacade'\nimport { printValidationErrors } from '../../lib/schema/SchemaValidationPrinter'\n\ntype Args = {\n\tmigrationName: string\n}\n\ntype Options = {\n\texecute?: true\n\tyes?: true\n\t'skip-initial-schema-validation'?: true\n}\n\nexport class MigrationDiffCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly migrationExecutorFacade: MigrationExecutionFacade,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Creates schema migration diff')\n\t\tconfiguration.argument('migrationName')\n\t\tconfiguration.option('execute').valueNone()\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\n\t\tconfiguration.option('skip-initial-schema-validation')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst migrationName = input.getArgument('migrationName')\n\t\tlet shouldExecute = input.getOption('execute')\n\t\tconst yes = input.getOption('yes')\n\t\tconst skipInitialSchemaValidation = input.getOption('skip-initial-schema-validation') === true\n\n\t\tconst schema = await this.schemaLoader.loadSchema()\n\t\ttry {\n\t\t\tconst initialSchema = await this.schemaVersionBuilder.buildSchema()\n\t\t\tconst result = await this.migrationCreator.prepareMigration(initialSchema, schema, migrationName, {\n\t\t\t\tskipInitialSchemaValidation: skipInitialSchemaValidation,\n\t\t\t})\n\t\t\tif (result === null) {\n\t\t\t\tconsole.log('Nothing to do')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.migrationPrinter.printMigrationDescription(result.initialSchema, result.migration, { noSql: true })\n\n\t\t\tif (!yes) {\n\t\t\t\tconst { action } = await prompts({\n\t\t\t\t\ttype: 'select',\n\t\t\t\t\tname: 'action',\n\t\t\t\t\tmessage: 'Do you want to continue?',\n\t\t\t\t\tchoices: [\n\t\t\t\t\t\t{ value: 'yes', title: 'Yes' },\n\t\t\t\t\t\t...(!shouldExecute ? [{ value: 'execute', title: 'Yes and execute immediately' }] : []),\n\t\t\t\t\t\t{ value: 'no', title: 'Abort' },\n\t\t\t\t\t],\n\t\t\t\t})\n\t\t\t\tif (!action || action === 'no') {\n\t\t\t\t\tconsole.log('Aborting')\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif (action === 'execute') {\n\t\t\t\t\tshouldExecute = true\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst filename = await this.migrationCreator.saveMigration(result.migration)\n\n\t\t\tconsole.log(`${filename} created`)\n\t\t} catch (e) {\n\t\t\tif (e instanceof InvalidSchemaException) {\n\t\t\t\tprintValidationErrors(e.validationErrors, e.message)\n\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\n\t\tif (shouldExecute) {\n\t\t\tawait this.migrationExecutorFacade.execute({\n\t\t\t\tforce: false,\n\t\t\t\trequireConfirmation: migrations => migrations.length !== 1 && !yes,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":["Command","InvalidSchemaException","printValidationErrors"],"mappings":";;;;;;AAmBO,MAAM,6BAA6BA,UAAAA,QAAuB;AAAA,EAChE,YACkB,cACA,sBACA,kBACA,kBACA,yBAChB;AACD,UAAA;AANiB,SAAA,eAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AACA,SAAA,mBAAA;AACA,SAAA,0BAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,+BAA+B;AAC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I,GAAG,QAAQ,UAAU;AAAA,IAClC,SAAS,GAAG;AACX,UAAI,aAAaC,iBAAAA,wBAAwB;AACxCC,gCAAAA,sBAAsB,EAAE,kBAAkB,EAAE,OAAO;AAEnD;AAAA,MACD;AACA,YAAM;AAAA,IACP;AAEA,QAAI,eAAe;AAClB,YAAM,KAAK,wBAAwB,QAAQ;AAAA,QAC1C,OAAO;AAAA,QACP,qBAAqB,CAAA,eAAc,WAAW,WAAW,KAAK,CAAC;AAAA,MAAA,CAC/D;AAAA,IACF;AAAA,EACD;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationDiffCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationDiffCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { InvalidSchemaException } from '@contember/schema-migrations'\nimport prompts from 'prompts'\nimport { MigrationCreator, SchemaVersionBuilder } from '@contember/migrations-client'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { MigrationExecutionFacade } from '../../lib/migrations/MigrationExecutionFacade'\nimport { printValidationErrors } from '../../lib/schema/SchemaValidationPrinter'\n\ntype Args = {\n\tmigrationName: string\n}\n\ntype Options = {\n\texecute?: true\n\tyes?: true\n\t'skip-initial-schema-validation'?: true\n}\n\nexport class MigrationDiffCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly migrationExecutorFacade: MigrationExecutionFacade,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Creates schema migration diff')\n\t\tconfiguration.argument('migrationName')\n\t\tconfiguration.option('execute').valueNone()\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\n\t\tconfiguration.option('skip-initial-schema-validation')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst migrationName = input.getArgument('migrationName')\n\t\tlet shouldExecute = input.getOption('execute')\n\t\tconst yes = input.getOption('yes')\n\t\tconst skipInitialSchemaValidation = input.getOption('skip-initial-schema-validation') === true\n\n\t\tconst schema = await this.schemaLoader.loadSchema()\n\t\ttry {\n\t\t\tconst initialSchema = await this.schemaVersionBuilder.buildSchema()\n\t\t\tconst result = await this.migrationCreator.prepareMigration(initialSchema, schema, migrationName, {\n\t\t\t\tskipInitialSchemaValidation: skipInitialSchemaValidation,\n\t\t\t})\n\t\t\tif (result === null) {\n\t\t\t\tconsole.log('Nothing to do')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.migrationPrinter.printMigrationDescription(result.initialSchema, result.migration, { noSql: true })\n\n\n\t\t\tif (!yes) {\n\t\t\t\tconst { action } = await prompts({\n\t\t\t\t\ttype: 'select',\n\t\t\t\t\tname: 'action',\n\t\t\t\t\tmessage: 'Do you want to continue?',\n\t\t\t\t\tchoices: [\n\t\t\t\t\t\t{ value: 'yes', title: 'Yes' },\n\t\t\t\t\t\t...(!shouldExecute ? [{ value: 'execute', title: 'Yes and execute immediately' }] : []),\n\t\t\t\t\t\t{ value: 'no', title: 'Abort' },\n\t\t\t\t\t],\n\t\t\t\t})\n\t\t\t\tif (!action || action === 'no') {\n\t\t\t\t\tconsole.log('Aborting')\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif (action === 'execute') {\n\t\t\t\t\tshouldExecute = true\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst filename = await this.migrationCreator.saveMigration(result.migration)\n\n\t\t\tconsole.log(`${filename} created`)\n\n\t\t} catch (e) {\n\t\t\tif (e instanceof InvalidSchemaException) {\n\t\t\t\tprintValidationErrors(e.validationErrors, e.message)\n\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\n\t\tif (shouldExecute) {\n\t\t\tawait this.migrationExecutorFacade.execute({\n\t\t\t\tforce: false,\n\t\t\t\trequireConfirmation: migrations => migrations.length !== 1 && !yes,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAmBO,MAAM,6BAA6B,QAAuB;AAAA,EAChE,YACkB,cACA,sBACA,kBACA,kBACA,yBAChB;AACK,UAAA;AANW,SAAA,eAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AACA,SAAA,mBAAA;AACA,SAAA,0BAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,+BAA+B;AACzD,kBAAc,SAAS,eAAe;AACxB,kBAAA,OAAO,SAAS,EAAE,UAAU;AAC1C,kBACE,OAAO,KAAK,EACZ,UAAU,EACV,YAAY,8BAA8B;AAE5C,kBAAc,OAAO,gCAAgC;AAAA,EAAA;AAAA,EAGtD,MAAgB,QAAQ,OAA4C;AAC7D,UAAA,gBAAgB,MAAM,YAAY,eAAe;AACnD,QAAA,gBAAgB,MAAM,UAAU,SAAS;AACvC,UAAA,MAAM,MAAM,UAAU,KAAK;AACjC,UAAM,8BAA8B,MAAM,UAAU,gCAAgC,MAAM;AAE1F,UAAM,SAAS,MAAM,KAAK,aAAa,WAAW;AAC9C,QAAA;AACH,YAAM,gBAAgB,MAAM,KAAK,qBAAqB,YAAY;AAClE,YAAM,SAAS,MAAM,KAAK,iBAAiB,iBAAiB,eAAe,QAAQ,eAAe;AAAA,QACjG;AAAA,MAAA,CACA;AACD,UAAI,WAAW,MAAM;AACpB,gBAAQ,IAAI,eAAe;AAC3B;AAAA,MAAA;AAEI,WAAA,iBAAiB,0BAA0B,OAAO,eAAe,OAAO,WAAW,EAAE,OAAO,MAAM;AAGvG,UAAI,CAAC,KAAK;AACT,cAAM,EAAE,WAAW,MAAM,QAAQ;AAAA,UAChC,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,SAAS;AAAA,YACR,EAAE,OAAO,OAAO,OAAO,MAAM;AAAA,YAC7B,GAAI,CAAC,gBAAgB,CAAC,EAAE,OAAO,WAAW,OAAO,8BAA+B,CAAA,IAAI,CAAC;AAAA,YACrF,EAAE,OAAO,MAAM,OAAO,QAAQ;AAAA,UAAA;AAAA,QAC/B,CACA;AACG,YAAA,CAAC,UAAU,WAAW,MAAM;AAC/B,kBAAQ,IAAI,UAAU;AACtB;AAAA,QAAA;AAED,YAAI,WAAW,WAAW;AACT,0BAAA;AAAA,QAAA;AAAA,MACjB;AAGD,YAAM,WAAW,MAAM,KAAK,iBAAiB,cAAc,OAAO,SAAS;AAEnE,cAAA,IAAI,GAAG,QAAQ,UAAU;AAAA,aAEzB,GAAG;AACX,UAAI,aAAa,wBAAwB;AAClB,8BAAA,EAAE,kBAAkB,EAAE,OAAO;AAEnD;AAAA,MAAA;AAEK,YAAA;AAAA,IAAA;AAGP,QAAI,eAAe;AACZ,YAAA,KAAK,wBAAwB,QAAQ;AAAA,QAC1C,OAAO;AAAA,QACP,qBAAqB,CAAA,eAAc,WAAW,WAAW,KAAK,CAAC;AAAA,MAAA,CAC/D;AAAA,IAAA;AAAA,EACF;AAEF;"}
1
+ {"version":3,"file":"MigrationDiffCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationDiffCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { InvalidSchemaException } from '@contember/schema-migrations'\nimport prompts from 'prompts'\nimport { MigrationCreator, SchemaVersionBuilder } from '@contember/migrations-client'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { MigrationExecutionFacade } from '../../lib/migrations/MigrationExecutionFacade'\nimport { printValidationErrors } from '../../lib/schema/SchemaValidationPrinter'\n\ntype Args = {\n\tmigrationName: string\n}\n\ntype Options = {\n\texecute?: true\n\tyes?: true\n\t'skip-initial-schema-validation'?: true\n}\n\nexport class MigrationDiffCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t\tprivate readonly migrationCreator: MigrationCreator,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t\tprivate readonly migrationExecutorFacade: MigrationExecutionFacade,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Creates schema migration diff')\n\t\tconfiguration.argument('migrationName')\n\t\tconfiguration.option('execute').valueNone()\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\n\t\tconfiguration.option('skip-initial-schema-validation')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst migrationName = input.getArgument('migrationName')\n\t\tlet shouldExecute = input.getOption('execute')\n\t\tconst yes = input.getOption('yes')\n\t\tconst skipInitialSchemaValidation = input.getOption('skip-initial-schema-validation') === true\n\n\t\tconst schema = await this.schemaLoader.loadSchema()\n\t\ttry {\n\t\t\tconst initialSchema = await this.schemaVersionBuilder.buildSchema()\n\t\t\tconst result = await this.migrationCreator.prepareMigration(initialSchema, schema, migrationName, {\n\t\t\t\tskipInitialSchemaValidation: skipInitialSchemaValidation,\n\t\t\t})\n\t\t\tif (result === null) {\n\t\t\t\tconsole.log('Nothing to do')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.migrationPrinter.printMigrationDescription(result.initialSchema, result.migration, { noSql: true })\n\n\t\t\tif (!yes) {\n\t\t\t\tconst { action } = await prompts({\n\t\t\t\t\ttype: 'select',\n\t\t\t\t\tname: 'action',\n\t\t\t\t\tmessage: 'Do you want to continue?',\n\t\t\t\t\tchoices: [\n\t\t\t\t\t\t{ value: 'yes', title: 'Yes' },\n\t\t\t\t\t\t...(!shouldExecute ? [{ value: 'execute', title: 'Yes and execute immediately' }] : []),\n\t\t\t\t\t\t{ value: 'no', title: 'Abort' },\n\t\t\t\t\t],\n\t\t\t\t})\n\t\t\t\tif (!action || action === 'no') {\n\t\t\t\t\tconsole.log('Aborting')\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif (action === 'execute') {\n\t\t\t\t\tshouldExecute = true\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst filename = await this.migrationCreator.saveMigration(result.migration)\n\n\t\t\tconsole.log(`${filename} created`)\n\t\t} catch (e) {\n\t\t\tif (e instanceof InvalidSchemaException) {\n\t\t\t\tprintValidationErrors(e.validationErrors, e.message)\n\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\n\t\tif (shouldExecute) {\n\t\t\tawait this.migrationExecutorFacade.execute({\n\t\t\t\tforce: false,\n\t\t\t\trequireConfirmation: migrations => migrations.length !== 1 && !yes,\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAmBO,MAAM,6BAA6B,QAAuB;AAAA,EAChE,YACkB,cACA,sBACA,kBACA,kBACA,yBAChB;AACD,UAAA;AANiB,SAAA,eAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AACA,SAAA,mBAAA;AACA,SAAA,0BAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,+BAA+B;AACzD,kBAAc,SAAS,eAAe;AACtC,kBAAc,OAAO,SAAS,EAAE,UAAA;AAChC,kBACE,OAAO,KAAK,EACZ,UAAA,EACA,YAAY,8BAA8B;AAE5C,kBAAc,OAAO,gCAAgC;AAAA,EACtD;AAAA,EAEA,MAAgB,QAAQ,OAA4C;AACnE,UAAM,gBAAgB,MAAM,YAAY,eAAe;AACvD,QAAI,gBAAgB,MAAM,UAAU,SAAS;AAC7C,UAAM,MAAM,MAAM,UAAU,KAAK;AACjC,UAAM,8BAA8B,MAAM,UAAU,gCAAgC,MAAM;A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"file":"MigrationExecuteCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationExecuteCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationExecutionFacade } from '../../lib/migrations/MigrationExecutionFacade'\n\ntype Args = {\n}\n\ntype Options = {\n\tuntil?: string\n\tforce: boolean\n\tyes?: boolean\n}\n\nexport class MigrationExecuteCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationExecutorFacade: MigrationExecutionFacade,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Executes migrations on Contember server.')\n\t\tconfiguration.option('force')\n\t\t\t.description('Ignore migrations order and missing migrations (dev only)')\n\t\tconfiguration.option('until')\n\t\t\t.valueRequired()\n\t\t\t.description('Execute all migrations leading up to, and inclusive of, a specified migration')\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst force = input.getOption('force')\n\t\tconst until = input.getOption('until')\n\n\t\tawait this.migrationExecutorFacade.execute({\n\t\t\tforce,\n\t\t\tuntil,\n\t\t\trequireConfirmation: !input.getOption('yes'),\n\t\t})\n\t}\n}\n"],"names":["Command"],"mappings":";;;AAYO,MAAM,gCAAgCA,UAAAA,QAAuB;AAAA,EACnE,YACkB,yBAChB;AACK,UAAA;AAFW,SAAA,0BAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,0CAA0C;AACpE,kBAAc,OAAO,OAAO,EAC1B,YAAY,2DAA2D;AACzE,kBAAc,OAAO,OAAO,EAC1B,cAAc,EACd,YAAY,+EAA+E;AAC7F,kBACE,OAAO,KAAK,EACZ,UAAU,EACV,YAAY,8BAA8B;AAAA,EAAA;AAAA,EAG7C,MAAgB,QAAQ,OAA4C;AAC7D,UAAA,QAAQ,MAAM,UAAU,OAAO;AAC/B,UAAA,QAAQ,MAAM,UAAU,OAAO;AAE/B,UAAA,KAAK,wBAAwB,QAAQ;AAAA,MAC1C;AAAA,MACA;AAAA,MACA,qBAAqB,CAAC,MAAM,UAAU,KAAK;AAAA,IAAA,CAC3C;AAAA,EAAA;AAEH;;"}
1
+ {"version":3,"file":"MigrationExecuteCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationExecuteCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationExecutionFacade } from '../../lib/migrations/MigrationExecutionFacade'\n\ntype Args = {}\n\ntype Options = {\n\tuntil?: string\n\tforce: boolean\n\tyes?: boolean\n}\n\nexport class MigrationExecuteCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationExecutorFacade: MigrationExecutionFacade,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Executes migrations on Contember server.')\n\t\tconfiguration.option('force')\n\t\t\t.description('Ignore migrations order and missing migrations (dev only)')\n\t\tconfiguration.option('until')\n\t\t\t.valueRequired()\n\t\t\t.description('Execute all migrations leading up to, and inclusive of, a specified migration')\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst force = input.getOption('force')\n\t\tconst until = input.getOption('until')\n\n\t\tawait this.migrationExecutorFacade.execute({\n\t\t\tforce,\n\t\t\tuntil,\n\t\t\trequireConfirmation: !input.getOption('yes'),\n\t\t})\n\t}\n}\n"],"names":["Command"],"mappings":";;;AAWO,MAAM,gCAAgCA,UAAAA,QAAuB;AAAA,EACnE,YACkB,yBAChB;AACD,UAAA;AAFiB,SAAA,0BAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,0CAA0C;AACpE,kBAAc,OAAO,OAAO,EAC1B,YAAY,2DAA2D;AACzE,kBAAc,OAAO,OAAO,EAC1B,cAAA,EACA,YAAY,+EAA+E;AAC7F,kBACE,OAAO,KAAK,EACZ,UAAA,EACA,YAAY,8BAA8B;AAAA,EAC7C;AAAA,EAEA,MAAgB,QAAQ,OAA4C;AACnE,UAAM,QAAQ,MAAM,UAAU,OAAO;AACrC,UAAM,QAAQ,MAAM,UAAU,OAAO;AAErC,UAAM,KAAK,wBAAwB,QAAQ;AAAA,MAC1C;AAAA,MACA;AAAA,MACA,qBAAqB,CAAC,MAAM,UAAU,KAAK;AAAA,IAAA,CAC3C;AAAA,EACF;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationExecuteCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationExecuteCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationExecutionFacade } from '../../lib/migrations/MigrationExecutionFacade'\n\ntype Args = {\n}\n\ntype Options = {\n\tuntil?: string\n\tforce: boolean\n\tyes?: boolean\n}\n\nexport class MigrationExecuteCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationExecutorFacade: MigrationExecutionFacade,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Executes migrations on Contember server.')\n\t\tconfiguration.option('force')\n\t\t\t.description('Ignore migrations order and missing migrations (dev only)')\n\t\tconfiguration.option('until')\n\t\t\t.valueRequired()\n\t\t\t.description('Execute all migrations leading up to, and inclusive of, a specified migration')\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst force = input.getOption('force')\n\t\tconst until = input.getOption('until')\n\n\t\tawait this.migrationExecutorFacade.execute({\n\t\t\tforce,\n\t\t\tuntil,\n\t\t\trequireConfirmation: !input.getOption('yes'),\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";AAYO,MAAM,gCAAgC,QAAuB;AAAA,EACnE,YACkB,yBAChB;AACK,UAAA;AAFW,SAAA,0BAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,0CAA0C;AACpE,kBAAc,OAAO,OAAO,EAC1B,YAAY,2DAA2D;AACzE,kBAAc,OAAO,OAAO,EAC1B,cAAc,EACd,YAAY,+EAA+E;AAC7F,kBACE,OAAO,KAAK,EACZ,UAAU,EACV,YAAY,8BAA8B;AAAA,EAAA;AAAA,EAG7C,MAAgB,QAAQ,OAA4C;AAC7D,UAAA,QAAQ,MAAM,UAAU,OAAO;AAC/B,UAAA,QAAQ,MAAM,UAAU,OAAO;AAE/B,UAAA,KAAK,wBAAwB,QAAQ;AAAA,MAC1C;AAAA,MACA;AAAA,MACA,qBAAqB,CAAC,MAAM,UAAU,KAAK;AAAA,IAAA,CAC3C;AAAA,EAAA;AAEH;"}
1
+ {"version":3,"file":"MigrationExecuteCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationExecuteCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationExecutionFacade } from '../../lib/migrations/MigrationExecutionFacade'\n\ntype Args = {}\n\ntype Options = {\n\tuntil?: string\n\tforce: boolean\n\tyes?: boolean\n}\n\nexport class MigrationExecuteCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationExecutorFacade: MigrationExecutionFacade,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Executes migrations on Contember server.')\n\t\tconfiguration.option('force')\n\t\t\t.description('Ignore migrations order and missing migrations (dev only)')\n\t\tconfiguration.option('until')\n\t\t\t.valueRequired()\n\t\t\t.description('Execute all migrations leading up to, and inclusive of, a specified migration')\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst force = input.getOption('force')\n\t\tconst until = input.getOption('until')\n\n\t\tawait this.migrationExecutorFacade.execute({\n\t\t\tforce,\n\t\t\tuntil,\n\t\t\trequireConfirmation: !input.getOption('yes'),\n\t\t})\n\t}\n}\n"],"names":[],"mappings":";AAWO,MAAM,gCAAgC,QAAuB;AAAA,EACnE,YACkB,yBAChB;AACD,UAAA;AAFiB,SAAA,0BAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,0CAA0C;AACpE,kBAAc,OAAO,OAAO,EAC1B,YAAY,2DAA2D;AACzE,kBAAc,OAAO,OAAO,EAC1B,cAAA,EACA,YAAY,+EAA+E;AAC7F,kBACE,OAAO,KAAK,EACZ,UAAA,EACA,YAAY,8BAA8B;AAAA,EAC7C;AAAA,EAEA,MAAgB,QAAQ,OAA4C;AACnE,UAAM,QAAQ,MAAM,UAAU,OAAO;AACrC,UAAM,QAAQ,MAAM,UAAU,OAAO;AAErC,UAAM,KAAK,wBAAwB,QAAQ;AAAA,MAC1C;AAAA,MACA;AAAA,MACA,qBAAqB,CAAC,MAAM,UAAU,KAAK;AAAA,IAAA,CAC3C;AAAA,EACF;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationRebaseCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationRebaseCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { Migration, MigrationsResolver } from '@contember/migrations-client'\nimport { MigrationRebaseFacade } from '../../lib/migrations/MigrationRebaseFacade'\n\ntype Args = {\n\tmigration: string[]\n}\n\ntype Options = {\n\tyes?: true\n}\n\nexport class MigrationRebaseCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly migrationRebaseFacade: MigrationRebaseFacade,\n\t) {\n\t\tsuper()\n\t}\n\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Rebase migrations on filesystem and in local instance')\n\t\tconfiguration.argument('migration').variadic()\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\n\t\tconst migrationNames = input.getArgument('migration')\n\n\t\tconst migrations: Migration[] = []\n\t\tfor (const migrationName of migrationNames) {\n\t\t\tconst migration = await this.migrationsResolver.findSchemaMigrationByVersion(migrationName)\n\t\t\tif (!migration) {\n\t\t\t\tthrow `Migration ${migrationName} not found`\n\t\t\t}\n\t\t\tmigrations.push(migration)\n\t\t}\n\n\t\tconsole.log('Rebasing: ' + migrations.map(it => it.name).join(', '))\n\t\tawait this.migrationRebaseFacade.rebase(migrations)\n\t\tconsole.log('Done')\n\t}\n}\n"],"names":["Command"],"mappings":";;;AAYO,MAAM,+BAA+BA,UAAAA,QAAuB;AAAA,EAClE,YACkB,oBACA,uBAChB;AACK,UAAA;AAHW,SAAA,qBAAA;AACA,SAAA,wBAAA;AAAA,EAAA;AAAA,EAMR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,uDAAuD;AACnE,kBAAA,SAAS,WAAW,EAAE,SAAS;AAC7C,kBACE,OAAO,KAAK,EACZ,UAAU,EACV,YAAY,8BAA8B;AAAA,EAAA;AAAA,EAG7C,MAAgB,QAAQ,OAA4C;AAE7D,UAAA,iBAAiB,MAAM,YAAY,WAAW;AAEpD,UAAM,aAA0B,CAAC;AACjC,eAAW,iBAAiB,gBAAgB;AAC3C,YAAM,YAAY,MAAM,KAAK,mBAAmB,6BAA6B,aAAa;AAC1F,UAAI,CAAC,WAAW;AACf,cAAM,aAAa,aAAa;AAAA,MAAA;AAEjC,iBAAW,KAAK,SAAS;AAAA,IAAA;AAGlB,YAAA,IAAI,eAAe,WAAW,IAAI,CAAA,OAAM,GAAG,IAAI,EAAE,KAAK,IAAI,CAAC;AAC7D,UAAA,KAAK,sBAAsB,OAAO,UAAU;AAClD,YAAQ,IAAI,MAAM;AAAA,EAAA;AAEpB;;"}
1
+ {"version":3,"file":"MigrationRebaseCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationRebaseCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { Migration, MigrationsResolver } from '@contember/migrations-client'\nimport { MigrationRebaseFacade } from '../../lib/migrations/MigrationRebaseFacade'\n\ntype Args = {\n\tmigration: string[]\n}\n\ntype Options = {\n\tyes?: true\n}\n\nexport class MigrationRebaseCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly migrationRebaseFacade: MigrationRebaseFacade,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Rebase migrations on filesystem and in local instance')\n\t\tconfiguration.argument('migration').variadic()\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst migrationNames = input.getArgument('migration')\n\n\t\tconst migrations: Migration[] = []\n\t\tfor (const migrationName of migrationNames) {\n\t\t\tconst migration = await this.migrationsResolver.findSchemaMigrationByVersion(migrationName)\n\t\t\tif (!migration) {\n\t\t\t\tthrow `Migration ${migrationName} not found`\n\t\t\t}\n\t\t\tmigrations.push(migration)\n\t\t}\n\n\t\tconsole.log('Rebasing: ' + migrations.map(it => it.name).join(', '))\n\t\tawait this.migrationRebaseFacade.rebase(migrations)\n\t\tconsole.log('Done')\n\t}\n}\n"],"names":["Command"],"mappings":";;;AAYO,MAAM,+BAA+BA,UAAAA,QAAuB;AAAA,EAClE,YACkB,oBACA,uBAChB;AACD,UAAA;AAHiB,SAAA,qBAAA;AACA,SAAA,wBAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,uDAAuD;AACjF,kBAAc,SAAS,WAAW,EAAE,SAAA;AACpC,kBACE,OAAO,KAAK,EACZ,UAAA,EACA,YAAY,8BAA8B;AAAA,EAC7C;AAAA,EAEA,MAAgB,QAAQ,OAA4C;AACnE,UAAM,iBAAiB,MAAM,YAAY,WAAW;AAEpD,UAAM,aAA0B,CAAA;AAChC,eAAW,iBAAiB,gBAAgB;AAC3C,YAAM,YAAY,MAAM,KAAK,mBAAmB,6BAA6B,aAAa;AAC1F,UAAI,CAAC,WAAW;AACf,cAAM,aAAa,aAAa;AAAA,MACjC;AACA,iBAAW,KAAK,SAAS;AAAA,IAC1B;AAEA,YAAQ,IAAI,eAAe,WAAW,IAAI,CAAA,OAAM,GAAG,IAAI,EAAE,KAAK,IAAI,CAAC;AACnE,UAAM,KAAK,sBAAsB,OAAO,UAAU;AAClD,YAAQ,IAAI,MAAM;AAAA,EACnB;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationRebaseCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationRebaseCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { Migration, MigrationsResolver } from '@contember/migrations-client'\nimport { MigrationRebaseFacade } from '../../lib/migrations/MigrationRebaseFacade'\n\ntype Args = {\n\tmigration: string[]\n}\n\ntype Options = {\n\tyes?: true\n}\n\nexport class MigrationRebaseCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly migrationRebaseFacade: MigrationRebaseFacade,\n\t) {\n\t\tsuper()\n\t}\n\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Rebase migrations on filesystem and in local instance')\n\t\tconfiguration.argument('migration').variadic()\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\n\t\tconst migrationNames = input.getArgument('migration')\n\n\t\tconst migrations: Migration[] = []\n\t\tfor (const migrationName of migrationNames) {\n\t\t\tconst migration = await this.migrationsResolver.findSchemaMigrationByVersion(migrationName)\n\t\t\tif (!migration) {\n\t\t\t\tthrow `Migration ${migrationName} not found`\n\t\t\t}\n\t\t\tmigrations.push(migration)\n\t\t}\n\n\t\tconsole.log('Rebasing: ' + migrations.map(it => it.name).join(', '))\n\t\tawait this.migrationRebaseFacade.rebase(migrations)\n\t\tconsole.log('Done')\n\t}\n}\n"],"names":[],"mappings":";AAYO,MAAM,+BAA+B,QAAuB;AAAA,EAClE,YACkB,oBACA,uBAChB;AACK,UAAA;AAHW,SAAA,qBAAA;AACA,SAAA,wBAAA;AAAA,EAAA;AAAA,EAMR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,uDAAuD;AACnE,kBAAA,SAAS,WAAW,EAAE,SAAS;AAC7C,kBACE,OAAO,KAAK,EACZ,UAAU,EACV,YAAY,8BAA8B;AAAA,EAAA;AAAA,EAG7C,MAAgB,QAAQ,OAA4C;AAE7D,UAAA,iBAAiB,MAAM,YAAY,WAAW;AAEpD,UAAM,aAA0B,CAAC;AACjC,eAAW,iBAAiB,gBAAgB;AAC3C,YAAM,YAAY,MAAM,KAAK,mBAAmB,6BAA6B,aAAa;AAC1F,UAAI,CAAC,WAAW;AACf,cAAM,aAAa,aAAa;AAAA,MAAA;AAEjC,iBAAW,KAAK,SAAS;AAAA,IAAA;AAGlB,YAAA,IAAI,eAAe,WAAW,IAAI,CAAA,OAAM,GAAG,IAAI,EAAE,KAAK,IAAI,CAAC;AAC7D,UAAA,KAAK,sBAAsB,OAAO,UAAU;AAClD,YAAQ,IAAI,MAAM;AAAA,EAAA;AAEpB;"}
1
+ {"version":3,"file":"MigrationRebaseCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationRebaseCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { Migration, MigrationsResolver } from '@contember/migrations-client'\nimport { MigrationRebaseFacade } from '../../lib/migrations/MigrationRebaseFacade'\n\ntype Args = {\n\tmigration: string[]\n}\n\ntype Options = {\n\tyes?: true\n}\n\nexport class MigrationRebaseCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly migrationRebaseFacade: MigrationRebaseFacade,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Rebase migrations on filesystem and in local instance')\n\t\tconfiguration.argument('migration').variadic()\n\t\tconfiguration //\n\t\t\t.option('yes')\n\t\t\t.valueNone()\n\t\t\t.description('Do not ask for confirmation.')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<void> {\n\t\tconst migrationNames = input.getArgument('migration')\n\n\t\tconst migrations: Migration[] = []\n\t\tfor (const migrationName of migrationNames) {\n\t\t\tconst migration = await this.migrationsResolver.findSchemaMigrationByVersion(migrationName)\n\t\t\tif (!migration) {\n\t\t\t\tthrow `Migration ${migrationName} not found`\n\t\t\t}\n\t\t\tmigrations.push(migration)\n\t\t}\n\n\t\tconsole.log('Rebasing: ' + migrations.map(it => it.name).join(', '))\n\t\tawait this.migrationRebaseFacade.rebase(migrations)\n\t\tconsole.log('Done')\n\t}\n}\n"],"names":[],"mappings":";AAYO,MAAM,+BAA+B,QAAuB;AAAA,EAClE,YACkB,oBACA,uBAChB;AACD,UAAA;AAHiB,SAAA,qBAAA;AACA,SAAA,wBAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,uDAAuD;AACjF,kBAAc,SAAS,WAAW,EAAE,SAAA;AACpC,kBACE,OAAO,KAAK,EACZ,UAAA,EACA,YAAY,8BAA8B;AAAA,EAC7C;AAAA,EAEA,MAAgB,QAAQ,OAA4C;AACnE,UAAM,iBAAiB,MAAM,YAAY,WAAW;AAEpD,UAAM,aAA0B,CAAA;AAChC,eAAW,iBAAiB,gBAAgB;AAC3C,YAAM,YAAY,MAAM,KAAK,mBAAmB,6BAA6B,aAAa;AAC1F,UAAI,CAAC,WAAW;AACf,cAAM,aAAa,aAAa;AAAA,MACjC;AACA,iBAAW,KAAK,SAAS;AAAA,IAC1B;AAEA,YAAQ,IAAI,eAAe,WAAW,IAAI,CAAA,OAAM,GAAG,IAAI,EAAE,KAAK,IAAI,CAAC;AACnE,UAAM,KAAK,sBAAsB,OAAO,UAAU;AAClD,YAAQ,IAAI,MAAM;AAAA,EACnB;AACD;"}
@@ -45,7 +45,7 @@ class MigrationStatusCommand extends cliCommon.Command {
45
45
  ...onlyErrors ? status.errorMigrations : [],
46
46
  ...onlyToExecute ? status.migrationsToExecute : []
47
47
  ]) : status.allMigrations;
48
- this.migrationPrinter.printStatusTable(filtered);
48
+ console.log(this.migrationPrinter.printStatusTable(filtered));
49
49
  const hasErrors = status.errorMigrations.length > 0;
50
50
  if (hasErrors) {
51
51
  console.error(chalk.redBright("Some migrations are broken"));
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationStatusCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationStatusCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationFilesManager, MigrationState, sortMigrations, SystemClient } from '@contember/migrations-client'\nimport chalk from 'chalk'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {\n}\n\ntype Options = {\n\t['only-to-execute']?: true\n\t['only-errors']?: true\n\t['restore-missing']?: true\n}\n\nexport class MigrationStatusCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly migrationFilesManager: MigrationFilesManager,\n\t\tprivate readonly systemClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Shows status of executed migrations on an instance & sync status')\n\t\tconfiguration //\n\t\t\t.option('only-errors')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations with an error.')\n\t\tconfiguration //\n\t\t\t.option('only-to-execute')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations to execute.')\n\t\tconfiguration //\n\t\t\t.option('restore-missing')\n\t\t\t.valueNone()\n\t\t\t.description('Restores migrations locally missing')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\n\t\tconst onlyErrors = input.getOption('only-errors')\n\t\tconst onlyToExecute = input.getOption('only-to-execute')\n\t\tconst restoreMissing = input.getOption('restore-missing')\n\n\t\tlet status = await this.migrationsStatusFacade.resolveMigrationsStatus({ allowError: true })\n\n\t\tif (restoreMissing) {\n\t\t\tconst missing = status.errorMigrations.filter(it => it.state === MigrationState.EXECUTED_MISSING)\n\t\t\tfor (const migration of missing) {\n\t\t\t\tconsole.log(`Restoring migration ${migration.name}`)\n\t\t\t\tconst fullMigration = await this.systemClientProvider.get().getExecutedMigration(migration.version)\n\t\t\t\tawait this.migrationFilesManager.createFile(\n\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tformatVersion: fullMigration.formatVersion,\n\t\t\t\t\t\t\tmodifications: fullMigration.modifications,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t'\\t',\n\t\t\t\t\t) + '\\n',\n\t\t\t\t\tfullMigration.name,\n\t\t\t\t)\n\t\t\t}\n\t\t\tstatus = await this.migrationsStatusFacade.resolveMigrationsStatus({})\n\t\t}\n\n\n\n\t\tconst filtered =\n\t\t\tonlyErrors || onlyToExecute\n\t\t\t\t? sortMigrations([\n\t\t\t\t\t...(onlyErrors ? status.errorMigrations : []),\n\t\t\t\t\t...(onlyToExecute ? status.migrationsToExecute : []),\n\t\t\t\t ])\n\t\t\t\t: status.allMigrations\n\n\t\tthis.migrationPrinter.printStatusTable(filtered)\n\n\t\tconst hasErrors = status.errorMigrations.length > 0\n\n\t\tif (hasErrors) {\n\t\t\tconsole.error(chalk.redBright('Some migrations are broken'))\n\t\t}\n\n\t\treturn hasErrors ? 1 : 0\n\t}\n}\n"],"names":["Command","MigrationState","sortMigrations"],"mappings":";;;;;AAgBO,MAAM,+BAA+BA,UAAAA,QAAuB;AAAA,EAClE,YACkB,wBACA,uBACA,sBACA,kBAChB;AACK,UAAA;AALW,SAAA,yBAAA;AACA,SAAA,wBAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kEAAkE;AAC5F,kBACE,OAAO,aAAa,EACpB,UAAU,EACV,YAAY,qCAAqC;AACnD,kBACE,OAAO,iBAAiB,EACxB,UAAU,EACV,YAAY,kCAAkC;AAChD,kBACE,OAAO,iBAAiB,EACxB,UAAU,EACV,YAAY,qCAAqC;AAAA,EAAA;AAAA,EAGpD,MAAgB,QAAQ,OAA8C;AAE/D,UAAA,aAAa,MAAM,UAAU,aAAa;AAC1C,UAAA,gBAAgB,MAAM,UAAU,iBAAiB;AACjD,UAAA,iBAAiB,MAAM,UAAU,iBAAiB;AAEpD,QAAA,SAAS,MAAM,KAAK,uBAAuB,wBAAwB,EAAE,YAAY,MAAM;AAE3F,QAAI,gBAAgB;AACb,YAAA,UAAU,OAAO,gBAAgB,OAAO,QAAM,GAAG,UAAUC,gCAAe,gBAAgB;AAChG,iBAAW,aAAa,SAAS;AAChC,gBAAQ,IAAI,uBAAuB,UAAU,IAAI,EAAE;AAC7C,cAAA,gBAAgB,MAAM,KAAK,qBAAqB,MAAM,qBAAqB,UAAU,OAAO;AAClG,cAAM,KAAK,sBAAsB;AAAA,UAChC,KAAK;AAAA,YACJ;AAAA,cACC,eAAe,cAAc;AAAA,cAC7B,eAAe,cAAc;AAAA,YAC9B;AAAA,YACA;AAAA,YACA;AAAA,UAAA,IACG;AAAA,UACJ,cAAc;AAAA,QACf;AAAA,MAAA;AAED,eAAS,MAAM,KAAK,uBAAuB,wBAAwB,CAAA,CAAE;AAAA,IAAA;AAKhE,UAAA,WACL,cAAc,gBACXC,gCAAe;AAAA,MAChB,GAAI,aAAa,OAAO,kBAAkB,CAAC;AAAA,MAC3C,GAAI,gBAAgB,OAAO,sBAAsB,CAAA;AAAA,IAAC,CAChD,IACD,OAAO;AAEN,SAAA,iBAAiB,iBAAiB,QAAQ;AAEzC,UAAA,YAAY,OAAO,gBAAgB,SAAS;AAElD,QAAI,WAAW;AACd,cAAQ,MAAM,MAAM,UAAU,4BAA4B,CAAC;AAAA,IAAA;AAG5D,WAAO,YAAY,IAAI;AAAA,EAAA;AAEzB;;"}
1
+ {"version":3,"file":"MigrationStatusCommand.cjs","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationStatusCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationFilesManager, MigrationState, sortMigrations, SystemClient } from '@contember/migrations-client'\nimport chalk from 'chalk'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {}\n\ntype Options = {\n\t['only-to-execute']?: true\n\t['only-errors']?: true\n\t['restore-missing']?: true\n}\n\nexport class MigrationStatusCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly migrationFilesManager: MigrationFilesManager,\n\t\tprivate readonly systemClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Shows status of executed migrations on an instance & sync status')\n\t\tconfiguration //\n\t\t\t.option('only-errors')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations with an error.')\n\t\tconfiguration //\n\t\t\t.option('only-to-execute')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations to execute.')\n\t\tconfiguration //\n\t\t\t.option('restore-missing')\n\t\t\t.valueNone()\n\t\t\t.description('Restores migrations locally missing')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst onlyErrors = input.getOption('only-errors')\n\t\tconst onlyToExecute = input.getOption('only-to-execute')\n\t\tconst restoreMissing = input.getOption('restore-missing')\n\n\t\tlet status = await this.migrationsStatusFacade.resolveMigrationsStatus({ allowError: true })\n\n\t\tif (restoreMissing) {\n\t\t\tconst missing = status.errorMigrations.filter(it => it.state === MigrationState.EXECUTED_MISSING)\n\t\t\tfor (const migration of missing) {\n\t\t\t\tconsole.log(`Restoring migration ${migration.name}`)\n\t\t\t\tconst fullMigration = await this.systemClientProvider.get().getExecutedMigration(migration.version)\n\t\t\t\tawait this.migrationFilesManager.createFile(\n\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tformatVersion: fullMigration.formatVersion,\n\t\t\t\t\t\t\tmodifications: fullMigration.modifications,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t'\\t',\n\t\t\t\t\t) + '\\n',\n\t\t\t\t\tfullMigration.name,\n\t\t\t\t)\n\t\t\t}\n\t\t\tstatus = await this.migrationsStatusFacade.resolveMigrationsStatus({})\n\t\t}\n\n\t\tconst filtered = onlyErrors || onlyToExecute\n\t\t\t? sortMigrations([\n\t\t\t\t...(onlyErrors ? status.errorMigrations : []),\n\t\t\t\t...(onlyToExecute ? status.migrationsToExecute : []),\n\t\t\t])\n\t\t\t: status.allMigrations\n\n\t\tconsole.log(this.migrationPrinter.printStatusTable(filtered))\n\n\t\tconst hasErrors = status.errorMigrations.length > 0\n\n\t\tif (hasErrors) {\n\t\t\tconsole.error(chalk.redBright('Some migrations are broken'))\n\t\t}\n\n\t\treturn hasErrors ? 1 : 0\n\t}\n}\n"],"names":["Command","MigrationState","sortMigrations"],"mappings":";;;;;AAeO,MAAM,+BAA+BA,UAAAA,QAAuB;AAAA,EAClE,YACkB,wBACA,uBACA,sBACA,kBAChB;AACD,UAAA;AALiB,SAAA,yBAAA;AACA,SAAA,wBAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kEAAkE;AAC5F,kBACE,OAAO,aAAa,EACpB,UAAA,EACA,YAAY,qCAAqC;AACnD,kBACE,OAAO,iBAAiB,EACxB,UAAA,EACA,YAAY,kCAAkC;AAChD,kBACE,OAAO,iBAAiB,EACxB,UAAA,EACA,YAAY,qCAAqC;AAAA,EACpD;AAAA,EAEA,MAAgB,QAAQ,OAA8C;AACrE,UAAM,aAAa,MAAM,UAAU,aAAa;AAChD,UAAM,gBAAgB,MAAM,UAAU,iBAAiB;AACvD,UAAM,iBAAiB,MAAM,UAAU,iBAAiB;AAExD,QAAI,SAAS,MAAM,KAAK,uBAAuB,wBAAwB,EAAE,YAAY,MAAM;AAE3F,QAAI,gBAAgB;AACnB,YAAM,UAAU,OAAO,gBAAgB,OAAO,QAAM,GAAG,UAAUC,iBAAAA,eAAe,gBAAgB;AAChG,iBAAW,aAAa,SAAS;AAChC,gBAAQ,IAAI,uBAAuB,UAAU,IAAI,EAAE;AACnD,cAAM,gBAAgB,MAAM,KAAK,qBAAqB,MAAM,qBAAqB,UAAU,OAAO;AAClG,cAAM,KAAK,sBAAsB;AAAA,UAChC,KAAK;AAAA,YACJ;AAAA,cACC,eAAe,cAAc;AAAA,cAC7B,eAAe,cAAc;AAAA,YAAA;AAAA,YAE9B;AAAA,YACA;AAAA,UAAA,IACG;AAAA,UACJ,cAAc;AAAA,QAAA;AAAA,MAEhB;AACA,eAAS,MAAM,KAAK,uBAAuB,wBAAwB,CAAA,CAAE;AAAA,IACtE;AAEA,UAAM,WAAW,cAAc,gBAC5BC,gCAAe;AAAA,MAChB,GAAI,aAAa,OAAO,kBAAkB,CAAA;AAAA,MAC1C,GAAI,gBAAgB,OAAO,sBAAsB,CAAA;AAAA,IAAC,CAClD,IACC,OAAO;AAEV,YAAQ,IAAI,KAAK,iBAAiB,iBAAiB,QAAQ,CAAC;AAE5D,UAAM,YAAY,OAAO,gBAAgB,SAAS;AAElD,QAAI,WAAW;AACd,cAAQ,MAAM,MAAM,UAAU,4BAA4B,CAAC;AAAA,IAC5D;AAEA,WAAO,YAAY,IAAI;AAAA,EACxB;AACD;;"}
@@ -43,7 +43,7 @@ class MigrationStatusCommand extends Command {
43
43
  ...onlyErrors ? status.errorMigrations : [],
44
44
  ...onlyToExecute ? status.migrationsToExecute : []
45
45
  ]) : status.allMigrations;
46
- this.migrationPrinter.printStatusTable(filtered);
46
+ console.log(this.migrationPrinter.printStatusTable(filtered));
47
47
  const hasErrors = status.errorMigrations.length > 0;
48
48
  if (hasErrors) {
49
49
  console.error(chalk.redBright("Some migrations are broken"));
@@ -1 +1 @@
1
- {"version":3,"file":"MigrationStatusCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationStatusCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationFilesManager, MigrationState, sortMigrations, SystemClient } from '@contember/migrations-client'\nimport chalk from 'chalk'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {\n}\n\ntype Options = {\n\t['only-to-execute']?: true\n\t['only-errors']?: true\n\t['restore-missing']?: true\n}\n\nexport class MigrationStatusCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly migrationFilesManager: MigrationFilesManager,\n\t\tprivate readonly systemClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Shows status of executed migrations on an instance & sync status')\n\t\tconfiguration //\n\t\t\t.option('only-errors')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations with an error.')\n\t\tconfiguration //\n\t\t\t.option('only-to-execute')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations to execute.')\n\t\tconfiguration //\n\t\t\t.option('restore-missing')\n\t\t\t.valueNone()\n\t\t\t.description('Restores migrations locally missing')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\n\t\tconst onlyErrors = input.getOption('only-errors')\n\t\tconst onlyToExecute = input.getOption('only-to-execute')\n\t\tconst restoreMissing = input.getOption('restore-missing')\n\n\t\tlet status = await this.migrationsStatusFacade.resolveMigrationsStatus({ allowError: true })\n\n\t\tif (restoreMissing) {\n\t\t\tconst missing = status.errorMigrations.filter(it => it.state === MigrationState.EXECUTED_MISSING)\n\t\t\tfor (const migration of missing) {\n\t\t\t\tconsole.log(`Restoring migration ${migration.name}`)\n\t\t\t\tconst fullMigration = await this.systemClientProvider.get().getExecutedMigration(migration.version)\n\t\t\t\tawait this.migrationFilesManager.createFile(\n\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tformatVersion: fullMigration.formatVersion,\n\t\t\t\t\t\t\tmodifications: fullMigration.modifications,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t'\\t',\n\t\t\t\t\t) + '\\n',\n\t\t\t\t\tfullMigration.name,\n\t\t\t\t)\n\t\t\t}\n\t\t\tstatus = await this.migrationsStatusFacade.resolveMigrationsStatus({})\n\t\t}\n\n\n\n\t\tconst filtered =\n\t\t\tonlyErrors || onlyToExecute\n\t\t\t\t? sortMigrations([\n\t\t\t\t\t...(onlyErrors ? status.errorMigrations : []),\n\t\t\t\t\t...(onlyToExecute ? status.migrationsToExecute : []),\n\t\t\t\t ])\n\t\t\t\t: status.allMigrations\n\n\t\tthis.migrationPrinter.printStatusTable(filtered)\n\n\t\tconst hasErrors = status.errorMigrations.length > 0\n\n\t\tif (hasErrors) {\n\t\t\tconsole.error(chalk.redBright('Some migrations are broken'))\n\t\t}\n\n\t\treturn hasErrors ? 1 : 0\n\t}\n}\n"],"names":[],"mappings":";;;AAgBO,MAAM,+BAA+B,QAAuB;AAAA,EAClE,YACkB,wBACA,uBACA,sBACA,kBAChB;AACK,UAAA;AALW,SAAA,yBAAA;AACA,SAAA,wBAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kEAAkE;AAC5F,kBACE,OAAO,aAAa,EACpB,UAAU,EACV,YAAY,qCAAqC;AACnD,kBACE,OAAO,iBAAiB,EACxB,UAAU,EACV,YAAY,kCAAkC;AAChD,kBACE,OAAO,iBAAiB,EACxB,UAAU,EACV,YAAY,qCAAqC;AAAA,EAAA;AAAA,EAGpD,MAAgB,QAAQ,OAA8C;AAE/D,UAAA,aAAa,MAAM,UAAU,aAAa;AAC1C,UAAA,gBAAgB,MAAM,UAAU,iBAAiB;AACjD,UAAA,iBAAiB,MAAM,UAAU,iBAAiB;AAEpD,QAAA,SAAS,MAAM,KAAK,uBAAuB,wBAAwB,EAAE,YAAY,MAAM;AAE3F,QAAI,gBAAgB;AACb,YAAA,UAAU,OAAO,gBAAgB,OAAO,QAAM,GAAG,UAAU,eAAe,gBAAgB;AAChG,iBAAW,aAAa,SAAS;AAChC,gBAAQ,IAAI,uBAAuB,UAAU,IAAI,EAAE;AAC7C,cAAA,gBAAgB,MAAM,KAAK,qBAAqB,MAAM,qBAAqB,UAAU,OAAO;AAClG,cAAM,KAAK,sBAAsB;AAAA,UAChC,KAAK;AAAA,YACJ;AAAA,cACC,eAAe,cAAc;AAAA,cAC7B,eAAe,cAAc;AAAA,YAC9B;AAAA,YACA;AAAA,YACA;AAAA,UAAA,IACG;AAAA,UACJ,cAAc;AAAA,QACf;AAAA,MAAA;AAED,eAAS,MAAM,KAAK,uBAAuB,wBAAwB,CAAA,CAAE;AAAA,IAAA;AAKhE,UAAA,WACL,cAAc,gBACX,eAAe;AAAA,MAChB,GAAI,aAAa,OAAO,kBAAkB,CAAC;AAAA,MAC3C,GAAI,gBAAgB,OAAO,sBAAsB,CAAA;AAAA,IAAC,CAChD,IACD,OAAO;AAEN,SAAA,iBAAiB,iBAAiB,QAAQ;AAEzC,UAAA,YAAY,OAAO,gBAAgB,SAAS;AAElD,QAAI,WAAW;AACd,cAAQ,MAAM,MAAM,UAAU,4BAA4B,CAAC;AAAA,IAAA;AAG5D,WAAO,YAAY,IAAI;AAAA,EAAA;AAEzB;"}
1
+ {"version":3,"file":"MigrationStatusCommand.js","sources":["../../../../../../packages/cli/src/commands/migrations/MigrationStatusCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { MigrationFilesManager, MigrationState, sortMigrations, SystemClient } from '@contember/migrations-client'\nimport chalk from 'chalk'\nimport { MigrationsStatusFacade } from '../../lib/migrations/MigrationsStatusFacade'\nimport { MigrationPrinter } from '../../lib/migrations/MigrationPrinter'\nimport { SystemClientProvider } from '../../lib/SystemClientProvider'\n\ntype Args = {}\n\ntype Options = {\n\t['only-to-execute']?: true\n\t['only-errors']?: true\n\t['restore-missing']?: true\n}\n\nexport class MigrationStatusCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly migrationsStatusFacade: MigrationsStatusFacade,\n\t\tprivate readonly migrationFilesManager: MigrationFilesManager,\n\t\tprivate readonly systemClientProvider: SystemClientProvider,\n\t\tprivate readonly migrationPrinter: MigrationPrinter,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Shows status of executed migrations on an instance & sync status')\n\t\tconfiguration //\n\t\t\t.option('only-errors')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations with an error.')\n\t\tconfiguration //\n\t\t\t.option('only-to-execute')\n\t\t\t.valueNone()\n\t\t\t.description('Show only migrations to execute.')\n\t\tconfiguration //\n\t\t\t.option('restore-missing')\n\t\t\t.valueNone()\n\t\t\t.description('Restores migrations locally missing')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst onlyErrors = input.getOption('only-errors')\n\t\tconst onlyToExecute = input.getOption('only-to-execute')\n\t\tconst restoreMissing = input.getOption('restore-missing')\n\n\t\tlet status = await this.migrationsStatusFacade.resolveMigrationsStatus({ allowError: true })\n\n\t\tif (restoreMissing) {\n\t\t\tconst missing = status.errorMigrations.filter(it => it.state === MigrationState.EXECUTED_MISSING)\n\t\t\tfor (const migration of missing) {\n\t\t\t\tconsole.log(`Restoring migration ${migration.name}`)\n\t\t\t\tconst fullMigration = await this.systemClientProvider.get().getExecutedMigration(migration.version)\n\t\t\t\tawait this.migrationFilesManager.createFile(\n\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tformatVersion: fullMigration.formatVersion,\n\t\t\t\t\t\t\tmodifications: fullMigration.modifications,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t'\\t',\n\t\t\t\t\t) + '\\n',\n\t\t\t\t\tfullMigration.name,\n\t\t\t\t)\n\t\t\t}\n\t\t\tstatus = await this.migrationsStatusFacade.resolveMigrationsStatus({})\n\t\t}\n\n\t\tconst filtered = onlyErrors || onlyToExecute\n\t\t\t? sortMigrations([\n\t\t\t\t...(onlyErrors ? status.errorMigrations : []),\n\t\t\t\t...(onlyToExecute ? status.migrationsToExecute : []),\n\t\t\t])\n\t\t\t: status.allMigrations\n\n\t\tconsole.log(this.migrationPrinter.printStatusTable(filtered))\n\n\t\tconst hasErrors = status.errorMigrations.length > 0\n\n\t\tif (hasErrors) {\n\t\t\tconsole.error(chalk.redBright('Some migrations are broken'))\n\t\t}\n\n\t\treturn hasErrors ? 1 : 0\n\t}\n}\n"],"names":[],"mappings":";;;AAeO,MAAM,+BAA+B,QAAuB;AAAA,EAClE,YACkB,wBACA,uBACA,sBACA,kBAChB;AACD,UAAA;AALiB,SAAA,yBAAA;AACA,SAAA,wBAAA;AACA,SAAA,uBAAA;AACA,SAAA,mBAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kEAAkE;AAC5F,kBACE,OAAO,aAAa,EACpB,UAAA,EACA,YAAY,qCAAqC;AACnD,kBACE,OAAO,iBAAiB,EACxB,UAAA,EACA,YAAY,kCAAkC;AAChD,kBACE,OAAO,iBAAiB,EACxB,UAAA,EACA,YAAY,qCAAqC;AAAA,EACpD;AAAA,EAEA,MAAgB,QAAQ,OAA8C;AACrE,UAAM,aAAa,MAAM,UAAU,aAAa;AAChD,UAAM,gBAAgB,MAAM,UAAU,iBAAiB;AACvD,UAAM,iBAAiB,MAAM,UAAU,iBAAiB;AAExD,QAAI,SAAS,MAAM,KAAK,uBAAuB,wBAAwB,EAAE,YAAY,MAAM;AAE3F,QAAI,gBAAgB;AACnB,YAAM,UAAU,OAAO,gBAAgB,OAAO,QAAM,GAAG,UAAU,eAAe,gBAAgB;AAChG,iBAAW,aAAa,SAAS;AAChC,gBAAQ,IAAI,uBAAuB,UAAU,IAAI,EAAE;AACnD,cAAM,gBAAgB,MAAM,KAAK,qBAAqB,MAAM,qBAAqB,UAAU,OAAO;AAClG,cAAM,KAAK,sBAAsB;AAAA,UAChC,KAAK;AAAA,YACJ;AAAA,cACC,eAAe,cAAc;AAAA,cAC7B,eAAe,cAAc;AAAA,YAAA;AAAA,YAE9B;AAAA,YACA;AAAA,UAAA,IACG;AAAA,UACJ,cAAc;AAAA,QAAA;AAAA,MAEhB;AACA,eAAS,MAAM,KAAK,uBAAuB,wBAAwB,CAAA,CAAE;AAAA,IACtE;AAEA,UAAM,WAAW,cAAc,gBAC5B,eAAe;AAAA,MAChB,GAAI,aAAa,OAAO,kBAAkB,CAAA;AAAA,MAC1C,GAAI,gBAAgB,OAAO,sBAAsB,CAAA;AAAA,IAAC,CAClD,IACC,OAAO;AAEV,YAAQ,IAAI,KAAK,iBAAiB,iBAAiB,QAAQ,CAAC;AAE5D,UAAM,YAAY,OAAO,gBAAgB,SAAS;AAElD,QAAI,WAAW;AACd,cAAQ,MAAM,MAAM,UAAU,4BAA4B,CAAC;AAAA,IAC5D;AAEA,WAAO,YAAY,IAAI;AAAA,EACxB;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"VersionCommand.cjs","sources":["../../../../../../packages/cli/src/commands/misc/VersionCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration } from '@contember/cli-common'\n\nexport class VersionCommand extends Command<{}, {}> {\n\tconstructor(\n\t\tprivate readonly version: string,\n\t) {\n\t\tsuper()\n\t}\n\tprotected configure(configuration: CommandConfiguration<{}, {}>): void {\n\t\tconfiguration.description('Prints Contember CLI version')\n\t}\n\n\tprotected async execute(): Promise<void | number> {\n\t\tconsole.log(this.version)\n\t\treturn 0\n\t}\n}\n"],"names":["Command"],"mappings":";;;AAEO,MAAM,uBAAuBA,UAAAA,QAAgB;AAAA,EACnD,YACkB,SAChB;AACK,UAAA;AAFW,SAAA,UAAA;AAAA,EAAA;AAAA,EAIR,UAAU,eAAmD;AACtE,kBAAc,YAAY,8BAA8B;AAAA,EAAA;AAAA,EAGzD,MAAgB,UAAkC;AACzC,YAAA,IAAI,KAAK,OAAO;AACjB,WAAA;AAAA,EAAA;AAET;;"}
1
+ {"version":3,"file":"VersionCommand.cjs","sources":["../../../../../../packages/cli/src/commands/misc/VersionCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration } from '@contember/cli-common'\n\nexport class VersionCommand extends Command<{}, {}> {\n\tconstructor(\n\t\tprivate readonly version: string,\n\t) {\n\t\tsuper()\n\t}\n\tprotected configure(configuration: CommandConfiguration<{}, {}>): void {\n\t\tconfiguration.description('Prints Contember CLI version')\n\t}\n\n\tprotected async execute(): Promise<void | number> {\n\t\tconsole.log(this.version)\n\t\treturn 0\n\t}\n}\n"],"names":["Command"],"mappings":";;;AAEO,MAAM,uBAAuBA,UAAAA,QAAgB;AAAA,EACnD,YACkB,SAChB;AACD,UAAA;AAFiB,SAAA,UAAA;AAAA,EAGlB;AAAA,EACU,UAAU,eAAmD;AACtE,kBAAc,YAAY,8BAA8B;AAAA,EACzD;AAAA,EAEA,MAAgB,UAAkC;AACjD,YAAQ,IAAI,KAAK,OAAO;AACxB,WAAO;AAAA,EACR;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"VersionCommand.js","sources":["../../../../../../packages/cli/src/commands/misc/VersionCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration } from '@contember/cli-common'\n\nexport class VersionCommand extends Command<{}, {}> {\n\tconstructor(\n\t\tprivate readonly version: string,\n\t) {\n\t\tsuper()\n\t}\n\tprotected configure(configuration: CommandConfiguration<{}, {}>): void {\n\t\tconfiguration.description('Prints Contember CLI version')\n\t}\n\n\tprotected async execute(): Promise<void | number> {\n\t\tconsole.log(this.version)\n\t\treturn 0\n\t}\n}\n"],"names":[],"mappings":";AAEO,MAAM,uBAAuB,QAAgB;AAAA,EACnD,YACkB,SAChB;AACK,UAAA;AAFW,SAAA,UAAA;AAAA,EAAA;AAAA,EAIR,UAAU,eAAmD;AACtE,kBAAc,YAAY,8BAA8B;AAAA,EAAA;AAAA,EAGzD,MAAgB,UAAkC;AACzC,YAAA,IAAI,KAAK,OAAO;AACjB,WAAA;AAAA,EAAA;AAET;"}
1
+ {"version":3,"file":"VersionCommand.js","sources":["../../../../../../packages/cli/src/commands/misc/VersionCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration } from '@contember/cli-common'\n\nexport class VersionCommand extends Command<{}, {}> {\n\tconstructor(\n\t\tprivate readonly version: string,\n\t) {\n\t\tsuper()\n\t}\n\tprotected configure(configuration: CommandConfiguration<{}, {}>): void {\n\t\tconfiguration.description('Prints Contember CLI version')\n\t}\n\n\tprotected async execute(): Promise<void | number> {\n\t\tconsole.log(this.version)\n\t\treturn 0\n\t}\n}\n"],"names":[],"mappings":";AAEO,MAAM,uBAAuB,QAAgB;AAAA,EACnD,YACkB,SAChB;AACD,UAAA;AAFiB,SAAA,UAAA;AAAA,EAGlB;AAAA,EACU,UAAU,eAAmD;AACtE,kBAAc,YAAY,8BAA8B;AAAA,EACzD;AAAA,EAEA,MAAgB,UAAkC;AACjD,YAAQ,IAAI,KAAK,OAAO;AACxB,WAAO;AAAA,EACR;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectGenerateDocumentationCommand.cjs","sources":["../../../../../../packages/cli/src/commands/project/ProjectGenerateDocumentationCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { renderProjectInfoHtml } from '../../lib/project/docs/projectDescribe'\nimport { writeFile } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { validateSchemaAndPrintErrors } from '../../lib/schema/SchemaValidationHelper'\nimport { SchemaVersionBuilder } from '@contember/migrations-client'\n\ntype Args = {\n}\n\ntype Options = {\n\tsource?: 'migrations' | 'definition'\n\tname?: string\n\toutput?: string\n}\n\nexport class ProjectGenerateDocumentationCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Generates HTML documentation from project schema')\n\t\tconfiguration.option('source').valueRequired().description('migrations|definition')\n\t\tconfiguration.option('output').valueRequired().description('file name or \"-\" for stdout')\n\t\tconfiguration.option('name').valueRequired().description('project name (for the title)')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst schema = input.getOption('source') === 'migrations'\n\t\t\t? await this.schemaVersionBuilder.buildSchema()\n\t\t\t: await this.schemaLoader.loadSchema()\n\t\tif (!validateSchemaAndPrintErrors(schema, 'Defined schema is invalid:')) {\n\t\t\treturn 1\n\t\t}\n\t\tconst name = input.getOption('name') ?? 'Contember project'\n\n\t\tconst html = await renderProjectInfoHtml(schema, name)\n\t\tconst output = input.getOption('output') ?? `${name.toLowerCase().replace(/\\s+/g, '-')}.html`\n\t\tif (output === '-') {\n\t\t\tconsole.log(html)\n\t\t} else {\n\t\t\tconsole.log(`Documentation saved to ${output}`)\n\t\t\tawait writeFile(join(process.cwd(), output), html)\n\t\t}\n\n\t\treturn 0\n\t}\n}\n"],"names":["Command","validateSchemaAndPrintErrors","renderProjectInfoHtml","writeFile","join"],"mappings":";;;;;;;AAiBO,MAAM,4CAA4CA,UAAAA,QAAuB;AAAA,EAC/E,YACkB,cACA,sBAChB;AACK,UAAA;AAHW,SAAA,eAAA;AACA,SAAA,uBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kDAAkD;AAC5E,kBAAc,OAAO,QAAQ,EAAE,cAAc,EAAE,YAAY,uBAAuB;AAClF,kBAAc,OAAO,QAAQ,EAAE,cAAc,EAAE,YAAY,6BAA6B;AACxF,kBAAc,OAAO,MAAM,EAAE,cAAc,EAAE,YAAY,8BAA8B;AAAA,EAAA;AAAA,EAGxF,MAAgB,QAAQ,OAA8C;AACrE,UAAM,SAAS,MAAM,UAAU,QAAQ,MAAM,eAC1C,MAAM,KAAK,qBAAqB,YAAY,IAC5C,MAAM,KAAK,aAAa,WAAW;AACtC,QAAI,CAACC,uBAAA,6BAA6B,QAAQ,4BAA4B,GAAG;AACjE,aAAA;AAAA,IAAA;AAER,UAAM,OAAO,MAAM,UAAU,MAAM,KAAK;AAExC,UAAM,OAAO,MAAMC,sCAAsB,QAAQ,IAAI;AACrD,UAAM,SAAS,MAAM,UAAU,QAAQ,KAAK,GAAG,KAAK,YAAc,EAAA,QAAQ,QAAQ,GAAG,CAAC;AACtF,QAAI,WAAW,KAAK;AACnB,cAAQ,IAAI,IAAI;AAAA,IAAA,OACV;AACE,cAAA,IAAI,0BAA0B,MAAM,EAAE;AAC9C,YAAMC,GAAAA,UAAUC,UAAAA,KAAK,QAAQ,OAAO,MAAM,GAAG,IAAI;AAAA,IAAA;AAG3C,WAAA;AAAA,EAAA;AAET;;"}
1
+ {"version":3,"file":"ProjectGenerateDocumentationCommand.cjs","sources":["../../../../../../packages/cli/src/commands/project/ProjectGenerateDocumentationCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { renderProjectInfoHtml } from '../../lib/project/docs/projectDescribe'\nimport { writeFile } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { validateSchemaAndPrintErrors } from '../../lib/schema/SchemaValidationHelper'\nimport { SchemaVersionBuilder } from '@contember/migrations-client'\n\ntype Args = {}\n\ntype Options = {\n\tsource?: 'migrations' | 'definition'\n\tname?: string\n\toutput?: string\n}\n\nexport class ProjectGenerateDocumentationCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Generates HTML documentation from project schema')\n\t\tconfiguration.option('source').valueRequired().description('migrations|definition')\n\t\tconfiguration.option('output').valueRequired().description('file name or \"-\" for stdout')\n\t\tconfiguration.option('name').valueRequired().description('project name (for the title)')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst schema = input.getOption('source') === 'migrations'\n\t\t\t? await this.schemaVersionBuilder.buildSchema()\n\t\t\t: await this.schemaLoader.loadSchema()\n\t\tif (!validateSchemaAndPrintErrors(schema, 'Defined schema is invalid:')) {\n\t\t\treturn 1\n\t\t}\n\t\tconst name = input.getOption('name') ?? 'Contember project'\n\n\t\tconst html = await renderProjectInfoHtml(schema, name)\n\t\tconst output = input.getOption('output') ?? `${name.toLowerCase().replace(/\\s+/g, '-')}.html`\n\t\tif (output === '-') {\n\t\t\tconsole.log(html)\n\t\t} else {\n\t\t\tconsole.log(`Documentation saved to ${output}`)\n\t\t\tawait writeFile(join(process.cwd(), output), html)\n\t\t}\n\n\t\treturn 0\n\t}\n}\n"],"names":["Command","validateSchemaAndPrintErrors","renderProjectInfoHtml","writeFile","join"],"mappings":";;;;;;;AAgBO,MAAM,4CAA4CA,UAAAA,QAAuB;AAAA,EAC/E,YACkB,cACA,sBAChB;AACD,UAAA;AAHiB,SAAA,eAAA;AACA,SAAA,uBAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kDAAkD;AAC5E,kBAAc,OAAO,QAAQ,EAAE,cAAA,EAAgB,YAAY,uBAAuB;AAClF,kBAAc,OAAO,QAAQ,EAAE,cAAA,EAAgB,YAAY,6BAA6B;AACxF,kBAAc,OAAO,MAAM,EAAE,cAAA,EAAgB,YAAY,8BAA8B;AAAA,EACxF;AAAA,EAEA,MAAgB,QAAQ,OAA8C;AACrE,UAAM,SAAS,MAAM,UAAU,QAAQ,MAAM,eAC1C,MAAM,KAAK,qBAAqB,YAAA,IAChC,MAAM,KAAK,aAAa,WAAA;AAC3B,QAAI,CAACC,uBAAAA,6BAA6B,QAAQ,4BAA4B,GAAG;AACxE,aAAO;AAAA,IACR;AACA,UAAM,OAAO,MAAM,UAAU,MAAM,KAAK;AAExC,UAAM,OAAO,MAAMC,sCAAsB,QAAQ,IAAI;AACrD,UAAM,SAAS,MAAM,UAAU,QAAQ,KAAK,GAAG,KAAK,YAAA,EAAc,QAAQ,QAAQ,GAAG,CAAC;AACtF,QAAI,WAAW,KAAK;AACnB,cAAQ,IAAI,IAAI;AAAA,IACjB,OAAO;AACN,cAAQ,IAAI,0BAA0B,MAAM,EAAE;AAC9C,YAAMC,GAAAA,UAAUC,UAAAA,KAAK,QAAQ,OAAO,MAAM,GAAG,IAAI;AAAA,IAClD;AAEA,WAAO;AAAA,EACR;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectGenerateDocumentationCommand.js","sources":["../../../../../../packages/cli/src/commands/project/ProjectGenerateDocumentationCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { renderProjectInfoHtml } from '../../lib/project/docs/projectDescribe'\nimport { writeFile } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { validateSchemaAndPrintErrors } from '../../lib/schema/SchemaValidationHelper'\nimport { SchemaVersionBuilder } from '@contember/migrations-client'\n\ntype Args = {\n}\n\ntype Options = {\n\tsource?: 'migrations' | 'definition'\n\tname?: string\n\toutput?: string\n}\n\nexport class ProjectGenerateDocumentationCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Generates HTML documentation from project schema')\n\t\tconfiguration.option('source').valueRequired().description('migrations|definition')\n\t\tconfiguration.option('output').valueRequired().description('file name or \"-\" for stdout')\n\t\tconfiguration.option('name').valueRequired().description('project name (for the title)')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst schema = input.getOption('source') === 'migrations'\n\t\t\t? await this.schemaVersionBuilder.buildSchema()\n\t\t\t: await this.schemaLoader.loadSchema()\n\t\tif (!validateSchemaAndPrintErrors(schema, 'Defined schema is invalid:')) {\n\t\t\treturn 1\n\t\t}\n\t\tconst name = input.getOption('name') ?? 'Contember project'\n\n\t\tconst html = await renderProjectInfoHtml(schema, name)\n\t\tconst output = input.getOption('output') ?? `${name.toLowerCase().replace(/\\s+/g, '-')}.html`\n\t\tif (output === '-') {\n\t\t\tconsole.log(html)\n\t\t} else {\n\t\t\tconsole.log(`Documentation saved to ${output}`)\n\t\t\tawait writeFile(join(process.cwd(), output), html)\n\t\t}\n\n\t\treturn 0\n\t}\n}\n"],"names":[],"mappings":";;;;;AAiBO,MAAM,4CAA4C,QAAuB;AAAA,EAC/E,YACkB,cACA,sBAChB;AACK,UAAA;AAHW,SAAA,eAAA;AACA,SAAA,uBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kDAAkD;AAC5E,kBAAc,OAAO,QAAQ,EAAE,cAAc,EAAE,YAAY,uBAAuB;AAClF,kBAAc,OAAO,QAAQ,EAAE,cAAc,EAAE,YAAY,6BAA6B;AACxF,kBAAc,OAAO,MAAM,EAAE,cAAc,EAAE,YAAY,8BAA8B;AAAA,EAAA;AAAA,EAGxF,MAAgB,QAAQ,OAA8C;AACrE,UAAM,SAAS,MAAM,UAAU,QAAQ,MAAM,eAC1C,MAAM,KAAK,qBAAqB,YAAY,IAC5C,MAAM,KAAK,aAAa,WAAW;AACtC,QAAI,CAAC,6BAA6B,QAAQ,4BAA4B,GAAG;AACjE,aAAA;AAAA,IAAA;AAER,UAAM,OAAO,MAAM,UAAU,MAAM,KAAK;AAExC,UAAM,OAAO,MAAM,sBAAsB,QAAQ,IAAI;AACrD,UAAM,SAAS,MAAM,UAAU,QAAQ,KAAK,GAAG,KAAK,YAAc,EAAA,QAAQ,QAAQ,GAAG,CAAC;AACtF,QAAI,WAAW,KAAK;AACnB,cAAQ,IAAI,IAAI;AAAA,IAAA,OACV;AACE,cAAA,IAAI,0BAA0B,MAAM,EAAE;AAC9C,YAAM,UAAU,KAAK,QAAQ,OAAO,MAAM,GAAG,IAAI;AAAA,IAAA;AAG3C,WAAA;AAAA,EAAA;AAET;"}
1
+ {"version":3,"file":"ProjectGenerateDocumentationCommand.js","sources":["../../../../../../packages/cli/src/commands/project/ProjectGenerateDocumentationCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport { renderProjectInfoHtml } from '../../lib/project/docs/projectDescribe'\nimport { writeFile } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { validateSchemaAndPrintErrors } from '../../lib/schema/SchemaValidationHelper'\nimport { SchemaVersionBuilder } from '@contember/migrations-client'\n\ntype Args = {}\n\ntype Options = {\n\tsource?: 'migrations' | 'definition'\n\tname?: string\n\toutput?: string\n}\n\nexport class ProjectGenerateDocumentationCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Generates HTML documentation from project schema')\n\t\tconfiguration.option('source').valueRequired().description('migrations|definition')\n\t\tconfiguration.option('output').valueRequired().description('file name or \"-\" for stdout')\n\t\tconfiguration.option('name').valueRequired().description('project name (for the title)')\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst schema = input.getOption('source') === 'migrations'\n\t\t\t? await this.schemaVersionBuilder.buildSchema()\n\t\t\t: await this.schemaLoader.loadSchema()\n\t\tif (!validateSchemaAndPrintErrors(schema, 'Defined schema is invalid:')) {\n\t\t\treturn 1\n\t\t}\n\t\tconst name = input.getOption('name') ?? 'Contember project'\n\n\t\tconst html = await renderProjectInfoHtml(schema, name)\n\t\tconst output = input.getOption('output') ?? `${name.toLowerCase().replace(/\\s+/g, '-')}.html`\n\t\tif (output === '-') {\n\t\t\tconsole.log(html)\n\t\t} else {\n\t\t\tconsole.log(`Documentation saved to ${output}`)\n\t\t\tawait writeFile(join(process.cwd(), output), html)\n\t\t}\n\n\t\treturn 0\n\t}\n}\n"],"names":[],"mappings":";;;;;AAgBO,MAAM,4CAA4C,QAAuB;AAAA,EAC/E,YACkB,cACA,sBAChB;AACD,UAAA;AAHiB,SAAA,eAAA;AACA,SAAA,uBAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,kDAAkD;AAC5E,kBAAc,OAAO,QAAQ,EAAE,cAAA,EAAgB,YAAY,uBAAuB;AAClF,kBAAc,OAAO,QAAQ,EAAE,cAAA,EAAgB,YAAY,6BAA6B;AACxF,kBAAc,OAAO,MAAM,EAAE,cAAA,EAAgB,YAAY,8BAA8B;AAAA,EACxF;AAAA,EAEA,MAAgB,QAAQ,OAA8C;AACrE,UAAM,SAAS,MAAM,UAAU,QAAQ,MAAM,eAC1C,MAAM,KAAK,qBAAqB,YAAA,IAChC,MAAM,KAAK,aAAa,WAAA;AAC3B,QAAI,CAAC,6BAA6B,QAAQ,4BAA4B,GAAG;AACxE,aAAO;AAAA,IACR;AACA,UAAM,OAAO,MAAM,UAAU,MAAM,KAAK;AAExC,UAAM,OAAO,MAAM,sBAAsB,QAAQ,IAAI;AACrD,UAAM,SAAS,MAAM,UAAU,QAAQ,KAAK,GAAG,KAAK,YAAA,EAAc,QAAQ,QAAQ,GAAG,CAAC;AACtF,QAAI,WAAW,KAAK;AACnB,cAAQ,IAAI,IAAI;AAAA,IACjB,OAAO;AACN,cAAQ,IAAI,0BAA0B,MAAM,EAAE;AAC9C,YAAM,UAAU,KAAK,QAAQ,OAAO,MAAM,GAAG,IAAI;AAAA,IAClD;AAEA,WAAO;AAAA,EACR;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectPrintSchemaCommand.cjs","sources":["../../../../../../packages/cli/src/commands/project/ProjectPrintSchemaCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport {\n\tAuthorizator,\n\tEntityRulesResolver,\n\tGraphQlSchemaBuilderFactory,\n\tIntrospectionSchemaDefinitionFactory,\n\tIntrospectionSchemaFactory,\n\tPermissionFactory,\n} from '@contember/engine-content-api'\nimport { printSchema } from 'graphql'\nimport { mergeSchemas } from '@graphql-tools/schema'\nimport { emptySchema, normalizeSchema } from '@contember/schema-utils'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { SchemaVersionBuilder } from '@contember/migrations-client'\nimport { validateSchemaAndPrintErrors } from '../../lib/schema/SchemaValidationHelper'\n\ntype Args = {\n}\n\ntype Options = {\n\trole?: string[]\n\tnormalize?: boolean\n\tformat?: 'graphql' | 'introspection' | 'schema'\n\tsource?: 'migrations' | 'definition'\n\t['omit-acl']?: boolean\n\t['omit-validation']?: boolean\n\t['omit-actions']?: boolean\n\t['omit-settings']?: boolean\n}\n\nexport class ProjectPrintSchemaCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Prints project schema')\n\t\tconfiguration.option('format').valueRequired().description('graphql|introspection|schema')\n\t\tconfiguration.option('source').valueRequired().description('migrations|definition')\n\t\tconfiguration.option('role').valueArray()\n\t\tconfiguration.option('normalize').valueNone()\n\t\tconfiguration.option('omit-acl').valueNone()\n\t\tconfiguration.option('omit-validation').valueNone()\n\t\tconfiguration.option('omit-actions').valueNone()\n\t\tconfiguration.option('omit-settings').valueNone()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst format = input.getOption('format') || 'graphql'\n\n\n\t\tconst schema = input.getOption('source') === 'migrations'\n\t\t\t? await this.schemaVersionBuilder.buildSchema()\n\t\t\t: await this.schemaLoader.loadSchema()\n\n\t\tconst filteredSchema = {\n\t\t\tmodel: schema.model,\n\t\t\tacl: input.getOption('omit-acl') ? emptySchema.acl : schema.acl,\n\t\t\tvalidation: input.getOption('omit-validation') ? emptySchema.validation : schema.validation,\n\t\t\tactions: input.getOption('omit-actions') ? emptySchema.actions : schema.actions,\n\t\t\tsettings: input.getOption('omit-settings') ? emptySchema.settings : schema.settings,\n\t\t}\n\n\t\tif (!validateSchemaAndPrintErrors(filteredSchema, 'Defined schema is invalid:')) {\n\t\t\treturn 1\n\t\t}\n\n\t\tconst permissionFactory = new PermissionFactory()\n\t\tconst inputRoles = input.getOption('role')\n\t\tconst schemaNormalized = input.getOption('normalize') ? normalizeSchema(filteredSchema) : filteredSchema\n\t\tconst permissions = permissionFactory.create(schemaNormalized, inputRoles || ['admin'])\n\t\tconst schemaBuilderFactory = new GraphQlSchemaBuilderFactory()\n\t\tconst authorizator = new Authorizator(\n\t\t\tpermissions,\n\t\t\tschemaNormalized.acl.customPrimary ?? false,\n\t\t\tObject.values(schemaNormalized.acl.roles).some(it => it.content?.refreshMaterializedView),\n\t\t)\n\t\tconst introspection = new IntrospectionSchemaFactory(\n\t\t\tschemaNormalized.model,\n\t\t\tnew EntityRulesResolver(schemaNormalized.validation, schemaNormalized.model),\n\t\t\tauthorizator,\n\t\t)\n\n\t\tconst printByLine = (out: string) => {\n\t\t\tout.split('\\n').forEach(line => {\n\t\t\t\tprocess.stdout.write(line + '\\n')\n\t\t\t})\n\t\t}\n\t\tif (format === 'schema') {\n\t\t\tif (inputRoles) {\n\t\t\t\tthrow `--roles option is not supported for \"schema\" format`\n\t\t\t}\n\t\t\tconst jsonString = JSON.stringify(schemaNormalized, null, '\\t')\n\t\t\tprintByLine(jsonString)\n\t\t} else if (format === 'introspection') {\n\t\t\tprintByLine(JSON.stringify(introspection.create(), null, '\\t'))\n\t\t} else if (format === 'graphql') {\n\t\t\tconst contentSchema = schemaBuilderFactory.create(schemaNormalized.model, authorizator).build()\n\t\t\tconst introspectionSchemaFactory = new IntrospectionSchemaDefinitionFactory(introspection)\n\t\t\tconst introspectionSchema = introspectionSchemaFactory.create()\n\t\t\tconst gqlSchema = mergeSchemas({\n\t\t\t\tschemas: [contentSchema, introspectionSchema],\n\t\t\t})\n\t\t\tgqlSchema.description = '' // this enforces schema definition print\n\t\t\tconst printedSchema = printSchema(gqlSchema).replace('\"\"\"\"\"\"\\n', '') // remove empty comment\n\t\t\tprintByLine(printedSchema)\n\t\t} else {\n\t\t\tthrow `Unknown format ${format}`\n\t\t}\n\n\t\treturn 0\n\t}\n}\n"],"names":["Command","schema","emptySchema","validateSchemaAndPrintErrors","PermissionFactory","normalizeSchema","GraphQlSchemaBuilderFactory","Authorizator","IntrospectionSchemaFactory","EntityRulesResolver","IntrospectionSchemaDefinitionFactory","mergeSchemas","printSchema"],"mappings":";;;;;;;;AA8BO,MAAM,kCAAkCA,UAAAA,QAAuB;AAAA,EACrE,YACkB,cACA,sBAChB;AACK,UAAA;AAHW,SAAA,eAAA;AACA,SAAA,uBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,uBAAuB;AACjD,kBAAc,OAAO,QAAQ,EAAE,cAAc,EAAE,YAAY,8BAA8B;AACzF,kBAAc,OAAO,QAAQ,EAAE,cAAc,EAAE,YAAY,uBAAuB;AACpE,kBAAA,OAAO,MAAM,EAAE,WAAW;AAC1B,kBAAA,OAAO,WAAW,EAAE,UAAU;AAC9B,kBAAA,OAAO,UAAU,EAAE,UAAU;AAC7B,kBAAA,OAAO,iBAAiB,EAAE,UAAU;AACpC,kBAAA,OAAO,cAAc,EAAE,UAAU;AACjC,kBAAA,OAAO,eAAe,EAAE,UAAU;AAAA,EAAA;AAAA,EAGjD,MAAgB,QAAQ,OAA8C;AACrE,UAAM,SAAS,MAAM,UAAU,QAAQ,KAAK;AAG5C,UAAMC,WAAS,MAAM,UAAU,QAAQ,MAAM,eAC1C,MAAM,KAAK,qBAAqB,YAAY,IAC5C,MAAM,KAAK,aAAa,WAAW;AAEtC,UAAM,iBAAiB;AAAA,MACtB,OAAOA,SAAO;AAAA,MACd,KAA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,kBAAY,KAAK,UAAU,cAAc,UAAU,MAAM,GAAI,CAAC;AAAA,IAAA,WACpD,WAAW,WAAW;AAChC,YAAM,gBAAgB,qBAAqB,OAAO,iBAAiB,OAAO,YAAY,EAAE,MAAM;AACxF,YAAA,6BAA6B,IAAIC,iBAAA,qCAAqC,aAAa;AACnF,YAAA,sBAAsB,2BAA2B,OAAO;AAC9D,YAAM,YAAYC,OAAAA,aAAa;AAAA,QAC9B,SAAS,CAAC,eAAe,mBAAmB;AAAA,MAAA,CAC5C;AACD,gBAAU,cAAc;AACxB,YAAM,gBAAgBC,QAAAA,YAAY,SAAS,EAAE,QAAQ,YAAY,EAAE;AACnE,kBAAY,aAAa;AAAA,IAAA,OACnB;AACN,YAAM,kBAAkB,MAAM;AAAA,IAAA;AAGxB,WAAA;AAAA,EAAA;AAET;;"}
1
+ {"version":3,"file":"ProjectPrintSchemaCommand.cjs","sources":["../../../../../../packages/cli/src/commands/project/ProjectPrintSchemaCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport {\n\tAuthorizator,\n\tEntityRulesResolver,\n\tGraphQlSchemaBuilderFactory,\n\tIntrospectionSchemaDefinitionFactory,\n\tIntrospectionSchemaFactory,\n\tPermissionFactory,\n} from '@contember/engine-content-api'\nimport { printSchema } from 'graphql'\nimport { mergeSchemas } from '@graphql-tools/schema'\nimport { emptySchema, normalizeSchema } from '@contember/schema-utils'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { SchemaVersionBuilder } from '@contember/migrations-client'\nimport { validateSchemaAndPrintErrors } from '../../lib/schema/SchemaValidationHelper'\n\ntype Args = {}\n\ntype Options = {\n\trole?: string[]\n\tnormalize?: boolean\n\tformat?: 'graphql' | 'introspection' | 'schema'\n\tsource?: 'migrations' | 'definition'\n\t['omit-acl']?: boolean\n\t['omit-validation']?: boolean\n\t['omit-actions']?: boolean\n\t['omit-settings']?: boolean\n}\n\nexport class ProjectPrintSchemaCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Prints project schema')\n\t\tconfiguration.option('format').valueRequired().description('graphql|introspection|schema')\n\t\tconfiguration.option('source').valueRequired().description('migrations|definition')\n\t\tconfiguration.option('role').valueArray()\n\t\tconfiguration.option('normalize').valueNone()\n\t\tconfiguration.option('omit-acl').valueNone()\n\t\tconfiguration.option('omit-validation').valueNone()\n\t\tconfiguration.option('omit-actions').valueNone()\n\t\tconfiguration.option('omit-settings').valueNone()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst format = input.getOption('format') || 'graphql'\n\n\t\tconst schema = input.getOption('source') === 'migrations'\n\t\t\t? await this.schemaVersionBuilder.buildSchema()\n\t\t\t: await this.schemaLoader.loadSchema()\n\n\t\tconst filteredSchema = {\n\t\t\tmodel: schema.model,\n\t\t\tacl: input.getOption('omit-acl') ? emptySchema.acl : schema.acl,\n\t\t\tvalidation: input.getOption('omit-validation') ? emptySchema.validation : schema.validation,\n\t\t\tactions: input.getOption('omit-actions') ? emptySchema.actions : schema.actions,\n\t\t\tsettings: input.getOption('omit-settings') ? emptySchema.settings : schema.settings,\n\t\t}\n\n\t\tif (!validateSchemaAndPrintErrors(filteredSchema, 'Defined schema is invalid:')) {\n\t\t\treturn 1\n\t\t}\n\n\t\tconst permissionFactory = new PermissionFactory()\n\t\tconst inputRoles = input.getOption('role')\n\t\tconst schemaNormalized = input.getOption('normalize') ? normalizeSchema(filteredSchema) : filteredSchema\n\t\tconst permissions = permissionFactory.create(schemaNormalized, inputRoles || ['admin'])\n\t\tconst schemaBuilderFactory = new GraphQlSchemaBuilderFactory()\n\t\tconst authorizator = new Authorizator(\n\t\t\tpermissions,\n\t\t\tschemaNormalized.acl.customPrimary ?? false,\n\t\t\tObject.values(schemaNormalized.acl.roles).some(it => it.content?.refreshMaterializedView),\n\t\t)\n\t\tconst introspection = new IntrospectionSchemaFactory(\n\t\t\tschemaNormalized.model,\n\t\t\tnew EntityRulesResolver(schemaNormalized.validation, schemaNormalized.model),\n\t\t\tauthorizator,\n\t\t)\n\n\t\tconst printByLine = (out: string) => {\n\t\t\tout.split('\\n').forEach(line => {\n\t\t\t\tprocess.stdout.write(line + '\\n')\n\t\t\t})\n\t\t}\n\t\tif (format === 'schema') {\n\t\t\tif (inputRoles) {\n\t\t\t\tthrow `--roles option is not supported for \"schema\" format`\n\t\t\t}\n\t\t\tconst jsonString = JSON.stringify(schemaNormalized, null, '\\t')\n\t\t\tprintByLine(jsonString)\n\t\t} else if (format === 'introspection') {\n\t\t\tprintByLine(JSON.stringify(introspection.create(), null, '\\t'))\n\t\t} else if (format === 'graphql') {\n\t\t\tconst contentSchema = schemaBuilderFactory.create(schemaNormalized.model, authorizator).build()\n\t\t\tconst introspectionSchemaFactory = new IntrospectionSchemaDefinitionFactory(introspection)\n\t\t\tconst introspectionSchema = introspectionSchemaFactory.create()\n\t\t\tconst gqlSchema = mergeSchemas({\n\t\t\t\tschemas: [contentSchema, introspectionSchema],\n\t\t\t})\n\t\t\tgqlSchema.description = '' // this enforces schema definition print\n\t\t\tconst printedSchema = printSchema(gqlSchema).replace('\"\"\"\"\"\"\\n', '') // remove empty comment\n\t\t\tprintByLine(printedSchema)\n\t\t} else {\n\t\t\tthrow `Unknown format ${format}`\n\t\t}\n\n\t\treturn 0\n\t}\n}\n"],"names":["Command","schema","emptySchema","validateSchemaAndPrintErrors","PermissionFactory","normalizeSchema","GraphQlSchemaBuilderFactory","Authorizator","IntrospectionSchemaFactory","EntityRulesResolver","IntrospectionSchemaDefinitionFactory","mergeSchemas","printSchema"],"mappings":";;;;;;;;AA6BO,MAAM,kCAAkCA,UAAAA,QAAuB;AAAA,EACrE,YACkB,cACA,sBAChB;AACD,UAAA;AAHiB,SAAA,eAAA;AACA,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
- {"version":3,"file":"ProjectPrintSchemaCommand.js","sources":["../../../../../../packages/cli/src/commands/project/ProjectPrintSchemaCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport {\n\tAuthorizator,\n\tEntityRulesResolver,\n\tGraphQlSchemaBuilderFactory,\n\tIntrospectionSchemaDefinitionFactory,\n\tIntrospectionSchemaFactory,\n\tPermissionFactory,\n} from '@contember/engine-content-api'\nimport { printSchema } from 'graphql'\nimport { mergeSchemas } from '@graphql-tools/schema'\nimport { emptySchema, normalizeSchema } from '@contember/schema-utils'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { SchemaVersionBuilder } from '@contember/migrations-client'\nimport { validateSchemaAndPrintErrors } from '../../lib/schema/SchemaValidationHelper'\n\ntype Args = {\n}\n\ntype Options = {\n\trole?: string[]\n\tnormalize?: boolean\n\tformat?: 'graphql' | 'introspection' | 'schema'\n\tsource?: 'migrations' | 'definition'\n\t['omit-acl']?: boolean\n\t['omit-validation']?: boolean\n\t['omit-actions']?: boolean\n\t['omit-settings']?: boolean\n}\n\nexport class ProjectPrintSchemaCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Prints project schema')\n\t\tconfiguration.option('format').valueRequired().description('graphql|introspection|schema')\n\t\tconfiguration.option('source').valueRequired().description('migrations|definition')\n\t\tconfiguration.option('role').valueArray()\n\t\tconfiguration.option('normalize').valueNone()\n\t\tconfiguration.option('omit-acl').valueNone()\n\t\tconfiguration.option('omit-validation').valueNone()\n\t\tconfiguration.option('omit-actions').valueNone()\n\t\tconfiguration.option('omit-settings').valueNone()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst format = input.getOption('format') || 'graphql'\n\n\n\t\tconst schema = input.getOption('source') === 'migrations'\n\t\t\t? await this.schemaVersionBuilder.buildSchema()\n\t\t\t: await this.schemaLoader.loadSchema()\n\n\t\tconst filteredSchema = {\n\t\t\tmodel: schema.model,\n\t\t\tacl: input.getOption('omit-acl') ? emptySchema.acl : schema.acl,\n\t\t\tvalidation: input.getOption('omit-validation') ? emptySchema.validation : schema.validation,\n\t\t\tactions: input.getOption('omit-actions') ? emptySchema.actions : schema.actions,\n\t\t\tsettings: input.getOption('omit-settings') ? emptySchema.settings : schema.settings,\n\t\t}\n\n\t\tif (!validateSchemaAndPrintErrors(filteredSchema, 'Defined schema is invalid:')) {\n\t\t\treturn 1\n\t\t}\n\n\t\tconst permissionFactory = new PermissionFactory()\n\t\tconst inputRoles = input.getOption('role')\n\t\tconst schemaNormalized = input.getOption('normalize') ? normalizeSchema(filteredSchema) : filteredSchema\n\t\tconst permissions = permissionFactory.create(schemaNormalized, inputRoles || ['admin'])\n\t\tconst schemaBuilderFactory = new GraphQlSchemaBuilderFactory()\n\t\tconst authorizator = new Authorizator(\n\t\t\tpermissions,\n\t\t\tschemaNormalized.acl.customPrimary ?? false,\n\t\t\tObject.values(schemaNormalized.acl.roles).some(it => it.content?.refreshMaterializedView),\n\t\t)\n\t\tconst introspection = new IntrospectionSchemaFactory(\n\t\t\tschemaNormalized.model,\n\t\t\tnew EntityRulesResolver(schemaNormalized.validation, schemaNormalized.model),\n\t\t\tauthorizator,\n\t\t)\n\n\t\tconst printByLine = (out: string) => {\n\t\t\tout.split('\\n').forEach(line => {\n\t\t\t\tprocess.stdout.write(line + '\\n')\n\t\t\t})\n\t\t}\n\t\tif (format === 'schema') {\n\t\t\tif (inputRoles) {\n\t\t\t\tthrow `--roles option is not supported for \"schema\" format`\n\t\t\t}\n\t\t\tconst jsonString = JSON.stringify(schemaNormalized, null, '\\t')\n\t\t\tprintByLine(jsonString)\n\t\t} else if (format === 'introspection') {\n\t\t\tprintByLine(JSON.stringify(introspection.create(), null, '\\t'))\n\t\t} else if (format === 'graphql') {\n\t\t\tconst contentSchema = schemaBuilderFactory.create(schemaNormalized.model, authorizator).build()\n\t\t\tconst introspectionSchemaFactory = new IntrospectionSchemaDefinitionFactory(introspection)\n\t\t\tconst introspectionSchema = introspectionSchemaFactory.create()\n\t\t\tconst gqlSchema = mergeSchemas({\n\t\t\t\tschemas: [contentSchema, introspectionSchema],\n\t\t\t})\n\t\t\tgqlSchema.description = '' // this enforces schema definition print\n\t\t\tconst printedSchema = printSchema(gqlSchema).replace('\"\"\"\"\"\"\\n', '') // remove empty comment\n\t\t\tprintByLine(printedSchema)\n\t\t} else {\n\t\t\tthrow `Unknown format ${format}`\n\t\t}\n\n\t\treturn 0\n\t}\n}\n"],"names":[],"mappings":";;;;;;AA8BO,MAAM,kCAAkC,QAAuB;AAAA,EACrE,YACkB,cACA,sBAChB;AACK,UAAA;AAHW,SAAA,eAAA;AACA,SAAA,uBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,uBAAuB;AACjD,kBAAc,OAAO,QAAQ,EAAE,cAAc,EAAE,YAAY,8BAA8B;AACzF,kBAAc,OAAO,QAAQ,EAAE,cAAc,EAAE,YAAY,uBAAuB;AACpE,kBAAA,OAAO,MAAM,EAAE,WAAW;AAC1B,kBAAA,OAAO,WAAW,EAAE,UAAU;AAC9B,kBAAA,OAAO,UAAU,EAAE,UAAU;AAC7B,kBAAA,OAAO,iBAAiB,EAAE,UAAU;AACpC,kBAAA,OAAO,cAAc,EAAE,UAAU;AACjC,kBAAA,OAAO,eAAe,EAAE,UAAU;AAAA,EAAA;AAAA,EAGjD,MAAgB,QAAQ,OAA8C;AACrE,UAAM,SAAS,MAAM,UAAU,QAAQ,KAAK;AAG5C,UAAM,SAAS,MAAM,UAAU,QAAQ,MAAM,eAC1C,MAAM,KAAK,qBAAqB,YAAY,IAC5C,MAAM,KAAK,aAAa,WAAW;AAEtC,UAAM,iBAAiB;AAAA,MACtB,OAAO,OAAO;AAAA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AAA,IAAA,WACpD,WAAW,WAAW;AAChC,YAAM,gBAAgB,qBAAqB,OAAO,iBAAiB,OAAO,YAAY,EAAE,MAAM;AACxF,YAAA,6BAA6B,IAAI,qCAAqC,aAAa;AACnF,YAAA,sBAAsB,2BAA2B,OAAO;AAC9D,YAAM,YAAY,aAAa;AAAA,QAC9B,SAAS,CAAC,eAAe,mBAAmB;AAAA,MAAA,CAC5C;AACD,gBAAU,cAAc;AACxB,YAAM,gBAAgB,YAAY,SAAS,EAAE,QAAQ,YAAY,EAAE;AACnE,kBAAY,aAAa;AAAA,IAAA,OACnB;AACN,YAAM,kBAAkB,MAAM;AAAA,IAAA;AAGxB,WAAA;AAAA,EAAA;AAET;"}
1
+ {"version":3,"file":"ProjectPrintSchemaCommand.js","sources":["../../../../../../packages/cli/src/commands/project/ProjectPrintSchemaCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration, Input } from '@contember/cli-common'\nimport {\n\tAuthorizator,\n\tEntityRulesResolver,\n\tGraphQlSchemaBuilderFactory,\n\tIntrospectionSchemaDefinitionFactory,\n\tIntrospectionSchemaFactory,\n\tPermissionFactory,\n} from '@contember/engine-content-api'\nimport { printSchema } from 'graphql'\nimport { mergeSchemas } from '@graphql-tools/schema'\nimport { emptySchema, normalizeSchema } from '@contember/schema-utils'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { SchemaVersionBuilder } from '@contember/migrations-client'\nimport { validateSchemaAndPrintErrors } from '../../lib/schema/SchemaValidationHelper'\n\ntype Args = {}\n\ntype Options = {\n\trole?: string[]\n\tnormalize?: boolean\n\tformat?: 'graphql' | 'introspection' | 'schema'\n\tsource?: 'migrations' | 'definition'\n\t['omit-acl']?: boolean\n\t['omit-validation']?: boolean\n\t['omit-actions']?: boolean\n\t['omit-settings']?: boolean\n}\n\nexport class ProjectPrintSchemaCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Prints project schema')\n\t\tconfiguration.option('format').valueRequired().description('graphql|introspection|schema')\n\t\tconfiguration.option('source').valueRequired().description('migrations|definition')\n\t\tconfiguration.option('role').valueArray()\n\t\tconfiguration.option('normalize').valueNone()\n\t\tconfiguration.option('omit-acl').valueNone()\n\t\tconfiguration.option('omit-validation').valueNone()\n\t\tconfiguration.option('omit-actions').valueNone()\n\t\tconfiguration.option('omit-settings').valueNone()\n\t}\n\n\tprotected async execute(input: Input<Args, Options>): Promise<number> {\n\t\tconst format = input.getOption('format') || 'graphql'\n\n\t\tconst schema = input.getOption('source') === 'migrations'\n\t\t\t? await this.schemaVersionBuilder.buildSchema()\n\t\t\t: await this.schemaLoader.loadSchema()\n\n\t\tconst filteredSchema = {\n\t\t\tmodel: schema.model,\n\t\t\tacl: input.getOption('omit-acl') ? emptySchema.acl : schema.acl,\n\t\t\tvalidation: input.getOption('omit-validation') ? emptySchema.validation : schema.validation,\n\t\t\tactions: input.getOption('omit-actions') ? emptySchema.actions : schema.actions,\n\t\t\tsettings: input.getOption('omit-settings') ? emptySchema.settings : schema.settings,\n\t\t}\n\n\t\tif (!validateSchemaAndPrintErrors(filteredSchema, 'Defined schema is invalid:')) {\n\t\t\treturn 1\n\t\t}\n\n\t\tconst permissionFactory = new PermissionFactory()\n\t\tconst inputRoles = input.getOption('role')\n\t\tconst schemaNormalized = input.getOption('normalize') ? normalizeSchema(filteredSchema) : filteredSchema\n\t\tconst permissions = permissionFactory.create(schemaNormalized, inputRoles || ['admin'])\n\t\tconst schemaBuilderFactory = new GraphQlSchemaBuilderFactory()\n\t\tconst authorizator = new Authorizator(\n\t\t\tpermissions,\n\t\t\tschemaNormalized.acl.customPrimary ?? false,\n\t\t\tObject.values(schemaNormalized.acl.roles).some(it => it.content?.refreshMaterializedView),\n\t\t)\n\t\tconst introspection = new IntrospectionSchemaFactory(\n\t\t\tschemaNormalized.model,\n\t\t\tnew EntityRulesResolver(schemaNormalized.validation, schemaNormalized.model),\n\t\t\tauthorizator,\n\t\t)\n\n\t\tconst printByLine = (out: string) => {\n\t\t\tout.split('\\n').forEach(line => {\n\t\t\t\tprocess.stdout.write(line + '\\n')\n\t\t\t})\n\t\t}\n\t\tif (format === 'schema') {\n\t\t\tif (inputRoles) {\n\t\t\t\tthrow `--roles option is not supported for \"schema\" format`\n\t\t\t}\n\t\t\tconst jsonString = JSON.stringify(schemaNormalized, null, '\\t')\n\t\t\tprintByLine(jsonString)\n\t\t} else if (format === 'introspection') {\n\t\t\tprintByLine(JSON.stringify(introspection.create(), null, '\\t'))\n\t\t} else if (format === 'graphql') {\n\t\t\tconst contentSchema = schemaBuilderFactory.create(schemaNormalized.model, authorizator).build()\n\t\t\tconst introspectionSchemaFactory = new IntrospectionSchemaDefinitionFactory(introspection)\n\t\t\tconst introspectionSchema = introspectionSchemaFactory.create()\n\t\t\tconst gqlSchema = mergeSchemas({\n\t\t\t\tschemas: [contentSchema, introspectionSchema],\n\t\t\t})\n\t\t\tgqlSchema.description = '' // this enforces schema definition print\n\t\t\tconst printedSchema = printSchema(gqlSchema).replace('\"\"\"\"\"\"\\n', '') // remove empty comment\n\t\t\tprintByLine(printedSchema)\n\t\t} else {\n\t\t\tthrow `Unknown format ${format}`\n\t\t}\n\n\t\treturn 0\n\t}\n}\n"],"names":[],"mappings":";;;;;;AA6BO,MAAM,kCAAkC,QAAuB;AAAA,EACrE,YACkB,cACA,sBAChB;AACD,UAAA;AAHiB,SAAA,eAAA;AACA,SAAA,uBAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,uBAAuB;AACjD,kBAAc,OAAO,QAAQ,EAAE,cAAA,EAAgB,YAAY,8BAA8B;AACzF,kBAAc,OAAO,QAAQ,EAAE,cAAA,EAAgB,YAAY,uBAAuB;AAClF,kBAAc,OAAO,MAAM,EAAE,WAAA;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I,oBAAoB,iBAAiB,YAAY,iBAAiB,KAAK;AAAA,MAC3E;AAAA,IAAA;AAGD,UAAM,cAAc,CAAC,QAAgB;AACpC,UAAI,MAAM,IAAI,EAAE,QAAQ,CAAA,SAAQ;AAC/B,gBAAQ,OAAO,MAAM,OAAO,IAAI;AAAA,MACjC,CAAC;AAAA,IACF;AACA,QAAI,WAAW,UAAU;AACxB,UAAI,YAAY;AACf,cAAM;AAAA,MACP;AACA,YAAM,aAAa,KAAK,UAAU,kBAAkB,MAAM,GAAI;AAC9D,kBAAY,UAAU;AAAA,IACvB,WAAW,WAAW,iBAAiB;AACtC,kBAAY,KAAK,UAAU,cAAc,UAAU,MAAM,GAAI,CAAC;AAAA,IAC/D,WAAW,WAAW,WAAW;AAChC,YAAM,gBAAgB,qBAAqB,OAAO,iBAAiB,OAAO,YAAY,EAAE,MAAA;AACxF,YAAM,6BAA6B,IAAI,qCAAqC,aAAa;AACzF,YAAM,sBAAsB,2BAA2B,OAAA;AACvD,YAAM,YAAY,aAAa;AAAA,QAC9B,SAAS,CAAC,eAAe,mBAAmB;AAAA,MAAA,CAC5C;AACD,gBAAU,cAAc;AACxB,YAAM,gBAAgB,YAAY,SAAS,EAAE,QAAQ,YAAY,EAAE;AACnE,kBAAY,aAAa;AAAA,IAC1B,OAAO;AACN,YAAM,kBAAkB,MAAM;AAAA,IAC/B;AAEA,WAAO;AAAA,EACR;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectValidateCommand.cjs","sources":["../../../../../../packages/cli/src/commands/project/ProjectValidateCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration } from '@contember/cli-common'\nimport { emptySchema } from '@contember/schema-utils'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { validateSchemaAndPrintErrors } from '../../lib/schema/SchemaValidationHelper'\nimport { MigrationsValidator } from '../../lib/migrations/MigrationsValidator'\nimport { MigrationsResolver, SchemaVersionBuilder } from '@contember/migrations-client'\nimport { SchemaDiffer } from '@contember/schema-migrations'\n\ntype Args = {}\n\ntype Options = {}\n\nexport class ProjectValidateCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly migrationValidator: MigrationsValidator,\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly schemaDiffer: SchemaDiffer,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Validates project schema')\n\t}\n\n\tprotected async execute(): Promise<number> {\n\t\tlet projectValid = true\n\n\t\tconst migrations = await this.migrationsResolver.getSchemaMigrations()\n\t\tprojectValid = this.migrationValidator.validate(emptySchema, migrations)\n\t\t\t&& projectValid\n\n\t\tconst schema = await this.schemaLoader.loadSchema()\n\t\tprojectValid = validateSchemaAndPrintErrors(schema, 'Defined schema is invalid:')\n\t\t\t&& projectValid\n\n\t\tconst builtSchema = await this.schemaVersionBuilder.buildSchema()\n\t\tprojectValid = validateSchemaAndPrintErrors(builtSchema, 'Schema built from migrations is invalid:')\n\t\t\t&& projectValid\n\n\t\tif (projectValid) {\n\t\t\tconst diff = await this.schemaDiffer.diffSchemas(builtSchema, schema)\n\t\t\tif (diff.length > 0) {\n\t\t\t\tconsole.log('Migrations are not in sync with a defined schema')\n\t\t\t\tprojectValid = false\n\t\t\t}\n\t\t}\n\n\t\tif (projectValid) {\n\t\t\tconsole.log('Project schema is valid')\n\t\t}\n\n\t\treturn projectValid ? 0 : 1\n\t}\n}\n"],"names":["Command","emptySchema","validateSchemaAndPrintErrors"],"mappings":";;;;;AAYO,MAAM,+BAA+BA,UAAAA,QAAuB;AAAA,EAClE,YACkB,cACA,oBACA,oBACA,cACA,sBAChB;AACK,UAAA;AANW,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,qBAAA;AACA,SAAA,eAAA;AACA,SAAA,uBAAA;AAAA,EAAA;AAAA,EAKR,UAAU,eAA0D;AAC7E,kBAAc,YAAY,0BAA0B;AAAA,EAAA;AAAA,EAGrD,MAAgB,UAA2B;AAC1C,QAAI,eAAe;AAEnB,UAAM,aAAa,MAAM,KAAK,mBAAmB,oBAAoB;AACrE,mBAAe,KAAK,mBAAmB,SAASC,YAAA,aAAa,UAAU,KACnE;AAEJ,UAAM,SAAS,MAAM,KAAK,aAAa,WAAW;AACnC,mBAAAC,uBAAA,6BAA6B,QAAQ,4BAA4B,KAC5E;AAEJ,UAAM,cAAc,MAAM,KAAK,qBAAqB,YAAY;AACjD,mBAAAA,uBAAA,6BAA6B,aAAa,0CAA0C,KAC/F;AAEJ,QAAI,cAAc;AACjB,YAAM,OAAO,MAAM,KAAK,aAAa,YAAY,aAAa,MAAM;AAChE,UAAA,KAAK,SAAS,GAAG;AACpB,gBAAQ,IAAI,kDAAkD;AAC/C,uBAAA;AAAA,MAAA;AAAA,IAChB;AAGD,QAAI,cAAc;AACjB,cAAQ,IAAI,yBAAyB;AAAA,IAAA;AAGtC,WAAO,eAAe,IAAI;AAAA,EAAA;AAE5B;;"}
1
+ {"version":3,"file":"ProjectValidateCommand.cjs","sources":["../../../../../../packages/cli/src/commands/project/ProjectValidateCommand.ts"],"sourcesContent":["import { Command, CommandConfiguration } from '@contember/cli-common'\nimport { emptySchema } from '@contember/schema-utils'\nimport { SchemaLoader } from '../../lib/schema/SchemaLoader'\nimport { validateSchemaAndPrintErrors } from '../../lib/schema/SchemaValidationHelper'\nimport { MigrationsValidator } from '../../lib/migrations/MigrationsValidator'\nimport { MigrationsResolver, SchemaVersionBuilder } from '@contember/migrations-client'\nimport { SchemaDiffer } from '@contember/schema-migrations'\n\ntype Args = {}\n\ntype Options = {}\n\nexport class ProjectValidateCommand extends Command<Args, Options> {\n\tconstructor(\n\t\tprivate readonly schemaLoader: SchemaLoader,\n\t\tprivate readonly migrationValidator: MigrationsValidator,\n\t\tprivate readonly migrationsResolver: MigrationsResolver,\n\t\tprivate readonly schemaDiffer: SchemaDiffer,\n\t\tprivate readonly schemaVersionBuilder: SchemaVersionBuilder,\n\t) {\n\t\tsuper()\n\t}\n\n\tprotected configure(configuration: CommandConfiguration<Args, Options>): void {\n\t\tconfiguration.description('Validates project schema')\n\t}\n\n\tprotected async execute(): Promise<number> {\n\t\tlet projectValid = true\n\n\t\tconst migrations = await this.migrationsResolver.getSchemaMigrations()\n\t\tprojectValid = this.migrationValidator.validate(emptySchema, migrations)\n\t\t\t&& projectValid\n\n\t\tconst schema = await this.schemaLoader.loadSchema()\n\t\tprojectValid = validateSchemaAndPrintErrors(schema, 'Defined schema is invalid:')\n\t\t\t&& projectValid\n\n\t\tconst builtSchema = await this.schemaVersionBuilder.buildSchema()\n\t\tprojectValid = validateSchemaAndPrintErrors(builtSchema, 'Schema built from migrations is invalid:')\n\t\t\t&& projectValid\n\n\t\tif (projectValid) {\n\t\t\tconst diff = await this.schemaDiffer.diffSchemas(builtSchema, schema)\n\t\t\tif (diff.length > 0) {\n\t\t\t\tconsole.log('Migrations are not in sync with a defined schema')\n\t\t\t\tprojectValid = false\n\t\t\t}\n\t\t}\n\n\t\tif (projectValid) {\n\t\t\tconsole.log('Project schema is valid')\n\t\t}\n\n\t\treturn projectValid ? 0 : 1\n\t}\n}\n"],"names":["Command","emptySchema","validateSchemaAndPrintErrors"],"mappings":";;;;;AAYO,MAAM,+BAA+BA,UAAAA,QAAuB;AAAA,EAClE,YACkB,cACA,oBACA,oBACA,cACA,sBAChB;AACD,UAAA;AANiB,SAAA,eAAA;AACA,SAAA,qBAAA;AACA,SAAA,qBAAA;AACA,SAAA,eAAA;AACA,SAAA,uBAAA;AAAA,EAGlB;AAAA,EAEU,UAAU,eAA0D;AAC7E,kBAAc,YAAY,0BAA0B;AAAA,EACrD;AAAA,EAEA,MAAgB,UAA2B;AAC1C,QAAI,eAAe;AAEnB,UAAM,aAAa,MAAM,KAAK,mBAAmB,oBAAA;AACjD,mBAAe,KAAK,mBAAmB,SAASC,YAAAA,aAAa,UAAU,KACnE;AAEJ,UAAM,SAAS,MAAM,KAAK,aAAa,WAAA;AACvC,mBAAeC,uBAAAA,6BAA6B,QAAQ,4BAA4B,KAC5E;AAEJ,UAAM,cAAc,MAAM,KAAK,qBAAqB,YAAA;AACpD,mBAAeA,uBAAAA,6BAA6B,aAAa,0CAA0C,KAC/F;AAEJ,QAAI,cAAc;AACjB,YAAM,OAAO,MAAM,KAAK,aAAa,YAAY,aAAa,MAAM;AACpE,UAAI,KAAK,SAAS,GAAG;AACpB,gBAAQ,IAAI,kDAAkD;AAC9D,uBAAe;AAAA,MAChB;AAAA,IACD;AAEA,QAAI,cAAc;AACjB,cAAQ,IAAI,yBAAyB;AAAA,IACtC;AAEA,WAAO,eAAe,IAAI;AAAA,EAC3B;AACD;;"}