@catladder/cli 0.0.0-main-c5822809 → 0.0.0-main-a38769c0

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.
@@ -39743,29 +39743,25 @@ exports.createRailsBuildJobs = void 0;
39743
39743
  var types_1 = __nccwpck_require__(1197);
39744
39744
  var docker_1 = __nccwpck_require__(3219);
39745
39745
  var createRailsBuildJobs = function (context) {
39746
- var _a, _b, _c, _d, _e, _f;
39746
+ var _a, _b, _c;
39747
39747
  var buildConfig = context.componentConfig.build;
39748
39748
  if (!(0, types_1.isOfBuildType)(buildConfig, "rails")) {
39749
39749
  // should not happen
39750
39750
  throw new Error("build type is not rails");
39751
39751
  }
39752
39752
  var cnbConf = buildConfig.cnbBuilder;
39753
- // backwards compatabilty with CNB_ENV_VARS
39754
- // TODO: remove when all projects are migrated
39755
- var packEnvArgs = (_c = (_b = (_a = buildConfig.extraVars) === null || _a === void 0 ? void 0 : _a.CNB_ENV_VARS) === null || _b === void 0 ? void 0 : _b.split(" ").map(function (v) {
39756
- return "--env '".concat(v, "'");
39757
- })) !== null && _c !== void 0 ? _c : Object.entries((_d = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.buildVars) !== null && _d !== void 0 ? _d : {}).map(function (_a) {
39753
+ var packEnvArgs = Object.entries((_a = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.buildVars) !== null && _a !== void 0 ? _a : {}).map(function (_a) {
39758
39754
  var _b = __read(_a, 2),
39759
39755
  k = _b[0],
39760
39756
  v = _b[1];
39761
39757
  return "--env '".concat(k).concat(v ? "=".concat(v) : "", "'");
39762
- });
39758
+ }).join(" ");
39763
39759
  return [(0, docker_1.createDockerBuildJobBase)(context, {
39764
39760
  variables: context.componentConfig.build.extraVars,
39765
39761
  // custom script
39766
39762
  script: [docker_1.gitlabDockerLogin, "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
39767
39763
  // replace private git ssh gem sources with https to make bundler with credentials via env var work
39768
- "sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "pack build \"$DOCKER_IMAGE:$DOCKER_IMAGE_TAG\" --builder '".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.image, "' --publish --cache-image \"$DOCKER_CACHE_IMAGE\" ").concat(packEnvArgs.join(" "), " ").concat((_f = (_e = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _e === void 0 ? void 0 : _e.join(" ")) !== null && _f !== void 0 ? _f : "")]
39764
+ "sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "pack build \"$DOCKER_IMAGE:$DOCKER_IMAGE_TAG\" --builder '".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.image, "' --publish --cache-image \"$DOCKER_CACHE_IMAGE\" ").concat(packEnvArgs, " ").concat((_c = (_b = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _b === void 0 ? void 0 : _b.join(" ")) !== null && _c !== void 0 ? _c : "")]
39769
39765
  })];
39770
39766
  };
39771
39767
  exports.createRailsBuildJobs = createRailsBuildJobs;
@@ -40112,7 +40108,7 @@ exports.readConfigSync = readConfigSync;
40112
40108
 
40113
40109
  exports.__esModule = true;
40114
40110
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
40115
- exports.PIPELINE_IMAGE_TAG = "main-c5822809" || 0;
40111
+ exports.PIPELINE_IMAGE_TAG = "main-a38769c0" || 0;
40116
40112
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
40117
40113
 
40118
40114
  /***/ }),
@@ -43011,22 +43007,183 @@ exports.getBaseCommitInfo = getBaseCommitInfo;
43011
43007
 
43012
43008
  /***/ }),
43013
43009
 
43014
- /***/ 8974:
43010
+ /***/ 7052:
43015
43011
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
43016
43012
 
43017
43013
  "use strict";
43018
43014
 
43019
43015
 
