@catladder/cli 0.0.1-bla → 1.0.3

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 +208 -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
@@ -1,245 +0,0 @@
1
- import { V1Secret } from "@kubernetes/client-node";
2
- import yaml from "js-yaml";
3
- import { difference, mapValues, pick } from "lodash";
4
- import Vorpal from "vorpal";
5
- import { GOOGLE_CLOUD_SQL_PASS_PATH } from "../../../../config/constants";
6
- import k8sApi from "../../../../k8sApi";
7
- import { ISecrets } from "../../../../types/types";
8
- import { logError } from "../../../../utils/log";
9
- import {
10
- editPass,
11
- insertPass,
12
- readPass,
13
- readPassEnvVars,
14
- syncBitwarden,
15
- } from "../../../../utils/passwordstore";
16
- import {
17
- getAllSecretsEnvVarsMapping,
18
- getPassPath,
19
- getProjectNamespace,
20
- } from "../../../../utils/projects";
21
- import { delay } from "../../../../utils/promise";
22
- import { envAutocompletion } from "./utils/autocompletions";
23
- import ensureCluster from "./utils/ensureCluster";
24
- import ensureNamespace from "./utils/ensureNamespace";
25
- import { promptForSubAppIfAny } from "./utils/monorepo";
26
-
27
- export default (vorpal: Vorpal) => {
28
- vorpal
29
- .command(
30
- "project-config-secrets <env>",
31
- "setup/update secrets stored in pass"
32
- )
33
- .autocomplete(envAutocompletion)
34
- .action(async function ({ env }) {
35
- await ensureCluster.call(this);
36
-
37
- const passPath = await getPassPath(env);
38
- this.log("");
39
- this.log(`😼 I will now open bitwarden @ '${passPath}'`);
40
- this.log("");
41
-
42
- const subapp = await promptForSubAppIfAny(this);
43
-
44
- const secretEnvVarsMapping = await getAllSecretsEnvVarsMapping(
45
- env,
46
- subapp
47
- );
48
-
49
- await syncBitwarden();
50
-
51
- // check if exist and fill in details if not
52
- try {
53
- await readPass(passPath);
54
- } catch (e) {
55
- // does not exist. create it
56
- await createNewEnvInPass.call(this, env, secretEnvVarsMapping);
57
- }
58
-
59
- let envConfigInPass: any = null;
60
- // eslint-disable-next-line no-constant-condition
61
- while (true) {
62
- let hasError = false;
63
- await editPass(passPath);
64
-
65
- try {
66
- envConfigInPass = await readPassEnvVars(passPath);
67
-
68
- const configuredKeysInPass = Object.keys(envConfigInPass);
69
-
70
- const allSecretEnvKeysInValues = Object.keys(secretEnvVarsMapping);
71
- const keysNotInValues = difference(
72
- configuredKeysInPass,
73
- allSecretEnvKeysInValues
74
- );
75
-
76
- const keysNotInPass = difference(
77
- allSecretEnvKeysInValues,
78
- configuredKeysInPass
79
- );
80
- if (keysNotInValues.length > 0) {
81
- this.log("");
82
- this.log(
83
- `☝️ Notice: the following keys are defined in pass, but not in values: ${keysNotInValues.join(
84
- ", "
85
- )}`
86
- );
87
- this.log(
88
- `These values are probably from another app that uses the same namespace.`
89
- );
90
- this.log("");
91
- }
92
- if (keysNotInPass.length > 0) {
93
- await logError(
94
- this,
95
- `the following keys are defined in the values.yaml, but not in pass: ${keysNotInPass.join(
96
- ", "
97
- )}`
98
- );
99
-
100
- hasError = true;
101
- }
102
- } catch (e) {
103
- await logError(this, "failed to parse yaml", e.message);
104
- hasError = true;
105
- }
106
-
107
- if (hasError) {
108
- this.log("");
109
- this.log("🤦 You miserably failed to provide something useful 💩");
110
- this.log("");
111
- await delay(1000);
112
- const { shouldContinue } = await this.prompt({
113
- default: true,
114
- message: "Try again? 🤔",
115
- name: "shouldContinue",
116
- type: "confirm",
117
- });
118
-
119
- if (!shouldContinue) {
120
- throw new Error("abort");
121
- }
122
- } else {
123
- break;
124
- }
125
- }
126
-
127
- if (env !== "env-local") {
128
- await ensureNamespace.call(this, env);
129
-
130
- this.log(
131
- "😼 Please be patient while i am doing some complicated stuff... "
132
- );
133
- const namespace = await getProjectNamespace(env);
134
-
135
- // secrets is object of [key]: secretName
136
- const grouped = Object.keys(secretEnvVarsMapping).reduce<{
137
- [secretName: string]: string[];
138
- }>((acc, key) => {
139
- const secretName = secretEnvVarsMapping[key];
140
- return {
141
- ...acc,
142
- [secretName]: [...(acc[secretName] || []), key],
143
- };
144
- }, {});
145
-
146
- for (const secretName of Object.keys(grouped)) {
147
- const valueKeysInGroup = grouped[secretName];
148
- const valuesFromPassInGroup = pick(envConfigInPass, valueKeysInGroup);
149
-
150
- let existingSecretValues = {};
151
- try {
152
- const existingSecretResult = await k8sApi.readNamespacedSecret(
153
- secretName,
154
- namespace
155
- );
156
- // tslint:disable-next-line:no-console
157
- if (existingSecretResult && existingSecretResult.body.data) {
158
- existingSecretValues = existingSecretResult.body.data;
159
- }
160
- } catch (e) {
161
- // ignore
162
- }
163
- await createKubernetesSecret.call(
164
- this,
165
- namespace,
166
- secretName,
167
-
168
- valuesFromPassInGroup,
169
- existingSecretValues
170
- );
171
- }
172
- this.log("");
173
- // adding gcloud sql proxy secret
174
- const cloudsqlCredentials = await readPass(GOOGLE_CLOUD_SQL_PASS_PATH);
175
- await createKubernetesSecret.call(
176
- this,
177
- namespace,
178
- "cloudsql-instance-credentials",
179
- {
180
- "credentials.json": cloudsqlCredentials,
181
- }
182
- );
183
- this.log("");
184
- this.log(
185
- "⚠️ You need to delete/restart pods in order to make them pick up the new config"
186
- );
187
- this.log(`you can use project-delete-pods ${env} to do that`);
188
- this.log("");
189
- this.log("");
190
- await delay(1000);
191
- }
192
- this.log("");
193
- this.log("😻 success!!!!!");
194
- this.log("");
195
- });
196
- };
197
- async function createKubernetesSecret(
198
- namespace: string,
199
- secretName: string,
200
- stringData: Pick<any, string>,
201
- existingSecretValues?: Record<string, string>
202
- ) {
203
- const secret = new V1Secret();
204
- secret.metadata = {
205
- name: secretName,
206
- };
207
- secret.data = existingSecretValues;
208
- secret.stringData = stringData;
209
- this.log(`😼 upserting secret '${secretName}' (push it real good!)`);
210
- try {
211
- await k8sApi.deleteNamespacedSecret(secretName, namespace, "true");
212
- } catch (e) {
213
- // ignore
214
- }
215
- try {
216
- await k8sApi.createNamespacedSecret(namespace, secret);
217
- } catch (e) {
218
- logError(this, "error pushing secrets", e.body.message);
219
- }
220
- }
221
-
222
- async function createNewEnvInPass(env: any, secretEnvVarsMapping: ISecrets) {
223
- const passPath = await getPassPath(env);
224
- this.log(
225
- "Your selected env is not yet in pass. Do you want to copy it from another env? "
226
- );
227
- const noAnswer = "No, I will create a new one from scratch.";
228
- const { sourceEnv } = await this.prompt({
229
- type: "list",
230
- name: "sourceEnv",
231
- choices: [...envAutocompletion.filter((e) => e !== env), noAnswer],
232
- message: "Do you want to copy an env?",
233
- });
234
- if (sourceEnv === noAnswer) {
235
- await insertPass(
236
- passPath,
237
- yaml.safeDump(mapValues(secretEnvVarsMapping, (value, key) => "fillme"))
238
- );
239
- } else {
240
- const sourceEnvPath = await getPassPath(sourceEnv);
241
- const stdout = await readPass(sourceEnvPath);
242
-
243
- await insertPass(passPath, stdout);
244
- }
245
- }
@@ -1,17 +0,0 @@
1
- import Vorpal from "vorpal";
2
- import { getAllEnvVars } from "../../../../utils/projects";
3
- import { envAutocompletion } from "./utils/autocompletions";
4
- import { promptForSubAppIfAny } from "./utils/monorepo";
5
-
6
- export default (vorpal: Vorpal) =>
7
- vorpal
8
- .command("project-env-vars <env>", "list env vars")
9
- .autocomplete(envAutocompletion)
10
- .action(async function ({ env }) {
11
- const subApp = await promptForSubAppIfAny(this);
12
-
13
- const envvars = await getAllEnvVars(env, subApp);
14
- Object.keys(envvars).forEach((key) =>
15
- this.log(`${key}: ${envvars[key]}`)
16
- );
17
- });
@@ -1,157 +0,0 @@
1
- import open from "open";
2
- import Vorpal from "vorpal";
3
- import { getClusterByName } from "../../../../utils/cluster";
4
- import { doGitlabRequest, getProjectInfo } from "../../../../utils/gitlab";
5
- import { readPass, syncBitwarden } from "../../../../utils/passwordstore/";
6
- import {
7
- getLocalProjectVariables,
8
- getProjectNamespace,
9
- } from "../../../../utils/projects";
10
-
11
- export default (vorpal: Vorpal) =>
12
- vorpal
13
- .command(
14
- "project-init-gitlab",
15
- "Initializes the gitlab repo, e.g. connects the cluster to it"
16
- )
17
- .action(async function () {
18
- const { id: projectId, web_url: projectWebUrl } = await getProjectInfo(
19
- this
20
- );
21
- await syncBitwarden();
22
- const clusters = await doGitlabRequest(
23
- this,
24
- `projects/${projectId}/clusters`
25
- );
26
-
27
- if (clusters.length === 0) {
28
- this.log("");
29
- this.log("there is no cluster on the current project?");
30
- } else {
31
- this.log("there are already these clusters on the gitlab: ");
32
- this.log("");
33
- clusters.forEach((cluster: any) => this.log(` - ${cluster.name}`));
34
- }
35
-
36
- this.log("");
37
- this.log("your project specifies the following cluster:");
38
- this.log("");
39
- const { CLUSTER_NAME } = await getLocalProjectVariables();
40
- const configuredCluster = await getClusterByName(CLUSTER_NAME);
41
- if (!configuredCluster) {
42
- throw new Error(
43
- `there exist no cluster with the name '${CLUSTER_NAME}'`
44
- );
45
- }
46
- this.log(`${CLUSTER_NAME} (${configuredCluster.fullName})`);
47
- this.log("");
48
- const { shouldContinue } = await this.prompt({
49
- type: "confirm",
50
- name: "shouldContinue",
51
- message: "Should I add the this cluster ? 🤔 ",
52
- });
53
- this.log("");
54
- if (shouldContinue) {
55
- const { api_url, passCredentials } = configuredCluster;
56
- if (!api_url) {
57
- throw new Error("no api_url on this cluster!");
58
- }
59
- if (!passCredentials) {
60
- throw new Error("no passCredentials on this cluster!");
61
- }
62
- const token = await readPass(passCredentials.token);
63
- const ca_cert = await readPass(passCredentials.ca_cert);
64
-
65
- const postResult = await doGitlabRequest(
66
- this,
67
- `projects/${projectId}/clusters/user`,
68
- {
69
- name: configuredCluster.fullName,
70
- managed: false,
71
- platform_kubernetes_attributes: {
72
- api_url,
73
- ca_cert,
74
- token,
75
- namespace: await getProjectNamespace("prod"),
76
- },
77
- }
78
- );
79
- const { message } = postResult;
80
- if (message) {
81
- this.log(`Message from gitlab: ${message}`);
82
- }
83
- }
84
-
85
- const variables = await doGitlabRequest(
86
- this,
87
- `projects/${projectId}/variables`
88
- );
89
-
90
- if (!variables.find((v: any) => v.key === "GL_TOKEN")) {
91
- this.log(
92
- "I need add a GL_TOKEN to the project, so that semantic release will work\n"
93
- );
94
- this.log(
95
- "👉 Please please create a project access token in gitlab and copy its value into clipboard\n\n - name: something like 'semantic-release'\n - expires: leave empty\n - scopes: api, read_repository"
96
- );
97
- this.log("\n");
98
-
99
- const { understood } = await this.prompt({
100
- default: true,
101
- message: "Understood and open gitlab now? 🤔",
102
- name: "understood",
103
- type: "confirm",
104
- });
105
- if (!understood) {
106
- this.log("continuing anyway...");
107
- }
108
- open(`${projectWebUrl}/-/settings/access_tokens`);
109
-
110
- this.log("\n");
111
-
112
- this.log("Enter your copied token now: ");
113
-
114
- this.log("\n");
115
- const { GL_TOKEN } = await this.prompt({
116
- type: "password",
117
- name: "GL_TOKEN",
118
- message: "Access Token: ",
119
- });
120
- await doGitlabRequest(this, `projects/${projectId}/variables`, {
121
- key: "GL_TOKEN",
122
- value: GL_TOKEN,
123
- });
124
- }
125
-
126
- const deploy_tokens = await doGitlabRequest(
127
- this,
128
- `projects/${projectId}/deploy_tokens`
129
- );
130
-
131
- if (
132
- !deploy_tokens.find(
133
- (v: { name: string }) => v.name === "gitlab-deploy-token"
134
- )
135
- ) {
136
- this.log(
137
- "I will setup the 'GitLab Deploy Token', so Kubernetes can pull images from this project."
138
- );
139
-
140
- await doGitlabRequest(this, `projects/${projectId}/deploy_tokens`, {
141
- id: projectId,
142
- name: "gitlab-deploy-token",
143
- scopes: ["read_registry"],
144
- });
145
- }
146
- this.log("gitlab is ready! 🥂");
147
- this.log("\n");
148
- this.log("do not forget to make sure that:");
149
- [
150
- "you have __health route in place",
151
- "lint and test are defined",
152
- "eat your vegetables",
153
- "be awesome 🤩",
154
- ].forEach((tip) => this.log(` - ${tip}`));
155
- this.log("\n");
156
- this.log("\n");
157
- });
@@ -1,21 +0,0 @@
1
- import yaml from "js-yaml";
2
- import { pick } from "lodash";
3
- import Vorpal from "vorpal";
4
- import { getProjectPods } from "../../../../utils/projects";
5
-
6
- import { envAutocompletion } from "./utils/autocompletions";
7
- import ensureCluster from "./utils/ensureCluster";
8
-
9
- export default (vorpal: Vorpal) =>
10
- vorpal
11
- .command("project-list-pods <env>", "list pods of local project")
12
- .autocomplete(envAutocompletion)
13
- .action(async function({ env }) {
14
- await ensureCluster.call(this);
15
- const pods = await getProjectPods(env);
16
- this.log(
17
- yaml.safeDump(
18
- pods.map(p => pick(p, ["metadata.name", "status.startTime"]))
19
- )
20
- );
21
- });
@@ -1,12 +0,0 @@
1
- import Vorpal from "vorpal";
2
- import { Env } from "../../../../types/types";
3
- import { getProjectNamespace } from "../../../../utils/projects";
4
- import { envAutocompletion } from "./utils/autocompletions";
5
-
6
- export default (vorpal: Vorpal) =>
7
- vorpal
8
- .command("project-namespace <env>", "show namespace of local project")
9
- .autocomplete(envAutocompletion)
10
- .action(async function({ env }) {
11
- this.log(await getProjectNamespace(env as Env));
12
- });
@@ -1,27 +0,0 @@
1
- import Vorpal from "vorpal";
2
- import { getCurrentConnectedClusterName } from "../../../../utils/cluster";
3
- import { getProjectNamespace } from "../../../../utils/projects";
4
- import { getGoogleAuthUserNumber } from "../../utils/getGoogleAuthUserNumber";
5
- import { openGoogleCloudKubernetesDashboard } from "../shared";
6
- import { envAutocompletion } from "./utils/autocompletions";
7
- import ensureCluster from "./utils/ensureCluster";
8
-
9
- export default (vorpal: Vorpal) =>
10
- vorpal
11
- .command(
12
- "project-open-dashboard <env>",
13
- "open kubernetes dashboard on google"
14
- )
15
- .autocomplete(envAutocompletion)
16
- .action(async function ({ env }) {
17
- await ensureCluster.call(this);
18
- const clustername = await getCurrentConnectedClusterName();
19
- const namespace = await getProjectNamespace(env);
20
- const authGoogleNumber = await getGoogleAuthUserNumber.call(this, vorpal);
21
-
22
- openGoogleCloudKubernetesDashboard(
23
- authGoogleNumber,
24
- clustername,
25
- namespace
26
- );
27
- });
@@ -1,18 +0,0 @@
1
- import open from "open";
2
- import Vorpal from "vorpal";
3
- import { getLocalProjectVariables } from "../../../../utils/projects";
4
-
5
- import { envAutocompletion } from "./utils/autocompletions";
6
- import ensureCluster from "./utils/ensureCluster";
7
-
8
- export default (vorpal: Vorpal) =>
9
- vorpal
10
- .command("project-open-env <env>", "open the live environment")
11
- .autocomplete(envAutocompletion)
12
- .action(async function ({ env }) {
13
- await ensureCluster.call(this);
14
- const { CUSTOMER_NAME, APP_NAME } = await getLocalProjectVariables();
15
- const url = `https://${APP_NAME}-${env}.${CUSTOMER_NAME}.panter.cloud`;
16
-
17
- open(url);
18
- });
@@ -1,13 +0,0 @@
1
- import yaml from "js-yaml";
2
- import Vorpal from "vorpal";
3
- import { getLocalProjectVariables } from "../../../../utils/projects";
4
-
5
- export default (vorpal: Vorpal) =>
6
- vorpal
7
- .command("project-variables", "get local project variables")
8
- .action(async function() {
9
- const variables = await getLocalProjectVariables();
10
- this.log("");
11
- this.log(yaml.safeDump(variables));
12
- this.log("");
13
- });
@@ -1,7 +0,0 @@
1
- export const envAutocompletion = [
2
- "review",
3
- "dev",
4
- "stage",
5
- "prod",
6
- "dev-local",
7
- ] as const;
@@ -1,31 +0,0 @@
1
- import {
2
- connectToCluster,
3
- getCurrentConnectedClusterName,
4
- } from "../../../../../utils/cluster";
5
- import { getLocalProjectVariables } from "../../../../../utils/projects/index";
6
- export default async function () {
7
- const { CLUSTER_NAME } = await getLocalProjectVariables();
8
- if (!CLUSTER_NAME) {
9
- throw new Error("no CLUSTER_NAME configured in current project");
10
- }
11
- const connectedClusterName = await getCurrentConnectedClusterName();
12
-
13
- if (CLUSTER_NAME !== connectedClusterName) {
14
- this.log(
15
- `you are currently connected to cluster '${connectedClusterName}'`
16
- );
17
- this.log(`but the project requires cluster '${CLUSTER_NAME}'`);
18
- const { shouldContinue } = await this.prompt({
19
- type: "confirm",
20
- name: "shouldContinue",
21
- default: true,
22
- message: `Do you want to connect to '${CLUSTER_NAME}'?`,
23
- });
24
- if (!shouldContinue) {
25
- this.log("abort");
26
- } else {
27
- await connectToCluster(CLUSTER_NAME);
28
- this.log(`connected to cluster '${CLUSTER_NAME}'`);
29
- }
30
- }
31
- }
@@ -1,45 +0,0 @@
1
- import { existsSync, readdirSync } from "fs-extra";
2
- import { join } from "path";
3
- import { CommandInstance } from "vorpal";
4
- import { getGitRoot } from "../../../../../utils/projects";
5
-
6
- export const getSubAppsInMonoRepo = async () => {
7
- const gitRoot = await getGitRoot();
8
- return readdirSync(gitRoot)
9
- .map((dir) => ({
10
- componentName: dir,
11
- ci: join(gitRoot, dir, ".gitlab-ci.yml"),
12
- path: join(gitRoot, dir),
13
- }))
14
- .filter(({ ci }) => existsSync(ci));
15
- };
16
-
17
- export const getCurrentSubApp = async () => {
18
- const gitRoot = await getGitRoot();
19
- const subApps = await getSubAppsInMonoRepo();
20
- const currentDir = process.cwd();
21
- return subApps.find((a) =>
22
- currentDir.startsWith(join(gitRoot, a.componentName))
23
- );
24
- };
25
-
26
- export const promptForSubAppIfAny = async (
27
- vorpal: CommandInstance
28
- ): Promise<string | null> => {
29
- const currentSubApp = await getCurrentSubApp();
30
- if (currentSubApp) {
31
- return currentSubApp.componentName;
32
- }
33
- const subApps = await getSubAppsInMonoRepo();
34
- if (subApps.length > 0) {
35
- const { subApp } = await vorpal.prompt({
36
- type: "list",
37
- name: "subApp",
38
- choices: subApps.map((a) => a.componentName),
39
- message: "Which subapp 🤔 ?",
40
- });
41
- return subApp;
42
- } else {
43
- return null;
44
- }
45
- };
package/src/index.ts DELETED
@@ -1,17 +0,0 @@
1
- import updateNotifier from "update-notifier";
2
- import { argv } from "yargs";
3
- import catenv from "./apps/catenv/catenv";
4
- import shell from "./apps/shell/shell";
5
- import packageInfos from "./packageInfos";
6
-
7
- // tslint:disable-next-line:no-var-requires
8
-
9
- updateNotifier({
10
- pkg: packageInfos,
11
- }).notify();
12
-
13
- if (argv.catenv) {
14
- catenv();
15
- } else {
16
- shell();
17
- }
@@ -1 +0,0 @@
1
- declare module "git-repo-name";
@@ -1 +0,0 @@
1
- declare module "yawn-yaml/cjs";
@@ -1,20 +0,0 @@
1
- import { exec } from "child-process-promise";
2
- import clipboardy from "clipboardy";
3
- export const getToken = async () => {
4
- const { stdout } = await exec(
5
- `kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | awk '/^deployment-controller-token-/{print $1}') | awk '$1=="token:"{print $2}'`
6
- );
7
- return stdout;
8
- };
9
-
10
- export async function printToken() {
11
- await this.log(
12
- "you will need to pass a token to the dashboard. We will copy it to your clipboard!"
13
- );
14
- const token = await getToken();
15
- await this.log("");
16
- await this.log(token);
17
- await this.log("");
18
- await clipboardy.write(token);
19
- await this.log("");
20
- }