@catladder/cli 0.0.0-node16-ddfae617 → 0.0.0-refactor-env-context-9e652b63

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 (229) hide show
  1. package/bin/catenv +1 -1
  2. package/bin/catenv-dev +3 -0
  3. package/bin/catladder +1 -1
  4. package/bin/catladder-dev +3 -0
  5. package/dist/apps/catenv/catenv.d.ts +4 -1
  6. package/dist/apps/catenv/catenv.js +28 -20
  7. package/dist/apps/catenv/catenv.js.map +1 -1
  8. package/dist/apps/cli/commands/general/index.d.ts +1 -1
  9. package/dist/apps/cli/commands/general/portForward.d.ts +1 -1
  10. package/dist/apps/cli/commands/mongodb/index.d.ts +1 -1
  11. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +1 -1
  12. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +2 -1
  13. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -1
  14. package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +1 -1
  15. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +1 -1
  16. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +25 -9
  17. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -1
  18. package/dist/apps/cli/commands/mongodb/utils/index.js +16 -4
  19. package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -1
  20. package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +1 -1
  21. package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +2 -1
  22. package/dist/apps/cli/commands/project/commandConfigSecrets.js +29 -51
  23. package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
  24. package/dist/apps/cli/commands/project/commandCopyDB.d.ts +1 -1
  25. package/dist/apps/cli/commands/project/commandCopyDB.js +1 -23
  26. package/dist/apps/cli/commands/project/commandCopyDB.js.map +1 -1
  27. package/dist/apps/cli/commands/project/commandDeletePods.d.ts +1 -1
  28. package/dist/apps/cli/commands/project/commandDeletePods.js +2 -1
  29. package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -1
  30. package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +1 -1
  31. package/dist/apps/cli/commands/project/commandEnvVars.d.ts +1 -1
  32. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +1 -1
  33. package/dist/apps/cli/commands/project/commandGetShell.d.ts +1 -1
  34. package/dist/apps/cli/commands/project/commandGetShell.js +2 -1
  35. package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -1
  36. package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +1 -1
  37. package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -1
  38. package/dist/apps/cli/commands/project/commandInitProject.old.d.ts +1 -1
  39. package/dist/apps/cli/commands/project/commandListPods.d.ts +1 -1
  40. package/dist/apps/cli/commands/project/commandListPods.js +2 -2
  41. package/dist/apps/cli/commands/project/commandListPods.js.map +1 -1
  42. package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +1 -1
  43. package/dist/apps/cli/commands/project/commandMigrateHelm3.js +1 -2
  44. package/dist/apps/cli/commands/project/commandMigrateHelm3.js.map +1 -1
  45. package/dist/apps/cli/commands/project/commandNamespace.d.ts +1 -1
  46. package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +1 -1
  47. package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +1 -1
  48. package/dist/apps/cli/commands/project/commandOpenDashboard.js +19 -20
  49. package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -1
  50. package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +1 -1
  51. package/dist/apps/cli/commands/project/commandOpenGit.d.ts +1 -1
  52. package/dist/apps/cli/commands/project/commandOpenGit.js +2 -7
  53. package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -1
  54. package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +1 -1
  55. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +1 -1
  56. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +2 -1
  57. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -1
  58. package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +1 -1
  59. package/dist/apps/cli/commands/project/commandOpenLogs.js +7 -20
  60. package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -1
  61. package/dist/apps/cli/commands/project/commandPauseProject.d.ts +1 -1
  62. package/dist/apps/cli/commands/project/commandPortForward.d.ts +1 -1
  63. package/dist/apps/cli/commands/project/commandPortForward.js +2 -1
  64. package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -1
  65. package/dist/apps/cli/commands/project/commandSecretsClearBackups.d.ts +5 -0
  66. package/dist/apps/cli/commands/project/commandSecretsClearBackups.js +90 -0
  67. package/dist/apps/cli/commands/project/commandSecretsClearBackups.js.map +1 -0
  68. package/dist/apps/cli/commands/project/commandSetup.d.ts +1 -1
  69. package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +1 -1
  70. package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -1
  71. package/dist/apps/cli/commands/project/index.d.ts +1 -1
  72. package/dist/apps/cli/commands/project/index.js +2 -0
  73. package/dist/apps/cli/commands/project/index.js.map +1 -1
  74. package/dist/apps/cli/commands/project/setup/index.d.ts +1 -1
  75. package/dist/apps/cli/commands/project/setup/setupAccessTokens.d.ts +1 -1
  76. package/dist/apps/cli/commands/project/setup/setupAccessTokens.js +5 -4
  77. package/dist/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -1
  78. package/dist/apps/cli/commands/project/setup/setupCloudRun.d.ts +3 -0
  79. package/dist/apps/cli/commands/project/setup/setupCloudRun.js +101 -0
  80. package/dist/apps/cli/commands/project/setup/setupCloudRun.js.map +1 -0
  81. package/dist/apps/cli/commands/project/setup/setupCloudSQL.d.ts +3 -0
  82. package/dist/apps/cli/commands/project/setup/setupCloudSQL.js +56 -0
  83. package/dist/apps/cli/commands/project/setup/setupCloudSQL.js.map +1 -0
  84. package/dist/apps/cli/commands/project/setup/setupContext.d.ts +2 -2
  85. package/dist/apps/cli/commands/project/setup/setupContext.js +17 -3
  86. package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -1
  87. package/dist/apps/cli/commands/project/setup/setupKubernetes.d.ts +2 -2
  88. package/dist/apps/cli/commands/project/setup/setupKubernetes.js +12 -16
  89. package/dist/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
  90. package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +1 -1
  91. package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -1
  92. package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +1 -1
  93. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +1 -1
  94. package/dist/apps/cli/config/writeConfig.d.ts +2 -2
  95. package/dist/apps/cli/verify/index.d.ts +1 -1
  96. package/dist/apps/cli/verify/migration/fromv2.d.ts +1 -1
  97. package/dist/apps/cli/verify/migration/fromv2.js.map +1 -1
  98. package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +3 -3
  99. package/dist/apps/cli/verify/migration/migrateSecrets.js +4 -3
  100. package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -1
  101. package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +1 -1
  102. package/dist/bundles/catenv/index.js +44322 -0
  103. package/dist/bundles/catenv/xdg-open +1066 -0
  104. package/dist/bundles/cli/clipboard_i686.exe +0 -0
  105. package/dist/bundles/cli/clipboard_x86_64.exe +0 -0
  106. package/dist/bundles/cli/exec-child.js +39 -0
  107. package/dist/bundles/cli/index.js +357696 -0
  108. package/dist/bundles/cli/xdg-open +1066 -0
  109. package/dist/bundles/cli/xsel +0 -0
  110. package/dist/catenv.js +3 -3
  111. package/dist/catenv.js.map +1 -1
  112. package/dist/cli.js +0 -7
  113. package/dist/cli.js.map +1 -1
  114. package/dist/config/constants.d.ts +0 -1
  115. package/dist/config/constants.js +1 -2
  116. package/dist/config/constants.js.map +1 -1
  117. package/dist/config/getProjectConfig.d.ts +3 -6
  118. package/dist/config/getProjectConfig.js +12 -7
  119. package/dist/config/getProjectConfig.js.map +1 -1
  120. package/dist/config/parseChoice.d.ts +4 -0
  121. package/dist/config/parseChoice.js +9 -0
  122. package/dist/config/parseChoice.js.map +1 -0
  123. package/dist/gcloud/artifactsRegistry.d.ts +5 -0
  124. package/dist/gcloud/artifactsRegistry.js +59 -0
  125. package/dist/gcloud/artifactsRegistry.js.map +1 -0
  126. package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.d.ts +2 -0
  127. package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js +67 -0
  128. package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js.map +1 -0
  129. package/dist/gcloud/cloudRun/openCloudRunDashboards.d.ts +3 -0
  130. package/dist/gcloud/cloudRun/openCloudRunDashboards.js +62 -0
  131. package/dist/gcloud/cloudRun/openCloudRunDashboards.js.map +1 -0
  132. package/dist/gcloud/enableServices.d.ts +3 -0
  133. package/dist/gcloud/enableServices.js +63 -0
  134. package/dist/gcloud/enableServices.js.map +1 -0
  135. package/dist/gcloud/openDashboard.d.ts +2 -0
  136. package/dist/{apps/cli/commands/shared/index.js → gcloud/openDashboard.js} +23 -27
  137. package/dist/gcloud/openDashboard.js.map +1 -0
  138. package/dist/gcloud/serviceAccounts.d.ts +12 -0
  139. package/dist/gcloud/serviceAccounts.js +144 -0
  140. package/dist/gcloud/serviceAccounts.js.map +1 -0
  141. package/dist/kubernetes/index.d.ts +3 -0
  142. package/dist/kubernetes/index.js +88 -0
  143. package/dist/kubernetes/index.js.map +1 -0
  144. package/dist/kubernetes/openKubernetesDashboards.d.ts +4 -0
  145. package/dist/kubernetes/openKubernetesDashboards.js +94 -0
  146. package/dist/kubernetes/openKubernetesDashboards.js.map +1 -0
  147. package/dist/tsconfig.tsbuildinfo +1 -1
  148. package/dist/utils/cluster.js +3 -8
  149. package/dist/utils/cluster.js.map +1 -1
  150. package/dist/utils/gitlab.d.ts +5 -3
  151. package/dist/utils/gitlab.js +165 -46
  152. package/dist/utils/gitlab.js.map +1 -1
  153. package/dist/utils/passwordstore/index.d.ts +0 -1
  154. package/dist/utils/passwordstore/index.js +1 -64
  155. package/dist/utils/passwordstore/index.js.map +1 -1
  156. package/dist/utils/projects/index.d.ts +0 -3
  157. package/dist/utils/projects/index.js +3 -53
  158. package/dist/utils/projects/index.js.map +1 -1
  159. package/package.json +24 -22
  160. package/scripts/bundle +4 -0
  161. package/src/apps/catenv/catenv.ts +15 -8
  162. package/src/apps/cli/commands/general/index.ts +1 -1
  163. package/src/apps/cli/commands/general/portForward.ts +1 -1
  164. package/src/apps/cli/commands/mongodb/index.ts +1 -1
  165. package/src/apps/cli/commands/mongodb/projectMongoDestroyMember.ts +3 -5
  166. package/src/apps/cli/commands/mongodb/projectMongoGetShell.ts +1 -1
  167. package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +16 -1
  168. package/src/apps/cli/commands/mongodb/utils/index.ts +19 -11
  169. package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +1 -1
  170. package/src/apps/cli/commands/project/commandConfigSecrets.ts +12 -31
  171. package/src/apps/cli/commands/project/commandCopyDB.ts +3 -2
  172. package/src/apps/cli/commands/project/commandDeletePods.ts +3 -5
  173. package/src/apps/cli/commands/project/commandDeleteProject.ts +1 -1
  174. package/src/apps/cli/commands/project/commandEnvVars.ts +1 -1
  175. package/src/apps/cli/commands/project/commandGetMyTotalWorktime.ts +1 -1
  176. package/src/apps/cli/commands/project/commandGetShell.ts +3 -5
  177. package/src/apps/cli/commands/project/commandGitlabCi.ts +2 -1
  178. package/src/apps/cli/commands/project/commandInitProject.old.ts +1 -1
  179. package/src/apps/cli/commands/project/commandListPods.ts +2 -2
  180. package/src/apps/cli/commands/project/commandMigrateHelm3.ts +4 -3
  181. package/src/apps/cli/commands/project/commandNamespace.ts +1 -1
  182. package/src/apps/cli/commands/project/commandOpenCostDashboard.ts +1 -1
  183. package/src/apps/cli/commands/project/commandOpenDashboard.ts +12 -32
  184. package/src/apps/cli/commands/project/commandOpenEnv.ts +1 -1
  185. package/src/apps/cli/commands/project/commandOpenGit.ts +3 -3
  186. package/src/apps/cli/commands/project/commandOpenGrafana.ts +1 -1
  187. package/src/apps/cli/commands/project/commandOpenGrafanaPod.ts +3 -5
  188. package/src/apps/cli/commands/project/commandOpenLogs.ts +4 -35
  189. package/src/apps/cli/commands/project/commandPauseProject.ts +1 -1
  190. package/src/apps/cli/commands/project/commandPortForward.ts +3 -5
  191. package/src/apps/cli/commands/project/commandSecretsClearBackups.ts +27 -0
  192. package/src/apps/cli/commands/project/commandSetup.ts +1 -1
  193. package/src/apps/cli/commands/project/commandTriggerCronjob.ts +3 -2
  194. package/src/apps/cli/commands/project/index.ts +3 -1
  195. package/src/apps/cli/commands/project/setup/index.ts +1 -1
  196. package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +23 -11
  197. package/src/apps/cli/commands/project/setup/setupCloudRun.ts +74 -0
  198. package/src/apps/cli/commands/project/setup/setupCloudSQL.ts +19 -0
  199. package/src/apps/cli/commands/project/setup/setupContext.ts +12 -2
  200. package/src/apps/cli/commands/project/setup/setupKubernetes.ts +34 -27
  201. package/src/apps/cli/commands/project/utils/ensureNamespace.ts +4 -2
  202. package/src/apps/cli/commands/project/utils/showProjectBanner.ts +1 -1
  203. package/src/apps/cli/commands/theStuffThatReallyMatters/index.ts +1 -1
  204. package/src/apps/cli/config/writeConfig.ts +2 -2
  205. package/src/apps/cli/verify/index.ts +1 -1
  206. package/src/apps/cli/verify/migration/fromv2.ts +4 -7
  207. package/src/apps/cli/verify/migration/migrateSecrets.ts +9 -4
  208. package/src/apps/cli/verify/migration/oldGitlabCi.ts +1 -1
  209. package/src/catenv.ts +6 -3
  210. package/src/cli.ts +1 -7
  211. package/src/config/constants.ts +0 -2
  212. package/src/config/getProjectConfig.ts +5 -8
  213. package/src/config/parseChoice.ts +4 -0
  214. package/src/gcloud/artifactsRegistry.ts +16 -0
  215. package/src/gcloud/cloudRun/getCloudRunDomainSuffix.ts +35 -0
  216. package/src/gcloud/cloudRun/openCloudRunDashboards.ts +22 -0
  217. package/src/gcloud/enableServices.ts +14 -0
  218. package/src/gcloud/openDashboard.ts +19 -0
  219. package/src/gcloud/serviceAccounts.ts +101 -0
  220. package/src/kubernetes/index.ts +27 -0
  221. package/src/kubernetes/openKubernetesDashboards.ts +52 -0
  222. package/src/types/child-process-promise.d.ts +36 -1
  223. package/src/utils/cluster.ts +3 -3
  224. package/src/utils/gitlab.ts +137 -26
  225. package/src/utils/passwordstore/index.ts +2 -30
  226. package/src/utils/projects/index.ts +3 -24
  227. package/dist/apps/cli/commands/shared/index.d.ts +0 -3
  228. package/dist/apps/cli/commands/shared/index.js.map +0 -1
  229. package/src/apps/cli/commands/shared/index.ts +0 -36
