@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.
@@ -351075,29 +351075,25 @@ exports.createRailsBuildJobs = void 0;
351075
351075
  var types_1 = __nccwpck_require__(71197);
351076
351076
  var docker_1 = __nccwpck_require__(33219);
351077
351077
  var createRailsBuildJobs = function (context) {
351078
- var _a, _b, _c, _d, _e, _f;
351078
+ var _a, _b, _c;
351079
351079
  var buildConfig = context.componentConfig.build;
351080
351080
  if (!(0, types_1.isOfBuildType)(buildConfig, "rails")) {
351081
351081
  // should not happen
351082
351082
  throw new Error("build type is not rails");
351083
351083
  }
351084
351084
  var cnbConf = buildConfig.cnbBuilder;
351085
- // backwards compatabilty with CNB_ENV_VARS
351086
- // TODO: remove when all projects are migrated
351087
- 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) {
351088
- return "--env '".concat(v, "'");
351089
- })) !== 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) {
351085
+ var packEnvArgs = Object.entries((_a = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.buildVars) !== null && _a !== void 0 ? _a : {}).map(function (_a) {
351090
351086
  var _b = __read(_a, 2),
351091
351087
  k = _b[0],
351092
351088
  v = _b[1];
351093
351089
  return "--env '".concat(k).concat(v ? "=".concat(v) : "", "'");
351094
- });
351090
+ }).join(" ");
351095
351091
  return [(0, docker_1.createDockerBuildJobBase)(context, {
351096
351092
  variables: context.componentConfig.build.extraVars,
351097
351093
  // custom script
351098
351094
  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",
351099
351095
  // replace private git ssh gem sources with https to make bundler with credentials via env var work
351100
- "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 : "")]
351096
+ "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 : "")]
351101
351097
  })];
351102
351098
  };
351103
351099
  exports.createRailsBuildJobs = createRailsBuildJobs;
@@ -351444,7 +351440,7 @@ exports.readConfigSync = readConfigSync;
351444
351440
 
351445
351441
  exports.__esModule = true;
351446
351442
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
351447
- exports.PIPELINE_IMAGE_TAG = "main-c5822809" || 0;
351443
+ exports.PIPELINE_IMAGE_TAG = "main-a38769c0" || 0;
351448
351444
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
351449
351445
 
351450
351446
  /***/ }),
@@ -354343,22 +354339,183 @@ exports.getBaseCommitInfo = getBaseCommitInfo;
354343
354339
 
354344
354340
  /***/ }),
354345
354341
 
354346
- /***/ 78974:
354342
+ /***/ 17052:
354347
354343
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
354348
354344
 
354349
354345
  "use strict";
354350
354346
 
354351
354347
 
