@catladder/cli 3.18.0 → 3.20.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 (47) 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/pipeline/src/catenv/index.d.ts +7 -0
  15. package/dist/pipeline/src/catenv/index.js +12 -0
  16. package/dist/pipeline/src/catenv/index.js.map +1 -0
  17. package/dist/pipeline/src/index.d.ts +1 -0
  18. package/dist/pipeline/src/index.js +1 -0
  19. package/dist/pipeline/src/index.js.map +1 -1
  20. package/dist/pipeline/src/pipeline/createMainPipeline.js +1 -1
  21. package/dist/pipeline/src/pipeline/createMainPipeline.js.map +1 -1
  22. package/dist/pipeline/src/pipeline/generatePipelineFiles.d.ts +2 -1
  23. package/dist/pipeline/src/pipeline/generatePipelineFiles.js +3 -4
  24. package/dist/pipeline/src/pipeline/generatePipelineFiles.js.map +1 -1
  25. package/dist/pipeline/src/pipeline/gitlab/gitlabReleaseJobs.d.ts +2 -1
  26. package/dist/pipeline/src/pipeline/gitlab/gitlabReleaseJobs.js +29 -3
  27. package/dist/pipeline/src/pipeline/gitlab/gitlabReleaseJobs.js.map +1 -1
  28. package/dist/pipeline/src/rules/index.d.ts +0 -2
  29. package/dist/pipeline/src/rules/index.js +1 -31
  30. package/dist/pipeline/src/rules/index.js.map +1 -1
  31. package/dist/pipeline/src/types/config.d.ts +10 -0
  32. package/dist/pipeline/src/types/config.js.map +1 -1
  33. package/dist/pipeline/src/types/hooks.d.ts +26 -0
  34. package/dist/pipeline/src/types/hooks.js +3 -0
  35. package/dist/pipeline/src/types/hooks.js.map +1 -0
  36. package/dist/pipeline/src/types/release.d.ts +7 -0
  37. package/dist/pipeline/src/types/release.js +3 -0
  38. package/dist/pipeline/src/types/release.js.map +1 -0
  39. package/dist/pipeline/src/utils/writeFiles.d.ts +12 -4
  40. package/dist/pipeline/src/utils/writeFiles.js +42 -27
  41. package/dist/pipeline/src/utils/writeFiles.js.map +1 -1
  42. package/dist/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +1 -1
  44. package/src/apps/catenv/catenv.ts +11 -5
  45. package/src/apps/catenv/printVariables.ts +6 -3
  46. package/src/apps/catenv/writeDotEnvFiles.ts +21 -8
  47. package/src/apps/catenv/writeEnvDTs.ts +15 -6
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "3.18.0",
56
+ "version": "3.20.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
  }