@catladder/cli 0.0.0-node16-ddfae617 → 0.0.0-pipeline-variables-ed2d2565

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 (295) 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 +2 -1
  6. package/dist/apps/catenv/catenv.js +13 -82
  7. package/dist/apps/catenv/catenv.js.map +1 -1
  8. package/dist/apps/catenv/printVariables.d.ts +3 -0
  9. package/dist/apps/catenv/printVariables.js +112 -0
  10. package/dist/apps/catenv/printVariables.js.map +1 -0
  11. package/dist/apps/catenv/types.d.ts +5 -0
  12. package/dist/apps/catenv/types.js +3 -0
  13. package/dist/apps/catenv/types.js.map +1 -0
  14. package/dist/apps/catenv/utils.d.ts +12 -0
  15. package/dist/apps/catenv/utils.js +108 -0
  16. package/dist/apps/catenv/utils.js.map +1 -0
  17. package/dist/apps/catenv/writeDotEnvFiles.d.ts +3 -0
  18. package/dist/apps/catenv/writeDotEnvFiles.js +94 -0
  19. package/dist/apps/catenv/writeDotEnvFiles.js.map +1 -0
  20. package/dist/apps/catenv/writeEnvDTs.d.ts +3 -0
  21. package/dist/apps/catenv/writeEnvDTs.js +114 -0
  22. package/dist/apps/catenv/writeEnvDTs.js.map +1 -0
  23. package/dist/apps/cli/cli.js +4 -2
  24. package/dist/apps/cli/cli.js.map +1 -1
  25. package/dist/apps/cli/commands/{project/commandCopyDB.d.ts → cloudSQL/commandRestoreDb.d.ts} +1 -1
  26. package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js +180 -0
  27. package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js.map +1 -0
  28. package/dist/apps/cli/commands/cloudSQL/index.d.ts +3 -0
  29. package/dist/apps/cli/commands/cloudSQL/index.js +50 -0
  30. package/dist/apps/cli/commands/cloudSQL/index.js.map +1 -0
  31. package/dist/apps/cli/commands/general/index.d.ts +1 -1
  32. package/dist/apps/cli/commands/general/index.js +11 -11
  33. package/dist/apps/cli/commands/general/index.js.map +1 -1
  34. package/dist/apps/cli/commands/general/portForward.d.ts +1 -1
  35. package/dist/apps/cli/commands/general/portForward.js +3 -3
  36. package/dist/apps/cli/commands/general/portForward.js.map +1 -1
  37. package/dist/apps/cli/commands/mongodb/index.d.ts +1 -1
  38. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +1 -1
  39. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +2 -1
  40. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -1
  41. package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +1 -1
  42. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +1 -1
  43. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +27 -11
  44. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -1
  45. package/dist/apps/cli/commands/mongodb/utils/index.js +16 -4
  46. package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -1
  47. package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +1 -1
  48. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +89 -62
  49. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
  50. package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +2 -1
  51. package/dist/apps/cli/commands/project/commandConfigSecrets.js +71 -57
  52. package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
  53. package/dist/apps/cli/commands/project/commandDeletePods.d.ts +1 -1
  54. package/dist/apps/cli/commands/project/commandDeletePods.js +2 -1
  55. package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -1
  56. package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +1 -1
  57. package/dist/apps/cli/commands/project/commandEnvVars.d.ts +1 -1
  58. package/dist/apps/cli/commands/project/commandEnvVars.js +1 -1
  59. package/dist/apps/cli/commands/project/commandEnvVars.js.map +1 -1
  60. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +1 -1
  61. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js +1 -1
  62. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js.map +1 -1
  63. package/dist/apps/cli/commands/project/commandGetShell.d.ts +1 -1
  64. package/dist/apps/cli/commands/project/commandGetShell.js +10 -6
  65. package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -1
  66. package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +1 -1
  67. package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -1
  68. package/dist/apps/cli/commands/project/commandInitProject.old.d.ts +1 -1
  69. package/dist/apps/cli/commands/project/commandListPods.d.ts +1 -1
  70. package/dist/apps/cli/commands/project/commandListPods.js +2 -2
  71. package/dist/apps/cli/commands/project/commandListPods.js.map +1 -1
  72. package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +1 -1
  73. package/dist/apps/cli/commands/project/commandMigrateHelm3.js +1 -2
  74. package/dist/apps/cli/commands/project/commandMigrateHelm3.js.map +1 -1
  75. package/dist/apps/cli/commands/project/commandNamespace.d.ts +1 -1
  76. package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +1 -1
  77. package/dist/apps/cli/commands/project/commandOpenCostDashboard.js +2 -2
  78. package/dist/apps/cli/commands/project/commandOpenCostDashboard.js.map +1 -1
  79. package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +1 -1
  80. package/dist/apps/cli/commands/project/commandOpenDashboard.js +19 -20
  81. package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -1
  82. package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +1 -1
  83. package/dist/apps/cli/commands/project/commandOpenGit.d.ts +1 -1
  84. package/dist/apps/cli/commands/project/commandOpenGit.js +2 -7
  85. package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -1
  86. package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +1 -1
  87. package/dist/apps/cli/commands/project/commandOpenGrafana.js +2 -2
  88. package/dist/apps/cli/commands/project/commandOpenGrafana.js.map +1 -1
  89. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +1 -1
  90. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +4 -3
  91. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -1
  92. package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +1 -1
  93. package/dist/apps/cli/commands/project/commandOpenLogs.js +7 -20
  94. package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -1
  95. package/dist/apps/cli/commands/project/commandPauseProject.d.ts +1 -1
  96. package/dist/apps/cli/commands/project/commandPortForward.d.ts +1 -1
  97. package/dist/apps/cli/commands/project/commandPortForward.js +98 -36
  98. package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -1
  99. package/dist/apps/cli/commands/project/commandSecretsClearBackups.d.ts +5 -0
  100. package/dist/apps/cli/commands/project/commandSecretsClearBackups.js +90 -0
  101. package/dist/apps/cli/commands/project/commandSecretsClearBackups.js.map +1 -0
  102. package/dist/apps/cli/commands/project/commandSetup.d.ts +1 -1
  103. package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +1 -1
  104. package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -1
  105. package/dist/apps/cli/commands/project/index.d.ts +1 -1
  106. package/dist/apps/cli/commands/project/index.js +2 -2
  107. package/dist/apps/cli/commands/project/index.js.map +1 -1
  108. package/dist/apps/cli/commands/project/setup/index.d.ts +1 -1
  109. package/dist/apps/cli/commands/project/setup/index.js +11 -7
  110. package/dist/apps/cli/commands/project/setup/index.js.map +1 -1
  111. package/dist/apps/cli/commands/project/setup/setupAccessTokens.d.ts +1 -1
  112. package/dist/apps/cli/commands/project/setup/setupAccessTokens.js +5 -4
  113. package/dist/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -1
  114. package/dist/apps/cli/commands/project/setup/setupCloudRun.d.ts +3 -0
  115. package/dist/apps/cli/commands/project/setup/setupCloudRun.js +118 -0
  116. package/dist/apps/cli/commands/project/setup/setupCloudRun.js.map +1 -0
  117. package/dist/apps/cli/commands/project/setup/setupContext.d.ts +2 -2
  118. package/dist/apps/cli/commands/project/setup/setupContext.js +10 -3
  119. package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -1
  120. package/dist/apps/cli/commands/project/setup/setupKubernetes.d.ts +2 -2
  121. package/dist/apps/cli/commands/project/setup/setupKubernetes.js +25 -18
  122. package/dist/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
  123. package/dist/apps/cli/commands/project/setup/setupTopic.d.ts +2 -0
  124. package/dist/apps/cli/commands/project/setup/setupTopic.js +69 -0
  125. package/dist/apps/cli/commands/project/setup/setupTopic.js.map +1 -0
  126. package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +1 -1
  127. package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -1
  128. package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +1 -1
  129. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +1 -1
  130. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js +1 -1
  131. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js.map +1 -1
  132. package/dist/apps/cli/config/writeConfig.d.ts +2 -2
  133. package/dist/apps/cli/verify/index.d.ts +1 -1
  134. package/dist/apps/cli/verify/migration/fromv2.d.ts +1 -1
  135. package/dist/apps/cli/verify/migration/fromv2.js +2 -0
  136. package/dist/apps/cli/verify/migration/fromv2.js.map +1 -1
  137. package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +3 -3
  138. package/dist/apps/cli/verify/migration/migrateSecrets.js +6 -3
  139. package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -1
  140. package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +1 -1
  141. package/dist/apps/cli/verify/migration/oldGitlabCi.js +1 -1
  142. package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +1 -1
  143. package/dist/bundles/catenv/index.js +45988 -0
  144. package/dist/bundles/catenv/xdg-open +1066 -0
  145. package/dist/bundles/cli/clipboard_i686.exe +0 -0
  146. package/dist/bundles/cli/clipboard_x86_64.exe +0 -0
  147. package/dist/bundles/cli/exec-child.js +39 -0
  148. package/dist/bundles/cli/index.js +359559 -0
  149. package/dist/bundles/cli/xdg-open +1066 -0
  150. package/dist/bundles/cli/xsel +0 -0
  151. package/dist/catenv.js +3 -3
  152. package/dist/catenv.js.map +1 -1
  153. package/dist/cli.js +0 -7
  154. package/dist/cli.js.map +1 -1
  155. package/dist/config/constants.d.ts +0 -1
  156. package/dist/config/constants.js +1 -2
  157. package/dist/config/constants.js.map +1 -1
  158. package/dist/config/getProjectConfig.d.ts +10 -10
  159. package/dist/config/getProjectConfig.js +77 -23
  160. package/dist/config/getProjectConfig.js.map +1 -1
  161. package/dist/config/parseChoice.d.ts +4 -0
  162. package/dist/config/parseChoice.js +9 -0
  163. package/dist/config/parseChoice.js.map +1 -0
  164. package/dist/gcloud/artifactsRegistry.d.ts +5 -0
  165. package/dist/gcloud/artifactsRegistry.js +59 -0
  166. package/dist/gcloud/artifactsRegistry.js.map +1 -0
  167. package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.d.ts +2 -0
  168. package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js +67 -0
  169. package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js.map +1 -0
  170. package/dist/gcloud/cloudRun/openCloudRunDashboards.d.ts +3 -0
  171. package/dist/gcloud/cloudRun/openCloudRunDashboards.js +62 -0
  172. package/dist/gcloud/cloudRun/openCloudRunDashboards.js.map +1 -0
  173. package/dist/gcloud/cloudSql/startProxy.d.ts +10 -0
  174. package/dist/gcloud/cloudSql/startProxy.js +121 -0
  175. package/dist/gcloud/cloudSql/startProxy.js.map +1 -0
  176. package/dist/gcloud/enableServices.d.ts +3 -0
  177. package/dist/gcloud/enableServices.js +63 -0
  178. package/dist/gcloud/enableServices.js.map +1 -0
  179. package/dist/gcloud/openDashboard.d.ts +2 -0
  180. package/dist/{apps/cli/commands/shared/index.js → gcloud/openDashboard.js} +23 -27
  181. package/dist/gcloud/openDashboard.js.map +1 -0
  182. package/dist/gcloud/serviceAccounts.d.ts +12 -0
  183. package/dist/gcloud/serviceAccounts.js +144 -0
  184. package/dist/gcloud/serviceAccounts.js.map +1 -0
  185. package/dist/kubernetes/index.d.ts +3 -0
  186. package/dist/kubernetes/index.js +88 -0
  187. package/dist/kubernetes/index.js.map +1 -0
  188. package/dist/kubernetes/openKubernetesDashboards.d.ts +4 -0
  189. package/dist/kubernetes/openKubernetesDashboards.js +94 -0
  190. package/dist/kubernetes/openKubernetesDashboards.js.map +1 -0
  191. package/dist/kubernetes/portForward.d.ts +1 -0
  192. package/dist/kubernetes/portForward.js +55 -0
  193. package/dist/kubernetes/portForward.js.map +1 -0
  194. package/dist/tsconfig.tsbuildinfo +1 -1
  195. package/dist/utils/cluster.js +3 -8
  196. package/dist/utils/cluster.js.map +1 -1
  197. package/dist/utils/gitlab.d.ts +8 -6
  198. package/dist/utils/gitlab.js +165 -46
  199. package/dist/utils/gitlab.js.map +1 -1
  200. package/dist/utils/passwordstore/index.d.ts +0 -1
  201. package/dist/utils/passwordstore/index.js +1 -64
  202. package/dist/utils/passwordstore/index.js.map +1 -1
  203. package/dist/utils/portForwards.d.ts +12 -0
  204. package/dist/utils/{portForward.js → portForwards.js} +20 -16
  205. package/dist/utils/portForwards.js.map +1 -0
  206. package/dist/utils/projects/index.d.ts +0 -3
  207. package/dist/utils/projects/index.js +3 -53
  208. package/dist/utils/projects/index.js.map +1 -1
  209. package/package.json +24 -22
  210. package/scripts/bundle +4 -0
  211. package/src/apps/catenv/catenv.ts +10 -54
  212. package/src/apps/catenv/printVariables.ts +53 -0
  213. package/src/apps/catenv/types.ts +6 -0
  214. package/src/apps/catenv/utils.ts +49 -0
  215. package/src/apps/catenv/writeDotEnvFiles.ts +46 -0
  216. package/src/apps/catenv/writeEnvDTs.ts +71 -0
  217. package/src/apps/cli/cli.ts +3 -1
  218. package/src/apps/cli/commands/cloudSQL/commandRestoreDb.ts +154 -0
  219. package/src/apps/cli/commands/cloudSQL/index.ts +8 -0
  220. package/src/apps/cli/commands/general/index.ts +11 -8
  221. package/src/apps/cli/commands/general/portForward.ts +4 -4
  222. package/src/apps/cli/commands/mongodb/index.ts +1 -1
  223. package/src/apps/cli/commands/mongodb/projectMongoDestroyMember.ts +3 -5
  224. package/src/apps/cli/commands/mongodb/projectMongoGetShell.ts +1 -1
  225. package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +21 -3
  226. package/src/apps/cli/commands/mongodb/utils/index.ts +19 -11
  227. package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +106 -55
  228. package/src/apps/cli/commands/project/commandConfigSecrets.ts +49 -35
  229. package/src/apps/cli/commands/project/commandDeletePods.ts +3 -5
  230. package/src/apps/cli/commands/project/commandDeleteProject.ts +1 -1
  231. package/src/apps/cli/commands/project/commandEnvVars.ts +6 -3
  232. package/src/apps/cli/commands/project/commandGetMyTotalWorktime.ts +2 -2
  233. package/src/apps/cli/commands/project/commandGetShell.ts +10 -9
  234. package/src/apps/cli/commands/project/commandGitlabCi.ts +2 -1
  235. package/src/apps/cli/commands/project/commandInitProject.old.ts +1 -1
  236. package/src/apps/cli/commands/project/commandListPods.ts +2 -2
  237. package/src/apps/cli/commands/project/commandMigrateHelm3.ts +4 -3
  238. package/src/apps/cli/commands/project/commandNamespace.ts +1 -1
  239. package/src/apps/cli/commands/project/commandOpenCostDashboard.ts +3 -3
  240. package/src/apps/cli/commands/project/commandOpenDashboard.ts +12 -32
  241. package/src/apps/cli/commands/project/commandOpenEnv.ts +1 -1
  242. package/src/apps/cli/commands/project/commandOpenGit.ts +3 -3
  243. package/src/apps/cli/commands/project/commandOpenGrafana.ts +3 -3
  244. package/src/apps/cli/commands/project/commandOpenGrafanaPod.ts +5 -7
  245. package/src/apps/cli/commands/project/commandOpenLogs.ts +4 -35
  246. package/src/apps/cli/commands/project/commandPauseProject.ts +1 -1
  247. package/src/apps/cli/commands/project/commandPortForward.ts +75 -34
  248. package/src/apps/cli/commands/project/commandSecretsClearBackups.ts +27 -0
  249. package/src/apps/cli/commands/project/commandSetup.ts +1 -1
  250. package/src/apps/cli/commands/project/commandTriggerCronjob.ts +3 -2
  251. package/src/apps/cli/commands/project/index.ts +4 -3
  252. package/src/apps/cli/commands/project/setup/index.ts +3 -1
  253. package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +23 -11
  254. package/src/apps/cli/commands/project/setup/setupCloudRun.ts +84 -0
  255. package/src/apps/cli/commands/project/setup/setupContext.ts +9 -2
  256. package/src/apps/cli/commands/project/setup/setupKubernetes.ts +56 -28
  257. package/src/apps/cli/commands/project/setup/setupTopic.ts +22 -0
  258. package/src/apps/cli/commands/project/utils/ensureNamespace.ts +4 -2
  259. package/src/apps/cli/commands/project/utils/showProjectBanner.ts +1 -1
  260. package/src/apps/cli/commands/theStuffThatReallyMatters/index.ts +2 -2
  261. package/src/apps/cli/config/writeConfig.ts +2 -2
  262. package/src/apps/cli/verify/index.ts +1 -1
  263. package/src/apps/cli/verify/migration/fromv2.ts +5 -7
  264. package/src/apps/cli/verify/migration/migrateSecrets.ts +15 -5
  265. package/src/apps/cli/verify/migration/oldGitlabCi.ts +2 -2
  266. package/src/catenv.ts +6 -3
  267. package/src/cli.ts +1 -7
  268. package/src/config/constants.ts +0 -2
  269. package/src/config/getProjectConfig.ts +70 -30
  270. package/src/config/parseChoice.ts +4 -0
  271. package/src/gcloud/artifactsRegistry.ts +16 -0
  272. package/src/gcloud/cloudRun/getCloudRunDomainSuffix.ts +35 -0
  273. package/src/gcloud/cloudRun/openCloudRunDashboards.ts +22 -0
  274. package/src/gcloud/cloudSql/startProxy.ts +74 -0
  275. package/src/gcloud/enableServices.ts +14 -0
  276. package/src/gcloud/openDashboard.ts +19 -0
  277. package/src/gcloud/serviceAccounts.ts +101 -0
  278. package/src/kubernetes/index.ts +27 -0
  279. package/src/kubernetes/openKubernetesDashboards.ts +52 -0
  280. package/src/kubernetes/portForward.ts +15 -0
  281. package/src/types/child-process-promise.d.ts +37 -1
  282. package/src/utils/cluster.ts +3 -3
  283. package/src/utils/gitlab.ts +141 -30
  284. package/src/utils/passwordstore/index.ts +2 -30
  285. package/src/utils/{portForward.ts → portForwards.ts} +27 -22
  286. package/src/utils/projects/index.ts +3 -24
  287. package/tsconfig.json +1 -1
  288. package/dist/apps/cli/commands/project/commandCopyDB.js +0 -102
  289. package/dist/apps/cli/commands/project/commandCopyDB.js.map +0 -1
  290. package/dist/apps/cli/commands/shared/index.d.ts +0 -3
  291. package/dist/apps/cli/commands/shared/index.js.map +0 -1
  292. package/dist/utils/portForward.d.ts +0 -4
  293. package/dist/utils/portForward.js.map +0 -1
  294. package/src/apps/cli/commands/project/commandCopyDB.ts +0 -91
  295. package/src/apps/cli/commands/shared/index.ts +0 -36
