@catladder/cli 3.17.1 → 3.19.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 (46) hide show
  1. package/dist/bundles/catenv/index.js +2 -2
  2. package/dist/bundles/cli/index.js +1 -1
  3. package/dist/cli/src/apps/catenv/catenv.js +5 -4
  4. package/dist/cli/src/apps/catenv/catenv.js.map +1 -1
  5. package/dist/cli/src/apps/catenv/printVariables.d.ts +2 -2
  6. package/dist/cli/src/apps/catenv/printVariables.js +2 -2
  7. package/dist/cli/src/apps/catenv/printVariables.js.map +1 -1
  8. package/dist/cli/src/apps/catenv/writeDotEnvFiles.d.ts +2 -2
  9. package/dist/cli/src/apps/catenv/writeDotEnvFiles.js +5 -6
  10. package/dist/cli/src/apps/catenv/writeDotEnvFiles.js.map +1 -1
  11. package/dist/cli/src/apps/catenv/writeEnvDTs.d.ts +2 -2
  12. package/dist/cli/src/apps/catenv/writeEnvDTs.js +5 -6
  13. package/dist/cli/src/apps/catenv/writeEnvDTs.js.map +1 -1
  14. package/dist/cli/src/apps/cli/commands/project/setup/index.js +6 -3
  15. package/dist/cli/src/apps/cli/commands/project/setup/index.js.map +1 -1
  16. package/dist/cli/src/apps/cli/commands/project/setup/logSection.d.ts +2 -0
  17. package/dist/cli/src/apps/cli/commands/project/setup/logSection.js +17 -0
  18. package/dist/cli/src/apps/cli/commands/project/setup/logSection.js.map +1 -0
  19. package/dist/cli/src/apps/cli/commands/project/setup/setupContext.js +11 -15
  20. package/dist/cli/src/apps/cli/commands/project/setup/setupContext.js.map +1 -1
  21. package/dist/pipeline/src/catenv/index.d.ts +7 -0
  22. package/dist/pipeline/src/catenv/index.js +12 -0
  23. package/dist/pipeline/src/catenv/index.js.map +1 -0
  24. package/dist/pipeline/src/index.d.ts +1 -0
  25. package/dist/pipeline/src/index.js +1 -0
  26. package/dist/pipeline/src/index.js.map +1 -1
  27. package/dist/pipeline/src/pipeline/generatePipelineFiles.d.ts +2 -1
  28. package/dist/pipeline/src/pipeline/generatePipelineFiles.js +3 -4
  29. package/dist/pipeline/src/pipeline/generatePipelineFiles.js.map +1 -1
  30. package/dist/pipeline/src/types/config.d.ts +5 -0
  31. package/dist/pipeline/src/types/config.js.map +1 -1
  32. package/dist/pipeline/src/types/hooks.d.ts +26 -0
  33. package/dist/pipeline/src/types/hooks.js +3 -0
  34. package/dist/pipeline/src/types/hooks.js.map +1 -0
  35. package/dist/pipeline/src/utils/writeFiles.d.ts +12 -4
  36. package/dist/pipeline/src/utils/writeFiles.js +42 -27
  37. package/dist/pipeline/src/utils/writeFiles.js.map +1 -1
  38. package/dist/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +1 -1
  40. package/src/apps/catenv/catenv.ts +11 -5
  41. package/src/apps/catenv/printVariables.ts +6 -3
  42. package/src/apps/catenv/writeDotEnvFiles.ts +21 -8
  43. package/src/apps/catenv/writeEnvDTs.ts +15 -6
  44. package/src/apps/cli/commands/project/setup/index.ts +8 -3
  45. package/src/apps/cli/commands/project/setup/logSection.ts +22 -0
  46. package/src/apps/cli/commands/project/setup/setupContext.ts +14 -19
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "3.17.1",
56
+ "version": "3.19.0",
57
57
  "scripts": {
58
58
  "lint": "eslint \"src/**/*.ts\"",
59
59
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
@@ -3,7 +3,11 @@ import { printVariables } from "./printVariables";
3
3
  import type { Choice } from "./types";
4
4
  import { writeDotEnvFiles } from "./writeDotEnvFiles";
5
5
  import { writeDTsFiles } from "./writeEnvDTs";
6
- import { generatePipelineFiles } from "@catladder/pipeline";
6
+ import {
7
+ FileWriter,
8
+ createCatenvContext,
9
+ generatePipelineFiles,
10
+ } from "@catladder/pipeline";
7
11
 
8
12
  export default async (choice?: Choice) => {
9
13
  const config = await getProjectConfig();
@@ -11,12 +15,14 @@ export default async (choice?: Choice) => {
11
15
  return;
12
16
  }
13
17
 
18
+ const context = createCatenvContext(config);
19
+
14
20
  await Promise.all([
15
- generatePipelineFiles(config, config.pipelineType ?? "gitlab"),
16
- writeDotEnvFiles(config, choice),
21
+ generatePipelineFiles(context, config.pipelineType ?? "gitlab"),
22
+ writeDotEnvFiles(context, choice),
17
23
 
18
- writeDTsFiles(config, choice),
24
+ writeDTsFiles(context, choice),
19
25
 
20
- printVariables(config, choice),
26
+ printVariables(context, choice),
21
27
  ]);
22
28
  };
@@ -1,4 +1,4 @@
1
- import type { Config } from "@catladder/pipeline";
1
+ import type { CatenvContext, Config } from "@catladder/pipeline";
2
2
  import { getEnvVarsResolved } from "../../config/getProjectConfig";
3
3
  import type { Choice } from "./types";
4
4
  import {
@@ -48,8 +48,11 @@ const getAllVariablesToPrint = async (config: Config, choice?: Choice) => {
48
48
  }
49
49
  };
50
50
 
51
- export const printVariables = async (config: Config, choice?: Choice) => {
52
- const variables = await getAllVariablesToPrint(config, choice);
51
+ export const printVariables = async (
52
+ context: CatenvContext,
53
+ choice?: Choice,
54
+ ) => {
55
+ const variables = await getAllVariablesToPrint(context.config, choice);
53
56
 
54
57
  console.log(makeExportKeyValuestring(variables));
55
58
  };
@@ -1,4 +1,3 @@
1
- import { writeGeneratedFile, type Config } from "@catladder/pipeline";
2
1
  import { join } from "path";
3
2
  import { getEnvVarsResolved } from "../../config/getProjectConfig";
4
3
  import { getGitRoot } from "../../utils/projects";
@@ -8,14 +7,20 @@ import {
8
7
  getCurrentComponentAndEnvFromChoice,
9
8
  makeKeyValueString,
10
9
  } from "./utils";
10
+ import type { CatenvContext } from "@catladder/pipeline";
11
11
 
12
- export const writeDotEnvFiles = async (config: Config, choice?: Choice) => {
12
+ export const writeDotEnvFiles = async (
13
+ context: CatenvContext,
14
+ choice?: Choice,
15
+ ) => {
13
16
  const { env, currentComponent } = await getCurrentComponentAndEnvFromChoice(
14
- config,
17
+ context.config,
15
18
  choice,
16
19
  );
17
20
 
18
- const componentsWithEnabledDotEnvWrite = Object.entries(config.components)
21
+ const componentsWithEnabledDotEnvWrite = Object.entries(
22
+ context.config.components,
23
+ )
19
24
  .filter(([, component]) => component?.dotEnv ?? true) // when set to true or "local"
20
25
  .map(([componentName]) => componentName);
21
26
 
@@ -29,11 +34,19 @@ export const writeDotEnvFiles = async (config: Config, choice?: Choice) => {
29
34
  for (const componentName of componentsToActuallyWriteDotEnvNow) {
30
35
  const variables = await getEnvVarsResolved(null, env, componentName);
31
36
  delete variables["_ALL_ENV_VAR_KEYS"];
32
- const componentDir = getComponentFullPath(gitRoot, config, componentName);
37
+ const componentDir = getComponentFullPath(
38
+ gitRoot,
39
+ context.config,
40
+ componentName,
41
+ );
33
42
  const filePath = join(componentDir, ".env");
34
43
 
35
- await writeGeneratedFile(filePath, makeKeyValueString(variables), {
36
- commentChar: "#",
37
- });
44
+ await context.fileWriter.writeGeneratedFile(
45
+ filePath,
46
+ makeKeyValueString(variables),
47
+ {
48
+ commentChar: "#",
49
+ },
50
+ );
38
51
  }
39
52
  };
@@ -1,4 +1,4 @@
1
- import { writeGeneratedFile, type Config } from "@catladder/pipeline";
1
+ import type { CatenvContext } from "@catladder/pipeline";
2
2
  import { join } from "path";
3
3
  import { getEnvironment } from "../../config/getProjectConfig";
4
4
  import { getGitRoot } from "../../utils/projects";
@@ -8,13 +8,18 @@ import {
8
8
  getCurrentComponentAndEnvFromChoice,
9
9
  } from "./utils";
10
10
 
11
- export const writeDTsFiles = async (config: Config, choice?: Choice) => {
11
+ export const writeDTsFiles = async (
12
+ context: CatenvContext,
13
+ choice?: Choice,
14
+ ) => {
12
15
  const { env, currentComponent } = await getCurrentComponentAndEnvFromChoice(
13
- config,
16
+ context.config,
14
17
  choice,
15
18
  );
16
19
 
17
- const componentsWithEnabledEnvDTsWrite = Object.entries(config.components)
20
+ const componentsWithEnabledEnvDTsWrite = Object.entries(
21
+ context.config.components,
22
+ )
18
23
  .filter(([, component]) => component?.envDTs ?? true)
19
24
  .map(([componentName]) => componentName);
20
25
 
@@ -29,9 +34,13 @@ export const writeDTsFiles = async (config: Config, choice?: Choice) => {
29
34
  const envNames = await getEnvsForDTs(env, componentName);
30
35
  const envDTsContent = createEnvDTsContent(envNames);
31
36
 
32
- const componentDir = getComponentFullPath(gitRoot, config, componentName);
37
+ const componentDir = getComponentFullPath(
38
+ gitRoot,
39
+ context.config,
40
+ componentName,
41
+ );
33
42
  const filePath = join(componentDir, "env.d.ts");
34
- await writeGeneratedFile(filePath, envDTsContent, {
43
+ await context.fileWriter.writeGeneratedFile(filePath, envDTsContent, {
35
44
  commentChar: "//",
36
45
  });
37
46
  }
@@ -4,6 +4,7 @@ import { setupAccessTokens } from "./setupAccessTokens";
4
4
  import { setupContext } from "./setupContext";
5
5
  import { setupTopic } from "./setupTopic";
6
6
  import { setupAgents } from "./setupAgents";
7
+ import { logSection } from "./logSection";
7
8
 
8
9
  export const setupProject = async (
9
10
  instance: CommandInstance,
@@ -14,12 +15,16 @@ export const setupProject = async (
14
15
  allContext.forEach((context) => {
15
16
  instance.log(` - ${context.name}:${context.env}`);
16
17
  });
18
+
19
+ await logSection(instance, "base setup", async () => {
20
+ await setupAccessTokens(instance);
21
+ await setupTopic(instance);
22
+ await setupAgents(instance);
23
+ });
17
24
  for (const context of allContext) {
18
25
  await setupContext(instance, context);
19
26
  }
20
- await setupAccessTokens(instance);
21
- await setupTopic(instance);
22
- await setupAgents(instance);
27
+
23
28
  instance.log("");
24
29
  instance.log("gitlab is ready! 🥂");
25
30
  instance.log("\n");
@@ -0,0 +1,22 @@
1
+ import type { CommandInstance } from "vorpal";
2
+
3
+ export const logSection = async (
4
+ instance: CommandInstance,
5
+ title: string,
6
+ work: () => Promise<void>,
7
+ ) => {
8
+ instance.log("");
9
+ instance.log(
10
+ "==================================================================================",
11
+ );
12
+ instance.log("🐱 🔧 " + title + "...");
13
+ instance.log("");
14
+ await work();
15
+ instance.log("");
16
+ instance.log("✅ " + title + " done!");
17
+ instance.log("");
18
+ instance.log(
19
+ "==================================================================================",
20
+ );
21
+ instance.log("");
22
+ };
@@ -4,29 +4,24 @@ import type { CommandInstance } from "vorpal";
4
4
  import { setupCloudRun } from "./setupCloudRun";
5
5
 
6
6
  import { setupKubernetes } from "./setupKubernetes";
7
+ import { logSection } from "./logSection";
7
8
 
8
9
  export const setupContext = async (
9
10
  instance: CommandInstance,
10
11
  context: ComponentContext,
11
12
  ) => {
12
- instance.log("");
13
- instance.log(
14
- "==================================================================================",
15
- );
16
-
17
- instance.log("🐱 🔧 setting up " + context.env + ":" + context.name + "...");
18
- instance.log("");
19
- if (isOfDeployType(context.deploy?.config, "google-cloudrun")) {
20
- await setupCloudRun(instance, context);
21
- }
22
-
23
- const deployConfig = context.deploy?.config;
24
- if (isOfDeployType(deployConfig, "kubernetes")) {
25
- await setupKubernetes(instance, context);
26
- }
13
+ await logSection(
14
+ instance,
15
+ "setting up " + context.env + ":" + context.name,
16
+ async () => {
17
+ if (isOfDeployType(context.deploy?.config, "google-cloudrun")) {
18
+ await setupCloudRun(instance, context);
19
+ }
27
20
 
28
- instance.log("");
29
- instance.log("✅ " + context.env + ":" + context.name + " done!");
30
-
31
- instance.log("");
21
+ const deployConfig = context.deploy?.config;
22
+ if (isOfDeployType(deployConfig, "kubernetes")) {
23
+ await setupKubernetes(instance, context);
24
+ }
25
+ },
26
+ );
32
27
  };