@catladder/cli 0.0.0-test3 → 0.0.0-updatemongo6-140b516e

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 (304) 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 +121 -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 +178 -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 +298 -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 +80 -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 +116 -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 +133 -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 +2 -0
  165. package/dist/config/constants.js +6 -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 +340 -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 +7 -0
  199. package/dist/utils/passwordstore/index.js +315 -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 +154 -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 +17 -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/cli/commands/mongodb/projectMongoPortForward.ts +62 -0
  226. package/src/apps/{shell → cli}/commands/mongodb/utils/index.ts +26 -15
  227. package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +88 -0
  228. package/src/apps/cli/commands/project/commandConfigSecrets.ts +200 -0
  229. package/src/apps/{shell → cli}/commands/project/commandCopyDB.ts +25 -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 +73 -0
  254. package/src/apps/cli/commands/project/setup/setupContext.ts +37 -0
  255. package/src/apps/cli/commands/project/setup/setupKubernetes.ts +113 -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 -3
  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 +212 -34
  278. package/src/utils/passwordstore/index.ts +4 -34
  279. package/src/utils/preferences/index.ts +6 -3
  280. package/src/utils/projects/index.ts +22 -138
  281. package/tsconfig.json +3 -7
  282. package/bin/catenv.sh +0 -1
  283. package/src/apps/shell/commands/mongodb/projectMongoPortForward.ts +0 -42
  284. package/src/apps/shell/commands/project/commandCloudSqlProxy.ts +0 -65
  285. package/src/apps/shell/commands/project/commandConfigSecrets.ts +0 -245
  286. package/src/apps/shell/commands/project/commandEnvVars.ts +0 -17
  287. package/src/apps/shell/commands/project/commandInitGitlab.ts +0 -157
  288. package/src/apps/shell/commands/project/commandListPods.ts +0 -21
  289. package/src/apps/shell/commands/project/commandNamespace.ts +0 -12
  290. package/src/apps/shell/commands/project/commandOpenDashboard.ts +0 -27
  291. package/src/apps/shell/commands/project/commandOpenEnv.ts +0 -18
  292. package/src/apps/shell/commands/project/commandOpenLogs.ts +0 -23
  293. package/src/apps/shell/commands/project/commandVariables.ts +0 -13
  294. package/src/apps/shell/commands/project/utils/autocompletions.ts +0 -7
  295. package/src/apps/shell/commands/project/utils/ensureCluster.ts +0 -31
  296. package/src/apps/shell/commands/project/utils/ensureNamespace.ts +0 -32
  297. package/src/apps/shell/commands/project/utils/monorepo.ts +0 -45
  298. package/src/apps/shell/commands/shared/index.ts +0 -31
  299. package/src/config/clusters.ts +0 -45
  300. package/src/index.ts +0 -17
  301. package/src/types/git-repo-name.d.ts +0 -1
  302. package/src/types/yawn-yaml.d.ts +0 -1
  303. package/src/utils/dashboardToken.ts +0 -20
  304. package/src/utils/formatEnvVars.ts +0 -7