43020
- var __assign = this && this.__assign || function () {
43021
- __assign = Object.assign || function (t) {
43022
- for (var s, i = 1, n = arguments.length; i < n; i++) {
43023
- s = arguments[i];
43024
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
43016
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
43017
+ function adopt(value) {
43018
+ return value instanceof P ? value : new P(function (resolve) {
43019
+ resolve(value);
43020
+ });
43021
+ }
43022
+ return new (P || (P = Promise))(function (resolve, reject) {
43023
+ function fulfilled(value) {
43024
+ try {
43025
+ step(generator.next(value));
43026
+ } catch (e) {
43027
+ reject(e);
43028
+ }
43025
43029
  }
43026
- return t;
43027
- };
43028
- return __assign.apply(this, arguments);
43030
+ function rejected(value) {
43031
+ try {
43032
+ step(generator["throw"](value));
43033
+ } catch (e) {
43034
+ reject(e);
43035
+ }
43036
+ }
43037
+ function step(result) {
43038
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
43039
+ }
43040
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43041
+ });
43029
43042
  };
43043
+ var __generator = this && this.__generator || function (thisArg, body) {
43044
+ var _ = {
43045
+ label: 0,
43046
+ sent: function () {
43047
+ if (t[0] & 1) throw t[1];
43048
+ return t[1];
43049
+ },
43050
+ trys: [],
43051
+ ops: []
43052
+ },
43053
+ f,
43054
+ y,
43055
+ t,
43056
+ g;
43057
+ return g = {
43058
+ next: verb(0),
43059
+ "throw": verb(1),
43060
+ "return": verb(2)
43061
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
43062
+ return this;
43063
+ }), g;
43064
+ function verb(n) {
43065
+ return function (v) {
43066
+ return step([n, v]);
43067
+ };
43068
+ }
43069
+ function step(op) {
43070
+ if (f) throw new TypeError("Generator is already executing.");
43071
+ while (_) try {
43072
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
43073
+ if (y = 0, t) op = [op[0] & 2, t.value];
43074
+ switch (op[0]) {
43075
+ case 0:
43076
+ case 1:
43077
+ t = op;
43078
+ break;
43079
+ case 4:
43080
+ _.label++;
43081
+ return {
43082
+ value: op[1],
43083
+ done: false
43084
+ };
43085
+ case 5:
43086
+ _.label++;
43087
+ y = op[1];
43088
+ op = [0];
43089
+ continue;
43090
+ case 7:
43091
+ op = _.ops.pop();
43092
+ _.trys.pop();
43093
+ continue;
43094
+ default:
43095
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
43096
+ _ = 0;
43097
+ continue;
43098
+ }
43099
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
43100
+ _.label = op[1];
43101
+ break;
43102
+ }
43103
+ if (op[0] === 6 && _.label < t[1]) {
43104
+ _.label = t[1];
43105
+ t = op;
43106
+ break;
43107
+ }
43108
+ if (t && _.label < t[2]) {
43109
+ _.label = t[2];
43110
+ _.ops.push(op);
43111
+ break;
43112
+ }
43113
+ if (t[2]) _.ops.pop();
43114
+ _.trys.pop();
43115
+ continue;
43116
+ }
43117
+ op = body.call(thisArg, _);
43118
+ } catch (e) {
43119
+ op = [6, e];
43120
+ y = 0;
43121
+ } finally {
43122
+ f = t = 0;
43123
+ }
43124
+ if (op[0] & 5) throw op[1];
43125
+ return {
43126
+ value: op[0] ? op[1] : void 0,
43127
+ done: true
43128
+ };
43129
+ }
43130
+ };
43131
+ exports.__esModule = true;
43132
+ exports.createAllJobs = void 0;
43133
+ var config_1 = __nccwpck_require__(3138);
43134
+ var createJobsForComponent_1 = __nccwpck_require__(962);
43135
+ var createAllJobs = function (config, trigger) {
43136
+ return __awaiter(void 0, void 0, void 0, function () {
43137
+ var _a, _b;
43138
+ return __generator(this, function (_c) {
43139
+ switch (_c.label) {
43140
+ case 0:
43141
+ _b = (_a = Object).fromEntries;
43142
+ return [4 /*yield*/, Promise.all(Object.keys(config.components).map(function (componentName) {
43143
+ return __awaiter(void 0, void 0, void 0, function () {
43144
+ var envs, _a, _b, _c;
43145
+ return __generator(this, function (_d) {
43146
+ switch (_d.label) {
43147
+ case 0:
43148
+ envs = (0, config_1.getAllEnvsByTrigger)(config, componentName, trigger);
43149
+ _a = [componentName];
43150
+ _c = (_b = Object).fromEntries;
43151
+ return [4 /*yield*/, Promise.all(envs.map(function (env) {
43152
+ return __awaiter(void 0, void 0, void 0, function () {
43153
+ var _a;
43154
+ return __generator(this, function (_b) {
43155
+ switch (_b.label) {
43156
+ case 0:
43157
+ _a = [env];
43158
+ return [4 /*yield*/, (0, createJobsForComponent_1.createJobsForComponent)(config, componentName, env, trigger)];
43159
+ case 1:
43160
+ return [2 /*return*/, _a.concat([_b.sent()])];
43161
+ }
43162
+ });
43163
+ });
43164
+ }))];
43165
+ case 1:
43166
+ return [2 /*return*/, _a.concat([_c.apply(_b, [_d.sent()])])];
43167
+ }
43168
+ });
43169
+ });
43170
+ }))];
43171
+ case 1:
43172
+ return [2 /*return*/, _b.apply(_a, [_c.sent()])];
43173
+ }
43174
+ });
43175
+ });
43176
+ };
43177
+ exports.createAllJobs = createAllJobs;
43178
+
43179
+ /***/ }),
43180
+
43181
+ /***/ 8974:
43182
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
43183
+
43184
+ "use strict";
43185
+
43186
+
43030
43187
  var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
