@catladder/cli 0.0.0-kube-command-59ed84cc → 0.0.0-lintstaged-7b3be981

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.
@@ -39053,18 +39053,22 @@ var requiresDockerBuild = function (context) {
39053
39053
  return false;
39054
39054
  };
39055
39055
  exports.requiresDockerBuild = requiresDockerBuild;
39056
+ var getDockerBaseVariables = function () {
39057
+ return {
39058
+ DOCKER_HOST: "tcp://0.0.0.0:2375",
39059
+ DOCKER_TLS_CERTDIR: "",
39060
+ DOCKER_DRIVER: "overlay2",
39061
+ DOCKER_BUILDKIT: "1"
39062
+ };
39063
+ };
39056
39064
  var getDockerBuildVariables = function (context) {
39057
39065
  var _a, _b, _c, _d;
39058
- return __assign(__assign(__assign({}, DOCKER_RUNNER_BUILD_VARIABLES), {
39059
- DOCKER_BUILDKIT: "1",
39066
+ return __assign(__assign(__assign(__assign({}, DOCKER_RUNNER_BUILD_VARIABLES), {
39060
39067
  DOCKERFILE_ADDITIONS: (_b = (_a = context.componentConfig.build.docker) === null || _a === void 0 ? void 0 : _a.additionsBegin) === null || _b === void 0 ? void 0 : _b.join("\n"),
39061
39068
  DOCKERFILE_ADDITIONS_END: (_d = (_c = context.componentConfig.build.docker) === null || _c === void 0 ? void 0 : _c.additionsEnd) === null || _d === void 0 ? void 0 : _d.join("\n"),
39062
39069
  APP_DIR: context.componentConfig.dir,
39063
- DOCKER_HOST: "tcp://0.0.0.0:2375",
39064
- DOCKER_TLS_CERTDIR: "",
39065
- DOCKER_DIR: ".",
39066
- DOCKER_DRIVER: "overlay2"
39067
- }), (0, exports.getDockerImageVariables)(context));
39070
+ DOCKER_DIR: "."
39071
+ }), getDockerBaseVariables()), (0, exports.getDockerImageVariables)(context));
39068
39072
  };
39069
39073
  exports.getDockerBuildVariables = getDockerBuildVariables;
39070
39074
  exports.DOCKER_BUILD_JOB_NAME = "🔨 docker";
@@ -39075,7 +39079,7 @@ var getDockerJobBaseProps = function (context) {
39075
39079
  name: "docker:20-dind",
39076
39080
  command: ["--tls=false"]
39077
39081
  }],
39078
- variables: (0, exports.getDockerBuildVariables)(context)
39082
+ variables: getDockerBaseVariables()
39079
39083
  };
39080
39084
  };
39081
39085
  exports.getDockerJobBaseProps = getDockerJobBaseProps;
@@ -39088,7 +39092,9 @@ var createDockerBuildJobBase = function (context, _a) {
39088
39092
  stage: "build"
39089
39093
  }, (0, exports.getDockerJobBaseProps)(context)), {
39090
39094
  script: script || []
39091
- }), def);
39095
+ }), {
39096
+ variables: (0, exports.getDockerBuildVariables)(context)
39097
+ }, def);
39092
39098
  };
39093
39099
  exports.createDockerBuildJobBase = createDockerBuildJobBase;
39094
39100
  exports.gitlabDockerLogin = "docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY";
@@ -39737,29 +39743,25 @@ exports.createRailsBuildJobs = void 0;
39737
39743
  var types_1 = __nccwpck_require__(1197);
39738
39744
  var docker_1 = __nccwpck_require__(3219);