package/package.json CHANGED
@@ -8,7 +8,9 @@
8
8
  "lint": "eslint \"src/**/*.ts\"",
9
9
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
10
10
  "test": "yarn run lint",
11
- "build": "yarn tsc",
11
+ "build": "yarn build:compile && yarn build:bundle",
12
+ "build:bundle": "./scripts/bundle",
13
+ "build:compile": "yarn tsc",
12
14
  "build:watch": "yarn tsc -w"
13
15
  },
14
16
  "bin": {
@@ -16,34 +18,19 @@
16
18
  "catladder": "./bin/catladder"
17
19
  },
18
20
  "dependencies": {
19
- "@catladder/pipeline": "0.0.0-node16-ddfae617",
20
- "@kubernetes/client-node": "^0.16.2",
21
- "child-process-promise": "^2.2.1",
22
- "command-exists-promise": "^2.0.2",
23
- "common-tags": "^1.8.0",
24
- "dayjs": "^1.10.4",
25
- "fs-extra": "^7.0.1",
26
- "gitlab": "^4.4.1",
27
- "js-yaml": "^4.1.0",
28
- "lodash": "^4.17.21",
29
- "memoizee": "^0.4.14",
30
- "node-fetch": "^2.3.0",
31
- "open": "^8.4.0",
32
- "prettier": "^2.5.1",
33
- "tmp-promise": "^2.0.2",
34
- "update-notifier": "^2.5.0",
35
- "vorpal": "^1.12.0",
36
- "zx": "^4.3.0"
21
+ "ts-node": "^10.9.1"
37
22
  },