@@ -1,8 +1,4 @@
1
1
  "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -40,16 +36,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
40
36
  }
41
37
  };
42
38
  exports.__esModule = true;
43
- exports.getProjectPodNames = exports.getProjectPvcs = exports.getProjectPods = exports.getProjectNamespace = exports.hasGitlabCiFile = exports.readRootGitlabCiFile = exports.getRootGitlabCiFile = exports.getGitRoot = void 0;
44
- var zx_1 = require("zx");
39
+ exports.getProjectNamespace = exports.hasGitlabCiFile = exports.readRootGitlabCiFile = exports.getRootGitlabCiFile = exports.getGitRoot = void 0;
45
40
  var path_1 = require("path");
46
41
  var getProjectConfig_1 = require("../../config/getProjectConfig");
47
- var k8sApi_1 = require("../../k8sApi");
48
42
  var files_1 = require("../files");
43
+ var child_process_promise_1 = require("child-process-promise");
49
44
  var getGitRoot = function () { return __awaiter(void 0, void 0, void 0, function () {
50
45
  return __generator(this, function (_a) {
51
46
  switch (_a.label) {
52
- case 0: return [4 /*yield*/, (0, zx_1.$)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["git rev-parse --show-toplevel"], ["git rev-parse --show-toplevel"])))];
47
+ case 0: return [4 /*yield*/, (0, child_process_promise_1.exec)("git rev-parse --show-toplevel")];
53
48
  case 1: return [2 /*return*/, (_a.sent()).stdout.trim()];
54
49
  }
55
50
  });