39739
39745
  var createRailsBuildJobs = function (context) {
39740
- var _a, _b, _c, _d, _e, _f;
39746
+ var _a, _b, _c;
39741
39747
  var buildConfig = context.componentConfig.build;
39742
39748
  if (!(0, types_1.isOfBuildType)(buildConfig, "rails")) {
39743
39749
  // should not happen
39744
39750
  throw new Error("build type is not rails");
39745
39751
  }
39746
39752
  var cnbConf = buildConfig.cnbBuilder;
39747
- // backwards compatabilty with CNB_ENV_VARS
39748
- // TODO: remove when all projects are migrated
39749
- 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) {
39750
- return "--env '".concat(v, "'");
39751
- })) !== 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) {
39752
39754
  var _b = __read(_a, 2),
39753
39755
  k = _b[0],
39754
39756
  v = _b[1];
39755
39757
  return "--env '".concat(k).concat(v ? "=".concat(v) : "", "'");
39756
- });
39758
+ }).join(" ");
39757
39759
  return [(0, docker_1.createDockerBuildJobBase)(context, {
39758
39760
  variables: context.componentConfig.build.extraVars,
39759
39761
  // custom script
39760
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",
39761
39763
  // replace private git ssh gem sources with https to make bundler with credentials via env var work
39762
- "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 : "")]
39763
39765
  })];
39764
39766
  };
39765
39767
  exports.createRailsBuildJobs = createRailsBuildJobs;
@@ -40106,7 +40108,7 @@ exports.readConfigSync = readConfigSync;
40106
40108
 
40107
40109
  exports.__esModule = true;
40108
40110
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
40109
- exports.PIPELINE_IMAGE_TAG = "kube-command-59ed84cc" || 0;
40111
+ exports.PIPELINE_IMAGE_TAG = "lintstaged-7b3be981" || 0;
40110
40112
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
40111
40113
 
40112
40114
  /***/ }),
@@ -43005,22 +43007,183 @@ exports.getBaseCommitInfo = getBaseCommitInfo;
43005
43007
 
43006
43008
  /***/ }),
43007
43009
 
43008
- /***/ 8974:
43010
+ /***/ 7052:
43009
43011
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
43010
43012
 
43011
43013
  "use strict";
43012
43014
 
43013
43015
 
43014
- var __assign = this && this.__assign || function () {
43015
- __assign = Object.assign || function (t) {
43016
- for (var s, i = 1, n = arguments.length; i < n; i++) {
43017
- s = arguments[i];
43018
- 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
+ }
43019
43029
  }
43020
- return t;
43021
- };
43022
- 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
+ });
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
+ }
43023
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
+
43024
43187
  var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