38
23
  "engines": {
39
24
  "node": ">=12.0.0"
40
25
  },
41
26
  "devDependencies": {
27
+ "@catladder/pipeline": "0.0.0-refactor-env-context-9e652b63",
28
+ "@kubernetes/client-node": "^0.16.2",
42
29
  "@tsconfig/node14": "^1.0.1",
43
30
  "@types/common-tags": "^1.8.0",
44
31
  "@types/fs-extra": "^5.0.4",
45
32
  "@types/js-yaml": "^4.0.5",
46
- "@types/lodash": "^4.14.119",
33
+ "@types/lodash": "^4.14.185",
47
34
  "@types/memoizee": "^0.4.2",
48
35
  "@types/node-fetch": "^2.1.4",
49
36
  "@types/request": "^2.48.1",
@@ -52,9 +39,24 @@
52
39
  "@types/vorpal": "^1.12.0",
53
40
  "@types/websocket": "^0.0.40",
54
41
  "@types/yargs": "^13.0.0",
42
+ "child-process-promise": "^2.2.1",
43
+ "clipboardy": "^2.0.0",
44
+ "command-exists-promise": "^2.0.2",
45
+ "common-tags": "^1.8.0",
46
+ "dayjs": "^1.10.4",
55
47
  "eslint": "^8.7.0",
56
- "typescript": "^4.5.4"
48
+ "fs-extra": "^7.0.1",
49
+ "gitlab": "^4.4.1",
50
+ "js-yaml": "^4.1.0",
51
+ "lodash": "^4.17.21",
52
+ "memoizee": "^0.4.14",
53
+ "node-fetch": "^2.3.0",
54
+ "open": "^8.4.0",
55
+ "prettier": "^2.5.1",
56
+ "tmp-promise": "^2.0.2",
57
+ "typescript": "^4.5.4",
58
+ "vorpal": "^1.12.0"
57
59
  },
