@catladder/pipeline 1.146.1 → 1.147.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 (153) hide show
  1. package/dist/build/base/createAppBuildJob.d.ts +2 -2
  2. package/dist/build/base/createAppBuildJob.js +6 -6
  3. package/dist/build/base/index.d.ts +2 -2
  4. package/dist/build/base/writeBuildInfo.d.ts +2 -2
  5. package/dist/build/base/writeBuildInfo.js +1 -1
  6. package/dist/build/base/writeDotEnv.d.ts +2 -2
  7. package/dist/build/base/writeDotEnv.js +1 -1
  8. package/dist/build/custom/__tests__/testJob.test.js +11 -14
  9. package/dist/build/custom/buildJob.d.ts +2 -2
  10. package/dist/build/custom/buildJob.js +5 -5
  11. package/dist/build/custom/index.d.ts +2 -2
  12. package/dist/build/custom/testJob.d.ts +2 -2
  13. package/dist/build/custom/testJob.js +5 -5
  14. package/dist/build/docker.d.ts +32 -15
  15. package/dist/build/docker.js +41 -20
  16. package/dist/build/index.d.ts +2 -2
  17. package/dist/build/node/buildJob.d.ts +2 -2
  18. package/dist/build/node/buildJob.js +8 -8
  19. package/dist/build/node/cache.d.ts +5 -5
  20. package/dist/build/node/cache.js +5 -5
  21. package/dist/build/node/index.d.ts +4 -4
  22. package/dist/build/node/meteor.d.ts +2 -2
  23. package/dist/build/node/meteor.js +6 -6
  24. package/dist/build/node/testJob.d.ts +2 -2
  25. package/dist/build/node/testJob.js +11 -11
  26. package/dist/build/node/yarn.d.ts +4 -4
  27. package/dist/build/node/yarn.js +1 -1
  28. package/dist/build/rails/build.d.ts +2 -2
  29. package/dist/build/rails/build.js +3 -3
  30. package/dist/build/rails/index.d.ts +2 -2
  31. package/dist/build/rails/test.d.ts +2 -2
  32. package/dist/build/rails/test.js +4 -4
  33. package/dist/build/sbom.d.ts +2 -2
  34. package/dist/build/sbom.js +2 -2
  35. package/dist/build/types.d.ts +34 -26
  36. package/dist/bundles/catladder-gitlab/index.js +2 -2
  37. package/dist/constants.js +1 -1
  38. package/dist/context/getEnvironment.d.ts +2 -2
  39. package/dist/context/getEnvironmentContext.d.ts +2 -2
  40. package/dist/context/getEnvironmentVariables.d.ts +4 -4
  41. package/dist/context/getLabels.d.ts +2 -2
  42. package/dist/context/getLabels.js +1 -1
  43. package/dist/context/index.d.ts +7 -3
  44. package/dist/context/index.js +43 -12
  45. package/dist/deploy/base/deploy.d.ts +2 -2
  46. package/dist/deploy/base/deploy.js +9 -8
  47. package/dist/deploy/base/index.d.ts +2 -2
  48. package/dist/deploy/base/rollback.d.ts +2 -2
  49. package/dist/deploy/base/stop.d.ts +2 -2
  50. package/dist/deploy/cloudRun/artifactsRegistry.d.ts +7 -11
  51. package/dist/deploy/cloudRun/artifactsRegistry.js +8 -9
  52. package/dist/deploy/cloudRun/cleanup.d.ts +2 -2
  53. package/dist/deploy/cloudRun/cloudRunRevisions.d.ts +2 -2
  54. package/dist/deploy/cloudRun/cloudRunRevisions.js +4 -5
  55. package/dist/deploy/cloudRun/createJobs/cloudRunJobs.d.ts +6 -6
  56. package/dist/deploy/cloudRun/createJobs/cloudRunServices.d.ts +3 -3
  57. package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +1 -1
  58. package/dist/deploy/cloudRun/createJobs/common.js +2 -1
  59. package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.d.ts +2 -2
  60. package/dist/deploy/cloudRun/createJobs/getCloudRunStopScripts.d.ts +2 -2
  61. package/dist/deploy/cloudRun/createJobs/index.d.ts +2 -2
  62. package/dist/deploy/cloudRun/createJobs/index.js +2 -4
  63. package/dist/deploy/cloudRun/utils/database.d.ts +3 -3
  64. package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.d.ts +2 -2
  65. package/dist/deploy/cloudRun/utils/getServiceName.d.ts +2 -2
  66. package/dist/deploy/custom/deployJob.d.ts +2 -2
  67. package/dist/deploy/custom/deployJob.js +7 -10
  68. package/dist/deploy/dockerTag/deployJob.d.ts +2 -2
  69. package/dist/deploy/dockerTag/deployJob.js +3 -5
  70. package/dist/deploy/index.d.ts +2 -2
  71. package/dist/deploy/kubernetes/cloudSql/index.d.ts +3 -3
  72. package/dist/deploy/kubernetes/cloudSql/index.js +11 -9
  73. package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
  74. package/dist/deploy/kubernetes/deployJob.js +4 -7
  75. package/dist/deploy/kubernetes/kubeEnv.d.ts +2 -2
  76. package/dist/deploy/kubernetes/kubeEnv.js +2 -1
  77. package/dist/deploy/kubernetes/kubeValues.d.ts +2 -2
  78. package/dist/deploy/kubernetes/kubeValues.js +10 -10
  79. package/dist/deploy/kubernetes/mongodb.d.ts +2 -2
  80. package/dist/deploy/kubernetes/mongodb.js +11 -11
  81. package/dist/deploy/sbom.d.ts +4 -4
  82. package/dist/deploy/sbom.js +1 -1
  83. package/dist/deploy/types/index.d.ts +1 -1
  84. package/dist/deploy/types/index.js +1 -1
  85. package/dist/deploy/utils.d.ts +2 -2
  86. package/dist/deploy/utils.js +2 -1
  87. package/dist/pipeline/createJobsForComponent.d.ts +2 -2
  88. package/dist/pipeline/createJobsForComponent.js +6 -6
  89. package/dist/tsconfig.tsbuildinfo +1 -1
  90. package/dist/types/config.d.ts +2 -2
  91. package/dist/types/context.d.ts +28 -2
  92. package/examples/__snapshots__/cloud-run-storybook.ts.snap +1687 -0
  93. package/examples/__snapshots__/cloud-run-with-ngnix.ts.snap +1971 -0
  94. package/examples/cloud-run-storybook.ts +24 -0
  95. package/examples/cloud-run-with-ngnix.ts +24 -0
  96. package/package.json +1 -1
  97. package/src/build/base/createAppBuildJob.ts +9 -9
  98. package/src/build/base/index.ts +2 -2
  99. package/src/build/base/writeBuildInfo.ts +3 -3
  100. package/src/build/base/writeDotEnv.ts +3 -3
  101. package/src/build/custom/__tests__/testJob.test.ts +8 -11
  102. package/src/build/custom/buildJob.ts +10 -11
  103. package/src/build/custom/index.ts +2 -2
  104. package/src/build/custom/testJob.ts +9 -7
  105. package/src/build/docker.ts +73 -29
  106. package/src/build/index.ts +2 -2
  107. package/src/build/node/buildJob.ts +19 -15
  108. package/src/build/node/cache.ts +10 -10
  109. package/src/build/node/index.ts +6 -4
  110. package/src/build/node/meteor.ts +16 -17
  111. package/src/build/node/testJob.ts +19 -16
  112. package/src/build/node/yarn.ts +6 -8
  113. package/src/build/rails/build.ts +7 -5
  114. package/src/build/rails/index.ts +2 -2
  115. package/src/build/rails/test.ts +8 -6
  116. package/src/build/sbom.ts +5 -5
  117. package/src/build/types.ts +53 -38
  118. package/src/context/getEnvironment.ts +2 -2
  119. package/src/context/getEnvironmentContext.ts +2 -2
  120. package/src/context/getEnvironmentVariables.ts +7 -4
  121. package/src/context/getLabels.ts +3 -3
  122. package/src/context/index.ts +33 -7
  123. package/src/deploy/base/deploy.ts +10 -16
  124. package/src/deploy/base/index.ts +2 -2
  125. package/src/deploy/base/rollback.ts +2 -2
  126. package/src/deploy/base/stop.ts +2 -2
  127. package/src/deploy/cloudRun/artifactsRegistry.ts +16 -16
  128. package/src/deploy/cloudRun/cleanup.ts +2 -2
  129. package/src/deploy/cloudRun/cloudRunRevisions.ts +6 -8
  130. package/src/deploy/cloudRun/createJobs/cloudRunJobs.ts +10 -10
  131. package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +4 -4
  132. package/src/deploy/cloudRun/createJobs/common.ts +1 -1
  133. package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +5 -2
  134. package/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.ts +2 -2
  135. package/src/deploy/cloudRun/createJobs/index.ts +3 -6
  136. package/src/deploy/cloudRun/utils/database.ts +3 -3
  137. package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +4 -2
  138. package/src/deploy/cloudRun/utils/getServiceName.ts +2 -2
  139. package/src/deploy/custom/deployJob.ts +10 -8
  140. package/src/deploy/dockerTag/deployJob.ts +6 -7
  141. package/src/deploy/index.ts +2 -2
  142. package/src/deploy/kubernetes/cloudSql/index.ts +10 -7
  143. package/src/deploy/kubernetes/deployJob.ts +3 -6
  144. package/src/deploy/kubernetes/kubeEnv.ts +3 -3
  145. package/src/deploy/kubernetes/kubeValues.ts +6 -6
  146. package/src/deploy/kubernetes/mongodb.ts +14 -14
  147. package/src/deploy/sbom.ts +9 -6
  148. package/src/deploy/types/index.ts +2 -2
  149. package/src/deploy/utils.ts +3 -3
  150. package/src/pipeline/createJobsForComponent.ts +17 -17
  151. package/src/pipeline/gitlab/createGitlabJobs.ts +2 -2
  152. package/src/types/config.ts +4 -2
  153. package/src/types/context.ts +33 -2