43025
43188
  function adopt(value) {
43026
43189
  return value instanceof P ? value : new P(function (resolve) {
@@ -43173,54 +43336,40 @@ var config_1 = __nccwpck_require__(3138);
43173
43336
  var rules_1 = __nccwpck_require__(2020);
43174
43337
  var runner_1 = __nccwpck_require__(5071);
43175
43338
  var jobs_1 = __nccwpck_require__(2339);
43176
- var createJobs_1 = __nccwpck_require__(7726);
43339
+ var createAllJobs_1 = __nccwpck_require__(7052);
43340
+ var createGitlabJobs_1 = __nccwpck_require__(3920);
43177
43341
  var createChildPipeline = function (type, trigger, config) {
43178
43342
  return __awaiter(void 0, void 0, void 0, function () {
43179
- var components, jobs, allEnvs, stages, pipeline;
43180
- return __generator(this, function (_a) {
43181
- switch (_a.label) {
43343
+ var jobs, allEnvs, stages, pipeline;
43344
+ var _a;
43345
+ return __generator(this, function (_b) {
43346
+ switch (_b.label) {
43182
43347
  case 0:
43183
- components = Object.keys(config.components);
43184
- return [4 /*yield*/, components.reduce(function (acc, componentName) {
43185
- return __awaiter(void 0, void 0, void 0, function () {
43186
- var envs, _a, _b;
43187
- return __generator(this, function (_c) {
43188
- switch (_c.label) {
43189
- case 0:
43190
- envs = (0, config_1.getAllEnvsByTrigger)(config, componentName, trigger);
43191
- _a = [{}];
43192
- return [4 /*yield*/, acc];
43193
- case 1:
43194
- _b = [__assign.apply(void 0, _a.concat([_c.sent()]))];
43195
- return [4 /*yield*/, (0, createJobs_1.createJobs)(type, envs, config, componentName, trigger)];
43196
- case 2:
43197
- return [2 /*return*/, __assign.apply(void 0, _b.concat([_c.sent()]))];
43198
- }
43199
- });
43200
- });
43201
- }, Promise.resolve({}))];
43348
+ return [4 /*yield*/, (0, createAllJobs_1.createAllJobs)(config, trigger)];
43202
43349
  case 1:
43203
- jobs = _a.sent();
43350
+ jobs = _b.sent();
43204
43351
  allEnvs = (0, config_1.getAllEnvsInAllComponents)(config);
43205
43352
  stages = jobs_1.BASE_STAGES.reduce(function (acc, baseStage) {
43206
43353
  return __spreadArray(__spreadArray(__spreadArray([], __read(acc), false), [baseStage], false), __read(allEnvs.map(function (e) {
43207
43354
  return "".concat(baseStage, " ").concat(e);
43208
43355
  })), false);
43209
43356
  }, []);
43210
- if (type === "gitlab") {
43211
- pipeline = {
43212
- image: (0, runner_1.getRunnerImage)("jobs-default"),
43213
- variables: {
43214
- FF_USE_FASTZIP: "true"
43215
- },
43216
- workflow: {
43217
- rules: rules_1.RULES_ALWAYS
43218
- },
43219
- stages: stages,
43220
- jobs: jobs
43221
- };
43222
- return [2 /*return*/, pipeline];
43223
- }
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:
43224
43373
  throw new Error("".concat(type, " is not supported"));
43225
43374
  }
43226
43375
  });
@@ -43230,7 +43379,7 @@ exports.createChildPipeline = createChildPipeline;
43230
43379
 
43231
43380
  /***/ }),
43232
43381
 
43233
- /***/ 7726:
43382
+ /***/ 962:
43234
43383
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
43235
43384
 
43236
43385
  "use strict";
@@ -43401,14 +43550,12 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
43401
43550
  return to.concat(ar || Array.prototype.slice.call(from));
43402
43551
  };
43403
43552
  exports.__esModule = true;
43404
- exports.createJobs = void 0;
43553
+ exports.createJobsForComponent = void 0;
43405
43554
  var lodash_1 = __nccwpck_require__(3255);
43406
43555
  var build_1 = __nccwpck_require__(3760);
43407
43556
  var context_1 = __nccwpck_require__(2041);
43408
43557
  var deploy_1 = __nccwpck_require__(223);
43409
- var utils_1 = __nccwpck_require__(7461);
43410
43558
  var getCommitInfo_1 = __nccwpck_require__(5923);
43411
- var makeGitlabJob_1 = __nccwpck_require__(5715);
43412
43559
  var packageManager_1 = __nccwpck_require__(9168);
43413
43560
  var injectDefaultVarsInCustomJobs = function (context, jobs) {
43414
43561
  return jobs.map(function (_a) {
@@ -43436,71 +43583,9 @@ var createRawJobs = function (context) {
43436
43583
  var customJobs = getCustomJobs(context);
43437
43584
  return __spreadArray(__spreadArray(__spreadArray([], __read(buildJobs), false), __read(deployJobs), false), __read(customJobs), false);
43438
43585
  };
43439
- var getFullJobName = function (name, componentName, env) {
43440
- if (env) {
43441
- return "".concat(componentName, " ").concat(name, " | ").concat(env, " ");
43442
- }
43443
- return "".concat(componentName, " ").concat(name);
43444
- };
43445
- var getFullReferencedJobName = function (referencedJobName, componentName, env, allRawJobs) {
43446
- var referencedJob = allRawJobs.find(function (j) {
43447
- return j.name === referencedJobName;
43448
- });
43449
- if (!referencedJob) {
43450
- throw new Error("unknown job referenced: " + referencedJobName);
43451
- }
43452
- var envToSet = referencedJob.envMode !== "none" ? env : null;
43453
- return getFullJobName(referencedJobName, componentName, envToSet);
43454
- };
43455
- // replaces references to other jobs with the full name
43456
- // the full name contains the componentname and the env name (if any)
43457
- var replaceReferences = function (job, componentName, env, allRawJobs) {
43458
- var _a, _b, _c;
43459
- var stage = job.envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
43460
- var cleanedNeeds = __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read((_b = job.needsOtherComponent) !== null && _b !== void 0 ? _b : []), false);
43461
- var needs = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
43462
- var _a;
43463
- return (0, lodash_1.isObject)(n) ? {
43464
- job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allRawJobs),
43465
- artifacts: n.artifacts
43466
- } : getFullReferencedJobName(n, componentName, env, allRawJobs);
43467
- });
43468
- return __assign(__assign({}, job), {
43469
- stage: stage,
43470
- needs: needs,
43471
- environment: ((_c = job.environment) === null || _c === void 0 ? void 0 : _c.on_stop) ? __assign(__assign({}, job.environment), {
43472
- on_stop: getFullReferencedJobName(job.environment.on_stop, componentName, env, allRawJobs)
43473
- }) : job.environment
43474
- });
43475
- };
43476
- // this can be removed once https://gitlab.com/gitlab-org/gitlab/-/issues/220758 is resolved
43477
- var addStageNeeds = function (jobs) {
43478
- // when a job defines needsStages, we add these as needs
43479
- return jobs.map(function (job) {
43480
- var _a;
43481
- if (!job.needsStages || job.needsStages.length === 0) {
43482
- return job;
43483
- }
43484
- var neededJobs = jobs.map(function (j) {
43485
- var _a, _b;
43486
- var neededStage = (_a = job.needsStages) === null || _a === void 0 ? void 0 : _a.find(function (s) {
43487
- return j.stage === s.stage;
43488
- });
43489
- if (neededStage) {
43490
- return {
43491
- job: j.name,
43492
- artifacts: (_b = neededStage.artifacts) !== null && _b !== void 0 ? _b : false
43493
- };
43494
- }
43495
- }).filter(utils_1.notNil);
43496
- return __assign(__assign({}, job), {
43497
- needs: __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read(neededJobs), false)
43498
- });
43499
- });
43500
- };
43501
- var createJobs = function (type, envs, config, componentName, trigger) {
43586
+ var createJobsForComponent = function (config, componentName, env, trigger) {
43502
43587
  return __awaiter(void 0, void 0, void 0, function () {
43503
- var commitInfo, _a, packageManagerInfo;
43588
+ var commitInfo, _a, packageManagerInfo, context;
43504
43589
  return __generator(this, function (_b) {
43505
43590
  switch (_b.label) {
43506
43591
  case 0:
@@ -43513,47 +43598,19 @@ var createJobs = function (type, envs, config, componentName, trigger) {
43513
43598
  return [4 /*yield*/, (0, packageManager_1.getPackageManagerInfo)(config, componentName)];
43514
43599
  case 2:
43515
43600
  packageManagerInfo = _b.sent();
43516
- return [2 /*return*/, envs.reduce(function (acc, env) {
43517
- return __awaiter(void 0, void 0, void 0, function () {
43518
- var context, jobs, result, _a, _b, _c, _d, _e;
43519
- return __generator(this, function (_f) {
43520
- switch (_f.label) {
43521
- case 0:
43522
- return [4 /*yield*/, (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo)];
43523
- case 1:
43524
- context = _f.sent();
43525
- jobs = addStageNeeds(createRawJobs(context));
43526
- _a = [{}];
43527
- return [4 /*yield*/, acc];
43528
- case 2:
43529
- _b = [__assign.apply(void 0, _a.concat([_f.sent()]))];
43530
- _d = (_c = jobs).reduce;
43531
- _e = [function (acc, job) {
43532
- var _a;
43533
- var jobWithResolvedReferences = replaceReferences(job, componentName, env, jobs);
43534
- var jobName = getFullJobName(job.name, componentName, job.envMode !== "none" ? env : undefined);
43535
- if (type === "gitlab") {
43536
- return __assign(__assign({}, acc), (_a = {}, _a[jobName] = (0, makeGitlabJob_1.makeGitlabJob)(jobWithResolvedReferences), _a));
43537
- }
43538
- throw new Error("not supported");
43539
- }];
43540
- return [4 /*yield*/, Promise.resolve({})];
43541
- case 3:
43542
- result = __assign.apply(void 0, _b.concat([_d.apply(_c, _e.concat([_f.sent()]))]));
43543
- return [2 /*return*/, result];
43544
- }
43545
- });
43546
- });
43547
- }, {})];
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)];
43548
43605
  }
43549
43606
  });
43550
43607
  });
43551
43608
  };
43552
- exports.createJobs = createJobs;
43609
+ exports.createJobsForComponent = createJobsForComponent;
43553
43610
 
43554
43611
  /***/ }),
43555
43612
 
43556
- /***/ 5715:
43613
+ /***/ 3920:
43557
43614
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
43558
43615
 
43559
43616
  "use strict";
@@ -43569,6 +43626,121 @@ var __assign = this && this.__assign || function () {
43569
43626
  };
43570
43627
  return __assign.apply(this, arguments);
43571
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
+ };
43572
43744
  var __rest = this && this.__rest || function (s, e) {
43573
43745
  var t = {};
43574
43746
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -43609,29 +43781,99 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
43609
43781
  return to.concat(ar || Array.prototype.slice.call(from));
43610
43782
  };
43611
43783
  exports.__esModule = true;
43612
- exports.makeGitlabJob = void 0;
43784
+ exports.createGitlabJobs = exports.makeGitlabJob = void 0;
43613
43785
  var lodash_1 = __nccwpck_require__(3255);
43614
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
+ };
43615
43804
  var getJobName = function (need) {
43616
43805
  return (0, lodash_1.isObject)(need) ? need.job : need;
43617
43806
  };