43031
43188
  function adopt(value) {
43032
43189
  return value instanceof P ? value : new P(function (resolve) {
@@ -43179,54 +43336,40 @@ var config_1 = __nccwpck_require__(3138);
43179
43336
  var rules_1 = __nccwpck_require__(2020);
43180
43337
  var runner_1 = __nccwpck_require__(5071);
43181
43338
  var jobs_1 = __nccwpck_require__(2339);
43182
- var createJobs_1 = __nccwpck_require__(7726);
43339
+ var createAllJobs_1 = __nccwpck_require__(7052);
43340
+ var createGitlabJobs_1 = __nccwpck_require__(3920);
43183
43341
  var createChildPipeline = function (type, trigger, config) {
43184
43342
  return __awaiter(void 0, void 0, void 0, function () {
43185
- var components, jobs, allEnvs, stages, pipeline;
43186
- return __generator(this, function (_a) {
43187
- switch (_a.label) {
43343
+ var jobs, allEnvs, stages, pipeline;
43344
+ var _a;
43345
+ return __generator(this, function (_b) {
43346
+ switch (_b.label) {
43188
43347
  case 0:
43189
- components = Object.keys(config.components);
43190
- return [4 /*yield*/, components.reduce(function (acc, componentName) {
43191
- return __awaiter(void 0, void 0, void 0, function () {
43192
- var envs, _a, _b;
43193
- return __generator(this, function (_c) {
43194
- switch (_c.label) {
43195
- case 0:
43196
- envs = (0, config_1.getAllEnvsByTrigger)(config, componentName, trigger);
43197
- _a = [{}];
43198
- return [4 /*yield*/, acc];
43199
- case 1:
43200
- _b = [__assign.apply(void 0, _a.concat([_c.sent()]))];
43201
- return [4 /*yield*/, (0, createJobs_1.createJobs)(type, envs, config, componentName, trigger)];
43202
- case 2:
43203
- return [2 /*return*/, __assign.apply(void 0, _b.concat([_c.sent()]))];
43204
- }
43205
- });
43206
- });
43207
- }, Promise.resolve({}))];
43348
+ return [4 /*yield*/, (0, createAllJobs_1.createAllJobs)(config, trigger)];
43208
43349
  case 1:
43209
- jobs = _a.sent();
43350
+ jobs = _b.sent();
43210
43351
  allEnvs = (0, config_1.getAllEnvsInAllComponents)(config);
43211
43352
  stages = jobs_1.BASE_STAGES.reduce(function (acc, baseStage) {
43212
43353
  return __spreadArray(__spreadArray(__spreadArray([], __read(acc), false), [baseStage], false), __read(allEnvs.map(function (e) {
43213
43354
  return "".concat(baseStage, " ").concat(e);
43214
43355
  })), false);
43215
43356
  }, []);
43216
- if (type === "gitlab") {
43217
- pipeline = {
43218
- image: (0, runner_1.getRunnerImage)("jobs-default"),
43219
- variables: {
43220
- FF_USE_FASTZIP: "true"
43221
- },
43222
- workflow: {
43223
- rules: rules_1.RULES_ALWAYS
43224
- },
43225
- stages: stages,
43226
- jobs: jobs
43227
- };
43228
- return [2 /*return*/, pipeline];
43229
- }
43357
+ if (!(type === "gitlab")) return [3 /*break*/, 3];
43358
+ _a = {
43359
+ image: (0, runner_1.getRunnerImage)("jobs-default"),
43360
+ variables: {
43361
+ FF_USE_FASTZIP: "true"
43362
+ },
43363
+ workflow: {
43364
+ rules: rules_1.RULES_ALWAYS
43365
+ },
43366
+ stages: stages
43367
+ };
43368
+ return [4 /*yield*/, (0, createGitlabJobs_1.createGitlabJobs)(jobs)];
43369
+ case 2:
43370
+ pipeline = (_a.jobs = _b.sent(), _a);
43371
+ return [2 /*return*/, pipeline];
43372
+ case 3:
43230
43373
  throw new Error("".concat(type, " is not supported"));
43231
43374
  }
43232
43375
  });
@@ -43236,7 +43379,7 @@ exports.createChildPipeline = createChildPipeline;
43236
43379
 
43237
43380
  /***/ }),
43238
43381
 
43239
- /***/ 7726:
43382
+ /***/ 962:
43240
43383
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
43241
43384
 
43242
43385
  "use strict";
@@ -43407,14 +43550,12 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
43407
43550
  return to.concat(ar || Array.prototype.slice.call(from));
43408
43551
  };
43409
43552
  exports.__esModule = true;
43410
- exports.createJobs = void 0;
43553
+ exports.createJobsForComponent = void 0;
43411
43554
  var lodash_1 = __nccwpck_require__(3255);
43412
43555
  var build_1 = __nccwpck_require__(3760);
43413
43556
  var context_1 = __nccwpck_require__(2041);
43414
43557
  var deploy_1 = __nccwpck_require__(223);
43415
- var utils_1 = __nccwpck_require__(7461);
43416
43558
  var getCommitInfo_1 = __nccwpck_require__(5923);
43417
- var makeGitlabJob_1 = __nccwpck_require__(5715);
43418
43559
  var packageManager_1 = __nccwpck_require__(9168);
43419
43560
  var injectDefaultVarsInCustomJobs = function (context, jobs) {
43420
43561
  return jobs.map(function (_a) {
@@ -43442,71 +43583,9 @@ var createRawJobs = function (context) {
43442
43583
  var customJobs = getCustomJobs(context);
43443
43584
  return __spreadArray(__spreadArray(__spreadArray([], __read(buildJobs), false), __read(deployJobs), false), __read(customJobs), false);
43444
43585
  };
43445
- var getFullJobName = function (name, componentName, env) {
43446
- if (env) {
43447
- return "".concat(componentName, " ").concat(name, " | ").concat(env, " ");
43448
- }
43449
- return "".concat(componentName, " ").concat(name);
43450
- };
43451
- var getFullReferencedJobName = function (referencedJobName, componentName, env, allRawJobs) {
43452
- var referencedJob = allRawJobs.find(function (j) {
43453
- return j.name === referencedJobName;
43454
- });
43455
- if (!referencedJob) {
43456
- throw new Error("unknown job referenced: " + referencedJobName);
43457
- }
43458
- var envToSet = referencedJob.envMode !== "none" ? env : null;
43459
- return getFullJobName(referencedJobName, componentName, envToSet);
43460
- };
43461
- // replaces references to other jobs with the full name
43462
- // the full name contains the componentname and the env name (if any)
43463
- var replaceReferences = function (job, componentName, env, allRawJobs) {
43464
- var _a, _b, _c;
43465
- var stage = job.envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
43466
- var cleanedNeeds = __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read((_b = job.needsOtherComponent) !== null && _b !== void 0 ? _b : []), false);
43467
- var needs = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
43468
- var _a;
43469
- return (0, lodash_1.isObject)(n) ? {
43470
- job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allRawJobs),
43471
- artifacts: n.artifacts
43472
- } : getFullReferencedJobName(n, componentName, env, allRawJobs);
43473
- });
43474
- return __assign(__assign({}, job), {
43475
- stage: stage,
43476
- needs: needs,
43477
- environment: ((_c = job.environment) === null || _c === void 0 ? void 0 : _c.on_stop) ? __assign(__assign({}, job.environment), {
43478
- on_stop: getFullReferencedJobName(job.environment.on_stop, componentName, env, allRawJobs)
43479
- }) : job.environment
43480
- });
43481
- };
43482
- // this can be removed once https://gitlab.com/gitlab-org/gitlab/-/issues/220758 is resolved
43483
- var addStageNeeds = function (jobs) {
43484
- // when a job defines needsStages, we add these as needs
43485
- return jobs.map(function (job) {
43486
- var _a;
43487
- if (!job.needsStages || job.needsStages.length === 0) {
43488
- return job;
43489
- }
43490
- var neededJobs = jobs.map(function (j) {
43491
- var _a, _b;
43492
- var neededStage = (_a = job.needsStages) === null || _a === void 0 ? void 0 : _a.find(function (s) {
43493
- return j.stage === s.stage;
43494
- });
43495
- if (neededStage) {
43496
- return {
43497
- job: j.name,
43498
- artifacts: (_b = neededStage.artifacts) !== null && _b !== void 0 ? _b : false
43499
- };
43500
- }
43501
- }).filter(utils_1.notNil);
43502
- return __assign(__assign({}, job), {
43503
- needs: __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read(neededJobs), false)
43504
- });
43505
- });
43506
- };
43507
- var createJobs = function (type, envs, config, componentName, trigger) {
43586
+ var createJobsForComponent = function (config, componentName, env, trigger) {
43508
43587
  return __awaiter(void 0, void 0, void 0, function () {
43509
- var commitInfo, _a, packageManagerInfo;
43588
+ var commitInfo, _a, packageManagerInfo, context;
43510
43589
  return __generator(this, function (_b) {
43511
43590
  switch (_b.label) {
43512
43591
  case 0:
@@ -43519,47 +43598,19 @@ var createJobs = function (type, envs, config, componentName, trigger) {
43519
43598
  return [4 /*yield*/, (0, packageManager_1.getPackageManagerInfo)(config, componentName)];
43520
43599
  case 2:
43521
43600
  packageManagerInfo = _b.sent();
43522
- return [2 /*return*/, envs.reduce(function (acc, env) {
43523
- return __awaiter(void 0, void 0, void 0, function () {
43524
- var context, jobs, result, _a, _b, _c, _d, _e;
43525
- return __generator(this, function (_f) {
43526
- switch (_f.label) {
43527
- case 0:
43528
- return [4 /*yield*/, (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo)];
43529
- case 1:
43530
- context = _f.sent();
43531
- jobs = addStageNeeds(createRawJobs(context));
43532
- _a = [{}];
43533
- return [4 /*yield*/, acc];
43534
- case 2:
43535
- _b = [__assign.apply(void 0, _a.concat([_f.sent()]))];
43536
- _d = (_c = jobs).reduce;
43537
- _e = [function (acc, job) {
43538
- var _a;
43539
- var jobWithResolvedReferences = replaceReferences(job, componentName, env, jobs);
43540
- var jobName = getFullJobName(job.name, componentName, job.envMode !== "none" ? env : undefined);
43541
- if (type === "gitlab") {
43542
- return __assign(__assign({}, acc), (_a = {}, _a[jobName] = (0, makeGitlabJob_1.makeGitlabJob)(jobWithResolvedReferences), _a));
43543
- }
43544
- throw new Error("not supported");
43545
- }];
43546
- return [4 /*yield*/, Promise.resolve({})];
43547
- case 3:
43548
- result = __assign.apply(void 0, _b.concat([_d.apply(_c, _e.concat([_f.sent()]))]));
43549
- return [2 /*return*/, result];
43550
- }
43551
- });
43552
- });
43553
- }, {})];
43601
+ return [4 /*yield*/, (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo)];
43602
+ case 3:
43603
+ context = _b.sent();
43604
+ return [2 /*return*/, createRawJobs(context)];
43554
43605
  }
43555
43606
  });
43556
43607
  });
43557
43608
  };
43558
- exports.createJobs = createJobs;
43609
+ exports.createJobsForComponent = createJobsForComponent;
43559
43610
 
43560
43611
  /***/ }),
43561
43612
 
43562
- /***/ 5715:
43613
+ /***/ 3920:
43563
43614
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
43564
43615
 
43565
43616
  "use strict";
@@ -43575,6 +43626,121 @@ var __assign = this && this.__assign || function () {
43575
43626
  };
43576
43627
  return __assign.apply(this, arguments);
43577
43628
  };
43629
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
43630
+ function adopt(value) {
43631
+ return value instanceof P ? value : new P(function (resolve) {
43632
+ resolve(value);
43633
+ });
43634
+ }
43635
+ return new (P || (P = Promise))(function (resolve, reject) {
43636
+ function fulfilled(value) {
43637
+ try {
43638
+ step(generator.next(value));
43639
+ } catch (e) {
43640
+ reject(e);
43641
+ }
43642
+ }
43643
+ function rejected(value) {
43644
+ try {
43645
+ step(generator["throw"](value));
43646
+ } catch (e) {
43647
+ reject(e);
43648
+ }
43649
+ }
43650
+ function step(result) {
43651
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
43652
+ }
43653
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43654
+ });
43655
+ };
43656
+ var __generator = this && this.__generator || function (thisArg, body) {
43657
+ var _ = {
43658
+ label: 0,
43659
+ sent: function () {
43660
+ if (t[0] & 1) throw t[1];
43661
+ return t[1];
43662
+ },
43663
+ trys: [],
43664
+ ops: []
43665
+ },
43666
+ f,
43667
+ y,
43668
+ t,
43669
+ g;
43670
+ return g = {
43671
+ next: verb(0),
43672
+ "throw": verb(1),
43673
+ "return": verb(2)
43674
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
43675
+ return this;
43676
+ }), g;
43677
+ function verb(n) {
43678
+ return function (v) {
43679
+ return step([n, v]);
43680
+ };
43681
+ }
43682
+ function step(op) {
43683
+ if (f) throw new TypeError("Generator is already executing.");
43684
+ while (_) try {
43685
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
43686
+ if (y = 0, t) op = [op[0] & 2, t.value];
43687
+ switch (op[0]) {
43688
+ case 0:
43689
+ case 1:
43690
+ t = op;
43691
+ break;
43692
+ case 4:
43693
+ _.label++;
43694
+ return {
43695
+ value: op[1],
43696
+ done: false
43697
+ };
43698
+ case 5:
43699
+ _.label++;
43700
+ y = op[1];
43701
+ op = [0];
43702
+ continue;
43703
+ case 7:
43704
+ op = _.ops.pop();
43705
+ _.trys.pop();
43706
+ continue;
43707
+ default:
43708
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
43709
+ _ = 0;
43710
+ continue;
43711
+ }
43712
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
43713
+ _.label = op[1];
43714
+ break;
43715
+ }
43716
+ if (op[0] === 6 && _.label < t[1]) {
43717
+ _.label = t[1];
43718
+ t = op;
43719
+ break;
43720
+ }
43721
+ if (t && _.label < t[2]) {
43722
+ _.label = t[2];
43723
+ _.ops.push(op);
43724
+ break;
43725
+ }
43726
+ if (t[2]) _.ops.pop();
43727
+ _.trys.pop();
43728
+ continue;
43729
+ }
43730
+ op = body.call(thisArg, _);
43731
+ } catch (e) {
43732
+ op = [6, e];
43733
+ y = 0;
43734
+ } finally {
43735
+ f = t = 0;
43736
+ }
43737
+ if (op[0] & 5) throw op[1];
43738
+ return {
43739
+ value: op[0] ? op[1] : void 0,
43740
+ done: true
43741
+ };
43742
+ }
43743
+ };
43578
43744
  var __rest = this && this.__rest || function (s, e) {
43579
43745
  var t = {};
43580
43746
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -43615,29 +43781,99 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
43615
43781
  return to.concat(ar || Array.prototype.slice.call(from));
43616
43782
  };
