@catladder/cli 3.47.1 → 4.0.0

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 (481) hide show
  1. package/README.md +23 -5
  2. package/dist/bundles/catenv/index.js +3 -3
  3. package/dist/bundles/cli/index.js +34 -30
  4. package/dist/cli/src/adapters/baseContext.d.ts +22 -0
  5. package/dist/cli/src/adapters/baseContext.js +40 -0
  6. package/dist/cli/src/adapters/baseContext.js.map +1 -0
  7. package/dist/cli/src/adapters/programmatic.d.ts +26 -0
  8. package/dist/cli/src/adapters/programmatic.js +67 -0
  9. package/dist/cli/src/adapters/programmatic.js.map +1 -0
  10. package/dist/cli/src/adapters/terminal.d.ts +28 -0
  11. package/dist/cli/src/adapters/terminal.js +201 -0
  12. package/dist/cli/src/adapters/terminal.js.map +1 -0
  13. package/dist/cli/src/apps/catenv/catenv.d.ts +1 -0
  14. package/dist/cli/src/apps/catenv/catenv.js +1 -1
  15. package/dist/cli/src/apps/catenv/catenv.js.map +1 -1
  16. package/dist/cli/src/apps/catenv/printVariables.js +0 -10
  17. package/dist/cli/src/apps/catenv/printVariables.js.map +1 -1
  18. package/dist/cli/src/apps/cli/commands/project/commandConfigSecrets.d.ts +2 -5
  19. package/dist/cli/src/apps/cli/commands/project/commandConfigSecrets.js +6 -21
  20. package/dist/cli/src/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
  21. package/dist/cli/src/apps/cli/commands/project/setup/index.d.ts +2 -2
  22. package/dist/cli/src/apps/cli/commands/project/setup/index.js.map +1 -1
  23. package/dist/cli/src/apps/cli/commands/project/setup/logSection.d.ts +2 -2
  24. package/dist/cli/src/apps/cli/commands/project/setup/logSection.js.map +1 -1
  25. package/dist/cli/src/apps/cli/commands/project/setup/setupAccessTokens.d.ts +2 -2
  26. package/dist/cli/src/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -1
  27. package/dist/cli/src/apps/cli/commands/project/setup/setupAgents.d.ts +2 -2
  28. package/dist/cli/src/apps/cli/commands/project/setup/setupAgents.js.map +1 -1
  29. package/dist/cli/src/apps/cli/commands/project/setup/setupCloudRun.d.ts +2 -2
  30. package/dist/cli/src/apps/cli/commands/project/setup/setupCloudRun.js.map +1 -1
  31. package/dist/cli/src/apps/cli/commands/project/setup/setupContext.d.ts +2 -2
  32. package/dist/cli/src/apps/cli/commands/project/setup/setupContext.js.map +1 -1
  33. package/dist/cli/src/apps/cli/commands/project/setup/setupKubernetes.d.ts +2 -2
  34. package/dist/cli/src/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
  35. package/dist/cli/src/apps/cli/commands/project/setup/setupTopic.d.ts +2 -2
  36. package/dist/cli/src/apps/cli/commands/project/setup/setupTopic.js.map +1 -1
  37. package/dist/cli/src/apps/cli/commands/project/utils/ensureCluster.d.ts +9 -1
  38. package/dist/cli/src/apps/cli/commands/project/utils/ensureCluster.js +15 -14
  39. package/dist/cli/src/apps/cli/commands/project/utils/ensureCluster.js.map +1 -1
  40. package/dist/cli/src/apps/cli/utils/getGoogleAuthUserNumber.d.ts +2 -1
  41. package/dist/cli/src/apps/cli/utils/getGoogleAuthUserNumber.js +4 -6
  42. package/dist/cli/src/apps/cli/utils/getGoogleAuthUserNumber.js.map +1 -1
  43. package/dist/cli/src/catenv.js +14 -16
  44. package/dist/cli/src/catenv.js.map +1 -1
  45. package/dist/cli/src/cli.js +186 -2
  46. package/dist/cli/src/cli.js.map +1 -1
  47. package/dist/cli/src/commands/cloudSQL/commandRestoreDb.d.ts +46 -0
  48. package/dist/cli/src/commands/cloudSQL/commandRestoreDb.js +111 -0
  49. package/dist/cli/src/commands/cloudSQL/commandRestoreDb.js.map +1 -0
  50. package/dist/cli/src/commands/fun/commandDadjoke.d.ts +1 -0
  51. package/dist/cli/src/commands/fun/commandDadjoke.js +30 -0
  52. package/dist/cli/src/commands/fun/commandDadjoke.js.map +1 -0
  53. package/dist/cli/src/commands/fun/commandStarwars.d.ts +1 -0
  54. package/dist/cli/src/commands/fun/commandStarwars.js +19 -0
  55. package/dist/cli/src/commands/fun/commandStarwars.js.map +1 -0
  56. package/dist/cli/src/commands/general/commandKubeCurrentContext.d.ts +1 -0
  57. package/dist/cli/src/commands/general/commandKubeCurrentContext.js +17 -0
  58. package/dist/cli/src/commands/general/commandKubeCurrentContext.js.map +1 -0
  59. package/dist/cli/src/commands/general/commandKubeGetShell.d.ts +12 -0
  60. package/dist/cli/src/commands/general/commandKubeGetShell.js +36 -0
  61. package/dist/cli/src/commands/general/commandKubeGetShell.js.map +1 -0
  62. package/dist/cli/src/commands/general/commandKubeListNamespaces.d.ts +1 -0
  63. package/dist/cli/src/commands/general/commandKubeListNamespaces.js +20 -0
  64. package/dist/cli/src/commands/general/commandKubeListNamespaces.js.map +1 -0
  65. package/dist/cli/src/commands/general/commandKubeListPods.d.ts +7 -0
  66. package/dist/cli/src/commands/general/commandKubeListPods.js +26 -0
  67. package/dist/cli/src/commands/general/commandKubeListPods.js.map +1 -0
  68. package/dist/cli/src/commands/general/commandKubeListSecrets.d.ts +7 -0
  69. package/dist/cli/src/commands/general/commandKubeListSecrets.js +26 -0
  70. package/dist/cli/src/commands/general/commandKubeListSecrets.js.map +1 -0
  71. package/dist/cli/src/commands/general/commandKubePortForward.d.ts +20 -0
  72. package/dist/cli/src/commands/general/commandKubePortForward.js +46 -0
  73. package/dist/cli/src/commands/general/commandKubePortForward.js.map +1 -0
  74. package/dist/cli/src/commands/general/commandKubeStopPortforward.d.ts +7 -0
  75. package/dist/cli/src/commands/general/commandKubeStopPortforward.js +24 -0
  76. package/dist/cli/src/commands/general/commandKubeStopPortforward.js.map +1 -0
  77. package/dist/cli/src/commands/index.d.ts +37 -0
  78. package/dist/cli/src/commands/index.js +283 -0
  79. package/dist/cli/src/commands/index.js.map +1 -0
  80. package/dist/cli/src/commands/mongodb/commandMongoDestroyMember.d.ts +16 -0
  81. package/dist/cli/src/commands/mongodb/commandMongoDestroyMember.js +89 -0
  82. package/dist/cli/src/commands/mongodb/commandMongoDestroyMember.js.map +1 -0
  83. package/dist/cli/src/commands/mongodb/commandMongoGetShell.d.ts +16 -0
  84. package/dist/cli/src/commands/mongodb/commandMongoGetShell.js +36 -0
  85. package/dist/cli/src/commands/mongodb/commandMongoGetShell.js.map +1 -0
  86. package/dist/cli/src/commands/mongodb/commandMongoPortForward.d.ts +21 -0
  87. package/dist/cli/src/commands/mongodb/commandMongoPortForward.js +65 -0
  88. package/dist/cli/src/commands/mongodb/commandMongoPortForward.js.map +1 -0
  89. package/dist/cli/src/commands/project/commandCloudSqlProxy.d.ts +13 -0
  90. package/dist/cli/src/commands/project/commandCloudSqlProxy.js +127 -0
  91. package/dist/cli/src/commands/project/commandCloudSqlProxy.js.map +1 -0
  92. package/dist/cli/src/commands/project/commandConfigSecrets.d.ts +9 -0
  93. package/dist/cli/src/commands/project/commandConfigSecrets.js +36 -0
  94. package/dist/cli/src/commands/project/commandConfigSecrets.js.map +1 -0
  95. package/dist/cli/src/commands/project/commandDeletePods.d.ts +13 -0
  96. package/dist/cli/src/commands/project/commandDeletePods.js +49 -0
  97. package/dist/cli/src/commands/project/commandDeletePods.js.map +1 -0
  98. package/dist/cli/src/commands/project/commandDeleteProject.d.ts +8 -0
  99. package/dist/cli/src/commands/project/commandDeleteProject.js +41 -0
  100. package/dist/cli/src/commands/project/commandDeleteProject.js.map +1 -0
  101. package/dist/cli/src/commands/project/commandEnvVars.d.ts +8 -0
  102. package/dist/cli/src/commands/project/commandEnvVars.js +32 -0
  103. package/dist/cli/src/commands/project/commandEnvVars.js.map +1 -0
  104. package/dist/cli/src/commands/project/commandGetMyTotalWorktime.d.ts +1 -0
  105. package/dist/cli/src/commands/project/commandGetMyTotalWorktime.js +19 -0
  106. package/dist/cli/src/commands/project/commandGetMyTotalWorktime.js.map +1 -0
  107. package/dist/cli/src/commands/project/commandGetShell.d.ts +13 -0
  108. package/dist/cli/src/commands/project/commandGetShell.js +41 -0
  109. package/dist/cli/src/commands/project/commandGetShell.js.map +1 -0
  110. package/dist/cli/src/commands/project/commandGitlabCi.d.ts +14 -0
  111. package/dist/cli/src/commands/project/commandGitlabCi.js +109 -0
  112. package/dist/cli/src/commands/project/commandGitlabCi.js.map +1 -0
  113. package/dist/cli/src/commands/project/commandListPods.d.ts +8 -0
  114. package/dist/cli/src/commands/project/commandListPods.js +31 -0
  115. package/dist/cli/src/commands/project/commandListPods.js.map +1 -0
  116. package/dist/cli/src/commands/project/commandNamespace.d.ts +8 -0
  117. package/dist/cli/src/commands/project/commandNamespace.js +26 -0
  118. package/dist/cli/src/commands/project/commandNamespace.js.map +1 -0
  119. package/dist/cli/src/commands/project/commandOpenEnv.d.ts +8 -0
  120. package/dist/cli/src/commands/project/commandOpenEnv.js +40 -0
  121. package/dist/cli/src/commands/project/commandOpenEnv.js.map +1 -0
  122. package/dist/cli/src/commands/project/commandOpenGit.d.ts +1 -0
  123. package/dist/cli/src/commands/project/commandOpenGit.js +17 -0
  124. package/dist/cli/src/commands/project/commandOpenGit.js.map +1 -0
  125. package/dist/cli/src/commands/project/commandOpenLogs.d.ts +8 -0
  126. package/dist/cli/src/commands/project/commandOpenLogs.js +32 -0
  127. package/dist/cli/src/commands/project/commandOpenLogs.js.map +1 -0
  128. package/dist/cli/src/commands/project/commandPauseProject.d.ts +8 -0
  129. package/dist/cli/src/commands/project/commandPauseProject.js +41 -0
  130. package/dist/cli/src/commands/project/commandPauseProject.js.map +1 -0
  131. package/dist/cli/src/commands/project/commandPortForward.d.ts +25 -0
  132. package/dist/cli/src/commands/project/commandPortForward.js +95 -0
  133. package/dist/cli/src/commands/project/commandPortForward.js.map +1 -0
  134. package/dist/cli/src/commands/project/commandProjectRestoreDb.d.ts +19 -0
  135. package/dist/cli/src/commands/project/commandProjectRestoreDb.js +159 -0
  136. package/dist/cli/src/commands/project/commandProjectRestoreDb.js.map +1 -0
  137. package/dist/cli/src/commands/project/commandRenewToken.d.ts +1 -0
  138. package/dist/cli/src/commands/project/commandRenewToken.js +17 -0
  139. package/dist/cli/src/commands/project/commandRenewToken.js.map +1 -0
  140. package/dist/cli/src/commands/project/commandSecretsClearBackups.d.ts +7 -0
  141. package/dist/cli/src/commands/project/commandSecretsClearBackups.js +24 -0
  142. package/dist/cli/src/commands/project/commandSecretsClearBackups.js.map +1 -0
  143. package/dist/cli/src/commands/project/commandSecurityEvaluate.d.ts +1 -0
  144. package/dist/cli/src/commands/project/commandSecurityEvaluate.js +26 -0
  145. package/dist/cli/src/commands/project/commandSecurityEvaluate.js.map +1 -0
  146. package/dist/cli/src/commands/project/commandSetup.d.ts +8 -0
  147. package/dist/cli/src/commands/project/commandSetup.js +25 -0
  148. package/dist/cli/src/commands/project/commandSetup.js.map +1 -0
  149. package/dist/cli/src/commands/project/commandTriggerCronjob.d.ts +25 -0
  150. package/dist/cli/src/commands/project/commandTriggerCronjob.js +95 -0
  151. package/dist/cli/src/commands/project/commandTriggerCronjob.js.map +1 -0
  152. package/dist/cli/src/commands/security/commandSecurityAuditCiJob.d.ts +27 -0
  153. package/dist/cli/src/commands/security/commandSecurityAuditCiJob.js +83 -0
  154. package/dist/cli/src/commands/security/commandSecurityAuditCiJob.js.map +1 -0
  155. package/dist/cli/src/commands/security/commandSecurityAuditCreate.d.ts +22 -0
  156. package/dist/cli/src/commands/security/commandSecurityAuditCreate.js +60 -0
  157. package/dist/cli/src/commands/security/commandSecurityAuditCreate.js.map +1 -0
  158. package/dist/cli/src/commands/security/commandSecurityAuditEvaluate.d.ts +7 -0
  159. package/dist/cli/src/commands/security/commandSecurityAuditEvaluate.js +35 -0
  160. package/dist/cli/src/commands/security/commandSecurityAuditEvaluate.js.map +1 -0
  161. package/dist/cli/src/completion.d.ts +24 -0
  162. package/dist/cli/src/completion.js +240 -0
  163. package/dist/cli/src/completion.js.map +1 -0
  164. package/dist/cli/src/config/getProjectConfig.d.ts +4 -4
  165. package/dist/cli/src/config/getProjectConfig.js +8 -8
  166. package/dist/cli/src/config/getProjectConfig.js.map +1 -1
  167. package/dist/cli/src/core/defineCommand.d.ts +27 -0
  168. package/dist/cli/src/core/defineCommand.js +35 -0
  169. package/dist/cli/src/core/defineCommand.js.map +1 -0
  170. package/dist/cli/src/core/index.d.ts +5 -0
  171. package/dist/cli/src/core/index.js +52 -0
  172. package/dist/cli/src/core/index.js.map +1 -0
  173. package/dist/cli/src/core/registry.d.ts +5 -0
  174. package/dist/cli/src/core/registry.js +26 -0
  175. package/dist/cli/src/core/registry.js.map +1 -0
  176. package/dist/cli/src/core/runner.d.ts +19 -0
  177. package/dist/cli/src/core/runner.js +29 -0
  178. package/dist/cli/src/core/runner.js.map +1 -0
  179. package/dist/cli/src/core/types.d.ts +105 -0
  180. package/dist/cli/src/core/types.js +17 -0
  181. package/dist/cli/src/core/types.js.map +1 -0
  182. package/dist/cli/src/gcloud/cloudRun/openCloudRunDashboards.d.ts +2 -2
  183. package/dist/cli/src/gcloud/cloudRun/openCloudRunDashboards.js.map +1 -1
  184. package/dist/cli/src/gcloud/openDashboard.d.ts +2 -2
  185. package/dist/cli/src/gcloud/openDashboard.js +1 -1
  186. package/dist/cli/src/gcloud/openDashboard.js.map +1 -1
  187. package/dist/cli/src/gcloud/serviceAccounts.d.ts +2 -2
  188. package/dist/cli/src/gcloud/serviceAccounts.js.map +1 -1
  189. package/dist/cli/src/kubernetes/openKubernetesDashboards.d.ts +3 -3
  190. package/dist/cli/src/kubernetes/openKubernetesDashboards.js.map +1 -1
  191. package/dist/cli/src/security/auditDocument.js.map +1 -0
  192. package/dist/cli/src/security/createSecurityAuditMergeRequest.js.map +1 -0
  193. package/dist/cli/src/security/evaluateSecurityAudit.js.map +1 -0
  194. package/dist/cli/src/utils/gitlab.d.ts +9 -9
  195. package/dist/cli/src/utils/gitlab.js +45 -54
  196. package/dist/cli/src/utils/gitlab.js.map +1 -1
  197. package/dist/cli/src/utils/log.d.ts +2 -2
  198. package/dist/pipeline/src/build/base/createBuildJobDefinition.js +1 -1
  199. package/dist/pipeline/src/build/base/createBuildJobDefinition.js.map +1 -1
  200. package/dist/pipeline/src/build/custom/buildJob.js +1 -1
  201. package/dist/pipeline/src/build/custom/buildJob.js.map +1 -1
  202. package/dist/pipeline/src/build/index.d.ts +2 -2
  203. package/dist/pipeline/src/build/index.js.map +1 -1
  204. package/dist/pipeline/src/build/node/buildJob.d.ts +3 -3
  205. package/dist/pipeline/src/build/node/buildJob.js +13 -12
  206. package/dist/pipeline/src/build/node/buildJob.js.map +1 -1
  207. package/dist/pipeline/src/build/node/cache.d.ts +3 -3
  208. package/dist/pipeline/src/build/node/cache.js +12 -9
  209. package/dist/pipeline/src/build/node/cache.js.map +1 -1
  210. package/dist/pipeline/src/build/node/index.d.ts +3 -3
  211. package/dist/pipeline/src/build/node/index.js +8 -6
  212. package/dist/pipeline/src/build/node/index.js.map +1 -1
  213. package/dist/pipeline/src/build/node/meteor.d.ts +1 -1
  214. package/dist/pipeline/src/build/node/meteor.js +9 -8
  215. package/dist/pipeline/src/build/node/meteor.js.map +1 -1
  216. package/dist/pipeline/src/build/node/testJob.d.ts +1 -1
  217. package/dist/pipeline/src/build/node/testJob.js +5 -5
  218. package/dist/pipeline/src/build/node/testJob.js.map +1 -1
  219. package/dist/pipeline/src/build/node/yarn.d.ts +2 -2
  220. package/dist/pipeline/src/build/node/yarn.js +10 -8
  221. package/dist/pipeline/src/build/node/yarn.js.map +1 -1
  222. package/dist/pipeline/src/build/types.d.ts +3 -3
  223. package/dist/pipeline/src/constants.js +1 -1
  224. package/dist/pipeline/src/context/createComponentContext.js +3 -3
  225. package/dist/pipeline/src/context/createComponentContext.js.map +1 -1
  226. package/dist/pipeline/src/context/createWorkspaceContext.js +1 -1
  227. package/dist/pipeline/src/context/createWorkspaceContext.js.map +1 -1
  228. package/dist/pipeline/src/context/getEnvironmentVariables.d.ts +1 -1
  229. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js.map +1 -1
  230. package/dist/pipeline/src/deploy/custom/deployJob.d.ts +1 -1
  231. package/dist/pipeline/src/deploy/custom/deployJob.js +2 -2
  232. package/dist/pipeline/src/deploy/custom/deployJob.js.map +1 -1
  233. package/dist/pipeline/src/deploy/index.d.ts +1 -1
  234. package/dist/pipeline/src/deploy/types/index.d.ts +2 -2
  235. package/dist/pipeline/src/pipeline/createAllJobs.js +4 -4
  236. package/dist/pipeline/src/pipeline/createAllJobs.js.map +1 -1
  237. package/dist/pipeline/src/pipeline/createJobsForComponent.d.ts +1 -1
  238. package/dist/pipeline/src/pipeline/createJobsForComponent.js +2 -3
  239. package/dist/pipeline/src/pipeline/createJobsForComponent.js.map +1 -1
  240. package/dist/pipeline/src/pipeline/createJobsForWorkspace.d.ts +1 -1
  241. package/dist/pipeline/src/pipeline/createJobsForWorkspace.js +2 -2
  242. package/dist/pipeline/src/pipeline/createJobsForWorkspace.js.map +1 -1
  243. package/dist/pipeline/src/types/config.d.ts +3 -3
  244. package/dist/pipeline/src/types/context.d.ts +3 -3
  245. package/dist/tsconfig.tsbuildinfo +1 -1
  246. package/package.json +3 -4
  247. package/scripts/bundle +0 -2
  248. package/src/adapters/baseContext.ts +68 -0
  249. package/src/adapters/programmatic.ts +88 -0
  250. package/src/adapters/terminal.ts +202 -0
  251. package/src/apps/catenv/catenv.ts +4 -2
  252. package/src/apps/catenv/printVariables.ts +0 -8
  253. package/src/apps/cli/commands/project/commandConfigSecrets.ts +8 -33
  254. package/src/apps/cli/commands/project/setup/index.ts +2 -2
  255. package/src/apps/cli/commands/project/setup/logSection.ts +2 -2
  256. package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +2 -2
  257. package/src/apps/cli/commands/project/setup/setupAgents.ts +11 -11
  258. package/src/apps/cli/commands/project/setup/setupCloudRun.ts +2 -2
  259. package/src/apps/cli/commands/project/setup/setupContext.ts +2 -5
  260. package/src/apps/cli/commands/project/setup/setupKubernetes.ts +2 -2
  261. package/src/apps/cli/commands/project/setup/setupTopic.ts +2 -2
  262. package/src/apps/cli/commands/project/utils/ensureCluster.ts +19 -12
  263. package/src/apps/cli/utils/getGoogleAuthUserNumber.ts +5 -4
  264. package/src/catenv.ts +24 -18
  265. package/src/cli.ts +213 -2
  266. package/src/commands/cloudSQL/commandRestoreDb.ts +105 -0
  267. package/src/commands/fun/commandDadjoke.ts +18 -0
  268. package/src/commands/fun/commandStarwars.ts +14 -0
  269. package/src/commands/general/commandKubeCurrentContext.ts +12 -0
  270. package/src/commands/general/commandKubeGetShell.ts +32 -0
  271. package/src/commands/general/commandKubeListNamespaces.ts +15 -0
  272. package/src/commands/general/commandKubeListPods.ts +21 -0
  273. package/src/commands/general/commandKubeListSecrets.ts +21 -0
  274. package/src/commands/general/commandKubePortForward.ts +35 -0
  275. package/src/commands/general/commandKubeStopPortforward.ts +15 -0
  276. package/src/commands/index.ts +51 -0
  277. package/src/commands/mongodb/commandMongoDestroyMember.ts +133 -0
  278. package/src/commands/mongodb/commandMongoGetShell.ts +36 -0
  279. package/src/commands/mongodb/commandMongoPortForward.ts +56 -0
  280. package/src/commands/project/commandCloudSqlProxy.ts +189 -0
  281. package/src/commands/project/commandConfigSecrets.ts +31 -0
  282. package/src/commands/project/commandDeletePods.ts +53 -0
  283. package/src/commands/project/commandDeleteProject.ts +33 -0
  284. package/src/commands/project/commandEnvVars.ts +24 -0
  285. package/src/commands/project/commandGetMyTotalWorktime.ts +14 -0
  286. package/src/commands/project/commandGetShell.ts +39 -0
  287. package/src/commands/project/commandGitlabCi.ts +122 -0
  288. package/src/commands/project/commandListPods.ts +30 -0
  289. package/src/commands/project/commandNamespace.ts +21 -0
  290. package/src/commands/project/commandOpenEnv.ts +27 -0
  291. package/src/commands/project/commandOpenGit.ts +12 -0
  292. package/src/commands/project/commandOpenLogs.ts +27 -0
  293. package/src/commands/project/commandPauseProject.ts +33 -0
  294. package/src/commands/project/commandPortForward.ts +74 -0
  295. package/src/commands/project/commandProjectRestoreDb.ts +201 -0
  296. package/src/commands/project/commandRenewToken.ts +12 -0
  297. package/src/commands/project/commandSecretsClearBackups.ts +19 -0
  298. package/src/commands/project/commandSecurityEvaluate.ts +22 -0
  299. package/src/commands/project/commandSetup.ts +21 -0
  300. package/src/commands/project/commandTriggerCronjob.ts +99 -0
  301. package/src/commands/security/commandSecurityAuditCiJob.ts +91 -0
  302. package/src/commands/security/commandSecurityAuditCreate.ts +58 -0
  303. package/src/commands/security/commandSecurityAuditEvaluate.ts +30 -0
  304. package/src/completion.ts +272 -0
  305. package/src/config/getProjectConfig.ts +9 -9
  306. package/src/core/defineCommand.ts +32 -0
  307. package/src/core/index.ts +23 -0
  308. package/src/core/registry.ts +22 -0
  309. package/src/core/runner.ts +31 -0
  310. package/src/core/types.ts +142 -0
  311. package/src/gcloud/cloudRun/openCloudRunDashboards.ts +2 -2
  312. package/src/gcloud/openDashboard.ts +3 -3
  313. package/src/gcloud/serviceAccounts.ts +2 -2
  314. package/src/kubernetes/openKubernetesDashboards.ts +3 -3
  315. package/src/utils/gitlab.ts +46 -58
  316. package/src/utils/log.ts +2 -2
  317. package/bin/catci +0 -3
  318. package/bin/catci-dev +0 -3
  319. package/dist/bundles/catci/index.js +0 -41
  320. package/dist/cli/src/apps/catci/catci.d.ts +0 -1
  321. package/dist/cli/src/apps/catci/catci.js +0 -33
  322. package/dist/cli/src/apps/catci/catci.js.map +0 -1
  323. package/dist/cli/src/apps/catci/commands/security/auditDocument.js.map +0 -1
  324. package/dist/cli/src/apps/catci/commands/security/commands.d.ts +0 -2
  325. package/dist/cli/src/apps/catci/commands/security/commands.js +0 -118
  326. package/dist/cli/src/apps/catci/commands/security/commands.js.map +0 -1
  327. package/dist/cli/src/apps/catci/commands/security/createSecurityAuditMergeRequest.js.map +0 -1
  328. package/dist/cli/src/apps/catci/commands/security/evaluateSecurityAudit.js.map +0 -1
  329. package/dist/cli/src/apps/cli/cli.d.ts +0 -2
  330. package/dist/cli/src/apps/cli/cli.js +0 -38
  331. package/dist/cli/src/apps/cli/cli.js.map +0 -1
  332. package/dist/cli/src/apps/cli/commands/cloudSQL/commandRestoreDb.d.ts +0 -3
  333. package/dist/cli/src/apps/cli/commands/cloudSQL/commandRestoreDb.js +0 -130
  334. package/dist/cli/src/apps/cli/commands/cloudSQL/commandRestoreDb.js.map +0 -1
  335. package/dist/cli/src/apps/cli/commands/cloudSQL/index.d.ts +0 -3
  336. package/dist/cli/src/apps/cli/commands/cloudSQL/index.js +0 -14
  337. package/dist/cli/src/apps/cli/commands/cloudSQL/index.js.map +0 -1
  338. package/dist/cli/src/apps/cli/commands/general/index.d.ts +0 -4
  339. package/dist/cli/src/apps/cli/commands/general/index.js +0 -83
  340. package/dist/cli/src/apps/cli/commands/general/index.js.map +0 -1
  341. package/dist/cli/src/apps/cli/commands/general/namespaceAutoCompletion.d.ts +0 -3
  342. package/dist/cli/src/apps/cli/commands/general/namespaceAutoCompletion.js +0 -13
  343. package/dist/cli/src/apps/cli/commands/general/namespaceAutoCompletion.js.map +0 -1
  344. package/dist/cli/src/apps/cli/commands/general/portForward.d.ts +0 -3
  345. package/dist/cli/src/apps/cli/commands/general/portForward.js +0 -47
  346. package/dist/cli/src/apps/cli/commands/general/portForward.js.map +0 -1
  347. package/dist/cli/src/apps/cli/commands/mongodb/index.d.ts +0 -3
  348. package/dist/cli/src/apps/cli/commands/mongodb/index.js +0 -18
  349. package/dist/cli/src/apps/cli/commands/mongodb/index.js.map +0 -1
  350. package/dist/cli/src/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +0 -3
  351. package/dist/cli/src/apps/cli/commands/mongodb/projectMongoDestroyMember.js +0 -96
  352. package/dist/cli/src/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +0 -1
  353. package/dist/cli/src/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +0 -3
  354. package/dist/cli/src/apps/cli/commands/mongodb/projectMongoGetShell.js +0 -38
  355. package/dist/cli/src/apps/cli/commands/mongodb/projectMongoGetShell.js.map +0 -1
  356. package/dist/cli/src/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +0 -3
  357. package/dist/cli/src/apps/cli/commands/mongodb/projectMongoPortForward.js +0 -64
  358. package/dist/cli/src/apps/cli/commands/mongodb/projectMongoPortForward.js.map +0 -1
  359. package/dist/cli/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.d.ts +0 -3
  360. package/dist/cli/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.js +0 -152
  361. package/dist/cli/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.js.map +0 -1
  362. package/dist/cli/src/apps/cli/commands/project/commandCloudSqlProxy.d.ts +0 -3
  363. package/dist/cli/src/apps/cli/commands/project/commandCloudSqlProxy.js +0 -120
  364. package/dist/cli/src/apps/cli/commands/project/commandCloudSqlProxy.js.map +0 -1
  365. package/dist/cli/src/apps/cli/commands/project/commandDeletePods.d.ts +0 -3
  366. package/dist/cli/src/apps/cli/commands/project/commandDeletePods.js +0 -54
  367. package/dist/cli/src/apps/cli/commands/project/commandDeletePods.js.map +0 -1
  368. package/dist/cli/src/apps/cli/commands/project/commandDeleteProject.d.ts +0 -3
  369. package/dist/cli/src/apps/cli/commands/project/commandDeleteProject.js +0 -33
  370. package/dist/cli/src/apps/cli/commands/project/commandDeleteProject.js.map +0 -1
  371. package/dist/cli/src/apps/cli/commands/project/commandEnvVars.d.ts +0 -3
  372. package/dist/cli/src/apps/cli/commands/project/commandEnvVars.js +0 -17
  373. package/dist/cli/src/apps/cli/commands/project/commandEnvVars.js.map +0 -1
  374. package/dist/cli/src/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +0 -3
  375. package/dist/cli/src/apps/cli/commands/project/commandGetMyTotalWorktime.js +0 -11
  376. package/dist/cli/src/apps/cli/commands/project/commandGetMyTotalWorktime.js.map +0 -1
  377. package/dist/cli/src/apps/cli/commands/project/commandGetShell.d.ts +0 -3
  378. package/dist/cli/src/apps/cli/commands/project/commandGetShell.js +0 -37
  379. package/dist/cli/src/apps/cli/commands/project/commandGetShell.js.map +0 -1
  380. package/dist/cli/src/apps/cli/commands/project/commandGitlabCi.d.ts +0 -3
  381. package/dist/cli/src/apps/cli/commands/project/commandGitlabCi.js +0 -88
  382. package/dist/cli/src/apps/cli/commands/project/commandGitlabCi.js.map +0 -1
  383. package/dist/cli/src/apps/cli/commands/project/commandListPods.d.ts +0 -3
  384. package/dist/cli/src/apps/cli/commands/project/commandListPods.js +0 -22
  385. package/dist/cli/src/apps/cli/commands/project/commandListPods.js.map +0 -1
  386. package/dist/cli/src/apps/cli/commands/project/commandNamespace.d.ts +0 -3
  387. package/dist/cli/src/apps/cli/commands/project/commandNamespace.js +0 -12
  388. package/dist/cli/src/apps/cli/commands/project/commandNamespace.js.map +0 -1
  389. package/dist/cli/src/apps/cli/commands/project/commandOpenEnv.d.ts +0 -3
  390. package/dist/cli/src/apps/cli/commands/project/commandOpenEnv.js +0 -26
  391. package/dist/cli/src/apps/cli/commands/project/commandOpenEnv.js.map +0 -1
  392. package/dist/cli/src/apps/cli/commands/project/commandOpenGit.d.ts +0 -3
  393. package/dist/cli/src/apps/cli/commands/project/commandOpenGit.js +0 -9
  394. package/dist/cli/src/apps/cli/commands/project/commandOpenGit.js.map +0 -1
  395. package/dist/cli/src/apps/cli/commands/project/commandOpenLogs.d.ts +0 -3
  396. package/dist/cli/src/apps/cli/commands/project/commandOpenLogs.js +0 -18
  397. package/dist/cli/src/apps/cli/commands/project/commandOpenLogs.js.map +0 -1
  398. package/dist/cli/src/apps/cli/commands/project/commandPauseProject.d.ts +0 -3
  399. package/dist/cli/src/apps/cli/commands/project/commandPauseProject.js +0 -33
  400. package/dist/cli/src/apps/cli/commands/project/commandPauseProject.js.map +0 -1
  401. package/dist/cli/src/apps/cli/commands/project/commandPortForward.d.ts +0 -3
  402. package/dist/cli/src/apps/cli/commands/project/commandPortForward.js +0 -97
  403. package/dist/cli/src/apps/cli/commands/project/commandPortForward.js.map +0 -1
  404. package/dist/cli/src/apps/cli/commands/project/commandRenewToken.d.ts +0 -3
  405. package/dist/cli/src/apps/cli/commands/project/commandRenewToken.js +0 -9
  406. package/dist/cli/src/apps/cli/commands/project/commandRenewToken.js.map +0 -1
  407. package/dist/cli/src/apps/cli/commands/project/commandSecretsClearBackups.d.ts +0 -5
  408. package/dist/cli/src/apps/cli/commands/project/commandSecretsClearBackups.js +0 -25
  409. package/dist/cli/src/apps/cli/commands/project/commandSecretsClearBackups.js.map +0 -1
  410. package/dist/cli/src/apps/cli/commands/project/commandSecurityEvaluate.d.ts +0 -3
  411. package/dist/cli/src/apps/cli/commands/project/commandSecurityEvaluate.js +0 -20
  412. package/dist/cli/src/apps/cli/commands/project/commandSecurityEvaluate.js.map +0 -1
  413. package/dist/cli/src/apps/cli/commands/project/commandSetup.d.ts +0 -3
  414. package/dist/cli/src/apps/cli/commands/project/commandSetup.js +0 -12
  415. package/dist/cli/src/apps/cli/commands/project/commandSetup.js.map +0 -1
  416. package/dist/cli/src/apps/cli/commands/project/commandTriggerCronjob.d.ts +0 -3
  417. package/dist/cli/src/apps/cli/commands/project/commandTriggerCronjob.js +0 -63
  418. package/dist/cli/src/apps/cli/commands/project/commandTriggerCronjob.js.map +0 -1
  419. package/dist/cli/src/apps/cli/commands/project/index.d.ts +0 -3
  420. package/dist/cli/src/apps/cli/commands/project/index.js +0 -54
  421. package/dist/cli/src/apps/cli/commands/project/index.js.map +0 -1
  422. package/dist/cli/src/apps/cli/commands/project/utils/showProjectBanner.d.ts +0 -2
  423. package/dist/cli/src/apps/cli/commands/project/utils/showProjectBanner.js +0 -16
  424. package/dist/cli/src/apps/cli/commands/project/utils/showProjectBanner.js.map +0 -1
  425. package/dist/cli/src/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +0 -3
  426. package/dist/cli/src/apps/cli/commands/theStuffThatReallyMatters/index.js +0 -37
  427. package/dist/cli/src/apps/cli/commands/theStuffThatReallyMatters/index.js.map +0 -1
  428. package/dist/cli/src/apps/cli/verify/index.d.ts +0 -2
  429. package/dist/cli/src/apps/cli/verify/index.js +0 -17
  430. package/dist/cli/src/apps/cli/verify/index.js.map +0 -1
  431. package/dist/cli/src/catci.d.ts +0 -1
  432. package/dist/cli/src/catci.js +0 -7
  433. package/dist/cli/src/catci.js.map +0 -1
  434. package/src/apps/catci/catci.ts +0 -26
  435. package/src/apps/catci/commands/security/commands.ts +0 -161
  436. package/src/apps/cli/cli.ts +0 -43
  437. package/src/apps/cli/commands/cloudSQL/commandRestoreDb.ts +0 -136
  438. package/src/apps/cli/commands/cloudSQL/index.ts +0 -7
  439. package/src/apps/cli/commands/general/index.ts +0 -90
  440. package/src/apps/cli/commands/general/namespaceAutoCompletion.ts +0 -7
  441. package/src/apps/cli/commands/general/portForward.ts +0 -48
  442. package/src/apps/cli/commands/mongodb/index.ts +0 -10
  443. package/src/apps/cli/commands/mongodb/projectMongoDestroyMember.ts +0 -132
  444. package/src/apps/cli/commands/mongodb/projectMongoGetShell.ts +0 -42
  445. package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +0 -64
  446. package/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.ts +0 -206
  447. package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +0 -194
  448. package/src/apps/cli/commands/project/commandDeletePods.ts +0 -48
  449. package/src/apps/cli/commands/project/commandDeleteProject.ts +0 -33
  450. package/src/apps/cli/commands/project/commandEnvVars.ts +0 -18
  451. package/src/apps/cli/commands/project/commandGetMyTotalWorktime.ts +0 -14
  452. package/src/apps/cli/commands/project/commandGetShell.ts +0 -36
  453. package/src/apps/cli/commands/project/commandGitlabCi.ts +0 -115
  454. package/src/apps/cli/commands/project/commandListPods.ts +0 -20
  455. package/src/apps/cli/commands/project/commandNamespace.ts +0 -14
  456. package/src/apps/cli/commands/project/commandOpenEnv.ts +0 -22
  457. package/src/apps/cli/commands/project/commandOpenGit.ts +0 -12
  458. package/src/apps/cli/commands/project/commandOpenLogs.ts +0 -21
  459. package/src/apps/cli/commands/project/commandPauseProject.ts +0 -33
  460. package/src/apps/cli/commands/project/commandPortForward.ts +0 -91
  461. package/src/apps/cli/commands/project/commandRenewToken.ts +0 -12
  462. package/src/apps/cli/commands/project/commandSecretsClearBackups.ts +0 -26
  463. package/src/apps/cli/commands/project/commandSecurityEvaluate.ts +0 -26
  464. package/src/apps/cli/commands/project/commandSetup.ts +0 -14
  465. package/src/apps/cli/commands/project/commandTriggerCronjob.ts +0 -62
  466. package/src/apps/cli/commands/project/index.ts +0 -56
  467. package/src/apps/cli/commands/project/utils/showProjectBanner.ts +0 -11
  468. package/src/apps/cli/commands/theStuffThatReallyMatters/index.ts +0 -32
  469. package/src/apps/cli/verify/index.ts +0 -14
  470. package/src/catci.ts +0 -3
  471. /package/dist/cli/src/{apps/catci/commands/security → security}/auditDocument.d.ts +0 -0
  472. /package/dist/cli/src/{apps/catci/commands/security → security}/auditDocument.js +0 -0
  473. /package/dist/cli/src/{apps/catci/commands/security → security}/createSecurityAuditMergeRequest.d.ts +0 -0
  474. /package/dist/cli/src/{apps/catci/commands/security → security}/createSecurityAuditMergeRequest.js +0 -0
  475. /package/dist/cli/src/{apps/catci/commands/security → security}/evaluateSecurityAudit.d.ts +0 -0
  476. /package/dist/cli/src/{apps/catci/commands/security → security}/evaluateSecurityAudit.js +0 -0
  477. /package/dist/cli/src/{apps/catci/commands/security → security}/topics.json +0 -0
  478. /package/src/{apps/catci/commands/security → security}/auditDocument.ts +0 -0
  479. /package/src/{apps/catci/commands/security → security}/createSecurityAuditMergeRequest.ts +0 -0
  480. /package/src/{apps/catci/commands/security → security}/evaluateSecurityAudit.ts +0 -0
  481. /package/src/{apps/catci/commands/security → security}/topics.json +0 -0
