@catladder/cli 1.4.5 → 1.5.3

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/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "catladder": "./bin/catladder"
17
17
  },
18
18
  "dependencies": {
19
- "@catladder/pipeline": "1.4.5",
19
+ "@catladder/pipeline": "1.5.3",
20
20
  "@kubernetes/client-node": "^0.16.2",
21
21
  "child-process-promise": "^2.2.1",
22
22
  "command-exists-promise": "^2.0.2",
@@ -29,6 +29,7 @@
29
29
  "memoizee": "^0.4.14",
30
30
  "node-fetch": "^2.3.0",
31
31
  "open": "^8.4.0",
32
+ "prettier": "^2.5.1",
32
33
  "tmp-promise": "^2.0.2",
33
34
  "update-notifier": "^2.5.0",
34
35
  "vorpal": "^1.12.0",
@@ -54,5 +55,5 @@
54
55
  "eslint": "^8.7.0",
55
56
  "typescript": "^4.5.4"
56
57
  },
57
- "version": "1.4.5"
58
+ "version": "1.5.3"
58
59
  }
@@ -24,8 +24,10 @@ export const openGoogleCloudKubernetesDashboard = async (
24
24
  googleAuthUserNumber = 0
25
25
  ) => {
26
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))
27
29
 
28
- const pageState = `pageState=("savedViews":("c":["gke/${cluster.region}/${cluster.name}"],"n":["${namespace}"],"i":"4e42e0b9cd6147f8a4fba7516752ec48"))`;
30
+ const pageState = `("savedViews":("c":["gke/${cluster.region}/${cluster.name}"],"n":["${namespace}"],"i":"4e42e0b9cd6147f8a4fba7516752ec48"))`;
29
31
  const url = `https://console.cloud.google.com/kubernetes/workload?authuser=${googleAuthUserNumber}&project=${
30
32
  cluster.projectId
31
33
  }&pageState=${encodeURIComponent(pageState)}`;
@@ -4,7 +4,7 @@ import {
4
4
  getProjectConfig,
5
5
  } from "../../../config/getProjectConfig";
6
6
  import { hasGitlabToken, setupGitlabToken } from "../../../utils/gitlab";
7
- import { migrateV2 } from "./migration/fromv2";
7
+ import { isV2, migrateV2 } from "./migration/fromv2";
8
8
 
9
9
  export const verify = async (vorpal: Vorpal) => {
10
10
  // check if has all settings
@@ -20,11 +20,7 @@ export const verify = async (vorpal: Vorpal) => {
20
20
  try {
21
21
  const gitlabCi = getGitlabCi();
22
22
 
23
- if (!gitlabCi) {
24
- vorpal.log("not initialized");
25
- }
26
-
27
- if (!projectConfig) {
23
+ if (gitlabCi && !projectConfig && (await isV2())) {
28
24
  vorpal.log("no project config, needs migration");
29
25
  await migrateV2(vorpal);
30
26
  }
@@ -24,7 +24,11 @@ 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 { detectBuildConfig, OldGitlabCiFile } from "./oldGitlabCi";
27
+ import {
28
+ detectBuildConfig,
29
+ isOldInclude,
30
+ OldGitlabCiFile,
31
+ } from "./oldGitlabCi";
28
32
  export const LEGACY_ENVS = [
29
33
  "dev-local",
30
34
  "dev",
@@ -78,6 +82,11 @@ const transformValues = (
78
82
  cronjobs: arrayToRecord(valuesIn?.cronjobs),
79
83
  };
80
84
  };
85
+
86
+ export const isV2 = async () => {
87
+ const gitlabCi = await getGitlabCi<OldGitlabCiFile>();
88
+ return isOldInclude(gitlabCi);
89
+ };
81
90
  export const migrateV2 = async (vorpal: Vorpal) => {
82
91
  const gitlabCi = await getGitlabCi<OldGitlabCiFile>();
83
92
  const gitRoot = await getGitRoot();
@@ -121,13 +130,14 @@ export const migrateV2 = async (vorpal: Vorpal) => {
121
130
  name: "shouldContinue",
122
131
  type: "confirm",
123
132
  });
124
- vorpal.log("");
125
- vorpal.log("");
126
- vorpal.log("💪😼 ok, let's go...");
127
- vorpal.log("");
128
- vorpal.log("");
129
133
 
130
134
  if (shouldContinue) {
135
+ vorpal.log("");
136
+ vorpal.log("");
137
+ vorpal.log("💪😼 ok, let's go...");
138
+ vorpal.log("");
139
+ vorpal.log("");
140
+
131
141
  const createComponent = async (
132
142
  dir: string,
133
143
  ciFile: OldGitlabCiFile
@@ -239,6 +249,10 @@ export const migrateV2 = async (vorpal: Vorpal) => {
239
249
  this.log("done!");
240
250
 
241
251
  this.log("-------------------");
252
+ } else {
253
+ this.log(
254
+ "☝ if you want to use catladder in legacy mode, install @panter/catladder globally and invoke catladder-legacy"
255
+ );
242
256
  }
243
257
  });
244
258
 
@@ -16,14 +16,19 @@ export type OldGitlabCiFile = {
16
16
  }[];
17
17
  };
18
18
 
19
+ export const isOldInclude = (gitlabCi: OldGitlabCiFile) => {
20
+ return gitlabCi.include[0]?.project === "catladder/gitlab-ci";
21
+ };
22
+
19
23
  export const detectBuildConfig = (
20
24
  gitlabCi: OldGitlabCiFile
21
25
  ): BuildConfig["type"] | "monorepo" => {
22
- const firstInclude = gitlabCi.include[0];
23
- if (!firstInclude || gitlabCi.include[0]?.project !== "catladder/gitlab-ci") {
26
+ if (!isOldInclude(gitlabCi)) {
24
27
  throw new Error("unsupported gitlab-ci file");
25
28
  }
26
29
 
30
+ const firstInclude = gitlabCi.include[0];
31
+
27
32
  if (firstInclude.file === "monorepo.yml") return "monorepo";
28
33
 
29
34
  if (firstInclude.file === "node-kubernetes.yml") {