354352
- var __assign = this && this.__assign || function () {
354353
- __assign = Object.assign || function (t) {
354354
- for (var s, i = 1, n = arguments.length; i < n; i++) {
354355
- s = arguments[i];
354356
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
354348
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
354349
+ function adopt(value) {
354350
+ return value instanceof P ? value : new P(function (resolve) {
354351
+ resolve(value);
354352
+ });
354353
+ }
354354
+ return new (P || (P = Promise))(function (resolve, reject) {
354355
+ function fulfilled(value) {
354356
+ try {
354357
+ step(generator.next(value));
354358
+ } catch (e) {
354359
+ reject(e);
354360
+ }
354357
354361
  }
354358
- return t;
354359
- };
354360
- return __assign.apply(this, arguments);
354362
+ function rejected(value) {
354363
+ try {
354364
+ step(generator["throw"](value));
354365
+ } catch (e) {
354366
+ reject(e);
354367
+ }
354368
+ }
354369
+ function step(result) {
354370
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
354371
+ }
354372
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
354373
+ });
354374
+ };
354375
+ var __generator = this && this.__generator || function (thisArg, body) {
354376
+ var _ = {
354377
+ label: 0,
354378
+ sent: function () {
354379
+ if (t[0] & 1) throw t[1];
354380
+ return t[1];
354381
+ },
354382
+ trys: [],
354383
+ ops: []
354384
+ },
354385
+ f,
354386
+ y,
354387
+ t,
354388
+ g;
354389
+ return g = {
354390
+ next: verb(0),
354391
+ "throw": verb(1),
354392
+ "return": verb(2)
354393
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
354394
+ return this;
354395
+ }), g;
354396
+ function verb(n) {
354397
+ return function (v) {
354398
+ return step([n, v]);
354399
+ };
354400
+ }
354401
+ function step(op) {
354402
+ if (f) throw new TypeError("Generator is already executing.");
354403
+ while (_) try {
354404
+ 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;
354405
+ if (y = 0, t) op = [op[0] & 2, t.value];
354406
+ switch (op[0]) {
354407
+ case 0:
354408
+ case 1:
354409
+ t = op;
354410
+ break;
354411
+ case 4:
354412
+ _.label++;
354413
+ return {
354414
+ value: op[1],
354415
+ done: false
354416
+ };
354417
+ case 5:
354418
+ _.label++;
354419
+ y = op[1];
354420
+ op = [0];
354421
+ continue;
354422
+ case 7:
354423
+ op = _.ops.pop();
354424
+ _.trys.pop();
354425
+ continue;
354426
+ default:
354427
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
354428
+ _ = 0;
354429
+ continue;
354430
+ }
354431
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
354432
+ _.label = op[1];
354433
+ break;
354434
+ }
354435
+ if (op[0] === 6 && _.label < t[1]) {
354436
+ _.label = t[1];
354437
+ t = op;
354438
+ break;
354439
+ }
354440
+ if (t && _.label < t[2]) {
354441
+ _.label = t[2];
354442
+ _.ops.push(op);
354443
+ break;
354444
+ }
354445
+ if (t[2]) _.ops.pop();
354446
+ _.trys.pop();
354447
+ continue;
354448
+ }
354449
+ op = body.call(thisArg, _);
354450
+ } catch (e) {
354451
+ op = [6, e];
354452
+ y = 0;
354453
+ } finally {
354454
+ f = t = 0;
354455
+ }
354456
+ if (op[0] & 5) throw op[1];
354457
+ return {
354458
+ value: op[0] ? op[1] : void 0,
354459
+ done: true
354460
+ };
354461
+ }
354462
+ };
354463
+ exports.__esModule = true;
354464
+ exports.createAllJobs = void 0;
354465
+ var config_1 = __nccwpck_require__(33138);
354466
+ var createJobsForComponent_1 = __nccwpck_require__(80962);
354467
+ var createAllJobs = function (config, trigger) {
354468
+ return __awaiter(void 0, void 0, void 0, function () {
354469
+ var _a, _b;
354470
+ return __generator(this, function (_c) {
354471
+ switch (_c.label) {
354472
+ case 0:
354473
+ _b = (_a = Object).fromEntries;
354474
+ return [4 /*yield*/, Promise.all(Object.keys(config.components).map(function (componentName) {
354475
+ return __awaiter(void 0, void 0, void 0, function () {
354476
+ var envs, _a, _b, _c;
354477
+ return __generator(this, function (_d) {
354478
+ switch (_d.label) {
354479
+ case 0:
354480
+ envs = (0, config_1.getAllEnvsByTrigger)(config, componentName, trigger);
354481
+ _a = [componentName];
354482
+ _c = (_b = Object).fromEntries;
354483
+ return [4 /*yield*/, Promise.all(envs.map(function (env) {
354484
+ return __awaiter(void 0, void 0, void 0, function () {
354485
+ var _a;
354486
+ return __generator(this, function (_b) {
354487
+ switch (_b.label) {
354488
+ case 0:
354489
+ _a = [env];
354490
+ return [4 /*yield*/, (0, createJobsForComponent_1.createJobsForComponent)(config, componentName, env, trigger)];
354491
+ case 1:
354492
+ return [2 /*return*/, _a.concat([_b.sent()])];
354493
+ }
354494
+ });
354495
+ });
354496
+ }))];
354497
+ case 1:
354498
+ return [2 /*return*/, _a.concat([_c.apply(_b, [_d.sent()])])];
354499
+ }
354500
+ });
354501
+ });
354502
+ }))];
354503
+ case 1:
354504
+ return [2 /*return*/, _b.apply(_a, [_c.sent()])];
354505
+ }
354506
+ });
354507
+ });
354361
354508
  };
354509
+ exports.createAllJobs = createAllJobs;
354510
+
354511
+ /***/ }),
354512
+
354513
+ /***/ 78974:
354514
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
354515
+
354516
+ "use strict";
354517
+
354518
+
354362
354519
  var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
