@catladder/cli 0.0.0-waitfor-deploy-31ebcf14 → 0.0.0-yarn-cache-a697966f

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 (305) hide show
  1. package/CONTRIBUTING.md +17 -12
  2. package/README.md +19 -12
  3. package/bin/catenv +1 -1
  4. package/bin/catenv-dev +3 -0
  5. package/bin/catladder +1 -1
  6. package/bin/catladder-dev +3 -0
  7. package/dist/apps/catenv/catenv.d.ts +2 -4
  8. package/dist/apps/catenv/catenv.js +12 -89
  9. package/dist/apps/catenv/catenv.js.map +1 -1
  10. package/dist/apps/catenv/printVariables.d.ts +3 -0
  11. package/dist/apps/catenv/printVariables.js +115 -0
  12. package/dist/apps/catenv/printVariables.js.map +1 -0
  13. package/dist/apps/catenv/types.d.ts +5 -0
  14. package/dist/apps/catenv/types.js +3 -0
  15. package/dist/apps/catenv/types.js.map +1 -0
  16. package/dist/apps/catenv/utils.d.ts +12 -0
  17. package/dist/apps/catenv/utils.js +108 -0
  18. package/dist/apps/catenv/utils.js.map +1 -0
  19. package/dist/apps/catenv/writeDotEnvFiles.d.ts +3 -0
  20. package/dist/apps/catenv/writeDotEnvFiles.js +94 -0
  21. package/dist/apps/catenv/writeDotEnvFiles.js.map +1 -0
  22. package/dist/apps/catenv/writeEnvDTs.d.ts +3 -0
  23. package/dist/apps/catenv/writeEnvDTs.js +114 -0
  24. package/dist/apps/catenv/writeEnvDTs.js.map +1 -0
  25. package/dist/apps/cli/cli.js +4 -2
  26. package/dist/apps/cli/cli.js.map +1 -1
  27. package/dist/apps/cli/commands/{project/commandCopyDB.d.ts → cloudSQL/commandRestoreDb.d.ts} +1 -1
  28. package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js +185 -0
  29. package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js.map +1 -0
  30. package/dist/apps/cli/commands/cloudSQL/index.d.ts +3 -0
  31. package/dist/apps/cli/commands/cloudSQL/index.js +50 -0
  32. package/dist/apps/cli/commands/cloudSQL/index.js.map +1 -0
  33. package/dist/apps/cli/commands/general/index.d.ts +1 -1
  34. package/dist/apps/cli/commands/general/index.js +11 -11
  35. package/dist/apps/cli/commands/general/index.js.map +1 -1
  36. package/dist/apps/cli/commands/general/portForward.d.ts +1 -1
  37. package/dist/apps/cli/commands/general/portForward.js +3 -3
  38. package/dist/apps/cli/commands/general/portForward.js.map +1 -1
  39. package/dist/apps/cli/commands/mongodb/index.d.ts +1 -1
  40. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +1 -1
  41. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +2 -1
  42. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -1
  43. package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +1 -1
  44. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +1 -1
  45. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +27 -11
  46. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -1
  47. package/dist/apps/cli/commands/mongodb/utils/index.js +16 -4
  48. package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -1
  49. package/dist/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.d.ts +3 -0
  50. package/dist/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.js +189 -0
  51. package/dist/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.js.map +1 -0
  52. package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +1 -1
  53. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +89 -62
  54. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
  55. package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +2 -1
  56. package/dist/apps/cli/commands/project/commandConfigSecrets.js +71 -57
  57. package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
  58. package/dist/apps/cli/commands/project/commandDeletePods.d.ts +1 -1
  59. package/dist/apps/cli/commands/project/commandDeletePods.js +2 -1
  60. package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -1
  61. package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +1 -1
  62. package/dist/apps/cli/commands/project/commandEnvVars.d.ts +1 -1
  63. package/dist/apps/cli/commands/project/commandEnvVars.js +1 -1
  64. package/dist/apps/cli/commands/project/commandEnvVars.js.map +1 -1
  65. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +1 -1
  66. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js +1 -1
  67. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js.map +1 -1
  68. package/dist/apps/cli/commands/project/commandGetShell.d.ts +1 -1
  69. package/dist/apps/cli/commands/project/commandGetShell.js +10 -6
  70. package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -1
  71. package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +1 -1
  72. package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -1
  73. package/dist/apps/cli/commands/project/commandInitProject.old.d.ts +1 -1
  74. package/dist/apps/cli/commands/project/commandListPods.d.ts +1 -1
  75. package/dist/apps/cli/commands/project/commandListPods.js +2 -2
  76. package/dist/apps/cli/commands/project/commandListPods.js.map +1 -1
  77. package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +1 -1
  78. package/dist/apps/cli/commands/project/commandMigrateHelm3.js +1 -2
  79. package/dist/apps/cli/commands/project/commandMigrateHelm3.js.map +1 -1
  80. package/dist/apps/cli/commands/project/commandNamespace.d.ts +1 -1
  81. package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +1 -1
  82. package/dist/apps/cli/commands/project/commandOpenCostDashboard.js +2 -2
  83. package/dist/apps/cli/commands/project/commandOpenCostDashboard.js.map +1 -1
  84. package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +1 -1
  85. package/dist/apps/cli/commands/project/commandOpenDashboard.js +19 -20
  86. package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -1
  87. package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +1 -1
  88. package/dist/apps/cli/commands/project/commandOpenGit.d.ts +1 -1
  89. package/dist/apps/cli/commands/project/commandOpenGit.js +2 -7
  90. package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -1
  91. package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +1 -1
  92. package/dist/apps/cli/commands/project/commandOpenGrafana.js +2 -2
  93. package/dist/apps/cli/commands/project/commandOpenGrafana.js.map +1 -1
  94. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +1 -1
  95. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +4 -3
  96. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -1
  97. package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +1 -1
  98. package/dist/apps/cli/commands/project/commandOpenLogs.js +7 -20
  99. package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -1
  100. package/dist/apps/cli/commands/project/commandPauseProject.d.ts +1 -1
  101. package/dist/apps/cli/commands/project/commandPortForward.d.ts +1 -1
  102. package/dist/apps/cli/commands/project/commandPortForward.js +98 -36
  103. package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -1
  104. package/dist/apps/cli/commands/project/commandSecretsClearBackups.d.ts +5 -0
  105. package/dist/apps/cli/commands/project/commandSecretsClearBackups.js +90 -0
  106. package/dist/apps/cli/commands/project/commandSecretsClearBackups.js.map +1 -0
  107. package/dist/apps/cli/commands/project/commandSetup.d.ts +1 -1
  108. package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +1 -1
  109. package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -1
  110. package/dist/apps/cli/commands/project/index.d.ts +1 -1
  111. package/dist/apps/cli/commands/project/index.js +4 -2
  112. package/dist/apps/cli/commands/project/index.js.map +1 -1
  113. package/dist/apps/cli/commands/project/setup/index.d.ts +1 -1
  114. package/dist/apps/cli/commands/project/setup/index.js +11 -7
  115. package/dist/apps/cli/commands/project/setup/index.js.map +1 -1
  116. package/dist/apps/cli/commands/project/setup/setupAccessTokens.d.ts +1 -1
  117. package/dist/apps/cli/commands/project/setup/setupAccessTokens.js +5 -4
  118. package/dist/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -1
  119. package/dist/apps/cli/commands/project/setup/setupCloudRun.d.ts +3 -0
  120. package/dist/apps/cli/commands/project/setup/setupCloudRun.js +118 -0
  121. package/dist/apps/cli/commands/project/setup/setupCloudRun.js.map +1 -0
  122. package/dist/apps/cli/commands/project/setup/setupContext.d.ts +2 -2
  123. package/dist/apps/cli/commands/project/setup/setupContext.js +10 -3
  124. package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -1
  125. package/dist/apps/cli/commands/project/setup/setupKubernetes.d.ts +2 -2
  126. package/dist/apps/cli/commands/project/setup/setupKubernetes.js +25 -18
  127. package/dist/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
  128. package/dist/apps/cli/commands/project/setup/setupTopic.d.ts +2 -0
  129. package/dist/apps/cli/commands/project/setup/setupTopic.js +69 -0
  130. package/dist/apps/cli/commands/project/setup/setupTopic.js.map +1 -0
  131. package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +1 -1
  132. package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -1
  133. package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +1 -1
  134. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +1 -1
  135. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js +1 -1
  136. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js.map +1 -1
  137. package/dist/apps/cli/config/writeConfig.d.ts +2 -2
  138. package/dist/apps/cli/verify/index.d.ts +1 -1
  139. package/dist/apps/cli/verify/migration/fromv2.d.ts +1 -1
  140. package/dist/apps/cli/verify/migration/fromv2.js +2 -0
  141. package/dist/apps/cli/verify/migration/fromv2.js.map +1 -1
  142. package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +3 -3
  143. package/dist/apps/cli/verify/migration/migrateSecrets.js +6 -3
  144. package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -1
  145. package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +1 -1
  146. package/dist/apps/cli/verify/migration/oldGitlabCi.js +1 -1
  147. package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +1 -1
  148. package/dist/bundles/catenv/index.js +46611 -0
  149. package/dist/bundles/catenv/xdg-open +1066 -0
  150. package/dist/bundles/cli/clipboard_i686.exe +0 -0
  151. package/dist/bundles/cli/clipboard_x86_64.exe +0 -0
  152. package/dist/bundles/cli/exec-child.js +39 -0
  153. package/dist/bundles/cli/index.js +363653 -0
  154. package/dist/bundles/cli/xdg-open +1066 -0
  155. package/dist/bundles/cli/xsel +0 -0
  156. package/dist/catenv.js +2 -4
  157. package/dist/catenv.js.map +1 -1
  158. package/dist/cli.js +0 -7
  159. package/dist/cli.js.map +1 -1
  160. package/dist/config/constants.d.ts +0 -1
  161. package/dist/config/constants.js +1 -2
  162. package/dist/config/constants.js.map +1 -1
  163. package/dist/config/getProjectConfig.d.ts +10 -10
  164. package/dist/config/getProjectConfig.js +77 -23
  165. package/dist/config/getProjectConfig.js.map +1 -1
  166. package/dist/config/parseChoice.d.ts +4 -0
  167. package/dist/config/parseChoice.js +9 -0
  168. package/dist/config/parseChoice.js.map +1 -0
  169. package/dist/gcloud/artifactsRegistry.d.ts +5 -0
  170. package/dist/gcloud/artifactsRegistry.js +59 -0
  171. package/dist/gcloud/artifactsRegistry.js.map +1 -0
  172. package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.d.ts +2 -0
  173. package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js +67 -0
  174. package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js.map +1 -0
  175. package/dist/gcloud/cloudRun/openCloudRunDashboards.d.ts +3 -0
  176. package/dist/gcloud/cloudRun/openCloudRunDashboards.js +62 -0
  177. package/dist/gcloud/cloudRun/openCloudRunDashboards.js.map +1 -0
  178. package/dist/gcloud/cloudSql/copyDb.d.ts +12 -0
  179. package/dist/gcloud/cloudSql/copyDb.js +64 -0
  180. package/dist/gcloud/cloudSql/copyDb.js.map +1 -0
  181. package/dist/gcloud/cloudSql/startProxy.d.ts +10 -0
  182. package/dist/gcloud/cloudSql/startProxy.js +121 -0
  183. package/dist/gcloud/cloudSql/startProxy.js.map +1 -0
  184. package/dist/gcloud/enableServices.d.ts +3 -0
  185. package/dist/gcloud/enableServices.js +63 -0
  186. package/dist/gcloud/enableServices.js.map +1 -0
  187. package/dist/gcloud/openDashboard.d.ts +2 -0
  188. package/dist/{apps/cli/commands/shared/index.js → gcloud/openDashboard.js} +23 -27
  189. package/dist/gcloud/openDashboard.js.map +1 -0
  190. package/dist/gcloud/serviceAccounts.d.ts +12 -0
  191. package/dist/gcloud/serviceAccounts.js +144 -0
  192. package/dist/gcloud/serviceAccounts.js.map +1 -0
  193. package/dist/kubernetes/index.d.ts +3 -0
  194. package/dist/kubernetes/index.js +88 -0
  195. package/dist/kubernetes/index.js.map +1 -0
  196. package/dist/kubernetes/openKubernetesDashboards.d.ts +4 -0
  197. package/dist/kubernetes/openKubernetesDashboards.js +94 -0
  198. package/dist/kubernetes/openKubernetesDashboards.js.map +1 -0
  199. package/dist/kubernetes/portForward.d.ts +1 -0
  200. package/dist/kubernetes/portForward.js +55 -0
  201. package/dist/kubernetes/portForward.js.map +1 -0
  202. package/dist/tsconfig.tsbuildinfo +1 -1
  203. package/dist/utils/cluster.js +3 -8
  204. package/dist/utils/cluster.js.map +1 -1
  205. package/dist/utils/gitlab.d.ts +8 -6
  206. package/dist/utils/gitlab.js +165 -46
  207. package/dist/utils/gitlab.js.map +1 -1
  208. package/dist/utils/passwordstore/index.d.ts +0 -1
  209. package/dist/utils/passwordstore/index.js +1 -64
  210. package/dist/utils/passwordstore/index.js.map +1 -1
  211. package/dist/utils/portForwards.d.ts +12 -0
  212. package/dist/utils/{portForward.js → portForwards.js} +20 -16
  213. package/dist/utils/portForwards.js.map +1 -0
  214. package/dist/utils/projects/index.d.ts +0 -3
  215. package/dist/utils/projects/index.js +3 -53
  216. package/dist/utils/projects/index.js.map +1 -1
  217. package/package.json +73 -22
  218. package/scripts/bundle +4 -0
  219. package/src/apps/catenv/catenv.ts +11 -62
  220. package/src/apps/catenv/printVariables.ts +58 -0
  221. package/src/apps/catenv/types.ts +6 -0
  222. package/src/apps/catenv/utils.ts +49 -0
  223. package/src/apps/catenv/writeDotEnvFiles.ts +44 -0
  224. package/src/apps/catenv/writeEnvDTs.ts +71 -0
  225. package/src/apps/cli/cli.ts +3 -1
  226. package/src/apps/cli/commands/cloudSQL/commandRestoreDb.ts +136 -0
  227. package/src/apps/cli/commands/cloudSQL/index.ts +8 -0
  228. package/src/apps/cli/commands/general/index.ts +11 -8
  229. package/src/apps/cli/commands/general/portForward.ts +4 -4
  230. package/src/apps/cli/commands/mongodb/index.ts +1 -1
  231. package/src/apps/cli/commands/mongodb/projectMongoDestroyMember.ts +3 -5
  232. package/src/apps/cli/commands/mongodb/projectMongoGetShell.ts +1 -1
  233. package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +21 -3
  234. package/src/apps/cli/commands/mongodb/utils/index.ts +19 -11
  235. package/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.ts +175 -0
  236. package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +106 -55
  237. package/src/apps/cli/commands/project/commandConfigSecrets.ts +49 -35
  238. package/src/apps/cli/commands/project/commandDeletePods.ts +3 -5
  239. package/src/apps/cli/commands/project/commandDeleteProject.ts +1 -1
  240. package/src/apps/cli/commands/project/commandEnvVars.ts +6 -3
  241. package/src/apps/cli/commands/project/commandGetMyTotalWorktime.ts +2 -2
  242. package/src/apps/cli/commands/project/commandGetShell.ts +10 -9
  243. package/src/apps/cli/commands/project/commandGitlabCi.ts +2 -1
  244. package/src/apps/cli/commands/project/commandInitProject.old.ts +1 -1
  245. package/src/apps/cli/commands/project/commandListPods.ts +2 -2
  246. package/src/apps/cli/commands/project/commandMigrateHelm3.ts +4 -3
  247. package/src/apps/cli/commands/project/commandNamespace.ts +1 -1
  248. package/src/apps/cli/commands/project/commandOpenCostDashboard.ts +3 -3
  249. package/src/apps/cli/commands/project/commandOpenDashboard.ts +12 -32
  250. package/src/apps/cli/commands/project/commandOpenEnv.ts +1 -1
  251. package/src/apps/cli/commands/project/commandOpenGit.ts +3 -3
  252. package/src/apps/cli/commands/project/commandOpenGrafana.ts +3 -3
  253. package/src/apps/cli/commands/project/commandOpenGrafanaPod.ts +5 -7
  254. package/src/apps/cli/commands/project/commandOpenLogs.ts +4 -35
  255. package/src/apps/cli/commands/project/commandPauseProject.ts +1 -1
  256. package/src/apps/cli/commands/project/commandPortForward.ts +75 -34
  257. package/src/apps/cli/commands/project/commandSecretsClearBackups.ts +27 -0
  258. package/src/apps/cli/commands/project/commandSetup.ts +1 -1
  259. package/src/apps/cli/commands/project/commandTriggerCronjob.ts +3 -2
  260. package/src/apps/cli/commands/project/index.ts +6 -3
  261. package/src/apps/cli/commands/project/setup/index.ts +3 -1
  262. package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +23 -11
  263. package/src/apps/cli/commands/project/setup/setupCloudRun.ts +84 -0
  264. package/src/apps/cli/commands/project/setup/setupContext.ts +9 -2
  265. package/src/apps/cli/commands/project/setup/setupKubernetes.ts +56 -28
  266. package/src/apps/cli/commands/project/setup/setupTopic.ts +22 -0
  267. package/src/apps/cli/commands/project/utils/ensureNamespace.ts +4 -2
  268. package/src/apps/cli/commands/project/utils/showProjectBanner.ts +1 -1
  269. package/src/apps/cli/commands/theStuffThatReallyMatters/index.ts +2 -2
  270. package/src/apps/cli/config/writeConfig.ts +2 -2
  271. package/src/apps/cli/verify/index.ts +1 -1
  272. package/src/apps/cli/verify/migration/fromv2.ts +5 -7
  273. package/src/apps/cli/verify/migration/migrateSecrets.ts +15 -5
  274. package/src/apps/cli/verify/migration/oldGitlabCi.ts +2 -2
  275. package/src/catenv.ts +3 -4
  276. package/src/cli.ts +1 -7
  277. package/src/config/constants.ts +0 -2
  278. package/src/config/getProjectConfig.ts +71 -31
  279. package/src/config/parseChoice.ts +4 -0
  280. package/src/gcloud/artifactsRegistry.ts +16 -0
  281. package/src/gcloud/cloudRun/getCloudRunDomainSuffix.ts +35 -0
  282. package/src/gcloud/cloudRun/openCloudRunDashboards.ts +22 -0
  283. package/src/gcloud/cloudSql/copyDb.ts +57 -0
  284. package/src/gcloud/cloudSql/startProxy.ts +74 -0
  285. package/src/gcloud/enableServices.ts +14 -0
  286. package/src/gcloud/openDashboard.ts +19 -0
  287. package/src/gcloud/serviceAccounts.ts +101 -0
  288. package/src/kubernetes/index.ts +27 -0
  289. package/src/kubernetes/openKubernetesDashboards.ts +52 -0
  290. package/src/kubernetes/portForward.ts +15 -0
  291. package/src/types/child-process-promise.d.ts +37 -1
  292. package/src/utils/cluster.ts +3 -3
  293. package/src/utils/gitlab.ts +141 -30
  294. package/src/utils/passwordstore/index.ts +2 -30
  295. package/src/utils/{portForward.ts → portForwards.ts} +27 -22
  296. package/src/utils/projects/index.ts +3 -24
  297. package/tsconfig.json +1 -1
  298. package/dist/apps/cli/commands/project/commandCopyDB.js +0 -102
  299. package/dist/apps/cli/commands/project/commandCopyDB.js.map +0 -1
  300. package/dist/apps/cli/commands/shared/index.d.ts +0 -3
  301. package/dist/apps/cli/commands/shared/index.js.map +0 -1
  302. package/dist/utils/portForward.d.ts +0 -4
  303. package/dist/utils/portForward.js.map +0 -1
  304. package/src/apps/cli/commands/project/commandCopyDB.ts +0 -91
  305. package/src/apps/cli/commands/shared/index.ts +0 -36
