@catladder/pipeline 1.150.1 → 1.150.3

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 (34) hide show
  1. package/dist/build/base/createAppBuildJob.js +1 -1
  2. package/dist/build/node/buildJob.js +6 -6
  3. package/dist/build/node/cache.d.ts +4 -4
  4. package/dist/build/node/cache.js +5 -5
  5. package/dist/build/node/meteor.js +2 -2
  6. package/dist/build/node/testJob.js +6 -6
  7. package/dist/build/node/yarn.d.ts +4 -4
  8. package/dist/build/node/yarn.js +1 -1
  9. package/dist/build/sbom.js +1 -1
  10. package/dist/bundles/catladder-gitlab/index.js +1 -1
  11. package/dist/constants.js +1 -1
  12. package/dist/context/createComponentContext.js +1 -1
  13. package/dist/deploy/custom/deployJob.js +1 -1
  14. package/dist/pipeline/createAllJobs.d.ts +6 -6
  15. package/dist/pipeline/createAllJobs.js +7 -24
  16. package/dist/pipeline/createMainPipeline.js +2 -2
  17. package/dist/pipeline/gitlab/createGitlabJobs.d.ts +5 -6
  18. package/dist/pipeline/gitlab/createGitlabJobs.js +31 -29
  19. package/dist/tsconfig.tsbuildinfo +1 -1
  20. package/dist/types/context.d.ts +3 -12
  21. package/package.json +1 -1
  22. package/src/build/base/createAppBuildJob.ts +1 -1
  23. package/src/build/node/buildJob.ts +7 -9
  24. package/src/build/node/cache.ts +9 -9
  25. package/src/build/node/meteor.ts +2 -2
  26. package/src/build/node/testJob.ts +6 -6
  27. package/src/build/node/yarn.ts +8 -6
  28. package/src/build/sbom.ts +1 -1
  29. package/src/context/createComponentContext.ts +1 -1
  30. package/src/deploy/custom/deployJob.ts +1 -1
  31. package/src/pipeline/createAllJobs.ts +9 -19
  32. package/src/pipeline/createMainPipeline.ts +6 -2
  33. package/src/pipeline/gitlab/createGitlabJobs.ts +47 -46
  34. package/src/types/context.ts +3 -11