354363
354520
  function adopt(value) {
354364
354521
  return value instanceof P ? value : new P(function (resolve) {
@@ -354511,54 +354668,40 @@ var config_1 = __nccwpck_require__(33138);
354511
354668
  var rules_1 = __nccwpck_require__(42020);
354512
354669
  var runner_1 = __nccwpck_require__(55071);
354513
354670
  var jobs_1 = __nccwpck_require__(62339);
354514
- var createJobs_1 = __nccwpck_require__(57726);
354671
+ var createAllJobs_1 = __nccwpck_require__(17052);
354672
+ var createGitlabJobs_1 = __nccwpck_require__(63920);
354515
354673
  var createChildPipeline = function (type, trigger, config) {
354516
354674
  return __awaiter(void 0, void 0, void 0, function () {
354517
- var components, jobs, allEnvs, stages, pipeline;
354518
- return __generator(this, function (_a) {
354519
- switch (_a.label) {
354675
+ var jobs, allEnvs, stages, pipeline;
354676
+ var _a;
354677
+ return __generator(this, function (_b) {
354678
+ switch (_b.label) {
354520
354679
  case 0:
354521
- components = Object.keys(config.components);
354522
- return [4 /*yield*/, components.reduce(function (acc, componentName) {
354523
- return __awaiter(void 0, void 0, void 0, function () {
354524
- var envs, _a, _b;
354525
- return __generator(this, function (_c) {
354526
- switch (_c.label) {
354527
- case 0:
354528
- envs = (0, config_1.getAllEnvsByTrigger)(config, componentName, trigger);
354529
- _a = [{}];
354530
- return [4 /*yield*/, acc];
354531
- case 1:
354532
- _b = [__assign.apply(void 0, _a.concat([_c.sent()]))];
354533
- return [4 /*yield*/, (0, createJobs_1.createJobs)(type, envs, config, componentName, trigger)];
354534
- case 2:
354535
- return [2 /*return*/, __assign.apply(void 0, _b.concat([_c.sent()]))];
354536
- }
354537
- });
354538
- });
354539
- }, Promise.resolve({}))];
354680
+ return [4 /*yield*/, (0, createAllJobs_1.createAllJobs)(config, trigger)];
354540
354681
  case 1:
354541
- jobs = _a.sent();
354682
+ jobs = _b.sent();
354542
354683
  allEnvs = (0, config_1.getAllEnvsInAllComponents)(config);
354543
354684
  stages = jobs_1.BASE_STAGES.reduce(function (acc, baseStage) {
354544
354685
  return __spreadArray(__spreadArray(__spreadArray([], __read(acc), false), [baseStage], false), __read(allEnvs.map(function (e) {
354545
354686
  return "".concat(baseStage, " ").concat(e);
354546
354687
  })), false);
354547
354688
  }, []);
354548
- if (type === "gitlab") {
354549
- pipeline = {
354550
- image: (0, runner_1.getRunnerImage)("jobs-default"),
354551
- variables: {
354552
- FF_USE_FASTZIP: "true"
354553
- },
354554
- workflow: {
354555
- rules: rules_1.RULES_ALWAYS
354556
- },
354557
- stages: stages,
354558
- jobs: jobs
354559
- };
354560
- return [2 /*return*/, pipeline];
354561
- }
354689
+ if (!(type === "gitlab")) return [3 /*break*/, 3];
354690
+ _a = {
354691
+ image: (0, runner_1.getRunnerImage)("jobs-default"),
354692
+ variables: {
354693
+ FF_USE_FASTZIP: "true"
354694
+ },
354695
+ workflow: {
354696
+ rules: rules_1.RULES_ALWAYS
354697
+ },
354698
+ stages: stages
354699
+ };
354700
+ return [4 /*yield*/, (0, createGitlabJobs_1.createGitlabJobs)(jobs)];
354701
+ case 2:
354702
+ pipeline = (_a.jobs = _b.sent(), _a);
354703
+ return [2 /*return*/, pipeline];
354704
+ case 3:
354562
354705
  throw new Error("".concat(type, " is not supported"));
354563
354706
  }
354564
354707
  });
@@ -354568,7 +354711,7 @@ exports.createChildPipeline = createChildPipeline;
354568
354711
 
354569
354712
  /***/ }),
354570
354713
 
354571
- /***/ 57726:
354714
+ /***/ 80962:
354572
354715
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
354573
354716
 
354574
354717
  "use strict";
@@ -354739,14 +354882,12 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
354739
354882
  return to.concat(ar || Array.prototype.slice.call(from));
354740
354883
  };
354741
354884
  exports.__esModule = true;
354742
- exports.createJobs = void 0;
354885
+ exports.createJobsForComponent = void 0;
354743
354886
  var lodash_1 = __nccwpck_require__(23255);
354744
354887
  var build_1 = __nccwpck_require__(73760);
354745
354888
  var context_1 = __nccwpck_require__(22041);
354746
354889
  var deploy_1 = __nccwpck_require__(90223);
354747
- var utils_1 = __nccwpck_require__(37461);
354748
354890
  var getCommitInfo_1 = __nccwpck_require__(5923);
354749
- var makeGitlabJob_1 = __nccwpck_require__(15715);
354750
354891
  var packageManager_1 = __nccwpck_require__(69168);
354751
354892
  var injectDefaultVarsInCustomJobs = function (context, jobs) {
354752
354893
  return jobs.map(function (_a) {
@@ -354774,71 +354915,9 @@ var createRawJobs = function (context) {
354774
354915
  var customJobs = getCustomJobs(context);
354775
354916
  return __spreadArray(__spreadArray(__spreadArray([], __read(buildJobs), false), __read(deployJobs), false), __read(customJobs), false);
354776
354917
  };
354777
- var getFullJobName = function (name, componentName, env) {
354778
- if (env) {
354779
- return "".concat(componentName, " ").concat(name, " | ").concat(env, " ");
354780
- }
354781
- return "".concat(componentName, " ").concat(name);
354782
- };
354783
- var getFullReferencedJobName = function (referencedJobName, componentName, env, allRawJobs) {
354784
- var referencedJob = allRawJobs.find(function (j) {
354785
- return j.name === referencedJobName;
354786
- });
354787
- if (!referencedJob) {
354788
- throw new Error("unknown job referenced: " + referencedJobName);
354789
- }
354790
- var envToSet = referencedJob.envMode !== "none" ? env : null;
354791
- return getFullJobName(referencedJobName, componentName, envToSet);
354792
- };
354793
- // replaces references to other jobs with the full name
354794
- // the full name contains the componentname and the env name (if any)
354795
- var replaceReferences = function (job, componentName, env, allRawJobs) {
354796
- var _a, _b, _c;
354797
- var stage = job.envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
354798
- var cleanedNeeds = __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read((_b = job.needsOtherComponent) !== null && _b !== void 0 ? _b : []), false);
354799
- var needs = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
354800
- var _a;
354801
- return (0, lodash_1.isObject)(n) ? {
354802
- job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allRawJobs),
354803
- artifacts: n.artifacts
354804
- } : getFullReferencedJobName(n, componentName, env, allRawJobs);
354805
- });
354806
- return __assign(__assign({}, job), {
354807
- stage: stage,
354808
- needs: needs,
354809
- environment: ((_c = job.environment) === null || _c === void 0 ? void 0 : _c.on_stop) ? __assign(__assign({}, job.environment), {
354810
- on_stop: getFullReferencedJobName(job.environment.on_stop, componentName, env, allRawJobs)
354811
- }) : job.environment
354812
- });
354813
- };
354814
- // this can be removed once https://gitlab.com/gitlab-org/gitlab/-/issues/220758 is resolved
354815
- var addStageNeeds = function (jobs) {
354816
- // when a job defines needsStages, we add these as needs
354817
- return jobs.map(function (job) {
354818
- var _a;
354819
- if (!job.needsStages || job.needsStages.length === 0) {
354820
- return job;
354821
- }
354822
- var neededJobs = jobs.map(function (j) {
354823
- var _a, _b;
354824
- var neededStage = (_a = job.needsStages) === null || _a === void 0 ? void 0 : _a.find(function (s) {
354825
- return j.stage === s.stage;
354826
- });
354827
- if (neededStage) {
354828
- return {
354829
- job: j.name,
354830
- artifacts: (_b = neededStage.artifacts) !== null && _b !== void 0 ? _b : false
354831
- };
354832
- }
354833
- }).filter(utils_1.notNil);
354834
- return __assign(__assign({}, job), {
354835
- needs: __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read(neededJobs), false)
354836
- });
354837
- });
354838
- };
354839
- var createJobs = function (type, envs, config, componentName, trigger) {
354918
+ var createJobsForComponent = function (config, componentName, env, trigger) {
354840
354919
  return __awaiter(void 0, void 0, void 0, function () {
354841
- var commitInfo, _a, packageManagerInfo;
354920
+ var commitInfo, _a, packageManagerInfo, context;
354842
354921
  return __generator(this, function (_b) {
354843
354922
  switch (_b.label) {
354844
354923
  case 0:
@@ -354851,47 +354930,19 @@ var createJobs = function (type, envs, config, componentName, trigger) {
354851
354930
  return [4 /*yield*/, (0, packageManager_1.getPackageManagerInfo)(config, componentName)];
354852
354931
  case 2:
354853
354932
  packageManagerInfo = _b.sent();
354854
- return [2 /*return*/, envs.reduce(function (acc, env) {
354855
- return __awaiter(void 0, void 0, void 0, function () {
354856
- var context, jobs, result, _a, _b, _c, _d, _e;
354857
- return __generator(this, function (_f) {
354858
- switch (_f.label) {
354859
- case 0:
354860
- return [4 /*yield*/, (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo)];
354861
- case 1:
354862
- context = _f.sent();
354863
- jobs = addStageNeeds(createRawJobs(context));
354864
- _a = [{}];
354865
- return [4 /*yield*/, acc];
354866
- case 2:
354867
- _b = [__assign.apply(void 0, _a.concat([_f.sent()]))];
354868
- _d = (_c = jobs).reduce;
354869
- _e = [function (acc, job) {
354870
- var _a;
354871
- var jobWithResolvedReferences = replaceReferences(job, componentName, env, jobs);
354872
- var jobName = getFullJobName(job.name, componentName, job.envMode !== "none" ? env : undefined);
354873
- if (type === "gitlab") {
354874
- return __assign(__assign({}, acc), (_a = {}, _a[jobName] = (0, makeGitlabJob_1.makeGitlabJob)(jobWithResolvedReferences), _a));
354875
- }
354876
- throw new Error("not supported");
354877
- }];
354878
- return [4 /*yield*/, Promise.resolve({})];
354879
- case 3:
354880
- result = __assign.apply(void 0, _b.concat([_d.apply(_c, _e.concat([_f.sent()]))]));
354881
- return [2 /*return*/, result];
354882
- }
354883
- });
354884
- });
354885
- }, {})];
354933
+ return [4 /*yield*/, (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo)];
354934
+ case 3:
354935
+ context = _b.sent();
354936
+ return [2 /*return*/, createRawJobs(context)];
354886
354937
  }
354887
354938
  });
354888
354939
  });
354889
354940
  };
354890
- exports.createJobs = createJobs;
354941
+ exports.createJobsForComponent = createJobsForComponent;
354891
354942
 
354892
354943
  /***/ }),
354893
354944
 
354894
- /***/ 15715:
354945
+ /***/ 63920:
354895
354946
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
354896
354947
 
354897
354948
  "use strict";
@@ -354907,6 +354958,121 @@ var __assign = this && this.__assign || function () {
354907
354958
  };
354908
354959
  return __assign.apply(this, arguments);
354909
354960
  };
354961
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
354962
+ function adopt(value) {
354963
+ return value instanceof P ? value : new P(function (resolve) {
354964
+ resolve(value);
354965
+ });
354966
+ }
354967
+ return new (P || (P = Promise))(function (resolve, reject) {
354968
+ function fulfilled(value) {
354969
+ try {
354970
+ step(generator.next(value));
354971
+ } catch (e) {
354972
+ reject(e);
354973
+ }
354974
+ }
354975
+ function rejected(value) {
354976
+ try {
354977
+ step(generator["throw"](value));
354978
+ } catch (e) {
354979
+ reject(e);
354980
+ }
354981
+ }
354982
+ function step(result) {
354983
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
354984
+ }
354985
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
354986
+ });
354987
+ };
354988
+ var __generator = this && this.__generator || function (thisArg, body) {
354989
+ var _ = {
354990
+ label: 0,
354991
+ sent: function () {
354992
+ if (t[0] & 1) throw t[1];
354993
+ return t[1];
354994
+ },
354995
+ trys: [],
354996
+ ops: []
354997
+ },
354998
+ f,
354999
+ y,
355000
+ t,
355001
+ g;
355002
+ return g = {
355003
+ next: verb(0),
355004
+ "throw": verb(1),
355005
+ "return": verb(2)
355006
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
355007
+ return this;
355008
+ }), g;
355009
+ function verb(n) {
355010
+ return function (v) {
355011
+ return step([n, v]);
355012
+ };
355013
+ }
355014
+ function step(op) {
355015
+ if (f) throw new TypeError("Generator is already executing.");
355016
+ while (_) try {
355017
+ 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;
355018
+ if (y = 0, t) op = [op[0] & 2, t.value];
355019
+ switch (op[0]) {
355020
+ case 0:
355021
+ case 1:
355022
+ t = op;
355023
+ break;
355024
+ case 4:
355025
+ _.label++;
355026
+ return {
355027
+ value: op[1],
355028
+ done: false
355029
+ };
355030
+ case 5:
355031
+ _.label++;
355032
+ y = op[1];
355033
+ op = [0];
355034
+ continue;
355035
+ case 7:
355036
+ op = _.ops.pop();
355037
+ _.trys.pop();
355038
+ continue;
355039
+ default:
355040
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
355041
+ _ = 0;
355042
+ continue;
355043
+ }
355044
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
355045
+ _.label = op[1];
355046
+ break;
355047
+ }
355048
+ if (op[0] === 6 && _.label < t[1]) {
355049
+ _.label = t[1];
355050
+ t = op;
355051
+ break;
355052
+ }
355053
+ if (t && _.label < t[2]) {
355054
+ _.label = t[2];
355055
+ _.ops.push(op);
355056
+ break;
355057
+ }
355058
+ if (t[2]) _.ops.pop();
355059
+ _.trys.pop();
355060
+ continue;
355061
+ }
355062
+ op = body.call(thisArg, _);
355063
+ } catch (e) {
355064
+ op = [6, e];
355065
+ y = 0;
355066
+ } finally {
355067
+ f = t = 0;
355068
+ }
355069
+ if (op[0] & 5) throw op[1];
355070
+ return {
355071
+ value: op[0] ? op[1] : void 0,
355072
+ done: true
355073
+ };
355074
+ }
355075
+ };
354910
355076
  var __rest = this && this.__rest || function (s, e) {
354911
355077
  var t = {};
354912
355078
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -354947,29 +355113,99 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
354947
355113
  return to.concat(ar || Array.prototype.slice.call(from));
354948
355114
  };