@@ -0,0 +1,136 @@
1
+ import type Vorpal from "vorpal";
2
+ import { spawnCopyDb } from "../../../../gcloud/cloudSql/copyDb";
3
+ import type { CloudSqlBackgroundProxy } from "../../../../gcloud/cloudSql/startProxy";
4
+ import { startCloudSqlProxyInBackground } from "../../../../gcloud/cloudSql/startProxy";
5
+
6
+ export default async (vorpal: Vorpal) =>
7
+ vorpal
8
+ .command(
9
+ "cloud-sql-restore-db",
10
+ "restore a db from one source to another target"
11
+ )
12
+ .action(async function restoreDb() {
13
+ const { sourceInstance } = await this.prompt({
14
+ type: "input",
15
+ name: "sourceInstance",
16
+
17
+ message: "Source instance (connection string or 'local')? šŸ¤” ",
18
+ });
19
+
20
+ let sourceProxy: CloudSqlBackgroundProxy;
21
+
22
+ let targetProxy: CloudSqlBackgroundProxy;
23
+
24
+ let sourcePort: number;
25
+ let targetPort: number;
26
+
27
+ if (sourceInstance === "local") {
28
+ const { sourceLocalPort } = await this.prompt({
29
+ type: "number",
30
+ name: "sourceLocalPort",
31
+ default: 5432,
32
+
33
+ message: "Local Port for source? šŸ¤” ",
34
+ });
35
+ sourcePort = sourceLocalPort;
36
+ } else {
37
+ sourcePort = 54399;
38
+ sourceProxy = await startCloudSqlProxyInBackground({
39
+ instanceName: sourceInstance,
40
+ localPort: sourcePort,
41
+ });
42
+ }
43
+
44
+ const { sourceUsername } = await this.prompt({
45
+ type: "input",
46
+ name: "sourceUsername",
47
+ default: "postgres",
48
+
49
+ message: "Source Username? šŸ¤” ",
50
+ });
51
+
52
+ const { sourcePassword } = await this.prompt({
53
+ type: "input",
54
+ name: "sourcePassword",
55
+
56
+ message: "Source Password? šŸ¤” ",
57
+ });
58
+
59
+ const { sourceDbName } = await this.prompt({
60
+ type: "input",
61
+ name: "sourceDbName",
62
+
63
+ message: "Source DB name? šŸ¤” ",
64
+ });
65
+
66
+ const { targetInstance } = await this.prompt({
67
+ type: "input",
68
+ name: "targetInstance",
69
+
70
+ message: "Target INSTANCE (connection string or 'local')? šŸ¤” ",
71
+ });
72
+
73
+ if (targetInstance === "local") {
74
+ const { targetLocalPort } = await this.prompt({
75
+ type: "number",
76
+ name: "targetLocalPort",
77
+ default: 5432,
78
+
79
+ message: "Local Port for target? šŸ¤” ",
80
+ });
81
+ targetPort = targetLocalPort;
82
+ } else {
83
+ targetPort = 54499;
84
+ targetProxy = await startCloudSqlProxyInBackground({
85
+ instanceName: targetInstance,
86
+ localPort: targetPort,
87
+ });
88
+ }
89
+
90
+ const { targetUsername } = await this.prompt({
91
+ type: "input",
92
+ name: "targetUsername",
93
+ default: "postgres",
94
+
95
+ message: "Target Username? šŸ¤” ",
96
+ });
97
+ const { targetPassword } = await this.prompt({
98
+ type: "input",
99
+ name: "targetPassword",
100
+
101
+ message: "Target Password? šŸ¤” ",
102
+ });
103
+
104
+ const { targetDbName } = await this.prompt({
105
+ type: "input",
106
+ name: "targetDbName",
107
+
108
+ message: "Target DB name? šŸ¤” ",
109
+ });
110
+
111
+ const { shouldContinue } = await this.prompt({
112
+ type: "confirm",
113
+ name: "shouldContinue",
114
+ message: `This will drop ${targetInstance}/${targetDbName} and replace it with ${sourceInstance}/${sourceDbName}. Continue? šŸ¤” `,
115
+ });
116
+
117
+ if (!shouldContinue) {
118
+ return;
119
+ }
120
+
121
+ try {
122
+ await spawnCopyDb({
123
+ targetPassword,
124
+ targetPort,
125
+ targetUsername,
126
+ sourceUsername,
127
+ sourcePassword,
128
+ sourcePort,
129
+ sourceDbName,
130
+ targetDbName,
131
+ });
132
+ } finally {
133
+ sourceProxy?.stop();
134
+ targetProxy?.stop();
135
+ }
136
+ });
@@ -0,0 +1,8 @@
1
+ import type Vorpal from "vorpal";
2
+ //import commandInitProject from "./commandInitProject.old";
3
+
4
+ import commandRestoreDb from "./commandRestoreDb";
5
+
6
+ export default async (vorpal: Vorpal) => {
7
+ commandRestoreDb(vorpal);
8
+ };
@@ -1,5 +1,5 @@
1
1
  import memoizee from "memoizee";