43618
- var makeGitlabJob = function (_a) {
43807
+ var makeGitlabJob = function (componentName, env, _a, allJobs) {
43808
+ var _b;
43619
43809
  var envMode = _a.envMode,
43620
43810
  needsStages = _a.needsStages,
43621
43811
  needsOtherComponent = _a.needsOtherComponent,
43622
43812
  name = _a.name,
43623
43813
  needs = _a.needs,
43624
- rest = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
43625
- 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,
43626
43849
  // sort in a predictable manner for snapshot tests
43627
- needs: needs ? __spreadArray([], __read(needs), false).sort(function (a, b) {
43628
- return getJobName(a).localeCompare(getJobName(b));
43629
- }) : undefined,
43850
+ needs: gitlabNeeds,
43630
43851
  retry: defaults_1.BASE_RETRY,
43631
43852
  interruptible: true
43632
43853
  });
43854
+ return [fullJobName, gitlabJob];
43633
43855
  };
43634
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;
43635
43877
 
43636
43878
  /***/ }),
43637
43879
 
@@ -43658,7 +43900,7 @@ var __exportStar = this && this.__exportStar || function (m, exports) {
43658
43900
  };
43659
43901
  exports.__esModule = true;
43660
43902
  __exportStar(__nccwpck_require__(8974), exports);
43661
- __exportStar(__nccwpck_require__(7726), exports);
43903
+ __exportStar(__nccwpck_require__(962), exports);
43662
43904
 
43663
43905
  /***/ }),
43664
43906