43617
43783
  exports.__esModule = true;
43618
- exports.makeGitlabJob = void 0;
43784
+ exports.createGitlabJobs = exports.makeGitlabJob = void 0;
43619
43785
  var lodash_1 = __nccwpck_require__(3255);
43620
43786
  var defaults_1 = __nccwpck_require__(7383);
43787
+ var getFullJobName = function (name, componentName, env) {
43788
+ if (env) {
43789
+ return "".concat(componentName, " ").concat(name, " | ").concat(env, " ");
43790
+ }
43791
+ return "".concat(componentName, " ").concat(name);
43792
+ };
43793
+ var getFullReferencedJobName = function (referencedJobName, componentName, env, allJobs) {
43794
+ var _a, _b;
43795
+ var referencedJob = (_b = (_a = allJobs[componentName]) === null || _a === void 0 ? void 0 : _a[env]) === null || _b === void 0 ? void 0 : _b.find(function (j) {
43796
+ return j.name === referencedJobName;
43797
+ });
43798
+ if (!referencedJob) {
43799
+ throw new Error("unknown job referenced: '".concat(referencedJobName, "' from '").concat(env, ":").concat(componentName, "'"));
43800
+ }
43801
+ var envToSet = referencedJob.envMode !== "none" ? env : null;
43802
+ return getFullJobName(referencedJobName, componentName, envToSet);
43803
+ };
43621
43804
  var getJobName = function (need) {
43622
43805
  return (0, lodash_1.isObject)(need) ? need.job : need;
43623
43806
  };