@@ -105,49 +100,4 @@ var getProjectNamespace = function (envComponent) { return __awaiter(void 0, voi
105
100
  });
106
101
  }); };
107
102
  exports.getProjectNamespace = getProjectNamespace;
108
- var getProjectPods = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
109
- var namespace, k8sApi, 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
- k8sApi = (0, k8sApi_1.getk8sApi)();
116
- return [4 /*yield*/, k8sApi.listNamespacedPod(namespace)];
117
- case 2:
118
- res = _a.sent();
119
- return [2 /*return*/, res.body.items];
120
- }
121
- });
122
- }); };
123
- exports.getProjectPods = getProjectPods;
124
- var getProjectPvcs = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
125
- var namespace, k8sApi, res;
126
- return __generator(this, function (_a) {
127
- switch (_a.label) {
128
- case 0: return [4 /*yield*/, (0, exports.getProjectNamespace)(envComponent)];
129
- case 1:
130
- namespace = _a.sent();
131
- k8sApi = (0, k8sApi_1.getk8sApi)();
132
- return [4 /*yield*/, k8sApi.listNamespacedPersistentVolumeClaim(namespace)];
133
- case 2:
134
- res = _a.sent();
135
- return [2 /*return*/, res.body.items];
136
- }
137
- });
138
- }); };
139
- exports.getProjectPvcs = getProjectPvcs;
140
- var getProjectPodNames = function (envComponent) { return __awaiter(void 0, void 0, void 0, function () {
141
- var pods;
142
- return __generator(this, function (_a) {
143
- switch (_a.label) {
144
- case 0: return [4 /*yield*/, (0, exports.getProjectPods)(envComponent)];
145
- case 1:
146
- pods = _a.sent();
147
- return [2 /*return*/, pods.map(function (n) { return n.metadata.name; })];
148
- }
149
- });
150
- }); };
151
- exports.getProjectPodNames = getProjectPodNames;
152
- var templateObject_1;
153
103
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/projects/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAAuB;AACvB,6BAA4B;AAC5B,kEAA8E;AAC9E,uCAAyC;AACzC,kCAA2C;AAEpC,IAAM,UAAU,GAAG;;;oBAChB,yBAAM,MAAC,mGAAA,+BAA+B,MAAA;oBAA9C,sBAAO,CAAC,SAAsC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,EAAC;;;KAC/D,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;gBACnD,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;gBACf,qBAAM,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAA;;gBAA/C,GAAG,GAAG,SAAyC;gBAErD,sBAAO,GAAG,CAAC,IAAI,CAAC,KAAK,EAAC;;;KACvB,CAAC;AANW,QAAA,cAAc,kBAMzB;AAEK,IAAM,cAAc,GAAG,UAAO,YAAoB;;;;oBACrC,qBAAM,IAAA,2BAAmB,EAAC,YAAY,CAAC,EAAA;;gBAAnD,SAAS,GAAG,SAAuC;gBACnD,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;gBACf,qBAAM,MAAM,CAAC,mCAAmC,CAAC,SAAS,CAAC,EAAA;;gBAAjE,GAAG,GAAG,SAA2D;gBAEvE,sBAAO,GAAG,CAAC,IAAI,CAAC,KAAK,EAAC;;;KACvB,CAAC;AANW,QAAA,cAAc,kBAMzB;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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/projects/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA4B;AAC5B,kEAA8E;AAE9E,kCAA2C;AAC3C,+DAA6C;AAEtC,IAAM,UAAU,GAAG;;;oBAChB,qBAAM,IAAA,4BAAI,EAAC,+BAA+B,CAAC,EAAA;oBAAnD,sBAAO,CAAC,SAA2C,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,EAAC;;;KACpE,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"}
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-pipeline-variables-ed2d2565",
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-pipeline-variables-ed2d2565",
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,62 +1,18 @@
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
- };
14
-
15
- const sanitizeEnvVarName = (name: string) => name.replace(/[\s\-.]+/g, "_");
16
-
17
- const getAllVariablesToPrint = async (config: Config) => {
18
- const { components } = config;
19
-
20
- const currentComponent = await getCurrentComponentName(components);
1
+ import { getProjectConfig } from "../../config/getProjectConfig";
2
+ import { printVariables } from "./printVariables";
3
+ import type { Choice } from "./types";
4
+ import { writeDotEnvFiles } from "./writeDotEnvFiles";
5
+ import { writeDTsFiles } from "./writeEnvDTs";
21
6
 
22
- let variables = {};
23
- if (currentComponent) {
24
- variables = await getEnvVars(null, "local", currentComponent);
25
- } else {
26
- // when in a monorep and not in a subapp, merge all env vars.
27
- // this is not 100% correct, but better than not exporting any vars at all
28
- // so we also add prefixed variants
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 () => {
7
+ export default async (choice?: Choice) => {
50
8
  const config = await getProjectConfig();
51
9
  if (!config) {
52
10
  return;
53
11
  }
54
12
 
55
- const variables = await getAllVariablesToPrint(config);
13
+ await printVariables(config, choice);
14
+
15
+ await writeDotEnvFiles(config, choice);
56
16
 
57
- console.log(
58
- Object.entries(variables)
59
- .map(([key, value]) => `export ${key}='${value}'`)
60
- .join("\n")
61
- );
17
+ await writeDTsFiles(config, choice);
62
18
  };
@@ -0,0 +1,53 @@
1
+ import type { Config } from "@catladder/pipeline";
2
+ import { getEnvVarsResolved } from "../../config/getProjectConfig";
3
+ import type { Choice, Variables } from "./types";
4
+ import {
5
+ getCurrentComponentAndEnvFromChoice,
6
+ makeKeyValueString,
7
+ sanitizeEnvVarName,
8
+ } from "./utils";
9
+
10
+ const getAllVariablesToPrint = async (config: Config, choice?: Choice) => {
11
+ const { env, currentComponent } = await getCurrentComponentAndEnvFromChoice(
12
+ config,
13
+ choice
14
+ );
15
+
16
+ let variables: Record<string, string> = {};
17
+ if (currentComponent) {
18
+ variables = await getEnvVarsResolved(null, env, currentComponent);
19
+ } else {
20
+ // when in a monorep and not in a subapp, merge all env vars.
21
+ // this is not 100% correct, but better than not exporting any vars at all
22
+ // so we also add prefixed variants
23
+ variables = await Object.keys(config.components).reduce(
24
+ async (acc, componentName) => {
25
+ const subappvars = await getEnvVarsResolved(null, env, componentName);
26
+ delete subappvars["_ALL_ENV_VAR_KEYS"];
27
+ return {
28
+ ...(await acc),
29
+ ...subappvars,
30
+ // also add prefixed variants in case
31
+ ...Object.fromEntries(
32
+ Object.entries(subappvars).map(([key, value]) => [
33
+ `${sanitizeEnvVarName(componentName.toUpperCase())}_${key}`,
34
+ value,
35
+ ])
36
+ ),
37
+ };
38
+ },
39
+ {}
40
+ );
41
+ }
42
+
43
+ return variables;
44
+ };
45
+
46
+ export const printVariables = async (config: Config, choice?: Choice) => {
47
+ const variables = await getAllVariablesToPrint(config, choice);
48
+
49
+ console.log(makeExportKeyValuestring(variables));
50
+ };
51
+
52
+ const makeExportKeyValuestring = (variables: Variables) =>
53
+ makeKeyValueString(variables, "export ");
@@ -0,0 +1,6 @@
1
+ export type Choice = {
2
+ env?: string;
3
+ componentName?: string;
4
+ };
5
+
6
+ export type Variables = Record<string, string>;
@@ -0,0 +1,49 @@
1
+ import type { Config } from "@catladder/pipeline";
2
+ import { join } from "path";
3
+ import { getGitRoot } from "../../utils/projects";
4
+ import type { Choice, Variables } from "./types";
5
+ export const getComponentFullPath = (
6
+ gitRoot: string,
7
+ config: Config,
8
+ componentName: string
9
+ ) => {
10
+ return join(gitRoot, config.components[componentName].dir);
11
+ };
12
+ const getCurrentComponentName = async (config: Config) => {
13
+ const gitRoot = await getGitRoot();
14
+ const currentDir = process.cwd();
15
+ return Object.keys(config.components).find((c) =>
16
+ currentDir.startsWith(getComponentFullPath(gitRoot, config, c))
17
+ );
18
+ };
19
+
20
+ export const getCurrentComponentAndEnvFromChoice = async (
21
+ config: Config,
22
+ choice?: Choice
23
+ ) => {
24
+ const env = choice?.env ?? "local";
25
+ const currentComponent =
26
+ choice?.componentName ?? (await getCurrentComponentName(config));
27
+
28
+ return {
29
+ currentComponent,
30
+ env,
31
+ };
32
+ };
33
+
34
+ export const makeKeyValueString = (variables: Variables, keyPrefix = "") =>
35
+ Object.entries(variables)
36
+ .map(([key, value]) => `${keyPrefix}${key}='${value}'`)
37
+ .join("\n");
38
+
39
+ export const sanitizeMultiLine = (variables: Variables) => {
40
+ return Object.fromEntries(
41
+ Object.entries(variables).map(([key, value]) => [
42
+ key,
43
+ value.replaceAll("\n", "\\n"),
44
+ ])
45
+ );
46
+ };
47
+
48
+ export const sanitizeEnvVarName = (name: string) =>
49
+ name.replace(/[\s\-.]+/g, "_");
@@ -0,0 +1,46 @@
1
+ import type { Config } from "@catladder/pipeline";
2
+ import { writeFile } from "fs-extra";
3
+ import { join } from "path";
4
+ import { getEnvVarsResolved } from "../../config/getProjectConfig";
5
+ import { getGitRoot } from "../../utils/projects";
6
+ import type { Choice } from "./types";
7
+ import {
8
+ getComponentFullPath,
9
+ getCurrentComponentAndEnvFromChoice,
10
+ makeKeyValueString,
11
+ sanitizeMultiLine,
12
+ } from "./utils";
13
+
14
+ export const writeDotEnvFiles = async (config: Config, choice?: Choice) => {
15
+ const { env, currentComponent } = await getCurrentComponentAndEnvFromChoice(
16
+ config,
17
+ choice
18
+ );
19
+
20
+ // whether to print .dotenv is currentl configure on the "local" part of the env
21
+
22
+ const componentsWithEnabledDotEnvWrite = Object.entries(config.components)
23
+ .filter(([, component]) => component?.dotEnv)
24
+ .map(([componentName]) => componentName);
25
+
26
+ const componentsToActuallyWriteDotEnvNow = currentComponent
27
+ ? componentsWithEnabledDotEnvWrite.includes(currentComponent)
28
+ ? [currentComponent]
29
+ : []
30
+ : componentsWithEnabledDotEnvWrite;
31
+ const gitRoot = await getGitRoot();
32
+
33
+ for (const componentName of componentsToActuallyWriteDotEnvNow) {
34
+ const variables = await getEnvVarsResolved(null, env, componentName);
35
+ delete variables["_ALL_ENV_VAR_KEYS"];
36
+ const componentDir = getComponentFullPath(gitRoot, config, componentName);
37
+ const filePath = join(componentDir, ".env");
38
+ // many .dotenv don't like multiline values, so we sanitize them here
39
+ const variablesSanitized = sanitizeMultiLine(variables);
40
+ await writeFile(
41
+ filePath,
42
+ "# automatically created by catladder. Do not modify!\n\n" +
43
+ makeKeyValueString(variablesSanitized)
44
+ );
45
+ }
46
+ };
@@ -0,0 +1,71 @@
1
+ import type { Config } from "@catladder/pipeline";
2
+ import { writeFile } from "fs-extra";
3
+ import { join } from "path";
4
+ import { getEnvironment } from "../../config/getProjectConfig";
5
+ import { getGitRoot } from "../../utils/projects";
6
+ import type { Choice } from "./types";
7
+ import {
8
+ getComponentFullPath,
9
+ getCurrentComponentAndEnvFromChoice,
10
+ } from "./utils";
11
+
12
+ export const writeDTsFiles = async (config: Config, choice?: Choice) => {
13
+ const { env, currentComponent } = await getCurrentComponentAndEnvFromChoice(
14
+ config,
15
+ choice
16
+ );
17
+
18
+ const componentsWithEnabledEnvDTsWrite = Object.entries(config.components)
19
+ .filter(([, component]) => component?.envDTs)
20
+ .map(([componentName]) => componentName);
21
+
22
+ const componentsToActuallyWriteDotEnvNow = currentComponent
23
+ ? componentsWithEnabledEnvDTsWrite.includes(currentComponent)
24
+ ? [currentComponent]
25
+ : []
26
+ : componentsWithEnabledEnvDTsWrite;
27
+ const gitRoot = await getGitRoot();
28
+
29
+ for (const componentName of componentsToActuallyWriteDotEnvNow) {
30
+ const envNames = await getEnvsForDTs(env, componentName);
31
+ const envDTsContent = createEnvDTsContent(envNames);
32
+
33
+ const componentDir = getComponentFullPath(gitRoot, config, componentName);
34
+ const filePath = join(componentDir, "env.d.ts");
35
+ await writeFile(filePath, envDTsContent);
36
+ }
37
+ };
38
+
39
+ async function getEnvsForDTs(
40
+ env: string,
41
+ componentName: string
42
+ ): Promise<string[]> {
43
+ const environment = await getEnvironment(env, componentName);
44
+ const allEnvKeys = Object.keys(environment.envVars);
45
+ const hiddenEnvKeys = new Set(
46
+ environment.secretEnvVarKeys
47
+ .filter((s) => s.hidden)
48
+ .map((s) => s.key)
49
+ .concat(["_ALL_ENV_VAR_KEYS"])
50
+ );
51
+ const dTsEnvKeys = allEnvKeys.filter((k) => !hiddenEnvKeys.has(k));
52
+
53
+ return dTsEnvKeys;
54
+ }
55
+
56
+ function createEnvDTsContent(envNames: string[]) {
57
+ return `/* tslint:disable prettier/prettier */
58
+ /* eslint-disable prettier/prettier */
59
+ /* prettier-ignore */
60
+ // automatically generated by catladder. Do not modify!
61
+ export {}
62
+
63
+ declare global {
64
+ namespace NodeJS {
65
+ interface ProcessEnv {
66
+ ${envNames.map((name) => ` ${name}: string`).join("\n")}
67
+ }
68
+ }
69
+ }
70
+ `;
71
+ }
@@ -1,9 +1,10 @@
1
1
  import Vorpal from "vorpal";
2
2
  // tslint:disable-next-line:no-var-requires
3
3
  import packageInfos from "../../packageInfos";
4
- import { stopAllPortForwards } from "../../utils/portForward";
4
+ import { stopAllPortForwards } from "../../utils/portForwards";
5
5
  import general from "./commands/general";
6
6
  import mongodb from "./commands/mongodb";
7
+ import cloudSQL from "./commands/cloudSQL";
7
8
  import project from "./commands/project";
8
9
  import theStuffThatReallyMatters from "./commands/theStuffThatReallyMatters";
9
10
 
@@ -29,6 +30,7 @@ export default async () => {
29
30
 
30
31
  general(vorpal);
31
32
  project(vorpal);
33
+ cloudSQL(vorpal);
32
34
  mongodb(vorpal);
33
35
  theStuffThatReallyMatters(vorpal);
34
36
 
@@ -0,0 +1,154 @@
1
+ import { spawn } from "child-process-promise";
2
+
3
+ import type Vorpal from "vorpal";
4
+ import type { CloudSqlBackgroundProxy } from "../../../../gcloud/cloudSql/startProxy";
5
+ import { startCloudSqlProxyInBackground } from "../../../../gcloud/cloudSql/startProxy";
6
+
7
+ export default async (vorpal: Vorpal) =>
8
+ vorpal
9
+ .command(
10
+ "cloud-sql-restore-db",
11
+ "restore a db from one source to another target"
12
+ )
13
+ .action(async function restoreDb() {
14
+ const { sourceInstance } = await this.prompt({
15
+ type: "input",
16
+ name: "sourceInstance",
17
+
18
+ message: "Source instance (connection string or 'local')? šŸ¤” ",
19
+ });
20
+
21
+ let sourceProxy: CloudSqlBackgroundProxy;
22
+
23
+ let targetProxy: CloudSqlBackgroundProxy;
24
+
25
+ let sourcePort: number;
26
+ let targetPort: number;
27
+
28
+ if (sourceInstance === "local") {
29
+ const { sourceLocalPort } = await this.prompt({
30
+ type: "number",
31
+ name: "sourceLocalPort",
32
+ default: 5432,
33
+
34
+ message: "Local Port for source? šŸ¤” ",
35
+ });
36
+ sourcePort = sourceLocalPort;
37
+ } else {
38
+ sourcePort = 54399;
39
+ sourceProxy = await startCloudSqlProxyInBackground({
40
+ instanceName: sourceInstance,
41
+ localPort: sourcePort,
42
+ });
43
+ }
44
+
45
+ const { sourceUsername } = await this.prompt({
46
+ type: "input",
47
+ name: "sourceUsername",
48
+ default: "postgres",
49
+
50
+ message: "Source Username? šŸ¤” ",
51
+ });
52
+
53
+ const { sourcePassword } = await this.prompt({
54
+ type: "input",
55
+ name: "sourcePassword",
56
+
57
+ message: "Source Password? šŸ¤” ",
58
+ });
59
+
60
+ const { sourceDbName } = await this.prompt({
61
+ type: "input",
62
+ name: "sourceDbName",
63
+
64
+ message: "Source DB name? šŸ¤” ",
65
+ });
66
+
67
+ const { targetInstance } = await this.prompt({
68
+ type: "input",
69
+ name: "targetInstance",
70
+
71
+ message: "Target INSTANCE (connection string or 'local')? šŸ¤” ",
72
+ });
73
+
74
+ if (targetInstance === "local") {
75
+ const { targetLocalPort } = await this.prompt({
76
+ type: "number",
77
+ name: "targetLocalPort",
78
+ default: 5432,
79
+
80
+ message: "Local Port for target? šŸ¤” ",
81
+ });
82
+ targetPort = targetLocalPort;
83
+ } else {
84
+ targetPort = 54499;
85
+ targetProxy = await startCloudSqlProxyInBackground({
86
+ instanceName: targetInstance,
87
+ localPort: targetPort,
88
+ });
89
+ }
90
+
91
+ const { targetUsername } = await this.prompt({
92
+ type: "input",
93
+ name: "targetUsername",
94
+ default: "postgres",
95
+
96
+ message: "Target Username? šŸ¤” ",
97
+ });
98
+ const { targetPassword } = await this.prompt({
99
+ type: "input",
100
+ name: "targetPassword",
101
+
102
+ message: "Target Password? šŸ¤” ",
103
+ });
104
+
105
+ const { targetDbName } = await this.prompt({
106
+ type: "input",
107
+ name: "targetDbName",
108
+
109
+ message: "Target DB name? šŸ¤” ",
110
+ });
111
+
112
+ const { shouldContinue } = await this.prompt({
113
+ type: "confirm",
114
+ name: "shouldContinue",
115
+ message: `This will drop ${targetInstance}/${targetDbName} and replace it with ${sourceInstance}/${sourceDbName}. Continue? šŸ¤” `,
116
+ });
117
+
118
+ if (!shouldContinue) {
119
+ return;
120
+ }
121
+
122
+ const targetPSQL = (command: string) =>
123
+ `PGPASSWORD=${targetPassword} psql -p ${targetPort} --host=localhost --user=${targetUsername} -q ${command}`;
124
+
125
+ const copyDBScript = `
126
+ set -e
127
+
128
+
129
+
130
+ dumptmp=$(mktemp /tmp/dump.XXXXXX)
131
+
132
+ echo "Dumping file to $dumptmp"
133
+ pg_dump --dbname=postgres://${sourceUsername}:${sourcePassword}@localhost:${sourcePort}/${sourceDbName} --no-owner --no-privileges > $dumptmp
134
+ echo "dump done"
135
+ ${targetPSQL(
136
+ `-c 'drop database "${targetDbName}" WITH (FORCE)' 1> /dev/null || true`
137
+ )}
138
+ ${targetPSQL(`-c 'create database "${targetDbName}"' 1> /dev/null`)}
139
+ echo "Restoring dump..."
140
+ ${targetPSQL(`"${targetDbName}" < $dumptmp 1> /dev/null`)}
141
+
142
+
143
+ echo "Clean up..."
144
+ set +e
145
+ rm $dumptmp
146
+ echo "\n🐱 Done!"
147
+ `;
148
+ try {
149
+ await spawn(copyDBScript, [], { shell: "bash", stdio: "inherit" });
150
+ } finally {
151
+ sourceProxy?.stop();
152
+ targetProxy?.stop();
153
+ }
154
+ });
@@ -0,0 +1,8 @@
1
+ import type Vorpal from "vorpal";
2
+ //import commandInitProject from "./commandInitProject.old";
3
+
4
+ import commandRestoreDb from "./commandRestoreDb";
5
+
6
+ export default async (vorpal: Vorpal) => {
7
+ commandRestoreDb(vorpal);
8
+ };