@catladder/pipeline 1.153.1 → 1.154.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/artifacts/createBuildJobArtifact.d.ts +3 -0
  2. package/dist/build/artifacts/createBuildJobArtifact.js +97 -0
  3. package/dist/build/base/createAppBuildJob.d.ts +3 -3
  4. package/dist/build/base/createAppBuildJob.js +9 -15
  5. package/dist/build/base/index.d.ts +6 -2
  6. package/dist/build/base/index.js +14 -5
  7. package/dist/build/base/writeDotEnv.js +2 -1
  8. package/dist/build/custom/__tests__/testJob.test.js +1 -1
  9. package/dist/build/custom/buildJob.js +3 -10
  10. package/dist/build/docker.js +3 -3
  11. package/dist/build/index.d.ts +13 -6
  12. package/dist/build/index.js +29 -7
  13. package/dist/build/node/buildJob.d.ts +7 -2
  14. package/dist/build/node/buildJob.js +40 -33
  15. package/dist/build/node/cache.d.ts +2 -2
  16. package/dist/build/node/cache.js +8 -4
  17. package/dist/build/node/index.d.ts +2 -2
  18. package/dist/build/node/meteor.js +3 -6
  19. package/dist/build/node/testJob.d.ts +3 -2
  20. package/dist/build/node/testJob.js +9 -4
  21. package/dist/build/node/yarn.js +1 -1
  22. package/dist/build/rails/build.d.ts +1 -1
  23. package/dist/build/rails/build.js +7 -2
  24. package/dist/build/rails/test.d.ts +1 -1
  25. package/dist/build/rails/test.js +5 -0
  26. package/dist/build/sbom.js +3 -2
  27. package/dist/build/types.d.ts +48 -4
  28. package/dist/build/types.js +7 -1
  29. package/dist/bundles/catladder-gitlab/index.js +2 -2
  30. package/dist/constants.js +1 -1
  31. package/dist/context/createAllComponentsContext.d.ts +12 -0
  32. package/dist/context/createAllComponentsContext.js +159 -0
  33. package/dist/context/createComponentContext.d.ts +1 -5
  34. package/dist/context/createComponentContext.js +82 -20
  35. package/dist/context/createWorkspaceContext.d.ts +16 -0
  36. package/dist/context/createWorkspaceContext.js +173 -0
  37. package/dist/context/getBuildInfoVariables.d.ts +1 -1
  38. package/dist/context/getEnvironmentContext.d.ts +1 -1
  39. package/dist/context/getEnvironmentVariables.d.ts +2 -2
  40. package/dist/context/getEnvironmentVariables.js +5 -4
  41. package/dist/context/getLabels.js +4 -4
  42. package/dist/deploy/base/deploy.d.ts +1 -1
  43. package/dist/deploy/base/deploy.js +18 -5
  44. package/dist/deploy/cloudRun/artifactsRegistry.js +2 -2
  45. package/dist/deploy/cloudRun/createJobs/common.d.ts +4 -4
  46. package/dist/deploy/cloudRun/index.d.ts +2 -2
  47. package/dist/deploy/custom/index.d.ts +2 -2
  48. package/dist/deploy/dockerTag/index.d.ts +2 -2
  49. package/dist/deploy/index.d.ts +7 -7
  50. package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +3 -1
  51. package/dist/deploy/kubernetes/cloudSql/index.js +1 -1
  52. package/dist/deploy/kubernetes/deployJob.js +2 -2
  53. package/dist/deploy/kubernetes/index.d.ts +2 -2
  54. package/dist/deploy/sbom.d.ts +1 -1
  55. package/dist/deploy/sbom.js +4 -3
  56. package/dist/deploy/types/index.d.ts +3 -3
  57. package/dist/pipeline/createAllJobs.d.ts +12 -10
  58. package/dist/pipeline/createAllJobs.js +94 -51
  59. package/dist/pipeline/createJobsForComponent.js +2 -3
  60. package/dist/pipeline/createJobsForWorkspace.d.ts +3 -0
  61. package/dist/pipeline/createJobsForWorkspace.js +12 -0
  62. package/dist/pipeline/createMainPipeline.js +26 -6
  63. package/dist/pipeline/gitlab/createGitlabJobs.d.ts +3 -16
  64. package/dist/pipeline/gitlab/createGitlabJobs.js +191 -73
  65. package/dist/pipeline/packageManager.d.ts +3 -2
  66. package/dist/pipeline/packageManager.js +43 -15
  67. package/dist/tsconfig.tsbuildinfo +1 -1
  68. package/dist/types/config.d.ts +5 -4
  69. package/dist/types/context.d.ts +77 -12
  70. package/dist/types/context.js +10 -1
  71. package/dist/types/environmentContext.d.ts +5 -6
  72. package/dist/types/jobs.d.ts +5 -0
  73. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +8 -8
  74. package/examples/__snapshots__/cloud-run-meteor-with-worker.ts.snap +8 -0
  75. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +8 -8
  76. package/examples/__snapshots__/cloud-run-no-service.ts.snap +8 -8
  77. package/examples/__snapshots__/cloud-run-non-public.ts.snap +8 -8
  78. package/examples/__snapshots__/cloud-run-post-stop-job.ts.snap +8 -8
  79. package/examples/__snapshots__/cloud-run-service-gen2.ts.snap +8 -8
  80. package/examples/__snapshots__/cloud-run-service-increase-timout.ts.snap +8 -8
  81. package/examples/__snapshots__/cloud-run-service-with-volumes.ts.snap +8 -8
  82. package/examples/__snapshots__/cloud-run-storybook.ts.snap +4 -8
  83. package/examples/__snapshots__/cloud-run-with-ngnix.ts.snap +4 -8
  84. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +16 -16
  85. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +589 -1097
  86. package/examples/__snapshots__/cloud-run-with-worker.ts.snap +8 -8
  87. package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +4 -0
  88. package/examples/__snapshots__/custom-build-job.ts.snap +4 -0
  89. package/examples/__snapshots__/custom-deploy.ts.snap +8 -8
  90. package/examples/__snapshots__/custom-envs.ts.snap +18 -12
  91. package/examples/__snapshots__/custom-sbom-java.ts.snap +4 -0
  92. package/examples/__snapshots__/kubernetes-application-customization.ts.snap +8 -8
  93. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +8 -8
  94. package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +8 -8
  95. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +16 -16
  96. package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +8 -8
  97. package/examples/__snapshots__/local-dot-env.ts.snap +8 -8
  98. package/examples/__snapshots__/meteor-kubernetes.ts.snap +8 -0
  99. package/examples/__snapshots__/multiline-var.ts.snap +16 -16
  100. package/examples/__snapshots__/native-app.ts.snap +24 -16
  101. package/examples/__snapshots__/node-build-with-custom-image.ts.snap +8 -8
  102. package/examples/__snapshots__/node-build-with-docker-additions.ts.snap +8 -8
  103. package/examples/__snapshots__/wait-for-other-deploy.ts.snap +16 -16
  104. package/examples/cloud-run-with-sql.ts +9 -2
  105. package/package.json +1 -1
  106. package/src/build/artifacts/createBuildJobArtifact.ts +61 -0
  107. package/src/build/base/createAppBuildJob.ts +26 -22
  108. package/src/build/base/index.ts +31 -4
  109. package/src/build/base/writeDotEnv.ts +6 -2
  110. package/src/build/custom/__tests__/testJob.test.ts +4 -4
  111. package/src/build/custom/buildJob.ts +2 -13
  112. package/src/build/docker.ts +6 -7
  113. package/src/build/index.ts +39 -7
  114. package/src/build/node/buildJob.ts +68 -56
  115. package/src/build/node/cache.ts +17 -8
  116. package/src/build/node/index.ts +4 -2
  117. package/src/build/node/meteor.ts +3 -9
  118. package/src/build/node/testJob.ts +21 -7
  119. package/src/build/node/yarn.ts +2 -2
  120. package/src/build/rails/build.ts +14 -4
  121. package/src/build/rails/test.ts +9 -1
  122. package/src/build/sbom.ts +7 -2
  123. package/src/build/types.ts +68 -4
  124. package/src/context/createAllComponentsContext.ts +31 -0
  125. package/src/context/createComponentContext.ts +59 -20
  126. package/src/context/createWorkspaceContext.ts +56 -0
  127. package/src/context/getBuildInfoVariables.ts +2 -1
  128. package/src/context/getEnvironmentContext.ts +2 -2
  129. package/src/context/getEnvironmentVariables.ts +12 -6
  130. package/src/context/getLabels.ts +2 -2
  131. package/src/deploy/base/deploy.ts +33 -7
  132. package/src/deploy/cloudRun/artifactsRegistry.ts +2 -3
  133. package/src/deploy/cloudRun/createJobs/common.ts +4 -4
  134. package/src/deploy/cloudRun/index.ts +68 -67
  135. package/src/deploy/custom/index.ts +2 -2
  136. package/src/deploy/dockerTag/index.ts +8 -7
  137. package/src/deploy/index.ts +11 -9
  138. package/src/deploy/kubernetes/additionalSecretKeys.ts +3 -1
  139. package/src/deploy/kubernetes/cloudSql/index.ts +1 -1
  140. package/src/deploy/kubernetes/deployJob.ts +2 -2
  141. package/src/deploy/kubernetes/index.ts +42 -41
  142. package/src/deploy/sbom.ts +9 -4
  143. package/src/pipeline/createAllJobs.ts +56 -55
  144. package/src/pipeline/createChildPipeline.ts +1 -0
  145. package/src/pipeline/createJobsForComponent.ts +5 -4
  146. package/src/pipeline/createJobsForWorkspace.ts +12 -0
  147. package/src/pipeline/createMainPipeline.ts +38 -23
  148. package/src/pipeline/gitlab/createGitlabJobs.ts +283 -119
  149. package/src/pipeline/packageManager.ts +25 -9
  150. package/src/types/config.ts +4 -1
  151. package/src/types/context.ts +105 -11
  152. package/src/types/environmentContext.ts +6 -7
  153. package/src/types/jobs.ts +3 -1
