@catladder/cli 0.0.0 → 1.0.2

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 (288) hide show
  1. package/.nvmrc +1 -1
  2. package/bin/catenv +3 -0
  3. package/bin/catladder +1 -1
  4. package/dist/apps/catenv/catenv.d.ts +2 -0
  5. package/dist/apps/catenv/catenv.js +135 -0
  6. package/dist/apps/catenv/catenv.js.map +1 -0
  7. package/dist/apps/cli/cli.d.ts +2 -0
  8. package/dist/apps/cli/cli.js +81 -0
  9. package/dist/apps/cli/cli.js.map +1 -0
  10. package/dist/apps/cli/commands/general/index.d.ts +4 -0
  11. package/dist/apps/cli/commands/general/index.js +274 -0
  12. package/dist/apps/cli/commands/general/index.js.map +1 -0
  13. package/dist/apps/cli/commands/general/namespaceAutoCompletion.d.ts +3 -0
  14. package/dist/apps/cli/commands/general/namespaceAutoCompletion.js +56 -0
  15. package/dist/apps/cli/commands/general/namespaceAutoCompletion.js.map +1 -0
  16. package/dist/apps/cli/commands/general/portForward.d.ts +3 -0
  17. package/dist/apps/cli/commands/general/portForward.js +98 -0
  18. package/dist/apps/cli/commands/general/portForward.js.map +1 -0
  19. package/dist/apps/cli/commands/mongodb/index.d.ts +3 -0
  20. package/dist/apps/cli/commands/mongodb/index.js +53 -0
  21. package/dist/apps/cli/commands/mongodb/index.js.map +1 -0
  22. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +3 -0
  23. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +190 -0
  24. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -0
  25. package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +3 -0
  26. package/dist/apps/cli/commands/mongodb/projectMongoGetShell.js +96 -0
  27. package/dist/apps/cli/commands/mongodb/projectMongoGetShell.js.map +1 -0
  28. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +3 -0
  29. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +105 -0
  30. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -0
  31. package/dist/apps/cli/commands/mongodb/utils/index.d.ts +13 -0
  32. package/dist/apps/cli/commands/mongodb/utils/index.js +167 -0
  33. package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -0
  34. package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +3 -0
  35. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +128 -0
  36. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -0
  37. package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +3 -0
  38. package/dist/apps/cli/commands/project/commandConfigSecrets.js +254 -0
  39. package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -0
  40. package/dist/apps/cli/commands/project/commandCopyDB.d.ts +3 -0
  41. package/dist/apps/cli/commands/project/commandCopyDB.js +102 -0
  42. package/dist/apps/cli/commands/project/commandCopyDB.js.map +1 -0
  43. package/dist/apps/cli/commands/project/commandDeletePods.d.ts +3 -0
  44. package/dist/apps/cli/commands/project/commandDeletePods.js +119 -0
  45. package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -0
  46. package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +3 -0
  47. package/dist/apps/cli/commands/project/commandDeleteProject.js +97 -0
  48. package/dist/apps/cli/commands/project/commandDeleteProject.js.map +1 -0
  49. package/dist/apps/cli/commands/project/commandEnvVars.d.ts +3 -0
  50. package/dist/apps/cli/commands/project/commandEnvVars.js +74 -0
  51. package/dist/apps/cli/commands/project/commandEnvVars.js.map +1 -0
  52. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +3 -0
  53. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js +58 -0
  54. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js.map +1 -0
  55. package/dist/apps/cli/commands/project/commandGetShell.d.ts +3 -0
  56. package/dist/apps/cli/commands/project/commandGetShell.js +92 -0
  57. package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -0
  58. package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +3 -0
  59. package/dist/apps/cli/commands/project/commandGitlabCi.js +185 -0
  60. package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -0
  61. package/dist/apps/cli/commands/project/commandInitGitlab.d.ts +3 -0
  62. package/dist/apps/cli/commands/project/commandInitGitlab.js +245 -0
  63. package/dist/apps/cli/commands/project/commandInitGitlab.js.map +1 -0
  64. package/dist/apps/cli/commands/project/commandInitProject.d.ts +3 -0
  65. package/dist/apps/cli/commands/project/commandInitProject.js +345 -0
  66. package/dist/apps/cli/commands/project/commandInitProject.js.map +1 -0
  67. package/dist/apps/cli/commands/project/commandListPods.d.ts +3 -0
  68. package/dist/apps/cli/commands/project/commandListPods.js +78 -0
  69. package/dist/apps/cli/commands/project/commandListPods.js.map +1 -0
  70. package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +7 -0
  71. package/dist/apps/cli/commands/project/commandMigrateHelm3.js +113 -0
  72. package/dist/apps/cli/commands/project/commandMigrateHelm3.js.map +1 -0
  73. package/dist/apps/cli/commands/project/commandNamespace.d.ts +3 -0
  74. package/dist/apps/cli/commands/project/commandNamespace.js +70 -0
  75. package/dist/apps/cli/commands/project/commandNamespace.js.map +1 -0
  76. package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +3 -0
  77. package/dist/apps/cli/commands/project/commandOpenCostDashboard.js +83 -0
  78. package/dist/apps/cli/commands/project/commandOpenCostDashboard.js.map +1 -0
  79. package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +3 -0
  80. package/dist/apps/cli/commands/project/commandOpenDashboard.js +92 -0
  81. package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -0
  82. package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +3 -0
  83. package/dist/apps/cli/commands/project/commandOpenEnv.js +80 -0
  84. package/dist/apps/cli/commands/project/commandOpenEnv.js.map +1 -0
  85. package/dist/apps/cli/commands/project/commandOpenGit.d.ts +3 -0
  86. package/dist/apps/cli/commands/project/commandOpenGit.js +56 -0
  87. package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -0
  88. package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +3 -0
  89. package/dist/apps/cli/commands/project/commandOpenGrafana.js +83 -0
  90. package/dist/apps/cli/commands/project/commandOpenGrafana.js.map +1 -0
  91. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +3 -0
  92. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +99 -0
  93. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -0
  94. package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +3 -0
  95. package/dist/apps/cli/commands/project/commandOpenLogs.js +87 -0
  96. package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -0
  97. package/dist/apps/cli/commands/project/commandPauseProject.d.ts +3 -0
  98. package/dist/apps/cli/commands/project/commandPauseProject.js +97 -0
  99. package/dist/apps/cli/commands/project/commandPauseProject.js.map +1 -0
  100. package/dist/apps/cli/commands/project/commandPortForward.d.ts +3 -0
  101. package/dist/apps/cli/commands/project/commandPortForward.js +106 -0
  102. package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -0
  103. package/dist/apps/cli/commands/project/commandReloadConfig.d.ts +3 -0
  104. package/dist/apps/cli/commands/project/commandReloadConfig.js +62 -0
  105. package/dist/apps/cli/commands/project/commandReloadConfig.js.map +1 -0
  106. package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +3 -0
  107. package/dist/apps/cli/commands/project/commandTriggerCronjob.js +144 -0
  108. package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -0
  109. package/dist/apps/cli/commands/project/index.d.ts +3 -0
  110. package/dist/apps/cli/commands/project/index.js +97 -0
  111. package/dist/apps/cli/commands/project/index.js.map +1 -0
  112. package/dist/apps/cli/commands/project/utils/autocompletions.d.ts +3 -0
  113. package/dist/apps/cli/commands/project/utils/autocompletions.js +96 -0
  114. package/dist/apps/cli/commands/project/utils/autocompletions.js.map +1 -0
  115. package/dist/apps/cli/commands/project/utils/ensureCluster.d.ts +1 -0
  116. package/dist/apps/cli/commands/project/utils/ensureCluster.js +84 -0
  117. package/dist/apps/cli/commands/project/utils/ensureCluster.js.map +1 -0
  118. package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +1 -0
  119. package/dist/apps/cli/commands/project/utils/ensureNamespace.js +92 -0
  120. package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -0
  121. package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +2 -0
  122. package/dist/apps/cli/commands/project/utils/showProjectBanner.js +58 -0
  123. package/dist/apps/cli/commands/project/utils/showProjectBanner.js.map +1 -0
  124. package/dist/apps/cli/commands/shared/index.d.ts +2 -0
  125. package/dist/apps/cli/commands/shared/index.js +72 -0
  126. package/dist/apps/cli/commands/shared/index.js.map +1 -0
  127. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +3 -0
  128. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js +131 -0
  129. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js.map +1 -0
  130. package/dist/apps/cli/config/writeConfig.d.ts +5 -0
  131. package/dist/apps/cli/config/writeConfig.js +104 -0
  132. package/dist/apps/cli/config/writeConfig.js.map +1 -0
  133. package/dist/apps/cli/utils/getGoogleAuthUserNumber.d.ts +1 -0
  134. package/dist/apps/cli/utils/getGoogleAuthUserNumber.js +69 -0
  135. package/dist/apps/cli/utils/getGoogleAuthUserNumber.js.map +1 -0
  136. package/dist/apps/cli/verify/index.d.ts +2 -0
  137. package/dist/apps/cli/verify/index.js +90 -0
  138. package/dist/apps/cli/verify/index.js.map +1 -0
  139. package/dist/apps/cli/verify/migration/fromv2.d.ts +3 -0
  140. package/dist/apps/cli/verify/migration/fromv2.js +322 -0
  141. package/dist/apps/cli/verify/migration/fromv2.js.map +1 -0
  142. package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +4 -0
  143. package/dist/apps/cli/verify/migration/migrateSecrets.js +88 -0
  144. package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -0
  145. package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +17 -0
  146. package/dist/apps/cli/verify/migration/oldGitlabCi.js +26 -0
  147. package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +1 -0
  148. package/dist/catenv.d.ts +1 -0
  149. package/dist/catenv.js +8 -0
  150. package/dist/catenv.js.map +1 -0
  151. package/dist/cli.d.ts +1 -0
  152. package/dist/cli.js +13 -0
  153. package/dist/cli.js.map +1 -0
  154. package/dist/config/clusters.d.ts +14 -0
  155. package/dist/config/clusters.js +72 -0
  156. package/dist/config/clusters.js.map +1 -0
  157. package/dist/config/constants.d.ts +4 -0
  158. package/dist/config/constants.js +8 -0
  159. package/dist/config/constants.js.map +1 -0
  160. package/dist/config/getProjectConfig.d.ts +21 -0
  161. package/dist/config/getProjectConfig.js +212 -0
  162. package/dist/config/getProjectConfig.js.map +1 -0
  163. package/dist/k8sApi/index.d.ts +5 -0
  164. package/dist/k8sApi/index.js +11 -0
  165. package/dist/k8sApi/index.js.map +1 -0
  166. package/dist/packageInfos.d.ts +2 -0
  167. package/dist/packageInfos.js +6 -0
  168. package/dist/packageInfos.js.map +1 -0
  169. package/dist/tsconfig.tsbuildinfo +1 -0
  170. package/dist/types/types.d.ts +18 -0
  171. package/dist/types/types.js +3 -0
  172. package/dist/types/types.js.map +1 -0
  173. package/dist/utils/cluster.d.ts +12 -0
  174. package/dist/utils/cluster.js +100 -0
  175. package/dist/utils/cluster.js.map +1 -0
  176. package/dist/utils/editAsFile.d.ts +1 -0
  177. package/dist/utils/editAsFile.js +85 -0
  178. package/dist/utils/editAsFile.js.map +1 -0
  179. package/dist/utils/files.d.ts +2 -0
  180. package/dist/utils/files.js +83 -0
  181. package/dist/utils/files.js.map +1 -0
  182. package/dist/utils/formatEnvVars.d.ts +2 -0
  183. package/dist/utils/formatEnvVars.js +10 -0
  184. package/dist/utils/formatEnvVars.js.map +1 -0
  185. package/dist/utils/getEditor.d.ts +4 -0
  186. package/dist/utils/getEditor.js +70 -0
  187. package/dist/utils/getEditor.js.map +1 -0
  188. package/dist/utils/gitlab.d.ts +21 -0
  189. package/dist/utils/gitlab.js +258 -0
  190. package/dist/utils/gitlab.js.map +1 -0
  191. package/dist/utils/log.d.ts +1 -0
  192. package/dist/utils/log.js +14 -0
  193. package/dist/utils/log.js.map +1 -0
  194. package/dist/utils/passwordstore/index.d.ts +8 -0
  195. package/dist/utils/passwordstore/index.js +378 -0
  196. package/dist/utils/passwordstore/index.js.map +1 -0
  197. package/dist/utils/portForward.d.ts +4 -0
  198. package/dist/utils/portForward.js +116 -0
  199. package/dist/utils/portForward.js.map +1 -0
  200. package/dist/utils/preferences/index.d.ts +3 -0
  201. package/dist/utils/preferences/index.js +119 -0
  202. package/dist/utils/preferences/index.js.map +1 -0
  203. package/dist/utils/projects/index.d.ts +8 -0
  204. package/dist/utils/projects/index.js +150 -0
  205. package/dist/utils/projects/index.js.map +1 -0
  206. package/dist/utils/promise.d.ts +2 -0
  207. package/dist/utils/promise.js +62 -0
  208. package/dist/utils/promise.js.map +1 -0
  209. package/dist/utils/shell.d.ts +1 -0
  210. package/dist/utils/shell.js +81 -0
  211. package/dist/utils/shell.js.map +1 -0
  212. package/package.json +12 -20
  213. package/src/apps/catenv/catenv.ts +48 -27
  214. package/src/apps/{shell/shell.ts → cli/cli.ts} +10 -2
  215. package/src/apps/{shell → cli}/commands/general/index.ts +1 -1
  216. package/src/apps/{shell → cli}/commands/general/namespaceAutoCompletion.ts +0 -0
  217. package/src/apps/{shell → cli}/commands/general/portForward.ts +1 -1
  218. package/src/apps/{shell → cli}/commands/mongodb/index.ts +1 -1
  219. package/src/apps/{shell → cli}/commands/mongodb/projectMongoDestroyMember.ts +18 -18
  220. package/src/apps/{shell → cli}/commands/mongodb/projectMongoGetShell.ts +12 -10
  221. package/src/apps/{shell → cli}/commands/mongodb/projectMongoPortForward.ts +13 -8
  222. package/src/apps/{shell → cli}/commands/mongodb/utils/index.ts +9 -8
  223. package/src/apps/{shell → cli}/commands/project/commandCloudSqlProxy.ts +23 -17
  224. package/src/apps/cli/commands/project/commandConfigSecrets.ts +204 -0
  225. package/src/apps/{shell → cli}/commands/project/commandCopyDB.ts +22 -23
  226. package/src/apps/{shell → cli}/commands/project/commandDeletePods.ts +8 -9
  227. package/src/apps/{shell → cli}/commands/project/commandDeleteProject.ts +7 -8
  228. package/src/apps/cli/commands/project/commandEnvVars.ts +15 -0
  229. package/src/apps/{shell → cli}/commands/project/commandGetMyTotalWorktime.ts +2 -2
  230. package/src/apps/{shell → cli}/commands/project/commandGetShell.ts +10 -10
  231. package/src/apps/{shell → cli}/commands/project/commandGitlabCi.ts +1 -1
  232. package/src/apps/cli/commands/project/commandInitGitlab.ts +203 -0
  233. package/src/apps/{shell → cli}/commands/project/commandInitProject.ts +14 -6
  234. package/src/apps/cli/commands/project/commandListPods.ts +18 -0
  235. package/src/apps/{shell → cli}/commands/project/commandMigrateHelm3.ts +16 -7
  236. package/src/apps/cli/commands/project/commandNamespace.ts +14 -0
  237. package/src/apps/{shell → cli}/commands/project/commandOpenCostDashboard.ts +10 -7
  238. package/src/apps/cli/commands/project/commandOpenDashboard.ts +45 -0
  239. package/src/apps/cli/commands/project/commandOpenEnv.ts +22 -0
  240. package/src/apps/{shell → cli}/commands/project/commandOpenGit.ts +1 -1
  241. package/src/apps/{shell → cli}/commands/project/commandOpenGrafana.ts +7 -7
  242. package/src/apps/{shell → cli}/commands/project/commandOpenGrafanaPod.ts +9 -10
  243. package/src/apps/{shell → cli}/commands/project/commandOpenLogs.ts +7 -7
  244. package/src/apps/{shell → cli}/commands/project/commandPauseProject.ts +9 -7
  245. package/src/apps/{shell → cli}/commands/project/commandPortForward.ts +8 -8
  246. package/src/apps/cli/commands/project/commandReloadConfig.ts +12 -0
  247. package/src/apps/{shell → cli}/commands/project/commandTriggerCronjob.ts +7 -7
  248. package/src/apps/{shell → cli}/commands/project/index.ts +4 -3
  249. package/src/apps/cli/commands/project/utils/autocompletions.ts +26 -0
  250. package/src/apps/cli/commands/project/utils/ensureCluster.ts +37 -0
  251. package/src/apps/{shell → cli}/commands/project/utils/ensureNamespace.ts +2 -3
  252. package/src/apps/cli/commands/project/utils/showProjectBanner.ts +11 -0
  253. package/src/apps/{shell → cli}/commands/shared/index.ts +0 -0
  254. package/src/apps/{shell → cli}/commands/theStuffThatReallyMatters/index.ts +11 -11
  255. package/src/apps/cli/config/writeConfig.ts +69 -0
  256. package/src/apps/{shell → cli}/utils/getGoogleAuthUserNumber.ts +0 -0
  257. package/src/apps/cli/verify/index.ts +34 -0
  258. package/src/apps/cli/verify/migration/fromv2.ts +241 -0
  259. package/src/apps/cli/verify/migration/migrateSecrets.ts +37 -0
  260. package/src/apps/cli/verify/migration/oldGitlabCi.ts +43 -0
  261. package/src/catenv.ts +3 -0
  262. package/src/cli.ts +8 -0
  263. package/src/config/getProjectConfig.ts +118 -0
  264. package/src/types/types.ts +0 -2
  265. package/src/utils/cluster.ts +15 -2
  266. package/src/utils/editAsFile.ts +31 -0
  267. package/src/utils/files.ts +6 -2
  268. package/src/utils/gitlab.ts +126 -32
  269. package/src/utils/passwordstore/index.ts +19 -21
  270. package/src/utils/preferences/index.ts +6 -3
  271. package/src/utils/projects/index.ts +14 -134
  272. package/tsconfig.json +3 -7
  273. package/bin/catenv.sh +0 -1
  274. package/src/apps/shell/commands/project/commandConfigSecrets.ts +0 -245
  275. package/src/apps/shell/commands/project/commandEnvVars.ts +0 -17
  276. package/src/apps/shell/commands/project/commandInitGitlab.ts +0 -157
  277. package/src/apps/shell/commands/project/commandListPods.ts +0 -21
  278. package/src/apps/shell/commands/project/commandNamespace.ts +0 -12
  279. package/src/apps/shell/commands/project/commandOpenDashboard.ts +0 -27
  280. package/src/apps/shell/commands/project/commandOpenEnv.ts +0 -18
  281. package/src/apps/shell/commands/project/commandVariables.ts +0 -13
  282. package/src/apps/shell/commands/project/utils/autocompletions.ts +0 -7
  283. package/src/apps/shell/commands/project/utils/ensureCluster.ts +0 -31
  284. package/src/apps/shell/commands/project/utils/monorepo.ts +0 -45
  285. package/src/index.ts +0 -17
  286. package/src/types/git-repo-name.d.ts +0 -1
  287. package/src/types/yawn-yaml.d.ts +0 -1
  288. package/src/utils/dashboardToken.ts +0 -20