58
- "version": "0.0.0-node16-ddfae617",
60
+ "version": "0.0.0-refactor-env-context-9e652b63",
59
61
  "stableVersion": "0.0.0"
60
62
  }
package/scripts/bundle ADDED
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+ ncc build dist/catenv.js -o dist/bundles/catenv -e 'ts-node' $( ((SHOULD_MINIFY == 1)) && printf %s '-m')
3
+
4
+ ncc build dist/cli.js -o dist/bundles/cli -e 'ts-node' $( ((SHOULD_MINIFY == 1)) && printf %s '-m')
@@ -1,4 +1,4 @@
1
- import { Config, ComponentConfig } from "@catladder/pipeline";
1
+ import type { Config, ComponentConfig } from "@catladder/pipeline";
2
2
  import { getEnvVars, getProjectConfig } from "../../config/getProjectConfig";
3
3
  import { getGitRoot } from "../../utils/projects";
4
4
  import { join } from "path";
@@ -14,21 +14,29 @@ const getCurrentComponentName = async (
14
14
 
15
15
  const sanitizeEnvVarName = (name: string) => name.replace(/[\s\-.]+/g, "_");
16
16
 
17
- const getAllVariablesToPrint = async (config: Config) => {
17
+ const getAllVariablesToPrint = async (
18
+ config: Config,
19
+ choice?: {
20
+ env?: string;
21
+ componentName?: string;
22
+ }
23
+ ) => {
24
+ const env = choice?.env ?? "local";
18
25
  const { components } = config;
19
26
 
20
- const currentComponent = await getCurrentComponentName(components);
27
+ const currentComponent =
28
+ choice?.componentName ?? (await getCurrentComponentName(components));
21
29
 
22
30
  let variables = {};
23
31
  if (currentComponent) {
24
- variables = await getEnvVars(null, "local", currentComponent);
32
+ variables = await getEnvVars(null, env, currentComponent);
25
33
  } else {
26
34
  // when in a monorep and not in a subapp, merge all env vars.
27
35
  // this is not 100% correct, but better than not exporting any vars at all
28
36
  // so we also add prefixed variants
29
37
  variables = await Object.keys(components).reduce(
30
38
  async (acc, componentName) => {
31
- const subappvars = await getEnvVars(null, "local", componentName);
39
+ const subappvars = await getEnvVars(null, env, componentName);
32
40
  return {
33
41
  ...(await acc),
34
42
  ...subappvars,
@@ -46,13 +54,12 @@ const getAllVariablesToPrint = async (config: Config) => {
46
54
  }
47
55
  return variables;
48
56
  };
49
- export default async () => {
57
+ export default async (choice?: { env?: string; componentName?: string }) => {
50
58
  const config = await getProjectConfig();
51
59
  if (!config) {
52
60
  return;
53
61
  }
54
-
55
- const variables = await getAllVariablesToPrint(config);
62
+ const variables = await getAllVariablesToPrint(config, choice);
56
63
 
57
64
  console.log(
58
65
  Object.entries(variables)
@@ -1,5 +1,5 @@
1
1
  import memoizee from "memoizee";
2
- import Vorpal from "vorpal";
2
+ import type Vorpal from "vorpal";
3
3
  import { getk8sApi } from "../../../../k8sApi";
4
4
  import { getCurrentContext } from "../../../../utils/cluster";
5
5
  import { logError } from "../../../../utils/log";
@@ -1,4 +1,4 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import { logError } from "../../../../utils/log";
3
3
 
4
4
  import { startPortForward } from "../../../../utils/portForward";
@@ -1,4 +1,4 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import projectMongoDestroyMember from "./projectMongoDestroyMember";
3
3
  import projectMongoGetShell from "./projectMongoGetShell";
4
4
  import projectMongoPortForward from "./projectMongoPortForward";
@@ -1,10 +1,8 @@
1
1
  import { exec } from "child-process-promise";
2
- import Vorpal from "vorpal";
2
+ import type Vorpal from "vorpal";
3
+ import { getProjectPvcs } from "../../../../kubernetes";
3
4
  import { logError } from "../../../../utils/log";
4
- import {
5
- getProjectNamespace,
6
- getProjectPvcs,
7
- } from "../../../../utils/projects";
5
+ import { getProjectNamespace } from "../../../../utils/projects";
8
6
  import { envAndComponents } from "../project/utils/autocompletions";
9
7
  import ensureCluster from "../project/utils/ensureCluster";
10
8
  import { getMongoDbPodsWithReplInfo } from "./utils";
@@ -1,4 +1,4 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import { logError } from "../../../../utils/log";
3
3
  import { getProjectNamespace } from "../../../../utils/projects";
4
4
  import { envAndComponents } from "../project/utils/autocompletions";
@@ -1,10 +1,12 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
+ import { getEnvVars, parseChoice } from "../../../../config/getProjectConfig";
2
3
  import { logError } from "../../../../utils/log";
3
4
  import { startPortForward } from "../../../../utils/portForward";
4
5
  import { getProjectNamespace } from "../../../../utils/projects";
5
6
  import { envAndComponents } from "../project/utils/autocompletions";
6
7
  import ensureCluster from "../project/utils/ensureCluster";
7
8
  import { getProjectMongodbAllPodsSortedWithLabel } from "./utils";
9
+ import clipboard from "clipboardy";
8
10
 
9
11
  export default async (vorpal: Vorpal) =>
10
12
  vorpal
@@ -43,5 +45,18 @@ export default async (vorpal: Vorpal) =>
43
45
  default: "30000",
44
46
  message: "Local port: ",
45
47
  });
48
+ const { env, componentName } = parseChoice(envComponent);
49
+ const envVars = await getEnvVars(this, env, componentName);
50
+ const MONGODB_ROOT_PASSWORD = envVars?.MONGODB_ROOT_PASSWORD;
51
+ const connectionUrl = `mongodb://root:${MONGODB_ROOT_PASSWORD}@localhost:${localPort}`;
52
+ clipboard.writeSync(connectionUrl);
53
+ this.log("");
54
+ this.log("username: root");
55
+ this.log(`password: ${MONGODB_ROOT_PASSWORD}`);
56
+ this.log(`connection string: ${connectionUrl}`);
57
+ this.log("");
58
+ this.log("👆 connection string has been copied to your clipboard!");
59
+ this.log("");
60
+
46
61
  return startPortForward(podName, localPort, 27017, namespace);
47
62
  });
@@ -1,11 +1,14 @@
1
1
  import { exec, spawn } from "child-process-promise";
2
- import {
3
- getProjectNamespace,
4
- getProjectPodNames,
5
- } from "../../../../../utils/projects";
2
+ import { getProjectPodNames } from "../../../../../kubernetes";
3
+ import { getProjectNamespace } from "../../../../../utils/projects";
6
4
 
7
5
  const filterMongoDbs = (podNames: string[]) =>
8
- podNames.filter((name) => name.includes("mongodb-replicaset"));
6
+ podNames.filter(
7
+ (name) =>
8
+ name.includes("mongodb") &&
9
+ !name.includes("mongodb-backup") &&
10
+ !name.includes("arbiter")
11
+ );
9
12
 
10
13
  export const getProjectMongodbAllPods = async (envComponent: string) =>
11
14
  filterMongoDbs(await getProjectPodNames(envComponent));
@@ -43,13 +46,18 @@ export const executeMongodbCommand = async (
43
46
  };
44
47
 
45
48
  export const podIsMaster = async (namespace: string, podName: string) => {
46
- const result = await executeMongodbCommand(
47
- namespace,
48
- podName,
49
- "db.isMaster()"
50
- );
49
+ try {
50
+ const result = await executeMongodbCommand(
51
+ namespace,
52
+ podName,
53
+ "db.isMaster()"
54
+ );
51
55
 
52
- return result.ismaster;
56
+ return result.ismaster;
57
+ } catch (e) {
58
+ // maybe shutting down ?
59
+ return null;
60
+ }
53
61
  };
54
62
 
55
63
  const spaces = (n: number) => " ".repeat(n);
@@ -2,7 +2,7 @@ import { isOfDeployType } from "@catladder/pipeline";
2
2
  import { spawn } from "child-process-promise";
3
3
  import { writeFile } from "fs-extra";
4
4
  import { withFile } from "tmp-promise";
5
- import Vorpal from "vorpal";
5
+ import type Vorpal from "vorpal";
6
6
  import {
7
7
  getEnvVars,
8
8
  getGitlabVar,
@@ -1,19 +1,18 @@
1
1
  /* eslint-disable no-constant-condition */
2
+ import { getSecretVarName } from "@catladder/pipeline";
2
3
  import { stripIndents } from "common-tags";
3
4
  import { difference } from "lodash";
4
- import Vorpal, { CommandInstance } from "vorpal";
5
- import { GOOGLE_CLOUD_SQL_PASS_PATH } from "../../../../config/constants";
5
+ import type { CommandInstance } from "vorpal";
6
+ import type Vorpal from "vorpal";
6
7
  import {
7
8
  getAllComponentsWithAllEnvsHierarchical,
8
9
  getEnvironment,
9
10
  getEnvVars,
10
- getPipelineContextByChoice,
11
11
  getProjectComponents,
12
12
  parseChoice,
13
13
  } from "../../../../config/getProjectConfig";
14
14
  import { editAsFile } from "../../../../utils/editAsFile";
15
15
  import { upsertAllVariables } from "../../../../utils/gitlab";
16
- import { hasBitwarden, readPass } from "../../../../utils/passwordstore";
17
16
  import { delay } from "../../../../utils/promise";
18
17
  import { allEnvsAndAllComponents } from "./utils/autocompletions";
19
18
 
@@ -45,6 +44,7 @@ const resolveJson = (v: Vars) =>
45
44
  ];
46
45
  })
47
46
  );
47
+
48
48
  const getEnvVarsToEdit = async (
49
49
  instance: CommandInstance,
50
50
  env: string,
@@ -54,7 +54,13 @@ const getEnvVarsToEdit = async (
54
54
 
55
55
  const allEnvVars = await getEnvVars(instance, env, componentName);
56
56
  return Object.fromEntries(
57
- secretEnvVarKeys.map((key) => [key, allEnvVars[key]])
57
+ secretEnvVarKeys.map((key) => {
58
+ const value = allEnvVars[key];
59
+ // due to some quirky way to resolve these variables, unset variables have the $CL_ prefix, so we remove thouse here
60
+ const variableIsNotSet =
61
+ value === "$" + getSecretVarName(env, componentName, key);
62
+ return [key, variableIsNotSet ? "🚨 FILL ME" : value];
63
+ })
58
64
  );
59
65
  };
60
66
  const doItFor = async (
@@ -148,32 +154,7 @@ const doItFor = async (
148
154
  env,
149
155
  componentName
150
156
  );
151
-
152
- if (hasBitwarden()) {
153
- // add cloud sql secret if needed.
154
- // TODO: this is legacy, in the future we want to have one service account per app
155
- try {
156
- const context = await getPipelineContextByChoice(env, componentName);
157
- if (
158
- context.componentConfig.deploy &&
159
- context.componentConfig.deploy.type === "kubernetes" &&
160
- context.componentConfig.deploy.values?.cloudsql?.enabled
161
- ) {
162
- await upsertAllVariables(
163
- instance,
164
- {
165
- cloudsqlProxyCredentials: await readPass(
166
- GOOGLE_CLOUD_SQL_PASS_PATH
167
- ),
168
- },
169
- env,
170
- componentName
171
- );
172
- }
173
- } catch (e) {
174
- // ignore atm
175
- }
176
- }
157
+ instance.log("");
177
158
  instance.log("✅ " + env + ":" + componentName);
178
159
  }
179
160
  }
@@ -1,6 +1,5 @@
1
1
  import { spawn } from "child-process-promise";
2
- import Vorpal from "vorpal";
3
- import { GOOGLE_CLOUD_SQL_PASS_PATH } from "../../../../config/constants";
2
+ import type Vorpal from "vorpal";
4
3
  import {
5
4
  getEnvVars,
6
5
  getProjectConfig,
@@ -32,6 +31,7 @@ export default async (vorpal: Vorpal) =>
32
31
  }
33
32
 
34
33
  // TODO: reimpleent with new config
34
+ /*
35
35
  throw new Error("needs reimplementation with new config");
36
36
  const GOOGLE_CLOUD_SQL_REGION = "europe-west6"; // currently hardcoded
37
37
  const { POSTGRESQL_PASSWORD } = await getEnvVars(
@@ -88,4 +88,5 @@ export default async (vorpal: Vorpal) =>
88
88
  `;
89
89
 
90
90
  await spawn(copyDBScript, [], { shell: "bash", stdio: "inherit" });
91
+ */
91
92
  });