43624
- var makeGitlabJob = function (_a) {
43807
+ var makeGitlabJob = function (componentName, env, _a, allJobs) {
43808
+ var _b;
43625
43809
  var envMode = _a.envMode,
43626
43810
  needsStages = _a.needsStages,
43627
43811
  needsOtherComponent = _a.needsOtherComponent,
43628
43812
  name = _a.name,
43629
43813
  needs = _a.needs,
43630
- rest = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
43631
- return __assign(__assign({}, rest), {
43814
+ job = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
43815
+ var stage = envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
43816
+ var needsFromStages = needsStages === null || needsStages === void 0 ? void 0 : needsStages.flatMap(function (n) {
43817
+ var _a, _b, _c, _d;
43818
+ var referencedComponentName = componentName;
43819
+ 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) {
43820
+ return j.stage === n.stage;
43821
+ })) === null || _c === void 0 ? void 0 : _c.map(function (j) {
43822
+ return j.name;
43823
+ })) !== null && _d !== void 0 ? _d : [];
43824
+ return allJobNamesFromThatStage.map(function (job) {
43825
+ var _a;
43826
+ return {
43827
+ job: job,
43828
+ artifacts: (_a = n.artifacts) !== null && _a !== void 0 ? _a : false,
43829
+ componentName: referencedComponentName
43830
+ };
43831
+ });
43832
+ });
43833
+ var cleanedNeeds = __spreadArray(__spreadArray(__spreadArray([], __read(needs !== null && needs !== void 0 ? needs : []), false), __read(needsOtherComponent !== null && needsOtherComponent !== void 0 ? needsOtherComponent : []), false), __read(needsFromStages !== null && needsFromStages !== void 0 ? needsFromStages : []), false);
43834
+ var gitlabNeeds = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
43835
+ var _a;
43836
+ return (0, lodash_1.isObject)(n) ? {
43837
+ job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allJobs),
43838
+ artifacts: n.artifacts
43839
+ } : getFullReferencedJobName(n, componentName, env, allJobs);
43840
+ }).sort(function (a, b) {
43841
+ return getJobName(a).localeCompare(getJobName(b));
43842
+ });
43843
+ var fullJobName = getFullJobName(name, componentName, envMode !== "none" ? env : undefined);
43844
+ var gitlabJob = __assign(__assign({}, job), {
43845
+ stage: stage,
43846
+ environment: ((_b = job.environment) === null || _b === void 0 ? void 0 : _b.on_stop) ? __assign(__assign({}, job.environment), {
43847
+ on_stop: getFullReferencedJobName(job.environment.on_stop, componentName, env, allJobs)
43848
+ }) : job.environment,
43632
43849
  // sort in a predictable manner for snapshot tests
43633
- needs: needs ? __spreadArray([], __read(needs), false).sort(function (a, b) {
43634
- return getJobName(a).localeCompare(getJobName(b));
43635
- }) : undefined,
43850
+ needs: gitlabNeeds,
43636
43851
  retry: defaults_1.BASE_RETRY,
43637
43852
  interruptible: true
43638
43853
  });
