@catladder/cli 3.48.0 → 4.0.1
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.
- package/README.md +23 -5
- package/dist/bundles/catenv/index.js +3 -3
- package/dist/bundles/cli/index.js +34 -30
- package/dist/cli/src/adapters/baseContext.d.ts +22 -0
- package/dist/cli/src/adapters/baseContext.js +40 -0
- package/dist/cli/src/adapters/baseContext.js.map +1 -0
- package/dist/cli/src/adapters/programmatic.d.ts +26 -0
- package/dist/cli/src/adapters/programmatic.js +67 -0
- package/dist/cli/src/adapters/programmatic.js.map +1 -0
- package/dist/cli/src/adapters/terminal.d.ts +28 -0
- package/dist/cli/src/adapters/terminal.js +205 -0
- package/dist/cli/src/adapters/terminal.js.map +1 -0
- package/dist/cli/src/apps/catenv/catenv.d.ts +1 -0
- package/dist/cli/src/apps/catenv/catenv.js +1 -1
- package/dist/cli/src/apps/catenv/catenv.js.map +1 -1
- package/dist/cli/src/apps/catenv/printVariables.js +0 -10
- package/dist/cli/src/apps/catenv/printVariables.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/commandConfigSecrets.d.ts +2 -5
- package/dist/cli/src/apps/cli/commands/project/commandConfigSecrets.js +6 -21
- package/dist/cli/src/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/index.d.ts +2 -2
- package/dist/cli/src/apps/cli/commands/project/setup/index.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/logSection.d.ts +2 -2
- package/dist/cli/src/apps/cli/commands/project/setup/logSection.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupAccessTokens.d.ts +2 -2
- package/dist/cli/src/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupAgents.d.ts +2 -2
- package/dist/cli/src/apps/cli/commands/project/setup/setupAgents.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupCloudRun.d.ts +2 -2
- package/dist/cli/src/apps/cli/commands/project/setup/setupCloudRun.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupContext.d.ts +2 -2
- package/dist/cli/src/apps/cli/commands/project/setup/setupContext.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupKubernetes.d.ts +2 -2
- package/dist/cli/src/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupTopic.d.ts +2 -2
- package/dist/cli/src/apps/cli/commands/project/setup/setupTopic.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/utils/ensureCluster.d.ts +9 -1
- package/dist/cli/src/apps/cli/commands/project/utils/ensureCluster.js +15 -14
- package/dist/cli/src/apps/cli/commands/project/utils/ensureCluster.js.map +1 -1
- package/dist/cli/src/apps/cli/utils/getGoogleAuthUserNumber.d.ts +2 -1
- package/dist/cli/src/apps/cli/utils/getGoogleAuthUserNumber.js +4 -6
- package/dist/cli/src/apps/cli/utils/getGoogleAuthUserNumber.js.map +1 -1
- package/dist/cli/src/catenv.js +14 -16
- package/dist/cli/src/catenv.js.map +1 -1
- package/dist/cli/src/cli.js +186 -2
- package/dist/cli/src/cli.js.map +1 -1
- package/dist/cli/src/commands/cloudSQL/commandRestoreDb.d.ts +46 -0
- package/dist/cli/src/commands/cloudSQL/commandRestoreDb.js +111 -0
- package/dist/cli/src/commands/cloudSQL/commandRestoreDb.js.map +1 -0
- package/dist/cli/src/commands/fun/commandDadjoke.d.ts +1 -0
- package/dist/cli/src/commands/fun/commandDadjoke.js +30 -0
- package/dist/cli/src/commands/fun/commandDadjoke.js.map +1 -0
- package/dist/cli/src/commands/fun/commandStarwars.d.ts +1 -0
- package/dist/cli/src/commands/fun/commandStarwars.js +19 -0
- package/dist/cli/src/commands/fun/commandStarwars.js.map +1 -0
- package/dist/cli/src/commands/general/commandKubeCurrentContext.d.ts +1 -0
- package/dist/cli/src/commands/general/commandKubeCurrentContext.js +17 -0
- package/dist/cli/src/commands/general/commandKubeCurrentContext.js.map +1 -0
- package/dist/cli/src/commands/general/commandKubeGetShell.d.ts +12 -0
- package/dist/cli/src/commands/general/commandKubeGetShell.js +36 -0
- package/dist/cli/src/commands/general/commandKubeGetShell.js.map +1 -0
- package/dist/cli/src/commands/general/commandKubeListNamespaces.d.ts +1 -0
- package/dist/cli/src/commands/general/commandKubeListNamespaces.js +20 -0
- package/dist/cli/src/commands/general/commandKubeListNamespaces.js.map +1 -0
- package/dist/cli/src/commands/general/commandKubeListPods.d.ts +7 -0
- package/dist/cli/src/commands/general/commandKubeListPods.js +26 -0
- package/dist/cli/src/commands/general/commandKubeListPods.js.map +1 -0
- package/dist/cli/src/commands/general/commandKubeListSecrets.d.ts +7 -0
- package/dist/cli/src/commands/general/commandKubeListSecrets.js +26 -0
- package/dist/cli/src/commands/general/commandKubeListSecrets.js.map +1 -0
- package/dist/cli/src/commands/general/commandKubePortForward.d.ts +20 -0
- package/dist/cli/src/commands/general/commandKubePortForward.js +46 -0
- package/dist/cli/src/commands/general/commandKubePortForward.js.map +1 -0
- package/dist/cli/src/commands/general/commandKubeStopPortforward.d.ts +7 -0
- package/dist/cli/src/commands/general/commandKubeStopPortforward.js +24 -0
- package/dist/cli/src/commands/general/commandKubeStopPortforward.js.map +1 -0
- package/dist/cli/src/commands/index.d.ts +37 -0
- package/dist/cli/src/commands/index.js +283 -0
- package/dist/cli/src/commands/index.js.map +1 -0
- package/dist/cli/src/commands/mongodb/commandMongoDestroyMember.d.ts +16 -0
- package/dist/cli/src/commands/mongodb/commandMongoDestroyMember.js +89 -0
- package/dist/cli/src/commands/mongodb/commandMongoDestroyMember.js.map +1 -0
- package/dist/cli/src/commands/mongodb/commandMongoGetShell.d.ts +16 -0
- package/dist/cli/src/commands/mongodb/commandMongoGetShell.js +36 -0
- package/dist/cli/src/commands/mongodb/commandMongoGetShell.js.map +1 -0
- package/dist/cli/src/commands/mongodb/commandMongoPortForward.d.ts +21 -0
- package/dist/cli/src/commands/mongodb/commandMongoPortForward.js +65 -0
- package/dist/cli/src/commands/mongodb/commandMongoPortForward.js.map +1 -0
- package/dist/cli/src/commands/project/commandCloudSqlProxy.d.ts +13 -0
- package/dist/cli/src/commands/project/commandCloudSqlProxy.js +127 -0
- package/dist/cli/src/commands/project/commandCloudSqlProxy.js.map +1 -0
- package/dist/cli/src/commands/project/commandConfigSecrets.d.ts +9 -0
- package/dist/cli/src/commands/project/commandConfigSecrets.js +36 -0
- package/dist/cli/src/commands/project/commandConfigSecrets.js.map +1 -0
- package/dist/cli/src/commands/project/commandDeletePods.d.ts +13 -0
- package/dist/cli/src/commands/project/commandDeletePods.js +49 -0
- package/dist/cli/src/commands/project/commandDeletePods.js.map +1 -0
- package/dist/cli/src/commands/project/commandDeleteProject.d.ts +8 -0
- package/dist/cli/src/commands/project/commandDeleteProject.js +41 -0
- package/dist/cli/src/commands/project/commandDeleteProject.js.map +1 -0
- package/dist/cli/src/commands/project/commandEnvVars.d.ts +8 -0
- package/dist/cli/src/commands/project/commandEnvVars.js +32 -0
- package/dist/cli/src/commands/project/commandEnvVars.js.map +1 -0
- package/dist/cli/src/commands/project/commandGetMyTotalWorktime.d.ts +1 -0
- package/dist/cli/src/commands/project/commandGetMyTotalWorktime.js +19 -0
- package/dist/cli/src/commands/project/commandGetMyTotalWorktime.js.map +1 -0
- package/dist/cli/src/commands/project/commandGetShell.d.ts +13 -0
- package/dist/cli/src/commands/project/commandGetShell.js +41 -0
- package/dist/cli/src/commands/project/commandGetShell.js.map +1 -0
- package/dist/cli/src/commands/project/commandGitlabCi.d.ts +14 -0
- package/dist/cli/src/commands/project/commandGitlabCi.js +109 -0
- package/dist/cli/src/commands/project/commandGitlabCi.js.map +1 -0
- package/dist/cli/src/commands/project/commandListPods.d.ts +8 -0
- package/dist/cli/src/commands/project/commandListPods.js +31 -0
- package/dist/cli/src/commands/project/commandListPods.js.map +1 -0
- package/dist/cli/src/commands/project/commandNamespace.d.ts +8 -0
- package/dist/cli/src/commands/project/commandNamespace.js +26 -0
- package/dist/cli/src/commands/project/commandNamespace.js.map +1 -0
- package/dist/cli/src/commands/project/commandOpenEnv.d.ts +8 -0
- package/dist/cli/src/commands/project/commandOpenEnv.js +40 -0
- package/dist/cli/src/commands/project/commandOpenEnv.js.map +1 -0
- package/dist/cli/src/commands/project/commandOpenGit.d.ts +1 -0
- package/dist/cli/src/commands/project/commandOpenGit.js +17 -0
- package/dist/cli/src/commands/project/commandOpenGit.js.map +1 -0
- package/dist/cli/src/commands/project/commandOpenLogs.d.ts +8 -0
- package/dist/cli/src/commands/project/commandOpenLogs.js +32 -0
- package/dist/cli/src/commands/project/commandOpenLogs.js.map +1 -0
- package/dist/cli/src/commands/project/commandPauseProject.d.ts +8 -0
- package/dist/cli/src/commands/project/commandPauseProject.js +41 -0
- package/dist/cli/src/commands/project/commandPauseProject.js.map +1 -0
- package/dist/cli/src/commands/project/commandPortForward.d.ts +25 -0
- package/dist/cli/src/commands/project/commandPortForward.js +95 -0
- package/dist/cli/src/commands/project/commandPortForward.js.map +1 -0
- package/dist/cli/src/commands/project/commandProjectRestoreDb.d.ts +19 -0
- package/dist/cli/src/commands/project/commandProjectRestoreDb.js +159 -0
- package/dist/cli/src/commands/project/commandProjectRestoreDb.js.map +1 -0
- package/dist/cli/src/commands/project/commandRenewToken.d.ts +1 -0
- package/dist/cli/src/commands/project/commandRenewToken.js +17 -0
- package/dist/cli/src/commands/project/commandRenewToken.js.map +1 -0
- package/dist/cli/src/commands/project/commandSecretsClearBackups.d.ts +7 -0
- package/dist/cli/src/commands/project/commandSecretsClearBackups.js +24 -0
- package/dist/cli/src/commands/project/commandSecretsClearBackups.js.map +1 -0
- package/dist/cli/src/commands/project/commandSecurityEvaluate.d.ts +1 -0
- package/dist/cli/src/commands/project/commandSecurityEvaluate.js +26 -0
- package/dist/cli/src/commands/project/commandSecurityEvaluate.js.map +1 -0
- package/dist/cli/src/commands/project/commandSetup.d.ts +8 -0
- package/dist/cli/src/commands/project/commandSetup.js +25 -0
- package/dist/cli/src/commands/project/commandSetup.js.map +1 -0
- package/dist/cli/src/commands/project/commandTriggerCronjob.d.ts +25 -0
- package/dist/cli/src/commands/project/commandTriggerCronjob.js +95 -0
- package/dist/cli/src/commands/project/commandTriggerCronjob.js.map +1 -0
- package/dist/cli/src/commands/security/commandSecurityAuditCiJob.d.ts +27 -0
- package/dist/cli/src/commands/security/commandSecurityAuditCiJob.js +83 -0
- package/dist/cli/src/commands/security/commandSecurityAuditCiJob.js.map +1 -0
- package/dist/cli/src/commands/security/commandSecurityAuditCreate.d.ts +22 -0
- package/dist/cli/src/commands/security/commandSecurityAuditCreate.js +60 -0
- package/dist/cli/src/commands/security/commandSecurityAuditCreate.js.map +1 -0
- package/dist/cli/src/commands/security/commandSecurityAuditEvaluate.d.ts +7 -0
- package/dist/cli/src/commands/security/commandSecurityAuditEvaluate.js +35 -0
- package/dist/cli/src/commands/security/commandSecurityAuditEvaluate.js.map +1 -0
- package/dist/cli/src/completion.d.ts +24 -0
- package/dist/cli/src/completion.js +240 -0
- package/dist/cli/src/completion.js.map +1 -0
- package/dist/cli/src/config/getProjectConfig.d.ts +4 -4
- package/dist/cli/src/config/getProjectConfig.js +8 -8
- package/dist/cli/src/config/getProjectConfig.js.map +1 -1
- package/dist/cli/src/core/defineCommand.d.ts +27 -0
- package/dist/cli/src/core/defineCommand.js +35 -0
- package/dist/cli/src/core/defineCommand.js.map +1 -0
- package/dist/cli/src/core/index.d.ts +5 -0
- package/dist/cli/src/core/index.js +52 -0
- package/dist/cli/src/core/index.js.map +1 -0
- package/dist/cli/src/core/registry.d.ts +5 -0
- package/dist/cli/src/core/registry.js +26 -0
- package/dist/cli/src/core/registry.js.map +1 -0
- package/dist/cli/src/core/runner.d.ts +19 -0
- package/dist/cli/src/core/runner.js +29 -0
- package/dist/cli/src/core/runner.js.map +1 -0
- package/dist/cli/src/core/types.d.ts +105 -0
- package/dist/cli/src/core/types.js +17 -0
- package/dist/cli/src/core/types.js.map +1 -0
- package/dist/cli/src/gcloud/cloudRun/openCloudRunDashboards.d.ts +2 -2
- package/dist/cli/src/gcloud/cloudRun/openCloudRunDashboards.js.map +1 -1
- package/dist/cli/src/gcloud/openDashboard.d.ts +2 -2
- package/dist/cli/src/gcloud/openDashboard.js +1 -1
- package/dist/cli/src/gcloud/openDashboard.js.map +1 -1
- package/dist/cli/src/gcloud/serviceAccounts.d.ts +2 -2
- package/dist/cli/src/gcloud/serviceAccounts.js.map +1 -1
- package/dist/cli/src/kubernetes/openKubernetesDashboards.d.ts +3 -3
- package/dist/cli/src/kubernetes/openKubernetesDashboards.js.map +1 -1
- package/dist/cli/src/security/auditDocument.js.map +1 -0
- package/dist/cli/src/security/createSecurityAuditMergeRequest.js.map +1 -0
- package/dist/cli/src/security/evaluateSecurityAudit.js.map +1 -0
- package/dist/cli/src/utils/gitlab.d.ts +9 -9
- package/dist/cli/src/utils/gitlab.js +45 -54
- package/dist/cli/src/utils/gitlab.js.map +1 -1
- package/dist/cli/src/utils/log.d.ts +2 -2
- package/dist/pipeline/src/build/index.d.ts +2 -2
- package/dist/pipeline/src/build/index.js.map +1 -1
- package/dist/pipeline/src/build/node/buildJob.d.ts +3 -3
- package/dist/pipeline/src/build/node/buildJob.js +13 -12
- package/dist/pipeline/src/build/node/buildJob.js.map +1 -1
- package/dist/pipeline/src/build/node/cache.d.ts +3 -3
- package/dist/pipeline/src/build/node/cache.js +12 -9
- package/dist/pipeline/src/build/node/cache.js.map +1 -1
- package/dist/pipeline/src/build/node/index.d.ts +3 -3
- package/dist/pipeline/src/build/node/index.js +8 -6
- package/dist/pipeline/src/build/node/index.js.map +1 -1
- package/dist/pipeline/src/build/node/meteor.d.ts +1 -1
- package/dist/pipeline/src/build/node/meteor.js +8 -7
- package/dist/pipeline/src/build/node/meteor.js.map +1 -1
- package/dist/pipeline/src/build/node/testJob.d.ts +1 -1
- package/dist/pipeline/src/build/node/testJob.js +5 -5
- package/dist/pipeline/src/build/node/testJob.js.map +1 -1
- package/dist/pipeline/src/build/node/yarn.d.ts +2 -2
- package/dist/pipeline/src/build/node/yarn.js +10 -8
- package/dist/pipeline/src/build/node/yarn.js.map +1 -1
- package/dist/pipeline/src/build/types.d.ts +1 -1
- package/dist/pipeline/src/constants.js +1 -1
- package/dist/pipeline/src/context/createComponentContext.js +3 -3
- package/dist/pipeline/src/context/createComponentContext.js.map +1 -1
- package/dist/pipeline/src/context/createWorkspaceContext.js +1 -1
- package/dist/pipeline/src/context/createWorkspaceContext.js.map +1 -1
- package/dist/pipeline/src/context/getEnvironmentVariables.d.ts +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js.map +1 -1
- package/dist/pipeline/src/deploy/custom/deployJob.d.ts +1 -1
- package/dist/pipeline/src/deploy/custom/deployJob.js +2 -2
- package/dist/pipeline/src/deploy/custom/deployJob.js.map +1 -1
- package/dist/pipeline/src/deploy/index.d.ts +1 -1
- package/dist/pipeline/src/deploy/types/index.d.ts +2 -2
- package/dist/pipeline/src/pipeline/createAllJobs.js +4 -4
- package/dist/pipeline/src/pipeline/createAllJobs.js.map +1 -1
- package/dist/pipeline/src/pipeline/createJobsForComponent.d.ts +1 -1
- package/dist/pipeline/src/pipeline/createJobsForComponent.js +2 -3
- package/dist/pipeline/src/pipeline/createJobsForComponent.js.map +1 -1
- package/dist/pipeline/src/pipeline/createJobsForWorkspace.d.ts +1 -1
- package/dist/pipeline/src/pipeline/createJobsForWorkspace.js +2 -2
- package/dist/pipeline/src/pipeline/createJobsForWorkspace.js.map +1 -1
- package/dist/pipeline/src/types/config.d.ts +3 -3
- package/dist/pipeline/src/types/context.d.ts +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/scripts/bundle +0 -2
- package/src/adapters/baseContext.ts +68 -0
- package/src/adapters/programmatic.ts +88 -0
- package/src/adapters/terminal.ts +207 -0
- package/src/apps/catenv/catenv.ts +4 -2
- package/src/apps/catenv/printVariables.ts +0 -8
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +8 -33
- package/src/apps/cli/commands/project/setup/index.ts +2 -2
- package/src/apps/cli/commands/project/setup/logSection.ts +2 -2
- package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +2 -2
- package/src/apps/cli/commands/project/setup/setupAgents.ts +11 -11
- package/src/apps/cli/commands/project/setup/setupCloudRun.ts +2 -2
- package/src/apps/cli/commands/project/setup/setupContext.ts +2 -5
- package/src/apps/cli/commands/project/setup/setupKubernetes.ts +2 -2
- package/src/apps/cli/commands/project/setup/setupTopic.ts +2 -2
- package/src/apps/cli/commands/project/utils/ensureCluster.ts +19 -12
- package/src/apps/cli/utils/getGoogleAuthUserNumber.ts +5 -4
- package/src/catenv.ts +24 -18
- package/src/cli.ts +213 -2
- package/src/commands/cloudSQL/commandRestoreDb.ts +105 -0
- package/src/commands/fun/commandDadjoke.ts +18 -0
- package/src/commands/fun/commandStarwars.ts +14 -0
- package/src/commands/general/commandKubeCurrentContext.ts +12 -0
- package/src/commands/general/commandKubeGetShell.ts +32 -0
- package/src/commands/general/commandKubeListNamespaces.ts +15 -0
- package/src/commands/general/commandKubeListPods.ts +21 -0
- package/src/commands/general/commandKubeListSecrets.ts +21 -0
- package/src/commands/general/commandKubePortForward.ts +35 -0
- package/src/commands/general/commandKubeStopPortforward.ts +15 -0
- package/src/commands/index.ts +51 -0
- package/src/commands/mongodb/commandMongoDestroyMember.ts +133 -0
- package/src/commands/mongodb/commandMongoGetShell.ts +36 -0
- package/src/commands/mongodb/commandMongoPortForward.ts +56 -0
- package/src/commands/project/commandCloudSqlProxy.ts +189 -0
- package/src/commands/project/commandConfigSecrets.ts +31 -0
- package/src/commands/project/commandDeletePods.ts +53 -0
- package/src/commands/project/commandDeleteProject.ts +33 -0
- package/src/commands/project/commandEnvVars.ts +24 -0
- package/src/commands/project/commandGetMyTotalWorktime.ts +14 -0
- package/src/commands/project/commandGetShell.ts +39 -0
- package/src/commands/project/commandGitlabCi.ts +122 -0
- package/src/commands/project/commandListPods.ts +30 -0
- package/src/commands/project/commandNamespace.ts +21 -0
- package/src/commands/project/commandOpenEnv.ts +27 -0
- package/src/commands/project/commandOpenGit.ts +12 -0
- package/src/commands/project/commandOpenLogs.ts +27 -0
- package/src/commands/project/commandPauseProject.ts +33 -0
- package/src/commands/project/commandPortForward.ts +74 -0
- package/src/commands/project/commandProjectRestoreDb.ts +201 -0
- package/src/commands/project/commandRenewToken.ts +12 -0
- package/src/commands/project/commandSecretsClearBackups.ts +19 -0
- package/src/commands/project/commandSecurityEvaluate.ts +22 -0
- package/src/commands/project/commandSetup.ts +21 -0
- package/src/commands/project/commandTriggerCronjob.ts +99 -0
- package/src/commands/security/commandSecurityAuditCiJob.ts +91 -0
- package/src/commands/security/commandSecurityAuditCreate.ts +58 -0
- package/src/commands/security/commandSecurityAuditEvaluate.ts +30 -0
- package/src/completion.ts +272 -0
- package/src/config/getProjectConfig.ts +9 -9
- package/src/core/defineCommand.ts +32 -0
- package/src/core/index.ts +23 -0
- package/src/core/registry.ts +22 -0
- package/src/core/runner.ts +31 -0
- package/src/core/types.ts +142 -0
- package/src/gcloud/cloudRun/openCloudRunDashboards.ts +2 -2
- package/src/gcloud/openDashboard.ts +3 -3
- package/src/gcloud/serviceAccounts.ts +2 -2
- package/src/kubernetes/openKubernetesDashboards.ts +3 -3
- package/src/utils/gitlab.ts +46 -58
- package/src/utils/log.ts +2 -2
- package/bin/catci +0 -3
- package/bin/catci-dev +0 -3
- package/dist/bundles/catci/index.js +0 -41
- package/dist/cli/src/apps/catci/catci.d.ts +0 -1
- package/dist/cli/src/apps/catci/catci.js +0 -33
- package/dist/cli/src/apps/catci/catci.js.map +0 -1
- package/dist/cli/src/apps/catci/commands/security/auditDocument.js.map +0 -1
- package/dist/cli/src/apps/catci/commands/security/commands.d.ts +0 -2
- package/dist/cli/src/apps/catci/commands/security/commands.js +0 -118
- package/dist/cli/src/apps/catci/commands/security/commands.js.map +0 -1
- package/dist/cli/src/apps/catci/commands/security/createSecurityAuditMergeRequest.js.map +0 -1
- package/dist/cli/src/apps/catci/commands/security/evaluateSecurityAudit.js.map +0 -1
- package/dist/cli/src/apps/cli/cli.d.ts +0 -2
- package/dist/cli/src/apps/cli/cli.js +0 -38
- package/dist/cli/src/apps/cli/cli.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/cloudSQL/commandRestoreDb.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/cloudSQL/commandRestoreDb.js +0 -130
- package/dist/cli/src/apps/cli/commands/cloudSQL/commandRestoreDb.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/cloudSQL/index.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/cloudSQL/index.js +0 -14
- package/dist/cli/src/apps/cli/commands/cloudSQL/index.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/general/index.d.ts +0 -4
- package/dist/cli/src/apps/cli/commands/general/index.js +0 -83
- package/dist/cli/src/apps/cli/commands/general/index.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/general/namespaceAutoCompletion.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/general/namespaceAutoCompletion.js +0 -13
- package/dist/cli/src/apps/cli/commands/general/namespaceAutoCompletion.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/general/portForward.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/general/portForward.js +0 -47
- package/dist/cli/src/apps/cli/commands/general/portForward.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/mongodb/index.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/mongodb/index.js +0 -18
- package/dist/cli/src/apps/cli/commands/mongodb/index.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/mongodb/projectMongoDestroyMember.js +0 -96
- package/dist/cli/src/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/mongodb/projectMongoGetShell.js +0 -38
- package/dist/cli/src/apps/cli/commands/mongodb/projectMongoGetShell.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/mongodb/projectMongoPortForward.js +0 -64
- package/dist/cli/src/apps/cli/commands/mongodb/projectMongoPortForward.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.js +0 -152
- package/dist/cli/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandCloudSqlProxy.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandCloudSqlProxy.js +0 -120
- package/dist/cli/src/apps/cli/commands/project/commandCloudSqlProxy.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandDeletePods.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandDeletePods.js +0 -54
- package/dist/cli/src/apps/cli/commands/project/commandDeletePods.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandDeleteProject.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandDeleteProject.js +0 -33
- package/dist/cli/src/apps/cli/commands/project/commandDeleteProject.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandEnvVars.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandEnvVars.js +0 -17
- package/dist/cli/src/apps/cli/commands/project/commandEnvVars.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandGetMyTotalWorktime.js +0 -11
- package/dist/cli/src/apps/cli/commands/project/commandGetMyTotalWorktime.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandGetShell.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandGetShell.js +0 -37
- package/dist/cli/src/apps/cli/commands/project/commandGetShell.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandGitlabCi.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandGitlabCi.js +0 -88
- package/dist/cli/src/apps/cli/commands/project/commandGitlabCi.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandListPods.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandListPods.js +0 -22
- package/dist/cli/src/apps/cli/commands/project/commandListPods.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandNamespace.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandNamespace.js +0 -12
- package/dist/cli/src/apps/cli/commands/project/commandNamespace.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandOpenEnv.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandOpenEnv.js +0 -26
- package/dist/cli/src/apps/cli/commands/project/commandOpenEnv.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandOpenGit.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandOpenGit.js +0 -9
- package/dist/cli/src/apps/cli/commands/project/commandOpenGit.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandOpenLogs.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandOpenLogs.js +0 -18
- package/dist/cli/src/apps/cli/commands/project/commandOpenLogs.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandPauseProject.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandPauseProject.js +0 -33
- package/dist/cli/src/apps/cli/commands/project/commandPauseProject.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandPortForward.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandPortForward.js +0 -97
- package/dist/cli/src/apps/cli/commands/project/commandPortForward.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandRenewToken.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandRenewToken.js +0 -9
- package/dist/cli/src/apps/cli/commands/project/commandRenewToken.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandSecretsClearBackups.d.ts +0 -5
- package/dist/cli/src/apps/cli/commands/project/commandSecretsClearBackups.js +0 -25
- package/dist/cli/src/apps/cli/commands/project/commandSecretsClearBackups.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandSecurityEvaluate.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandSecurityEvaluate.js +0 -20
- package/dist/cli/src/apps/cli/commands/project/commandSecurityEvaluate.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandSetup.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandSetup.js +0 -12
- package/dist/cli/src/apps/cli/commands/project/commandSetup.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/commandTriggerCronjob.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/commandTriggerCronjob.js +0 -63
- package/dist/cli/src/apps/cli/commands/project/commandTriggerCronjob.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/index.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/project/index.js +0 -54
- package/dist/cli/src/apps/cli/commands/project/index.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/project/utils/showProjectBanner.d.ts +0 -2
- package/dist/cli/src/apps/cli/commands/project/utils/showProjectBanner.js +0 -16
- package/dist/cli/src/apps/cli/commands/project/utils/showProjectBanner.js.map +0 -1
- package/dist/cli/src/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +0 -3
- package/dist/cli/src/apps/cli/commands/theStuffThatReallyMatters/index.js +0 -37
- package/dist/cli/src/apps/cli/commands/theStuffThatReallyMatters/index.js.map +0 -1
- package/dist/cli/src/apps/cli/verify/index.d.ts +0 -2
- package/dist/cli/src/apps/cli/verify/index.js +0 -17
- package/dist/cli/src/apps/cli/verify/index.js.map +0 -1
- package/dist/cli/src/catci.d.ts +0 -1
- package/dist/cli/src/catci.js +0 -7
- package/dist/cli/src/catci.js.map +0 -1
- package/src/apps/catci/catci.ts +0 -26
- package/src/apps/catci/commands/security/commands.ts +0 -161
- package/src/apps/cli/cli.ts +0 -43
- package/src/apps/cli/commands/cloudSQL/commandRestoreDb.ts +0 -136
- package/src/apps/cli/commands/cloudSQL/index.ts +0 -7
- package/src/apps/cli/commands/general/index.ts +0 -90
- package/src/apps/cli/commands/general/namespaceAutoCompletion.ts +0 -7
- package/src/apps/cli/commands/general/portForward.ts +0 -48
- package/src/apps/cli/commands/mongodb/index.ts +0 -10
- package/src/apps/cli/commands/mongodb/projectMongoDestroyMember.ts +0 -132
- package/src/apps/cli/commands/mongodb/projectMongoGetShell.ts +0 -42
- package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +0 -64
- package/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.ts +0 -206
- package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +0 -194
- package/src/apps/cli/commands/project/commandDeletePods.ts +0 -48
- package/src/apps/cli/commands/project/commandDeleteProject.ts +0 -33
- package/src/apps/cli/commands/project/commandEnvVars.ts +0 -18
- package/src/apps/cli/commands/project/commandGetMyTotalWorktime.ts +0 -14
- package/src/apps/cli/commands/project/commandGetShell.ts +0 -36
- package/src/apps/cli/commands/project/commandGitlabCi.ts +0 -115
- package/src/apps/cli/commands/project/commandListPods.ts +0 -20
- package/src/apps/cli/commands/project/commandNamespace.ts +0 -14
- package/src/apps/cli/commands/project/commandOpenEnv.ts +0 -22
- package/src/apps/cli/commands/project/commandOpenGit.ts +0 -12
- package/src/apps/cli/commands/project/commandOpenLogs.ts +0 -21
- package/src/apps/cli/commands/project/commandPauseProject.ts +0 -33
- package/src/apps/cli/commands/project/commandPortForward.ts +0 -91
- package/src/apps/cli/commands/project/commandRenewToken.ts +0 -12
- package/src/apps/cli/commands/project/commandSecretsClearBackups.ts +0 -26
- package/src/apps/cli/commands/project/commandSecurityEvaluate.ts +0 -26
- package/src/apps/cli/commands/project/commandSetup.ts +0 -14
- package/src/apps/cli/commands/project/commandTriggerCronjob.ts +0 -62
- package/src/apps/cli/commands/project/index.ts +0 -56
- package/src/apps/cli/commands/project/utils/showProjectBanner.ts +0 -11
- package/src/apps/cli/commands/theStuffThatReallyMatters/index.ts +0 -32
- package/src/apps/cli/verify/index.ts +0 -14
- package/src/catci.ts +0 -3
- /package/dist/cli/src/{apps/catci/commands/security → security}/auditDocument.d.ts +0 -0
- /package/dist/cli/src/{apps/catci/commands/security → security}/auditDocument.js +0 -0
- /package/dist/cli/src/{apps/catci/commands/security → security}/createSecurityAuditMergeRequest.d.ts +0 -0
- /package/dist/cli/src/{apps/catci/commands/security → security}/createSecurityAuditMergeRequest.js +0 -0
- /package/dist/cli/src/{apps/catci/commands/security → security}/evaluateSecurityAudit.d.ts +0 -0
- /package/dist/cli/src/{apps/catci/commands/security → security}/evaluateSecurityAudit.js +0 -0
- /package/dist/cli/src/{apps/catci/commands/security → security}/topics.json +0 -0
- /package/src/{apps/catci/commands/security → security}/auditDocument.ts +0 -0
- /package/src/{apps/catci/commands/security → security}/createSecurityAuditMergeRequest.ts +0 -0
- /package/src/{apps/catci/commands/security → security}/evaluateSecurityAudit.ts +0 -0
- /package/src/{apps/catci/commands/security → security}/topics.json +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CommandDef, InputsSchema } from "./types";
|
|
2
|
+
import { createProgrammaticContext } from "../adapters/programmatic";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Run a command programmatically.
|
|
6
|
+
* This is the main entry point for calling commands from code.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { commandPortForward } from "./commands/project/portForward";
|
|
11
|
+
* import { runCommand } from "./core/runner";
|
|
12
|
+
*
|
|
13
|
+
* await runCommand(commandPortForward, {
|
|
14
|
+
* inputs: { envComponent: "dev:web", podName: "web-abc", localPort: 3000, remotePort: 3000 },
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export async function runCommand<TInputs extends InputsSchema>(
|
|
19
|
+
command: CommandDef<TInputs>,
|
|
20
|
+
options: {
|
|
21
|
+
inputs?: Record<string, unknown>;
|
|
22
|
+
onLog?: (message: string) => void;
|
|
23
|
+
} = {},
|
|
24
|
+
): Promise<void> {
|
|
25
|
+
const ctx = createProgrammaticContext(command, {
|
|
26
|
+
inputs: options.inputs,
|
|
27
|
+
onLog: options.onLog,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
await command.execute(ctx);
|
|
31
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// ─── Input Definitions ───────────────────────────────────────────────
|
|
2
|
+
|
|
3
|
+
export type PromptChoice = string | { name: string; value: string };
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Function that returns choices for an input.
|
|
7
|
+
* Receives the command context so it can resolve other inputs first.
|
|
8
|
+
*/
|
|
9
|
+
export type ChoicesFn<TCtx = any> = (
|
|
10
|
+
ctx: TCtx,
|
|
11
|
+
) => PromptChoice[] | Promise<PromptChoice[]>;
|
|
12
|
+
|
|
13
|
+
export type StringInputDef = {
|
|
14
|
+
type: "string";
|
|
15
|
+
message: string;
|
|
16
|
+
default?: string;
|
|
17
|
+
positional?: boolean;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
/** If provided, renders as a list selection in interactive mode */
|
|
20
|
+
choices?: ChoicesFn;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type StringArrayInputDef = {
|
|
24
|
+
type: "string[]";
|
|
25
|
+
message: string;
|
|
26
|
+
positional?: boolean;
|
|
27
|
+
required?: boolean;
|
|
28
|
+
/** If provided, renders as checkboxes in interactive mode */
|
|
29
|
+
choices?: ChoicesFn;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type NumberInputDef = {
|
|
33
|
+
type: "number";
|
|
34
|
+
message: string;
|
|
35
|
+
default?: number;
|
|
36
|
+
positional?: boolean;
|
|
37
|
+
required?: boolean;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type BooleanInputDef = {
|
|
41
|
+
type: "boolean";
|
|
42
|
+
message: string;
|
|
43
|
+
default?: boolean;
|
|
44
|
+
positional?: boolean;
|
|
45
|
+
required?: boolean;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type InputDef =
|
|
49
|
+
| StringInputDef
|
|
50
|
+
| StringArrayInputDef
|
|
51
|
+
| NumberInputDef
|
|
52
|
+
| BooleanInputDef;
|
|
53
|
+
|
|
54
|
+
/** Map an InputDef to its resolved TypeScript value type */
|
|
55
|
+
export type InputResultType<P extends InputDef> = P extends { type: "string" }
|
|
56
|
+
? string
|
|
57
|
+
: P extends { type: "string[]" }
|
|
58
|
+
? string[]
|
|
59
|
+
: P extends { type: "number" }
|
|
60
|
+
? number
|
|
61
|
+
: P extends { type: "boolean" }
|
|
62
|
+
? boolean
|
|
63
|
+
: never;
|
|
64
|
+
|
|
65
|
+
// ─── Inputs Schema ──────────────────────────────────────────────────
|
|
66
|
+
|
|
67
|
+
export type InputsSchema = Record<string, InputDef>;
|
|
68
|
+
|
|
69
|
+
// ─── IO Interface (for helpers) ──────────────────────────────────────
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Base IO interface for helper functions that need to log or prompt.
|
|
73
|
+
* Helpers use `promptDirect` for ad-hoc prompts (confirmations, sub-selections)
|
|
74
|
+
* that are NOT part of a command's declared input schema.
|
|
75
|
+
*/
|
|
76
|
+
export interface IO {
|
|
77
|
+
log(message: string): void;
|
|
78
|
+
/**
|
|
79
|
+
* Ask for confirmation. Returns true/false.
|
|
80
|
+
* Skipped (returns true) when --yes is active.
|
|
81
|
+
* Throws or returns false on decline, depending on the adapter.
|
|
82
|
+
*/
|
|
83
|
+
confirm(message: string): Promise<boolean>;
|
|
84
|
+
promptDirect<P extends InputDef>(
|
|
85
|
+
spec: P & { name: string },
|
|
86
|
+
): Promise<InputResultType<P>>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ─── Command Context ─────────────────────────────────────────────────
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Runtime context passed to command execute functions.
|
|
93
|
+
* Extends IO so it can be passed to helpers that only need log + promptDirect.
|
|
94
|
+
*
|
|
95
|
+
* - `get(name)`: consume a declared input by name (type-safe).
|
|
96
|
+
* Returns the value if already provided (positional arg, CLI flag, JSON),
|
|
97
|
+
* or prompts for it interactively, or throws if non-interactive.
|
|
98
|
+
* - `log(message)`: output a message.
|
|
99
|
+
* - `promptDirect(spec)`: ad-hoc prompt for helpers (not type-checked against schema).
|
|
100
|
+
*/
|
|
101
|
+
export interface CommandContext<TInputs extends InputsSchema> extends IO {
|
|
102
|
+
/**
|
|
103
|
+
* Consume a declared input by name.
|
|
104
|
+
* - Compile error if `name` is not in TInputs
|
|
105
|
+
* - Return type matches the input's type (string, number, boolean, string[])
|
|
106
|
+
* - If `required: false`, returns `undefined` when not provided (no prompt)
|
|
107
|
+
* - Otherwise: pre-supplied value > choices function + interactive prompt > default > throw
|
|
108
|
+
*/
|
|
109
|
+
get<K extends keyof TInputs & string>(
|
|
110
|
+
name: K,
|
|
111
|
+
): Promise<OptionalInput<TInputs[K]>>;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** If the input has `required: false`, the result can be undefined */
|
|
115
|
+
export type OptionalInput<T extends InputDef> = T extends { required: false }
|
|
116
|
+
? InputResultType<T> | undefined
|
|
117
|
+
: InputResultType<T>;
|
|
118
|
+
|
|
119
|
+
// ─── Command Definition ──────────────────────────────────────────────
|
|
120
|
+
|
|
121
|
+
export interface CommandDef<TInputs extends InputsSchema = InputsSchema> {
|
|
122
|
+
name: string;
|
|
123
|
+
description: string;
|
|
124
|
+
group?: string;
|
|
125
|
+
inputs: TInputs;
|
|
126
|
+
execute: (ctx: CommandContext<TInputs>) => Promise<void>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ─── Errors ──────────────────────────────────────────────────────────
|
|
130
|
+
|
|
131
|
+
export class MissingInputError extends Error {
|
|
132
|
+
constructor(
|
|
133
|
+
public readonly inputName: string,
|
|
134
|
+
public readonly promptMessage: string,
|
|
135
|
+
) {
|
|
136
|
+
super(
|
|
137
|
+
`Missing required input: "${inputName}" (${promptMessage}). ` +
|
|
138
|
+
`Provide it via --${inputName}=<value> or --inputs='{"${inputName}": ...}'`,
|
|
139
|
+
);
|
|
140
|
+
this.name = "MissingInputError";
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ComponentContext } from "@catladder/pipeline";
|
|
2
2
|
import { isOfDeployType } from "@catladder/pipeline";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IO } from "../../core/types";
|
|
4
4
|
import { openGoogleCloudDashboard } from "../openDashboard";
|
|
5
5
|
|
|
6
6
|
export const openGoogleCloudRunDashboard = async (
|
|
7
|
-
instance:
|
|
7
|
+
instance: IO,
|
|
8
8
|
context: ComponentContext,
|
|
9
9
|
) => {
|
|
10
10
|
if (!isOfDeployType(context.deploy?.config, "google-cloudrun")) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IO } from "../core/types";
|
|
2
2
|
import { getGoogleAuthUserNumber } from "../apps/cli/utils/getGoogleAuthUserNumber";
|
|
3
3
|
import open from "open";
|
|
4
4
|
export const openGoogleCloudDashboard = async (
|
|
5
|
-
instance:
|
|
5
|
+
instance: IO,
|
|
6
6
|
path: string,
|
|
7
7
|
params: Record<string, string>,
|
|
8
8
|
) => {
|
|
@@ -12,7 +12,7 @@ export const openGoogleCloudDashboard = async (
|
|
|
12
12
|
url.searchParams.set(key, value);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const googleAuthUserNumber = await getGoogleAuthUserNumber
|
|
15
|
+
const googleAuthUserNumber = await getGoogleAuthUserNumber(instance);
|
|
16
16
|
url.searchParams.set("authuser", googleAuthUserNumber);
|
|
17
17
|
|
|
18
18
|
open(url.toString());
|
|
@@ -2,7 +2,7 @@ import type { ComponentContext } from "@catladder/pipeline";
|
|
|
2
2
|
|
|
3
3
|
import { exec } from "child-process-promise";
|
|
4
4
|
import { createHmac } from "crypto";
|
|
5
|
-
import type {
|
|
5
|
+
import type { IO } from "../core/types";
|
|
6
6
|
import { upsertAllVariables } from "../utils/gitlab";
|
|
7
7
|
|
|
8
8
|
export const accountExists = async (fullIdentifier: string) => {
|
|
@@ -93,7 +93,7 @@ const upsertGcloudServiceAccount = async (
|
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
export const upsertGcloudServiceAccountAndSaveSecret = async (
|
|
96
|
-
instance:
|
|
96
|
+
instance: IO,
|
|
97
97
|
context: ComponentContext,
|
|
98
98
|
account: ServiceAccount,
|
|
99
99
|
secretName: string,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ComponentContext } from "@catladder/pipeline";
|
|
2
2
|
import { isOfDeployType } from "@catladder/pipeline";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IO } from "../core/types";
|
|
4
4
|
import { openGoogleCloudDashboard } from "../gcloud/openDashboard";
|
|
5
5
|
|
|
6
6
|
export const openGoogleCloudLogs = async (
|
|
7
|
-
instance:
|
|
7
|
+
instance: IO,
|
|
8
8
|
context: ComponentContext,
|
|
9
9
|
) => {
|
|
10
10
|
const deployConfig = context.deploy?.config;
|
|
@@ -30,7 +30,7 @@ export const openGoogleCloudLogs = async (
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export const openGoogleCloudKubernetesDashboard = async (
|
|
33
|
-
instance:
|
|
33
|
+
instance: IO,
|
|
34
34
|
context: ComponentContext,
|
|
35
35
|
) => {
|
|
36
36
|
const deployConfig = context.deploy?.config;
|
package/src/utils/gitlab.ts
CHANGED
|
@@ -3,36 +3,31 @@ import { has, isObject } from "lodash";
|
|
|
3
3
|
import memoizee from "memoizee";
|
|
4
4
|
import fetch from "node-fetch";
|
|
5
5
|
import open from "open";
|
|
6
|
-
import type {
|
|
6
|
+
import type { IO } from "../core/types";
|
|
7
7
|
import { getPreference, hasPreference, setPreference } from "./preferences";
|
|
8
8
|
import { getGitRemoteHostAndPath } from "../git/gitProjectInformation";
|
|
9
9
|
|
|
10
10
|
const TOKEN_KEY = "gitlab-personal-access-token";
|
|
11
11
|
|
|
12
12
|
export const hasGitlabToken = async () => await hasPreference(TOKEN_KEY);
|
|
13
|
-
export const setupGitlabToken = async (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const [
|
|
22
|
-
|
|
23
|
-
default: true,
|
|
24
|
-
message: "Ok",
|
|
25
|
-
name: "shouldContinue",
|
|
26
|
-
type: "prompt",
|
|
27
|
-
}),
|
|
13
|
+
export const setupGitlabToken = async (io: IO) => {
|
|
14
|
+
io.log("");
|
|
15
|
+
io.log("☝ in order to access the api, we need a personal access token");
|
|
16
|
+
io.log("Its best to create one specifically for catladder");
|
|
17
|
+
io.log("Scopes needed: api");
|
|
18
|
+
io.log("");
|
|
19
|
+
io.log("☝ we open up the settings page for you!");
|
|
20
|
+
io.log("");
|
|
21
|
+
const [shouldContinue, { gitRemoteHost }] = await Promise.all([
|
|
22
|
+
io.confirm("Ok"),
|
|
28
23
|
getGitRemoteHostAndPath(),
|
|
29
24
|
]);
|
|
30
25
|
|
|
31
26
|
open(`https://${gitRemoteHost}/-/user_settings/personal_access_tokens`);
|
|
32
27
|
|
|
33
|
-
|
|
28
|
+
io.log("Please type in gitlab's personal access token");
|
|
34
29
|
|
|
35
|
-
const
|
|
30
|
+
const personalToken = await io.promptDirect({
|
|
36
31
|
type: "string",
|
|
37
32
|
name: "personalToken",
|
|
38
33
|
default: "",
|
|
@@ -42,28 +37,28 @@ export const setupGitlabToken = async (vorpal: CommandInstance) => {
|
|
|
42
37
|
await setPreference(TOKEN_KEY, personalToken);
|
|
43
38
|
}
|
|
44
39
|
};
|
|
45
|
-
export const getGitlabToken = async (
|
|
40
|
+
export const getGitlabToken = async (io: IO | null) => {
|
|
46
41
|
if (!(await hasGitlabToken())) {
|
|
47
|
-
if (!
|
|
42
|
+
if (!io) {
|
|
48
43
|
console.error(
|
|
49
44
|
"⚠️ gitlab token missing, please run catladder to set it up",
|
|
50
45
|
);
|
|
51
46
|
process.exit(1);
|
|
52
47
|
}
|
|
53
|
-
await setupGitlabToken(
|
|
48
|
+
await setupGitlabToken(io);
|
|
54
49
|
}
|
|
55
50
|
return getPreference(TOKEN_KEY);
|
|
56
51
|
};
|
|
57
52
|
|
|
58
53
|
type Method = "GET" | "PUT" | "POST" | "DELETE";
|
|
59
54
|
export const doGitlabRequest = async <T = any>(
|
|
60
|
-
|
|
55
|
+
io: IO | null,
|
|
61
56
|
path: string,
|
|
62
57
|
data: any = undefined,
|
|
63
58
|
method: Method = "GET",
|
|
64
59
|
): Promise<T> => {
|
|
65
60
|
const [rootToken, { gitRemoteHost }] = await Promise.all([
|
|
66
|
-
getGitlabToken(
|
|
61
|
+
getGitlabToken(io),
|
|
67
62
|
getGitRemoteHostAndPath(),
|
|
68
63
|
]);
|
|
69
64
|
|
|
@@ -96,11 +91,11 @@ export const doGitlabRequest = async <T = any>(
|
|
|
96
91
|
};
|
|
97
92
|
|
|
98
93
|
export const getProjectInfo = async (
|
|
99
|
-
|
|
94
|
+
io: IO | null,
|
|
100
95
|
): Promise<{ id: string; web_url: string }> => {
|
|
101
96
|
const { gitRemotePath } = await getGitRemoteHostAndPath();
|
|
102
97
|
const project = await doGitlabRequest(
|
|
103
|
-
|
|
98
|
+
io,
|
|
104
99
|
`projects/${encodeURIComponent(gitRemotePath)}`,
|
|
105
100
|
);
|
|
106
101
|
return project;
|
|
@@ -116,10 +111,10 @@ type GitlabVariable = {
|
|
|
116
111
|
};
|
|
117
112
|
export const getAllVariables = memoizee(
|
|
118
113
|
async (
|
|
119
|
-
|
|
114
|
+
io: IO | null,
|
|
120
115
|
n = 5, // how many requests to do in parallel, 5 seems a good value for many projects, ideally we would do one request in parallel per component
|
|
121
116
|
): Promise<Array<GitlabVariable>> => {
|
|
122
|
-
const { id } = await getProjectInfo(
|
|
117
|
+
const { id } = await getProjectInfo(io);
|
|
123
118
|
|
|
124
119
|
let all: Array<GitlabVariable> = [];
|
|
125
120
|
let result: Array<Array<GitlabVariable>> = [];
|
|
@@ -129,7 +124,7 @@ export const getAllVariables = memoizee(
|
|
|
129
124
|
// Create an array of promises for N pages
|
|
130
125
|
const promises = Array.from({ length: n }, (_, i) => {
|
|
131
126
|
return doGitlabRequest(
|
|
132
|
-
|
|
127
|
+
io,
|
|
133
128
|
`projects/${id}/variables?per_page=100&page=${page + i}`,
|
|
134
129
|
);
|
|
135
130
|
});
|
|
@@ -150,11 +145,8 @@ export const getAllVariables = memoizee(
|
|
|
150
145
|
{ promise: true },
|
|
151
146
|
);
|
|
152
147
|
|
|
153
|
-
export const getVariableValueByRawName = async (
|
|
154
|
-
|
|
155
|
-
rawName: string,
|
|
156
|
-
) => {
|
|
157
|
-
const allVariables = await getAllVariables(vorpal);
|
|
148
|
+
export const getVariableValueByRawName = async (io: IO, rawName: string) => {
|
|
149
|
+
const allVariables = await getAllVariables(io);
|
|
158
150
|
return allVariables.find((v) => v.key === rawName)?.value;
|
|
159
151
|
};
|
|
160
152
|
|
|
@@ -162,7 +154,7 @@ const maskableRegex = new RegExp("^[a-zA-Z0-9_+=/@:.~-]{8,}$"); // SEE https://g
|
|
|
162
154
|
const isMaskable = (value: string): boolean => maskableRegex.test(value);
|
|
163
155
|
|
|
164
156
|
const createVariable = async (
|
|
165
|
-
|
|
157
|
+
io: IO,
|
|
166
158
|
projectId: string,
|
|
167
159
|
key: string,
|
|
168
160
|
value: string,
|
|
@@ -170,7 +162,7 @@ const createVariable = async (
|
|
|
170
162
|
environment_scope = "*",
|
|
171
163
|
) => {
|
|
172
164
|
return await doGitlabRequest(
|
|
173
|
-
|
|
165
|
+
io,
|
|
174
166
|
`projects/${projectId}/variables`,
|
|
175
167
|
{
|
|
176
168
|
key,
|
|
@@ -183,14 +175,14 @@ const createVariable = async (
|
|
|
183
175
|
};
|
|
184
176
|
|
|
185
177
|
const updateVariable = async (
|
|
186
|
-
|
|
178
|
+
io: IO,
|
|
187
179
|
projectId: string,
|
|
188
180
|
key: string,
|
|
189
181
|
value: string,
|
|
190
182
|
masked = true,
|
|
191
183
|
) => {
|
|
192
184
|
return await doGitlabRequest(
|
|
193
|
-
|
|
185
|
+
io,
|
|
194
186
|
`projects/${projectId}/variables/${key}`,
|
|
195
187
|
{
|
|
196
188
|
value,
|
|
@@ -200,21 +192,17 @@ const updateVariable = async (
|
|
|
200
192
|
);
|
|
201
193
|
};
|
|
202
194
|
|
|
203
|
-
const deleteVariable = async (
|
|
204
|
-
vorpal: CommandInstance,
|
|
205
|
-
projectId: string,
|
|
206
|
-
key: string,
|
|
207
|
-
) => {
|
|
195
|
+
const deleteVariable = async (io: IO, projectId: string, key: string) => {
|
|
208
196
|
return await doGitlabRequest(
|
|
209
|
-
|
|
197
|
+
io,
|
|
210
198
|
`projects/${projectId}/variables/${key}`,
|
|
211
199
|
undefined,
|
|
212
200
|
"DELETE",
|
|
213
201
|
);
|
|
214
202
|
};
|
|
215
203
|
|
|
216
|
-
const getAllCatladderEnvVarsInGitlab = async (
|
|
217
|
-
const allVariables = await getAllVariables(
|
|
204
|
+
const getAllCatladderEnvVarsInGitlab = async (io: IO) => {
|
|
205
|
+
const allVariables = await getAllVariables(io).then((v) =>
|
|
218
206
|
v.reduce<{
|
|
219
207
|
[key: string]: {
|
|
220
208
|
value?: string;
|
|
@@ -257,32 +245,32 @@ const getAllCatladderEnvVarsInGitlab = async (vorpal: CommandInstance) => {
|
|
|
257
245
|
|
|
258
246
|
const getBackupKey = (fullKey: string, timestamp: number) =>
|
|
259
247
|
`${fullKey}_backup_${timestamp}`;
|
|
260
|
-
export const clearBackups = async (
|
|
261
|
-
const existingVariables = await getAllCatladderEnvVarsInGitlab(
|
|
262
|
-
const { id } = await getProjectInfo(
|
|
248
|
+
export const clearBackups = async (io: IO, keep: number) => {
|
|
249
|
+
const existingVariables = await getAllCatladderEnvVarsInGitlab(io);
|
|
250
|
+
const { id } = await getProjectInfo(io);
|
|
263
251
|
for (const [key, { backups }] of Object.entries(existingVariables)) {
|
|
264
252
|
const backupsSorted = backups.sort((a, b) => b - a);
|
|
265
253
|
//const toKeep = backupsSorted.slice(0, keep);
|
|
266
254
|
const toDelete = backupsSorted.slice(keep);
|
|
267
255
|
|
|
268
256
|
for (const timestamp of toDelete) {
|
|
269
|
-
await deleteVariable(
|
|
257
|
+
await deleteVariable(io, id, getBackupKey(key, timestamp));
|
|
270
258
|
}
|
|
271
259
|
}
|
|
272
260
|
};
|
|
273
261
|
|
|
274
262
|
export const upsertAllVariables = async (
|
|
275
|
-
|
|
263
|
+
io: IO,
|
|
276
264
|
variables: Record<string, any>,
|
|
277
265
|
env: string,
|
|
278
266
|
componentName: string,
|
|
279
267
|
backup = true,
|
|
280
268
|
masked = true, // FIXME: would be better to have this per variable
|
|
281
269
|
): Promise<void> => {
|
|
282
|
-
const { id } = await getProjectInfo(
|
|
270
|
+
const { id } = await getProjectInfo(io);
|
|
283
271
|
|
|
284
272
|
// we list all existing variables. We also gather backup versions, but its currently unused
|
|
285
|
-
const existingVariables = await getAllCatladderEnvVarsInGitlab(
|
|
273
|
+
const existingVariables = await getAllCatladderEnvVarsInGitlab(io);
|
|
286
274
|
for (const [key, value] of Object.entries(variables ?? {})) {
|
|
287
275
|
const fullKey = getSecretVarName(env, componentName, key);
|
|
288
276
|
const valueSanitized = isObject(value) ? JSON.stringify(value) : `${value}`;
|
|
@@ -292,13 +280,13 @@ export const upsertAllVariables = async (
|
|
|
292
280
|
const changed = oldValue !== valueSanitized;
|
|
293
281
|
if (changed) {
|
|
294
282
|
if (exists) {
|
|
295
|
-
|
|
283
|
+
io.log(`changed: ${key}`);
|
|
296
284
|
|
|
297
|
-
await updateVariable(
|
|
285
|
+
await updateVariable(io, id, fullKey, valueSanitized, masked);
|
|
298
286
|
// write backup
|
|
299
287
|
if (backup) {
|
|
300
288
|
await createVariable(
|
|
301
|
-
|
|
289
|
+
io,
|
|
302
290
|
id,
|
|
303
291
|
getBackupKey(fullKey, new Date().getTime()),
|
|
304
292
|
oldValue,
|
|
@@ -307,11 +295,11 @@ export const upsertAllVariables = async (
|
|
|
307
295
|
);
|
|
308
296
|
}
|
|
309
297
|
} else {
|
|
310
|
-
|
|
311
|
-
await createVariable(
|
|
298
|
+
io.log(`new : ${key}`);
|
|
299
|
+
await createVariable(io, id, fullKey, valueSanitized, masked);
|
|
312
300
|
}
|
|
313
301
|
} else {
|
|
314
|
-
|
|
302
|
+
io.log(`skip : ${key}`);
|
|
315
303
|
}
|
|
316
304
|
}
|
|
317
305
|
getAllVariables.clear();
|
package/src/utils/log.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IO } from "../core/types";
|
|
2
2
|
|
|
3
3
|
type AnyMessagesFn = (message?: any, ...optionalParams: any[]) => void;
|
|
4
4
|
type StringMessagesFn = (message?: string, ...optionalParams: string[]) => void;
|
|
@@ -21,7 +21,7 @@ type HasSomeKindOfLogMethod = { log: SomeKindOfLogFn };
|
|
|
21
21
|
* null and undefined will fall back to console.log.
|
|
22
22
|
*/
|
|
23
23
|
export type LoggerCmdInstance =
|
|
24
|
-
|
|
|
24
|
+
| IO
|
|
25
25
|
| Console
|
|
26
26
|
| HasSomeKindOfLogMethod
|
|
27
27
|
| null
|
package/bin/catci
DELETED
package/bin/catci-dev
DELETED