@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.
- 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 +201 -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/base/createBuildJobDefinition.js +1 -1
- package/dist/pipeline/src/build/base/createBuildJobDefinition.js.map +1 -1
- package/dist/pipeline/src/build/custom/buildJob.js +1 -1
- package/dist/pipeline/src/build/custom/buildJob.js.map +1 -1
- 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 +9 -8
- 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 +3 -3
- 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 +202 -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,99 @@
|
|
|
1
|
+
import type { V1ObjectMeta } from "@kubernetes/client-node";
|
|
2
|
+
import { V1Job } from "@kubernetes/client-node";
|
|
3
|
+
import { defineCommand } from "../../core/defineCommand";
|
|
4
|
+
import { getk8sApiBatch, getk8sApiBatchBeta } from "../../k8sApi";
|
|
5
|
+
import { logError } from "../../utils/log";
|
|
6
|
+
import { getProjectNamespace } from "../../utils/projects";
|
|
7
|
+
import { ensureCluster } from "../../apps/cli/commands/project/utils/ensureCluster";
|
|
8
|
+
import { envAndComponents } from "../../apps/cli/commands/project/utils/autocompletions";
|
|
9
|
+
|
|
10
|
+
const getCronjobChoices = async (namespace: string) => {
|
|
11
|
+
const {
|
|
12
|
+
body: { items: jobs },
|
|
13
|
+
} = await getk8sApiBatchBeta().listNamespacedCronJob(namespace);
|
|
14
|
+
return jobs.map((j: any) => j.metadata.name) as string[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const runCronjob = async (
|
|
18
|
+
io: { log: (msg: string) => void },
|
|
19
|
+
namespace: string,
|
|
20
|
+
jobName: string,
|
|
21
|
+
) => {
|
|
22
|
+
const {
|
|
23
|
+
body: { items: jobs },
|
|
24
|
+
} = await getk8sApiBatchBeta().listNamespacedCronJob(namespace);
|
|
25
|
+
|
|
26
|
+
const cronjob = jobs.find((j: any) => j.metadata.name === jobName);
|
|
27
|
+
const jobSpec = (cronjob as any).spec.jobTemplate.spec;
|
|
28
|
+
|
|
29
|
+
const job = new V1Job();
|
|
30
|
+
const metadata: Partial<V1ObjectMeta> = {
|
|
31
|
+
name: `manual-${Math.round(Date.now() / 1000)}-${(cronjob as any).metadata.name}`,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
job.metadata = metadata as V1ObjectMeta;
|
|
35
|
+
job.spec = jobSpec;
|
|
36
|
+
try {
|
|
37
|
+
const result = await getk8sApiBatch().createNamespacedJob(namespace, job);
|
|
38
|
+
io.log("");
|
|
39
|
+
io.log(
|
|
40
|
+
`yeah, you got a job, man. 😺 ${(result as any).body.metadata.name}`,
|
|
41
|
+
);
|
|
42
|
+
io.log("");
|
|
43
|
+
} catch (e: any) {
|
|
44
|
+
logError(io, "command failed", e.body);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const commandTriggerCronjobGeneral = defineCommand({
|
|
49
|
+
name: "kube trigger-cronjob",
|
|
50
|
+
description: "trigger cronjob",
|
|
51
|
+
group: "general",
|
|
52
|
+
inputs: {
|
|
53
|
+
namespace: {
|
|
54
|
+
type: "string",
|
|
55
|
+
message: "kubernetes namespace",
|
|
56
|
+
positional: true,
|
|
57
|
+
},
|
|
58
|
+
jobName: {
|
|
59
|
+
type: "string",
|
|
60
|
+
message: "Which cronjob? 🤔",
|
|
61
|
+
choices: async (ctx) => getCronjobChoices(await ctx.get("namespace")),
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
execute: async (ctx) => {
|
|
65
|
+
const namespace = await ctx.get("namespace");
|
|
66
|
+
const jobName = await ctx.get("jobName");
|
|
67
|
+
await runCronjob(ctx, namespace, jobName);
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export const commandTriggerCronjobProject = defineCommand({
|
|
72
|
+
name: "project trigger-cronjob",
|
|
73
|
+
description: "trigger cronjob",
|
|
74
|
+
group: "project",
|
|
75
|
+
inputs: {
|
|
76
|
+
envComponent: {
|
|
77
|
+
type: "string",
|
|
78
|
+
message: "environment:component",
|
|
79
|
+
positional: true,
|
|
80
|
+
choices: async () => envAndComponents(),
|
|
81
|
+
},
|
|
82
|
+
jobName: {
|
|
83
|
+
type: "string",
|
|
84
|
+
message: "Which cronjob? 🤔",
|
|
85
|
+
choices: async (ctx) => {
|
|
86
|
+
const envComponent = await ctx.get("envComponent");
|
|
87
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
88
|
+
return getCronjobChoices(namespace);
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
execute: async (ctx) => {
|
|
93
|
+
const envComponent = await ctx.get("envComponent");
|
|
94
|
+
await ensureCluster(ctx, envComponent);
|
|
95
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
96
|
+
const jobName = await ctx.get("jobName");
|
|
97
|
+
await runCronjob(ctx, namespace, jobName);
|
|
98
|
+
},
|
|
99
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { defineCommand } from "../../core/defineCommand";
|
|
2
|
+
import { Gitlab } from "@gitbeaker/rest";
|
|
3
|
+
import {
|
|
4
|
+
evaluateSecurityAudit,
|
|
5
|
+
makeSecurityAuditOverview,
|
|
6
|
+
} from "../../security/evaluateSecurityAudit";
|
|
7
|
+
import {
|
|
8
|
+
createSecurityAuditMergeRequest,
|
|
9
|
+
SECURITY_AUDIT_FILE_NAME,
|
|
10
|
+
} from "../../security/createSecurityAuditMergeRequest";
|
|
11
|
+
|
|
12
|
+
const GITLAB_HOST = "https://git.panter.ch";
|
|
13
|
+
|
|
14
|
+
export const commandSecurityAuditCiJob = defineCommand({
|
|
15
|
+
name: "security audit ci-job",
|
|
16
|
+
description:
|
|
17
|
+
"Evaluates security audit document. Creates MR with template if missing.",
|
|
18
|
+
group: "security",
|
|
19
|
+
inputs: {
|
|
20
|
+
path: { type: "string", message: "path to project root", positional: true },
|
|
21
|
+
token: {
|
|
22
|
+
type: "string",
|
|
23
|
+
message: "GitLab token (api scope)",
|
|
24
|
+
positional: true,
|
|
25
|
+
},
|
|
26
|
+
mainBranch: {
|
|
27
|
+
type: "string",
|
|
28
|
+
message: "main branch name",
|
|
29
|
+
positional: true,
|
|
30
|
+
},
|
|
31
|
+
projectId: {
|
|
32
|
+
type: "string",
|
|
33
|
+
message: "GitLab project ID",
|
|
34
|
+
positional: true,
|
|
35
|
+
},
|
|
36
|
+
userId: {
|
|
37
|
+
type: "string",
|
|
38
|
+
message: "GitLab user ID (assignee)",
|
|
39
|
+
positional: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
execute: async (ctx) => {
|
|
43
|
+
const path = await ctx.get("path");
|
|
44
|
+
const evaluation = await evaluateSecurityAudit({ path });
|
|
45
|
+
|
|
46
|
+
if (evaluation.isErr()) {
|
|
47
|
+
ctx.log("could not evaluate security audit document");
|
|
48
|
+
ctx.log("creating new merge request with security audit template...");
|
|
49
|
+
|
|
50
|
+
const token = await ctx.get("token");
|
|
51
|
+
const mainBranch = await ctx.get("mainBranch");
|
|
52
|
+
const projectId = await ctx.get("projectId");
|
|
53
|
+
const userId = await ctx.get("userId");
|
|
54
|
+
|
|
55
|
+
const api = new Gitlab({ host: GITLAB_HOST, token });
|
|
56
|
+
|
|
57
|
+
const mr = await createSecurityAuditMergeRequest({
|
|
58
|
+
api,
|
|
59
|
+
mainBranch,
|
|
60
|
+
projectId,
|
|
61
|
+
userId: parseInt(userId),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (mr.isErr()) {
|
|
65
|
+
ctx.log(
|
|
66
|
+
`could not create merge request with security audit template: ${mr.error}`,
|
|
67
|
+
);
|
|
68
|
+
process.exitCode = 1;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
ctx.log("security audit merge request created successfully");
|
|
73
|
+
ctx.log(
|
|
74
|
+
`please finish the MR by updating SECURITY.md document: ${mr.value.web_url}`,
|
|
75
|
+
);
|
|
76
|
+
process.exitCode = 1;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (evaluation.value.score.answeredTopics === 0) {
|
|
81
|
+
ctx.log("audit document has no answered topics");
|
|
82
|
+
ctx.log(
|
|
83
|
+
`please answer security topics in ${SECURITY_AUDIT_FILE_NAME} by adding responsible people and check/cross in the table`,
|
|
84
|
+
);
|
|
85
|
+
process.exitCode = 1;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
ctx.log(makeSecurityAuditOverview(evaluation.value));
|
|
90
|
+
},
|
|
91
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { defineCommand } from "../../core/defineCommand";
|
|
2
|
+
import { Gitlab } from "@gitbeaker/rest";
|
|
3
|
+
import { createSecurityAuditMergeRequest } from "../../security/createSecurityAuditMergeRequest";
|
|
4
|
+
|
|
5
|
+
const GITLAB_HOST = "https://git.panter.ch";
|
|
6
|
+
|
|
7
|
+
export const commandSecurityAuditCreate = defineCommand({
|
|
8
|
+
name: "security audit create",
|
|
9
|
+
description: "Creates a MR with the latest security audit template document",
|
|
10
|
+
group: "security",
|
|
11
|
+
inputs: {
|
|
12
|
+
token: {
|
|
13
|
+
type: "string",
|
|
14
|
+
message: "GitLab token (api scope)",
|
|
15
|
+
positional: true,
|
|
16
|
+
},
|
|
17
|
+
mainBranch: {
|
|
18
|
+
type: "string",
|
|
19
|
+
message: "main branch name",
|
|
20
|
+
positional: true,
|
|
21
|
+
},
|
|
22
|
+
projectId: {
|
|
23
|
+
type: "string",
|
|
24
|
+
message: "GitLab project ID",
|
|
25
|
+
positional: true,
|
|
26
|
+
},
|
|
27
|
+
userId: {
|
|
28
|
+
type: "string",
|
|
29
|
+
message: "GitLab user ID (assignee)",
|
|
30
|
+
positional: true,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
execute: async (ctx) => {
|
|
34
|
+
const token = await ctx.get("token");
|
|
35
|
+
const mainBranch = await ctx.get("mainBranch");
|
|
36
|
+
const projectId = await ctx.get("projectId");
|
|
37
|
+
const userId = await ctx.get("userId");
|
|
38
|
+
|
|
39
|
+
const api = new Gitlab({ host: GITLAB_HOST, token });
|
|
40
|
+
|
|
41
|
+
const result = await createSecurityAuditMergeRequest({
|
|
42
|
+
api,
|
|
43
|
+
mainBranch,
|
|
44
|
+
projectId,
|
|
45
|
+
userId: parseInt(userId),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (result.isErr()) {
|
|
49
|
+
ctx.log(`could not create security audit merge request: ${result.error}`);
|
|
50
|
+
process.exitCode = 1;
|
|
51
|
+
} else {
|
|
52
|
+
ctx.log("security audit merge request created successfully");
|
|
53
|
+
ctx.log(
|
|
54
|
+
`please finish the MR by updating SECURITY.md document: ${result.value.web_url}`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defineCommand } from "../../core/defineCommand";
|
|
2
|
+
import {
|
|
3
|
+
evaluateSecurityAudit,
|
|
4
|
+
makeSecurityAuditOverview,
|
|
5
|
+
} from "../../security/evaluateSecurityAudit";
|
|
6
|
+
import { SECURITY_AUDIT_FILE_NAME } from "../../security/createSecurityAuditMergeRequest";
|
|
7
|
+
|
|
8
|
+
export const commandSecurityAuditEvaluate = defineCommand({
|
|
9
|
+
name: "security audit evaluate",
|
|
10
|
+
description: "Evaluates security audit document in given path",
|
|
11
|
+
group: "security",
|
|
12
|
+
inputs: {
|
|
13
|
+
path: { type: "string", message: "path to project root", positional: true },
|
|
14
|
+
},
|
|
15
|
+
execute: async (ctx) => {
|
|
16
|
+
const path = await ctx.get("path");
|
|
17
|
+
ctx.log("evaluating security audit document...");
|
|
18
|
+
|
|
19
|
+
const result = await evaluateSecurityAudit({ path });
|
|
20
|
+
if (result.isErr()) {
|
|
21
|
+
ctx.log(`${result.error}`);
|
|
22
|
+
ctx.log(
|
|
23
|
+
`please make sure the security audit document ${SECURITY_AUDIT_FILE_NAME} is in the repository`,
|
|
24
|
+
);
|
|
25
|
+
process.exitCode = 1;
|
|
26
|
+
} else {
|
|
27
|
+
ctx.log(makeSecurityAuditOverview(result.value));
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync } from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
import type { CommandDef, InputDef } from "./core/types";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generate completions for the current command line.
|
|
8
|
+
*
|
|
9
|
+
* @param allCommands - All registered command definitions
|
|
10
|
+
* @param words - The words typed so far (argv without the binary name)
|
|
11
|
+
* @param cursorWord - The word currently being completed (may be empty)
|
|
12
|
+
* @returns Array of completion strings
|
|
13
|
+
*/
|
|
14
|
+
export async function getCompletions(
|
|
15
|
+
allCommands: CommandDef[],
|
|
16
|
+
words: string[],
|
|
17
|
+
cursorWord: string,
|
|
18
|
+
): Promise<string[]> {
|
|
19
|
+
// Try to find a command by matching the longest prefix of words.
|
|
20
|
+
// E.g., for words ["project", "cloudsql", "restore-db", "--source"],
|
|
21
|
+
// we match "project cloudsql restore-db" and treat ["--source"] as args.
|
|
22
|
+
const matched = findCommand(allCommands, words);
|
|
23
|
+
|
|
24
|
+
if (matched) {
|
|
25
|
+
const { command, argsAfterCommand } = matched;
|
|
26
|
+
|
|
27
|
+
// Check if cursor is a --flag name
|
|
28
|
+
if (cursorWord.startsWith("--")) {
|
|
29
|
+
return getFlagCompletions(command, cursorWord);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Check if previous word was a --flag (complete its value)
|
|
33
|
+
const prevWord = argsAfterCommand[argsAfterCommand.length - 1];
|
|
34
|
+
if (prevWord?.startsWith("--")) {
|
|
35
|
+
const flagName = prevWord.replace(/^--/, "");
|
|
36
|
+
const inputName = flagNameToInputName(flagName);
|
|
37
|
+
const inputDef = command.inputs[inputName];
|
|
38
|
+
if (inputDef && "choices" in inputDef && inputDef.choices) {
|
|
39
|
+
return resolveChoicesForCompletion(inputDef, cursorWord);
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Complete positional inputs
|
|
45
|
+
const positionalInputs = getPositionalInputs(command);
|
|
46
|
+
const positionalArgs = argsAfterCommand.filter((w) => !w.startsWith("--"));
|
|
47
|
+
const positionalIndex = positionalArgs.length;
|
|
48
|
+
const targetInput = positionalInputs[positionalIndex];
|
|
49
|
+
|
|
50
|
+
if (targetInput) {
|
|
51
|
+
const [, inputDef] = targetInput;
|
|
52
|
+
if ("choices" in inputDef && inputDef.choices) {
|
|
53
|
+
return resolveChoicesForCompletion(inputDef, cursorWord);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// No command matched. Complete subcommand names at the current level.
|
|
60
|
+
const typed = words.join(" ");
|
|
61
|
+
const prefix = typed ? typed + " " : "";
|
|
62
|
+
|
|
63
|
+
const nextParts = new Set<string>();
|
|
64
|
+
for (const cmd of allCommands) {
|
|
65
|
+
if (cmd.name.startsWith(prefix)) {
|
|
66
|
+
const rest = cmd.name.slice(prefix.length);
|
|
67
|
+
const nextPart = rest.split(" ")[0];
|
|
68
|
+
if (nextPart && nextPart.startsWith(cursorWord)) {
|
|
69
|
+
nextParts.add(nextPart);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return [...nextParts].sort();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Find a command by matching the longest prefix of words against command names.
|
|
79
|
+
* Returns the matched command and the remaining words (args/flags after the command name).
|
|
80
|
+
*/
|
|
81
|
+
function findCommand(
|
|
82
|
+
allCommands: CommandDef[],
|
|
83
|
+
words: string[],
|
|
84
|
+
): { command: CommandDef; argsAfterCommand: string[] } | null {
|
|
85
|
+
// Try longest match first
|
|
86
|
+
for (let i = words.length; i >= 1; i--) {
|
|
87
|
+
const candidate = words.slice(0, i).join(" ");
|
|
88
|
+
const command = allCommands.find((c) => c.name === candidate);
|
|
89
|
+
if (command) {
|
|
90
|
+
return { command, argsAfterCommand: words.slice(i) };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function getPositionalInputs(command: CommandDef): [string, InputDef][] {
|
|
97
|
+
return Object.entries(command.inputs).filter(([, def]) => def.positional);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function getFlagCompletions(command: CommandDef, cursorWord: string): string[] {
|
|
101
|
+
const flags: string[] = [];
|
|
102
|
+
for (const [name, inputDef] of Object.entries(command.inputs)) {
|
|
103
|
+
if (inputDef.positional) continue;
|
|
104
|
+
const flagName = `--${name.replace(/([A-Z])/g, "-$1").toLowerCase()}`;
|
|
105
|
+
flags.push(flagName);
|
|
106
|
+
}
|
|
107
|
+
flags.push("--inputs");
|
|
108
|
+
flags.push("--yes");
|
|
109
|
+
return flags.filter((f) => f.startsWith(cursorWord));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function flagNameToInputName(flagName: string): string {
|
|
113
|
+
return flagName.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function resolveChoicesForCompletion(
|
|
117
|
+
inputDef: InputDef,
|
|
118
|
+
cursorWord: string,
|
|
119
|
+
): Promise<string[]> {
|
|
120
|
+
if (!("choices" in inputDef) || !inputDef.choices) return [];
|
|
121
|
+
try {
|
|
122
|
+
// Create a minimal ctx that returns empty for any get() call.
|
|
123
|
+
// This works for choices functions that don't depend on other inputs
|
|
124
|
+
// (like envAndComponents). For dependent choices, completion won't work
|
|
125
|
+
// but that's acceptable -- those are typically non-positional.
|
|
126
|
+
const noopCtx = {
|
|
127
|
+
get: () => Promise.reject(new Error("not available during completion")),
|
|
128
|
+
log: () => {},
|
|
129
|
+
confirm: () => Promise.resolve(true),
|
|
130
|
+
promptDirect: () =>
|
|
131
|
+
Promise.reject(new Error("not available during completion")),
|
|
132
|
+
};
|
|
133
|
+
const choices = await inputDef.choices(noopCtx);
|
|
134
|
+
return choices
|
|
135
|
+
.map((c) => (typeof c === "string" ? c : c.value))
|
|
136
|
+
.filter((v) => v.startsWith(cursorWord));
|
|
137
|
+
} catch {
|
|
138
|
+
// If choices function fails (e.g., needs other inputs), return nothing
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Generate the zsh completion script.
|
|
145
|
+
* The script discovers the local catladder binary at completion time,
|
|
146
|
+
* so it works without a global install.
|
|
147
|
+
*/
|
|
148
|
+
export function generateZshCompletionScript(): string {
|
|
149
|
+
return `
|
|
150
|
+
###-begin-catladder-completions-###
|
|
151
|
+
# Find catladder binary by walking up from cwd
|
|
152
|
+
_catladder_find_binary() {
|
|
153
|
+
local dir="$PWD"
|
|
154
|
+
while [[ "$dir" != "/" ]]; do
|
|
155
|
+
if [[ -x "$dir/node_modules/.bin/catladder" ]]; then
|
|
156
|
+
echo "$dir/node_modules/.bin/catladder"
|
|
157
|
+
return
|
|
158
|
+
fi
|
|
159
|
+
# Also check for catladder-dev (monorepo development)
|
|
160
|
+
if [[ -x "$dir/cli/bin/catladder-dev" ]]; then
|
|
161
|
+
echo "$dir/cli/bin/catladder-dev"
|
|
162
|
+
return
|
|
163
|
+
fi
|
|
164
|
+
dir="\${dir:h}"
|
|
165
|
+
done
|
|
166
|
+
# Fall back to global
|
|
167
|
+
if command -v catladder &>/dev/null; then
|
|
168
|
+
echo "catladder"
|
|
169
|
+
elif command -v catladder-dev &>/dev/null; then
|
|
170
|
+
echo "catladder-dev"
|
|
171
|
+
fi
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
# Run completion with given offset (number of words to skip before CLI args)
|
|
175
|
+
_catladder_do_complete() {
|
|
176
|
+
local skip=$1
|
|
177
|
+
local catladder_bin=$(_catladder_find_binary)
|
|
178
|
+
[[ -z "$catladder_bin" ]] && return
|
|
179
|
+
|
|
180
|
+
local -a completions
|
|
181
|
+
local current_word="\${words[$CURRENT]}"
|
|
182
|
+
local -a cmd_words=(\${words:$skip:$((CURRENT-skip-1))})
|
|
183
|
+
|
|
184
|
+
completions=(\${(f)"$($catladder_bin __complete -- "\${cmd_words[*]}" "$current_word" 2>/dev/null)"})
|
|
185
|
+
|
|
186
|
+
if [[ \${#completions[@]} -gt 0 ]]; then
|
|
187
|
+
compadd -a completions
|
|
188
|
+
fi
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
# catladder <TAB>
|
|
192
|
+
_catladder_completions() { _catladder_do_complete 1; }
|
|
193
|
+
|
|
194
|
+
# yarn catladder <TAB>
|
|
195
|
+
_yarn_catladder_completions() {
|
|
196
|
+
[[ $CURRENT -le 2 || "\${words[2]}" != "catladder" ]] && return
|
|
197
|
+
_catladder_do_complete 2
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
compdef _catladder_completions catladder
|
|
201
|
+
compdef _catladder_completions catladder-dev
|
|
202
|
+
compdef _yarn_catladder_completions yarn
|
|
203
|
+
###-end-catladder-completions-###
|
|
204
|
+
`.trim();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const BEGIN_MARKER = "###-begin-catladder-completions-###";
|
|
208
|
+
const END_MARKER = "###-end-catladder-completions-###";
|
|
209
|
+
|
|
210
|
+
function getZshrcPath(): string {
|
|
211
|
+
return join(homedir(), ".zshrc");
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Install completions by writing the script directly into .zshrc.
|
|
216
|
+
*/
|
|
217
|
+
export async function installCompletions(): Promise<void> {
|
|
218
|
+
const zshrcPath = getZshrcPath();
|
|
219
|
+
|
|
220
|
+
let content = "";
|
|
221
|
+
if (existsSync(zshrcPath)) {
|
|
222
|
+
content = readFileSync(zshrcPath, "utf-8");
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (content.includes(BEGIN_MARKER)) {
|
|
226
|
+
// Replace existing
|
|
227
|
+
const startIdx = content.indexOf(BEGIN_MARKER);
|
|
228
|
+
const endIdx = content.indexOf(END_MARKER) + END_MARKER.length;
|
|
229
|
+
content =
|
|
230
|
+
content.slice(0, startIdx) +
|
|
231
|
+
generateZshCompletionScript() +
|
|
232
|
+
content.slice(endIdx);
|
|
233
|
+
writeFileSync(zshrcPath, content);
|
|
234
|
+
console.log(`Updated catladder completions in ${zshrcPath}`);
|
|
235
|
+
} else {
|
|
236
|
+
writeFileSync(
|
|
237
|
+
zshrcPath,
|
|
238
|
+
content + "\n" + generateZshCompletionScript() + "\n",
|
|
239
|
+
);
|
|
240
|
+
console.log(`Installed catladder completions in ${zshrcPath}`);
|
|
241
|
+
}
|
|
242
|
+
console.log(`Restart your shell or run: source ${zshrcPath}`);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Remove completions from .zshrc.
|
|
247
|
+
*/
|
|
248
|
+
export async function uninstallCompletions(): Promise<void> {
|
|
249
|
+
const zshrcPath = getZshrcPath();
|
|
250
|
+
if (!existsSync(zshrcPath)) {
|
|
251
|
+
console.log("No .zshrc found");
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const content = readFileSync(zshrcPath, "utf-8");
|
|
256
|
+
|
|
257
|
+
if (!content.includes(BEGIN_MARKER)) {
|
|
258
|
+
console.log("No catladder completions found in " + zshrcPath);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const startIdx = content.indexOf(BEGIN_MARKER);
|
|
263
|
+
const endIdx = content.indexOf(END_MARKER) + END_MARKER.length;
|
|
264
|
+
const cleaned = (content.slice(0, startIdx) + content.slice(endIdx)).replace(
|
|
265
|
+
/\n{3,}/g,
|
|
266
|
+
"\n\n",
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
writeFileSync(zshrcPath, cleaned);
|
|
270
|
+
console.log(`Removed catladder completions from ${zshrcPath}`);
|
|
271
|
+
console.log(`Restart your shell or run: source ${zshrcPath}`);
|
|
272
|
+
}
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getSecretVarName,
|
|
12
12
|
} from "@catladder/pipeline";
|
|
13
13
|
|
|
14
|
-
import type {
|
|
14
|
+
import type { IO } from "../core/types";
|
|
15
15
|
import { getAllVariables, getVariableValueByRawName } from "../utils/gitlab";
|
|
16
16
|
|
|
17
17
|
import { getGitRoot } from "../utils/projects";
|
|
@@ -121,20 +121,20 @@ export const getEnvironment = async (env: string, componentName: string) => {
|
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
export const getGitlabVar = async (
|
|
124
|
-
|
|
124
|
+
io: IO,
|
|
125
125
|
env: string,
|
|
126
126
|
componentName: string,
|
|
127
127
|
variableName: string,
|
|
128
128
|
) => {
|
|
129
129
|
const rawVariableName = getSecretVarName(env, componentName, variableName);
|
|
130
|
-
return await getVariableValueByRawName(
|
|
130
|
+
return await getVariableValueByRawName(io, rawVariableName);
|
|
131
131
|
};
|
|
132
132
|
|
|
133
133
|
const resolveSecrets = async (
|
|
134
|
-
|
|
134
|
+
io: IO | null,
|
|
135
135
|
varSets: EnvironmentEnvVars[],
|
|
136
136
|
): Promise<Record<string, string>> => {
|
|
137
|
-
const allVariablesInGitlab = await getAllVariables(
|
|
137
|
+
const allVariablesInGitlab = await getAllVariables(io);
|
|
138
138
|
|
|
139
139
|
return Object.fromEntries(
|
|
140
140
|
varSets.flatMap(({ envVars, secretEnvVarKeys }) =>
|
|
@@ -158,7 +158,7 @@ const resolveSecrets = async (
|
|
|
158
158
|
};
|
|
159
159
|
|
|
160
160
|
export const getEnvVarsResolved = async (
|
|
161
|
-
|
|
161
|
+
io: IO | null,
|
|
162
162
|
env: string,
|
|
163
163
|
componentName: string | null,
|
|
164
164
|
) => {
|
|
@@ -170,7 +170,7 @@ export const getEnvVarsResolved = async (
|
|
|
170
170
|
|
|
171
171
|
// in the pipeline the secrets alreadyy exists and bash will expand them
|
|
172
172
|
// but here we need to manually load them
|
|
173
|
-
return resolveSecrets(
|
|
173
|
+
return resolveSecrets(io, [
|
|
174
174
|
{
|
|
175
175
|
envVars: envionment.envVars,
|
|
176
176
|
secretEnvVarKeys: envionment.secretEnvVarKeys,
|
|
@@ -183,12 +183,12 @@ export const getEnvVarsResolved = async (
|
|
|
183
183
|
* is used to get job only vars that should also be editable locally with catladder.
|
|
184
184
|
*/
|
|
185
185
|
export const getJobOnlyEnvVarsResolved = async (
|
|
186
|
-
|
|
186
|
+
io: IO,
|
|
187
187
|
env: string,
|
|
188
188
|
componentName: string,
|
|
189
189
|
) => {
|
|
190
190
|
const envionment = await getEnvironment(env, componentName);
|
|
191
|
-
return resolveSecrets(
|
|
191
|
+
return resolveSecrets(io, [
|
|
192
192
|
envionment.jobOnlyVars.build,
|
|
193
193
|
envionment.jobOnlyVars.deploy,
|
|
194
194
|
]);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CommandDef, InputDef } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type-safe builder for command definitions.
|
|
5
|
+
* Infers TInputs from the definition object so that
|
|
6
|
+
* `ctx.get("...")` is fully typed.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* export const myCommand = defineCommand({
|
|
11
|
+
* name: "my-command",
|
|
12
|
+
* description: "Does something",
|
|
13
|
+
* inputs: {
|
|
14
|
+
* envComponent: { type: "string", message: "env:component", positional: true },
|
|
15
|
+
* podName: { type: "string", message: "Which pod?", choices: async () => ["a", "b"] },
|
|
16
|
+
* mr: { type: "number", message: "Which MR?" },
|
|
17
|
+
* confirmed: { type: "boolean", message: "Continue?" },
|
|
18
|
+
* },
|
|
19
|
+
* execute: async (ctx) => {
|
|
20
|
+
* const env = await ctx.get("envComponent"); // string
|
|
21
|
+
* const pod = await ctx.get("podName"); // string
|
|
22
|
+
* const mr = await ctx.get("mr"); // number
|
|
23
|
+
* const ok = await ctx.get("confirmed"); // boolean
|
|
24
|
+
* },
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function defineCommand<const TInputs extends Record<string, InputDef>>(
|
|
29
|
+
def: CommandDef<TInputs>,
|
|
30
|
+
): CommandDef<TInputs> {
|
|
31
|
+
return def;
|
|
32
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
CommandContext,
|
|
3
|
+
CommandDef,
|
|
4
|
+
IO,
|
|
5
|
+
InputDef,
|
|
6
|
+
InputResultType,
|
|
7
|
+
InputsSchema,
|
|
8
|
+
StringInputDef,
|
|
9
|
+
StringArrayInputDef,
|
|
10
|
+
NumberInputDef,
|
|
11
|
+
BooleanInputDef,
|
|
12
|
+
PromptChoice,
|
|
13
|
+
ChoicesFn,
|
|
14
|
+
} from "./types";
|
|
15
|
+
export { MissingInputError } from "./types";
|
|
16
|
+
export { defineCommand } from "./defineCommand";
|
|
17
|
+
export {
|
|
18
|
+
registerCommand,
|
|
19
|
+
getCommand,
|
|
20
|
+
getAllCommands,
|
|
21
|
+
getCommandsByGroup,
|
|
22
|
+
} from "./registry";
|
|
23
|
+
export { runCommand } from "./runner";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CommandDef } from "./types";
|
|
2
|
+
|
|
3
|
+
const commands: Map<string, CommandDef> = new Map();
|
|
4
|
+
|
|
5
|
+
export function registerCommand(def: CommandDef): void {
|
|
6
|
+
if (commands.has(def.name)) {
|
|
7
|
+
throw new Error(`Command "${def.name}" is already registered`);
|
|
8
|
+
}
|
|
9
|
+
commands.set(def.name, def);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getCommand(name: string): CommandDef | undefined {
|
|
13
|
+
return commands.get(name);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getAllCommands(): CommandDef[] {
|
|
17
|
+
return Array.from(commands.values());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function getCommandsByGroup(group: string): CommandDef[] {
|
|
21
|
+
return getAllCommands().filter((c) => c.group === group);
|
|
22
|
+
}
|