@@ -0,0 +1,150 @@
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.getProjectPodNames = exports.getProjectPvcs = exports.getProjectPods = exports.getProjectNamespace = exports.hasGitlabCiFile = exports.readRootGitlabCiFile = exports.getRootGitlabCiFile = exports.getGitRoot = void 0;
43
+ var child_process_promise_1 = require("child-process-promise");
44
+ var path_1 = require("path");
45
+ var getProjectConfig_1 = require("../../config/getProjectConfig");
46
+ var k8sApi_1 = __importDefault(require("../../k8sApi"));
47
+ var files_1 = require("../files");
48
+ var getGitRoot = function () { return __awaiter(void 0, void 0, void 0, function () {
49
+ var _a;
50
+ return __generator(this, function (_b) {
51
+ switch (_b.label) {
52
+ case 0: return [4 /*yield*/, (0, child_process_promise_1.exec)("git rev-parse --show-toplevel")];
53
+ case 1: return [2 /*return*/, (_a = (_b.sent()).stdout) === null || _a === void 0 ? void 0 : _a.trim()];
54
+ }
55
+ });
56
+ }); };
57
+ exports.getGitRoot = getGitRoot;
58
+ var getRootGitlabCiFile = function () { return __awaiter(void 0, void 0, void 0, function () {
59
+ var gitRoot;
60
+ return __generator(this, function (_a) {
61
+ switch (_a.label) {
62
+ case 0: return [4 /*yield*/, (0, exports.getGitRoot)()];
63
+ case 1:
64
+ gitRoot = _a.sent();
65
+ return [2 /*return*/, (0, path_1.join)(gitRoot, ".gitlab-ci.yml")];
66
+ }
67
+ });
68
+ }); };
69
+ exports.getRootGitlabCiFile = getRootGitlabCiFile;
70
+ var readRootGitlabCiFile = function () { return __awaiter(void 0, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
71
+ switch (_b.label) {
72
+ case 0:
73
+ _a = files_1.readFileOrError;
74
+ return [4 /*yield*/, (0, exports.getRootGitlabCiFile)()];
75
+ case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
76
+ }
77
+ }); }); };
78
+ exports.readRootGitlabCiFile = readRootGitlabCiFile;
79
+ var hasGitlabCiFile = function () { return __awaiter(void 0, void 0, void 0, function () {
80
+ var _a, error, file;
81
+ return __generator(this, function (_b) {
82
+ switch (_b.label) {
83
+ case 0: return [4 /*yield*/, (0, exports.readRootGitlabCiFile)()];
84
+ case 1:
85
+ _a = _b.sent(), error = _a[0], file = _a[1];
86
+ if (error) {
87
+ return [2 /*return*/, false];
88
+ }
89
+ return [2 /*return*/, true];
90
+ }
91
+ });
92
+ }); };
93
+ exports.hasGitlabCiFile = hasGitlabCiFile;
94
+ var getProjectNamespace = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
95
+ var env, config;
96
+ return __generator(this, function (_a) {
97
+ switch (_a.label) {
98
+ case 0:
99
+ env = (0, getProjectConfig_1.parseChoice)(envComponent).env;
100
+ return [4 /*yield*/, (0, getProjectConfig_1.getProjectConfig)()];
101
+ case 1:
102
+ config = _a.sent();
103
+ return [2 /*return*/, "".concat(config.customerName, "-").concat(config.appName, "-").concat(env)];
104
+ }
105
+ });
106
+ }); };
107
+ exports.getProjectNamespace = getProjectNamespace;
108
+ var getProjectPods = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
109
+ var namespace, res;
110
+ return __generator(this, function (_a) {
111
+ switch (_a.label) {
112
+ case 0: return [4 /*yield*/, (0, exports.getProjectNamespace)(envComponent)];
113
+ case 1:
114
+ namespace = _a.sent();
115
+ return [4 /*yield*/, k8sApi_1["default"].listNamespacedPod(namespace)];
116
+ case 2:
117
+ res = _a.sent();
118
+ return [2 /*return*/, res.body.items];
119
+ }
120
+ });
121
+ }); };
122
+ exports.getProjectPods = getProjectPods;
123
+ var getProjectPvcs = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
124
+ var namespace, res;
125
+ return __generator(this, function (_a) {
126
+ switch (_a.label) {
127
+ case 0: return [4 /*yield*/, (0, exports.getProjectNamespace)(envComponent)];
128
+ case 1:
129
+ namespace = _a.sent();
130
+ return [4 /*yield*/, k8sApi_1["default"].listNamespacedPersistentVolumeClaim(namespace)];
131
+ case 2:
132
+ res = _a.sent();
133
+ return [2 /*return*/, res.body.items];
134
+ }
135
+ });
136
+ }); };
137
+ exports.getProjectPvcs = getProjectPvcs;
138
+ var getProjectPodNames = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
139
+ var pods;
140
+ return __generator(this, function (_a) {
141
+ switch (_a.label) {
142
+ case 0: return [4 /*yield*/, (0, exports.getProjectPods)(envComponent)];
143
+ case 1:
144
+ pods = _a.sent();
145
+ return [2 /*return*/, pods.map(function (n) { return n.metadata.name; })];
146
+ }
147
+ });
148
+ }); };
149
+ exports.getProjectPodNames = getProjectPodNames;
150
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/projects/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAA6C;AAE7C,6BAA4B;AAC5B,kEAA8E;AAC9E,wDAAkC;AAClC,kCAA2C;AAEpC,IAAM,UAAU,GAAG;;;;oBAChB,qBAAM,IAAA,4BAAI,EAAC,+BAA+B,CAAC,EAAA;oBAAnD,sBAAO,MAAA,CAAC,SAA2C,CAAC,CAAC,MAAM,0CAAE,IAAI,EAAE,EAAC;;;KACrE,CAAC;AAFW,QAAA,UAAU,cAErB;AAEK,IAAM,mBAAmB,GAAG;;;;oBACjB,qBAAM,IAAA,kBAAU,GAAE,EAAA;;gBAA5B,OAAO,GAAG,SAAkB;gBAClC,sBAAO,IAAA,WAAI,EAAC,OAAO,EAAE,gBAAgB,CAAC,EAAC;;;KACxC,CAAC;AAHW,QAAA,mBAAmB,uBAG9B;AAEK,IAAM,oBAAoB,GAAG;;;YAClC,KAAA,uBAAe,CAAA;YAAC,qBAAM,IAAA,2BAAmB,GAAE,EAAA;gBAA3C,sBAAA,kBAAgB,SAA2B,EAAC,EAAA;;SAAA,CAAC;AADlC,QAAA,oBAAoB,wBACc;AAExC,IAAM,eAAe,GAAG;;;;oBACP,qBAAM,IAAA,4BAAoB,GAAE,EAAA;;gBAA5C,KAAgB,SAA4B,EAA3C,KAAK,QAAA,EAAE,IAAI,QAAA;gBAClB,IAAI,KAAK,EAAE;oBACT,sBAAO,KAAK,EAAC;iBACd;gBACD,sBAAO,IAAI,EAAC;;;KACb,CAAC;AANW,QAAA,eAAe,mBAM1B;AAEK,IAAM,mBAAmB,GAAG,UAAO,YAAoB;;;;;gBACpD,GAAG,GAAK,IAAA,8BAAW,EAAC,YAAY,CAAC,IAA9B,CAA+B;gBAC3B,qBAAM,IAAA,mCAAgB,GAAE,EAAA;;gBAAjC,MAAM,GAAG,SAAwB;gBACvC,sBAAO,UAAG,MAAM,CAAC,YAAY,cAAI,MAAM,CAAC,OAAO,cAAI,GAAG,CAAE,EAAC;;;KAC1D,CAAC;AAJW,QAAA,mBAAmB,uBAI9B;AAEK,IAAM,cAAc,GAAG,UAAO,YAAoB;;;;oBACrC,qBAAM,IAAA,2BAAmB,EAAC,YAAY,CAAC,EAAA;;gBAAnD,SAAS,GAAG,SAAuC;gBAC7C,qBAAM,mBAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAA;;gBAA/C,GAAG,GAAG,SAAyC;gBAErD,sBAAO,GAAG,CAAC,IAAI,CAAC,KAAK,EAAC;;;KACvB,CAAC;AALW,QAAA,cAAc,kBAKzB;AAEK,IAAM,cAAc,GAAG,UAAO,YAAoB;;;;oBACrC,qBAAM,IAAA,2BAAmB,EAAC,YAAY,CAAC,EAAA;;gBAAnD,SAAS,GAAG,SAAuC;gBAC7C,qBAAM,mBAAM,CAAC,mCAAmC,CAAC,SAAS,CAAC,EAAA;;gBAAjE,GAAG,GAAG,SAA2D;gBAEvE,sBAAO,GAAG,CAAC,IAAI,CAAC,KAAK,EAAC;;;KACvB,CAAC;AALW,QAAA,cAAc,kBAKzB;AAEK,IAAM,kBAAkB,GAAG,UAAO,YAAoB;;;;oBAC9C,qBAAM,IAAA,sBAAc,EAAC,YAAY,CAAC,EAAA;;gBAAzC,IAAI,GAAG,SAAkC;gBAC/C,sBAAO,IAAI,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAf,CAAe,CAAC,EAAC;;;KACzC,CAAC;AAHW,QAAA,kBAAkB,sBAG7B"}
@@ -0,0 +1,2 @@
1
+ export declare function filter<T>(arr: T[], iterator: (item: T) => Promise<boolean>): Promise<T[]>;
2
+ export declare const delay: (ms: number) => Promise<unknown>;
@@ -0,0 +1,62 @@
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
+ exports.delay = exports.filter = void 0;
40
+ function filter(arr, iterator) {
41
+ return __awaiter(this, void 0, void 0, function () {
42
+ var fail;
43
+ var _this = this;
44
+ return __generator(this, function (_a) {
45
+ switch (_a.label) {
46
+ case 0:
47
+ fail = Symbol("fail");
48
+ return [4 /*yield*/, Promise.all(arr.map(function (item) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
49
+ switch (_a.label) {
50
+ case 0: return [4 /*yield*/, iterator(item)];
51
+ case 1: return [2 /*return*/, ((_a.sent()) ? item : fail)];
52
+ }
53
+ }); }); }))];
54
+ case 1: return [2 /*return*/, (_a.sent()).filter(function (i) { return i !== fail; })];
55
+ }
56
+ });
57
+ });
58
+ }
59
+ exports.filter = filter;
60
+ var delay = function (ms) { return new Promise(function (res) { return setTimeout(res, ms); }); };
61
+ exports.delay = delay;
62
+ //# sourceMappingURL=promise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise.js","sourceRoot":"","sources":["../../src/utils/promise.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAsB,MAAM,CAC1B,GAAQ,EACR,QAAuC;;;;;;;oBAEjC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;oBACnB,qBAAM,OAAO,CAAC,GAAG,CACxB,GAAG,CAAC,GAAG,CAAC,UAAM,IAAI;;wCAAM,qBAAM,QAAQ,CAAC,IAAI,CAAC,EAAA;wCAAtB,sBAAA,CAAC,CAAC,SAAoB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAA;;iCAAA,CAAC,CAC9D,EAAA;wBAFD,sBAAQ,CAAC,SAER,CAAC,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,KAAK,IAAI,EAAV,CAAU,CAAyB,EAAC;;;;CACpD;AARD,wBAQC;AAEM,IAAM,KAAK,GAAG,UAAC,EAAU,IAAK,OAAA,IAAI,OAAO,CAAC,UAAA,GAAG,IAAI,OAAA,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,EAAnB,CAAmB,CAAC,EAAvC,CAAuC,CAAC;AAAhE,QAAA,KAAK,SAA2D"}
@@ -0,0 +1 @@
1
+ export declare const getShell: (namespace: string, podName: string) => Promise<void>;
@@ -0,0 +1,81 @@
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.getShell = void 0;
51
+ var child_process_promise_1 = require("child-process-promise");
52
+ var getShell = function (namespace, podName) { return __awaiter(void 0, void 0, void 0, function () {
53
+ var command, e_1;
54
+ return __generator(this, function (_a) {
55
+ switch (_a.label) {
56
+ case 0:
57
+ command = "kubectl exec -it ".concat(podName, " -n ").concat(namespace, " -- /bin/sh -xc 'bash||sh'");
58
+ _a.label = 1;
59
+ case 1:
60
+ _a.trys.push([1, 3, , 4]);
61
+ return [4 /*yield*/, (0, child_process_promise_1.spawn)(command, {
62
+ stdio: "inherit",
63
+ shell: true,
64
+ env: __assign(__assign({}, process.env), { DEBUG: "" })
65
+ })];
66
+ case 2:
67
+ _a.sent();
68
+ return [3 /*break*/, 4];
69
+ case 3:
70
+ e_1 = _a.sent();
71
+ // tslint:disable-next-line:no-console
72
+ if (e_1.code !== 130) {
73
+ console.log(e_1);
74
+ }
75
+ return [3 /*break*/, 4];
76
+ case 4: return [2 /*return*/];
77
+ }
78
+ });
79
+ }); };
80
+ exports.getShell = getShell;
81
+ //# sourceMappingURL=shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/utils/shell.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAA8C;AAEvC,IAAM,QAAQ,GAAG,UAAO,SAAiB,EAAE,OAAe;;;;;gBACzD,OAAO,GAAG,2BAAoB,OAAO,iBAAO,SAAS,+BAA4B,CAAC;;;;gBAEtF,qBAAM,IAAA,6BAAK,EAAC,OAAO,EAAE;wBACnB,KAAK,EAAE,SAAS;wBAChB,KAAK,EAAE,IAAI;wBACX,GAAG,wBACE,OAAO,CAAC,GAAG,KACd,KAAK,EAAE,EAAE,GACV;qBACF,CAAC,EAAA;;gBAPF,SAOE,CAAC;;;;gBAEH,sCAAsC;gBACtC,IAAI,GAAC,CAAC,IAAI,KAAK,GAAG,EAAE;oBAClB,OAAO,CAAC,GAAG,CAAC,GAAC,CAAC,CAAC;iBAChB;;;;;KAEJ,CAAC;AAjBW,QAAA,QAAQ,YAiBnB"}
package/package.json CHANGED
@@ -7,59 +7,51 @@
7
7
  "scripts": {
8
8
  "lint": "eslint \"src/**/*.ts\"",
9
9
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
10
- "test": "npm run lint",
11
- "build": "tsc",
12
- "build:watch": "tsc -w"
10
+ "test": "yarn run lint",
11
+ "build": "yarn tsc",
12
+ "build:watch": "yarn tsc -w"
13
13
  },
