@catladder/cli 0.0.0-test7 → 0.0.0-update-meteor-53480fed
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/.nvmrc +1 -1
- package/README.md +6 -3
- package/bin/catenv +3 -0
- package/bin/catenv-dev +3 -0
- package/bin/catladder +1 -1
- package/bin/catladder-dev +3 -0
- package/dist/apps/catenv/catenv.d.ts +3 -0
- package/dist/apps/catenv/catenv.js +66 -0
- package/dist/apps/catenv/catenv.js.map +1 -0
- package/dist/apps/catenv/printVariables.d.ts +3 -0
- package/dist/apps/catenv/printVariables.js +115 -0
- package/dist/apps/catenv/printVariables.js.map +1 -0
- package/dist/apps/catenv/types.d.ts +5 -0
- package/dist/apps/catenv/types.js +3 -0
- package/dist/apps/catenv/types.js.map +1 -0
- package/dist/apps/catenv/utils.d.ts +12 -0
- package/dist/apps/catenv/utils.js +108 -0
- package/dist/apps/catenv/utils.js.map +1 -0
- package/dist/apps/catenv/writeDotEnvFiles.d.ts +3 -0
- package/dist/apps/catenv/writeDotEnvFiles.js +94 -0
- package/dist/apps/catenv/writeDotEnvFiles.js.map +1 -0
- package/dist/apps/catenv/writeEnvDTs.d.ts +3 -0
- package/dist/apps/catenv/writeEnvDTs.js +114 -0
- package/dist/apps/catenv/writeEnvDTs.js.map +1 -0
- package/dist/apps/cli/cli.d.ts +2 -0
- package/dist/apps/cli/cli.js +83 -0
- package/dist/apps/cli/cli.js.map +1 -0
- package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.d.ts +3 -0
- package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js +180 -0
- package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js.map +1 -0
- package/dist/apps/cli/commands/cloudSQL/index.d.ts +3 -0
- package/dist/apps/cli/commands/cloudSQL/index.js +50 -0
- package/dist/apps/cli/commands/cloudSQL/index.js.map +1 -0
- package/dist/apps/cli/commands/general/index.d.ts +4 -0
- package/dist/apps/cli/commands/general/index.js +216 -0
- package/dist/apps/cli/commands/general/index.js.map +1 -0
- package/dist/apps/cli/commands/general/namespaceAutoCompletion.d.ts +3 -0
- package/dist/apps/cli/commands/general/namespaceAutoCompletion.js +56 -0
- package/dist/apps/cli/commands/general/namespaceAutoCompletion.js.map +1 -0
- package/dist/apps/cli/commands/general/portForward.d.ts +3 -0
- package/dist/apps/cli/commands/general/portForward.js +97 -0
- package/dist/apps/cli/commands/general/portForward.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/index.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/index.js +53 -0
- package/dist/apps/cli/commands/mongodb/index.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +191 -0
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.js +96 -0
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +121 -0
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/utils/index.d.ts +13 -0
- package/dist/apps/cli/commands/mongodb/utils/index.js +179 -0
- package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -0
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +164 -0
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +5 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.js +334 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -0
- package/dist/apps/cli/commands/project/commandDeletePods.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandDeletePods.js +121 -0
- package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -0
- package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandDeleteProject.js +97 -0
- package/dist/apps/cli/commands/project/commandDeleteProject.js.map +1 -0
- package/dist/apps/cli/commands/project/commandEnvVars.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandEnvVars.js +74 -0
- package/dist/apps/cli/commands/project/commandEnvVars.js.map +1 -0
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js +58 -0
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js.map +1 -0
- package/dist/apps/cli/commands/project/commandGetShell.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandGetShell.js +96 -0
- package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -0
- package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandGitlabCi.js +185 -0
- package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -0
- package/dist/apps/cli/commands/project/commandInitProject.old.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandInitProject.old.js +345 -0
- package/dist/apps/cli/commands/project/commandInitProject.old.js.map +1 -0
- package/dist/apps/cli/commands/project/commandListPods.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandListPods.js +78 -0
- package/dist/apps/cli/commands/project/commandListPods.js.map +1 -0
- package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +7 -0
- package/dist/apps/cli/commands/project/commandMigrateHelm3.js +112 -0
- package/dist/apps/cli/commands/project/commandMigrateHelm3.js.map +1 -0
- package/dist/apps/cli/commands/project/commandNamespace.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandNamespace.js +70 -0
- package/dist/apps/cli/commands/project/commandNamespace.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.js +83 -0
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenDashboard.js +84 -0
- package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenEnv.js +80 -0
- package/dist/apps/cli/commands/project/commandOpenEnv.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenGit.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenGit.js +56 -0
- package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenGrafana.js +83 -0
- package/dist/apps/cli/commands/project/commandOpenGrafana.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +100 -0
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenLogs.js +74 -0
- package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -0
- package/dist/apps/cli/commands/project/commandPauseProject.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandPauseProject.js +97 -0
- package/dist/apps/cli/commands/project/commandPauseProject.js.map +1 -0
- package/dist/apps/cli/commands/project/commandPortForward.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandPortForward.js +168 -0
- package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -0
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.d.ts +5 -0
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.js +90 -0
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.js.map +1 -0
- package/dist/apps/cli/commands/project/commandSetup.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandSetup.js +58 -0
- package/dist/apps/cli/commands/project/commandSetup.js.map +1 -0
- package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandTriggerCronjob.js +144 -0
- package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -0
- package/dist/apps/cli/commands/project/index.d.ts +3 -0
- package/dist/apps/cli/commands/project/index.js +94 -0
- package/dist/apps/cli/commands/project/index.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/index.d.ts +2 -0
- package/dist/apps/cli/commands/project/setup/index.js +107 -0
- package/dist/apps/cli/commands/project/setup/index.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.d.ts +2 -0
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js +116 -0
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupCloudRun.d.ts +3 -0
- package/dist/apps/cli/commands/project/setup/setupCloudRun.js +118 -0
- package/dist/apps/cli/commands/project/setup/setupCloudRun.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupContext.d.ts +3 -0
- package/dist/apps/cli/commands/project/setup/setupContext.js +81 -0
- package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupKubernetes.d.ts +3 -0
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js +139 -0
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupTopic.d.ts +2 -0
- package/dist/apps/cli/commands/project/setup/setupTopic.js +69 -0
- package/dist/apps/cli/commands/project/setup/setupTopic.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/autocompletions.d.ts +3 -0
- package/dist/apps/cli/commands/project/utils/autocompletions.js +96 -0
- package/dist/apps/cli/commands/project/utils/autocompletions.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/ensureCluster.d.ts +1 -0
- package/dist/apps/cli/commands/project/utils/ensureCluster.js +84 -0
- package/dist/apps/cli/commands/project/utils/ensureCluster.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +2 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js +104 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +2 -0
- package/dist/apps/cli/commands/project/utils/showProjectBanner.js +58 -0
- package/dist/apps/cli/commands/project/utils/showProjectBanner.js.map +1 -0
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +3 -0
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js +101 -0
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js.map +1 -0
- package/dist/apps/cli/config/writeConfig.d.ts +5 -0
- package/dist/apps/cli/config/writeConfig.js +106 -0
- package/dist/apps/cli/config/writeConfig.js.map +1 -0
- package/dist/apps/cli/utils/getGoogleAuthUserNumber.d.ts +1 -0
- package/dist/apps/cli/utils/getGoogleAuthUserNumber.js +69 -0
- package/dist/apps/cli/utils/getGoogleAuthUserNumber.js.map +1 -0
- package/dist/apps/cli/verify/index.d.ts +2 -0
- package/dist/apps/cli/verify/index.js +94 -0
- package/dist/apps/cli/verify/index.js.map +1 -0
- package/dist/apps/cli/verify/migration/fromv2.d.ts +4 -0
- package/dist/apps/cli/verify/migration/fromv2.js +349 -0
- package/dist/apps/cli/verify/migration/fromv2.js.map +1 -0
- package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +4 -0
- package/dist/apps/cli/verify/migration/migrateSecrets.js +91 -0
- package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -0
- package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +18 -0
- package/dist/apps/cli/verify/migration/oldGitlabCi.js +30 -0
- package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +1 -0
- package/dist/bundles/catenv/index.js +46512 -0
- package/dist/bundles/catenv/xdg-open +1066 -0
- package/dist/bundles/cli/clipboard_i686.exe +0 -0
- package/dist/bundles/cli/clipboard_x86_64.exe +0 -0
- package/dist/bundles/cli/exec-child.js +39 -0
- package/dist/bundles/cli/index.js +363134 -0
- package/dist/bundles/cli/xdg-open +1066 -0
- package/dist/bundles/cli/xsel +0 -0
- package/dist/catenv.d.ts +1 -0
- package/dist/catenv.js +13 -0
- package/dist/catenv.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +8 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/constants.d.ts +2 -0
- package/dist/config/constants.js +6 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/config/getProjectConfig.d.ts +24 -0
- package/dist/config/getProjectConfig.js +313 -0
- package/dist/config/getProjectConfig.js.map +1 -0
- package/dist/config/parseChoice.d.ts +4 -0
- package/dist/config/parseChoice.js +9 -0
- package/dist/config/parseChoice.js.map +1 -0
- package/dist/gcloud/artifactsRegistry.d.ts +5 -0
- package/dist/gcloud/artifactsRegistry.js +59 -0
- package/dist/gcloud/artifactsRegistry.js.map +1 -0
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.d.ts +2 -0
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js +67 -0
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js.map +1 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.d.ts +3 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.js +62 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.js.map +1 -0
- package/dist/gcloud/cloudSql/startProxy.d.ts +10 -0
- package/dist/gcloud/cloudSql/startProxy.js +121 -0
- package/dist/gcloud/cloudSql/startProxy.js.map +1 -0
- package/dist/gcloud/enableServices.d.ts +3 -0
- package/dist/gcloud/enableServices.js +63 -0
- package/dist/gcloud/enableServices.js.map +1 -0
- package/dist/gcloud/openDashboard.d.ts +2 -0
- package/dist/gcloud/openDashboard.js +66 -0
- package/dist/gcloud/openDashboard.js.map +1 -0
- package/dist/gcloud/serviceAccounts.d.ts +12 -0
- package/dist/gcloud/serviceAccounts.js +144 -0
- package/dist/gcloud/serviceAccounts.js.map +1 -0
- package/dist/k8sApi/index.d.ts +8 -0
- package/dist/k8sApi/index.js +29 -0
- package/dist/k8sApi/index.js.map +1 -0
- package/dist/kubernetes/index.d.ts +3 -0
- package/dist/kubernetes/index.js +88 -0
- package/dist/kubernetes/index.js.map +1 -0
- package/dist/kubernetes/openKubernetesDashboards.d.ts +4 -0
- package/dist/kubernetes/openKubernetesDashboards.js +94 -0
- package/dist/kubernetes/openKubernetesDashboards.js.map +1 -0
- package/dist/kubernetes/portForward.d.ts +1 -0
- package/dist/kubernetes/portForward.js +55 -0
- package/dist/kubernetes/portForward.js.map +1 -0
- package/dist/packageInfos.d.ts +2 -0
- package/dist/packageInfos.js +6 -0
- package/dist/packageInfos.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/types.d.ts +18 -0
- package/dist/types/types.js +3 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils/cluster.d.ts +3 -0
- package/dist/utils/cluster.js +68 -0
- package/dist/utils/cluster.js.map +1 -0
- package/dist/utils/editAsFile.d.ts +1 -0
- package/dist/utils/editAsFile.js +85 -0
- package/dist/utils/editAsFile.js.map +1 -0
- package/dist/utils/files.d.ts +2 -0
- package/dist/utils/files.js +83 -0
- package/dist/utils/files.js.map +1 -0
- package/dist/utils/getEditor.d.ts +4 -0
- package/dist/utils/getEditor.js +70 -0
- package/dist/utils/getEditor.js.map +1 -0
- package/dist/utils/gitlab.d.ts +24 -0
- package/dist/utils/gitlab.js +397 -0
- package/dist/utils/gitlab.js.map +1 -0
- package/dist/utils/log.d.ts +1 -0
- package/dist/utils/log.js +14 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/passwordstore/index.d.ts +7 -0
- package/dist/utils/passwordstore/index.js +315 -0
- package/dist/utils/passwordstore/index.js.map +1 -0
- package/dist/utils/portForwards.d.ts +12 -0
- package/dist/utils/portForwards.js +120 -0
- package/dist/utils/portForwards.js.map +1 -0
- package/dist/utils/preferences/index.d.ts +3 -0
- package/dist/utils/preferences/index.js +119 -0
- package/dist/utils/preferences/index.js.map +1 -0
- package/dist/utils/projects/index.d.ts +5 -0
- package/dist/utils/projects/index.js +103 -0
- package/dist/utils/projects/index.js.map +1 -0
- package/dist/utils/promise.d.ts +2 -0
- package/dist/utils/promise.js +62 -0
- package/dist/utils/promise.js.map +1 -0
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.js +81 -0
- package/dist/utils/shell.js.map +1 -0
- package/package.json +32 -35
- package/scripts/bundle +4 -0
- package/src/apps/catenv/catenv.ts +14 -37
- package/src/apps/catenv/printVariables.ts +58 -0
- package/src/apps/catenv/types.ts +6 -0
- package/src/apps/catenv/utils.ts +49 -0
- package/src/apps/catenv/writeDotEnvFiles.ts +44 -0
- package/src/apps/catenv/writeEnvDTs.ts +71 -0
- package/src/apps/{shell/shell.ts → cli/cli.ts} +13 -3
- package/src/apps/cli/commands/cloudSQL/commandRestoreDb.ts +154 -0
- package/src/apps/cli/commands/cloudSQL/index.ts +8 -0
- package/src/apps/{shell → cli}/commands/general/index.ts +16 -52
- package/src/apps/{shell → cli}/commands/general/portForward.ts +7 -6
- package/src/apps/{shell → cli}/commands/mongodb/index.ts +2 -2
- package/src/apps/{shell → cli}/commands/mongodb/projectMongoDestroyMember.ts +20 -22
- package/src/apps/{shell → cli}/commands/mongodb/projectMongoGetShell.ts +13 -11
- package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +65 -0
- package/src/apps/{shell → cli}/commands/mongodb/utils/index.ts +28 -19
- package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +139 -0
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +234 -0
- package/src/apps/{shell → cli}/commands/project/commandDeletePods.ts +13 -15
- package/src/apps/{shell → cli}/commands/project/commandDeleteProject.ts +8 -9
- package/src/apps/cli/commands/project/commandEnvVars.ts +18 -0
- package/src/apps/{shell → cli}/commands/project/commandGetMyTotalWorktime.ts +4 -4
- package/src/apps/cli/commands/project/commandGetShell.ts +36 -0
- package/src/apps/{shell → cli}/commands/project/commandGitlabCi.ts +3 -2
- package/src/apps/{shell/commands/project/commandInitProject.ts → cli/commands/project/commandInitProject.old.ts} +15 -7
- package/src/apps/cli/commands/project/commandListPods.ts +18 -0
- package/src/apps/{shell → cli}/commands/project/commandMigrateHelm3.ts +18 -8
- package/src/apps/cli/commands/project/commandNamespace.ts +14 -0
- package/src/apps/cli/commands/project/commandOpenCostDashboard.ts +32 -0
- package/src/apps/cli/commands/project/commandOpenDashboard.ts +28 -0
- package/src/apps/cli/commands/project/commandOpenEnv.ts +22 -0
- package/src/apps/{shell → cli}/commands/project/commandOpenGit.ts +2 -2
- package/src/apps/{shell → cli}/commands/project/commandOpenGrafana.ts +10 -10
- package/src/apps/{shell → cli}/commands/project/commandOpenGrafanaPod.ts +14 -17
- package/src/apps/cli/commands/project/commandOpenLogs.ts +21 -0
- package/src/apps/{shell → cli}/commands/project/commandPauseProject.ts +10 -8
- package/src/apps/cli/commands/project/commandPortForward.ts +86 -0
- package/src/apps/cli/commands/project/commandSecretsClearBackups.ts +27 -0
- package/src/apps/cli/commands/project/commandSetup.ts +12 -0
- package/src/apps/{shell → cli}/commands/project/commandTriggerCronjob.ts +13 -12
- package/src/apps/{shell → cli}/commands/project/index.ts +10 -10
- package/src/apps/cli/commands/project/setup/index.ts +44 -0
- package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +84 -0
- package/src/apps/cli/commands/project/setup/setupCloudRun.ts +84 -0
- package/src/apps/cli/commands/project/setup/setupContext.ts +44 -0
- package/src/apps/cli/commands/project/setup/setupKubernetes.ts +140 -0
- package/src/apps/cli/commands/project/setup/setupTopic.ts +22 -0
- package/src/apps/cli/commands/project/utils/autocompletions.ts +26 -0
- package/src/apps/cli/commands/project/utils/ensureCluster.ts +42 -0
- package/src/apps/cli/commands/project/utils/ensureNamespace.ts +58 -0
- package/src/apps/cli/commands/project/utils/showProjectBanner.ts +11 -0
- package/src/apps/cli/commands/theStuffThatReallyMatters/index.ts +32 -0
- package/src/apps/cli/config/writeConfig.ts +71 -0
- package/src/apps/cli/verify/index.ts +30 -0
- package/src/apps/cli/verify/migration/fromv2.ts +262 -0
- package/src/apps/cli/verify/migration/migrateSecrets.ts +47 -0
- package/src/apps/cli/verify/migration/oldGitlabCi.ts +48 -0
- package/src/catenv.ts +10 -0
- package/src/cli.ts +3 -0
- package/src/config/constants.ts +0 -3
- package/src/config/getProjectConfig.ts +200 -0
- package/src/config/parseChoice.ts +4 -0
- package/src/gcloud/artifactsRegistry.ts +16 -0
- package/src/gcloud/cloudRun/getCloudRunDomainSuffix.ts +35 -0
- package/src/gcloud/cloudRun/openCloudRunDashboards.ts +22 -0
- package/src/gcloud/cloudSql/startProxy.ts +74 -0
- package/src/gcloud/enableServices.ts +14 -0
- package/src/gcloud/openDashboard.ts +19 -0
- package/src/gcloud/serviceAccounts.ts +101 -0
- package/src/k8sApi/index.ts +22 -6
- package/src/kubernetes/index.ts +27 -0
- package/src/kubernetes/openKubernetesDashboards.ts +52 -0
- package/src/kubernetes/portForward.ts +15 -0
- package/src/types/child-process-promise.d.ts +37 -1
- package/src/types/types.ts +0 -2
- package/src/utils/cluster.ts +5 -14
- package/src/utils/editAsFile.ts +31 -0
- package/src/utils/files.ts +6 -2
- package/src/utils/gitlab.ts +263 -42
- package/src/utils/passwordstore/index.ts +6 -36
- package/src/utils/{portForward.ts → portForwards.ts} +27 -22
- package/src/utils/preferences/index.ts +6 -3
- package/src/utils/projects/index.ts +9 -149
- package/tsconfig.json +3 -7
- package/bin/catenv.sh +0 -1
- package/src/apps/shell/commands/mongodb/projectMongoPortForward.ts +0 -42
- package/src/apps/shell/commands/project/commandCloudSqlProxy.ts +0 -65
- package/src/apps/shell/commands/project/commandConfigSecrets.ts +0 -245
- package/src/apps/shell/commands/project/commandCopyDB.ts +0 -93
- package/src/apps/shell/commands/project/commandEnvVars.ts +0 -17
- package/src/apps/shell/commands/project/commandGetShell.ts +0 -35
- package/src/apps/shell/commands/project/commandInitGitlab.ts +0 -157
- package/src/apps/shell/commands/project/commandListPods.ts +0 -21
- package/src/apps/shell/commands/project/commandNamespace.ts +0 -12
- package/src/apps/shell/commands/project/commandOpenCostDashboard.ts +0 -29
- package/src/apps/shell/commands/project/commandOpenDashboard.ts +0 -27
- package/src/apps/shell/commands/project/commandOpenEnv.ts +0 -18
- package/src/apps/shell/commands/project/commandOpenLogs.ts +0 -23
- package/src/apps/shell/commands/project/commandPortForward.ts +0 -45
- package/src/apps/shell/commands/project/commandVariables.ts +0 -13
- package/src/apps/shell/commands/project/utils/autocompletions.ts +0 -7
- package/src/apps/shell/commands/project/utils/ensureCluster.ts +0 -31
- package/src/apps/shell/commands/project/utils/ensureNamespace.ts +0 -32
- package/src/apps/shell/commands/project/utils/monorepo.ts +0 -45
- package/src/apps/shell/commands/shared/index.ts +0 -31
- package/src/apps/shell/commands/theStuffThatReallyMatters/index.ts +0 -51
- package/src/config/clusters.ts +0 -45
- package/src/index.ts +0 -17
- package/src/types/git-repo-name.d.ts +0 -1
- package/src/types/yawn-yaml.d.ts +0 -1
- package/src/utils/dashboardToken.ts +0 -20
- package/src/utils/formatEnvVars.ts +0 -7
- /package/src/apps/{shell → cli}/commands/general/namespaceAutoCompletion.ts +0 -0
- /package/src/apps/{shell → cli}/utils/getGoogleAuthUserNumber.ts +0 -0
package/src/utils/gitlab.ts
CHANGED
|
@@ -1,80 +1,301 @@
|
|
|
1
|
+
import { getSecretVarName } from "@catladder/pipeline";
|
|
1
2
|
import { exec } from "child-process-promise";
|
|
3
|
+
import { has, isObject } from "lodash";
|
|
4
|
+
import memoizee from "memoizee";
|
|
2
5
|
import fetch from "node-fetch";
|
|
3
6
|
import open from "open";
|
|
4
|
-
import { CommandInstance } from "vorpal";
|
|
7
|
+
import type { CommandInstance } from "vorpal";
|
|
5
8
|
import { getPreference, hasPreference, setPreference } from "./preferences";
|
|
6
9
|
|
|
7
10
|
const TOKEN_KEY = "gitlab-personal-access-token";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
11
|
+
|
|
12
|
+
export const hasGitlabToken = async () => await hasPreference(TOKEN_KEY);
|
|
13
|
+
export const setupGitlabToken = async (vorpal: CommandInstance) => {
|
|
14
|
+
vorpal.log("");
|
|
15
|
+
vorpal.log("☝ in order to access the api, we need a personal access token");
|
|
16
|
+
vorpal.log("Its best to create one specifically for catladder");
|
|
17
|
+
vorpal.log("");
|
|
18
|
+
vorpal.log("☝ we open up the settings page for you!");
|
|
19
|
+
vorpal.log("");
|
|
20
|
+
const { shouldContinue } = await vorpal.prompt({
|
|
21
|
+
default: true,
|
|
22
|
+
message: "Ok",
|
|
23
|
+
name: "shouldContinue",
|
|
24
|
+
type: "prompt",
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
open("https://git.panter.ch/-/profile/personal_access_tokens");
|
|
28
|
+
|
|
29
|
+
vorpal.log("Please type in gitlab's personal access token");
|
|
30
|
+
|
|
31
|
+
const { personalToken } = await vorpal.prompt({
|
|
32
|
+
type: "string",
|
|
33
|
+
name: "personalToken",
|
|
34
|
+
default: "",
|
|
35
|
+
message: "Your personal access token ",
|
|
36
|
+
});
|
|
37
|
+
if (personalToken) {
|
|
38
|
+
await setPreference(TOKEN_KEY, personalToken);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export const getGitlabToken = async (vorpal: CommandInstance | null) => {
|
|
42
|
+
if (!(await hasGitlabToken())) {
|
|
43
|
+
if (!vorpal) {
|
|
44
|
+
console.error(
|
|
45
|
+
"⚠️ gitlab token missing, please run catladder to set it up"
|
|
46
|
+
);
|
|
47
|
+
process.exit(1);
|
|
37
48
|
}
|
|
49
|
+
await setupGitlabToken(vorpal);
|
|
38
50
|
}
|
|
39
51
|
return getPreference(TOKEN_KEY);
|
|
40
52
|
};
|
|
41
53
|
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
type Method = "GET" | "PUT" | "POST" | "DELETE";
|
|
55
|
+
export const doGitlabRequest = async <T = any>(
|
|
56
|
+
vorpal: CommandInstance | null,
|
|
44
57
|
path: string,
|
|
45
|
-
data
|
|
46
|
-
|
|
58
|
+
data: any = undefined,
|
|
59
|
+
method: Method = "GET"
|
|
60
|
+
): Promise<T> => {
|
|
47
61
|
const rootToken = await getGitlabToken(vorpal);
|
|
62
|
+
|
|
63
|
+
//const method = data ? (update ? "PUT" : "POST") : "GET";
|
|
64
|
+
|
|
48
65
|
const result = await fetch(`https://git.panter.ch/api/v4/${path}`, {
|
|
49
|
-
method
|
|
66
|
+
method,
|
|
50
67
|
headers: {
|
|
51
68
|
"Content-Type": "application/json",
|
|
52
69
|
"Private-Token": rootToken,
|
|
53
70
|
},
|
|
54
|
-
body: JSON.stringify(data),
|
|
71
|
+
body: data ? JSON.stringify(data) : undefined,
|
|
55
72
|
});
|
|
56
73
|
|
|
57
74
|
if (result.status >= 200 && result.status < 400) {
|
|
58
|
-
|
|
75
|
+
if (result.headers.get("content-type") === "application/json") {
|
|
76
|
+
return result.json();
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
if (result.status === 404) {
|
|
81
|
+
throw new Error("not found");
|
|
59
82
|
}
|
|
60
83
|
|
|
61
84
|
throw new Error(
|
|
62
|
-
`Could not send request to gitlab api: ${result.status} "${
|
|
85
|
+
`Could not send request to gitlab api ${path}: ${result.status} "${
|
|
63
86
|
result.statusText
|
|
64
87
|
}".\nResponse: ${JSON.stringify(await result.json(), null, 2)}`
|
|
65
88
|
);
|
|
66
89
|
};
|
|
67
90
|
|
|
68
|
-
export const getProjectInfo = async (
|
|
91
|
+
export const getProjectInfo = async (
|
|
92
|
+
vorpal: CommandInstance | null
|
|
93
|
+
): Promise<{ id: string; web_url: string }> => {
|
|
69
94
|
const gitRemoteOriginUrl = (
|
|
70
95
|
await exec("git config --get remote.origin.url")
|
|
71
96
|
).stdout.trim();
|
|
72
|
-
const projectPath =
|
|
73
|
-
|
|
74
|
-
|
|
97
|
+
const projectPath =
|
|
98
|
+
/(https:\/\/|git@)git\.panter\.ch[:/]([^.]*)(\.git)?/g.exec(
|
|
99
|
+
gitRemoteOriginUrl
|
|
100
|
+
);
|
|
75
101
|
const project = await doGitlabRequest(
|
|
76
102
|
vorpal,
|
|
77
103
|
`projects/${encodeURIComponent(projectPath[2])}`
|
|
78
104
|
);
|
|
79
105
|
return project;
|
|
80
106
|
};
|
|
107
|
+
|
|
108
|
+
type GitlabVariable = {
|
|
109
|
+
variable_type: string;
|
|
110
|
+
key: string;
|
|
111
|
+
value: string;
|
|
112
|
+
protected: boolean;
|
|
113
|
+
masked: boolean;
|
|
114
|
+
environment_scope: string;
|
|
115
|
+
};
|
|
116
|
+
export const getAllVariables = memoizee(
|
|
117
|
+
async (vorpal: CommandInstance | null): Promise<Array<GitlabVariable>> => {
|
|
118
|
+
const { id } = await getProjectInfo(vorpal);
|
|
119
|
+
let all: Array<GitlabVariable> = [];
|
|
120
|
+
let result: Array<GitlabVariable>;
|
|
121
|
+
let page = 1;
|
|
122
|
+
do {
|
|
123
|
+
result = await doGitlabRequest(
|
|
124
|
+
vorpal,
|
|
125
|
+
// 100 is max page size
|
|
126
|
+
`projects/${id}/variables?per_page=100&page=${page}`
|
|
127
|
+
);
|
|
128
|
+
page++;
|
|
129
|
+
all = [...all, ...result];
|
|
130
|
+
} while (result?.length > 0);
|
|
131
|
+
return all;
|
|
132
|
+
},
|
|
133
|
+
{ promise: true }
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
export const getVariableValueByRawName = async (
|
|
137
|
+
vorpal: CommandInstance,
|
|
138
|
+
rawName: string
|
|
139
|
+
) => {
|
|
140
|
+
const allVariables = await getAllVariables(vorpal);
|
|
141
|
+
return allVariables.find((v) => v.key === rawName)?.value;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const maskableRegex = new RegExp("^[a-zA-Z0-9_+=/@:.~-]{8,}$"); // SEE https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js#L20
|
|
145
|
+
const isMaskable = (value: string): boolean => maskableRegex.test(value);
|
|
146
|
+
|
|
147
|
+
const createVariable = async (
|
|
148
|
+
vorpal: CommandInstance,
|
|
149
|
+
projectId: string,
|
|
150
|
+
key: string,
|
|
151
|
+
value: string,
|
|
152
|
+
masked = true,
|
|
153
|
+
environment_scope = "*"
|
|
154
|
+
) => {
|
|
155
|
+
return await doGitlabRequest(
|
|
156
|
+
vorpal,
|
|
157
|
+
`projects/${projectId}/variables`,
|
|
158
|
+
{
|
|
159
|
+
key,
|
|
160
|
+
value,
|
|
161
|
+
masked: masked && isMaskable(value),
|
|
162
|
+
environment_scope,
|
|
163
|
+
},
|
|
164
|
+
"POST"
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const updateVariable = async (
|
|
169
|
+
vorpal: CommandInstance,
|
|
170
|
+
projectId: string,
|
|
171
|
+
key: string,
|
|
172
|
+
value: string,
|
|
173
|
+
masked = true
|
|
174
|
+
) => {
|
|
175
|
+
return await doGitlabRequest(
|
|
176
|
+
vorpal,
|
|
177
|
+
`projects/${projectId}/variables/${key}`,
|
|
178
|
+
{
|
|
179
|
+
value,
|
|
180
|
+
masked: masked && isMaskable(value),
|
|
181
|
+
},
|
|
182
|
+
"PUT"
|
|
183
|
+
);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const deleteVariable = async (
|
|
187
|
+
vorpal: CommandInstance,
|
|
188
|
+
projectId: string,
|
|
189
|
+
key: string
|
|
190
|
+
) => {
|
|
191
|
+
return await doGitlabRequest(
|
|
192
|
+
vorpal,
|
|
193
|
+
`projects/${projectId}/variables/${key}`,
|
|
194
|
+
undefined,
|
|
195
|
+
"DELETE"
|
|
196
|
+
);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const getAllCatladderEnvVarsInGitlab = async (vorpal: CommandInstance) => {
|
|
200
|
+
const allVariables = await getAllVariables(vorpal).then((v) =>
|
|
201
|
+
v.reduce<{
|
|
202
|
+
[key: string]: {
|
|
203
|
+
value?: string;
|
|
204
|
+
backups: number[];
|
|
205
|
+
};
|
|
206
|
+
}>((acc, variable) => {
|
|
207
|
+
const { key } = variable;
|
|
208
|
+
|
|
209
|
+
if (key.startsWith("CL_")) {
|
|
210
|
+
const matchBackup = key.match(/(CL_.*)_backup_([0-9]+)/);
|
|
211
|
+
|
|
212
|
+
if (matchBackup) {
|
|
213
|
+
const key = matchBackup[1];
|
|
214
|
+
const timestamp = Number(matchBackup[2]);
|
|
215
|
+
const backups = [...(acc[key]?.backups ?? []), timestamp];
|
|
216
|
+
return {
|
|
217
|
+
...acc,
|
|
218
|
+
[key]: {
|
|
219
|
+
...(acc[key] ?? {}), // add value
|
|
220
|
+
backups,
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
...acc,
|
|
227
|
+
[key]: {
|
|
228
|
+
backups: [],
|
|
229
|
+
...(acc[key] ?? {}), // may add backups
|
|
230
|
+
value: variable.value,
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return acc;
|
|
236
|
+
}, {})
|
|
237
|
+
);
|
|
238
|
+
return allVariables;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const getBackupKey = (fullKey: string, timestamp: number) =>
|
|
242
|
+
`${fullKey}_backup_${timestamp}`;
|
|
243
|
+
export const clearBackups = async (vorpal: CommandInstance, keep: number) => {
|
|
244
|
+
const existingVariables = await getAllCatladderEnvVarsInGitlab(vorpal);
|
|
245
|
+
const { id } = await getProjectInfo(vorpal);
|
|
246
|
+
for (const [key, { backups }] of Object.entries(existingVariables)) {
|
|
247
|
+
const backupsSorted = backups.sort((a, b) => b - a);
|
|
248
|
+
//const toKeep = backupsSorted.slice(0, keep);
|
|
249
|
+
const toDelete = backupsSorted.slice(keep);
|
|
250
|
+
|
|
251
|
+
for (const timestamp of toDelete) {
|
|
252
|
+
await deleteVariable(vorpal, id, getBackupKey(key, timestamp));
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
export const upsertAllVariables = async (
|
|
258
|
+
vorpal: CommandInstance,
|
|
259
|
+
variables: Record<string, any>,
|
|
260
|
+
env: string,
|
|
261
|
+
componentName: string,
|
|
262
|
+
backup = true,
|
|
263
|
+
masked = true // FIXME: would be better to have this per variable
|
|
264
|
+
): Promise<void> => {
|
|
265
|
+
const { id } = await getProjectInfo(vorpal);
|
|
266
|
+
|
|
267
|
+
// we list all existing variables. We also gather backup versions, but its currently unused
|
|
268
|
+
const existingVariables = await getAllCatladderEnvVarsInGitlab(vorpal);
|
|
269
|
+
for (const [key, value] of Object.entries(variables ?? {})) {
|
|
270
|
+
const fullKey = getSecretVarName(env, componentName, key);
|
|
271
|
+
const valueSanitized = isObject(value) ? JSON.stringify(value) : `${value}`;
|
|
272
|
+
|
|
273
|
+
const exists = has(existingVariables, fullKey);
|
|
274
|
+
const oldValue = existingVariables[fullKey]?.value;
|
|
275
|
+
const changed = oldValue !== valueSanitized;
|
|
276
|
+
if (changed) {
|
|
277
|
+
if (exists) {
|
|
278
|
+
vorpal.log(`changed: ${key}`);
|
|
279
|
+
|
|
280
|
+
await updateVariable(vorpal, id, fullKey, valueSanitized, masked);
|
|
281
|
+
// write backup
|
|
282
|
+
if (backup) {
|
|
283
|
+
await createVariable(
|
|
284
|
+
vorpal,
|
|
285
|
+
id,
|
|
286
|
+
getBackupKey(fullKey, new Date().getTime()),
|
|
287
|
+
oldValue,
|
|
288
|
+
masked,
|
|
289
|
+
"_backup"
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
} else {
|
|
293
|
+
vorpal.log(`new : ${key}`);
|
|
294
|
+
await createVariable(vorpal, id, fullKey, valueSanitized, masked);
|
|
295
|
+
}
|
|
296
|
+
} else {
|
|
297
|
+
vorpal.log(`skip : ${key}`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
getAllVariables.clear();
|
|
301
|
+
};
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { exec, spawn } from "child-process-promise";
|
|
2
2
|
import commandExists from "command-exists-promise";
|
|
3
3
|
import dayjs from "dayjs";
|
|
4
|
-
|
|
5
|
-
import { readFile, writeFile } from "fs-extra";
|
|
6
|
-
import yaml from "js-yaml";
|
|
7
|
-
import { withFile } from "tmp-promise";
|
|
8
|
-
import formatEnvVars from "../formatEnvVars";
|
|
9
|
-
import getEditor from "../getEditor";
|
|
10
4
|
import { getPreference, hasPreference, setPreference } from "../preferences";
|
|
11
5
|
|
|
12
6
|
const DEBUG = false;
|
|
@@ -21,7 +15,7 @@ const unlockBitwarden = async () => {
|
|
|
21
15
|
let session = null;
|
|
22
16
|
promise.childProcess.stdout.on(
|
|
23
17
|
"data",
|
|
24
|
-
(d
|
|
18
|
+
(d) => (session = d.toString("utf-8"))
|
|
25
19
|
);
|
|
26
20
|
await promise;
|
|
27
21
|
await setPreference("bwsession", session);
|
|
@@ -36,7 +30,7 @@ const loginBitwarden = async () => {
|
|
|
36
30
|
let session = null;
|
|
37
31
|
promise.childProcess.stdout.on(
|
|
38
32
|
"data",
|
|
39
|
-
(d
|
|
33
|
+
(d) => (session = d.toString("utf-8"))
|
|
40
34
|
);
|
|
41
35
|
await promise;
|
|
42
36
|
await setPreference("bwsession", session);
|
|
@@ -78,9 +72,7 @@ const execBitwardenCommand = async (command: string): Promise<any> => {
|
|
|
78
72
|
await loginBitwarden();
|
|
79
73
|
return execBitwardenCommand(command);
|
|
80
74
|
} else {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
console.log("wooops", e.message);
|
|
75
|
+
throw e;
|
|
84
76
|
}
|
|
85
77
|
}
|
|
86
78
|
};
|
|
@@ -125,14 +117,6 @@ export const readPass = async (path: string) => {
|
|
|
125
117
|
return result.notes || result.login?.password;
|
|
126
118
|
};
|
|
127
119
|
|
|
128
|
-
const update = async (type: string, itemId: string, value: any) => {
|
|
129
|
-
const result = await execBitwardenCommand(
|
|
130
|
-
`edit ${type} ${itemId} ${encode(value)}`
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
return result;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
120
|
const MAX_SYNC_AGE_IN_MINUTES = 30;
|
|
137
121
|
export const syncBitwarden = async (force = true) => {
|
|
138
122
|
const lastSync = (await hasPreference("bwLastSync"))
|
|
@@ -169,24 +153,10 @@ const share = async (itemId: string) =>
|
|
|
169
153
|
])}`
|
|
170
154
|
);
|
|
171
155
|
|
|
172
|
-
export const
|
|
156
|
+
export const trashItem = async (path: string) => {
|
|
173
157
|
const item = await getItem(path);
|
|
174
158
|
|
|
175
|
-
await
|
|
176
|
-
await writeFile(tmpFilePath, item.notes);
|
|
177
|
-
await (await getEditor()).open(tmpFilePath);
|
|
178
|
-
const newContent = (await readFile(tmpFilePath)).toString("utf-8");
|
|
159
|
+
const result = await execBitwardenCommand(`delete item ${item.id}`);
|
|
179
160
|
|
|
180
|
-
|
|
181
|
-
...item,
|
|
182
|
-
notes: newContent,
|
|
183
|
-
});
|
|
184
|
-
}, { postfix: ".yml" });
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
export const readPassEnvVars = async (path: string) => {
|
|
188
|
-
// make sure that you have pulled pass beforehand
|
|
189
|
-
const yamlstring = await readPass(path);
|
|
190
|
-
// if a value is an object, we convert it to strings
|
|
191
|
-
return formatEnvVars(yaml.load(yamlstring));
|
|
161
|
+
return result;
|
|
192
162
|
};
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { spawn } from "child-process-promise";
|
|
2
|
+
import type { ReadStream } from "fs-extra";
|
|
3
|
+
import open from "open";
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
export type PortForward = Promise<unknown> & {
|
|
6
|
+
childProcess: {
|
|
7
|
+
stdout: ReadStream;
|
|
8
|
+
kill: () => any;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
const portForwards = new Map<string, PortForward>();
|
|
4
12
|
|
|
5
13
|
export const stopPortForward = async (name: string) => {
|
|
6
14
|
const old = portForwards.get(name);
|
|
@@ -19,32 +27,29 @@ export const stopPortForward = async (name: string) => {
|
|
|
19
27
|
export const getAllRunningPortForwards = () => {
|
|
20
28
|
return Array.from(portForwards.keys());
|
|
21
29
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
|
|
31
|
+
const addPortForward = (name: string, portForward: PortForward) => {
|
|
32
|
+
portForwards.set(name, portForward);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const startPortForwardCommand = async (
|
|
36
|
+
name: string,
|
|
37
|
+
command: string
|
|
27
38
|
) => {
|
|
28
|
-
const name = `${namespace}/${podname}/${localPort}:${remotePort}`;
|
|
29
39
|
// stop if already there
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const promise = spawn(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
portForwards.set(name, promise);
|
|
40
|
+
await stopPortForward(name);
|
|
41
|
+
const [cmd, ...args] = command.split(" ");
|
|
42
|
+
|
|
43
|
+
const promise = spawn(cmd, args, {
|
|
44
|
+
env: {
|
|
45
|
+
...process.env,
|
|
46
|
+
DEBUG: "",
|
|
47
|
+
},
|
|
48
|
+
}) as PortForward;
|
|
49
|
+
addPortForward(name, promise);
|
|
44
50
|
// wait a moment so that is surley started, unfortunatly we don't know that
|
|
45
51
|
await new Promise((r) => setTimeout(r, 1000));
|
|
46
52
|
};
|
|
47
|
-
|
|
48
53
|
export const stopAllPortForwards = async () => {
|
|
49
54
|
getAllRunningPortForwards().forEach((name) => {
|
|
50
55
|
stopPortForward(name);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "fs-extra";
|
|
2
2
|
import { homedir } from "os";
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { load, dump } from "js-yaml";
|
|
5
5
|
const directory = `${homedir()}/.catladder`;
|
|
6
6
|
const file = `${directory}/preferences.yml`;
|
|
7
7
|
|
|
@@ -9,7 +9,10 @@ const getPreferences = async () => {
|
|
|
9
9
|
if (!(await fs.pathExists(file))) {
|
|
10
10
|
await fs.createFile(file);
|
|
11
11
|
}
|
|
12
|
-
return
|
|
12
|
+
return (load(await fs.readFile(file, { encoding: "utf-8" })) ?? {}) as Record<
|
|
13
|
+
string,
|
|
14
|
+
string
|
|
15
|
+
>;
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
export const hasPreference = async (key: string) => {
|
|
@@ -29,5 +32,5 @@ export const setPreference = async (key: string, value: string | number) => {
|
|
|
29
32
|
[key]: value,
|
|
30
33
|
};
|
|
31
34
|
|
|
32
|
-
await fs.writeFile(file,
|
|
35
|
+
await fs.writeFile(file, dump(newPreferences));
|
|
33
36
|
};
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import { exec } from "child-process-promise";
|
|
2
1
|
import { join } from "path";
|
|
3
|
-
import
|
|
4
|
-
import { Env, ISecrets, IValueFile } from "../../types/types";
|
|
5
|
-
import { readFileOrError, readYaml } from "../files";
|
|
6
|
-
import formatEnvVars from "../formatEnvVars";
|
|
7
|
-
import { hasBitwarden, readPassEnvVars, syncBitwarden } from "../passwordstore";
|
|
8
|
-
import { filter } from "../promise";
|
|
9
|
-
|
|
10
|
-
import { merge } from "lodash";
|
|
2
|
+
import { getProjectConfig, parseChoice } from "../../config/getProjectConfig";
|
|
11
3
|
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
import { readFileOrError } from "../files";
|
|
5
|
+
import { exec } from "child-process-promise";
|
|
14
6
|
|
|
15
|
-
export const getGitRoot = async () => {
|
|
16
|
-
return (await exec(
|
|
7
|
+
export const getGitRoot = async (): Promise<string> => {
|
|
8
|
+
return (await exec(`git rev-parse --show-toplevel`)).stdout.trim();
|
|
17
9
|
};
|
|
18
10
|
|
|
19
11
|
export const getRootGitlabCiFile = async () => {
|
|
@@ -31,141 +23,9 @@ export const hasGitlabCiFile = async () => {
|
|
|
31
23
|
}
|
|
32
24
|
return true;
|
|
33
25
|
};
|
|
34
|
-
export const getLocalProjectVariables = async () => {
|
|
35
|
-
const [error, file] = await readRootGitlabCiFile();
|
|
36
|
-
if (error) {
|
|
37
|
-
throw new Error("there is no '.gitlab-ci.yml' in the current project");
|
|
38
|
-
}
|
|
39
|
-
// yawn allows to modify yaml while keeping comments!
|
|
40
|
-
const yawn = new YAWN(file);
|
|
41
|
-
const { variables } = yawn.json;
|
|
42
|
-
if (!variables) {
|
|
43
|
-
throw new Error("your '.gitlab-ci.yml' does not define `variables`");
|
|
44
|
-
}
|
|
45
|
-
const defaults = {
|
|
46
|
-
CLUSTER_NAME: "production",
|
|
47
|
-
};
|
|
48
|
-
return {
|
|
49
|
-
...defaults,
|
|
50
|
-
...variables,
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export const getProjectNamespace = async (env: Env) => {
|
|
55
|
-
const { CUSTOMER_NAME, APP_NAME } = await getLocalProjectVariables();
|
|
56
|
-
return `${CUSTOMER_NAME}-${APP_NAME}-${env}`;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const getProjectHelmReleaseName = async (env: Env) => {
|
|
60
|
-
// can't properly get the release name for review as it contains an additional branch slug
|
|
61
|
-
if (env === "review" || env === "dev-local") {
|
|
62
|
-
throw new Error(`can't get helm release name for ${env}`);
|
|
63
|
-
}
|
|
64
|
-
const {
|
|
65
|
-
CUSTOMER_NAME,
|
|
66
|
-
APP_NAME,
|
|
67
|
-
COMPONENT_NAME = "web",
|
|
68
|
-
} = await getLocalProjectVariables();
|
|
69
|
-
return `${CUSTOMER_NAME}-${APP_NAME}-${env}-${COMPONENT_NAME}`;
|
|
70
|
-
};
|
|
71
|
-
export const getProjectPods = async (env: Env) => {
|
|
72
|
-
const namespace = await getProjectNamespace(env);
|
|
73
|
-
const res = await k8sApi.listNamespacedPod(namespace);
|
|
74
|
-
|
|
75
|
-
return res.body.items;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export const getProjectPvcs = async (env: Env) => {
|
|
79
|
-
const namespace = await getProjectNamespace(env);
|
|
80
|
-
const res = await k8sApi.listNamespacedPersistentVolumeClaim(namespace);
|
|
81
|
-
|
|
82
|
-
return res.body.items;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export const getProjectPodNames = async (env: Env) => {
|
|
86
|
-
const pods = await getProjectPods(env);
|
|
87
|
-
return pods.map((n) => n.metadata.name);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export const getPassPath = async (env: Env) => {
|
|
91
|
-
const { CUSTOMER_NAME, APP_NAME } = await getLocalProjectVariables();
|
|
92
|
-
return `${CUSTOMER_NAME}/${APP_NAME}/${env}/secrets.yml`;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export const getProjectValuesFiles = async (env: Env, subApp?: string) => {
|
|
96
|
-
const gitRoot = await getGitRoot();
|
|
97
|
-
const possibleFiles = ["values.yml", `values-${env}.yml`].map((file) =>
|
|
98
|
-
subApp ? join(gitRoot, subApp, file) : join(gitRoot, file)
|
|
99
|
-
);
|
|
100
|
-
return filter(possibleFiles, async (file) => {
|
|
101
|
-
const [error] = await readFileOrError(file);
|
|
102
|
-
return !error;
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export const getAllValues = async (env: Env, subApp?: string) => {
|
|
107
|
-
const valuesFilePaths = await getProjectValuesFiles(env, subApp);
|
|
108
|
-
return Promise.all(
|
|
109
|
-
valuesFilePaths.map(async (file) => (await readYaml(file)) as IValueFile)
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export const getProjectValues = async (env: Env, subApp?: string) => {
|
|
114
|
-
const values = await getAllValues(env, subApp);
|
|
115
|
-
return merge({}, ...values) as IValueFile;
|
|
116
|
-
};
|
|
117
26
|
|
|
118
|
-
export const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return {
|
|
123
|
-
...acc,
|
|
124
|
-
...value.env.public,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
return acc;
|
|
128
|
-
}, {})
|
|
129
|
-
);
|
|
130
|
-
};
|
|
131
|
-
export const getAllSecretsEnvVarsMapping = async (
|
|
132
|
-
env: Env,
|
|
133
|
-
subApp?: string
|
|
134
|
-
) => {
|
|
135
|
-
return (await getAllValues(env, subApp)).reduce<ISecrets>((acc, value) => {
|
|
136
|
-
if (value.env && value.env.secret) {
|
|
137
|
-
return {
|
|
138
|
-
...acc,
|
|
139
|
-
...value.env.secret,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
return acc;
|
|
143
|
-
}, {});
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
export const hasSecrets = async (env: Env, subApp?: string) => {
|
|
147
|
-
return Object.keys(await getAllSecretsEnvVarsMapping(env, subApp)).length > 0;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
export const getAllEnvVars = async (
|
|
151
|
-
env: Env,
|
|
152
|
-
subApp?: string
|
|
153
|
-
): Promise<Record<string, string>> => {
|
|
154
|
-
return {
|
|
155
|
-
...(await getAllPublicEnvVars(env, subApp)),
|
|
156
|
-
...(await getAllSecretEnvVars(env, subApp)),
|
|
157
|
-
};
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
export const getAllSecretEnvVars = async (env: Env, subApp?: string) => {
|
|
161
|
-
if (!(await hasSecrets(env, subApp))) {
|
|
162
|
-
return {};
|
|
163
|
-
}
|
|
164
|
-
if (await hasBitwarden()) {
|
|
165
|
-
await syncBitwarden(false /* do not force sync */);
|
|
166
|
-
const passPath = await getPassPath(env);
|
|
167
|
-
return readPassEnvVars(passPath);
|
|
168
|
-
} else {
|
|
169
|
-
return {};
|
|
170
|
-
}
|
|
27
|
+
export const getProjectNamespace = async (envComponent: string) => {
|
|
28
|
+
const { env } = parseChoice(envComponent);
|
|
29
|
+
const config = await getProjectConfig();
|
|
30
|
+
return `${config.customerName}-${config.appName}-${env}`;
|
|
171
31
|
};
|