@catladder/cli 1.4.3 → 1.5.1

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.3",
19
+ "@catladder/pipeline": "1.5.1",
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.3"
58
+ "version": "1.5.1"
58
59
  }
@@ -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",
@@ -69,7 +73,7 @@ const transformValues = (
69
73
  if (isEmpty(valuesIn)) {
70
74
  return undefined;
71
75
  }
72
- delete valuesIn?.application?.hostname;
76
+ delete valuesIn?.application?.host;
73
77
  delete valuesIn?.application?.command;
74
78
 
75
79
  return {
@@ -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
@@ -167,12 +177,12 @@ export const migrateV2 = async (vorpal: Vorpal) => {
167
177
  const envValues =
168
178
  (await readYaml(dir + `/values-${envName}.yml`)) ?? {};
169
179
  const { env, ...rest } = envValues;
170
- const hostname = rest?.application?.hostname;
180
+ const host = rest?.application?.host;
171
181
  const values = transformValues(rest);
172
182
  return {
173
183
  ...(await acc),
174
184
  [newEnvName]: {
175
- hostname: hostname,
185
+ host: host,
176
186
  vars: env ? transformVars(env) : undefined,
177
187
  deploy: values
178
188
  ? {
@@ -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") {