@catladder/cli 0.0.0-test7 → 0.0.0-waitfor-deploy-e64a33ba

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 (303) hide show
  1. package/.nvmrc +1 -1
  2. package/README.md +6 -3
  3. package/bin/catenv +3 -0
  4. package/bin/catladder +1 -1
  5. package/dist/apps/catenv/catenv.d.ts +5 -0
  6. package/dist/apps/catenv/catenv.js +143 -0
  7. package/dist/apps/catenv/catenv.js.map +1 -0
  8. package/dist/apps/cli/cli.d.ts +2 -0
  9. package/dist/apps/cli/cli.js +81 -0
  10. package/dist/apps/cli/cli.js.map +1 -0
  11. package/dist/apps/cli/commands/general/index.d.ts +4 -0
  12. package/dist/apps/cli/commands/general/index.js +216 -0
  13. package/dist/apps/cli/commands/general/index.js.map +1 -0
  14. package/dist/apps/cli/commands/general/namespaceAutoCompletion.d.ts +3 -0
  15. package/dist/apps/cli/commands/general/namespaceAutoCompletion.js +56 -0
  16. package/dist/apps/cli/commands/general/namespaceAutoCompletion.js.map +1 -0
  17. package/dist/apps/cli/commands/general/portForward.d.ts +3 -0
  18. package/dist/apps/cli/commands/general/portForward.js +97 -0
  19. package/dist/apps/cli/commands/general/portForward.js.map +1 -0
  20. package/dist/apps/cli/commands/mongodb/index.d.ts +3 -0
  21. package/dist/apps/cli/commands/mongodb/index.js +53 -0
  22. package/dist/apps/cli/commands/mongodb/index.js.map +1 -0
  23. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +3 -0
  24. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +190 -0
  25. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -0
  26. package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +3 -0
  27. package/dist/apps/cli/commands/mongodb/projectMongoGetShell.js +96 -0
  28. package/dist/apps/cli/commands/mongodb/projectMongoGetShell.js.map +1 -0
  29. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +3 -0
  30. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +105 -0
  31. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -0
  32. package/dist/apps/cli/commands/mongodb/utils/index.d.ts +13 -0
  33. package/dist/apps/cli/commands/mongodb/utils/index.js +167 -0
  34. package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -0
  35. package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +3 -0
  36. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +137 -0
  37. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -0
  38. package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +4 -0
  39. package/dist/apps/cli/commands/project/commandConfigSecrets.js +320 -0
  40. package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -0
  41. package/dist/apps/cli/commands/project/commandCopyDB.d.ts +3 -0
  42. package/dist/apps/cli/commands/project/commandCopyDB.js +102 -0
  43. package/dist/apps/cli/commands/project/commandCopyDB.js.map +1 -0
  44. package/dist/apps/cli/commands/project/commandDeletePods.d.ts +3 -0
  45. package/dist/apps/cli/commands/project/commandDeletePods.js +120 -0
  46. package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -0
  47. package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +3 -0
  48. package/dist/apps/cli/commands/project/commandDeleteProject.js +97 -0
  49. package/dist/apps/cli/commands/project/commandDeleteProject.js.map +1 -0
  50. package/dist/apps/cli/commands/project/commandEnvVars.d.ts +3 -0
  51. package/dist/apps/cli/commands/project/commandEnvVars.js +74 -0
  52. package/dist/apps/cli/commands/project/commandEnvVars.js.map +1 -0
  53. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +3 -0
  54. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js +58 -0
  55. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js.map +1 -0
  56. package/dist/apps/cli/commands/project/commandGetShell.d.ts +3 -0
  57. package/dist/apps/cli/commands/project/commandGetShell.js +92 -0
  58. package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -0
  59. package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +3 -0
  60. package/dist/apps/cli/commands/project/commandGitlabCi.js +185 -0
  61. package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -0
  62. package/dist/apps/cli/commands/project/commandInitProject.old.d.ts +3 -0
  63. package/dist/apps/cli/commands/project/commandInitProject.old.js +345 -0
  64. package/dist/apps/cli/commands/project/commandInitProject.old.js.map +1 -0
  65. package/dist/apps/cli/commands/project/commandListPods.d.ts +3 -0
  66. package/dist/apps/cli/commands/project/commandListPods.js +78 -0
  67. package/dist/apps/cli/commands/project/commandListPods.js.map +1 -0
  68. package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +7 -0
  69. package/dist/apps/cli/commands/project/commandMigrateHelm3.js +113 -0
  70. package/dist/apps/cli/commands/project/commandMigrateHelm3.js.map +1 -0
  71. package/dist/apps/cli/commands/project/commandNamespace.d.ts +3 -0
  72. package/dist/apps/cli/commands/project/commandNamespace.js +70 -0
  73. package/dist/apps/cli/commands/project/commandNamespace.js.map +1 -0
  74. package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +3 -0
  75. package/dist/apps/cli/commands/project/commandOpenCostDashboard.js +83 -0
  76. package/dist/apps/cli/commands/project/commandOpenCostDashboard.js.map +1 -0
  77. package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +3 -0
  78. package/dist/apps/cli/commands/project/commandOpenDashboard.js +85 -0
  79. package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -0
  80. package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +3 -0
  81. package/dist/apps/cli/commands/project/commandOpenEnv.js +80 -0
  82. package/dist/apps/cli/commands/project/commandOpenEnv.js.map +1 -0
  83. package/dist/apps/cli/commands/project/commandOpenGit.d.ts +3 -0
  84. package/dist/apps/cli/commands/project/commandOpenGit.js +61 -0
  85. package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -0
  86. package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +3 -0
  87. package/dist/apps/cli/commands/project/commandOpenGrafana.js +83 -0
  88. package/dist/apps/cli/commands/project/commandOpenGrafana.js.map +1 -0
  89. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +3 -0
  90. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +99 -0
  91. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -0
  92. package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +3 -0
  93. package/dist/apps/cli/commands/project/commandOpenLogs.js +87 -0
  94. package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -0
  95. package/dist/apps/cli/commands/project/commandPauseProject.d.ts +3 -0
  96. package/dist/apps/cli/commands/project/commandPauseProject.js +97 -0
  97. package/dist/apps/cli/commands/project/commandPauseProject.js.map +1 -0
  98. package/dist/apps/cli/commands/project/commandPortForward.d.ts +3 -0
  99. package/dist/apps/cli/commands/project/commandPortForward.js +106 -0
  100. package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -0
  101. package/dist/apps/cli/commands/project/commandSetup.d.ts +3 -0
  102. package/dist/apps/cli/commands/project/commandSetup.js +58 -0
  103. package/dist/apps/cli/commands/project/commandSetup.js.map +1 -0
  104. package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +3 -0
  105. package/dist/apps/cli/commands/project/commandTriggerCronjob.js +144 -0
  106. package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -0
  107. package/dist/apps/cli/commands/project/index.d.ts +3 -0
  108. package/dist/apps/cli/commands/project/index.js +94 -0
  109. package/dist/apps/cli/commands/project/index.js.map +1 -0
  110. package/dist/apps/cli/commands/project/setup/index.d.ts +2 -0
  111. package/dist/apps/cli/commands/project/setup/index.js +103 -0
  112. package/dist/apps/cli/commands/project/setup/index.js.map +1 -0
  113. package/dist/apps/cli/commands/project/setup/setupAccessTokens.d.ts +2 -0
  114. package/dist/apps/cli/commands/project/setup/setupAccessTokens.js +115 -0
  115. package/dist/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -0
  116. package/dist/apps/cli/commands/project/setup/setupContext.d.ts +3 -0
  117. package/dist/apps/cli/commands/project/setup/setupContext.js +74 -0
  118. package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -0
  119. package/dist/apps/cli/commands/project/setup/setupKubernetes.d.ts +3 -0
  120. package/dist/apps/cli/commands/project/setup/setupKubernetes.js +132 -0
  121. package/dist/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -0
  122. package/dist/apps/cli/commands/project/utils/autocompletions.d.ts +3 -0
  123. package/dist/apps/cli/commands/project/utils/autocompletions.js +96 -0
  124. package/dist/apps/cli/commands/project/utils/autocompletions.js.map +1 -0
  125. package/dist/apps/cli/commands/project/utils/ensureCluster.d.ts +1 -0
  126. package/dist/apps/cli/commands/project/utils/ensureCluster.js +84 -0
  127. package/dist/apps/cli/commands/project/utils/ensureCluster.js.map +1 -0
  128. package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +2 -0
  129. package/dist/apps/cli/commands/project/utils/ensureNamespace.js +104 -0
  130. package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -0
  131. package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +2 -0
  132. package/dist/apps/cli/commands/project/utils/showProjectBanner.js +58 -0
  133. package/dist/apps/cli/commands/project/utils/showProjectBanner.js.map +1 -0
  134. package/dist/apps/cli/commands/shared/index.d.ts +3 -0
  135. package/dist/apps/cli/commands/shared/index.js +70 -0
  136. package/dist/apps/cli/commands/shared/index.js.map +1 -0
  137. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +3 -0
  138. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js +101 -0
  139. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js.map +1 -0
  140. package/dist/apps/cli/config/writeConfig.d.ts +5 -0
  141. package/dist/apps/cli/config/writeConfig.js +106 -0
  142. package/dist/apps/cli/config/writeConfig.js.map +1 -0
  143. package/dist/apps/cli/utils/getGoogleAuthUserNumber.d.ts +1 -0
  144. package/dist/apps/cli/utils/getGoogleAuthUserNumber.js +69 -0
  145. package/dist/apps/cli/utils/getGoogleAuthUserNumber.js.map +1 -0
  146. package/dist/apps/cli/verify/index.d.ts +2 -0
  147. package/dist/apps/cli/verify/index.js +94 -0
  148. package/dist/apps/cli/verify/index.js.map +1 -0
  149. package/dist/apps/cli/verify/migration/fromv2.d.ts +4 -0
  150. package/dist/apps/cli/verify/migration/fromv2.js +347 -0
  151. package/dist/apps/cli/verify/migration/fromv2.js.map +1 -0
  152. package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +4 -0
  153. package/dist/apps/cli/verify/migration/migrateSecrets.js +88 -0
  154. package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -0
  155. package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +18 -0
  156. package/dist/apps/cli/verify/migration/oldGitlabCi.js +30 -0
  157. package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +1 -0
  158. package/dist/catenv.d.ts +1 -0
  159. package/dist/catenv.js +15 -0
  160. package/dist/catenv.js.map +1 -0
  161. package/dist/cli.d.ts +1 -0
  162. package/dist/cli.js +15 -0
  163. package/dist/cli.js.map +1 -0
  164. package/dist/config/constants.d.ts +3 -0
  165. package/dist/config/constants.js +7 -0
  166. package/dist/config/constants.js.map +1 -0
  167. package/dist/config/getProjectConfig.d.ts +24 -0
  168. package/dist/config/getProjectConfig.js +259 -0
  169. package/dist/config/getProjectConfig.js.map +1 -0
  170. package/dist/k8sApi/index.d.ts +8 -0
  171. package/dist/k8sApi/index.js +29 -0
  172. package/dist/k8sApi/index.js.map +1 -0
  173. package/dist/packageInfos.d.ts +2 -0
  174. package/dist/packageInfos.js +6 -0
  175. package/dist/packageInfos.js.map +1 -0
  176. package/dist/tsconfig.tsbuildinfo +1 -0
  177. package/dist/types/types.d.ts +18 -0
  178. package/dist/types/types.js +3 -0
  179. package/dist/types/types.js.map +1 -0
  180. package/dist/utils/cluster.d.ts +3 -0
  181. package/dist/utils/cluster.js +73 -0
  182. package/dist/utils/cluster.js.map +1 -0
  183. package/dist/utils/editAsFile.d.ts +1 -0
  184. package/dist/utils/editAsFile.js +85 -0
  185. package/dist/utils/editAsFile.js.map +1 -0
  186. package/dist/utils/files.d.ts +2 -0
  187. package/dist/utils/files.js +83 -0
  188. package/dist/utils/files.js.map +1 -0
  189. package/dist/utils/getEditor.d.ts +4 -0
  190. package/dist/utils/getEditor.js +70 -0
  191. package/dist/utils/getEditor.js.map +1 -0
  192. package/dist/utils/gitlab.d.ts +22 -0
  193. package/dist/utils/gitlab.js +278 -0
  194. package/dist/utils/gitlab.js.map +1 -0
  195. package/dist/utils/log.d.ts +1 -0
  196. package/dist/utils/log.js +14 -0
  197. package/dist/utils/log.js.map +1 -0
  198. package/dist/utils/passwordstore/index.d.ts +8 -0
  199. package/dist/utils/passwordstore/index.js +378 -0
  200. package/dist/utils/passwordstore/index.js.map +1 -0
  201. package/dist/utils/portForward.d.ts +4 -0
  202. package/dist/utils/portForward.js +116 -0
  203. package/dist/utils/portForward.js.map +1 -0
  204. package/dist/utils/preferences/index.d.ts +3 -0
  205. package/dist/utils/preferences/index.js +119 -0
  206. package/dist/utils/preferences/index.js.map +1 -0
  207. package/dist/utils/projects/index.d.ts +8 -0
  208. package/dist/utils/projects/index.js +153 -0
  209. package/dist/utils/projects/index.js.map +1 -0
  210. package/dist/utils/promise.d.ts +2 -0
  211. package/dist/utils/promise.js +62 -0
  212. package/dist/utils/promise.js.map +1 -0
  213. package/dist/utils/shell.d.ts +1 -0
  214. package/dist/utils/shell.js +81 -0
  215. package/dist/utils/shell.js.map +1 -0
  216. package/package.json +16 -21
  217. package/src/apps/catenv/catenv.ts +55 -27
  218. package/src/apps/{shell/shell.ts → cli/cli.ts} +10 -2
  219. package/src/apps/{shell → cli}/commands/general/index.ts +7 -46
  220. package/src/apps/{shell → cli}/commands/general/namespaceAutoCompletion.ts +0 -0
  221. package/src/apps/{shell → cli}/commands/general/portForward.ts +3 -2
  222. package/src/apps/{shell → cli}/commands/mongodb/index.ts +1 -1
  223. package/src/apps/{shell → cli}/commands/mongodb/projectMongoDestroyMember.ts +18 -18
  224. package/src/apps/{shell → cli}/commands/mongodb/projectMongoGetShell.ts +12 -10
  225. package/src/apps/{shell → cli}/commands/mongodb/projectMongoPortForward.ts +13 -8
  226. package/src/apps/{shell → cli}/commands/mongodb/utils/index.ts +9 -8
  227. package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +88 -0
  228. package/src/apps/cli/commands/project/commandConfigSecrets.ts +220 -0
  229. package/src/apps/{shell → cli}/commands/project/commandCopyDB.ts +24 -26
  230. package/src/apps/{shell → cli}/commands/project/commandDeletePods.ts +10 -10
  231. package/src/apps/{shell → cli}/commands/project/commandDeleteProject.ts +7 -8
  232. package/src/apps/cli/commands/project/commandEnvVars.ts +15 -0
  233. package/src/apps/{shell → cli}/commands/project/commandGetMyTotalWorktime.ts +2 -2
  234. package/src/apps/{shell → cli}/commands/project/commandGetShell.ts +10 -10
  235. package/src/apps/{shell → cli}/commands/project/commandGitlabCi.ts +1 -1
  236. package/src/apps/{shell/commands/project/commandInitProject.ts → cli/commands/project/commandInitProject.old.ts} +14 -6
  237. package/src/apps/cli/commands/project/commandListPods.ts +18 -0
  238. package/src/apps/{shell → cli}/commands/project/commandMigrateHelm3.ts +16 -7
  239. package/src/apps/cli/commands/project/commandNamespace.ts +14 -0
  240. package/src/apps/{shell → cli}/commands/project/commandOpenCostDashboard.ts +10 -7
  241. package/src/apps/cli/commands/project/commandOpenDashboard.ts +48 -0
  242. package/src/apps/cli/commands/project/commandOpenEnv.ts +22 -0
  243. package/src/apps/{shell → cli}/commands/project/commandOpenGit.ts +3 -3
  244. package/src/apps/{shell → cli}/commands/project/commandOpenGrafana.ts +7 -7
  245. package/src/apps/{shell → cli}/commands/project/commandOpenGrafanaPod.ts +9 -10
  246. package/src/apps/cli/commands/project/commandOpenLogs.ts +52 -0
  247. package/src/apps/{shell → cli}/commands/project/commandPauseProject.ts +9 -7
  248. package/src/apps/{shell → cli}/commands/project/commandPortForward.ts +8 -8
  249. package/src/apps/cli/commands/project/commandSetup.ts +12 -0
  250. package/src/apps/{shell → cli}/commands/project/commandTriggerCronjob.ts +10 -10
  251. package/src/apps/{shell → cli}/commands/project/index.ts +6 -7
  252. package/src/apps/cli/commands/project/setup/index.ts +42 -0
  253. package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +72 -0
  254. package/src/apps/cli/commands/project/setup/setupContext.ts +37 -0
  255. package/src/apps/cli/commands/project/setup/setupKubernetes.ts +112 -0
  256. package/src/apps/cli/commands/project/utils/autocompletions.ts +26 -0
  257. package/src/apps/cli/commands/project/utils/ensureCluster.ts +42 -0
  258. package/src/apps/cli/commands/project/utils/ensureNamespace.ts +56 -0
  259. package/src/apps/cli/commands/project/utils/showProjectBanner.ts +11 -0
  260. package/src/apps/cli/commands/shared/index.ts +36 -0
  261. package/src/apps/{shell → cli}/commands/theStuffThatReallyMatters/index.ts +7 -26
  262. package/src/apps/cli/config/writeConfig.ts +71 -0
  263. package/src/apps/{shell → cli}/utils/getGoogleAuthUserNumber.ts +0 -0
  264. package/src/apps/cli/verify/index.ts +30 -0
  265. package/src/apps/cli/verify/migration/fromv2.ts +264 -0
  266. package/src/apps/cli/verify/migration/migrateSecrets.ts +37 -0
  267. package/src/apps/cli/verify/migration/oldGitlabCi.ts +48 -0
  268. package/src/catenv.ts +11 -0
  269. package/src/cli.ts +9 -0
  270. package/src/config/constants.ts +0 -1
  271. package/src/config/getProjectConfig.ts +160 -0
  272. package/src/k8sApi/index.ts +22 -6
  273. package/src/types/types.ts +0 -2
  274. package/src/utils/cluster.ts +6 -15
  275. package/src/utils/editAsFile.ts +31 -0
  276. package/src/utils/files.ts +6 -2
  277. package/src/utils/gitlab.ts +144 -34
  278. package/src/utils/passwordstore/index.ts +19 -21
  279. package/src/utils/preferences/index.ts +6 -3
  280. package/src/utils/projects/index.ts +18 -137
  281. package/tsconfig.json +3 -7
  282. package/bin/catenv.sh +0 -1
  283. package/src/apps/shell/commands/project/commandCloudSqlProxy.ts +0 -65
  284. package/src/apps/shell/commands/project/commandConfigSecrets.ts +0 -245
  285. package/src/apps/shell/commands/project/commandEnvVars.ts +0 -17
  286. package/src/apps/shell/commands/project/commandInitGitlab.ts +0 -157
  287. package/src/apps/shell/commands/project/commandListPods.ts +0 -21
  288. package/src/apps/shell/commands/project/commandNamespace.ts +0 -12
  289. package/src/apps/shell/commands/project/commandOpenDashboard.ts +0 -27
  290. package/src/apps/shell/commands/project/commandOpenEnv.ts +0 -18
  291. package/src/apps/shell/commands/project/commandOpenLogs.ts +0 -23
  292. package/src/apps/shell/commands/project/commandVariables.ts +0 -13
  293. package/src/apps/shell/commands/project/utils/autocompletions.ts +0 -7
  294. package/src/apps/shell/commands/project/utils/ensureCluster.ts +0 -31
  295. package/src/apps/shell/commands/project/utils/ensureNamespace.ts +0 -32
  296. package/src/apps/shell/commands/project/utils/monorepo.ts +0 -45
  297. package/src/apps/shell/commands/shared/index.ts +0 -31
  298. package/src/config/clusters.ts +0 -45
  299. package/src/index.ts +0 -17
  300. package/src/types/git-repo-name.d.ts +0 -1
  301. package/src/types/yawn-yaml.d.ts +0 -1
  302. package/src/utils/dashboardToken.ts +0 -20
  303. package/src/utils/formatEnvVars.ts +0 -7
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ exports.__esModule = true;
50
+ exports.getProjectMongodbAllPodsSortedWithLabel = exports.getMongoDbPodsWithReplInfo = exports.podIsMaster = exports.executeMongodbCommand = exports.getMongodbShell = exports.getProjectMongodbAllPods = void 0;
51
+ var child_process_promise_1 = require("child-process-promise");
52
+ var projects_1 = require("../../../../../utils/projects");
53
+ var filterMongoDbs = function (podNames) {
54
+ return podNames.filter(function (name) { return name.includes("mongodb-replicaset"); });
55
+ };
56
+ var getProjectMongodbAllPods = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
57
+ switch (_b.label) {
58
+ case 0:
59
+ _a = filterMongoDbs;
60
+ return [4 /*yield*/, (0, projects_1.getProjectPodNames)(envComponent)];
61
+ case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
62
+ }
63
+ }); }); };
64
+ exports.getProjectMongodbAllPods = getProjectMongodbAllPods;
65
+ var getMongodbShell = function (namespace, podName) { return __awaiter(void 0, void 0, void 0, function () {
66
+ var command, e_1;
67
+ return __generator(this, function (_a) {
68
+ switch (_a.label) {
69
+ case 0:
70
+ command = "kubectl exec -it ".concat(podName, " --namespace ").concat(namespace, " mongo");
71
+ _a.label = 1;
72
+ case 1:
73
+ _a.trys.push([1, 3, , 4]);
74
+ return [4 /*yield*/, (0, child_process_promise_1.spawn)(command, {
75
+ shell: true,
76
+ stdio: "inherit",
77
+ env: __assign(__assign({}, process.env), { DEBUG: "" })
78
+ })];
79
+ case 2:
80
+ _a.sent();
81
+ return [3 /*break*/, 4];
82
+ case 3:
83
+ e_1 = _a.sent();
84
+ return [3 /*break*/, 4];
85
+ case 4: return [2 /*return*/];
86
+ }
87
+ });
88
+ }); };
89
+ exports.getMongodbShell = getMongodbShell;
90
+ var executeMongodbCommand = function (namespace, podName, mongoCommand) { return __awaiter(void 0, void 0, void 0, function () {
91
+ var fullCommand, stdout;
92
+ return __generator(this, function (_a) {
93
+ switch (_a.label) {
94
+ case 0:
95
+ fullCommand = "kubectl exec -it ".concat(podName, " --namespace ").concat(namespace, " -- mongo --quiet --eval \"JSON.stringify(").concat(mongoCommand, ")\"");
96
+ return [4 /*yield*/, (0, child_process_promise_1.exec)(fullCommand, {
97
+ env: __assign(__assign({}, process.env), { DEBUG: "" })
98
+ })];
99
+ case 1:
100
+ stdout = (_a.sent()).stdout;
101
+ return [2 /*return*/, JSON.parse(stdout)];
102
+ }
103
+ });
104
+ }); };
105
+ exports.executeMongodbCommand = executeMongodbCommand;
106
+ var podIsMaster = function (namespace, podName) { return __awaiter(void 0, void 0, void 0, function () {
107
+ var result;
108
+ return __generator(this, function (_a) {
109
+ switch (_a.label) {
110
+ case 0: return [4 /*yield*/, (0, exports.executeMongodbCommand)(namespace, podName, "db.isMaster()")];
111
+ case 1:
112
+ result = _a.sent();
113
+ return [2 /*return*/, result.ismaster];
114
+ }
115
+ });
116
+ }); };
117
+ exports.podIsMaster = podIsMaster;
118
+ var spaces = function (n) { return " ".repeat(n); };
119
+ var getMongoDbPodsWithReplInfo = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
120
+ var namespace, _a, _b;
121
+ return __generator(this, function (_c) {
122
+ switch (_c.label) {
123
+ case 0: return [4 /*yield*/, (0, projects_1.getProjectNamespace)(envComponent)];
124
+ case 1:
125
+ namespace = _c.sent();
126
+ _b = (_a = Promise).all;
127
+ return [4 /*yield*/, (0, exports.getProjectMongodbAllPods)(envComponent)];
128
+ case 2: return [4 /*yield*/, _b.apply(_a, [(_c.sent()).map(function (podName) { return __awaiter(void 0, void 0, void 0, function () {
129
+ var _a;
130
+ return __generator(this, function (_b) {
131
+ switch (_b.label) {
132
+ case 0:
133
+ _a = {
134
+ podName: podName,
135
+ componentName: podName.replace(/-mongodb-replicaset-[0-9]+/, "")
136
+ };
137
+ return [4 /*yield*/, (0, exports.podIsMaster)(namespace, podName)];
138
+ case 1: return [2 /*return*/, (_a.isMaster = _b.sent(),
139
+ _a)];
140
+ }
141
+ });
142
+ }); })])];
143
+ case 3: return [2 /*return*/, (_c.sent()).sort(function (podA, podB) { return (podA.isMaster ? (podB.isMaster ? 0 : -1) : 1); })];
144
+ }
145
+ });
146
+ }); };
147
+ exports.getMongoDbPodsWithReplInfo = getMongoDbPodsWithReplInfo;
148
+ var getProjectMongodbAllPodsSortedWithLabel = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
149
+ var pods, maxComponentNameLength;
150
+ return __generator(this, function (_a) {
151
+ switch (_a.label) {
152
+ case 0: return [4 /*yield*/, (0, exports.getMongoDbPodsWithReplInfo)(envComponent)];
153
+ case 1:
154
+ pods = _a.sent();
155
+ maxComponentNameLength = Math.max.apply(Math, pods.map(function (c) { return c.componentName.length; }));
156
+ return [2 /*return*/, pods.map(function (_a) {
157
+ var podName = _a.podName, isMaster = _a.isMaster, componentName = _a.componentName;
158
+ return ({
159
+ value: podName,
160
+ name: "[ ".concat(componentName).concat(spaces(maxComponentNameLength - componentName.length), " ").concat(isMaster ? " PRIMARY " : " secondary ", "] ").concat(podName)
161
+ });
162
+ })];
163
+ }
164
+ });
165
+ }); };
166
+ exports.getProjectMongodbAllPodsSortedWithLabel = getProjectMongodbAllPodsSortedWithLabel;
167
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/apps/cli/commands/mongodb/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAoD;AACpD,0DAGuC;AAEvC,IAAM,cAAc,GAAG,UAAC,QAAkB;IACxC,OAAA,QAAQ,CAAC,MAAM,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAnC,CAAmC,CAAC;AAA9D,CAA8D,CAAC;AAE1D,IAAM,wBAAwB,GAAG,UAAO,YAAoB;;;YACjE,KAAA,cA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BAAlC,OAAO,aAAA,EAAE,QAAQ,cAAA,EAAE,aAAa,mBAAA;wBAAO,OAAA,CAAC;4BACzD,KAAK,EAAE,OAAO;4BACd,IAAI,EAAE,YAAK,aAAa,SAAG,MAAM,CAC/B,sBAAsB,GAAG,aAAa,CAAC,MAAM,CAC9C,cAAI,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,eAAK,OAAO,CAAE;yBAC5D,CAAC;oBALwD,CAKxD,CAAC,EAAC;;;KACL,CAAC;AAbW,QAAA,uCAAuC,2CAalD"}
@@ -0,0 +1,3 @@
1
+ import Vorpal from "vorpal";
2
+ declare const _default: (vorpal: Vorpal) => Promise<Vorpal.Command>;
3
+ export default _default;
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ exports.__esModule = true;
39
+ var pipeline_1 = require("@catladder/pipeline");
40
+ var child_process_promise_1 = require("child-process-promise");
41
+ var fs_extra_1 = require("fs-extra");
42
+ var tmp_promise_1 = require("tmp-promise");
43
+ var getProjectConfig_1 = require("../../../../config/getProjectConfig");
44
+ var autocompletions_1 = require("./utils/autocompletions");
45
+ exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
46
+ var _a, _b;
47
+ return __generator(this, function (_c) {
48
+ switch (_c.label) {
49
+ case 0:
50
+ _b = (_a = vorpal
51
+ .command("project-cloud-sql-proxy <envComponent>", "proxy to cloud sql db"))
52
+ .autocomplete;
53
+ return [4 /*yield*/, (0, autocompletions_1.envAndComponents)()];
54
+ case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])
55
+ .action(function (_a) {
56
+ var _b, _c, _d, _e;
57
+ var envComponent = _a.envComponent;
58
+ return __awaiter(this, void 0, void 0, function () {
59
+ var _f, env, componentName, config, localPort, envVars, POSTGRESQL_PASSWORD, context, values, projectId, defaultInstanceId, instanceId, defaultRegion, region, instanceName, cloudsqlProxyCredentials;
60
+ var _this = this;
61
+ return __generator(this, function (_g) {
62
+ switch (_g.label) {
63
+ case 0:
64
+ _f = (0, getProjectConfig_1.parseChoice)(envComponent), env = _f.env, componentName = _f.componentName;
65
+ return [4 /*yield*/, (0, getProjectConfig_1.getProjectConfig)()];
66
+ case 1:
67
+ config = _g.sent();
68
+ return [4 /*yield*/, this.prompt({
69
+ type: "number",
70
+ name: "localPort",
71
+ "default": "54320",
72
+ message: "Local port: "
73
+ })];
74
+ case 2:
75
+ localPort = (_g.sent()).localPort;
76
+ return [4 /*yield*/, (0, getProjectConfig_1.getEnvVars)(this, env, componentName)];
77
+ case 3:
78
+ envVars = _g.sent();
79
+ POSTGRESQL_PASSWORD = envVars === null || envVars === void 0 ? void 0 : envVars.POSTGRESQL_PASSWORD;
80
+ return [4 /*yield*/, (0, getProjectConfig_1.getPipelineContextByChoice)(env, componentName)];
81
+ case 4:
82
+ context = _g.sent();
83
+ if (!(0, pipeline_1.isOfDeployType)(context.componentConfig.deploy, "kubernetes")) {
84
+ throw new Error("currently only supported for kubernetes deployment");
85
+ }
86
+ this.log("");
87
+ this.log("postgres-PW: ".concat(POSTGRESQL_PASSWORD));
88
+ this.log("");
89
+ this.log("POSTGRESQL_URL=postgresql://postgres:".concat(POSTGRESQL_PASSWORD, "@localhost:").concat(localPort, "/").concat(context.environment.envVars.KUBE_APP_NAME, "?schema=public"));
90
+ this.log("");
91
+ values = context.componentConfig.deploy.values;
92
+ projectId = ((_b = values === null || values === void 0 ? void 0 : values.cloudsql) === null || _b === void 0 ? void 0 : _b.projectId) ||
93
+ ((_c = context.componentConfig.deploy.cluster) === null || _c === void 0 ? void 0 : _c.projectId);
94
+ defaultInstanceId = "".concat(config.customerName, "-").concat(config.appName, "-").concat(env);
95
+ instanceId = ((_d = values === null || values === void 0 ? void 0 : values.cloudsql) === null || _d === void 0 ? void 0 : _d.instanceId) || defaultInstanceId;
96
+ defaultRegion = "europe-west6";
97
+ region = ((_e = values === null || values === void 0 ? void 0 : values.cloudsql) === null || _e === void 0 ? void 0 : _e.region) || defaultRegion;
98
+ instanceName = "".concat(projectId, ":").concat(region, ":").concat(instanceId, "=tcp:").concat(localPort);
99
+ return [4 /*yield*/, (0, getProjectConfig_1.getGitlabVar)(this, env, componentName, "cloudsqlProxyCredentials")];
100
+ case 5:
101
+ cloudsqlProxyCredentials = _g.sent();
102
+ if (!cloudsqlProxyCredentials) {
103
+ // we store cloudsqlProxyCredentials on gitlab, but its currently get pushed via bitwarden due to legacy reasons
104
+ // this will be fixed with when https://git.panter.ch/catladder/catladder/-/merge_requests/32/ is merged
105
+ this.log("cloudsqlProxyCredentials env var missing in gitlab. Please contact gilde-ci-cd about that.");
106
+ throw new Error("cloudsqlProxyCredentials missing in secrets");
107
+ }
108
+ return [4 /*yield*/, (0, tmp_promise_1.withFile)(function (_a) {
109
+ var tmpFilePath = _a.path;
110
+ return __awaiter(_this, void 0, void 0, function () {
111
+ return __generator(this, function (_b) {
112
+ switch (_b.label) {
113
+ case 0: return [4 /*yield*/, (0, fs_extra_1.writeFile)(tmpFilePath, cloudsqlProxyCredentials)];
114
+ case 1:
115
+ _b.sent();
116
+ return [4 /*yield*/, (0, child_process_promise_1.spawn)("cloud_sql_proxy", ["-instances", instanceName, "-credential_file", tmpFilePath], {
117
+ stdio: "inherit",
118
+ shell: true
119
+ })];
120
+ case 2:
121
+ _b.sent();
122
+ return [2 /*return*/];
123
+ }
124
+ });
125
+ });
126
+ })];
127
+ case 6:
128
+ _g.sent();
129
+ return [2 /*return*/];
130
+ }
131
+ });
132
+ });
133
+ })];
134
+ }
135
+ });
136
+ }); });
137
+ //# sourceMappingURL=commandCloudSqlProxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandCloudSqlProxy.js","sourceRoot":"","sources":["../../../../../src/apps/cli/commands/project/commandCloudSqlProxy.ts"],"names":[],"mappings":";;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,CAAC,6CAA6C,CAAC,CAAC;qCAChE;oCACD,qBAAM,IAAA,sBAAQ,EAAC,UAAO,EAAqB;gDAAb,WAAW,UAAA;;;;gEACvC,qBAAM,IAAA,oBAAS,EAAC,WAAW,EAAE,wBAAwB,CAAC,EAAA;;4DAAtD,SAAsD,CAAC;4DAEvD,qBAAM,IAAA,6BAAK,EACT,iBAAiB,EACjB,CAAC,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,CAAC,EAC7D;oEACE,KAAK,EAAE,SAAS;oEAChB,KAAK,EAAE,IAAI;iEACZ,CACF,EAAA;;4DAPD,SAOC,CAAC;;;;;yCACH,CAAC,EAAA;;oCAXF,SAWE,CAAC;;;;;iBACJ,CAAC,EAAA;;;KAAA,EAAC"}
@@ -0,0 +1,4 @@
1
+ import Vorpal, { CommandInstance } from "vorpal";
2
+ export declare const projectConfigSecrets: (vorpal: CommandInstance, envComponent?: string) => Promise<void>;
3
+ declare const _default: (vorpal: Vorpal) => Promise<void>;
4
+ export default _default;
@@ -0,0 +1,320 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ var __generator = (this && this.__generator) || function (thisArg, body) {
16
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
17
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
18
+ function verb(n) { return function (v) { return step([n, v]); }; }
19
+ function step(op) {
20
+ if (f) throw new TypeError("Generator is already executing.");
21
+ while (_) try {
22
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
23
+ if (y = 0, t) op = [op[0] & 2, t.value];
24
+ switch (op[0]) {
25
+ case 0: case 1: t = op; break;
26
+ case 4: _.label++; return { value: op[1], done: false };
27
+ case 5: _.label++; y = op[1]; op = [0]; continue;
28
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
29
+ default:
30
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
31
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
32
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
33
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
34
+ if (t[2]) _.ops.pop();
35
+ _.trys.pop(); continue;
36
+ }
37
+ op = body.call(thisArg, _);
38
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
39
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
40
+ }
41
+ };
42
+ exports.__esModule = true;
43
+ exports.projectConfigSecrets = void 0;
44
+ /* eslint-disable no-constant-condition */
45
+ var common_tags_1 = require("common-tags");
46
+ var lodash_1 = require("lodash");
47
+ var constants_1 = require("../../../../config/constants");
48
+ var getProjectConfig_1 = require("../../../../config/getProjectConfig");
49
+ var editAsFile_1 = require("../../../../utils/editAsFile");
50
+ var gitlab_1 = require("../../../../utils/gitlab");
51
+ var passwordstore_1 = require("../../../../utils/passwordstore");
52
+ var promise_1 = require("../../../../utils/promise");
53
+ var autocompletions_1 = require("./utils/autocompletions");
54
+ /* for convenience, parse json objects. that makes it easier to edit secrets that are object */
55
+ var resolveJson = function (v) {
56
+ return Object.fromEntries(Object.entries(v).map(function (_a) {
57
+ var componentName = _a[0], envs = _a[1];
58
+ return [
59
+ componentName,
60
+ Object.fromEntries(Object.entries(envs).map(function (_a) {
61
+ var env = _a[0], secrets = _a[1];
62
+ return [
63
+ env,
64
+ Object.fromEntries(Object.entries(secrets).map(function (_a) {
65
+ var key = _a[0], value = _a[1];
66
+ try {
67
+ return [key, JSON.parse(value)];
68
+ }
69
+ catch (e) {
70
+ return [key, value];
71
+ }
72
+ })),
73
+ ];
74
+ })),
75
+ ];
76
+ }));
77
+ };
78
+ var getEnvVarsToEdit = function (instance, env, componentName) { return __awaiter(void 0, void 0, void 0, function () {
79
+ var secretEnvVarKeys, allEnvVars;
80
+ return __generator(this, function (_a) {
81
+ switch (_a.label) {
82
+ case 0: return [4 /*yield*/, (0, getProjectConfig_1.getEnvironment)(env, componentName)];
83
+ case 1:
84
+ secretEnvVarKeys = (_a.sent()).secretEnvVarKeys;
85
+ return [4 /*yield*/, (0, getProjectConfig_1.getEnvVars)(instance, env, componentName)];
86
+ case 2:
87
+ allEnvVars = _a.sent();
88
+ return [2 /*return*/, Object.fromEntries(secretEnvVarKeys.map(function (key) { return [key, allEnvVars[key]]; }))];
89
+ }
90
+ });
91
+ }); };
92
+ var doItFor = function (instance, envAndComponents) { return __awaiter(void 0, void 0, void 0, function () {
93
+ var valuesToEdit, _a, _b, hasErrors, _i, _c, _d, componentName, envs, _e, envs_1, env, usedKeys, secretEnvVarKeys, extranous, missing, shouldContinue, _f, _g, _h, componentName, envs, _j, envs_2, env, context, _k, _l, e_1;
94
+ var _m;
95
+ var _o, _p;
96
+ return __generator(this, function (_q) {
97
+ switch (_q.label) {
98
+ case 0:
99
+ _b = (_a = Object).fromEntries;
100
+ return [4 /*yield*/, Promise.all(Object.entries(envAndComponents).map(function (_a) {
101
+ var componentName = _a[0], envs = _a[1];
102
+ return __awaiter(void 0, void 0, void 0, function () {
103
+ var _b, _c, _d;
104
+ return __generator(this, function (_e) {
105
+ switch (_e.label) {
106
+ case 0:
107
+ _b = [componentName];
108
+ _d = (_c = Object).fromEntries;
109
+ return [4 /*yield*/, Promise.all(envs.map(function (env) { return __awaiter(void 0, void 0, void 0, function () {
110
+ var _a;
111
+ return __generator(this, function (_b) {
112
+ switch (_b.label) {
113
+ case 0:
114
+ _a = [env];
115
+ return [4 /*yield*/, getEnvVarsToEdit(instance, env, componentName)];
116
+ case 1: return [2 /*return*/, _a.concat([
117
+ _b.sent()
118
+ ])];
119
+ }
120
+ });
121
+ }); }))];
122
+ case 1: return [2 /*return*/, _b.concat([
123
+ _d.apply(_c, [_e.sent()])
124
+ ])];
125
+ }
126
+ });
127
+ });
128
+ }))];
129
+ case 1:
130
+ valuesToEdit = _b.apply(_a, [_q.sent()]);
131
+ hasErrors = true;
132
+ _q.label = 2;
133
+ case 2:
134
+ if (!hasErrors) return [3 /*break*/, 12];
135
+ return [4 /*yield*/, (0, editAsFile_1.editAsFile)(resolveJson(valuesToEdit), (0, common_tags_1.stripIndents)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n Please fill in all secrets for: \n\n ", "\n\n "], ["\n Please fill in all secrets for: \n\n ", "\n\n "])), Object.entries(envAndComponents)
136
+ .map(function (_a) {
137
+ var componentName = _a[0], envs = _a[1];
138
+ return "- ".concat(componentName, ": ").concat(envs.join(", "));
139
+ })
140
+ .join("\n")))];
141
+ case 3:
142
+ valuesToEdit = _q.sent();
143
+ // check for errors
144
+ hasErrors = false;
145
+ _i = 0, _c = Object.entries(envAndComponents);
146
+ _q.label = 4;
147
+ case 4:
148
+ if (!(_i < _c.length)) return [3 /*break*/, 11];
149
+ _d = _c[_i], componentName = _d[0], envs = _d[1];
150
+ _e = 0, envs_1 = envs;
151
+ _q.label = 5;
152
+ case 5:
153
+ if (!(_e < envs_1.length)) return [3 /*break*/, 10];
154
+ env = envs_1[_e];
155
+ usedKeys = valuesToEdit[componentName][env]
156
+ ? Object.keys(valuesToEdit[componentName][env])
157
+ : [];
158
+ return [4 /*yield*/, (0, getProjectConfig_1.getEnvironment)(env, componentName)];
159
+ case 6:
160
+ secretEnvVarKeys = (_q.sent()).secretEnvVarKeys;
161
+ extranous = (0, lodash_1.difference)(usedKeys, secretEnvVarKeys);
162
+ missing = (0, lodash_1.difference)(secretEnvVarKeys, usedKeys);
163
+ if (!(extranous.length > 0 || missing.length > 0)) return [3 /*break*/, 9];
164
+ instance.log("");
165
+ instance.log("\uD83D\uDE3F Oh no! There is something wrong with \"".concat(componentName, "\""));
166
+ instance.log("");
167
+ if (extranous.length > 0) {
168
+ instance.log("these secrets are not declared in the config");
169
+ extranous.forEach(function (key) { return instance.log(key); });
170
+ instance.log("");
171
+ }
172
+ if (missing.length > 0) {
173
+ instance.log("these secrets have not been provided:");
174
+ missing.forEach(function (key) { return instance.log(key); });
175
+ instance.log("");
176
+ }
177
+ return [4 /*yield*/, (0, promise_1.delay)(1000)];
178
+ case 7:
179
+ _q.sent();
180
+ return [4 /*yield*/, instance.prompt({
181
+ "default": true,
182
+ message: "Try again? 🤔",
183
+ name: "shouldContinue",
184
+ type: "confirm"
185
+ })];
186
+ case 8:
187
+ shouldContinue = (_q.sent()).shouldContinue;
188
+ if (!shouldContinue) {
189
+ throw new Error("abort");
190
+ }
191
+ hasErrors = true;
192
+ _q.label = 9;
193
+ case 9:
194
+ _e++;
195
+ return [3 /*break*/, 5];
196
+ case 10:
197
+ _i++;
198
+ return [3 /*break*/, 4];
199
+ case 11: return [3 /*break*/, 2];
200
+ case 12:
201
+ instance.log("upserting all variables, please wait...");
202
+ instance.log("");
203
+ _f = 0, _g = Object.entries(envAndComponents);
204
+ _q.label = 13;
205
+ case 13:
206
+ if (!(_f < _g.length)) return [3 /*break*/, 25];
207
+ _h = _g[_f], componentName = _h[0], envs = _h[1];
208
+ _j = 0, envs_2 = envs;
209
+ _q.label = 14;
210
+ case 14:
211
+ if (!(_j < envs_2.length)) return [3 /*break*/, 24];
212
+ env = envs_2[_j];
213
+ return [4 /*yield*/, (0, gitlab_1.upsertAllVariables)(instance, valuesToEdit[componentName][env], env, componentName)];
214
+ case 15:
215
+ _q.sent();
216
+ if (!(0, passwordstore_1.hasBitwarden)()) return [3 /*break*/, 22];
217
+ _q.label = 16;
218
+ case 16:
219
+ _q.trys.push([16, 21, , 22]);
220
+ return [4 /*yield*/, (0, getProjectConfig_1.getPipelineContextByChoice)(env, componentName)];
221
+ case 17:
222
+ context = _q.sent();
223
+ if (!(context.componentConfig.deploy &&
224
+ context.componentConfig.deploy.type === "kubernetes" &&
225
+ ((_p = (_o = context.componentConfig.deploy.values) === null || _o === void 0 ? void 0 : _o.cloudsql) === null || _p === void 0 ? void 0 : _p.enabled))) return [3 /*break*/, 20];
226
+ _k = gitlab_1.upsertAllVariables;
227
+ _l = [instance];
228
+ _m = {};
229
+ return [4 /*yield*/, (0, passwordstore_1.readPass)(constants_1.GOOGLE_CLOUD_SQL_PASS_PATH)];
230
+ case 18: return [4 /*yield*/, _k.apply(void 0, _l.concat([(_m.cloudsqlProxyCredentials = _q.sent(),
231
+ _m), env,
232
+ componentName]))];
233
+ case 19:
234
+ _q.sent();
235
+ _q.label = 20;
236
+ case 20: return [3 /*break*/, 22];
237
+ case 21:
238
+ e_1 = _q.sent();
239
+ return [3 /*break*/, 22];
240
+ case 22:
241
+ instance.log("✅ " + env + ":" + componentName);
242
+ _q.label = 23;
243
+ case 23:
244
+ _j++;
245
+ return [3 /*break*/, 14];
246
+ case 24:
247
+ _f++;
248
+ return [3 /*break*/, 13];
249
+ case 25:
250
+ instance.log("done! 😻");
251
+ instance.log("");
252
+ return [2 /*return*/];
253
+ }
254
+ });
255
+ }); };
256
+ var projectConfigSecrets = function (vorpal, envComponent) { return __awaiter(void 0, void 0, void 0, function () {
257
+ var allEnvAndcomponents, _a, env_1, componentName, components;
258
+ var _b;
259
+ return __generator(this, function (_c) {
260
+ switch (_c.label) {
261
+ case 0:
262
+ if (!!envComponent) return [3 /*break*/, 3];
263
+ return [4 /*yield*/, (0, getProjectConfig_1.getAllComponentsWithAllEnvsHierarchical)()];
264
+ case 1:
265
+ allEnvAndcomponents = _c.sent();
266
+ return [4 /*yield*/, doItFor(vorpal, allEnvAndcomponents)];
267
+ case 2:
268
+ _c.sent();
269
+ return [3 /*break*/, 8];
270
+ case 3:
271
+ _a = (0, getProjectConfig_1.parseChoice)(envComponent), env_1 = _a.env, componentName = _a.componentName;
272
+ if (!!componentName) return [3 /*break*/, 6];
273
+ return [4 /*yield*/, (0, getProjectConfig_1.getProjectComponents)()];
274
+ case 4:
275
+ components = _c.sent();
276
+ return [4 /*yield*/, doItFor(vorpal, Object.fromEntries(components.map(function (c) { return [c, [env_1]]; })))];
277
+ case 5:
278
+ _c.sent();
279
+ _c.label = 6;
280
+ case 6:
281
+ if (!componentName) return [3 /*break*/, 8];
282
+ return [4 /*yield*/, doItFor(vorpal, (_b = {},
283
+ _b[componentName] = [env_1],
284
+ _b))];
285
+ case 7:
286
+ _c.sent();
287
+ _c.label = 8;
288
+ case 8: return [2 /*return*/];
289
+ }
290
+ });
291
+ }); };
292
+ exports.projectConfigSecrets = projectConfigSecrets;
293
+ exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
294
+ var _a, _b;
295
+ return __generator(this, function (_c) {
296
+ switch (_c.label) {
297
+ case 0:
298
+ _b = (_a = vorpal
299
+ .command("project-config-secrets [envComponent]", "setup/update secrets stored in pass"))
300
+ .autocomplete;
301
+ return [4 /*yield*/, (0, autocompletions_1.allEnvsAndAllComponents)()];
302
+ case 1:
303
+ _b.apply(_a, [_c.sent()])
304
+ .action(function (_a) {
305
+ var envComponent = _a.envComponent;
306
+ return __awaiter(this, void 0, void 0, function () {
307
+ return __generator(this, function (_b) {
308
+ switch (_b.label) {
309
+ case 0: return [4 /*yield*/, (0, exports.projectConfigSecrets)(this, envComponent)];
310
+ case 1: return [2 /*return*/, _b.sent()];
311
+ }
312
+ });
313
+ });
314
+ });
315
+ return [2 /*return*/];
316
+ }
317
+ });
318
+ }); });
319
+ var templateObject_1;
320
+ //# sourceMappingURL=commandConfigSecrets.js.map