@@ -5,7 +5,7 @@ import {
5
5
  isOfDeployType,
6
6
  } from "@catladder/pipeline";
7
7
 
8
- import type { CommandInstance } from "vorpal";
8
+ import type { IO } from "../../../../../core/types";
9
9
  import { upsertGcloudArtifactsRegistry } from "../../../../../gcloud/artifactsRegistry";
10
10
  import { getCloudRunDomainSuffix } from "../../../../../gcloud/cloudRun/getCloudRunDomainSuffix";
11
11
  import { enableGCloudServices } from "../../../../../gcloud/enableServices";
@@ -13,7 +13,7 @@ import { upsertGcloudServiceAccountAndSaveSecret } from "../../../../../gcloud/s
13
13
  import { upsertAllVariables } from "../../../../../utils/gitlab";
14
14
 
15
15
  export const setupCloudRun = async (
16
- instance: CommandInstance,
16
+ instance: IO,
17
17
  context: ComponentContext,
18
18
  ) => {
19
19
  if (!isOfDeployType(context.deploy?.config, "google-cloudrun")) {
@@ -1,15 +1,12 @@
1
1
  import type { ComponentContext } from "@catladder/pipeline";
2
2
  import { isOfDeployType } from "@catladder/pipeline";
3
- import type { CommandInstance } from "vorpal";
3
+ import type { IO } from "../../../../../core/types";
4
4
  import { setupCloudRun } from "./setupCloudRun";
5
5
 
6
6
  import { setupKubernetes } from "./setupKubernetes";
7
7
  import { logSection } from "./logSection";
8
8
 
9
- export const setupContext = async (
10
- instance: CommandInstance,
11
- context: ComponentContext,
12
- ) => {
9
+ export const setupContext = async (instance: IO, context: ComponentContext) => {
13
10
  await logSection(
14
11
  instance,
15
12
  "setting up " + context.env + ":" + context.name,
@@ -3,7 +3,7 @@ import {
3
3
  getFullKubernetesClusterName,
4
4
  isOfDeployType,
5
5
  } from "@catladder/pipeline";
6
- import type { CommandInstance } from "vorpal";
6
+ import type { IO } from "../../../../../core/types";
7
7
  import { exec } from "child-process-promise";
8
8
  import { connectToCluster } from "../../../../../utils/cluster";
9
9
  import {
@@ -14,7 +14,7 @@ import {
14
14
  import ensureNamespace from "../utils/ensureNamespace";
15
15
 
16
16
  export const setupKubernetes = async (
17
- instance: CommandInstance,
17
+ instance: IO,
18
18
  context: ComponentContext,
19
19
  ) => {
20
20
  const deployConfig = context.deploy?.config;
@@ -1,9 +1,9 @@
1
- import type { CommandInstance } from "vorpal";
1
+ import type { IO } from "../../../../../core/types";
2
2
  import { doGitlabRequest, getProjectInfo } from "../../../../../utils/gitlab";
3
3
 
4
4
  const catladderTopic = "catladder";
5
5
 
6
- export const setupTopic = async (instance: CommandInstance) => {
6
+ export const setupTopic = async (instance: IO) => {
7
7
  const { id: projectId } = await getProjectInfo(instance);
8
8
 
9
9
  const { topics } = await doGitlabRequest(instance, `projects/${projectId}`);
@@ -10,7 +10,19 @@ import {
10
10
  connectToCluster,
11
11
  getCurrentConnectedClusterName,
12
12
  } from "../../../../../utils/cluster";
13
- export default async function (envComponent: string) {
13
+ import type { IO } from "../../../../../core/types";
14
+
15
+ /**
16
+ * Ensures the user is connected to the correct Kubernetes cluster for the given envComponent.
17
+ * If already connected, does nothing. If not, prompts for confirmation to switch (in interactive mode).
18
+ *
19
+ * Accepts an IO instance for logging and prompting.
20
+ * Also works with Vorpal's CommandInstance via .call(this, envComponent) for backward compatibility.
21
+ */
22
+ export async function ensureCluster(
23
+ io: IO,
24
+ envComponent: string,
25
+ ): Promise<void> {
14
26
  const { env, componentName } = parseChoice(envComponent);
15
27
  const context = await getPipelineContextByChoice(env, componentName);
16
28
  if (!isOfDeployType(context.deploy?.config, "kubernetes")) {
@@ -20,21 +32,16 @@ export default async function (envComponent: string) {
20
32
  const connectedClusterName = await getCurrentConnectedClusterName();
21
33
 
22
34
  if (cluster !== connectedClusterName) {
23
- this.log(
24
- `you are currently connected to cluster '${connectedClusterName}'`,
35
+ io.log(`you are currently connected to cluster '${connectedClusterName}'`);
36
+ io.log(`but the project requires cluster '${cluster}'`);
37
+ const shouldContinue = await io.confirm(
38
+ `Do you want to connect to '${cluster}'?`,
25
39
  );
26
- this.log(`but the project requires cluster '${cluster}'`);
27
- const { shouldContinue } = await this.prompt({
28
- type: "confirm",
29
- name: "shouldContinue",
30
- default: true,
31
- message: `Do you want to connect to '${cluster}'?`,
32
- });
33
40
  if (!shouldContinue) {
34
- this.log("abort");
41
+ io.log("abort");
35
42
  } else {
36
43
  await connectToCluster(cluster);
37
- this.log(`connected to cluster '${cluster}'`);
44
+ io.log(`connected to cluster '${cluster}'`);
38
45
  }
39
46
  }
40
47
  }
@@ -1,3 +1,4 @@
1
+ import type { IO } from "../../../core/types";
1
2
  import {
2
3
  getPreference,
3
4
  hasPreference,
@@ -5,16 +6,16 @@ import {
5
6
  } from "../../../utils/preferences";
6
7
 
7
8
  const KEY = "googleAuthUserNumber";
8
- export const getGoogleAuthUserNumber = async function () {
9
+ export const getGoogleAuthUserNumber = async (io: IO) => {
9
10
  if (!(await hasPreference(KEY))) {
10
- this.log(
11
+ io.log(
11
12
  "Please type in your google auth user number (0 if you have only one google account or maybe 1 if you have multiple)",
12
13
  );
13
14
 
14
- const { authUserNumber } = await this.prompt({
15
+ const authUserNumber = await io.promptDirect({
15
16
  type: "number",
16
17
  name: "authUserNumber",
17
- default: "0",
18
+ default: 0,
18
19
  message: "Auth user ",
19
20
  });
20
21
  await setPreference(KEY, authUserNumber);
package/src/catenv.ts CHANGED
@@ -1,24 +1,30 @@
1
+ import { Command } from "commander";
1
2
  import catenv from "./apps/catenv/catenv";
2
-
3
3
  import { parseChoice } from "./config/parseChoice";
4
+ import packageInfos from "./packageInfos";
4
5
 
5
- const args = process.argv.slice(2);
6
+ const program = new Command();
6
7
 
7
- const helpFlags = ["--help", "-h", "help"];
8
- if (args.some((arg) => helpFlags.includes(arg))) {
9
- const docLink =
10
- "https://git.panter.ch/catladder/catladder/-/blob/main/docs/1_VARS.md";
11
- console.log(
12
- `\nUsage: catenv [env|env:component] [-v|--verbose]\n\nEnv variable and catenv documentation:\n${docLink}`,
8
+ program
9
+ .name("catenv")
10
+ .description("Environment variable and pipeline generation via direnv")
11
+ .version(packageInfos.version)
12
+ .argument("[envComponent]", "env or env:component")
13
+ .option("-v, --verbose", "verbose output")
14
+ .option("-p, --print-variables", "print variables")
15
+ .action(
16
+ (
17
+ envComponent: string | undefined,
18
+ opts: { verbose?: boolean; printVariables?: boolean },
19
+ ) => {
20
+ catenv(envComponent ? parseChoice(envComponent) : null, {
21
+ verbose: opts.verbose ?? false,
22
+ printVariables: opts.printVariables ?? false,
23
+ }).then(() => {
24
+ // we have to exit manually, because we have some file watches
25
+ process.exit();
26
+ });
27
+ },
13
28
  );
14
- process.exit(0);
15
- }
16
-
17
- const verbose = args.some((arg) => arg === "-v" || arg === "--verbose");
18
- // choise arg is deprecated and will be removed in the future
19
- const choiceArg = args.find((arg) => arg !== "-v" && arg !== "--verbose");
20
29
 
21
- catenv(choiceArg ? parseChoice(choiceArg) : null, { verbose }).then(() => {
22
- // we have to exit manually, because we have some file watches
23
- process.exit();
24
- });
30
+ program.parse();
package/src/cli.ts CHANGED
@@ -1,3 +1,214 @@
1
- import cli from "./apps/cli/cli";
1
+ import { Command } from "commander";
2
+ import packageInfos from "./packageInfos";
3
+ import { stopAllPortForwards } from "./utils/portForwards";
4
+ import { createTerminalContext } from "./adapters/terminal";
5
+ import type { CommandDef } from "./core/types";
6
+ import {
7
+ getCompletions,
8
+ generateZshCompletionScript,
9
+ installCompletions,
10
+ uninstallCompletions,
11
+ } from "./completion";
2
12
 
3
- cli();
13
+ // Import all commands
14
+ import * as commands from "./commands";
15
+
16
+ const program = new Command();
17
+
18
+ program
19
+ .name("catladder")
20
+ .description("Panter CLI tool for cloud CI/CD and DevOps")
21
+ .version(packageInfos.version)
22
+ .option("-y, --yes", "skip all confirmation prompts");
23
+
24
+ // Collect all command defs for completion
25
+ const allCommandDefs: CommandDef[] = [];
26
+
27
+ // Cache for intermediate subcommand groups (e.g., "project", "project cloudsql")
28
+ const subcommandCache = new Map<string, Command>();
29
+
30
+ /**
31
+ * Get or create a chain of nested subcommands.
32
+ * E.g., for ["project", "cloudsql"], ensures program.command("project").command("cloudsql") exists.
33
+ */
34
+ function getOrCreateParent(parts: string[]): Command {
35
+ if (parts.length === 0) return program;
36
+
37
+ const key = parts.join(" ");
38
+ if (subcommandCache.has(key)) return subcommandCache.get(key)!;
39
+
40
+ const parent = getOrCreateParent(parts.slice(0, -1));
41
+ const cmd = parent.command(parts[parts.length - 1]);
42
+ subcommandCache.set(key, cmd);
43
+ return cmd;
44
+ }
45
+
46
+ /**
47
+ * Register a CommandDef with Commander.js.
48
+ * - Command name can contain spaces for nesting (e.g., "project cloudsql proxy")
49
+ * - Inputs with `positional: true` become Commander positional args
50
+ * - Other inputs become optional --flags
51
+ * - --inputs accepts JSON for programmatic use
52
+ */
53
+ function registerCommand(def: CommandDef): void {
54
+ allCommandDefs.push(def);
55
+
56
+ // Separate positional inputs from flag inputs
57
+ const positionalInputs: [string, (typeof def.inputs)[string]][] = [];
58
+ const flagInputs: [string, (typeof def.inputs)[string]][] = [];
59
+
60
+ for (const [name, inputDef] of Object.entries(def.inputs)) {
61
+ if (inputDef.positional) {
62
+ positionalInputs.push([name, inputDef]);
63
+ } else {
64
+ flagInputs.push([name, inputDef]);
65
+ }
66
+ }
67
+
68
+ // Split name into parent groups + leaf command
69
+ const nameParts = def.name.split(" ");
70
+ const parentParts = nameParts.slice(0, -1);
71
+ const leafName = nameParts[nameParts.length - 1];
72
+
73
+ // Build leaf command string with positional args
74
+ let cmdStr = leafName;
75
+ for (const [name] of positionalInputs) {
76
+ cmdStr += ` [${name}]`;
77
+ }
78
+
79
+ const parent = getOrCreateParent(parentParts);
80
+ const cmd = parent.command(cmdStr).description(def.description);
81
+
82
+ // Add --flag for each non-positional input
83
+ for (const [name, inputDef] of flagInputs) {
84
+ const flagName = name.replace(/([A-Z])/g, "-$1").toLowerCase();
85
+ const desc = inputDef.message.replace(/\s*🤔\s*$/, "").trim();
86
+ if (inputDef.type === "boolean") {
87
+ cmd.option(`--${flagName}`, desc);
88
+ cmd.option(`--no-${flagName}`, `negate: ${desc}`);
89
+ } else {
90
+ cmd.option(`--${flagName} <value>`, desc);
91
+ }
92
+ }
93
+
94
+ // Add --inputs for JSON input
95
+ cmd.option("--inputs <json>", "JSON object with input values");
96
+
97
+ cmd.action(async (...rawArgs: any[]) => {
98
+ // Commander passes positional args first, then options object, then the Command
99
+ const opts = rawArgs[rawArgs.length - 2];
100
+
101
+ // Parse positional args into cliOptions
102
+ const cliOptions: Record<string, unknown> = {};
103
+ positionalInputs.forEach(([name], i) => {
104
+ if (rawArgs[i] !== undefined) {
105
+ cliOptions[name] = rawArgs[i];
106
+ }
107
+ });
108
+
109
+ // Parse CLI flag overrides
110
+ for (const [name, inputDef] of flagInputs) {
111
+ const flagName = name.replace(/([A-Z])/g, "-$1").toLowerCase();
112
+ const camelName = flagName.replace(/-([a-z])/g, (_, c) =>
113
+ c.toUpperCase(),
114
+ );
115
+ if (opts[camelName] !== undefined) {
116
+ let value = opts[camelName];
117
+ if (inputDef.type === "number" && typeof value === "string") {
118
+ value = Number(value);
119
+ }
120
+ cliOptions[name] = value;
121
+ }
122
+ }
123
+
124
+ // Parse --inputs JSON
125
+ let jsonInputs: Record<string, unknown> = {};
126
+ if (opts.inputs) {
127
+ try {
128
+ jsonInputs = JSON.parse(opts.inputs);
129
+ } catch {
130
+ console.error("Error: --inputs must be valid JSON");
131
+ process.exit(1);
132
+ }
133
+ }
134
+
135
+ const ctx = createTerminalContext(def, {
136
+ cliOptions,
137
+ jsonInputs,
138
+ yes: program.opts().yes,
139
+ });
140
+
141
+ try {
142
+ await def.execute(ctx);
143
+ } catch (err: any) {
144
+ if (err.name === "MissingInputError") {
145
+ console.error(`\n${err.message}\n`);
146
+ process.exit(1);
147
+ }
148
+ throw err;
149
+ }
150
+ });
151
+ }
152
+
153
+ // Register all commands
154
+ for (const cmd of Object.values(commands)) {
155
+ if (cmd && typeof cmd === "object" && "name" in cmd && "execute" in cmd) {
156
+ registerCommand(cmd as CommandDef);
157
+ }
158
+ }
159
+
160
+ // Hidden __complete command for shell completion
161
+ program
162
+ .command("__complete", { hidden: true })
163
+ .argument("[words]", "words typed so far")
164
+ .argument("[cursor]", "word at cursor")
165
+ .action(async (wordsStr: string | undefined, cursor: string | undefined) => {
166
+ const words = wordsStr ? wordsStr.split(" ").filter(Boolean) : [];
167
+ const cursorWord = cursor ?? "";
168
+ try {
169
+ const completions = await getCompletions(
170
+ allCommandDefs,
171
+ words,
172
+ cursorWord,
173
+ );
174
+ for (const c of completions) {
175
+ console.log(c);
176
+ }
177
+ } catch {
178
+ // Silently fail -- completion should never break the shell
179
+ }
180
+ process.exit(0);
181
+ });
182
+
183
+ // completion commands
184
+ const completionCmd = program
185
+ .command("completion")
186
+ .description("shell completion setup");
187
+
188
+ completionCmd
189
+ .command("zsh")
190
+ .description("output zsh completion script")
191
+ .action(() => {
192
+ console.log(generateZshCompletionScript());
193
+ });
194
+
195
+ completionCmd
196
+ .command("install")
197
+ .description("install shell completions into your .zshrc")
198
+ .action(async () => {
199
+ await installCompletions();
200
+ });
201
+
202
+ completionCmd
203
+ .command("uninstall")
204
+ .description("remove shell completions from your .zshrc")
205
+ .action(async () => {
206
+ await uninstallCompletions();
207
+ });
208
+
209
+ // Cleanup on exit
210
+ process.on("exit", () => {
211
+ stopAllPortForwards();
212
+ });
213
+
214
+ program.parse();
@@ -0,0 +1,105 @@
1
+ import { defineCommand } from "../../core/defineCommand";
2
+ import { spawnCopyDb } from "../../gcloud/cloudSql/copyDb";
3
+ import type { CloudSqlBackgroundProxy } from "../../gcloud/cloudSql/startProxy";
4
+ import { startCloudSqlProxyInBackground } from "../../gcloud/cloudSql/startProxy";
5
+
6
+ export const commandRestoreDb = defineCommand({
7
+ name: "cloudsql restore-db",
8
+ description: "restore a db from one source to another target",
9
+ group: "cloudSQL",
10
+ inputs: {
11
+ source: {
12
+ type: "string",
13
+ message: "Source instance (connection string or 'local')? 🤔 ",
14
+ },
15
+ sourceLocalPort: {
16
+ type: "number",
17
+ message: "Local Port for source? 🤔 ",
18
+ default: 5432,
19
+ },
20
+ sourceUsername: {
21
+ type: "string",
22
+ message: "Source Username? 🤔 ",
23
+ default: "postgres",
24
+ },
25
+ sourcePassword: { type: "string", message: "Source Password? 🤔 " },
26
+ sourceDbName: { type: "string", message: "Source DB name? 🤔 " },
27
+ target: {
28
+ type: "string",
29
+ message: "Target INSTANCE (connection string or 'local')? 🤔 ",
30
+ },
31
+ targetLocalPort: {
32
+ type: "number",
33
+ message: "Local Port for target? 🤔 ",
34
+ default: 5432,
35
+ },
36
+ targetUsername: {
37
+ type: "string",
38
+ message: "Target Username? 🤔 ",
39
+ default: "postgres",
40
+ },
41
+ targetPassword: { type: "string", message: "Target Password? 🤔 " },
42
+ targetDbName: { type: "string", message: "Target DB name? 🤔 " },
43
+ },
44
+ execute: async (ctx) => {
45
+ const source = await ctx.get("source");
46
+
47
+ let sourceProxy: CloudSqlBackgroundProxy;
48
+ let targetProxy: CloudSqlBackgroundProxy;
49
+ let sourcePort: number;
50
+ let targetPort: number;
51
+
52
+ if (source === "local") {
53
+ sourcePort = await ctx.get("sourceLocalPort");
54
+ } else {
55
+ sourcePort = 54399;
56
+ sourceProxy = await startCloudSqlProxyInBackground({
57
+ instanceName: source,
58
+ localPort: sourcePort,
59
+ });
60
+ }
61
+
62
+ const sourceUsername = await ctx.get("sourceUsername");
63
+ const sourcePassword = await ctx.get("sourcePassword");
64
+ const sourceDbName = await ctx.get("sourceDbName");
65
+
66
+ const target = await ctx.get("target");
67
+
68
+ if (target === "local") {
69
+ targetPort = await ctx.get("targetLocalPort");
70
+ } else {
71
+ targetPort = 54499;
72
+ targetProxy = await startCloudSqlProxyInBackground({
73
+ instanceName: target,
74
+ localPort: targetPort,
75
+ });
76
+ }
77
+
78
+ const targetUsername = await ctx.get("targetUsername");
79
+ const targetPassword = await ctx.get("targetPassword");
80
+ const targetDbName = await ctx.get("targetDbName");
81
+
82
+ const shouldContinue = await ctx.confirm(
83
+ `This will drop ${target}/${targetDbName} and replace it with ${source}/${sourceDbName}. Continue? 🤔 `,
84
+ );
85
+ if (!shouldContinue) {
86
+ return;
87
+ }
88
+
89
+ try {
90
+ await spawnCopyDb({
91
+ targetPassword,
92
+ targetPort,
93
+ targetUsername,
94
+ sourceUsername,
95
+ sourcePassword,
96
+ sourcePort,
97
+ sourceDbName,
98
+ targetDbName,
99
+ });
100
+ } finally {
101
+ sourceProxy?.stop();
102
+ targetProxy?.stop();
103
+ }
104
+ },
105
+ });
@@ -0,0 +1,18 @@
1
+ import fetch from "node-fetch";
2
+ import { defineCommand } from "../../core/defineCommand";
3
+
4
+ export const commandDadjoke = defineCommand({
5
+ name: "fun dadjoke",
6
+ description: "something for jonas.",
7
+ group: "fun",
8
+ inputs: {},
9
+ execute: async (ctx) => {
10
+ const result = await fetch("https://icanhazdadjoke.com/", {
11
+ headers: { Accept: "text/plain" },
12
+ });
13
+ const text = await result.text();
14
+ ctx.log("");
15
+ ctx.log(text);
16
+ ctx.log("");
17
+ },
18
+ });
@@ -0,0 +1,14 @@
1
+ import { spawn } from "child-process-promise";
2
+ import { defineCommand } from "../../core/defineCommand";
3
+
4
+ export const commandStarwars = defineCommand({
5
+ name: "fun starwars",
6
+ description: "Long time ago... in a galaxy far far away...",
7
+ group: "fun",
8
+ inputs: {},
9
+ execute: async () => {
10
+ await spawn("nc", ["towel.blinkenlights.nl", "23"], {
11
+ stdio: ["pipe", "inherit", "pipe"],
12
+ });
13
+ },
14
+ });
@@ -0,0 +1,12 @@
1
+ import { defineCommand } from "../../core/defineCommand";
2
+ import { getCurrentContext } from "../../utils/cluster";
3
+
4
+ export const commandKubeCurrentContext = defineCommand({
5
+ name: "kube current-context",
6
+ description: "show current kubernetes context",
7
+ group: "general",
8
+ inputs: {},
9
+ execute: async (ctx) => {
10
+ ctx.log(await getCurrentContext());
11
+ },
12
+ });
@@ -0,0 +1,32 @@
1
+ import { defineCommand } from "../../core/defineCommand";
2
+ import { getk8sApi } from "../../k8sApi";
3
+
4
+ import { getShell } from "../../utils/shell";
5
+
6
+ export const commandKubeGetShell = defineCommand({
7
+ name: "kube get-shell",
8
+ description: "get a shell to a pod in the environment",
9
+ group: "general",
10
+ inputs: {
11
+ namespace: {
12
+ type: "string",
13
+ message: "kubernetes namespace",
14
+ positional: true,
15
+ },
16
+ podName: {
17
+ type: "string",
18
+ message: "Which pod? 🤔",
19
+ choices: async (ctx) => {
20
+ const namespace = await ctx.get("namespace");
21
+ const k8sApi = getk8sApi();
22
+ const res = await k8sApi.listNamespacedPod(namespace);
23
+ return res.body.items.map((i: any) => i.metadata.name);
24
+ },
25
+ },
26
+ },
27
+ execute: async (ctx) => {
28
+ const namespace = await ctx.get("namespace");
29
+ const podName = await ctx.get("podName");
30
+ await getShell(namespace, podName);
31
+ },
32
+ });
@@ -0,0 +1,15 @@
1
+ import { defineCommand } from "../../core/defineCommand";
2
+ import { getk8sApi } from "../../k8sApi";
3
+
4
+ export const commandKubeListNamespaces = defineCommand({
5
+ name: "kube list-namespaces",
6
+ description: "list all namespaces",
7
+ group: "general",
8
+ inputs: {},
9
+ execute: async (ctx) => {
10
+ const k8sApi = getk8sApi();
11
+ const res = await k8sApi.listNamespace();
12
+ const namespaces = res.body.items.map((n: any) => n.metadata.name);
13
+ ctx.log(namespaces.join("\n"));
14
+ },
15
+ });
@@ -0,0 +1,21 @@
1
+ import { defineCommand } from "../../core/defineCommand";
2
+ import { getk8sApi } from "../../k8sApi";
3
+
4
+ export const commandKubeListPods = defineCommand({
5
+ name: "kube list-pods",
6
+ description: "list all pods of namespace",
7
+ group: "general",
8
+ inputs: {
9
+ namespace: {
10
+ type: "string",
11
+ message: "kubernetes namespace",
12
+ positional: true,
13
+ },
14
+ },
15
+ execute: async (ctx) => {
16
+ const namespace = await ctx.get("namespace");
17
+ const k8sApi = getk8sApi();
18
+ const res = await k8sApi.listNamespacedPod(namespace);
19
+ ctx.log(res.body.items.map((n: any) => n.metadata.name).join("\n"));
20
+ },
21
+ });
@@ -0,0 +1,21 @@
1
+ import { defineCommand } from "../../core/defineCommand";
2
+ import { getk8sApi } from "../../k8sApi";
3
+
4
+ export const commandKubeListSecrets = defineCommand({
5
+ name: "kube list-secrets",
6
+ description: "show secrets",
7
+ group: "general",
8
+ inputs: {
9
+ namespace: {
10
+ type: "string",
11
+ message: "kubernetes namespace",
12
+ positional: true,
13
+ },
14
+ },
15
+ execute: async (ctx) => {
16
+ const namespace = await ctx.get("namespace");
17
+ const k8sApi = getk8sApi();
18
+ const res = await k8sApi.listNamespacedSecret(namespace);
19
+ ctx.log(res.body.items.map((n: any) => n.metadata.name).join("\n"));
20
+ },
21
+ });