2
- import Vorpal from "vorpal";
2
+ import type Vorpal from "vorpal";
3
3
  import { getk8sApi } from "../../../../k8sApi";
4
4
  import { getCurrentContext } from "../../../../utils/cluster";
5
5
  import { logError } from "../../../../utils/log";
@@ -7,7 +7,7 @@ import { syncBitwarden } from "../../../../utils/passwordstore";
7
7
  import {
8
8
  getAllRunningPortForwards,
9
9
  stopPortForward,
10
- } from "../../../../utils/portForward";
10
+ } from "../../../../utils/portForwards";
11
11
  import { getShell } from "../../../../utils/shell";
12
12
  import { namespaceAutoCompletion } from "./namespaceAutoCompletion";
13
13
  import portForward from "./portForward";
@@ -26,19 +26,19 @@ export const getAllNamespacesNames = async () => {
26
26
  return namespaces.map((n) => n.metadata.name);
27
27
  };
28
28
  export default async (vorpal: Vorpal) => {
29
- vorpal.command("current-context").action(async function () {
29
+ vorpal.command("kube-current-context").action(async function () {
30
30
  this.log(await getCurrentContext());
31
31
  });
32
32
 
33
33
  vorpal
34
- .command("list-namespaces", "list all namespaces")
34
+ .command("kube-list-namespaces", "list all namespaces")
35
35
  .action(async function () {
36
36
  const namespaces = await getAllNamespacesNames();
37
37
  this.log(namespaces.join("\n"));
38
38
  });
39
39
 
40
40
  vorpal
41
- .command("list-secrets <namespace>", "show secrets")
41
+ .command("kube-list-secrets <namespace>", "show secrets")
42
42
  .autocomplete(namespaceAutoCompletion)
43
43
  .action(async function ({ namespace }) {
44
44
  const k8sApi = getk8sApi();
@@ -53,7 +53,7 @@ export default async (vorpal: Vorpal) => {
53
53
  });
54
54
 
55
55
  vorpal
56
- .command("list-pods <namespace>", "list all pods of namespace")
56
+ .command("kube-list-pods <namespace>", "list all pods of namespace")
57
57
  .autocomplete(namespaceAutoCompletion)
58
58
  .action(async function ({ namespace }) {
59
59
  const k8sApi = getk8sApi();
@@ -62,14 +62,17 @@ export default async (vorpal: Vorpal) => {
62
62
  });
63
63
 
64
64
  vorpal
65
- .command("stop-portforward <name>", "stop a running port forward")
65
+ .command("kube-stop-portforward <name>", "stop a running port forward")
66
66
  .autocomplete({ data: async () => getAllRunningPortForwards() })
67
67
  .action(async function ({ name }) {
68
68
  stopPortForward(name.trim());
69
69
  });
70
70
 
71
71
  vorpal
72
- .command("get-shell <namespace>", "get a shell to a pod in the environment")
72
+ .command(
73
+ "kube-get-shell <namespace>",
74
+ "get a shell to a pod in the environment"
75
+ )
73
76
  .autocomplete(namespaceAutoCompletion)
74
77
  .action(async function ({ namespace }) {
75
78
  const k8sApi = getk8sApi();
@@ -1,14 +1,14 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import { logError } from "../../../../utils/log";
3
3
 
4
- import { startPortForward } from "../../../../utils/portForward";
4
+ import { startKubePortForward } from "../../../../kubernetes/portForward";
5
5
 
6
6
  import { getk8sApi } from "../../../../k8sApi";
7
7
  import { namespaceAutoCompletion } from "./namespaceAutoCompletion";
8
8
 
9
9
  export default async (vorpal: Vorpal) =>
10
10
  vorpal
11
- .command("port-forward <namespace>", "start port-forwarding")
11
+ .command("kube-port-forward <namespace>", "start port-forwarding")
12
12
  .autocomplete(namespaceAutoCompletion)
13
13
  .action(async function ({ namespace }) {
14
14
  const k8sApi = getk8sApi();
@@ -44,5 +44,5 @@ export default async (vorpal: Vorpal) =>
44
44
  message: "Remote port: ",
45
45
  });
46
46
 
47
- return startPortForward(podName, localPort, remotePort, namespace);
47
+ return startKubePortForward(podName, localPort, remotePort, namespace);
48
48
  });
@@ -1,4 +1,4 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import projectMongoDestroyMember from "./projectMongoDestroyMember";
3
3
  import projectMongoGetShell from "./projectMongoGetShell";
4
4
  import projectMongoPortForward from "./projectMongoPortForward";
@@ -1,10 +1,8 @@
1
1
  import { exec } from "child-process-promise";
2
- import Vorpal from "vorpal";
2
+ import type Vorpal from "vorpal";
3
+ import { getProjectPvcs } from "../../../../kubernetes";
3
4
  import { logError } from "../../../../utils/log";
4
- import {
5
- getProjectNamespace,
6
- getProjectPvcs,
7
- } from "../../../../utils/projects";
5
+ import { getProjectNamespace } from "../../../../utils/projects";
8
6
  import { envAndComponents } from "../project/utils/autocompletions";
9
7
  import ensureCluster from "../project/utils/ensureCluster";
10
8
  import { getMongoDbPodsWithReplInfo } from "./utils";
@@ -1,4 +1,4 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import { logError } from "../../../../utils/log";
3
3
  import { getProjectNamespace } from "../../../../utils/projects";
4
4
  import { envAndComponents } from "../project/utils/autocompletions";
@@ -1,10 +1,15 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
+ import {
3
+ getEnvVarsResolved,
4
+ parseChoice,
5
+ } from "../../../../config/getProjectConfig";
2
6
  import { logError } from "../../../../utils/log";
3
- import { startPortForward } from "../../../../utils/portForward";
7
+ import { startKubePortForward } from "../../../../kubernetes/portForward";
4
8
  import { getProjectNamespace } from "../../../../utils/projects";
5
9
  import { envAndComponents } from "../project/utils/autocompletions";
6
10
  import ensureCluster from "../project/utils/ensureCluster";
7
11
  import { getProjectMongodbAllPodsSortedWithLabel } from "./utils";
12
+ import clipboard from "clipboardy";
8
13
 
9
14
  export default async (vorpal: Vorpal) =>
10
15
  vorpal
@@ -43,5 +48,18 @@ export default async (vorpal: Vorpal) =>
43
48
  default: "30000",
44
49
  message: "Local port: ",
45
50
  });
46
- return startPortForward(podName, localPort, 27017, namespace);
51
+ const { env, componentName } = parseChoice(envComponent);
52
+ const envVars = await getEnvVarsResolved(this, env, componentName);
53
+ const MONGODB_ROOT_PASSWORD = envVars?.MONGODB_ROOT_PASSWORD;
54
+ const connectionUrl = `mongodb://root:${MONGODB_ROOT_PASSWORD}@localhost:${localPort}`;
55
+ clipboard.writeSync(connectionUrl);
56
+ this.log("");
57
+ this.log("username: root");
58
+ this.log(`password: ${MONGODB_ROOT_PASSWORD}`);
59
+ this.log(`connection string: ${connectionUrl}`);
60
+ this.log("");
61
+ this.log("šŸ‘† connection string has been copied to your clipboard!");
62
+ this.log("");
63
+
64
+ return startKubePortForward(podName, localPort, 27017, namespace);
47
65
  });
@@ -1,11 +1,14 @@
1
1
  import { exec, spawn } from "child-process-promise";
2
- import {
3
- getProjectNamespace,
4
- getProjectPodNames,
5
- } from "../../../../../utils/projects";
2
+ import { getProjectPodNames } from "../../../../../kubernetes";
3
+ import { getProjectNamespace } from "../../../../../utils/projects";
6
4
 
7
5
  const filterMongoDbs = (podNames: string[]) =>
8
- podNames.filter((name) => name.includes("mongodb-replicaset"));
6
+ podNames.filter(
7
+ (name) =>
8
+ name.includes("mongodb") &&
9
+ !name.includes("mongodb-backup") &&
10
+ !name.includes("arbiter")
11
+ );
9
12
 
10
13
  export const getProjectMongodbAllPods = async (envComponent: string) =>
11
14
  filterMongoDbs(await getProjectPodNames(envComponent));
@@ -43,13 +46,18 @@ export const executeMongodbCommand = async (
43
46
  };
44
47
 
45
48
  export const podIsMaster = async (namespace: string, podName: string) => {
46
- const result = await executeMongodbCommand(
47
- namespace,
48
- podName,
49
- "db.isMaster()"
50
- );
49
+ try {
50
+ const result = await executeMongodbCommand(
51
+ namespace,
52
+ podName,
53
+ "db.isMaster()"
54
+ );
51
55
 
52
- return result.ismaster;
56
+ return result.ismaster;
57
+ } catch (e) {
58
+ // maybe shutting down ?
59
+ return null;
60
+ }
53
61
  };
54
62
 
55
63
  const spaces = (n: number) => " ".repeat(n);
@@ -0,0 +1,175 @@
1
+ import type Vorpal from "vorpal";
2
+ import {
3
+ getEnvVarsResolved,
4
+ getPipelineContextByChoice,
5
+ } from "../../../../../config/getProjectConfig";
6
+ import type { CloudSqlBackgroundProxy } from "../../../../../gcloud/cloudSql/startProxy";
7
+ import { startCloudSqlProxyInBackground } from "../../../../../gcloud/cloudSql/startProxy";
8
+ import { envAndComponents } from "../utils/autocompletions";
9
+
10
+ import { ConnectionStringParser } from "connection-string-parser";
11
+ import { spawnCopyDb } from "../../../../../gcloud/cloudSql/copyDb";
12
+
13
+ export default async (vorpal: Vorpal) =>
14
+ vorpal
15
+ .command(
16
+ "project-cloud-sql-restore-db",
17
+ "restores a project db from one source to another target"
18
+ )
19
+ .action(async function restoreDb() {
20
+ const envs = await envAndComponents();
21
+
22
+ const { sourceEnvAndComponent } = await this.prompt({
23
+ type: "list",
24
+ name: "sourceEnvAndComponent",
25
+ choices: envs,
26
+
27
+ message: "Source instance (connection string or 'local')? šŸ¤” ",
28
+ });
29
+
30
+ const [sourceEnv, sourceComponent] = sourceEnvAndComponent.split(":");
31
+
32
+ const sourceContext = await getPipelineContextByChoice(
33
+ sourceEnv,
34
+ sourceComponent
35
+ );
36
+
37
+ const sourceEnvVars = await getEnvVarsResolved(
38
+ this,
39
+ sourceContext.environment.shortName,
40
+ sourceContext.componentName
41
+ );
42
+
43
+ let sourceProxy: CloudSqlBackgroundProxy;
44
+ let sourceDbName: string;
45
+
46
+ let sourceUsername: string;
47
+ let sourcePassword: string;
48
+
49
+ let targetUsername: string;
50
+ let targetPassword: string;
51
+ let targetProxy: CloudSqlBackgroundProxy;
52
+
53
+ let sourcePort: number;
54
+ let targetPort: number;
55
+ let targetDbName: string;
56
+
57
+ const closeAll = () => {
58
+ sourceProxy?.stop();
59
+ targetProxy?.stop();
60
+ };
61
+
62
+ if (sourceEnv === "local") {
63
+ const parser = new ConnectionStringParser({
64
+ scheme: "postgres",
65
+ hosts: [],
66
+ });
67
+
68
+ const parsersResult = parser.parse(sourceEnvVars.DATABASE_URL);
69
+ sourcePort = parsersResult.hosts?.[0]?.port;
70
+ sourceUsername = parsersResult.username;
71
+ sourcePassword = parsersResult.password;
72
+ sourceDbName = parsersResult.endpoint;
73
+ } else {
74
+ sourcePort = 54399;
75
+ sourceProxy = await startCloudSqlProxyInBackground({
76
+ instanceName: sourceEnvVars.CLOUD_SQL_INSTANCE_CONNECTION_NAME,
77
+ localPort: sourcePort,
78
+ });
79
+
80
+ sourceUsername = sourceEnvVars.DB_USER;
81
+ sourcePassword = sourceEnvVars.DB_PASSWORD;
82
+ sourceDbName = sourceEnvVars.DB_NAME;
83
+ }
84
+
85
+ const { targetEnvAndComponent } = await this.prompt({
86
+ type: "list",
87
+ name: "targetEnvAndComponent",
88
+ choices: envs,
89
+
90
+ message: "target env? šŸ¤” ",
91
+ });
92
+
93
+ const [targetEnv, targetComponent] = targetEnvAndComponent.split(":");
94
+
95
+ const targetContext = await getPipelineContextByChoice(
96
+ targetEnv,
97
+ targetComponent
98
+ );
99
+
100
+ const targetEnvVars = await getEnvVarsResolved(
101
+ this,
102
+ targetContext.environment.shortName,
103
+ targetContext.componentName
104
+ );
105
+
106
+ if (targetEnv === "local") {
107
+ const parser = new ConnectionStringParser({
108
+ scheme: "postgres",
109
+ hosts: [],
110
+ });
111
+
112
+ const parsersResult = parser.parse(targetEnvVars.DATABASE_URL);
113
+
114
+ targetPort = parsersResult.hosts?.[0]?.port;
115
+ targetUsername = parsersResult.username;
116
+ targetPassword = parsersResult.password;
117
+ targetDbName = parsersResult.endpoint;
118
+ } else {
119
+ targetPort = 54499;
120
+ targetProxy = await startCloudSqlProxyInBackground({
121
+ instanceName: targetEnvVars.CLOUD_SQL_INSTANCE_CONNECTION_NAME,
122
+ localPort: targetPort,
123
+ });
124
+
125
+ targetUsername = targetEnvVars.DB_USER;
126
+ targetPassword = targetEnvVars.DB_PASSWORD;
127
+ targetDbName = sourceEnvVars.DB_NAME;
128
+ }
129
+
130
+ const { shouldContinue } = await this.prompt({
131
+ type: "confirm",
132
+ name: "shouldContinue",
133
+ message: `This will drop ${targetEnv}/${targetDbName} and replace it with ${sourceEnv}/${sourceDbName}. Continue? šŸ¤” `,
134
+ });
135
+
136
+ if (!shouldContinue) {
137
+ this.log("abort");
138
+ closeAll();
139
+ return;
140
+ }
141
+
142
+ if (targetContext.environment.envType === "prod") {
143
+ this.log(
144
+ `\n🚨 You are overriding a production environment. Please type in ${targetEnvVars.CLOUD_SQL_INSTANCE_CONNECTION_NAME} to continue\n\n`
145
+ );
146
+ const { confirmInstance } = await this.prompt({
147
+ type: "input",
148
+ name: "confirmInstance",
149
+ message: "confirm: ",
150
+ });
151
+
152
+ if (
153
+ confirmInstance !== targetEnvVars.CLOUD_SQL_INSTANCE_CONNECTION_NAME
154
+ ) {
155
+ this.log("abort");
156
+ closeAll();
157
+ return;
158
+ }
159
+ }
160
+
161
+ try {
162
+ await spawnCopyDb({
163
+ targetPassword,
164
+ targetPort,
165
+ targetUsername,
166
+ sourceUsername,
167
+ sourcePassword,
168
+ sourcePort,
169
+ sourceDbName,
170
+ targetDbName,
171
+ });
172
+ } finally {
173
+ closeAll();
174
+ }
175
+ });