@catladder/cli 0.0.0-test3 → 0.0.0-yarnrc-support-bdbef31f
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 +4 -2
- package/bin/catenv +3 -0
- package/bin/catladder +1 -1
- package/dist/apps/catenv/catenv.d.ts +2 -0
- package/dist/apps/catenv/catenv.js +135 -0
- package/dist/apps/catenv/catenv.js.map +1 -0
- package/dist/apps/cli/cli.d.ts +2 -0
- package/dist/apps/cli/cli.js +81 -0
- package/dist/apps/cli/cli.js.map +1 -0
- package/dist/apps/cli/commands/general/index.d.ts +4 -0
- package/dist/apps/cli/commands/general/index.js +208 -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 +98 -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 +190 -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 +105 -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 +167 -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 +129 -0
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.js +294 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -0
- package/dist/apps/cli/commands/project/commandCopyDB.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandCopyDB.js +102 -0
- package/dist/apps/cli/commands/project/commandCopyDB.js.map +1 -0
- package/dist/apps/cli/commands/project/commandDeletePods.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandDeletePods.js +119 -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 +92 -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/commandInitGitlab.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandInitGitlab.js +136 -0
- package/dist/apps/cli/commands/project/commandInitGitlab.js.map +1 -0
- package/dist/apps/cli/commands/project/commandInitProject.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandInitProject.js +345 -0
- package/dist/apps/cli/commands/project/commandInitProject.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 +113 -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 +85 -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 +61 -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 +99 -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 +87 -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 +106 -0
- package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -0
- package/dist/apps/cli/commands/project/commandReloadConfig.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandReloadConfig.js +62 -0
- package/dist/apps/cli/commands/project/commandReloadConfig.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 +97 -0
- package/dist/apps/cli/commands/project/index.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 +106 -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/shared/index.d.ts +3 -0
- package/dist/apps/cli/commands/shared/index.js +70 -0
- package/dist/apps/cli/commands/shared/index.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 +345 -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 +88 -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/catenv.d.ts +1 -0
- package/dist/catenv.js +10 -0
- package/dist/catenv.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +15 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/constants.d.ts +3 -0
- package/dist/config/constants.js +7 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/config/getProjectConfig.d.ts +24 -0
- package/dist/config/getProjectConfig.js +232 -0
- package/dist/config/getProjectConfig.js.map +1 -0
- package/dist/k8sApi/index.d.ts +6 -0
- package/dist/k8sApi/index.js +15 -0
- package/dist/k8sApi/index.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 +75 -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/formatEnvVars.d.ts +2 -0
- package/dist/utils/formatEnvVars.js +10 -0
- package/dist/utils/formatEnvVars.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 +21 -0
- package/dist/utils/gitlab.js +262 -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 +8 -0
- package/dist/utils/passwordstore/index.js +378 -0
- package/dist/utils/passwordstore/index.js.map +1 -0
- package/dist/utils/portForward.d.ts +4 -0
- package/dist/utils/portForward.js +116 -0
- package/dist/utils/portForward.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 +8 -0
- package/dist/utils/projects/index.js +154 -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 +16 -21
- package/src/apps/catenv/catenv.ts +48 -27
- package/src/apps/{shell/shell.ts → cli/cli.ts} +10 -2
- package/src/apps/{shell → cli}/commands/general/index.ts +2 -40
- package/src/apps/{shell → cli}/commands/general/namespaceAutoCompletion.ts +0 -0
- package/src/apps/{shell → cli}/commands/general/portForward.ts +1 -1
- package/src/apps/{shell → cli}/commands/mongodb/index.ts +1 -1
- package/src/apps/{shell → cli}/commands/mongodb/projectMongoDestroyMember.ts +18 -18
- package/src/apps/{shell → cli}/commands/mongodb/projectMongoGetShell.ts +12 -10
- package/src/apps/{shell → cli}/commands/mongodb/projectMongoPortForward.ts +13 -8
- package/src/apps/{shell → cli}/commands/mongodb/utils/index.ts +9 -8
- package/src/apps/{shell → cli}/commands/project/commandCloudSqlProxy.ts +26 -21
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +205 -0
- package/src/apps/{shell → cli}/commands/project/commandCopyDB.ts +24 -26
- package/src/apps/{shell → cli}/commands/project/commandDeletePods.ts +8 -9
- package/src/apps/{shell → cli}/commands/project/commandDeleteProject.ts +7 -8
- package/src/apps/cli/commands/project/commandEnvVars.ts +15 -0
- package/src/apps/{shell → cli}/commands/project/commandGetMyTotalWorktime.ts +2 -2
- package/src/apps/{shell → cli}/commands/project/commandGetShell.ts +10 -10
- package/src/apps/{shell → cli}/commands/project/commandGitlabCi.ts +1 -1
- package/src/apps/cli/commands/project/commandInitGitlab.ts +248 -0
- package/src/apps/{shell → cli}/commands/project/commandInitProject.ts +14 -6
- package/src/apps/cli/commands/project/commandListPods.ts +18 -0
- package/src/apps/{shell → cli}/commands/project/commandMigrateHelm3.ts +16 -7
- package/src/apps/cli/commands/project/commandNamespace.ts +14 -0
- package/src/apps/{shell → cli}/commands/project/commandOpenCostDashboard.ts +10 -7
- package/src/apps/cli/commands/project/commandOpenDashboard.ts +48 -0
- package/src/apps/cli/commands/project/commandOpenEnv.ts +22 -0
- package/src/apps/{shell → cli}/commands/project/commandOpenGit.ts +3 -3
- package/src/apps/{shell → cli}/commands/project/commandOpenGrafana.ts +7 -7
- package/src/apps/{shell → cli}/commands/project/commandOpenGrafanaPod.ts +9 -10
- package/src/apps/cli/commands/project/commandOpenLogs.ts +52 -0
- package/src/apps/{shell → cli}/commands/project/commandPauseProject.ts +9 -7
- package/src/apps/{shell → cli}/commands/project/commandPortForward.ts +8 -8
- package/src/apps/cli/commands/project/commandReloadConfig.ts +12 -0
- package/src/apps/{shell → cli}/commands/project/commandTriggerCronjob.ts +7 -7
- package/src/apps/{shell → cli}/commands/project/index.ts +4 -3
- 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 +55 -0
- package/src/apps/cli/commands/project/utils/showProjectBanner.ts +11 -0
- package/src/apps/cli/commands/shared/index.ts +36 -0
- package/src/apps/{shell → cli}/commands/theStuffThatReallyMatters/index.ts +7 -26
- package/src/apps/cli/config/writeConfig.ts +71 -0
- package/src/apps/{shell → cli}/utils/getGoogleAuthUserNumber.ts +0 -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 +37 -0
- package/src/apps/cli/verify/migration/oldGitlabCi.ts +48 -0
- package/src/catenv.ts +4 -0
- package/src/cli.ts +9 -0
- package/src/config/constants.ts +0 -1
- package/src/config/getProjectConfig.ts +136 -0
- package/src/k8sApi/index.ts +5 -1
- package/src/types/types.ts +0 -2
- package/src/utils/cluster.ts +8 -15
- package/src/utils/editAsFile.ts +31 -0
- package/src/utils/files.ts +6 -2
- package/src/utils/gitlab.ts +133 -34
- package/src/utils/passwordstore/index.ts +19 -21
- package/src/utils/preferences/index.ts +6 -3
- package/src/utils/projects/index.ts +15 -136
- package/tsconfig.json +3 -7
- package/bin/catenv.sh +0 -1
- package/src/apps/shell/commands/project/commandConfigSecrets.ts +0 -245
- package/src/apps/shell/commands/project/commandEnvVars.ts +0 -17
- 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/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/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/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
|
@@ -8,18 +8,18 @@ import {
|
|
|
8
8
|
|
|
9
9
|
import { getProjectNamespace } from "../../../../utils/projects";
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
12
12
|
import ensureCluster from "./utils/ensureCluster";
|
|
13
|
-
export default (vorpal: Vorpal) =>
|
|
13
|
+
export default async (vorpal: Vorpal) =>
|
|
14
14
|
vorpal
|
|
15
15
|
.command(
|
|
16
|
-
"project-open-grafana <
|
|
16
|
+
"project-open-grafana <envComponent>",
|
|
17
17
|
"open Grafana dashboard for your namespace"
|
|
18
18
|
)
|
|
19
|
-
.autocomplete(
|
|
20
|
-
.action(async function ({
|
|
21
|
-
await ensureCluster.call(this);
|
|
22
|
-
const namespace = await getProjectNamespace(
|
|
19
|
+
.autocomplete(await envAndComponents())
|
|
20
|
+
.action(async function ({ envComponent }) {
|
|
21
|
+
await ensureCluster.call(this, envComponent);
|
|
22
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
23
23
|
const url = `http://localhost:${GRAFANA_PROXY_LOCAL_PORT}/grafana/d/at-cost-analysis-namespace2/namespace-utilization-metrics?var-namespace=${namespace}`;
|
|
24
24
|
await startPortForward(
|
|
25
25
|
"deployment/kubecost-cost-analyzer",
|
|
@@ -6,24 +6,23 @@ import {
|
|
|
6
6
|
} from "../../../../config/constants";
|
|
7
7
|
import { logError } from "../../../../utils/log";
|
|
8
8
|
import { startPortForward } from "../../../../utils/portForward";
|
|
9
|
-
|
|
10
9
|
import {
|
|
11
10
|
getProjectNamespace,
|
|
12
11
|
getProjectPodNames,
|
|
13
12
|
} from "../../../../utils/projects";
|
|
14
|
-
|
|
15
|
-
import { envAutocompletion } from "./utils/autocompletions";
|
|
13
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
16
14
|
import ensureCluster from "./utils/ensureCluster";
|
|
17
|
-
|
|
15
|
+
|
|
16
|
+
export default async (vorpal: Vorpal) =>
|
|
18
17
|
vorpal
|
|
19
18
|
.command(
|
|
20
|
-
"project-open-grafana-pod <
|
|
19
|
+
"project-open-grafana-pod <envComponent>",
|
|
21
20
|
"open Grafana dashboard for a specific pod"
|
|
22
21
|
)
|
|
23
|
-
.autocomplete(
|
|
24
|
-
.action(async function ({
|
|
25
|
-
await ensureCluster.call(this);
|
|
26
|
-
const podNames = await getProjectPodNames(
|
|
22
|
+
.autocomplete(await envAndComponents())
|
|
23
|
+
.action(async function ({ envComponent }) {
|
|
24
|
+
await ensureCluster.call(this, envComponent);
|
|
25
|
+
const podNames = await getProjectPodNames(envComponent);
|
|
27
26
|
if (podNames.length === 0) {
|
|
28
27
|
logError(this, "sorry, no pods found");
|
|
29
28
|
return;
|
|
@@ -34,7 +33,7 @@ export default (vorpal: Vorpal) =>
|
|
|
34
33
|
choices: podNames,
|
|
35
34
|
message: "Which pod? 🤔",
|
|
36
35
|
});
|
|
37
|
-
const namespace = await getProjectNamespace(
|
|
36
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
38
37
|
const url = `http://localhost:${GRAFANA_PROXY_LOCAL_PORT}/grafana/d/at-cost-analysis-pod/pod-cost-and-utilization-metrics?var-namespace=${namespace}&var-pod=${podName}`;
|
|
39
38
|
await startPortForward(
|
|
40
39
|
"deployment/kubecost-cost-analyzer",
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import Vorpal from "vorpal";
|
|
2
|
+
import {
|
|
3
|
+
getPipelineContextByChoice,
|
|
4
|
+
parseChoice,
|
|
5
|
+
} from "../../../../config/getProjectConfig";
|
|
6
|
+
import { getCurrentConnectedClusterName } from "../../../../utils/cluster";
|
|
7
|
+
import { getProjectNamespace } from "../../../../utils/projects";
|
|
8
|
+
import { getGoogleAuthUserNumber } from "../../utils/getGoogleAuthUserNumber";
|
|
9
|
+
import { openGoogleCloudLogs } from "../shared";
|
|
10
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
11
|
+
import ensureCluster from "./utils/ensureCluster";
|
|
12
|
+
|
|
13
|
+
export default async (vorpal: Vorpal) =>
|
|
14
|
+
vorpal
|
|
15
|
+
.command(
|
|
16
|
+
"project-open-logs <envComponent>",
|
|
17
|
+
"open google cloud logs (stackdriver logs)"
|
|
18
|
+
)
|
|
19
|
+
.autocomplete(await envAndComponents())
|
|
20
|
+
.action(async function ({ envComponent }) {
|
|
21
|
+
const { env, componentName } = parseChoice(envComponent);
|
|
22
|
+
const { componentConfig, environment } = await getPipelineContextByChoice(
|
|
23
|
+
env,
|
|
24
|
+
componentName
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
if (
|
|
28
|
+
!componentConfig.deploy ||
|
|
29
|
+
componentConfig.deploy.type !== "kubernetes"
|
|
30
|
+
) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
"only kubernetes deployments are supported at the moment"
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (
|
|
37
|
+
!componentConfig.deploy.cluster ||
|
|
38
|
+
componentConfig.deploy.cluster.type !== "gcloud"
|
|
39
|
+
) {
|
|
40
|
+
throw new Error("no gcloud custer configured");
|
|
41
|
+
}
|
|
42
|
+
// currently only supports kubernetes
|
|
43
|
+
const namespace = environment.envVars.KUBE_NAMESPACE;
|
|
44
|
+
|
|
45
|
+
const authGoogleNumber = await getGoogleAuthUserNumber.call(this, vorpal);
|
|
46
|
+
|
|
47
|
+
await openGoogleCloudLogs(
|
|
48
|
+
componentConfig.deploy.cluster,
|
|
49
|
+
namespace,
|
|
50
|
+
authGoogleNumber
|
|
51
|
+
);
|
|
52
|
+
});
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import Vorpal from "vorpal";
|
|
2
2
|
import { exec } from "child-process-promise";
|
|
3
|
-
import { Env } from "../../../../types/types";
|
|
4
3
|
import { getProjectNamespace } from "../../../../utils/projects";
|
|
5
|
-
import {
|
|
4
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
6
5
|
|
|
7
|
-
export default (vorpal: Vorpal) =>
|
|
6
|
+
export default async (vorpal: Vorpal) =>
|
|
8
7
|
vorpal
|
|
9
|
-
.command(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
.command(
|
|
9
|
+
"project-pause <envComponent>",
|
|
10
|
+
"halts all running pods (scales to 0)"
|
|
11
|
+
)
|
|
12
|
+
.autocomplete(await envAndComponents())
|
|
13
|
+
.action(async function ({ envComponent }) {
|
|
14
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
13
15
|
const { shouldContinue } = await this.prompt({
|
|
14
16
|
type: "confirm",
|
|
15
17
|
name: "shouldContinue",
|
|
@@ -5,17 +5,17 @@ import {
|
|
|
5
5
|
getProjectNamespace,
|
|
6
6
|
getProjectPodNames,
|
|
7
7
|
} from "../../../../utils/projects";
|
|
8
|
-
import {
|
|
8
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
9
9
|
import ensureCluster from "./utils/ensureCluster";
|
|
10
10
|
|
|
11
|
-
export default (vorpal: Vorpal) =>
|
|
11
|
+
export default async (vorpal: Vorpal) =>
|
|
12
12
|
vorpal
|
|
13
|
-
.command("project-port-forward <
|
|
14
|
-
.autocomplete(
|
|
15
|
-
.action(async function ({
|
|
16
|
-
await ensureCluster.call(this);
|
|
17
|
-
const namespace = await getProjectNamespace(
|
|
18
|
-
const podNames = await getProjectPodNames(
|
|
13
|
+
.command("project-port-forward <envComponent>", "start port-forwarding")
|
|
14
|
+
.autocomplete(await envAndComponents())
|
|
15
|
+
.action(async function ({ envComponent }) {
|
|
16
|
+
await ensureCluster.call(this, envComponent);
|
|
17
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
18
|
+
const podNames = await getProjectPodNames(envComponent);
|
|
19
19
|
if (podNames.length === 0) {
|
|
20
20
|
logError(this, "sorry, no pods found");
|
|
21
21
|
return;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Vorpal from "vorpal";
|
|
2
|
+
import { reloadConfig } from "../../../../config/getProjectConfig";
|
|
3
|
+
import { showProjectBanner } from "./utils/showProjectBanner";
|
|
4
|
+
|
|
5
|
+
export default async (vorpal: Vorpal) =>
|
|
6
|
+
vorpal
|
|
7
|
+
.command("project-reload-config", "reloads the config")
|
|
8
|
+
|
|
9
|
+
.action(async function () {
|
|
10
|
+
await reloadConfig();
|
|
11
|
+
await showProjectBanner(vorpal);
|
|
12
|
+
});
|
|
@@ -6,7 +6,7 @@ import { logError } from "../../../../utils/log";
|
|
|
6
6
|
import { namespaceAutoCompletion } from "../general/namespaceAutoCompletion";
|
|
7
7
|
|
|
8
8
|
import { getProjectNamespace } from "../../../../utils/projects";
|
|
9
|
-
import {
|
|
9
|
+
import { envAndComponents } from "./utils/autocompletions";
|
|
10
10
|
import ensureCluster from "./utils/ensureCluster";
|
|
11
11
|
|
|
12
12
|
async function triggerCronjob(namespace: string) {
|
|
@@ -43,7 +43,7 @@ async function triggerCronjob(namespace: string) {
|
|
|
43
43
|
logError(this, "command failed", e.body);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
export default (vorpal: Vorpal) => {
|
|
46
|
+
export default async (vorpal: Vorpal) => {
|
|
47
47
|
vorpal
|
|
48
48
|
.command("trigger-cronjob <namespace>", "trigger cronjob")
|
|
49
49
|
.autocomplete(namespaceAutoCompletion)
|
|
@@ -51,11 +51,11 @@ export default (vorpal: Vorpal) => {
|
|
|
51
51
|
await triggerCronjob.call(this, namespace);
|
|
52
52
|
});
|
|
53
53
|
vorpal
|
|
54
|
-
.command("project-trigger-cronjob <
|
|
55
|
-
.autocomplete(
|
|
56
|
-
.action(async function ({
|
|
57
|
-
await ensureCluster.call(this);
|
|
58
|
-
const namespace = await getProjectNamespace(
|
|
54
|
+
.command("project-trigger-cronjob <envComponent>", "trigger cronjob")
|
|
55
|
+
.autocomplete(await envAndComponents())
|
|
56
|
+
.action(async function ({ envComponent }) {
|
|
57
|
+
await ensureCluster.call(this, envComponent);
|
|
58
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
59
59
|
await triggerCronjob.call(this, namespace);
|
|
60
60
|
});
|
|
61
61
|
};
|
|
@@ -22,15 +22,16 @@ import commandPauseProject from "./commandPauseProject";
|
|
|
22
22
|
import commandOpenGrafana from "./commandOpenGrafana";
|
|
23
23
|
import commandPortForward from "./commandPortForward";
|
|
24
24
|
import commandTriggerCronjob from "./commandTriggerCronjob";
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
import commandOpenGrafanaPod from "./commandOpenGrafanaPod";
|
|
27
|
+
import commandReloadConfig from "./commandReloadConfig";
|
|
27
28
|
|
|
28
|
-
export default (vorpal: Vorpal) => {
|
|
29
|
+
export default async (vorpal: Vorpal) => {
|
|
30
|
+
commandReloadConfig(vorpal);
|
|
29
31
|
commandInitProject(vorpal);
|
|
30
32
|
commandInitGitlab(vorpal);
|
|
31
33
|
commandEnvVars(vorpal);
|
|
32
34
|
|
|
33
|
-
commandVariables(vorpal);
|
|
34
35
|
commandNamespace(vorpal);
|
|
35
36
|
commandListPods(vorpal);
|
|
36
37
|
commandPauseProject(vorpal);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getAllEnvs, getAllEnvsInAllComponents } from "@catladder/pipeline";
|
|
2
|
+
import {
|
|
3
|
+
getAllComponentsWithAllEnvsFlat,
|
|
4
|
+
getProjectConfig,
|
|
5
|
+
} from "../../../../../config/getProjectConfig";
|
|
6
|
+
|
|
7
|
+
export const allEnvs = async () => {
|
|
8
|
+
const config = await getProjectConfig();
|
|
9
|
+
if (!config) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
return getAllEnvsInAllComponents(config);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const envAndComponents = async () => {
|
|
16
|
+
const allEnvAndcomponents = await getAllComponentsWithAllEnvsFlat();
|
|
17
|
+
|
|
18
|
+
return allEnvAndcomponents.reduce<string[]>(
|
|
19
|
+
(acc, { env, componentName }) => [...acc, env + ":" + componentName],
|
|
20
|
+
[]
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const allEnvsAndAllComponents = async () => {
|
|
25
|
+
return [...(await allEnvs()), ...(await envAndComponents())];
|
|
26
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isOfDeployType,
|
|
3
|
+
getFullKubernetesClusterName,
|
|
4
|
+
} from "@catladder/pipeline";
|
|
5
|
+
import {
|
|
6
|
+
getPipelineContextByChoice,
|
|
7
|
+
parseChoice,
|
|
8
|
+
} from "../../../../../config/getProjectConfig";
|
|
9
|
+
import {
|
|
10
|
+
connectToCluster,
|
|
11
|
+
getCurrentConnectedClusterName,
|
|
12
|
+
} from "../../../../../utils/cluster";
|
|
13
|
+
export default async function (envComponent: string) {
|
|
14
|
+
const { env, componentName } = parseChoice(envComponent);
|
|
15
|
+
const context = await getPipelineContextByChoice(env, componentName);
|
|
16
|
+
if (!isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
17
|
+
throw new Error("can't ensure cluster for non-kubernetes deployments");
|
|
18
|
+
}
|
|
19
|
+
const cluster = getFullKubernetesClusterName(
|
|
20
|
+
context.componentConfig.deploy.cluster
|
|
21
|
+
);
|
|
22
|
+
const connectedClusterName = await getCurrentConnectedClusterName();
|
|
23
|
+
|
|
24
|
+
if (cluster !== connectedClusterName) {
|
|
25
|
+
this.log(
|
|
26
|
+
`you are currently connected to cluster '${connectedClusterName}'`
|
|
27
|
+
);
|
|
28
|
+
this.log(`but the project requires cluster '${cluster}'`);
|
|
29
|
+
const { shouldContinue } = await this.prompt({
|
|
30
|
+
type: "confirm",
|
|
31
|
+
name: "shouldContinue",
|
|
32
|
+
default: true,
|
|
33
|
+
message: `Do you want to connect to '${cluster}'?`,
|
|
34
|
+
});
|
|
35
|
+
if (!shouldContinue) {
|
|
36
|
+
this.log("abort");
|
|
37
|
+
} else {
|
|
38
|
+
await connectToCluster(cluster);
|
|
39
|
+
this.log(`connected to cluster '${cluster}'`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Context, getKubernetesNamespace } from "@catladder/pipeline";
|
|
2
|
+
import { V1Namespace, V1ObjectMeta } from "@kubernetes/client-node";
|
|
3
|
+
import k8sApi from "../../../../../k8sApi";
|
|
4
|
+
|
|
5
|
+
export default async function (context: Context) {
|
|
6
|
+
const namespace = getKubernetesNamespace(
|
|
7
|
+
context.fullConfig,
|
|
8
|
+
context.environment.shortName
|
|
9
|
+
);
|
|
10
|
+
const namespaceBody = new V1Namespace();
|
|
11
|
+
const metadata: V1ObjectMeta = {
|
|
12
|
+
name: namespace,
|
|
13
|
+
labels: {
|
|
14
|
+
customerName: context.fullConfig.customerName,
|
|
15
|
+
appName: context.fullConfig.appName,
|
|
16
|
+
environment: context.environment.shortName,
|
|
17
|
+
components: Object.keys(context.fullConfig.components).join("_"), // limited chars available...
|
|
18
|
+
buildTypes: Object.values(context.fullConfig.components)
|
|
19
|
+
.map((config) => config.build.type)
|
|
20
|
+
.join("_"), // limited chars available...
|
|
21
|
+
...Object.fromEntries(
|
|
22
|
+
Object.entries(context.fullConfig.components).map(
|
|
23
|
+
([componentName, config]) => [
|
|
24
|
+
"buildType_" + componentName,
|
|
25
|
+
config.build.type,
|
|
26
|
+
]
|
|
27
|
+
)
|
|
28
|
+
),
|
|
29
|
+
...(context.fullConfig.meta?.labels ?? {}),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
namespaceBody.metadata = metadata;
|
|
34
|
+
try {
|
|
35
|
+
await k8sApi.readNamespace(namespace);
|
|
36
|
+
|
|
37
|
+
await k8sApi.patchNamespace(
|
|
38
|
+
namespace,
|
|
39
|
+
namespaceBody,
|
|
40
|
+
undefined,
|
|
41
|
+
undefined,
|
|
42
|
+
undefined,
|
|
43
|
+
undefined,
|
|
44
|
+
{ headers: { "content-type": "application/merge-patch+json" } } // see https://github.com/kubernetes-client/javascript/issues/443
|
|
45
|
+
); // update meta data
|
|
46
|
+
} catch (e) {
|
|
47
|
+
if (e.response?.body?.reason === "NotFound") {
|
|
48
|
+
await k8sApi.createNamespace(namespaceBody);
|
|
49
|
+
} else {
|
|
50
|
+
console.error(e.response?.body);
|
|
51
|
+
throw e;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return namespace;
|
|
55
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Vorpal from "vorpal";
|
|
2
|
+
import { getProjectConfig } from "../../../../../config/getProjectConfig";
|
|
3
|
+
|
|
4
|
+
export const showProjectBanner = async (vorpal: Vorpal) => {
|
|
5
|
+
const projectConfig = await getProjectConfig();
|
|
6
|
+
if (projectConfig) {
|
|
7
|
+
vorpal.log("project: " + projectConfig.appName);
|
|
8
|
+
vorpal.log("customer: " + projectConfig.customerName);
|
|
9
|
+
vorpal.log("");
|
|
10
|
+
}
|
|
11
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DeployConfigKubernetesCluster } from "@catladder/pipeline";
|
|
2
|
+
import open from "open";
|
|
3
|
+
|
|
4
|
+
export const openGoogleCloudLogs = async (
|
|
5
|
+
cluster?: DeployConfigKubernetesCluster,
|
|
6
|
+
namespace?: string,
|
|
7
|
+
googleAuthUserNumber = 0
|
|
8
|
+
) => {
|
|
9
|
+
const resource = `k8s_container/cluster_name/${cluster.name}${
|
|
10
|
+
namespace ? `/namespace_name/${namespace}` : ""
|
|
11
|
+
}`;
|
|
12
|
+
|
|
13
|
+
const url = `https://console.cloud.google.com/logs/viewer?project=${
|
|
14
|
+
cluster.projectId
|
|
15
|
+
}${
|
|
16
|
+
resource ? `&resource=${encodeURIComponent(resource)}` : ""
|
|
17
|
+
}&authuser=${googleAuthUserNumber}`;
|
|
18
|
+
open(url);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const openGoogleCloudKubernetesDashboard = async (
|
|
22
|
+
cluster: DeployConfigKubernetesCluster,
|
|
23
|
+
namespace: string,
|
|
24
|
+
googleAuthUserNumber = 0
|
|
25
|
+
) => {
|
|
26
|
+
//gke_skynet-164509_europe-west1-d_production
|
|
27
|
+
// ?authuser=1&project=skynet-swiss&pageState=pageState%3D(%22savedViews%22:(%22c%22:%5B%22gke%2Feurope-west6-a%2Fch-production%22%5D,%22n%22:%5B%22pvl-bike2school-review%22%5D,%22i%22:%224e42e0b9cd6147f8a4fba7516752ec48%22))
|
|
28
|
+
// ?authuser=1&project=skynet-swiss&pageState=(%22savedViews%22:(%22i%22:%2279802e2b154d46d480dff4e086e87875%22,%22c%22:%5B%22gke%2Feurope-west6-a%2Fch-production%22%5D,%22n%22:%5B%22pvl-bike2school-review%22%5D))
|
|
29
|
+
|
|
30
|
+
const pageState = `("savedViews":("c":["gke/${cluster.region}/${cluster.name}"],"n":["${namespace}"],"i":"4e42e0b9cd6147f8a4fba7516752ec48"))`;
|
|
31
|
+
const url = `https://console.cloud.google.com/kubernetes/workload?authuser=${googleAuthUserNumber}&project=${
|
|
32
|
+
cluster.projectId
|
|
33
|
+
}&pageState=${encodeURIComponent(pageState)}`;
|
|
34
|
+
|
|
35
|
+
open(url);
|
|
36
|
+
};
|
|
@@ -2,50 +2,31 @@ import { spawn } from "child-process-promise";
|
|
|
2
2
|
import fetch from "node-fetch";
|
|
3
3
|
import Vorpal from "vorpal";
|
|
4
4
|
|
|
5
|
-
export default (vorpal: Vorpal) => {
|
|
6
|
-
vorpal.command("dadjoke", "something for jonas.").action(async function() {
|
|
5
|
+
export default async (vorpal: Vorpal) => {
|
|
6
|
+
vorpal.command("dadjoke", "something for jonas.").action(async function () {
|
|
7
7
|
const result = await fetch("https://icanhazdadjoke.com/", {
|
|
8
8
|
headers: {
|
|
9
|
-
Accept: "text/plain"
|
|
10
|
-
}
|
|
9
|
+
Accept: "text/plain",
|
|
10
|
+
},
|
|
11
11
|
});
|
|
12
12
|
const text = await result.text();
|
|
13
13
|
this.log("");
|
|
14
14
|
this.log(text);
|
|
15
15
|
this.log("");
|
|
16
16
|
});
|
|
17
|
-
vorpal.command("pantobot", "the allknowing oracle").action(async function() {
|
|
18
|
-
const { message } = await this.prompt({
|
|
19
|
-
type: "string",
|
|
20
|
-
name: "message",
|
|
21
17
|
|
|
22
|
-
message: "Your question, unworthy?: "
|
|
23
|
-
});
|
|
24
|
-
const result = await fetch(
|
|
25
|
-
`https://paas.panter.cloud/api/pantobot/${message}`,
|
|
26
|
-
{
|
|
27
|
-
headers: {
|
|
28
|
-
Accept: "text/plain"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
const text = await result.text();
|
|
33
|
-
this.log("");
|
|
34
|
-
this.log(text);
|
|
35
|
-
this.log("");
|
|
36
|
-
});
|
|
37
18
|
let starwarsPromise: any;
|
|
38
19
|
vorpal
|
|
39
20
|
.command("starwars", "Long time ago... in a galaxy far far away...")
|
|
40
|
-
.action(async function() {
|
|
21
|
+
.action(async function () {
|
|
41
22
|
starwarsPromise = spawn("telnet", ["towel.blinkenlights.nl"], {
|
|
42
|
-
stdio: ["pipe", "inherit", "pipe"]
|
|
23
|
+
stdio: ["pipe", "inherit", "pipe"],
|
|
43
24
|
});
|
|
44
25
|
await starwarsPromise;
|
|
45
26
|
})
|
|
46
27
|
// we need to close it properly, because telnet towel.blinkenlights.nl has no way to cancel and stop itself
|
|
47
28
|
// this is also why we need to only inherit the stdout and not the stdin
|
|
48
|
-
.cancel(async function() {
|
|
29
|
+
.cancel(async function () {
|
|
49
30
|
starwarsPromise.childProcess.kill();
|
|
50
31
|
});
|
|
51
32
|
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Config } from "@catladder/pipeline";
|
|
2
|
+
import { spawn, exec } from "child-process-promise";
|
|
3
|
+
import { writeFile } from "fs-extra";
|
|
4
|
+
import { dump } from "js-yaml";
|
|
5
|
+
import { format } from "prettier";
|
|
6
|
+
import { CommandInstance } from "vorpal";
|
|
7
|
+
import { getGitRoot } from "../../../utils/projects";
|
|
8
|
+
|
|
9
|
+
export const writeConfig = async (
|
|
10
|
+
vorpal: CommandInstance,
|
|
11
|
+
config: Config,
|
|
12
|
+
options?: {
|
|
13
|
+
endComment?: string;
|
|
14
|
+
}
|
|
15
|
+
) => {
|
|
16
|
+
const gitRoot = await getGitRoot();
|
|
17
|
+
const TS = "typescript (recommended)";
|
|
18
|
+
const { configType } = await vorpal.prompt({
|
|
19
|
+
type: "list",
|
|
20
|
+
name: "configType",
|
|
21
|
+
choices: [TS, "yaml"],
|
|
22
|
+
message: "In which format do you want the config? 🤔",
|
|
23
|
+
});
|
|
24
|
+
vorpal.log("");
|
|
25
|
+
if (configType === TS) {
|
|
26
|
+
const file = gitRoot + "/catladder.ts";
|
|
27
|
+
const content = format(
|
|
28
|
+
`
|
|
29
|
+
import type { Config } from "@catladder/pipeline";
|
|
30
|
+
|
|
31
|
+
const config: Config = ${JSON.stringify(config)};
|
|
32
|
+
|
|
33
|
+
export default config;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
${options?.endComment ? `/*${options.endComment}*/` : ""}
|
|
37
|
+
|
|
38
|
+
`,
|
|
39
|
+
{
|
|
40
|
+
parser: "babel",
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
await writeFile(file, content, {
|
|
45
|
+
encoding: "utf-8",
|
|
46
|
+
});
|
|
47
|
+
vorpal.log("adding type @catladder/pipeline....");
|
|
48
|
+
await spawn("yarn add --non-interactive @catladder/pipeline -DW", {
|
|
49
|
+
shell: true,
|
|
50
|
+
});
|
|
51
|
+
await exec("git add " + file);
|
|
52
|
+
} else {
|
|
53
|
+
const file = gitRoot + "/catladder.yml";
|
|
54
|
+
const content = dump(config);
|
|
55
|
+
|
|
56
|
+
await writeFile(
|
|
57
|
+
file,
|
|
58
|
+
content +
|
|
59
|
+
"\n\n" +
|
|
60
|
+
(options.endComment
|
|
61
|
+
? "# " + options.endComment.split("\n").join("\n# ")
|
|
62
|
+
: ""),
|
|
63
|
+
{
|
|
64
|
+
encoding: "utf-8",
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
await exec("git add " + file);
|
|
68
|
+
}
|
|
69
|
+
vorpal.log("done!");
|
|
70
|
+
vorpal.log("");
|
|
71
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Vorpal from "vorpal";
|
|
2
|
+
import {
|
|
3
|
+
getGitlabCi,
|
|
4
|
+
getProjectConfig,
|
|
5
|
+
} from "../../../config/getProjectConfig";
|
|
6
|
+
import { hasGitlabToken, setupGitlabToken } from "../../../utils/gitlab";
|
|
7
|
+
import { isV2, migrateV2 } from "./migration/fromv2";
|
|
8
|
+
|
|
9
|
+
export const verify = async (vorpal: Vorpal) => {
|
|
10
|
+
// check if has all settings
|
|
11
|
+
|
|
12
|
+
if (!(await hasGitlabToken())) {
|
|
13
|
+
vorpal.command("setup-gitlab-token").action(async function () {
|
|
14
|
+
await setupGitlabToken(this);
|
|
15
|
+
});
|
|
16
|
+
vorpal.exec("setup-gitlab-token");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const projectConfig = await getProjectConfig();
|
|
20
|
+
try {
|
|
21
|
+
const gitlabCi = getGitlabCi();
|
|
22
|
+
|
|
23
|
+
if (gitlabCi && !projectConfig && (await isV2())) {
|
|
24
|
+
vorpal.log("no project config, needs migration");
|
|
25
|
+
await migrateV2(vorpal);
|
|
26
|
+
}
|
|
27
|
+
} catch (e) {
|
|
28
|
+
// no gitroot, ignore
|
|
29
|
+
}
|
|
30
|
+
};
|