14
14
  "bin": {
15
- "catladder": "./bin/catladder",
16
- "catenv": "./bin/catenv.sh"
15
+ "catenv": "./bin/catenv",
16
+ "catladder": "./bin/catladder"
17
17
  },
18
18
  "dependencies": {
19
- "@bitwarden/cli": "^1.8.0",
19
+ "@catladder/pipeline": "1.0.2",
20
20
  "@kubernetes/client-node": "^0.16.1",
21
21
  "child-process-promise": "^2.2.1",
22
- "clipboardy": "^2.2.0",
23
22
  "command-exists-promise": "^2.0.2",
24
23
  "common-tags": "^1.8.0",
25
24
  "dayjs": "^1.10.4",
26
25
  "fs-extra": "^7.0.1",
27
- "git-repo-name": "^1.0.1",
28
26
  "gitlab": "^4.4.1",
29
27
  "js-yaml": "^3.12.0",
30
- "lodash": "^4.17.11",
28
+ "lodash": "^4.17.21",
31
29
  "memoizee": "^0.4.14",
32
30
  "node-fetch": "^2.3.0",
33
31
  "open": "^8.4.0",
34
- "open-editor": "^2.0.1",
35
- "open-in-editor": "^2.2.0",
36
32
  "tmp-promise": "^2.0.2",
37
33
  "update-notifier": "^2.5.0",
38
- "vorpal": "^1.12.0",
39
- "yargs": "^13.2.4",
40
- "yawn-yaml": "^1.3.4"
34
+ "vorpal": "^1.12.0"
41
35
  },