@@ -1,12 +1,16 @@
1
1
  import type { StringOrBashExpression } from "../bash/BashExpression";
2
- import type { BuildConfig } from "../build";
2
+ import type {
3
+ BuildConfigFromWorkspace,
4
+ BuildConfigStandalone,
5
+ WorkspaceBuildConfig,
6
+ } from "../build";
3
7
  import type { PredefinedVariables, SecretEnvVar } from "../context";
4
8
  import type { DeployConfig } from "../deploy";
5
9
  import type {
6
- PipelineTrigger,
7
10
  ComponentConfig,
8
11
  Config,
9
12
  EnvType,
13
+ PipelineTrigger,
10
14
  } from "./config";
11
15
  import type { BaseStage, CatladderJob } from "./jobs";
12
16
  import type { PipelineType } from "./pipeline";
@@ -68,12 +72,15 @@ export type YarnWorkspace = {
68
72
  workspaceDependencies: string[];
69
73
  mismatchedWorkspaceDependencies: string[];
70
74
  };
71
- export type YarnPackageManagerInfoComponent = {
75
+ export type YarnPackageManagerInfoBase = {
72
76
  type: "yarn";
73
77
  version: string;
74
78
  workspaces: YarnWorkspace[];
75
- currentWorkspace?: YarnWorkspace;
76
79
  isClassic: boolean;
80
+ };
81
+
82
+ export type YarnPackageManagerInfoComponent = YarnPackageManagerInfoBase & {
83
+ currentWorkspace?: YarnWorkspace;
77
84
  componentIsInWorkspace: boolean;
78
85
  pathsToCopyInDocker: string[];
79
86
  currentWorkspaceDependencies: string[];
@@ -81,25 +88,80 @@ export type YarnPackageManagerInfoComponent = {
81
88
 
82
89
  export type PackageManagerInfoComponent = YarnPackageManagerInfoComponent;
83
90
 
91
+ /**
92
+ * not confuse with yarn workspaces
93
+ */
94
+ export type PackageManagerInfoBase = YarnPackageManagerInfoBase;
95
+
84
96
  export type ContextBeforeConfig = {
85
97
  componentName: string;
86
98
  fullConfig: Config;
87
99
  packageManagerInfo?: PackageManagerInfoComponent;
88
100
  };
89
101
 
90
- export type BuildContextComponent = {
102
+ export type BuildContextBase = {
103
+ /**
104
+ * the directory where the component or workspace is located
105
+ */
91
106
  dir: string;
107
+ /**
108
+ * directories of all components that are part of the build.
109
+ * In case of a standalone build, this is just the dir of the component + yarn workspace dependencies (if mode = all)
110
+ *
111
+ * in case of a workspace this contains all components in the workspace (+ yarn workspace dependencies if mode = all)
112
+ */
113
+ getComponentDirs: (mode: "direct" | "all") => string[];
114
+ };
92
115
 
93
- config: BuildConfig;
116
+ export type BuildContextComponentBase = BuildContextBase;
117
+
118
+ export type BuildContextStandalone<
119
+ C extends BuildConfigStandalone = BuildConfigStandalone,
120
+ > = BuildContextComponentBase & {
121
+ config: C;
122
+ type: "standalone";
123
+ buildType: C["type"];
94
124
  };
95
125
 
96
- export type BuildContext = BuildContextComponent;
126
+ export type BuildContextFromWorkspace = BuildContextComponentBase & {
127
+ config: BuildConfigFromWorkspace;
128
+ workspaceName: string;
129
+ buildType: WorkspaceBuildConfig["type"];
130
+ /**
131
+ * merged docker config
132
+ */
133
+ workspaceBuildConfig: WorkspaceBuildConfig;
134
+ type: "fromWorkspace";
135
+ };
136
+
137
+ export type BuildContextWorkspace = BuildContextBase & {
138
+ type: "workspace";
139
+ buildType: WorkspaceBuildConfig["type"];
140
+ config: WorkspaceBuildConfig;
141
+ };
142
+
143
+ export type BuildContextComponent =
144
+ | BuildContextStandalone
145
+ | BuildContextFromWorkspace;
146
+
147
+ export type BuildContext = BuildContextComponent | BuildContextWorkspace;
148
+
97
149
  export type DeployContext = {
98
150
  config: DeployConfig;
99
151
  };
100
- export type ComponentContext = {
101
- componentName: string;
152
+ export type ComponentContext<
153
+ BC extends BuildContextComponent = BuildContextComponent,
154
+ > = {
155
+ type: "component";
102
156
  env: string;
157
+ /**
158
+ * the name of the component
159
+ */
160
+ name: string;
161
+ /**
162
+ * @deprecated use name instead
163
+ */
164
+ componentName: string;
103
165
 
104
166
  /**
105
167
  * the merged component config.
@@ -108,7 +170,7 @@ export type ComponentContext = {
108
170
  *
109
171
  */
110
172
  componentConfig: ComponentConfig;
111
- build: BuildContextComponent;
173
+ build: BC;
112
174
  deploy?: DeployContext | null;
113
175
  fullConfig: Config;
114
176
  environment: Environment;
@@ -121,4 +183,36 @@ export type ComponentContext = {
121
183
  customJobs?: CatladderJob[];
122
184
  };
123
185
 
124
- export type Context = ComponentContext;
186
+ export type Context = ComponentContext | WorkspaceContext;
187
+
188
+ export type CatladderJobWithContext<S = BaseStage> = CatladderJob<S> & {
189
+ context: ComponentContext;
190
+ };
191
+
192
+ export const componentContextIsStandaloneBuild = (
193
+ context: ComponentContext<BuildContextComponent>,
194
+ ): context is ComponentContext<BuildContextStandalone> => {
195
+ return context.build.type === "standalone";
196
+ };
197
+
198
+ export const componentContextHasWorkspaceBuild = (
199
+ context: ComponentContext<BuildContextComponent>,
200
+ ): context is ComponentContext<BuildContextFromWorkspace> => {
201
+ return context.build.type === "fromWorkspace";
202
+ };
203
+
204
+ export type WorkspaceContext = {
205
+ type: "workspace";
206
+ /**
207
+ * the name of the workspace
208
+ */
209
+ name: string;
210
+ fullConfig: Config;
211
+ workspaceConfig: WorkspaceBuildConfig;
212
+ packageManagerInfo: PackageManagerInfoBase;
213
+ components: Array<ComponentContext>;
214
+ build: BuildContextWorkspace;
215
+ trigger: PipelineTrigger;
216
+ pipelineType: PipelineType;
217
+ env: string;
218
+ };
@@ -1,17 +1,16 @@
1
1
  import type { StringOrBashExpression } from "../bash/BashExpression";
2
- import type { BuildConfigGeneric, BuildConfigType } from "../build";
3
- import type { DeployConfigGeneric } from "../deploy";
4
- import type { DeployConfigType } from "../deploy";
2
+ import type { BuildConfig } from "../build";
3
+ import type { DeployConfig } from "../deploy";
5
4
  import type { Config, EnvConfigWithComponent, EnvType } from "./config";
6
5
  import type { PipelineType } from "./pipeline";
7
6
 
8
7
  export type EnvironmentContext<
9
- B extends BuildConfigType,
10
- D extends DeployConfigType,
8
+ B extends BuildConfig = BuildConfig,
9
+ D extends DeployConfig = DeployConfig,
11
10
  > = {
12
11
  envConfigRaw: EnvConfigWithComponent;
13
- buildConfigRaw: false | BuildConfigGeneric<B>;
14
- deployConfigRaw: false | DeployConfigGeneric<D>;
12
+ buildConfigRaw: false | B;
13
+ deployConfigRaw: false | D;
15
14
 
16
15
  env: string;
17
16
  envType: EnvType;
package/src/types/jobs.ts CHANGED
@@ -25,7 +25,8 @@ export type BaseStage = (typeof BASE_STAGES)[number];
25
25
 
26
26
  export type CatladderJobNeed =
27
27
  | string
28
- | { job: string; artifacts: boolean; componentName?: string };
28
+ | { job: string; artifacts: boolean; componentName?: string }
29
+ | { job: string; artifacts: boolean; workspaceName: string };
29
30
 
30
31
  export type CatladderJobEnvironmentConfig = {
31
32
  action?: GitlabEnvironment["action"];
@@ -61,6 +62,7 @@ export type CatladderJob<S = BaseStage> = {
61
62
  needsStages?: {
62
63
  stage: S;
63
64
  artifacts?: boolean;
65
+ workspaceName?: string;
64
66
  }[];
65
67
 
66
68
  /**