@catladder/cli 1.40.2 → 1.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/bin/catenv +1 -1
  2. package/bin/catenv-dev +3 -0
  3. package/bin/catladder +1 -1
  4. package/bin/catladder-dev +3 -0
  5. package/dist/apps/cli/commands/general/index.d.ts +1 -1
  6. package/dist/apps/cli/commands/general/portForward.d.ts +1 -1
  7. package/dist/apps/cli/commands/mongodb/index.d.ts +1 -1
  8. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +1 -1
  9. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +2 -1
  10. package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -1
  11. package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +1 -1
  12. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +1 -1
  13. package/dist/apps/cli/commands/mongodb/utils/index.js +2 -1
  14. package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -1
  15. package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +1 -1
  16. package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +2 -1
  17. package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
  18. package/dist/apps/cli/commands/project/commandCopyDB.d.ts +1 -1
  19. package/dist/apps/cli/commands/project/commandDeletePods.d.ts +1 -1
  20. package/dist/apps/cli/commands/project/commandDeletePods.js +2 -1
  21. package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -1
  22. package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +1 -1
  23. package/dist/apps/cli/commands/project/commandEnvVars.d.ts +1 -1
  24. package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +1 -1
  25. package/dist/apps/cli/commands/project/commandGetShell.d.ts +1 -1
  26. package/dist/apps/cli/commands/project/commandGetShell.js +2 -1
  27. package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -1
  28. package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +1 -1
  29. package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -1
  30. package/dist/apps/cli/commands/project/commandInitProject.old.d.ts +1 -1
  31. package/dist/apps/cli/commands/project/commandListPods.d.ts +1 -1
  32. package/dist/apps/cli/commands/project/commandListPods.js +2 -2
  33. package/dist/apps/cli/commands/project/commandListPods.js.map +1 -1
  34. package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +1 -1
  35. package/dist/apps/cli/commands/project/commandNamespace.d.ts +1 -1
  36. package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +1 -1
  37. package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +1 -1
  38. package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +1 -1
  39. package/dist/apps/cli/commands/project/commandOpenGit.d.ts +1 -1
  40. package/dist/apps/cli/commands/project/commandOpenGit.js +2 -7
  41. package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -1
  42. package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +1 -1
  43. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +1 -1
  44. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +2 -1
  45. package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -1
  46. package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +1 -1
  47. package/dist/apps/cli/commands/project/commandPauseProject.d.ts +1 -1
  48. package/dist/apps/cli/commands/project/commandPortForward.d.ts +1 -1
  49. package/dist/apps/cli/commands/project/commandPortForward.js +2 -1
  50. package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -1
  51. package/dist/apps/cli/commands/project/commandSetup.d.ts +1 -1
  52. package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +1 -1
  53. package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -1
  54. package/dist/apps/cli/commands/project/index.d.ts +1 -1
  55. package/dist/apps/cli/commands/project/setup/index.d.ts +1 -1
  56. package/dist/apps/cli/commands/project/setup/setupAccessTokens.d.ts +1 -1
  57. package/dist/apps/cli/commands/project/setup/setupContext.d.ts +2 -2
  58. package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -1
  59. package/dist/apps/cli/commands/project/setup/setupKubernetes.d.ts +2 -2
  60. package/dist/apps/cli/commands/project/setup/setupKubernetes.js +10 -15
  61. package/dist/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
  62. package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +1 -1
  63. package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -1
  64. package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +1 -1
  65. package/dist/apps/cli/commands/shared/index.d.ts +1 -1
  66. package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +1 -1
  67. package/dist/apps/cli/config/writeConfig.d.ts +2 -2
  68. package/dist/apps/cli/verify/index.d.ts +1 -1
  69. package/dist/apps/cli/verify/migration/fromv2.d.ts +1 -1
  70. package/dist/apps/cli/verify/migration/fromv2.js.map +1 -1
  71. package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +3 -3
  72. package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -1
  73. package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +1 -1
  74. package/dist/bundles/catenv/index.js +15 -0
  75. package/dist/bundles/catenv/xdg-open +1066 -0
  76. package/dist/bundles/cli/clipboard_i686.exe +0 -0
  77. package/dist/bundles/cli/clipboard_x86_64.exe +0 -0
  78. package/dist/bundles/cli/exec-child.js +39 -0
  79. package/dist/bundles/cli/index.js +574 -0
  80. package/dist/bundles/cli/xdg-open +1066 -0
  81. package/dist/bundles/cli/xsel +0 -0
  82. package/dist/catenv.js +2 -4
  83. package/dist/catenv.js.map +1 -1
  84. package/dist/cli.js +0 -2
  85. package/dist/cli.js.map +1 -1
  86. package/dist/config/getProjectConfig.d.ts +3 -6
  87. package/dist/config/getProjectConfig.js +10 -6
  88. package/dist/config/getProjectConfig.js.map +1 -1
  89. package/dist/config/parseChoice.d.ts +4 -0
  90. package/dist/config/parseChoice.js +9 -0
  91. package/dist/config/parseChoice.js.map +1 -0
  92. package/dist/kubernetes/index.d.ts +3 -0
  93. package/dist/kubernetes/index.js +88 -0
  94. package/dist/kubernetes/index.js.map +1 -0
  95. package/dist/tsconfig.tsbuildinfo +1 -1
  96. package/dist/utils/cluster.d.ts +2 -2
  97. package/dist/utils/cluster.js +3 -8
  98. package/dist/utils/cluster.js.map +1 -1
  99. package/dist/utils/gitlab.d.ts +1 -1
  100. package/dist/utils/gitlab.js +1 -1
  101. package/dist/utils/gitlab.js.map +1 -1
  102. package/dist/utils/projects/index.d.ts +0 -3
  103. package/dist/utils/projects/index.js +3 -54
  104. package/dist/utils/projects/index.js.map +1 -1
  105. package/package.json +25 -23
  106. package/scripts/bundle +4 -0
  107. package/src/apps/catenv/catenv.ts +1 -1
  108. package/src/apps/cli/commands/general/index.ts +1 -1
  109. package/src/apps/cli/commands/general/portForward.ts +1 -1
  110. package/src/apps/cli/commands/mongodb/index.ts +1 -1
  111. package/src/apps/cli/commands/mongodb/projectMongoDestroyMember.ts +3 -5
  112. package/src/apps/cli/commands/mongodb/projectMongoGetShell.ts +1 -1
  113. package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +1 -1
  114. package/src/apps/cli/commands/mongodb/utils/index.ts +2 -4
  115. package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +1 -1
  116. package/src/apps/cli/commands/project/commandConfigSecrets.ts +2 -1
  117. package/src/apps/cli/commands/project/commandCopyDB.ts +1 -1
  118. package/src/apps/cli/commands/project/commandDeletePods.ts +3 -5
  119. package/src/apps/cli/commands/project/commandDeleteProject.ts +1 -1
  120. package/src/apps/cli/commands/project/commandEnvVars.ts +1 -1
  121. package/src/apps/cli/commands/project/commandGetMyTotalWorktime.ts +1 -1
  122. package/src/apps/cli/commands/project/commandGetShell.ts +3 -5
  123. package/src/apps/cli/commands/project/commandGitlabCi.ts +2 -1
  124. package/src/apps/cli/commands/project/commandInitProject.old.ts +1 -1
  125. package/src/apps/cli/commands/project/commandListPods.ts +2 -2
  126. package/src/apps/cli/commands/project/commandMigrateHelm3.ts +1 -1
  127. package/src/apps/cli/commands/project/commandNamespace.ts +1 -1
  128. package/src/apps/cli/commands/project/commandOpenCostDashboard.ts +1 -1
  129. package/src/apps/cli/commands/project/commandOpenDashboard.ts +1 -1
  130. package/src/apps/cli/commands/project/commandOpenEnv.ts +1 -1
  131. package/src/apps/cli/commands/project/commandOpenGit.ts +3 -3
  132. package/src/apps/cli/commands/project/commandOpenGrafana.ts +1 -1
  133. package/src/apps/cli/commands/project/commandOpenGrafanaPod.ts +3 -5
  134. package/src/apps/cli/commands/project/commandOpenLogs.ts +1 -1
  135. package/src/apps/cli/commands/project/commandPauseProject.ts +1 -1
  136. package/src/apps/cli/commands/project/commandPortForward.ts +3 -5
  137. package/src/apps/cli/commands/project/commandSetup.ts +1 -1
  138. package/src/apps/cli/commands/project/commandTriggerCronjob.ts +3 -2
  139. package/src/apps/cli/commands/project/index.ts +1 -1
  140. package/src/apps/cli/commands/project/setup/index.ts +1 -1
  141. package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +1 -1
  142. package/src/apps/cli/commands/project/setup/setupContext.ts +3 -2
  143. package/src/apps/cli/commands/project/setup/setupKubernetes.ts +30 -23
  144. package/src/apps/cli/commands/project/utils/ensureNamespace.ts +4 -2
  145. package/src/apps/cli/commands/project/utils/showProjectBanner.ts +1 -1
  146. package/src/apps/cli/commands/shared/index.ts +1 -1
  147. package/src/apps/cli/commands/theStuffThatReallyMatters/index.ts +1 -1
  148. package/src/apps/cli/config/writeConfig.ts +2 -2
  149. package/src/apps/cli/verify/index.ts +1 -1
  150. package/src/apps/cli/verify/migration/fromv2.ts +4 -7
  151. package/src/apps/cli/verify/migration/migrateSecrets.ts +4 -3
  152. package/src/apps/cli/verify/migration/oldGitlabCi.ts +1 -1
  153. package/src/catenv.ts +3 -4
  154. package/src/cli.ts +1 -2
  155. package/src/config/getProjectConfig.ts +6 -8
  156. package/src/config/parseChoice.ts +4 -0
  157. package/src/kubernetes/index.ts +27 -0
  158. package/src/utils/cluster.ts +3 -3
  159. package/src/utils/gitlab.ts +5 -4
  160. package/src/utils/projects/index.ts +3 -27