@@ -0,0 +1,178 @@
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) {
55
+ return name.includes("mongodb") &&
56
+ !name.includes("mongodb-backup") &&
57
+ !name.includes("arbiter");
58
+ });
59
+ };
60
+ var getProjectMongodbAllPods = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
61
+ switch (_b.label) {
62
+ case 0:
63
+ _a = filterMongoDbs;
64
+ return [4 /*yield*/, (0, projects_1.getProjectPodNames)(envComponent)];
65
+ case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
66
+ }
67
+ }); }); };
68
+ exports.getProjectMongodbAllPods = getProjectMongodbAllPods;
69
+ var getMongodbShell = function (namespace, podName) { return __awaiter(void 0, void 0, void 0, function () {
70
+ var command, e_1;
71
+ return __generator(this, function (_a) {
72
+ switch (_a.label) {
73
+ case 0:
74
+ command = "kubectl exec -it ".concat(podName, " --namespace ").concat(namespace, " mongo");
75
+ _a.label = 1;
76
+ case 1:
77
+ _a.trys.push([1, 3, , 4]);
78
+ return [4 /*yield*/, (0, child_process_promise_1.spawn)(command, {
79
+ shell: true,
80
+ stdio: "inherit",
81
+ env: __assign(__assign({}, process.env), { DEBUG: "" })
82
+ })];
83
+ case 2:
84
+ _a.sent();
85
+ return [3 /*break*/, 4];
86
+ case 3:
87
+ e_1 = _a.sent();
88
+ return [3 /*break*/, 4];
89
+ case 4: return [2 /*return*/];
90
+ }
91
+ });
92
+ }); };
93
+ exports.getMongodbShell = getMongodbShell;
94
+ var executeMongodbCommand = function (namespace, podName, mongoCommand) { return __awaiter(void 0, void 0, void 0, function () {
95
+ var fullCommand, stdout;
96
+ return __generator(this, function (_a) {
97
+ switch (_a.label) {
98
+ case 0:
99
+ fullCommand = "kubectl exec -it ".concat(podName, " --namespace ").concat(namespace, " -- mongo --quiet --eval \"JSON.stringify(").concat(mongoCommand, ")\"");
100
+ return [4 /*yield*/, (0, child_process_promise_1.exec)(fullCommand, {
101
+ env: __assign(__assign({}, process.env), { DEBUG: "" })
102
+ })];
103
+ case 1:
104
+ stdout = (_a.sent()).stdout;
105
+ return [2 /*return*/, JSON.parse(stdout)];
106
+ }
107
+ });
108
+ }); };
109
+ exports.executeMongodbCommand = executeMongodbCommand;
110
+ var podIsMaster = function (namespace, podName) { return __awaiter(void 0, void 0, void 0, function () {
111
+ var result, e_2;
112
+ return __generator(this, function (_a) {
113
+ switch (_a.label) {
114
+ case 0:
115
+ _a.trys.push([0, 2, , 3]);
116
+ return [4 /*yield*/, (0, exports.executeMongodbCommand)(namespace, podName, "db.isMaster()")];
117
+ case 1:
118
+ result = _a.sent();
119
+ return [2 /*return*/, result.ismaster];
120
+ case 2:
121
+ e_2 = _a.sent();
122
+ // maybe shutting down ?
123
+ return [2 /*return*/, null];
124
+ case 3: return [2 /*return*/];
125
+ }
126
+ });
127
+ }); };
128
+ exports.podIsMaster = podIsMaster;
129
+ var spaces = function (n) { return " ".repeat(n); };
130
+ var getMongoDbPodsWithReplInfo = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
131
+ var namespace, _a, _b;
132
+ return __generator(this, function (_c) {
133
+ switch (_c.label) {
134
+ case 0: return [4 /*yield*/, (0, projects_1.getProjectNamespace)(envComponent)];
135
+ case 1:
136
+ namespace = _c.sent();
137
+ _b = (_a = Promise).all;
138
+ return [4 /*yield*/, (0, exports.getProjectMongodbAllPods)(envComponent)];
139
+ case 2: return [4 /*yield*/, _b.apply(_a, [(_c.sent()).map(function (podName) { return __awaiter(void 0, void 0, void 0, function () {
140
+ var _a;
141
+ return __generator(this, function (_b) {
142
+ switch (_b.label) {
143
+ case 0:
144
+ _a = {
145
+ podName: podName,
146
+ componentName: podName.replace(/-mongodb-replicaset-[0-9]+/, "")
147
+ };
148
+ return [4 /*yield*/, (0, exports.podIsMaster)(namespace, podName)];
149
+ case 1: return [2 /*return*/, (_a.isMaster = _b.sent(),
150
+ _a)];
151
+ }
152
+ });
153
+ }); })])];
154
+ case 3: return [2 /*return*/, (_c.sent()).sort(function (podA, podB) { return (podA.isMaster ? (podB.isMaster ? 0 : -1) : 1); })];
155
+ }
156
+ });
157
+ }); };
158
+ exports.getMongoDbPodsWithReplInfo = getMongoDbPodsWithReplInfo;
159
+ var getProjectMongodbAllPodsSortedWithLabel = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
160
+ var pods, maxComponentNameLength;
161
+ return __generator(this, function (_a) {
162
+ switch (_a.label) {
163
+ case 0: return [4 /*yield*/, (0, exports.getMongoDbPodsWithReplInfo)(envComponent)];
164
+ case 1:
165
+ pods = _a.sent();
166
+ maxComponentNameLength = Math.max.apply(Math, pods.map(function (c) { return c.componentName.length; }));
167
+ return [2 /*return*/, pods.map(function (_a) {
168
+ var podName = _a.podName, isMaster = _a.isMaster, componentName = _a.componentName;
169
+ return ({
170
+ value: podName,
171
+ name: "[ ".concat(componentName).concat(spaces(maxComponentNameLength - componentName.length), " ").concat(isMaster ? " PRIMARY " : " secondary ", "] ").concat(podName)
172
+ });
173
+ })];
174
+ }
175
+ });
176
+ }); };
177
+ exports.getProjectMongodbAllPodsSortedWithLabel = getProjectMongodbAllPodsSortedWithLabel;
178
+ //# 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,G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BAA0B,8BAarC;AAEK,IAAM,uCAAuC,GAAG,UACrD,YAAoB;;;;oBAEP,qBAAM,IAAA,kCAA0B,EAAC,YAAY,CAAC,EAAA;;gBAArD,IAAI,GAAG,SAA8C;gBACrD,sBAAsB,GAAG,IAAI,CAAC,GAAG,OAAR,IAAI,EAC9B,IAAI,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,aAAa,CAAC,MAAM,EAAtB,CAAsB,CAAC,CAC3C,CAAC;gBACF,sBAAO,IAAI,CAAC,GAAG,CAAC,UAAC,EAAoC;4BAAlC,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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAqD;AACrD,+DAA8C;AAC9C,qCAAqC;AACrC,2CAAuC;AAEvC,wEAM6C;AAC7C,2DAA2D;AAE3D,sBAAe,UAAO,MAAc;;;;;gBAClC,KAAA,CAAA,KAAA,MAAM;qBACH,OAAO,CAAC,wCAAwC,EAAE,uBAAuB,CAAC,CAAA;qBAC1E,YAAY,CAAA;gBAAC,qBAAM,IAAA,kCAAgB,GAAE,EAAA;oBAFxC,sBAAA,cAEgB,SAAwB,EAAC;qBACtC,MAAM,CAAC,UAAgB,EAAgB;;wBAAd,YAAY,kBAAA;;;;;;;oCAC9B,KAAyB,IAAA,8BAAW,EAAC,YAAY,CAAC,EAAhD,GAAG,SAAA,EAAE,aAAa,mBAAA,CAA+B;oCAE1C,qBAAM,IAAA,mCAAgB,GAAE,EAAA;;oCAAjC,MAAM,GAAG,SAAwB;oCAGjB,qBAAM,IAAI,CAAC,MAAM,CAAC;4CACtC,IAAI,EAAE,QAAQ;4CACd,IAAI,EAAE,WAAW;4CACjB,SAAO,EAAE,OAAO;4CAChB,OAAO,EAAE,cAAc;yCACxB,CAAC,EAAA;;oCALM,SAAS,GAAK,CAAA,SAKpB,CAAA,UALe;oCAOD,qBAAM,IAAA,6BAAU,EAAC,IAAI,EAAE,GAAG,EAAE,aAAa,CAAC,EAAA;;oCAApD,OAAO,GAAG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,KAAI,aAAa,CAAC;oCAEnD,YAAY,GAAG,UAAG,SAAS,cAAI,MAAM,cAAI,UAAU,kBAAQ,SAAS,CAAE,CAAC;oCAE5C,qBAAM,IAAA,+BAAY,EACjD,IAAI,EACJ,GAAG,EACH,aAAa,EACb,0BAA0B,CAC3B,EAAA;;oCALK,wBAAwB,GAAG,SAKhC;oCAED,IAAI,CAAC,wBAAwB,EAAE;wCAC7B,gHAAgH;wCAChH,wGAAwG;wCACxG,IAAI,CAAC,GAAG,CACN,4FAA4F,CAC7F,CAAC;wCACF,MAAM,IAAI,KAAK,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,298 @@
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 pipeline_1 = require("@catladder/pipeline");
46
+ var common_tags_1 = require("common-tags");
47
+ var lodash_1 = require("lodash");
48
+ var getProjectConfig_1 = require("../../../../config/getProjectConfig");
49
+ var editAsFile_1 = require("../../../../utils/editAsFile");
50
+ var gitlab_1 = require("../../../../utils/gitlab");
51
+ var promise_1 = require("../../../../utils/promise");
52
+ var autocompletions_1 = require("./utils/autocompletions");
53
+ /* for convenience, parse json objects. that makes it easier to edit secrets that are object */
54
+ var resolveJson = function (v) {
55
+ return Object.fromEntries(Object.entries(v).map(function (_a) {
56
+ var componentName = _a[0], envs = _a[1];
57
+ return [
58
+ componentName,
59
+ Object.fromEntries(Object.entries(envs).map(function (_a) {
60
+ var env = _a[0], secrets = _a[1];
61
+ return [
62
+ env,
63
+ Object.fromEntries(Object.entries(secrets).map(function (_a) {
64
+ var key = _a[0], value = _a[1];
65
+ try {
66
+ return [key, JSON.parse(value)];
67
+ }
68
+ catch (e) {
69
+ return [key, value];
70
+ }
71
+ })),
72
+ ];
73
+ })),
74
+ ];
75
+ }));
76
+ };
77
+ var getEnvVarsToEdit = function (instance, env, componentName) { return __awaiter(void 0, void 0, void 0, function () {
78
+ var secretEnvVarKeys, allEnvVars;
79
+ return __generator(this, function (_a) {
80
+ switch (_a.label) {
81
+ case 0: return [4 /*yield*/, (0, getProjectConfig_1.getEnvironment)(env, componentName)];
82
+ case 1:
83
+ secretEnvVarKeys = (_a.sent()).secretEnvVarKeys;
84
+ return [4 /*yield*/, (0, getProjectConfig_1.getEnvVars)(instance, env, componentName)];
85
+ case 2:
86
+ allEnvVars = _a.sent();
87
+ return [2 /*return*/, Object.fromEntries(secretEnvVarKeys.map(function (key) {
88
+ var value = allEnvVars[key];
89
+ // due to some quirky way to resolve these variables, unset variables have the $CL_ prefix, so we remove thouse here
90
+ var variableIsNotSet = value === "$" + (0, pipeline_1.getSecretVarName)(env, componentName, key);
91
+ return [key, variableIsNotSet ? "🚨 FILL ME" : value];
92
+ }))];
93
+ }
94
+ });
95
+ }); };
96
+ var doItFor = function (instance, envAndComponents) { return __awaiter(void 0, void 0, void 0, function () {
97
+ 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;
98
+ return __generator(this, function (_k) {
99
+ switch (_k.label) {
100
+ case 0:
101
+ _b = (_a = Object).fromEntries;
102
+ return [4 /*yield*/, Promise.all(Object.entries(envAndComponents).map(function (_a) {
103
+ var componentName = _a[0], envs = _a[1];
104
+ return __awaiter(void 0, void 0, void 0, function () {
105
+ var _b, _c, _d;
106
+ return __generator(this, function (_e) {
107
+ switch (_e.label) {
108
+ case 0:
109
+ _b = [componentName];
110
+ _d = (_c = Object).fromEntries;
111
+ return [4 /*yield*/, Promise.all(envs.map(function (env) { return __awaiter(void 0, void 0, void 0, function () {
112
+ var _a;
113
+ return __generator(this, function (_b) {
114
+ switch (_b.label) {
115
+ case 0:
116
+ _a = [env];
117
+ return [4 /*yield*/, getEnvVarsToEdit(instance, env, componentName)];
118
+ case 1: return [2 /*return*/, _a.concat([
119
+ _b.sent()
120
+ ])];
121
+ }
122
+ });
123
+ }); }))];
124
+ case 1: return [2 /*return*/, _b.concat([
125
+ _d.apply(_c, [_e.sent()])
126
+ ])];
127
+ }
128
+ });
129
+ });
130
+ }))];
131
+ case 1:
132
+ valuesToEdit = _b.apply(_a, [_k.sent()]);
133
+ hasErrors = true;
134
+ _k.label = 2;
135
+ case 2:
136
+ if (!hasErrors) return [3 /*break*/, 12];
137
+ 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)
138
+ .map(function (_a) {
139
+ var componentName = _a[0], envs = _a[1];
140
+ return "- ".concat(componentName, ": ").concat(envs.join(", "));
141
+ })
142
+ .join("\n")))];
143
+ case 3:
144
+ valuesToEdit = _k.sent();
145
+ // check for errors
146
+ hasErrors = false;
147
+ _i = 0, _c = Object.entries(envAndComponents);
148
+ _k.label = 4;
149
+ case 4:
150
+ if (!(_i < _c.length)) return [3 /*break*/, 11];
151
+ _d = _c[_i], componentName = _d[0], envs = _d[1];
152
+ _e = 0, envs_1 = envs;
153
+ _k.label = 5;
154
+ case 5:
155
+ if (!(_e < envs_1.length)) return [3 /*break*/, 10];
156
+ env = envs_1[_e];
157
+ usedKeys = valuesToEdit[componentName][env]
158
+ ? Object.keys(valuesToEdit[componentName][env])
159
+ : [];
160
+ return [4 /*yield*/, (0, getProjectConfig_1.getEnvironment)(env, componentName)];
161
+ case 6:
162
+ secretEnvVarKeys = (_k.sent()).secretEnvVarKeys;
163
+ extranous = (0, lodash_1.difference)(usedKeys, secretEnvVarKeys);
164
+ missing = (0, lodash_1.difference)(secretEnvVarKeys, usedKeys);
165
+ if (!(extranous.length > 0 || missing.length > 0)) return [3 /*break*/, 9];
166
+ instance.log("");
167
+ instance.log("\uD83D\uDE3F Oh no! There is something wrong with \"".concat(componentName, "\""));
168
+ instance.log("");
169
+ if (extranous.length > 0) {
170
+ instance.log("these secrets are not declared in the config");
171
+ extranous.forEach(function (key) { return instance.log(key); });
172
+ instance.log("");
173
+ }
174
+ if (missing.length > 0) {
175
+ instance.log("these secrets have not been provided:");
176
+ missing.forEach(function (key) { return instance.log(key); });
177
+ instance.log("");
178
+ }
179
+ return [4 /*yield*/, (0, promise_1.delay)(1000)];
180
+ case 7:
181
+ _k.sent();
182
+ return [4 /*yield*/, instance.prompt({
183
+ "default": true,
184
+ message: "Try again? 🤔",
185
+ name: "shouldContinue",
186
+ type: "confirm"
187
+ })];
188
+ case 8:
189
+ shouldContinue = (_k.sent()).shouldContinue;
190
+ if (!shouldContinue) {
191
+ throw new Error("abort");
192
+ }
193
+ hasErrors = true;
194
+ _k.label = 9;
195
+ case 9:
196
+ _e++;
197
+ return [3 /*break*/, 5];
198
+ case 10:
199
+ _i++;
200
+ return [3 /*break*/, 4];
201
+ case 11: return [3 /*break*/, 2];
202
+ case 12:
203
+ instance.log("upserting all variables, please wait...");
204
+ instance.log("");
205
+ _f = 0, _g = Object.entries(envAndComponents);
206
+ _k.label = 13;
207
+ case 13:
208
+ if (!(_f < _g.length)) return [3 /*break*/, 18];
209
+ _h = _g[_f], componentName = _h[0], envs = _h[1];
210
+ _j = 0, envs_2 = envs;
211
+ _k.label = 14;
212
+ case 14:
213
+ if (!(_j < envs_2.length)) return [3 /*break*/, 17];
214
+ env = envs_2[_j];
215
+ return [4 /*yield*/, (0, gitlab_1.upsertAllVariables)(instance, valuesToEdit[componentName][env], env, componentName)];
216
+ case 15:
217
+ _k.sent();
218
+ instance.log("");
219
+ instance.log("✅ " + env + ":" + componentName);
220
+ _k.label = 16;
221
+ case 16:
222
+ _j++;
223
+ return [3 /*break*/, 14];
224
+ case 17:
225
+ _f++;
226
+ return [3 /*break*/, 13];
227
+ case 18:
228
+ instance.log("done! 😻");
229
+ instance.log("");
230
+ return [2 /*return*/];
231
+ }
232
+ });
233
+ }); };
234
+ var projectConfigSecrets = function (vorpal, envComponent) { return __awaiter(void 0, void 0, void 0, function () {
235
+ var allEnvAndcomponents, _a, env_1, componentName, components;
236
+ var _b;
237
+ return __generator(this, function (_c) {
238
+ switch (_c.label) {
239
+ case 0:
240
+ if (!!envComponent) return [3 /*break*/, 3];
241
+ return [4 /*yield*/, (0, getProjectConfig_1.getAllComponentsWithAllEnvsHierarchical)()];
242
+ case 1:
243
+ allEnvAndcomponents = _c.sent();
244
+ return [4 /*yield*/, doItFor(vorpal, allEnvAndcomponents)];
245
+ case 2:
246
+ _c.sent();
247
+ return [3 /*break*/, 8];
248
+ case 3:
249
+ _a = (0, getProjectConfig_1.parseChoice)(envComponent), env_1 = _a.env, componentName = _a.componentName;
250
+ if (!!componentName) return [3 /*break*/, 6];
251
+ return [4 /*yield*/, (0, getProjectConfig_1.getProjectComponents)()];
252
+ case 4:
253
+ components = _c.sent();
254
+ return [4 /*yield*/, doItFor(vorpal, Object.fromEntries(components.map(function (c) { return [c, [env_1]]; })))];
255
+ case 5:
256
+ _c.sent();
257
+ _c.label = 6;
258
+ case 6:
259
+ if (!componentName) return [3 /*break*/, 8];
260
+ return [4 /*yield*/, doItFor(vorpal, (_b = {},
261
+ _b[componentName] = [env_1],
262
+ _b))];
263
+ case 7:
264
+ _c.sent();
265
+ _c.label = 8;
266
+ case 8: return [2 /*return*/];
267
+ }
268
+ });
269
+ }); };
270
+ exports.projectConfigSecrets = projectConfigSecrets;
271
+ exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
272
+ var _a, _b;
273
+ return __generator(this, function (_c) {
274
+ switch (_c.label) {
275
+ case 0:
276
+ _b = (_a = vorpal
277
+ .command("project-config-secrets [envComponent]", "setup/update secrets stored in pass"))
278
+ .autocomplete;
279
+ return [4 /*yield*/, (0, autocompletions_1.allEnvsAndAllComponents)()];
280
+ case 1:
281
+ _b.apply(_a, [_c.sent()])
282
+ .action(function (_a) {
283
+ var envComponent = _a.envComponent;
284
+ return __awaiter(this, void 0, void 0, function () {
285
+ return __generator(this, function (_b) {
286
+ switch (_b.label) {
287
+ case 0: return [4 /*yield*/, (0, exports.projectConfigSecrets)(this, envComponent)];
288
+ case 1: return [2 /*return*/, _b.sent()];
289
+ }
290
+ });
291
+ });
292
+ });
293
+ return [2 /*return*/];
294
+ }
295
+ });
296
+ }); });
297
+ var templateObject_1;
298
+ //# sourceMappingURL=commandConfigSecrets.js.map