354949
355115
  exports.__esModule = true;
354950
- exports.makeGitlabJob = void 0;
355116
+ exports.createGitlabJobs = exports.makeGitlabJob = void 0;
354951
355117
  var lodash_1 = __nccwpck_require__(23255);
354952
355118
  var defaults_1 = __nccwpck_require__(87383);
355119
+ var getFullJobName = function (name, componentName, env) {
355120
+ if (env) {
355121
+ return "".concat(componentName, " ").concat(name, " | ").concat(env, " ");
355122
+ }
355123
+ return "".concat(componentName, " ").concat(name);
355124
+ };
355125
+ var getFullReferencedJobName = function (referencedJobName, componentName, env, allJobs) {
355126
+ var _a, _b;
355127
+ var referencedJob = (_b = (_a = allJobs[componentName]) === null || _a === void 0 ? void 0 : _a[env]) === null || _b === void 0 ? void 0 : _b.find(function (j) {
355128
+ return j.name === referencedJobName;
355129
+ });
355130
+ if (!referencedJob) {
355131
+ throw new Error("unknown job referenced: '".concat(referencedJobName, "' from '").concat(env, ":").concat(componentName, "'"));
355132
+ }
355133
+ var envToSet = referencedJob.envMode !== "none" ? env : null;
355134
+ return getFullJobName(referencedJobName, componentName, envToSet);
355135
+ };
354953
355136
  var getJobName = function (need) {
354954
355137
  return (0, lodash_1.isObject)(need) ? need.job : need;
354955
355138
  };