@@ -1,5 +1,5 @@
1
1
  import open from "open";
2
- import { CommandInstance } from "vorpal";
2
+ import type { CommandInstance } from "vorpal";
3
3
  import { doGitlabRequest, getProjectInfo } from "../../../../../utils/gitlab";
4
4
 
5
5
  export const setupAccessTokens = async (instance: CommandInstance) => {
@@ -1,5 +1,6 @@
1
- import { Context, isOfDeployType } from "@catladder/pipeline";
2
- import { CommandInstance } from "vorpal";
1
+ import type { Context} from "@catladder/pipeline";
2
+ import { isOfDeployType } from "@catladder/pipeline";
3
+ import type { CommandInstance } from "vorpal";
3
4
  import { setupKubernetes } from "./setupKubernetes";
4
5
 
5
6
  export const setupContext = async (
@@ -1,10 +1,11 @@
1
+ import type {
2
+ Context} from "@catladder/pipeline";
1
3
  import {
2
- Context,
3
4
  getFullKubernetesClusterName,
4
5
  isOfDeployType,
5
6
  } from "@catladder/pipeline";
6
- import { CommandInstance } from "vorpal";
7
- import { $ } from "zx";
7
+ import type { CommandInstance } from "vorpal";
8
+ import { exec } from "child-process-promise";
8
9
  import { connectToCluster } from "../../../../../utils/cluster";
9
10
  import { upsertAllVariables } from "../../../../../utils/gitlab";
10
11
  import ensureNamespace from "../utils/ensureNamespace";
@@ -33,25 +34,32 @@ export const setupKubernetes = async (
33
34
  // we currently create one per component to better separate them
34
35
  instance.log("ensuring service accounts...");
35
36
  const serviceAccountName = `cl-${context.componentName}-deploy`;
36
- const KUBE_URL =
37
- await $`TERM=dumb kubectl cluster-info | grep -E 'Kubernetes master|Kubernetes control plane' | awk '/http/ {print $NF}'`.then(
38
- (s) => s.stdout.trim()
39
- );
37
+ const KUBE_URL = await exec(
38
+ `TERM=dumb kubectl cluster-info | grep -E 'Kubernetes master|Kubernetes control plane' | awk '/http/ {print $NF}'`
39
+ ).then((s: any) => s.stdout.trim());
40
40
 
41
41
  // first upsert service acount in the ns
42
42
  try {
43
- await $`kubectl delete serviceaccount --namespace ${namespace} ${serviceAccountName}`;
44
- await $`kubectl delete rolebinding --namespace ${namespace} ${serviceAccountName}`;
45
- await $`kubectl delete role --namespace ${namespace} ${serviceAccountName}`;
43
+ await exec(
44
+ `kubectl delete serviceaccount --namespace ${namespace} ${serviceAccountName}`
45
+ );
46
+ await exec(
47
+ `kubectl delete rolebinding --namespace ${namespace} ${serviceAccountName}`
48
+ );
49
+ await exec(
50
+ `kubectl delete role --namespace ${namespace} ${serviceAccountName}`
51
+ );
46
52
  } catch (e) {
47
53
  // ignore
48
54
  }
49
55
 
50
- await $`kubectl create serviceaccount --namespace ${namespace} ${serviceAccountName}`;
56
+ await exec(
57
+ `kubectl create serviceaccount --namespace ${namespace} ${serviceAccountName}`
58
+ );
51
59
 
52
60
  // upsert role in the ns
53
61
 
54
- await $`cat <<EOF | kubectl apply -f -
62
+ await exec(`cat <<EOF | kubectl apply -f -
55
63
  kind: Role
56
64
  apiVersion: rbac.authorization.k8s.io/v1
57
65
  metadata:
@@ -76,20 +84,19 @@ roleRef:
76
84
  name: ${serviceAccountName}
77
85
  apiGroup: rbac.authorization.k8s.io
78
86
  EOF
79
- `;
87
+ `);
80
88
 
81
89
  // get token name
82
- const tokenName =
83
- await $`kubectl get serviceaccount --namespace ${namespace} ${serviceAccountName} -o jsonpath='{.secrets[0].name}'`;
90
+ const tokenName = await exec(
91
+ `kubectl get serviceaccount --namespace ${namespace} ${serviceAccountName} -o jsonpath='{.secrets[0].name}'`
92
+ ).then((c: any) => c.stdout.trim());
84
93
 
85
- const KUBE_CA_PEM =
86
- await $`kubectl get secret ${tokenName} --namespace ${namespace} -o jsonpath="{['data']['ca\\.crt']}"`.then(
87
- (c) => c.stdout.trim()
88
- );
89
- const KUBE_TOKEN =
90
- await $`kubectl get secret ${tokenName} --namespace ${namespace} -o jsonpath="{['data']['token']}" | base64 --decode`.then(
91
- (c) => c.stdout.trim()
92
- );
94
+ const KUBE_CA_PEM = await exec(
95
+ `kubectl get secret ${tokenName} --namespace ${namespace} -o jsonpath="{['data']['ca\\.crt']}"`
96
+ ).then((c: any) => c.stdout.trim());
97
+ const KUBE_TOKEN = await exec(
98
+ `kubectl get secret ${tokenName} --namespace ${namespace} -o jsonpath="{['data']['token']}" | base64 --decode`
99
+ ).then((c: any) => c.stdout.trim());
93
100
 
94
101
  const vars = {
95
102
  KUBE_TOKEN,
@@ -1,5 +1,7 @@
1
- import { Context, getKubernetesNamespace } from "@catladder/pipeline";
2
- import { V1Namespace, V1ObjectMeta } from "@kubernetes/client-node";
1
+ import type { Context} from "@catladder/pipeline";
2
+ import { getKubernetesNamespace } from "@catladder/pipeline";
3
+ import type { V1ObjectMeta } from "@kubernetes/client-node";
4
+ import { V1Namespace } from "@kubernetes/client-node";
3
5
  import { getk8sApi } from "../../../../../k8sApi";
4
6
 
5
7
  export default async function (context: Context) {
@@ -1,4 +1,4 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import { getProjectConfig } from "../../../../../config/getProjectConfig";
3
3
 
4
4
  export const showProjectBanner = async (vorpal: Vorpal) => {
@@ -1,4 +1,4 @@
1
- import { DeployConfigKubernetesCluster } from "@catladder/pipeline";
1
+ import type { DeployConfigKubernetesCluster } from "@catladder/pipeline";
2
2
  import open from "open";
3
3
 
4
4
  export const openGoogleCloudLogs = async (
@@ -1,6 +1,6 @@
1
1
  import { spawn } from "child-process-promise";
2
2
  import fetch from "node-fetch";
3
- import Vorpal from "vorpal";
3
+ import type Vorpal from "vorpal";
4
4
 
5
5
  export default async (vorpal: Vorpal) => {
6
6
  vorpal.command("dadjoke", "something for jonas.").action(async function () {
@@ -1,9 +1,9 @@
1
- import { Config } from "@catladder/pipeline";
1
+ import type { Config } from "@catladder/pipeline";
2
2
  import { spawn, exec } from "child-process-promise";
3
3
  import { writeFile } from "fs-extra";
4
4
  import { dump } from "js-yaml";
5
5
  import { format } from "prettier";
6
- import { CommandInstance } from "vorpal";
6
+ import type { CommandInstance } from "vorpal";
7
7
  import { getGitRoot } from "../../../utils/projects";
8
8
 
9
9
  export const writeConfig = async (
@@ -1,4 +1,4 @@
1
- import Vorpal from "vorpal";
1
+ import type Vorpal from "vorpal";
2
2
  import {
3
3
  getGitlabCi,
4
4
  getProjectConfig,
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  BuildConfig,
3
3
  ComponentConfig,
4
4
  Config,
@@ -14,7 +14,7 @@ import {
14
14
  } from "fs-extra";
15
15
  import { isEmpty } from "lodash";
16
16
  import { join } from "path";
17
- import Vorpal from "vorpal";
17
+ import type Vorpal from "vorpal";
18
18
  import {
19
19
  getGitlabCi,
20
20
  getGitlabCiFilePath,
@@ -24,11 +24,8 @@ import { syncBitwarden } from "../../../../utils/passwordstore";
24
24
  import { getGitRoot } from "../../../../utils/projects";
25
25
  import { writeConfig } from "../../config/writeConfig";
26
26
  import { migrateSecrets } from "./migrateSecrets";
27
- import {
28
- detectBuildConfig,
29
- isOldInclude,
30
- OldGitlabCiFile,
31
- } from "./oldGitlabCi";
27
+ import type { OldGitlabCiFile } from "./oldGitlabCi";
28
+ import { detectBuildConfig, isOldInclude } from "./oldGitlabCi";
32
29
  export const LEGACY_ENVS = [
33
30
  "dev-local",
34
31
  "dev",
@@ -1,10 +1,11 @@
1
- import { Config, getEnvironment } from "@catladder/pipeline";
1
+ import type { Config } from "@catladder/pipeline";
2
+ import { getEnvironment } from "@catladder/pipeline";
2
3
  import { load } from "js-yaml";
3
4
  import { pick } from "lodash";
4
- import { CommandInstance } from "vorpal";
5
+ import type { CommandInstance } from "vorpal";
5
6
  import { upsertAllVariables } from "../../../../utils/gitlab";
6
7
  import { readPass, trashItem } from "../../../../utils/passwordstore";
7
- import { LEGACY_ENVS } from "./fromv2";
8
+ import type { LEGACY_ENVS } from "./fromv2";
8
9
 
9
10
  const getPassPath = (newConfig: Config, env: string) => {
10
11
  return `${newConfig.customerName}/${newConfig.appName}/${env}/secrets.yml`;
@@ -1,4 +1,4 @@
1
- import { BuildConfig } from "@catladder/pipeline";
1
+ import type { BuildConfig } from "@catladder/pipeline";
2
2
 
3
3
  export type OldGitlabCiFile = {
4
4
  variables: {
package/src/catenv.ts CHANGED
@@ -1,10 +1,9 @@
1
1
  import catenv from "./apps/catenv/catenv";
2
- import { $, argv } from "zx";
3
- import { parseChoice } from "./config/getProjectConfig";
4
2
 
5
- const choice = argv._[0] ? parseChoice(argv._[0]) : null;
3
+ import { parseChoice } from "./config/parseChoice";
4
+
5
+ const choice = process.argv[2] ? parseChoice(process.argv[2]) : null;
6
6
 
7
- $.verbose = false;
8
7
  catenv(choice).then(() => {
9
8
  // we have to exit manually, because we have some file watches
10
9
  process.exit();
package/src/cli.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import updateNotifier from "update-notifier";
2
2
  import cli from "./apps/cli/cli";
3
3
  import packageInfos from "./packageInfos";
4
- import { $ } from "zx";
5
- $.verbose = false;
4
+
6
5
  updateNotifier({
7
6
  pkg: packageInfos,
8
7
  }).notify();
@@ -1,19 +1,22 @@
1
+ import type {
2
+ Config} from "@catladder/pipeline";
1
3
  import {
2
4
  readConfigSync,
3
5
  getAllEnvs,
4
6
  getEnvironment as _getEnvironment,
5
7
  createContext,
6
- getSecretVarName,
7
- Config,
8
+ getSecretVarName
8
9
  } from "@catladder/pipeline";
9
10
 
10
- import { CommandInstance } from "vorpal";
11
+ import type { CommandInstance } from "vorpal";
11
12
  import { getAllVariables, getVariableValueByRawName } from "../utils/gitlab";
12
13
 
13
14
  import { getGitRoot } from "../utils/projects";
14
15
  import { readYaml } from "../utils/files";
15
16
  import { watch } from "fs";
16
17
 
18
+ export { parseChoice } from "./parseChoice";
19
+
17
20
  let currentConfig: Config = null;
18
21
 
19
22
  // reload the config on change
@@ -59,11 +62,6 @@ export const getProjectComponents = async () => {
59
62
  return Object.keys(config.components);
60
63
  };
61
64
 
62
- export const parseChoice = (envComponent: string) => {
63
- const [env, componentName] = envComponent.split(":").map((x) => x || null);
64
- return { env, componentName };
65
- };
66
-
67
65
  export const getPipelineContextByChoice = async (
68
66
  env: string,
69
67
  componentName: string
@@ -0,0 +1,4 @@
1
+ export const parseChoice = (envComponent: string) => {
2
+ const [env, componentName] = envComponent.split(":").map((x) => x || null);
3
+ return { env, componentName };
4
+ };
@@ -0,0 +1,27 @@
1
+ import { parseChoice } from "../config/parseChoice";
2
+ import { getk8sApi } from "../k8sApi";
3
+ import { getProjectNamespace } from "../utils/projects";
4
+
5
+ export const getProjectPods = async (envComponent: string) => {
6
+ const namespace = await getProjectNamespace(envComponent);
7
+ const k8sApi = getk8sApi();
8
+ const res = await k8sApi.listNamespacedPod(namespace);
9
+
10
+ const { componentName } = parseChoice(envComponent);
11
+ return res.body.items.filter((item) =>
12
+ componentName ? item.metadata?.name?.includes(componentName + "-") : true
13
+ );
14
+ };
15
+
16
+ export const getProjectPvcs = async (envComponent: string) => {
17
+ const namespace = await getProjectNamespace(envComponent);
18
+ const k8sApi = getk8sApi();
19
+ const res = await k8sApi.listNamespacedPersistentVolumeClaim(namespace);
20
+
21
+ return res.body.items;
22
+ };
23
+
24
+ export const getProjectPodNames = async (envComponent: string) => {
25
+ const pods = await getProjectPods(envComponent);
26
+ return pods.map((n) => n.metadata.name);
27
+ };
@@ -1,12 +1,12 @@
1
- import { $ } from "zx";
1
+ import { exec } from "child-process-promise";
2
2
 
3
3
  export const getCurrentContext = async () =>
4
- (await $`kubectl config current-context`).stdout.trim();
4
+ (await exec(`kubectl config current-context`)).stdout.trim();
5
5
 
6
6
  export const getCurrentConnectedClusterName = async () => {
7
7
  return await getCurrentContext();
8
8
  };
9
9
 
10
10
  export const connectToCluster = async (fullname: string) => {
11
- await $`kubectl config use-context ${fullname}`;
11
+ await exec(`kubectl config use-context ${fullname}`);
12
12
  };
@@ -4,7 +4,7 @@ import { has, isObject, times } from "lodash";
4
4
  import memoizee from "memoizee";
5
5
  import fetch from "node-fetch";
6
6
  import open from "open";
7
- import { CommandInstance } from "vorpal";
7
+ import type { CommandInstance } from "vorpal";
8
8
  import { getPreference, hasPreference, setPreference } from "./preferences";
9
9
 
10
10
  const TOKEN_KEY = "gitlab-personal-access-token";
@@ -90,9 +90,10 @@ export const getProjectInfo = async (
90
90
  const gitRemoteOriginUrl = (
91
91
  await exec("git config --get remote.origin.url")
92
92
  ).stdout.trim();
93
- const projectPath = /(https:\/\/|git@)git\.panter\.ch[:/](.*)\.git/g.exec(
94
- gitRemoteOriginUrl
95
- );
93
+ const projectPath =
94
+ /(https:\/\/|git@)git\.panter\.ch[:/]([^.]*)(\.git)?/g.exec(
95
+ gitRemoteOriginUrl
96
+ );
96
97
  const project = await doGitlabRequest(
97
98
  vorpal,
98
99
  `projects/${encodeURIComponent(projectPath[2])}`
@@ -1,11 +1,11 @@
1
- import { $ } from "zx";
2
1
  import { join } from "path";
3
2
  import { getProjectConfig, parseChoice } from "../../config/getProjectConfig";
4
- import { getk8sApi } from "../../k8sApi";
3
+
5
4
  import { readFileOrError } from "../files";
5
+ import { exec } from "child-process-promise";
6
6
 
7
7
  export const getGitRoot = async (): Promise<string> => {
8
- return (await $`git rev-parse --show-toplevel`).stdout.trim();
8
+ return (await exec(`git rev-parse --show-toplevel`)).stdout.trim();
9
9
  };
10
10
 
11
11
  export const getRootGitlabCiFile = async () => {
@@ -29,27 +29,3 @@ export const getProjectNamespace = async (envComponent: string) => {
29
29
  const config = await getProjectConfig();
30
30
  return `${config.customerName}-${config.appName}-${env}`;
31
31
  };
32
-
33
- export const getProjectPods = async (envComponent: string) => {
34
- const namespace = await getProjectNamespace(envComponent);
35
- const k8sApi = getk8sApi();
36
- const res = await k8sApi.listNamespacedPod(namespace);
37
-
38
- const { componentName } = parseChoice(envComponent);
39
- return res.body.items.filter((item) =>
40
- componentName ? item.metadata?.name?.includes(componentName + "-") : true
41
- );
42
- };
43
-
44
- export const getProjectPvcs = async (envComponent: string) => {
45
- const namespace = await getProjectNamespace(envComponent);
46
- const k8sApi = getk8sApi();
47
- const res = await k8sApi.listNamespacedPersistentVolumeClaim(namespace);
48
-
49
- return res.body.items;
50
- };
51
-
52
- export const getProjectPodNames = async (envComponent: string) => {
53
- const pods = await getProjectPods(envComponent);
54
- return pods.map((n) => n.metadata.name);
55
- };