@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,73 @@
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.connectToCluster = exports.getCurrentConnectedClusterName = exports.getCurrentContext = void 0;
44
+ var zx_1 = require("zx");
45
+ var getCurrentContext = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0: return [4 /*yield*/, (0, zx_1.$)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["kubectl config current-context"], ["kubectl config current-context"])))];
48
+ case 1: return [2 /*return*/, (_a.sent()).stdout.trim()];
49
+ }
50
+ }); }); };
51
+ exports.getCurrentContext = getCurrentContext;
52
+ var getCurrentConnectedClusterName = function () { return __awaiter(void 0, void 0, void 0, function () {
53
+ return __generator(this, function (_a) {
54
+ switch (_a.label) {
55
+ case 0: return [4 /*yield*/, (0, exports.getCurrentContext)()];
56
+ case 1: return [2 /*return*/, _a.sent()];
57
+ }
58
+ });
59
+ }); };
60
+ exports.getCurrentConnectedClusterName = getCurrentConnectedClusterName;
61
+ var connectToCluster = function (fullname) { return __awaiter(void 0, void 0, void 0, function () {
62
+ return __generator(this, function (_a) {
63
+ switch (_a.label) {
64
+ case 0: return [4 /*yield*/, (0, zx_1.$)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["kubectl config use-context ", ""], ["kubectl config use-context ", ""])), fullname)];
65
+ case 1:
66
+ _a.sent();
67
+ return [2 /*return*/];
68
+ }
69
+ });
70
+ }); };
71
+ exports.connectToCluster = connectToCluster;
72
+ var templateObject_1, templateObject_2;
73
+ //# sourceMappingURL=cluster.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cluster.js","sourceRoot":"","sources":["../../src/utils/cluster.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAAuB;AAEhB,IAAM,iBAAiB,GAAG;;gBAC9B,yBAAM,MAAC,oGAAA,gCAAgC,MAAA;gBAAxC,sBAAA,CAAC,SAAuC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,EAAA;;SAAA,CAAC;AAD7C,QAAA,iBAAiB,qBAC4B;AAEnD,IAAM,8BAA8B,GAAG;;;oBACrC,qBAAM,IAAA,yBAAiB,GAAE,EAAA;oBAAhC,sBAAO,SAAyB,EAAC;;;KAClC,CAAC;AAFW,QAAA,8BAA8B,kCAEzC;AAEK,IAAM,gBAAgB,GAAG,UAAO,QAAgB;;;oBACrD,yBAAM,MAAC,qGAAA,6BAA8B,EAAQ,EAAE,KAAV,QAAQ,GAAE;;gBAA/C,SAA+C,CAAC;;;;KACjD,CAAC;AAFW,QAAA,gBAAgB,oBAE3B"}
@@ -0,0 +1 @@
1
+ export declare const editAsFile: <T>(inObject: T, preamble?: string) => Promise<T>;
@@ -0,0 +1,85 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ exports.__esModule = true;
42
+ exports.editAsFile = void 0;
43
+ var tmp_promise_1 = require("tmp-promise");
44
+ var js_yaml_1 = require("js-yaml");
45
+ var fs_extra_1 = require("fs-extra");
46
+ var getEditor_1 = __importDefault(require("./getEditor"));
47
+ var editAsFile = function (inObject, preamble) { return __awaiter(void 0, void 0, void 0, function () {
48
+ var fullPreamble, asString, newContent;
49
+ return __generator(this, function (_a) {
50
+ switch (_a.label) {
51
+ case 0:
52
+ fullPreamble = preamble
53
+ ? "#\n# ".concat(preamble.split("\n").join("\n# "), "\n#\n\n")
54
+ : "\n";
55
+ asString = fullPreamble + (0, js_yaml_1.dump)(inObject, { noRefs: true });
56
+ return [4 /*yield*/, (0, tmp_promise_1.withFile)(function (_a) {
57
+ var tmpFilePath = _a.path;
58
+ return __awaiter(void 0, void 0, void 0, function () {
59
+ var _b;
60
+ return __generator(this, function (_c) {
61
+ switch (_c.label) {
62
+ case 0: return [4 /*yield*/, (0, fs_extra_1.writeFile)(tmpFilePath, asString)];
63
+ case 1:
64
+ _c.sent();
65
+ return [4 /*yield*/, (0, getEditor_1["default"])()];
66
+ case 2: return [4 /*yield*/, (_c.sent()).open(tmpFilePath)];
67
+ case 3:
68
+ _c.sent();
69
+ _b = js_yaml_1.load;
70
+ return [4 /*yield*/, (0, fs_extra_1.readFile)(tmpFilePath)];
71
+ case 4:
72
+ newContent = _b.apply(void 0, [(_c.sent()).toString("utf-8")]);
73
+ return [2 /*return*/];
74
+ }
75
+ });
76
+ });
77
+ }, { postfix: ".yml" })];
78
+ case 1:
79
+ _a.sent();
80
+ return [2 /*return*/, newContent];
81
+ }
82
+ });
83
+ }); };
84
+ exports.editAsFile = editAsFile;
85
+ //# sourceMappingURL=editAsFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editAsFile.js","sourceRoot":"","sources":["../../src/utils/editAsFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAuC;AACvC,mCAAqC;AAErC,qCAA+C;AAC/C,0DAAoC;AAE7B,IAAM,UAAU,GAAG,UACxB,QAAW,EACX,QAAiB;;;;;gBAEX,YAAY,GAAG,QAAQ;oBAC3B,CAAC,CAAC,eACF,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,YAGpC;oBACG,CAAC,CAAC,IAAI,CAAC;gBACH,QAAQ,GAAG,YAAY,GAAG,IAAA,cAAI,EAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;gBAGjE,qBAAM,IAAA,sBAAQ,EACZ,UAAO,EAAqB;4BAAb,WAAW,UAAA;;;;;4CACxB,qBAAM,IAAA,oBAAS,EAAC,WAAW,EAAE,QAAQ,CAAC,EAAA;;wCAAtC,SAAsC,CAAC;wCAChC,qBAAM,IAAA,sBAAS,GAAE,EAAA;4CAAxB,qBAAM,CAAC,SAAiB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,EAAA;;wCAA3C,SAA2C,CAAC;wCAC/B,KAAA,cAAI,CAAA;wCAAE,qBAAM,IAAA,mBAAQ,EAAC,WAAW,CAAC,EAAA;;wCAA9C,UAAU,GAAG,kBAAK,CAAC,SAA2B,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAM,CAAC;;;;;qBACzE,EACD,EAAE,OAAO,EAAE,MAAM,EAAE,CACpB,EAAA;;gBAPD,SAOC,CAAC;gBAEF,sBAAO,UAAU,EAAC;;;KACnB,CAAC;AAxBW,QAAA,UAAU,cAwBrB"}
@@ -0,0 +1,2 @@
1
+ export declare const readFileOrError: (filePath: string) => Promise<any[]>;
2
+ export declare const readYaml: <T = Record<string, any>>(filename: string) => Promise<T>;
@@ -0,0 +1,83 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ exports.__esModule = true;
42
+ exports.readYaml = exports.readFileOrError = void 0;
43
+ var fs_extra_1 = __importDefault(require("fs-extra"));
44
+ var js_yaml_1 = __importDefault(require("js-yaml"));
45
+ var readFile = function (file) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
46
+ return [2 /*return*/, fs_extra_1["default"].readFile(file, { encoding: "utf-8" })];
47
+ }); }); };
48
+ var readFileOrError = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
49
+ var file, e_1;
50
+ return __generator(this, function (_a) {
51
+ switch (_a.label) {
52
+ case 0:
53
+ _a.trys.push([0, 2, , 3]);
54
+ return [4 /*yield*/, readFile(filePath)];
55
+ case 1:
56
+ file = _a.sent();
57
+ return [2 /*return*/, [null, file]];
58
+ case 2:
59
+ e_1 = _a.sent();
60
+ return [2 /*return*/, [e_1]];
61
+ case 3: return [2 /*return*/];
62
+ }
63
+ });
64
+ }); };
65
+ exports.readFileOrError = readFileOrError;
66
+ var readYaml = function (filename) { return __awaiter(void 0, void 0, void 0, function () {
67
+ var _a, _b, e_2;
68
+ return __generator(this, function (_c) {
69
+ switch (_c.label) {
70
+ case 0:
71
+ _c.trys.push([0, 2, , 3]);
72
+ _b = (_a = js_yaml_1["default"]).load;
73
+ return [4 /*yield*/, readFile(filename)];
74
+ case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
75
+ case 2:
76
+ e_2 = _c.sent();
77
+ return [2 /*return*/, null];
78
+ case 3: return [2 /*return*/];
79
+ }
80
+ });
81
+ }); };
82
+ exports.readYaml = readYaml;
83
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/utils/files.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA0B;AAC1B,oDAA2B;AAE3B,IAAM,QAAQ,GAAG,UAAO,IAAY;IAClC,sBAAA,qBAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAA;SAAA,CAAC;AAEpC,IAAM,eAAe,GAAG,UAAO,QAAgB;;;;;;gBAErC,qBAAM,QAAQ,CAAC,QAAQ,CAAC,EAAA;;gBAA/B,IAAI,GAAG,SAAwB;gBACrC,sBAAO,CAAC,IAAI,EAAE,IAAI,CAAC,EAAC;;;gBAEpB,sBAAO,CAAC,GAAC,CAAC,EAAC;;;;KAEd,CAAC;AAPW,QAAA,eAAe,mBAO1B;AAEK,IAAM,QAAQ,GAAG,UAAgC,QAAgB;;;;;;gBAE7D,KAAA,CAAA,KAAA,oBAAI,CAAA,CAAC,IAAI,CAAA;gBAAC,qBAAM,QAAQ,CAAC,QAAQ,CAAC,EAAA;oBAAzC,sBAAO,cAAU,SAAwB,EAAM,EAAC;;;gBAEhD,sBAAO,IAAI,EAAC;;;;KAEf,CAAC;AANW,QAAA,QAAQ,YAMnB"}
@@ -0,0 +1,4 @@
1
+ declare const _default: () => Promise<{
2
+ open: (path: string) => Promise<void>;
3
+ }>;
4
+ export default _default;
@@ -0,0 +1,70 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ exports.__esModule = true;
42
+ /* eslint-disable @typescript-eslint/no-var-requires */
43
+ var child_process_promise_1 = require("child-process-promise");
44
+ var command_exists_promise_1 = __importDefault(require("command-exists-promise"));
45
+ var cmd;
46
+ exports["default"] = (function () { return __awaiter(void 0, void 0, void 0, function () {
47
+ return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0:
50
+ if (!!cmd) return [3 /*break*/, 2];
51
+ return [4 /*yield*/, (0, command_exists_promise_1["default"])("code")];
52
+ case 1:
53
+ cmd = (_a.sent()) ? "code --wait" : "vim";
54
+ _a.label = 2;
55
+ case 2: return [2 /*return*/, {
56
+ open: function (path) { return __awaiter(void 0, void 0, void 0, function () {
57
+ return __generator(this, function (_a) {
58
+ switch (_a.label) {
59
+ case 0: return [4 /*yield*/, (0, child_process_promise_1.spawn)("".concat(cmd, " ").concat(path), { shell: true, stdio: "inherit" })];
60
+ case 1:
61
+ _a.sent();
62
+ return [2 /*return*/];
63
+ }
64
+ });
65
+ }); }
66
+ }];
67
+ }
68
+ });
69
+ }); });
70
+ //# sourceMappingURL=getEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getEditor.js","sourceRoot":"","sources":["../../src/utils/getEditor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,+DAA8C;AAC9C,kFAAmD;AAEnD,IAAI,GAAW,CAAC;AAChB,sBAAe;;;;qBACT,CAAC,GAAG,EAAJ,wBAAI;gBACC,qBAAM,IAAA,mCAAa,EAAC,MAAM,CAAC,EAAA;;gBAAlC,GAAG,GAAG,CAAC,SAA2B,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC;;oBAG9D,sBAAO;oBACL,IAAI,EAAE,UAAO,IAAY;;;wCACvB,qBAAM,IAAA,6BAAK,EAAC,UAAG,GAAG,cAAI,IAAI,CAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EAAA;;oCAAhE,SAAgE,CAAC;;;;yBAClE;iBACF,EAAC;;;KACH,EAAC"}
@@ -0,0 +1,22 @@
1
+ import memoizee from "memoizee";
2
+ import { CommandInstance } from "vorpal";
3
+ export declare const hasGitlabToken: () => Promise<boolean>;
4
+ export declare const setupGitlabToken: (vorpal: CommandInstance) => Promise<void>;
5
+ export declare const getGitlabToken: (vorpal: CommandInstance) => Promise<string>;
6
+ export declare const doGitlabRequest: <T = any>(vorpal: CommandInstance, path: string, data?: any, update?: boolean) => Promise<T>;
7
+ export declare const getProjectInfo: (vorpal: CommandInstance) => Promise<{
8
+ id: string;
9
+ web_url: string;
10
+ }>;
11
+ declare type GitlabVariable = {
12
+ variable_type: string;
13
+ key: string;
14
+ value: string;
15
+ protected: boolean;
16
+ masked: boolean;
17
+ environment_scope: string;
18
+ };
19
+ export declare const getAllVariables: ((vorpal: CommandInstance) => Promise<Array<GitlabVariable>>) & memoizee.Memoized<(vorpal: CommandInstance) => Promise<Array<GitlabVariable>>>;
20
+ export declare const getVariableValueByRawName: (vorpal: CommandInstance, rawName: string) => Promise<string>;
21
+ export declare const upsertAllVariables: (vorpal: CommandInstance, variables: Record<string, any>, env: string, componentName: string) => Promise<void>;
22
+ export {};
@@ -0,0 +1,278 @@
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
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
+ if (ar || !(i in from)) {
41
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
+ ar[i] = from[i];
43
+ }
44
+ }
45
+ return to.concat(ar || Array.prototype.slice.call(from));
46
+ };
47
+ var __importDefault = (this && this.__importDefault) || function (mod) {
48
+ return (mod && mod.__esModule) ? mod : { "default": mod };
49
+ };
50
+ exports.__esModule = true;
51
+ exports.upsertAllVariables = exports.getVariableValueByRawName = exports.getAllVariables = exports.getProjectInfo = exports.doGitlabRequest = exports.getGitlabToken = exports.setupGitlabToken = exports.hasGitlabToken = void 0;
52
+ var child_process_promise_1 = require("child-process-promise");
53
+ var pipeline_1 = require("@catladder/pipeline");
54
+ var lodash_1 = require("lodash");
55
+ var memoizee_1 = __importDefault(require("memoizee"));
56
+ var node_fetch_1 = __importDefault(require("node-fetch"));
57
+ var open_1 = __importDefault(require("open"));
58
+ var preferences_1 = require("./preferences");
59
+ var TOKEN_KEY = "gitlab-personal-access-token";
60
+ var hasGitlabToken = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
61
+ switch (_a.label) {
62
+ case 0: return [4 /*yield*/, (0, preferences_1.hasPreference)(TOKEN_KEY)];
63
+ case 1: return [2 /*return*/, _a.sent()];
64
+ }
65
+ }); }); };
66
+ exports.hasGitlabToken = hasGitlabToken;
67
+ var setupGitlabToken = function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
68
+ var shouldContinue, personalToken;
69
+ return __generator(this, function (_a) {
70
+ switch (_a.label) {
71
+ case 0:
72
+ vorpal.log("");
73
+ vorpal.log("☝ in order to access the api, we need a personal access token");
74
+ vorpal.log("Its best to create one specifically for catladder");
75
+ vorpal.log("");
76
+ vorpal.log("☝ we open up the settings page for you!");
77
+ vorpal.log("");
78
+ return [4 /*yield*/, vorpal.prompt({
79
+ "default": true,
80
+ message: "Ok",
81
+ name: "shouldContinue",
82
+ type: "prompt"
83
+ })];
84
+ case 1:
85
+ shouldContinue = (_a.sent()).shouldContinue;
86
+ (0, open_1["default"])("https://git.panter.ch/-/profile/personal_access_tokens");
87
+ vorpal.log("Please type in gitlab's personal access token");
88
+ return [4 /*yield*/, vorpal.prompt({
89
+ type: "string",
90
+ name: "personalToken",
91
+ "default": "",
92
+ message: "Your personal access token "
93
+ })];
94
+ case 2:
95
+ personalToken = (_a.sent()).personalToken;
96
+ if (!personalToken) return [3 /*break*/, 4];
97
+ return [4 /*yield*/, (0, preferences_1.setPreference)(TOKEN_KEY, personalToken)];
98
+ case 3:
99
+ _a.sent();
100
+ _a.label = 4;
101
+ case 4: return [2 /*return*/];
102
+ }
103
+ });
104
+ }); };
105
+ exports.setupGitlabToken = setupGitlabToken;
106
+ var getGitlabToken = function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
107
+ return __generator(this, function (_a) {
108
+ switch (_a.label) {
109
+ case 0: return [4 /*yield*/, (0, exports.hasGitlabToken)()];
110
+ case 1:
111
+ if (!!(_a.sent())) return [3 /*break*/, 3];
112
+ if (!vorpal) {
113
+ console.error("⚠️ gitlab token missing, please run catladder to set it up");
114
+ process.exit(1);
115
+ }
116
+ return [4 /*yield*/, (0, exports.setupGitlabToken)(vorpal)];
117
+ case 2:
118
+ _a.sent();
119
+ _a.label = 3;
120
+ case 3: return [2 /*return*/, (0, preferences_1.getPreference)(TOKEN_KEY)];
121
+ }
122
+ });
123
+ }); };
124
+ exports.getGitlabToken = getGitlabToken;
125
+ var doGitlabRequest = function (vorpal, path, data, update) {
126
+ if (data === void 0) { data = undefined; }
127
+ return __awaiter(void 0, void 0, void 0, function () {
128
+ var rootToken, method, result, _a, _b, _c, _d, _e;
129
+ return __generator(this, function (_f) {
130
+ switch (_f.label) {
131
+ case 0: return [4 /*yield*/, (0, exports.getGitlabToken)(vorpal)];
132
+ case 1:
133
+ rootToken = _f.sent();
134
+ method = data ? (update ? "PUT" : "POST") : "GET";
135
+ return [4 /*yield*/, (0, node_fetch_1["default"])("https://git.panter.ch/api/v4/".concat(path), {
136
+ method: method,
137
+ headers: {
138
+ "Content-Type": "application/json",
139
+ "Private-Token": rootToken
140
+ },
141
+ body: JSON.stringify(data)
142
+ })];
143
+ case 2:
144
+ result = _f.sent();
145
+ if (result.status >= 200 && result.status < 400) {
146
+ return [2 /*return*/, result.json()];
147
+ }
148
+ if (result.status === 404) {
149
+ throw new Error("not found");
150
+ }
151
+ _a = Error.bind;
152
+ _c = (_b = "Could not send request to gitlab api ".concat(path, ": ").concat(result.status, " \"").concat(result.statusText, "\".\nResponse: ")).concat;
153
+ _e = (_d = JSON).stringify;
154
+ return [4 /*yield*/, result.json()];
155
+ case 3: throw new (_a.apply(Error, [void 0, _c.apply(_b, [_e.apply(_d, [_f.sent(), null, 2])])]))();
156
+ }
157
+ });
158
+ });
159
+ };
160
+ exports.doGitlabRequest = doGitlabRequest;
161
+ var getProjectInfo = function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
162
+ var gitRemoteOriginUrl, projectPath, project;
163
+ return __generator(this, function (_a) {
164
+ switch (_a.label) {
165
+ case 0: return [4 /*yield*/, (0, child_process_promise_1.exec)("git config --get remote.origin.url")];
166
+ case 1:
167
+ gitRemoteOriginUrl = (_a.sent()).stdout.trim();
168
+ projectPath = /(https:\/\/|git@)git\.panter\.ch[:/](.*)\.git/g.exec(gitRemoteOriginUrl);
169
+ return [4 /*yield*/, (0, exports.doGitlabRequest)(vorpal, "projects/".concat(encodeURIComponent(projectPath[2])))];
170
+ case 2:
171
+ project = _a.sent();
172
+ return [2 /*return*/, project];
173
+ }
174
+ });
175
+ }); };
176
+ exports.getProjectInfo = getProjectInfo;
177
+ exports.getAllVariables = (0, memoizee_1["default"])(function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
178
+ var id, all, result, page;
179
+ return __generator(this, function (_a) {
180
+ switch (_a.label) {
181
+ case 0: return [4 /*yield*/, (0, exports.getProjectInfo)(vorpal)];
182
+ case 1:
183
+ id = (_a.sent()).id;
184
+ all = [];
185
+ page = 1;
186
+ _a.label = 2;
187
+ case 2: return [4 /*yield*/, (0, exports.doGitlabRequest)(vorpal,
188
+ // 100 is max page size
189
+ "projects/".concat(id, "/variables?per_page=100&page=").concat(page))];
190
+ case 3:
191
+ result = _a.sent();
192
+ page++;
193
+ all = __spreadArray(__spreadArray([], all, true), result, true);
194
+ _a.label = 4;
195
+ case 4:
196
+ if ((result === null || result === void 0 ? void 0 : result.length) > 0) return [3 /*break*/, 2];
197
+ _a.label = 5;
198
+ case 5: return [2 /*return*/, all];
199
+ }
200
+ });
201
+ }); }, { promise: true });
202
+ var getVariableValueByRawName = function (vorpal, rawName) { return __awaiter(void 0, void 0, void 0, function () {
203
+ var allVariables;
204
+ var _a;
205
+ return __generator(this, function (_b) {
206
+ switch (_b.label) {
207
+ case 0: return [4 /*yield*/, (0, exports.getAllVariables)(vorpal)];
208
+ case 1:
209
+ allVariables = _b.sent();
210
+ return [2 /*return*/, (_a = allVariables.find(function (v) { return v.key === rawName; })) === null || _a === void 0 ? void 0 : _a.value];
211
+ }
212
+ });
213
+ }); };
214
+ exports.getVariableValueByRawName = getVariableValueByRawName;
215
+ var maskableRegex = new RegExp("^[a-zA-Z0-9_+=/@:.~-]{8,}$"); // SEE https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js#L20
216
+ var isMaskable = function (value) { return maskableRegex.test(value); };
217
+ var createVariable = function (vorpal, projectId, key, value) { return __awaiter(void 0, void 0, void 0, function () {
218
+ return __generator(this, function (_a) {
219
+ switch (_a.label) {
220
+ case 0: return [4 /*yield*/, (0, exports.doGitlabRequest)(vorpal, "projects/".concat(projectId, "/variables"), {
221
+ key: key,
222
+ value: value,
223
+ masked: isMaskable(value)
224
+ })];
225
+ case 1: return [2 /*return*/, _a.sent()];
226
+ }
227
+ });
228
+ }); };
229
+ var updateVariable = function (vorpal, projectId, key, value) { return __awaiter(void 0, void 0, void 0, function () {
230
+ return __generator(this, function (_a) {
231
+ switch (_a.label) {
232
+ case 0: return [4 /*yield*/, (0, exports.doGitlabRequest)(vorpal, "projects/".concat(projectId, "/variables/").concat(key), {
233
+ value: value,
234
+ masked: isMaskable(value)
235
+ }, true)];
236
+ case 1: return [2 /*return*/, _a.sent()];
237
+ }
238
+ });
239
+ }); };
240
+ var upsertAllVariables = function (vorpal, variables, env, componentName) { return __awaiter(void 0, void 0, void 0, function () {
241
+ var id, _i, _a, _b, key, value, fullKey, valueSanitized, e_1;
242
+ return __generator(this, function (_c) {
243
+ switch (_c.label) {
244
+ case 0: return [4 /*yield*/, (0, exports.getProjectInfo)(vorpal)];
245
+ case 1:
246
+ id = (_c.sent()).id;
247
+ _i = 0, _a = Object.entries(variables !== null && variables !== void 0 ? variables : {});
248
+ _c.label = 2;
249
+ case 2:
250
+ if (!(_i < _a.length)) return [3 /*break*/, 9];
251
+ _b = _a[_i], key = _b[0], value = _b[1];
252
+ fullKey = (0, pipeline_1.getSecretVarName)(env, componentName, key);
253
+ valueSanitized = (0, lodash_1.isObject)(value) ? JSON.stringify(value) : "".concat(value);
254
+ _c.label = 3;
255
+ case 3:
256
+ _c.trys.push([3, 5, 7, 8]);
257
+ return [4 /*yield*/, updateVariable(vorpal, id, fullKey, valueSanitized)];
258
+ case 4:
259
+ _c.sent();
260
+ return [3 /*break*/, 8];
261
+ case 5:
262
+ e_1 = _c.sent();
263
+ return [4 /*yield*/, createVariable(vorpal, id, fullKey, valueSanitized)];
264
+ case 6:
265
+ _c.sent();
266
+ return [3 /*break*/, 8];
267
+ case 7:
268
+ exports.getAllVariables.clear();
269
+ return [7 /*endfinally*/];
270
+ case 8:
271
+ _i++;
272
+ return [3 /*break*/, 2];
273
+ case 9: return [2 /*return*/];
274
+ }
275
+ });
276
+ }); };
277
+ exports.upsertAllVariables = upsertAllVariables;
278
+ //# sourceMappingURL=gitlab.js.map