354956
- var makeGitlabJob = function (_a) {
355139
+ var makeGitlabJob = function (componentName, env, _a, allJobs) {
355140
+ var _b;
354957
355141
  var envMode = _a.envMode,
354958
355142
  needsStages = _a.needsStages,
354959
355143
  needsOtherComponent = _a.needsOtherComponent,
354960
355144
  name = _a.name,
354961
355145
  needs = _a.needs,
354962
- rest = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
354963
- return __assign(__assign({}, rest), {
355146
+ job = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
355147
+ var stage = envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
355148
+ var needsFromStages = needsStages === null || needsStages === void 0 ? void 0 : needsStages.flatMap(function (n) {
355149
+ var _a, _b, _c, _d;
355150
+ var referencedComponentName = componentName;
355151
+ 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) {
355152
+ return j.stage === n.stage;
355153
+ })) === null || _c === void 0 ? void 0 : _c.map(function (j) {
355154
+ return j.name;
355155
+ })) !== null && _d !== void 0 ? _d : [];
355156
+ return allJobNamesFromThatStage.map(function (job) {
355157
+ var _a;
355158
+ return {
355159
+ job: job,
355160
+ artifacts: (_a = n.artifacts) !== null && _a !== void 0 ? _a : false,
355161
+ componentName: referencedComponentName
355162
+ };
355163
+ });
355164
+ });
355165
+ 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);
355166
+ var gitlabNeeds = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
355167
+ var _a;
355168
+ return (0, lodash_1.isObject)(n) ? {
355169
+ job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allJobs),
355170
+ artifacts: n.artifacts
355171
+ } : getFullReferencedJobName(n, componentName, env, allJobs);
355172
+ }).sort(function (a, b) {
355173
+ return getJobName(a).localeCompare(getJobName(b));
355174
+ });
355175
+ var fullJobName = getFullJobName(name, componentName, envMode !== "none" ? env : undefined);
355176
+ var gitlabJob = __assign(__assign({}, job), {
355177
+ stage: stage,
355178
+ environment: ((_b = job.environment) === null || _b === void 0 ? void 0 : _b.on_stop) ? __assign(__assign({}, job.environment), {
355179
+ on_stop: getFullReferencedJobName(job.environment.on_stop, componentName, env, allJobs)
355180
+ }) : job.environment,
354964
355181
  // sort in a predictable manner for snapshot tests
354965
- needs: needs ? __spreadArray([], __read(needs), false).sort(function (a, b) {
354966
- return getJobName(a).localeCompare(getJobName(b));
354967
- }) : undefined,
355182
+ needs: gitlabNeeds,
354968
355183
  retry: defaults_1.BASE_RETRY,
354969
355184
  interruptible: true
354970
355185
  });