42
36
  "engines": {
43
37
  "node": ">=12.0.0"
44
38
  },
45
39
  "devDependencies": {
46
- "@semantic-release/git": "^10.0.1",
47
- "@semantic-release/gitlab": "^7.0.4",
48
40
  "@tsconfig/node14": "^1.0.1",
49
41
  "@types/common-tags": "^1.8.0",
50
42
  "@types/fs-extra": "^5.0.4",
51
- "@types/js-yaml": "^3.11.2",
43
+ "@types/js-yaml": "^4.0.5",
52
44
  "@types/lodash": "^4.14.119",
53
45
  "@types/memoizee": "^0.4.2",
54
46
  "@types/node-fetch": "^2.1.4",
55
47
  "@types/request": "^2.48.1",
48
+ "@types/tmp": "^0.2.3",
56
49
  "@types/update-notifier": "^2.5.0",
57
50
  "@types/vorpal": "^1.12.0",
58
51
  "@types/websocket": "^0.0.40",
59
52
  "@types/yargs": "^13.0.0",
60
- "@typescript-eslint/eslint-plugin": "^5.8.0",
61
- "@typescript-eslint/parser": "^5.8.0",
53
+ "eslint": "^8.7.0",
62
54
  "typescript": "^4.5.4"
63
55
  },