package/dist/constants.js CHANGED
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
7
- exports.PIPELINE_IMAGE_TAG = "v1-150-1-76b8c1d7" || "latest";
7
+ exports.PIPELINE_IMAGE_TAG = "v1-150-3-6b689f25" || "latest";
8
8
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";
@@ -165,9 +165,9 @@ var createComponentContext = function (ctx) {
165
165
  context = {
166
166
  fullConfig: ctx.config,
167
167
  componentConfig: componentConfig,
168
+ env: ctx.env,
168
169
  build: {
169
170
  dir: dir,
170
- packageManagerInfo: packageManagerInfo,
171
171
  config: build
172
172
  },
173
173
  deploy: deploy ? {
@@ -48,7 +48,7 @@ var createCustomDeployJobs = function (context) {
48
48
  throw new Error("deploy config is not custom");
49
49
  }
50
50
  // FIXME: custom deploy currently assumes yarn-based project
51
- var yarnInstall = (0, yarn_1.getYarnInstall)(context.build, {
51
+ var yarnInstall = (0, yarn_1.getYarnInstall)(context, {
52
52
  noCustomPostInstall: true
53
53
  });
54
54
  return (0, base_1.createDeployementJobs)(context, {
@@ -1,9 +1,9 @@
1
- import type { CatladderJobWithContext, Config, PipelineTrigger, PipelineType } from "../types";
2
- export type AllCatladderJobs = {
3
- [componentName: string]: {
4
- [env: string]: Array<CatladderJobWithContext>;
5
- };
6
- };
1
+ import type { ComponentContext, Config, PipelineTrigger, PipelineType } from "../types";
2
+ import type { CatladderJob } from "../types/jobs";
3
+ export type AllCatladderJobs = Array<{
4
+ context: ComponentContext;
5
+ jobs: Array<CatladderJob>;
6
+ }>;
7
7
  export type AllJobsContext = {
8
8
  config: Config;
9
9
  trigger: PipelineTrigger;
@@ -1,15 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var __assign = this && this.__assign || function () {
4
- __assign = Object.assign || function (t) {
5
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6
- s = arguments[i];
7
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
3
  var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
14
4
  function adopt(value) {
15
5
  return value instanceof P ? value : new P(function (resolve) {
@@ -189,20 +179,13 @@ var createAllJobs = function (_a) {
189
179
  })];
190
180
  case 1:
191
181
  allComponentContext = _c.sent();
192
- return [2 /*return*/, allComponentContext.reduce(function (acc, _a) {
193
- var componentName = _a.componentName,
194
- env = _a.env,
195
- context = _a.context;
196
- if (!acc[componentName]) {
197
- acc[componentName] = {};
198
- }
199
- acc[componentName][env] = (0, createJobsForComponent_1.createJobsForComponentContext)(context).map(function (job) {
200
- return __assign(__assign({}, job), {
201
- context: context
202
- });
203
- });
204
- return acc;
205
- }, {})];
182
+ return [2 /*return*/, allComponentContext.map(function (_a) {
183
+ var context = _a.context;
184
+ return {
185
+ context: context,
186
+ jobs: (0, createJobsForComponent_1.createJobsForComponentContext)(context)
187
+ };
188
+ })];
206
189
  }
207
190
  });
208
191
  });
@@ -203,10 +203,10 @@ var createMainPipeline = function (pipelineType, config) {
203
203
  .sort(function (a, b) {
204
204
  var componentNames = Object.keys(config.components);
205
205
  var aIndex = componentNames.findIndex(function (c) {
206
- return c === a.componentName;
206
+ return c === a.context.componentName;
207
207
  });
208
208
  var bIndex = componentNames.findIndex(function (c) {
209
- return c === b.componentName;
209
+ return c === b.context.componentName;
210
210
  });
211
211
  return aIndex - bIndex;
212
212
  }).reduce(function (acc, _a) {
@@ -1,13 +1,13 @@
1
- import type { CatladderJobWithContext, GitlabJobDef, GitlabRule } from "../../types";
1
+ import type { ComponentContext, GitlabJobDef, GitlabRule } from "../../types";
2
+ import type { CatladderJob } from "../../types/jobs";
2
3
  import type { AllCatladderJobs } from "../createAllJobs";
3
4
  export type AllGitlabJobs = {
4
5
  name: string;
5
6
  gitlabJob: GitlabJobDef;
6
- componentName: string;
7
- env: string;
7
+ context: ComponentContext;
8
8
  }[];
9
9
  export declare const GITLAB_ENVIRONMENT_URL_VARIABLE = "CL_GITLAB_ENVIRONMENT_URL";
10
- export declare const makeGitlabJob: (componentName: string, env: string, {
10
+ export declare const makeGitlabJob: (context: ComponentContext, {
11
11
  environment,
12
12
  envMode,
13
13
  needsStages,
@@ -16,10 +16,9 @@ export declare const makeGitlabJob: (componentName: string, env: string, {
16
16
  needs,
17
17
  jobTags,
18
18
  script,
19
- context,
20
19
  variables,
21
20
  runnerVariables,
22
21
  when,
23
22
  ...job
24
- }: CatladderJobWithContext<string>, allJobs: AllCatladderJobs, baseRules?: GitlabRule[]) => [fullName: string, job: GitlabJobDef];
23
+ }: CatladderJob<string>, allJobs: AllCatladderJobs, baseRules?: GitlabRule[]) => [fullName: string, job: GitlabJobDef];
25
24
  export declare const createGitlabJobs: (allJobs: AllCatladderJobs, baseRules?: GitlabRule[]) => Promise<AllGitlabJobs>;
@@ -183,7 +183,9 @@ var getFullJobName = function (name, componentName, env) {
183
183
  };
184
184
  var getFullReferencedJobName = function (referencedJobName, componentName, env, allJobs) {
185
185
  var _a, _b;
186
- var referencedJob = (_b = (_a = allJobs[componentName]) === null || _a === void 0 ? void 0 : _a[env]) === null || _b === void 0 ? void 0 : _b.find(function (j) {
186
+ var referencedJob = (_b = (_a = allJobs.find(function (j) {
187
+ return j.context.componentName === componentName && j.context.env === env;
188
+ })) === null || _a === void 0 ? void 0 : _a.jobs) === null || _b === void 0 ? void 0 : _b.find(function (j) {
187
189
  return j.name === referencedJobName;
188
190
  });
189
191
  if (!referencedJob) {
@@ -195,7 +197,7 @@ var getFullReferencedJobName = function (referencedJobName, componentName, env,
195
197
  var getJobName = function (need) {
196
198
  return (0, lodash_1.isObject)(need) ? need.job : need;
197
199
  };
198
- var makeGitlabJob = function (componentName, env, _a, allJobs, baseRules) {
200
+ var makeGitlabJob = function (context, _a, allJobs, baseRules) {
199
201
  var _b, _c;
200
202
  var environment = _a.environment,
201
203
  envMode = _a.envMode,
@@ -205,20 +207,23 @@ var makeGitlabJob = function (componentName, env, _a, allJobs, baseRules) {
205
207
  needs = _a.needs,
206
208
  jobTags = _a.jobTags,
207
209
  script = _a.script,
208
- context = _a.context,
209
210
  variables = _a.variables,
210
211
  runnerVariables = _a.runnerVariables,
211
212
  when = _a.when,
212
- job = __rest(_a, ["environment", "envMode", "needsStages", "needsOtherComponent", "name", "needs", "jobTags", "script", "context", "variables", "runnerVariables", "when"]);
213
- var stage = envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
213
+ job = __rest(_a, ["environment", "envMode", "needsStages", "needsOtherComponent", "name", "needs", "jobTags", "script", "variables", "runnerVariables", "when"]);
214
+ var stage = envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(context.env) : job.stage;
214
215
  var needsFromStages = needsStages === null || needsStages === void 0 ? void 0 : needsStages.flatMap(function (n) {
215
- var _a, _b, _c, _d;
216
- var referencedComponentName = componentName;
217
- var allJobNamesFromThatStage = (_d = (_c = (_b = (_a = allJobs[referencedComponentName]) === null || _a === void 0 ? void 0 : _a[env]) === null || _b === void 0 ? void 0 : _b.filter(function (j) {
216
+ var _a, _b, _c;
217
+ var referencedComponentName = context.componentName;
218
+ var allJobNamesFromThatStage = (_c = (_b = (_a = allJobs.filter(function (j) {
219
+ return j.context.componentName === referencedComponentName && j.context.env === context.env;
220
+ }).flatMap(function (j) {
221
+ return j.jobs;
222
+ })) === null || _a === void 0 ? void 0 : _a.filter(function (j) {
218
223
  return j.stage === n.stage;
219
- })) === null || _c === void 0 ? void 0 : _c.map(function (j) {
224
+ })) === null || _b === void 0 ? void 0 : _b.map(function (j) {
220
225
  return j.name;
221
- })) !== null && _d !== void 0 ? _d : [];
226
+ })) !== null && _c !== void 0 ? _c : [];
222
227
  return allJobNamesFromThatStage.map(function (job) {
223
228
  var _a;
224
229
  return {
@@ -232,16 +237,16 @@ var makeGitlabJob = function (componentName, env, _a, allJobs, baseRules) {
232
237
  var gitlabNeeds = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
233
238
  var _a;
234
239
  return (0, lodash_1.isObject)(n) ? {
235
- job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allJobs),
240
+ job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : context.componentName, context.env, allJobs),
236
241
  artifacts: n.artifacts
237
- } : getFullReferencedJobName(n, componentName, env, allJobs);
242
+ } : getFullReferencedJobName(n, context.componentName, context.env, allJobs);
238
243
  }).sort(function (a, b) {
239
244
  return getJobName(a).localeCompare(getJobName(b));
240
245
  });
241
246
  var deduplicatedGitlabNeeds = __spreadArray([], __read(new Map(gitlabNeeds.map(function (n) {
242
247
  return [(0, lodash_1.isObject)(n) ? n.job : n, n];
243
248
  })).values()), false);
244
- var fullJobName = getFullJobName(name, componentName, envMode !== "none" ? env : undefined);
249
+ var fullJobName = getFullJobName(name, context.componentName, envMode !== "none" ? context.env : undefined);
245
250
  // backwards compatibility, some may still use KUBERNETES_CPU_REQUEST, KUBERNETES_MEMORY_REQUEST, etc. in variables.
246
251
  // those should now be set in the runnerVariables as they don't work in the variables key of the catladder job, becuase those get injected
247
252
  var PIPELINE_RUNNER_VARIABLES = ["KUBERNETES_CPU_REQUEST", "KUBERNETES_MEMORY_REQUEST", "KUBERNETES_CPU_LIMIT", "KUBERNETES_MEMORY_LIMIT"];
@@ -278,7 +283,7 @@ var makeGitlabJob = function (componentName, env, _a, allJobs, baseRules) {
278
283
  needs: deduplicatedGitlabNeeds,
279
284
  retry: defaults_1.BASE_RETRY,
280
285
  interruptible: true
281
- }), componentName, env, allJobs);
286
+ }), context.componentName, context.env, allJobs);
282
287
  return [fullJobName, (0, removeUndefined_1.removeUndefined)(modified)];
283
288
  };
284
289
  exports.makeGitlabJob = makeGitlabJob;
@@ -318,21 +323,18 @@ allJobs) {
318
323
  var createGitlabJobs = function (allJobs, baseRules) {
319
324
  return __awaiter(void 0, void 0, void 0, function () {
320
325
  return __generator(this, function (_a) {
321
- return [2 /*return*/, Object.keys(allJobs).flatMap(function (componentName) {
322
- var componentJobs = allJobs[componentName];
323
- return Object.keys(componentJobs).flatMap(function (env) {
324
- var jobs = componentJobs[env];
325
- return jobs.flatMap(function (job) {
326
- var _a = __read((0, exports.makeGitlabJob)(componentName, env, job, allJobs, baseRules), 2),
327
- fullJobName = _a[0],
328
- gitlabJob = _a[1];
329
- return {
330
- name: fullJobName,
331
- gitlabJob: gitlabJob,
332
- componentName: componentName,
333
- env: env
334
- };
335
- });
326
+ return [2 /*return*/, allJobs.flatMap(function (_a) {
327
+ var context = _a.context,
328
+ jobs = _a.jobs;
329
+ return jobs.map(function (job) {
330
+ var _a = __read((0, exports.makeGitlabJob)(context, job, allJobs, baseRules), 2),
331
+ fullJobName = _a[0],
332
+ gitlabJob = _a[1];
333
+ return {
334
+ name: fullJobName,
335
+ gitlabJob: gitlabJob,
336
+ context: context
337
+ };
336
338
  });
337
339
  })];
338
340
  });