@@ -1,11 +1,9 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import { getk8sApi } from "../../../../k8sApi";
3
+ import { getProjectPodNames } from "../../../../kubernetes";
3
4
 
4
5
  import { logError } from "../../../../utils/log";
5
- import {
6
- getProjectNamespace,
7
- getProjectPodNames,
8
- } from "../../../../utils/projects";
6
+ import { getProjectNamespace } from "../../../../utils/projects";
9
7
  import { envAndComponents } from "./utils/autocompletions";
10
8
  import ensureCluster from "./utils/ensureCluster";
11
9
 
@@ -1,4 +1,4 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import { exec } from "child-process-promise";
3
3
  import { getProjectNamespace } from "../../../../utils/projects";
4
4
  import { envAndComponents } from "./utils/autocompletions";
@@ -1,4 +1,4 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import { getEnvVars, parseChoice } from "../../../../config/getProjectConfig";
3
3
  import { envAndComponents } from "./utils/autocompletions";
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { spawn } from "child-process-promise";
2
- import Vorpal from "vorpal";
2
+ import type Vorpal from "vorpal";
3
3
 
4
4
  export default async (vorpal: Vorpal) =>
5
5
  vorpal
@@ -1,9 +1,7 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
+ import { getProjectPodNames } from "../../../../kubernetes";
2
3
  import { logError } from "../../../../utils/log";