64
- "version": "v0.0.0"
56
+ "version": "1.0.2"
65
57
  }
@@ -1,38 +1,59 @@
1
- import { getAllEnvVars } from "../../utils/projects";
2
- import {
3
- getCurrentSubApp,
4
- getSubAppsInMonoRepo,
5
- } from "../shell/commands/project/utils/monorepo";
1
+ import { Config, ComponentConfig } from "@catladder/pipeline";
2
+ import { getEnvVars, getProjectConfig } from "../../config/getProjectConfig";
3
+ import { getGitRoot } from "../../utils/projects";
4
+ import { join } from "path";
5
+ const getCurrentComponentName = async (
6
+ components: Record<string, ComponentConfig>
7
+ ) => {
8
+ const gitRoot = await getGitRoot();
9
+ const currentDir = process.cwd();
10
+ return Object.keys(components).find((c) =>
11
+ currentDir.startsWith(join(gitRoot, components[c].dir))
12
+ );
13
+ };
6
14
 
7
15
  const sanitizeEnvVarName = (name: string) => name.replace(/[\s\-.]+/g, "_");
8
- export default async () => {
9
- const subapps = await getSubAppsInMonoRepo();
10
- const currentSubApp = await getCurrentSubApp();
16
+
17
+ const getAllVariablesToPrint = async (config: Config) => {
18
+ const { components } = config;
19
+
20
+ const currentComponent = await getCurrentComponentName(components);
21
+
11
22
  let variables = {};
12
- if (currentSubApp) {
13
- variables = await getAllEnvVars("dev-local", currentSubApp.componentName);
14
- } else if (subapps.length > 0) {
23
+ if (currentComponent) {
24
+ variables = await getEnvVars(null, "local", currentComponent);
25
+ } else {
15
26
  // when in a monorep and not in a subapp, merge all env vars.
16
27
  // this is not 100% correct, but better than not exporting any vars at all
17
28
  // so we also add prefixed variants
18
- variables = await subapps.reduce(async (acc, subapp) => {
19
- const subappvars = await getAllEnvVars("dev-local", subapp.componentName);
20
- return {
21
- ...(await acc),
22
- ...subappvars,
23
- // also add prefixed variants in case
24
- ...Object.fromEntries(
25
- Object.entries(subappvars).map(([key, value]) => [
26
- `${sanitizeEnvVarName(subapp.componentName.toUpperCase())}_${key}`,
27
- value,
28
- ])
29
- ),
30
- };
31
- }, {});
32
- } else {
33
- variables = await getAllEnvVars("dev-local");
29
+ variables = await Object.keys(components).reduce(
30
+ async (acc, componentName) => {
31
+ const subappvars = await getEnvVars(null, "local", componentName);
32
+ return {
33
+ ...(await acc),
34
+ ...subappvars,
35
+ // also add prefixed variants in case
36
+ ...Object.fromEntries(
37
+ Object.entries(subappvars).map(([key, value]) => [
38
+ `${sanitizeEnvVarName(componentName.toUpperCase())}_${key}`,
39
+ value,
40
+ ])
41
+ ),
42
+ };
43
+ },
44
+ {}
45
+ );
46
+ }
47
+ return variables;
48
+ };
49
+ export default async () => {
50
+ const config = await getProjectConfig();
51
+ if (!config) {
52
+ return;
34
53
  }
35
54
 
55
+ const variables = await getAllVariablesToPrint(config);
56
+
36
57
  console.log(
37
58
  Object.entries(variables)
38
59
  .map(([key, value]) => `export ${key}='${value}'`)
@@ -6,11 +6,15 @@ import general from "./commands/general";
6
6
  import mongodb from "./commands/mongodb";
7
7
  import project from "./commands/project";
8
8
  import theStuffThatReallyMatters from "./commands/theStuffThatReallyMatters";
9
- const welcomeMessage = `catladder 2 😻 version ${packageInfos.version}`;
10
9
 
11
- export default () => {
10
+ import { verify } from "./verify";
11
+ import { showProjectBanner } from "./commands/project/utils/showProjectBanner";
12
+
13
+ export default async () => {
12
14
  const vorpal = new Vorpal();
13
15
 
16
+ const welcomeMessage = `catladder 2022 😻 version ${packageInfos.version}`;
17
+
14
18
  vorpal
15
19
  .delimiter("catladder $") // emoji messes with cursor :-( https://github.com/dthree/vorpal/issues/332
16
20
  .history("catladder")
@@ -19,6 +23,10 @@ export default () => {
19
23
  .log(welcomeMessage)
20
24
  .log("");
21
25
 
26
+ await showProjectBanner(vorpal);
27
+
28
+ verify(vorpal);
29
+
22
30
  general(vorpal);
23
31
  project(vorpal);
24
32
  mongodb(vorpal);
@@ -34,7 +34,7 @@ export const getAllNamespacesNames = async () => {
34
34
  const namespaces = await getAllNamespaces();
35
35
  return namespaces.map((n) => n.metadata.name);
36
36
  };
37
- export default (vorpal: Vorpal) => {
37
+ export default async (vorpal: Vorpal) => {
38
38
  vorpal
39
39
  .command("connect-cluster <clustername>")
40
40
  .autocomplete(getAllClusterNames())
@@ -6,7 +6,7 @@ import { startPortForward } from "../../../../utils/portForward";
6
6
  import k8sApi from "../../../../k8sApi";
7
7
  import { namespaceAutoCompletion } from "./namespaceAutoCompletion";
8
8
 
9
- export default (vorpal: Vorpal) =>
9
+ export default async (vorpal: Vorpal) =>
10
10
  vorpal
11
11
  .command("port-forward <namespace>", "start port-forwarding")
12
12
  .autocomplete(namespaceAutoCompletion)
@@ -3,7 +3,7 @@ import projectMongoDestroyMember from "./projectMongoDestroyMember";
3
3
  import projectMongoGetShell from "./projectMongoGetShell";
4
4
  import projectMongoPortForward from "./projectMongoPortForward";
5
5
 
6
- export default (vorpal: Vorpal) => {
6
+ export default async (vorpal: Vorpal) => {
7
7
  projectMongoGetShell(vorpal);
8
8
  projectMongoPortForward(vorpal);
9
9
  projectMongoDestroyMember(vorpal);
@@ -3,9 +3,9 @@ import Vorpal from "vorpal";
3
3
  import { logError } from "../../../../utils/log";
4
4
  import {
5
5
  getProjectNamespace,
6
- getProjectPvcs
6
+ getProjectPvcs,
7
7
  } from "../../../../utils/projects";
8
- import { envAutocompletion } from "../project/utils/autocompletions";
8
+ import { envAndComponents } from "../project/utils/autocompletions";
9
9
  import ensureCluster from "../project/utils/ensureCluster";
10
10
  import { getMongoDbPodsWithReplInfo } from "./utils";
11
11
 
@@ -31,18 +31,18 @@ const removeFinalizerAndDelete = async (
31
31
  ) => {
32
32
  return Promise.all([
33
33
  removeFinalizer(namespace, type, name),
34
- await deleteResource(namespace, type, name)
34
+ await deleteResource(namespace, type, name),
35
35
  ]);
36
36
  };
37
- export default (vorpal: Vorpal) =>
37
+ export default async (vorpal: Vorpal) =>
38
38
  vorpal
39
39
  .command(
40
- "project-mongo-destroy-member <env>",
40
+ "project-mongo-destroy-member <envComponent>",
41
41
  "DESTROY a member of a replicaset in order to reinitialize it"
42
42
  )
43
- .autocomplete(envAutocompletion)
44
- .action(async function({ env }) {
45
- await ensureCluster.call(this);
43
+ .autocomplete(await envAndComponents())
44
+ .action(async function ({ envComponent }) {
45
+ await ensureCluster.call(this, envComponent);
46
46
  this.log(
47
47
  "this command tries to delete a (secondary) member of the replicaset, it's persistent volume claim (pvc) and the volume"
48
48
  );
@@ -67,18 +67,18 @@ export default (vorpal: Vorpal) =>
67
67
  default: true,
68
68
  message: "DO YOU UNDERSTAND?",
69
69
  name: "understood",
70
- type: "confirm"
70
+ type: "confirm",
71
71
  });
72
72
 
73
73
  if (!understood) {
74
74
  throw new Error("abort");
75
75
  }
76
76
 
77
- const namespace = await getProjectNamespace(env);
78
- const mongodbPods = await getMongoDbPodsWithReplInfo(env);
77
+ const namespace = await getProjectNamespace(envComponent);
78
+ const mongodbPods = await getMongoDbPodsWithReplInfo(envComponent);
79
79
 
80
- const pvcs = await getProjectPvcs(env);
81
- const secondaries = mongodbPods.filter(pod => !pod.isMaster);
80
+ const pvcs = await getProjectPvcs(envComponent);
81
+ const secondaries = mongodbPods.filter((pod) => !pod.isMaster);
82
82
 
83
83
  if (secondaries.length === 0) {
84
84
  logError(this, "sorry, no pods found");
@@ -89,16 +89,16 @@ export default (vorpal: Vorpal) =>
89
89
  await this.prompt({
90
90
  type: "list",
91
91
  name: "podName",
92
- choices: secondaries.map(p => ({
92
+ choices: secondaries.map((p) => ({
93
93
  name: `[ secondary ] ${p.podName}`,
94
- value: p.podName
94
+ value: p.podName,
95
95
  })),
96
- message: "Which pod? 🤔"
96
+ message: "Which pod? 🤔",
97
97
  })
98
98
  ).podName;
99
99
 
100
100
  const thePvc = pvcs.find(
101
- pvc => pvc.metadata.name === `datadir-${podName}`
101
+ (pvc) => pvc.metadata.name === `datadir-${podName}`
102
102
  );
103
103
  if (!thePvc) {
104
104
  logError(this, `sorry, no pvc found for ${podName}`);
@@ -109,7 +109,7 @@ export default (vorpal: Vorpal) =>
109
109
  message:
110
110
  "THIS WILL DESTROY THE POD, ITS VOLUME AND ALL ITS DATA 🙀🙀🙀!!! continue? 🤔",
111
111
  name: "shouldContinue",
112
- type: "confirm"
112
+ type: "confirm",
113
113
  });
114
114
 
115
115
  if (!shouldContinue) {