355186
+ return [fullJobName, gitlabJob];
354971
355187
  };
354972
355188
  exports.makeGitlabJob = makeGitlabJob;
355189
+ var createGitlabJobs = function (allJobs) {
355190
+ return __awaiter(void 0, void 0, void 0, function () {
355191
+ return __generator(this, function (_a) {
355192
+ return [2 /*return*/, Object.keys(allJobs).reduce(function (accForComponents, componentName) {
355193
+ var componentJobs = allJobs[componentName];
355194
+ return __assign(__assign({}, accForComponents), Object.keys(componentJobs).reduce(function (accForEnvs, env) {
355195
+ var jobs = componentJobs[env];
355196
+ return __assign(__assign({}, accForEnvs), jobs.reduce(function (accForJobs, job) {
355197
+ var _a;
355198
+ var _b = __read((0, exports.makeGitlabJob)(componentName, env, job, allJobs), 2),
355199
+ fullJobName = _b[0],
355200
+ gitlabJob = _b[1];
355201
+ return __assign(__assign({}, accForJobs), (_a = {}, _a[fullJobName] = gitlabJob, _a));
355202
+ }, {}));
355203
+ }, {}));
355204
+ }, {})];
355205
+ });
355206
+ });
355207
+ };
355208
+ exports.createGitlabJobs = createGitlabJobs;
354973
355209
 
354974
355210
  /***/ }),
354975
355211
 
@@ -354996,7 +355232,7 @@ var __exportStar = this && this.__exportStar || function (m, exports) {
354996
355232
  };
354997
355233
  exports.__esModule = true;
354998
355234
  __exportStar(__nccwpck_require__(78974), exports);
354999
- __exportStar(__nccwpck_require__(57726), exports);
355235
+ __exportStar(__nccwpck_require__(80962), exports);
355000
355236
 
355001
355237
  /***/ }),
355002
355238