3
- import {
4
- getProjectNamespace,
5
- getProjectPodNames,
6
- } from "../../../../utils/projects";
4
+ import { getProjectNamespace } from "../../../../utils/projects";
7
5
  import { getShell } from "../../../../utils/shell";
8
6
 
9
7
  import { envAndComponents } from "./utils/autocompletions";
@@ -1,7 +1,8 @@
1
1
  import { exec } from "child-process-promise";
2
2
  import { last } from "lodash";
3
3
  import open from "open";
4
- import Vorpal, { CommandInstance } from "vorpal";
4
+ import type { CommandInstance } from "vorpal";
5
+ import type Vorpal from "vorpal";
5
6
  import {
6
7
  doGitlabRequest,
7
8
  getGitlabToken,
@@ -2,7 +2,7 @@ import { readFile, writeFile } from "fs-extra";
2
2
  import { dump } from "js-yaml";
3
3
  import { mapKeys, snakeCase, toUpper } from "lodash";
4
4
  import path from "path";
5
- import Vorpal from "vorpal";
5
+ import type Vorpal from "vorpal";
6
6
  import { hasGitlabCiFile } from "../../../../utils/projects";
7
7
 
8
8
  const transformVar = (key: string) => toUpper(snakeCase(key));
@@ -1,7 +1,7 @@
1
1
  import { dump } from "js-yaml";
2
2
  import { pick } from "lodash";
3
- import Vorpal from "vorpal";
4
- import { getProjectPods } from "../../../../utils/projects";
3
+ import type Vorpal from "vorpal";
4
+ import { getProjectPods } from "../../../../kubernetes";
5
5
  import { envAndComponents } from "./utils/autocompletions";
6
6
  import ensureCluster from "./utils/ensureCluster";
7
7
 
@@ -1,5 +1,5 @@
1
1
  import { exec } from "child-process-promise";
2
- import Vorpal from "vorpal";
2
+ import type Vorpal from "vorpal";
3
3
  import {
4
4
  getEnvironment,
5
5
  parseChoice,
@@ -43,8 +43,9 @@ export default async (vorpal: Vorpal) =>
43
43
  // ignore
44
44
  }
45
45
 
46
- const releaseName = (await getEnvironment(env, componentName)).envVars
47
- .RELEASE_NAME; // TODO: maybe its own function would be better
46
+ // we use the app full name as the release name
47
+ const releaseName = (await getEnvironment(env, componentName)).fullName;
48
+
48
49
  this.log(`helm release name: ${releaseName}`);
49
50
  this.log("");
50
51
  this.log("migrating now... 😼. This may take a moment");
@@ -1,4 +1,4 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import { getProjectNamespace } from "../../../../utils/projects";
3
3
  import { envAndComponents } from "./utils/autocompletions";
4
4
 
@@ -1,5 +1,5 @@
1
1
  import open from "open";
2
- import Vorpal from "vorpal";
2
+ import type Vorpal from "vorpal";
3
3
  import {
4
4
  GRAFANA_PROXY_LOCAL_PORT,
5
5
  GRAFANA_PROXY_TARGET_PORT,
@@ -1,48 +1,28 @@
1
- import Vorpal from "vorpal";
1
+ import { isOfDeployType } from "@catladder/pipeline";
2
+ import type Vorpal from "vorpal";
2
3
  import {
3
4
  getPipelineContextByChoice,
4
5
  parseChoice,
5
6
  } from "../../../../config/getProjectConfig";
6
- import { getGoogleAuthUserNumber } from "../../utils/getGoogleAuthUserNumber";
7
- import { openGoogleCloudKubernetesDashboard } from "../shared";
7
+ import { openGoogleCloudRunDashboard } from "../../../../gcloud/cloudRun/openCloudRunDashboards";
8
+ import { openGoogleCloudKubernetesDashboard } from "../../../../kubernetes/openKubernetesDashboards";
9
+
8
10
  import { envAndComponents } from "./utils/autocompletions";
11
+
9
12
  export default async (vorpal: Vorpal) =>
10
13
  vorpal
11
14
  .command(
12
15
  "project-open-dashboard <envComponent>",
13
- "open kubernetes dashboard on google"
16
+ "open an apps dashboard (kubernetes or cloudrun)"
14
17
  )
15
18
  .autocomplete(await envAndComponents())
16
19
  .action(async function ({ envComponent }) {
17
20
  const { env, componentName } = parseChoice(envComponent);
18
- const { componentConfig, environment } = await getPipelineContextByChoice(
19
- env,
20
- componentName
21
- );
22
-
23
- if (
24
- !componentConfig.deploy ||
25
- componentConfig.deploy.type !== "kubernetes"
26
- ) {
27
- throw new Error(
28
- "only kubernetes deployments are supported at the moment"
29
- );
21
+ const context = await getPipelineContextByChoice(env, componentName);
22
+ if (isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
23
+ await openGoogleCloudKubernetesDashboard(this, context);
30
24
  }
31
-
32
- if (
33
- !componentConfig.deploy.cluster ||
34
- componentConfig.deploy.cluster.type !== "gcloud"
35
- ) {
36
- throw new Error("no gcloud custer configured");
25
+ if (isOfDeployType(context.componentConfig.deploy, "google-cloudrun")) {
26
+ await openGoogleCloudRunDashboard(this, context);
37
27
  }
38
- // currently only supports kubernetes
39
- const namespace = environment.envVars.KUBE_NAMESPACE;
40
-
41
- const authGoogleNumber = await getGoogleAuthUserNumber.call(this, vorpal);
42
-
43
- openGoogleCloudKubernetesDashboard(
44
- componentConfig.deploy.cluster,
45
- namespace,
46
- authGoogleNumber
47
- );
48
28
  });
@@ -1,5 +1,5 @@
1
1
  import open from "open";
2
- import Vorpal from "vorpal";
2
+ import type Vorpal from "vorpal";
3
3
  import {
4
4
  getEnvironment,
5
5
  parseChoice,
@@ -1,5 +1,5 @@
1
- import Vorpal from "vorpal";
2
- import { $ } from "zx";
1
+ import type Vorpal from "vorpal";
2
+ import { exec } from "child-process-promise";
3
3
 
4
4
  export default async (vorpal: Vorpal) =>
5
5
  vorpal
@@ -8,5 +8,5 @@ export default async (vorpal: Vorpal) =>
8
8
  "open the repo on gitlab / github in your browser"
9
9
  )
10
10
  .action(async () => {
11
- await $`npx git-open`;
11
+ await exec("npx git-open");
12
12
  });
@@ -1,6 +1,6 @@
1
1
  import open from "open";
2
2
  import { startPortForward } from "../../../../utils/portForward";
3
- import Vorpal from "vorpal";
3
+ import type Vorpal from "vorpal";
4
4
  import {
5
5
  GRAFANA_PROXY_LOCAL_PORT,
6
6
  GRAFANA_PROXY_TARGET_PORT,
@@ -1,15 +1,13 @@
1
1
  import open from "open";
2
- import Vorpal from "vorpal";
2
+ import type Vorpal from "vorpal";
3
3
  import {
4
4
  GRAFANA_PROXY_LOCAL_PORT,
5
5
  GRAFANA_PROXY_TARGET_PORT,
6
6
  } from "../../../../config/constants";
7
+ import { getProjectPodNames } from "../../../../kubernetes";
7
8
  import { logError } from "../../../../utils/log";
8
9
  import { startPortForward } from "../../../../utils/portForward";
9
- import {
10
- getProjectNamespace,
11
- getProjectPodNames,
12
- } from "../../../../utils/projects";
10
+ import { getProjectNamespace } from "../../../../utils/projects";
13
11
  import { envAndComponents } from "./utils/autocompletions";
14
12
  import ensureCluster from "./utils/ensureCluster";
15
13