@@ -1,11 +1,11 @@
1
1
  import { join } from "path";
2
2
  import slugify from "slugify";
3
- import type { Context } from "../../types/context";
3
+ import type { BuildContext, ComponentContext } from "../../types/context";
4
4
  import type { GitlabJobCache } from "../../types/gitlab-types";
5
5
  import { uniq } from "lodash";
6
6
 
7
7
  export const getYarnCache = (
8
- context: Context,
8
+ context: BuildContext,
9
9
  policy = "pull-push",
10
10
  ): GitlabJobCache[] => {
11
11
  const componentIsInWorkspace =
@@ -18,15 +18,15 @@ export const getYarnCache = (
18
18
  paths: [".yarn"],
19
19
  }
20
20
  : {
21
- key: slugify(context.componentConfig.dir) + "-yarn",
21
+ key: slugify(context.dir) + "-yarn",
22
22
  policy,
23
- paths: [join(context.componentConfig.dir, ".yarn")],
23
+ paths: [join(context.dir, ".yarn")],
24
24
  },
25
25
  ];
26
26
  };
27
27
 
28
28
  export const getNodeModulesCache = (
29
- context: Context,
29
+ context: BuildContext,
30
30
  policy = "pull-push",
31
31
  ): GitlabJobCache[] => {
32
32
  const componentIsInWorkspace =
@@ -39,7 +39,7 @@ export const getNodeModulesCache = (
39
39
  // if component is in a shared workspace, use workspace cache. use individual cache else
40
40
  key: componentIsInWorkspace
41
41
  ? "node-modules-workspace"
42
- : slugify(context.componentConfig.dir) + "-node-modules", // we use the dirname, not the component name, because in certain cases we have two apps in the same directory and want to share the cache, e.g. when having storybook in the same package.json
42
+ : slugify(context.dir) + "-node-modules", // we use the dirname, not the component name, because in certain cases we have two apps in the same directory and want to share the cache, e.g. when having storybook in the same package.json
43
43
  policy,
44
44
  paths: [
45
45
  ...(componentIsInWorkspace
@@ -49,13 +49,13 @@ export const getNodeModulesCache = (
49
49
  join(w.location, "node_modules"),
50
50
  ) ?? []),
51
51
  ])
52
- : [join(context.componentConfig.dir, "node_modules")]),
52
+ : [join(context.dir, "node_modules")]),
53
53
  ],