43854
+ return [fullJobName, gitlabJob];
43639
43855
  };
43640
43856
  exports.makeGitlabJob = makeGitlabJob;
43857
+ var createGitlabJobs = function (allJobs) {
43858
+ return __awaiter(void 0, void 0, void 0, function () {
43859
+ return __generator(this, function (_a) {
43860
+ return [2 /*return*/, Object.keys(allJobs).reduce(function (accForComponents, componentName) {
43861
+ var componentJobs = allJobs[componentName];
43862
+ return __assign(__assign({}, accForComponents), Object.keys(componentJobs).reduce(function (accForEnvs, env) {
43863
+ var jobs = componentJobs[env];
43864
+ return __assign(__assign({}, accForEnvs), jobs.reduce(function (accForJobs, job) {
43865
+ var _a;
43866
+ var _b = __read((0, exports.makeGitlabJob)(componentName, env, job, allJobs), 2),
43867
+ fullJobName = _b[0],
43868
+ gitlabJob = _b[1];
43869
+ return __assign(__assign({}, accForJobs), (_a = {}, _a[fullJobName] = gitlabJob, _a));
43870
+ }, {}));
43871
+ }, {}));
43872
+ }, {})];
43873
+ });
43874
+ });
43875
+ };
43876
+ exports.createGitlabJobs = createGitlabJobs;
43641
43877
 
43642
43878
  /***/ }),
43643
43879
 
@@ -43664,7 +43900,7 @@ var __exportStar = this && this.__exportStar || function (m, exports) {
43664
43900
  };
43665
43901
  exports.__esModule = true;
43666
43902
  __exportStar(__nccwpck_require__(8974), exports);
43667
- __exportStar(__nccwpck_require__(7726), exports);
43903
+ __exportStar(__nccwpck_require__(962), exports);
43668
43904
 
43669
43905
  /***/ }),
43670
43906