54
54
  },
55
55
  ];
56
56
  };
57
57
  export const getNodeCache = (
58
- context: Context,
58
+ context: BuildContext,
59
59
  policy = "pull-push",
60
60
  ): GitlabJobCache[] => {
61
61
  return [
@@ -64,10 +64,10 @@ export const getNodeCache = (
64
64
  ];
65
65
  };
66
66
 
67
- export const getNextCache = (context: Context): GitlabJobCache[] => [
67
+ export const getNextCache = (context: ComponentContext): GitlabJobCache[] => [
68
68
  {
69
69
  key: context.componentName + "-next-cache",
70
70
  policy: "pull-push",
71
- paths: [context.componentConfig.dir + "/.next/cache/"],
71
+ paths: [context.build.dir + "/.next/cache/"],
72
72
  },
73
73
  ];
@@ -1,17 +1,19 @@
1
- import type { Context } from "../../types/context";
1
+ import type { ComponentContext } from "../../types/context";
2
2
  import type { CatladderJob } from "../../types/jobs";
3
3
  import { createNodeBuildJobs } from "./buildJob";
4
4
  import { createMeteorBuildJobs } from "./meteor";
5
5
  import { createNodeTestJobs } from "./testJob";
6
6
 
7
- export const createNodeJobs = (context: Context): CatladderJob[] => {
7
+ export const createNodeJobs = (context: ComponentContext): CatladderJob[] => {
8
8
  return [...createNodeTestJobs(context), ...createNodeBuildJobs(context)];
9
9
  };
10
10
 
11
- export const createStorybookJobs = (context: Context): CatladderJob[] => {
11
+ export const createStorybookJobs = (
12
+ context: ComponentContext,
13
+ ): CatladderJob[] => {
12
14
  return [...createNodeBuildJobs(context)];
13
15
  };
14
16
 
15
- export const createMeteorJobs = (context: Context): CatladderJob[] => {
17
+ export const createMeteorJobs = (context: ComponentContext): CatladderJob[] => {
16
18
  return [...createNodeTestJobs(context), ...createMeteorBuildJobs(context)];
17
19
  };
@@ -1,45 +1,44 @@
1
1
  import { join } from "path";
2
2
  import { getRunnerImage } from "../../runner";
3
3
  import type { GitlabJobCache } from "../../types";
4
- import type { Context } from "../../types/context";
4
+ import type { ComponentContext } from "../../types/context";
5
5
 
6
6
  import type { CatladderJob } from "../../types/jobs";
7
7
 
8
8
  import { createBuildJobs } from "../base";
9
- import { getDockerBuildDefaultScript } from "../docker";
9
+ import { getDockerBuildScriptWithBuiltInDockerFile } from "../docker";
10
10
  import { isOfBuildType } from "../types";
11
11
  import { getNodeCache } from "./cache";
12
12
  import { getYarnInstall } from "./yarn";
13
13
 
14
- const getMeteorCache = (context: Context): GitlabJobCache[] => [
14
+ const getMeteorCache = (context: ComponentContext): GitlabJobCache[] => [
15
15
  {
16
16
  key: context.componentName + "meteor-build-cache",
17
17
  policy: "pull-push",
18
18
  paths: [
19
- join(
20
- context.componentConfig.dir,
21
- ".meteor/local/resolver-result-cache.json",
22
- ),
23
- join(context.componentConfig.dir, ".meteor/local/plugin-cache"),
24
- join(context.componentConfig.dir, ".meteor/local/isopacks"),
25
- join(context.componentConfig.dir, ".meteor/local/bundler-cache/scanner"),
19
+ join(context.build.dir, ".meteor/local/resolver-result-cache.json"),
20
+ join(context.build.dir, ".meteor/local/plugin-cache"),
21
+ join(context.build.dir, ".meteor/local/isopacks"),
22
+ join(context.build.dir, ".meteor/local/bundler-cache/scanner"),
26
23
  ],
27
24
  },
28
25
  ];
29
- export const createMeteorBuildJobs = (context: Context): CatladderJob[] => {
30
- const buildConfig = context.componentConfig.build;
26
+ export const createMeteorBuildJobs = (
27
+ context: ComponentContext,
28
+ ): CatladderJob[] => {
29
+ const buildConfig = context.build.config;
31
30
 
32
31
  if (!isOfBuildType(buildConfig, "meteor")) {
33
32
  throw new Error("deploy config is not meteor");
34
33
  }
35
34
 
36
- const yarnInstall = getYarnInstall(context);
35
+ const yarnInstall = getYarnInstall(context.build);
37
36
 
38
37
  return createBuildJobs(context, {
39
38
  appBuild:
40
39
  buildConfig.buildCommand !== null
41
40
  ? {
42
- cache: [...getNodeCache(context), ...getMeteorCache(context)],
41
+ cache: [...getNodeCache(context.build), ...getMeteorCache(context)],
43
42
  image: getRunnerImage("jobs-meteor"),
44
43
  variables: {
45
44
  METEOR_DISABLE_OPTIMISTIC_CACHING: "1", // see https://forums.meteor.com/t/veeery-long-building-time-inside-docker-container/58673/17?u=macrozone
@@ -57,14 +56,14 @@ export const createMeteorBuildJobs = (context: Context): CatladderJob[] => {
57
56
  ],
58
57
  artifacts: {
59
58
  paths: [
60
- context.componentConfig.dir + "/__build_info.json",
61
- context.componentConfig.dir + "/dist",
59
+ context.build.dir + "/__build_info.json",
60
+ context.build.dir + "/dist",
62
61
  ],
63
62
  },
64
63
  }
65
64
  : undefined,
66
65
  dockerBuild: {
67
- script: getDockerBuildDefaultScript(context, "ensureMeteorDockerfile"),
66
+ script: getDockerBuildScriptWithBuiltInDockerFile(context, "meteor"),
68
67
  variables: {
69
68
  METEOR_INSTALL_SCRIPTS: buildConfig.installScripts ? "true" : "",
70
69
  },
@@ -1,5 +1,5 @@
1
1
  import { getRunnerImage } from "../../runner";
2
- import type { Context } from "../../types/context";
2
+ import type { ComponentContext } from "../../types/context";
3
3
  import type { CatladderJob } from "../../types/jobs";
4
4
  import { ensureArray, notNil } from "../../utils";
5
5
  import { getNodeCache } from "./cache";
@@ -7,18 +7,21 @@ import { NODE_RUNNER_BUILD_VARIABLES } from "./constants";
7
7
  import { ensureNodeVersion, getYarnInstall } from "./yarn";
8
8
  import { createArtifactsConfig } from "../base/createArtifactsConfig";
9
9
 
10
- export const createNodeTestJobs = (context: Context): CatladderJob[] => {
10
+ export const createNodeTestJobs = (
11
+ context: ComponentContext,
12
+ ): CatladderJob[] => {
11
13
  // don't run tests after release
12
14
  // TODO: this will be replaced by using rules
13
15
  if (context.trigger === "taggedRelease") {
14
16
  return [];
15
17
  }
16
18
 
17
- const buildConfig = context.componentConfig.build;
19
+ const buildConfig = context.build.config;
20
+
18
21
  const defaultImage = getRunnerImage("jobs-default");
19
22
  const base: Omit<CatladderJob, "script" | "name"> = {
20
23
  variables: {
21
- APP_PATH: context.componentConfig.dir,
24
+ APP_PATH: context.build.dir,
22
25
  ...context.environment.jobOnlyVars.build.envVars,
23
26
  ...(buildConfig.extraVars ?? {}),
24
27
  },
@@ -27,7 +30,7 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
27
30
  needs: [],
28
31
  envMode: "none",
29
32
  };
30
- const yarnInstall = getYarnInstall(context);
33
+ const yarnInstall = getYarnInstall(context.build);
31
34
  const auditJob: CatladderJob | null =
32
35
  buildConfig.audit !== false
33
36
  ? {
@@ -36,16 +39,16 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
36
39
  image: buildConfig.audit?.jobImage ?? defaultImage,
37
40
  cache: undefined, // audit does not need yarn install and no cache
38
41
  script: [
39
- `cd ${context.componentConfig.dir}`,
42
+ `cd ${context.build.dir}`,
40
43
  ...(ensureArray(buildConfig.audit?.command) ?? [
41
- context.packageManagerInfo?.isClassic
44
+ context.build.packageManagerInfo?.isClassic
42
45
  ? "yarn audit"
43
46
  : "yarn npm audit --environment production", // yarn 2
44
47
  ]),
45
48
  ],
46
49
  allow_failure: true,
47
50
  ...createArtifactsConfig(
48
- context.componentConfig.dir,
51
+ context.build.dir,
49
52
  buildConfig.audit?.artifactsReports,
50
53
  buildConfig.audit?.artifacts,
51
54
  ),
@@ -58,15 +61,15 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
58
61
  name: "👮 lint",
59
62
  ...base,
60
63
  image: buildConfig.lint?.jobImage ?? defaultImage,
61
- cache: getNodeCache(context),
64
+ cache: getNodeCache(context.build),
62
65
  script: [
63
- ...ensureNodeVersion(context),
64
- `cd ${context.componentConfig.dir}`,
66
+ ...ensureNodeVersion(context.build),
67
+ `cd ${context.build.dir}`,
65
68
  ...yarnInstall,
66
69
  ...(ensureArray(buildConfig.lint?.command) ?? ["yarn lint"]),
67
70
  ],
68
71
  ...createArtifactsConfig(
69
- context.componentConfig.dir,
72
+ context.build.dir,
70
73
  buildConfig.lint?.artifactsReports,
71
74
  buildConfig.lint?.artifacts,
72
75
  ),
@@ -80,15 +83,15 @@ export const createNodeTestJobs = (context: Context): CatladderJob[] => {
80
83
  ...base,
81
84
  image:
82
85
  buildConfig.test?.jobImage ?? getRunnerImage("jobs-testing-chrome"),
83
- cache: getNodeCache(context),
86
+ cache: getNodeCache(context.build),
84
87
  script: [
85
- ...ensureNodeVersion(context),
86
- `cd ${context.componentConfig.dir}`,
88
+ ...ensureNodeVersion(context.build),
89
+ `cd ${context.build.dir}`,
87
90
  ...yarnInstall,
88
91
  ...(ensureArray(buildConfig.test?.command) ?? ["yarn test"]),
89
92
  ],
90
93
  ...createArtifactsConfig(
91
- context.componentConfig.dir,
94
+ context.build.dir,
92
95
  buildConfig.test?.artifactsReports,
93
96
  buildConfig.test?.artifacts,
94
97
  ),
@@ -1,5 +1,5 @@
1
1
  import { BashExpression } from "../../bash/BashExpression";
2
- import type { Context } from "../../types";
2
+ import type { BuildContext, ComponentContext } from "../../types";
3
3
  import { ensureArray } from "../../utils";
4
4
  import { collapseableSection } from "../../utils/gitlab";
5
5
 
@@ -8,7 +8,7 @@ const YARN_INSTALL_CLASSIC = `yarn install --frozen-lockfile`;
8
8
  // FIXME: check why and when rebuild is needed
9
9
  const YARN_BERRY_PROD_REBUILD = `yarn workspaces focus --production && yarn rebuild`;
10
10
 
11
- const getYarnInstallCommand = (context: Context) => {
11
+ const getYarnInstallCommand = (context: BuildContext) => {
12
12
  if (context.packageManagerInfo?.isClassic) {
13
13
  return YARN_INSTALL_CLASSIC;
14
14
  }
@@ -16,7 +16,7 @@ const getYarnInstallCommand = (context: Context) => {
16
16
  return `yarn install --immutable`;
17
17
  };
18
18
 
19
- export const ensureNodeVersion = (context: Context) =>
19
+ export const ensureNodeVersion = (context: BuildContext) =>
20
20
  collapseableSection(
21
21
  "nodeinstall",
22
22
  "Ensure node version",
@@ -26,15 +26,13 @@ export const ensureNodeVersion = (context: Context) =>
26
26
  ]);
27
27
 
28
28
  export const getYarnInstall = (
29
- context: Context,
29
+ context: BuildContext,
30
30
  options?: {
31
31
  noCustomPostInstall: boolean;
32
32
  },
33
33
  ) => {
34
34
  const postInstall =
35
- "postInstall" in context.componentConfig.build
36
- ? context.componentConfig.build.postInstall
37
- : null;
35
+ "postInstall" in context.config ? context.config.postInstall : null;
38
36
  return [
39
37
  ...ensureNodeVersion(context),
40
38
  ...collapseableSection(
@@ -52,7 +50,7 @@ export const getYarnInstall = (
52
50
 
53
51
  const DOCKER_COPY_FILES = `COPY --chown=node:node $APP_DIR .`;
54
52
 
55
- export const getDockerAppCopyAndBuildScript = (context: Context) => {
53
+ export const getDockerAppCopyAndBuildScript = (context: BuildContext) => {
56
54
  if (context.packageManagerInfo?.isClassic) {
57
55
  return new BashExpression(
58
56
  `
@@ -1,4 +1,4 @@
1
- import type { Context } from "../..";
1
+ import type { ComponentContext } from "../..";
2
2
  import type { CatladderJob } from "../../types/jobs";
3
3
  import { createBuildJobs } from "../base";
4
4
  import {
@@ -8,8 +8,10 @@ import {
8
8
  } from "../docker";
9
9
  import { isOfBuildType } from "../types";
10
10
 
11
- export const createRailsBuildJobs = (context: Context): CatladderJob[] => {
12
- const buildConfig = context.componentConfig.build;
11
+ export const createRailsBuildJobs = (
12
+ context: ComponentContext,
13
+ ): CatladderJob[] => {
14
+ const buildConfig = context.build.config;
13
15
  if (!isOfBuildType(buildConfig, "rails")) {
14
16
  // should not happen
15
17
  throw new Error("build type is not rails");
@@ -35,12 +37,12 @@ export const createRailsBuildJobs = (context: Context): CatladderJob[] => {
35
37
  dockerBuild: {
36
38
  variables: {
37
39
  ...context.environment.jobOnlyVars.build.envVars,
38
- ...context.componentConfig.build.extraVars,
40
+ ...context.build.config.extraVars,
39
41
  },
40
42
  // custom script
41
43
  script: [
42
44
  ...gitlabDockerLogin(context),
43
- `cd ${context.componentConfig.dir}`,
45
+ `cd ${context.build.dir}`,
44
46
  `docker pull $DOCKER_CACHE_IMAGE || true`,
45
47
  `wget --output-document=- https://github.com/buildpacks/pack/releases/download/v${cnbConf?.packVersion}/pack-v${cnbConf?.packVersion}-linux.tgz | tar -zx --directory /usr/local/bin pack`,
46
48
  `chmod +x /usr/local/bin/pack`,
@@ -1,8 +1,8 @@
1
- import type { Context } from "../../types";
1
+ import type { ComponentContext } from "../../types";
2
2
  import type { CatladderJob } from "../../types/jobs";
3
3
  import { createRailsBuildJobs } from "./build";
4
4
  import { createRailsTestJobs } from "./test";
5
5
 
6
- export const createRailsJobs = (context: Context): CatladderJob[] => {
6
+ export const createRailsJobs = (context: ComponentContext): CatladderJob[] => {
7
7
  return [...createRailsTestJobs(context), ...createRailsBuildJobs(context)];
8
8
  };
@@ -1,15 +1,17 @@
1
- import type { Context } from "../..";
1
+ import type { ComponentContext } from "../..";
2
2
  import type { CatladderJob } from "../../types/jobs";
3
3
  import { ensureArray, notNil } from "../../utils";
4
4
 
5
- export const createRailsTestJobs = (context: Context): CatladderJob[] => {
5
+ export const createRailsTestJobs = (
6
+ context: ComponentContext,
7
+ ): CatladderJob[] => {
6
8
  // don't run tests after release
7
9
  // TODO: this will be replaced by using rules
8
10
  if (context.trigger === "taggedRelease") {
9
11
  return [];
10
12
  }
11
13
 
12
- const buildConfig = context.componentConfig.build;
14
+ const buildConfig = context.build.config;
13
15
 
14
16
  const base: Omit<CatladderJob, "script" | "name"> = {
15
17
  variables: {
@@ -43,7 +45,7 @@ export const createRailsTestJobs = (context: Context): CatladderJob[] => {
43
45
  image:
44
46
  buildConfig.audit?.jobImage ?? buildConfig.jobImage ?? defaultImage,
45
47
  script: [
46
- `cd ${context.componentConfig.dir}`,
48
+ `cd ${context.build.dir}`,
47
49
  ...(ensureArray(buildConfig.audit?.command) ?? [
48
50
  "gem install bundler-audit",
49
51
  "bundle audit check",
@@ -63,7 +65,7 @@ export const createRailsTestJobs = (context: Context): CatladderJob[] => {
63
65
  image:
64
66
  buildConfig.lint?.jobImage ?? buildConfig.jobImage ?? defaultImage,
65
67
  script: [
66
- `cd ${context.componentConfig.dir}`,
68
+ `cd ${context.build.dir}`,
67
69
  ...bundlerInstall,
68
70
  ...(ensureArray(buildConfig.lint?.command) ?? [
69
71
  "bundle exec rubocop",
@@ -81,7 +83,7 @@ export const createRailsTestJobs = (context: Context): CatladderJob[] => {
81
83
  image:
82
84
  buildConfig.test?.jobImage ?? buildConfig.jobImage ?? defaultImage,
83
85
  script: [
84
- `cd ${context.componentConfig.dir}`,
86
+ `cd ${context.build.dir}`,
85
87
  ...bundlerInstall,
86
88
  ...(ensureArray(buildConfig.test?.command) ?? [
87
89
  "bundle exec rspec",
package/src/build/sbom.ts CHANGED
@@ -1,19 +1,19 @@
1
- import type { Context } from "../types/context";
1
+ import type { ComponentContext } from "../types/context";
2
2
  import type { CatladderJob } from "../types/jobs";
3
3
  import { ensureArray } from "../utils";
4
4
 
5
5
  export const SBOM_BUILD_JOB_NAME = "🧾 sbom";
6
6
  export const SBOM_FILE = "__sbom.json";
7
7
 
8
- export const createSbomBuildJob = (context: Context): CatladderJob => {
9
- const buildConfig = context.componentConfig.build;
8
+ export const createSbomBuildJob = (context: ComponentContext): CatladderJob => {
9
+ const buildConfig = context.build.config;
10
10
 
11
11
  const defaultImage = "aquasec/trivy:0.38.3";
12
12
  const defaultScript = [
13
13
  `trivy fs --quiet --format cyclonedx --output "${SBOM_FILE}" ${
14
- context.packageManagerInfo?.componentIsInWorkspace
14
+ context.build.packageManagerInfo?.componentIsInWorkspace
15
15
  ? "."
16
- : context.componentConfig.dir
16
+ : context.build.dir
17
17
  }`,
18
18
  ];
19
19
 
@@ -58,28 +58,6 @@ export type BuildConfigBase = {
58
58
  */
59
59
  buildCommand?: string | string[] | null;
60
60
 
61
- /**
62
- * customize docker build
63
- */
64
- docker?: {
65
- /**
66
- * Custom Dockerfile lines integrated in the generated Dockerfile before the standard build steps.
67
- *
68
- * - [runner-images/docker-build/scripts/ensureNodeDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureNodeDockerfile)
69
- * - [runner-images/docker-build/scripts/ensureNginxDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureNginxDockerfile)
70
- * - [runner-images/docker-build/scripts/ensureMeteorDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureMeteorDockerfile)
71
- */
72
- additionsBegin?: string[];
73
- /**
74
- * Custom Dockerfile lines integrated in the generated Dockerfile after the standard build steps.
75
- *
76
- * - [runner-images/docker-build/scripts/ensureNodeDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureNodeDockerfile)
77
- * - [runner-images/docker-build/scripts/ensureNginxDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureNginxDockerfile)
78
- * - [runner-images/docker-build/scripts/ensureMeteorDockerfile](https://git.panter.ch/catladder/catladder/-/tree/main/runner-images/docker-build/scripts/ensureMeteorDockerfile)
79
- */
80
- additionsEnd?: string[];
81
- };
82
-
83
61
  /**
84
62
  * customize lint, set false to disable
85
63
  */
@@ -132,11 +110,13 @@ export type BuildConfigNodeBase = BuildConfigBase & {
132
110
 
133
111
  export type BuildConfigNode = {
134
112
  type: "node";
113
+ docker?: Omit<BuildConfigDockerBuiltInNode, "type"> | BuildConfigDocker;
135
114
  } & BuildConfigNodeBase;
136
115
 
137
116
  export type BuildConfigNodeStatic = BuildConfigNodeBase & {
138
117
  type: "node-static";
139
118
  startCommand?: never;
119
+ docker?: Omit<BuildConfigDockerBuiltInNgninx, "type"> | BuildConfigDocker;
140
120
  };
141
121
 
142
122
  export type BuildConfigMeteor = BuildConfigNodeBase & {
@@ -146,23 +126,58 @@ export type BuildConfigMeteor = BuildConfigNodeBase & {
146
126
  * This is only required if you have custom scripts in your image
147
127
  */
148
128
  installScripts?: boolean;
129
+ docker?: Omit<BuildConfigDockerBuiltInMeteor, "type"> | BuildConfigDocker;
149
130
  };
150
131
 
151
- export type BuildConfigCustomDocker = BuildConfigBase["docker"] &
152
- (
153
- | {
154
- /**
155
- * use the built-in nginx image for simple static apps
156
- */
157
- type: "nginx";
158
- }
159
- | {
160
- /**
161
- * custom docker build, expect that a Dockerfile in your directory
162
- */
163
- type: "custom";
164
- }
165
- );
132
+ type BuildConfigDockerWithAdditions = {
133
+ /**
134
+ * Custom Dockerfile lines integrated in the generated Dockerfile before the standard build steps.
135
+ *
136
+ */
137
+ additionsBegin?: string[];
138
+ /**
139
+ * Custom Dockerfile lines integrated in the generated Dockerfile after the standard build steps.
140
+ *
141
+ */
142
+ additionsEnd?: string[];
143
+ };
144
+
145
+ type BuildConfigDockerBuiltInNode = {
146
+ type: "node";
147
+ } & BuildConfigDockerWithAdditions;
148
+
149
+ type BuildConfigDockerBuiltInMeteor = {
150
+ type: "meteor";
151
+ } & BuildConfigDockerWithAdditions;
152
+
153
+ type BuildConfigDockerBuiltInNgninx = {
154
+ /**
155
+ * use the built-in nginx image for simple static apps
156
+ */
157
+ type: "nginx";
158
+ } & BuildConfigDockerWithAdditions;
159
+ type BuildConfigDockerBuiltIn =
160
+ | BuildConfigDockerBuiltInNgninx
161
+ | BuildConfigDockerBuiltInNode
162
+ | BuildConfigDockerBuiltInMeteor;
163
+
164
+ type BuildConfigDockerCustom = {
165
+ /**
166
+ * custom docker build, expect that a Dockerfile in your directory
167
+ */
168
+ type: "custom";
169
+ };
170
+
171
+ export type BuildConfigDocker =
172
+ | BuildConfigDockerBuiltIn
173
+ | BuildConfigDockerCustom;
174
+
175
+ /**
176
+ * @deprecated this type is no longer used. Use {@link BuildConfigDocker} instead.
177
+ */
178
+ export type BuildConfigCustomDocker =
179
+ | BuildConfigDockerCustom
180
+ | BuildConfigDockerBuiltInNgninx;
166
181
 
167
182
  export type BuildConfigCustom = Omit<
168
183
  BuildConfigBase,
@@ -175,7 +190,7 @@ export type BuildConfigCustom = Omit<
175
190
  */
176
191
  jobServices?: Services;
177
192
 
178
- docker: BuildConfigCustomDocker;
193
+ docker: BuildConfigDocker;
179
194
 
180
195
  /**
181
196
  * custom lint, disabled when not set
@@ -1,11 +1,11 @@
1
- import type { CreateContextContext } from "..";
1
+ import type { CreateComponentContextContext } from "..";
2
2
 
3
3
  import type { Environment } from "../types/context";
4
4
  import { getEnvironmentContext } from "./getEnvironmentContext";
5
5
  import { getEnvironmentVariables } from "./getEnvironmentVariables";
6
6
 
7
7
  export const getEnvironment = async (
8
- ctx: CreateContextContext,
8
+ ctx: CreateComponentContextContext,
9
9
  ): Promise<Environment> => {
10
10
  const { env } = ctx;
11
11
  const variables = await getEnvironmentVariables(ctx);
@@ -1,4 +1,4 @@
1
- import type { CreateContextContext } from "..";
1
+ import type { CreateComponentContextContext } from "..";
2
2
  import type { StringOrBashExpression } from "../bash/BashExpression";
3
3
  import { joinBashExpressions } from "../bash/BashExpression";
4
4
 
@@ -22,7 +22,7 @@ export const getEnvironmentContext = ({
22
22
  componentName,
23
23
  config,
24
24
  pipelineType,
25
- }: CreateContextContext): EnvironmentContext<any, any> => {
25
+ }: CreateComponentContextContext): EnvironmentContext<any, any> => {
26
26
  const envConfigRaw = getEnvConfig(config, componentName, env);
27
27
  const envType = getEnvType(env, envConfigRaw);
28
28
  const reviewSlug = getReviewSlug(envConfigRaw, env, pipelineType);
@@ -1,12 +1,12 @@
1
1
  import { merge } from "lodash";
2
2
  import { DEPLOY_TYPES } from "../deploy";
3
3
  import type {
4
- Context,
4
+ ComponentContext,
5
5
  EnvironmentEnvVarPart as EnvironmentVariables,
6
6
  } from "../types";
7
7
  import type { DevLocalEnvConfig } from "../types/config";
8
8
 
9
- import type { CreateContextContext, UnspecifiedEnvVars } from "..";
9
+ import type { CreateComponentContextContext, UnspecifiedEnvVars } from "..";
10
10
  import type { StringOrBashExpression } from "../bash/BashExpression";
11
11
  import { getBashVariable, joinBashExpressions } from "../bash/BashExpression";
12
12
  import type { EnvironmentContext } from "../types/environmentContext";
@@ -52,7 +52,7 @@ export type PredefinedVariables = BasePredefinedVariables & {
52
52
  };
53
53
 
54
54
  export const getEnvironmentVariables = async (
55
- ctx: CreateContextContext,
55
+ ctx: CreateComponentContextContext,
56
56
  alreadyVisited: Record<string, Record<string, boolean>> = {}, // to prevent endless loop
57
57
  ): Promise<EnvironmentVariables> => {
58
58
  const environmentContext = getEnvironmentContext(ctx);
@@ -198,5 +198,8 @@ const addIndexVar = <V extends Record<string, unknown>>(
198
198
  _ALL_ENV_VAR_KEYS: JSON.stringify(Object.keys(vars)),
199
199
  });
200
200
 
201
- export const getSecretVarNameForContext = (context: Context, key: string) =>
201
+ export const getSecretVarNameForContext = (
202
+ context: ComponentContext,
203
+ key: string,
204
+ ) =>
202
205
  getSecretVarName(context.environment.shortName, context.componentName, key);
@@ -1,5 +1,5 @@
1
1
  import slugify from "slugify";
2
- import type { Context } from "../types";
2
+ import type { ComponentContext } from "../types";
3
3
 
4
4
  const sanitize = (value?: string) => {
5
5
  if (!value) return value;
@@ -7,14 +7,14 @@ const sanitize = (value?: string) => {
7
7
  // slugify should do the job
8
8
  return slugify(value).toLowerCase();
9
9
  };
10
- export const getLabels = (context: Context) => {
10
+ export const getLabels = (context: ComponentContext) => {
11
11
  const labels = {
12
12
  "customer-name": sanitize(context.fullConfig.customerName),
13
13
  "component-name": sanitize(context.componentName),
14
14
  "app-name": sanitize(context.fullConfig.appName),
15
15
  "env-type": sanitize(context.environment.envType),
16
16
  "env-name": sanitize(context.environment.shortName),
17
- "build-type": sanitize(context.componentConfig.build?.type),
17
+ "build-type": sanitize(context.build.config?.type),
18
18
  ...(context.fullConfig.meta?.labels ?? {}),
19
19
  };
20
20
  return labels;