@catladder/pipeline 1.10.2 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/build/base/constants.js +1 -1
  2. package/dist/build/base/createBuildJob.d.ts +4 -2
  3. package/dist/build/base/createBuildJob.js +13 -18
  4. package/dist/build/docker.d.ts +6 -3
  5. package/dist/build/docker.js +24 -9
  6. package/dist/build/index.d.ts +2 -2
  7. package/dist/build/node/buildJob.d.ts +2 -2
  8. package/dist/build/node/buildJob.js +26 -13
  9. package/dist/build/node/cache.d.ts +3 -1
  10. package/dist/build/node/cache.js +33 -5
  11. package/dist/build/node/constants.js +2 -2
  12. package/dist/build/node/index.d.ts +4 -4
  13. package/dist/build/node/meteor.d.ts +2 -2
  14. package/dist/build/node/meteor.js +4 -23
  15. package/dist/build/node/testJob.d.ts +2 -2
  16. package/dist/build/node/testJob.js +20 -29
  17. package/dist/build/node/yarn.d.ts +4 -0
  18. package/dist/build/node/yarn.js +10 -3
  19. package/dist/build/tests/storybook.test.js +10 -23
  20. package/dist/build/types.d.ts +6 -0
  21. package/dist/catladder-gitlab.js +33 -2
  22. package/dist/constants.js +1 -1
  23. package/dist/context/index.d.ts +2 -2
  24. package/dist/context/index.js +2 -2
  25. package/dist/deploy/base.d.ts +3 -4
  26. package/dist/deploy/base.js +27 -33
  27. package/dist/deploy/index.d.ts +2 -2
  28. package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
  29. package/dist/deploy/kubernetes/deployJob.js +32 -38
  30. package/dist/pipeline/createChildPipeline.d.ts +2 -11
  31. package/dist/pipeline/createChildPipeline.js +24 -18
  32. package/dist/pipeline/createChildPipeline.test.js +3 -14
  33. package/dist/pipeline/createJobs.d.ts +2 -2
  34. package/dist/pipeline/createJobs.js +29 -23
  35. package/dist/pipeline/gitlab/makeGitlabJob.d.ts +8 -0
  36. package/dist/pipeline/gitlab/makeGitlabJob.js +45 -0
  37. package/dist/pipeline/packageManager.d.ts +2 -0
  38. package/dist/pipeline/{yarnInfo.js → packageManager.js} +69 -8
  39. package/dist/tsconfig.tsbuildinfo +1 -1
  40. package/dist/types/context.d.ts +15 -6
  41. package/dist/types/gitlab-types.d.ts +10 -22
  42. package/dist/types/gitlab-types.js +1 -3
  43. package/dist/types/index.d.ts +2 -1
  44. package/dist/types/index.js +3 -1
  45. package/dist/types/jobs.d.ts +75 -0
  46. package/dist/types/jobs.js +5 -0
  47. package/dist/types/pipeline.d.ts +4 -0
  48. package/dist/types/pipeline.js +3 -0
  49. package/package.json +1 -1
  50. package/src/build/base/constants.ts +1 -1
  51. package/src/build/base/createBuildJob.ts +29 -31
  52. package/src/build/docker.ts +50 -45
  53. package/src/build/index.ts +3 -2
  54. package/src/build/node/buildJob.ts +35 -25
  55. package/src/build/node/cache.ts +30 -5
  56. package/src/build/node/constants.ts +2 -2
  57. package/src/build/node/index.ts +4 -4
  58. package/src/build/node/meteor.ts +10 -18
  59. package/src/build/node/testJob.ts +31 -40
  60. package/src/build/node/yarn.ts +20 -3
  61. package/src/build/tests/storybook.test.ts +4 -2
  62. package/src/build/types.ts +6 -0
  63. package/src/catladder-gitlab.ts +9 -5
  64. package/src/context/index.ts +8 -4
  65. package/src/deploy/base.ts +40 -45
  66. package/src/deploy/index.ts +2 -2
  67. package/src/deploy/kubernetes/deployJob.ts +43 -48
  68. package/src/pipeline/createChildPipeline.test.ts +2 -1
  69. package/src/pipeline/createChildPipeline.ts +23 -21
  70. package/src/pipeline/createJobs.ts +50 -41
  71. package/src/pipeline/gitlab/makeGitlabJob.ts +16 -0
  72. package/src/pipeline/packageManager.ts +99 -0
  73. package/src/types/context.ts +14 -3
  74. package/src/types/gitlab-types.ts +10 -30
  75. package/src/types/index.ts +1 -0
  76. package/src/types/jobs.ts +88 -0
  77. package/src/types/pipeline.ts +11 -0
  78. package/dist/pipeline/yarnInfo.d.ts +0 -2
  79. package/src/pipeline/yarnInfo.ts +0 -54
@@ -183,7 +183,7 @@ var getEnvironment = function (config, componentName, env, commitInfo, skipRefer
183
183
 
184
184
  exports.getEnvironment = getEnvironment;
185
185
 
186
- var createContext = function (config, componentName, env, commitInfo, yarnInfo) {
186
+ var createContext = function (config, componentName, env, commitInfo, packageManagerInfo) {
187
187
  var _a, _b;
188
188
 
189
189
  if (!/^[a-z0-9-]+$/.test(componentName)) {
@@ -214,7 +214,7 @@ var createContext = function (config, componentName, env, commitInfo, yarnInfo)
214
214
  componentName: componentName,
215
215
  environment: (0, exports.getEnvironment)(config, componentName, env, commitInfo),
216
216
  commitInfo: commitInfo,
217
- yarnInfo: yarnInfo
217
+ packageManagerInfo: packageManagerInfo
218
218
  };
219
219
  };
220
220
 
@@ -1,9 +1,8 @@
1
- import { GitlabJob, Context, GitlabJobDef } from "../types";
1
+ import { Context } from "../types";
2
+ import { CatladderJob } from "../types/jobs";
2
3
  export declare const DEPLOY_JOB_NAME = "\uD83D\uDE80 Deploy";
3
4
  export declare const STOP_JOB_NAME = "\uD83D\uDED1 Stop \u26A0\uFE0F";
4
- declare type JobWithoutScript = Omit<GitlabJob, "job"> & {
5
- job: Omit<GitlabJobDef, "script">;
6
- };
5
+ declare type JobWithoutScript = Omit<CatladderJob, "script">;
7
6
  export declare const getBaseDeploymentJob: (context: Context) => JobWithoutScript;
8
7
  export declare const getBaseDeploymentStopJob: (context: Context) => JobWithoutScript;
9
8
  export {};
@@ -49,20 +49,17 @@ var getBaseDeploymentJob = function (context) {
49
49
  stage: "test",
50
50
  artifacts: false
51
51
  }],
52
- job: {
53
- rules: [autoDeploy ? {
54
- when: "on_success"
55
- } : {
56
- when: "manual"
57
- }],
58
- stage: "deploy",
59
- dependencies: [],
60
- variables: __assign({}, DEPLOY_RUNNER_VARIABLES),
61
- environment: __assign(__assign({}, environment), {
62
- on_stop: exports.STOP_JOB_NAME,
63
- auto_stop_in: autoStop
64
- })
65
- }
52
+ rules: [autoDeploy ? {
53
+ when: "on_success"
54
+ } : {
55
+ when: "manual"
56
+ }],
57
+ stage: "deploy",
58
+ variables: __assign({}, DEPLOY_RUNNER_VARIABLES),
59
+ environment: __assign(__assign({}, environment), {
60
+ on_stop: exports.STOP_JOB_NAME,
61
+ auto_stop_in: autoStop
62
+ })
66
63
  };
67
64
  };
68
65
 
@@ -76,25 +73,22 @@ var getBaseDeploymentStopJob = function (context) {
76
73
  return {
77
74
  name: exports.STOP_JOB_NAME,
78
75
  envMode: "stagePerEnv",
79
- job: {
80
- needs: [exports.DEPLOY_JOB_NAME],
81
- rules: [{
82
- "if": "$CI_COMMIT_BRANCH =~ /^[0-9]+\\.([0-9]+|x)\\.x$/",
83
- when: "on_success",
84
- allow_failure: true
85
- }, {
86
- when: "manual",
87
- allow_failure: true
88
- }],
89
- variables: __assign(__assign({}, DEPLOY_RUNNER_VARIABLES), {
90
- GIT_STRATEGY: "none"
91
- }),
92
- stage: "stop",
93
- dependencies: [],
94
- environment: __assign(__assign({}, environment), {
95
- action: "stop"
96
- })
97
- }
76
+ needs: [exports.DEPLOY_JOB_NAME],
77
+ rules: [{
78
+ "if": "$CI_COMMIT_BRANCH =~ /^[0-9]+\\.([0-9]+|x)\\.x$/",
79
+ when: "on_success",
80
+ allow_failure: true
81
+ }, {
82
+ when: "manual",
83
+ allow_failure: true
84
+ }],
85
+ variables: __assign(__assign({}, DEPLOY_RUNNER_VARIABLES), {
86
+ GIT_STRATEGY: "none"
87
+ }),
88
+ stage: "stop",
89
+ environment: __assign(__assign({}, environment), {
90
+ action: "stop"
91
+ })
98
92
  };
99
93
  };
100
94
 
@@ -1,11 +1,11 @@
1
- import { GitlabJobs } from "../types/gitlab-types";
2
1
  import { Context } from "../types/context";
2
+ import { CatladderJob } from "../types/jobs";
3
3
  import { DeployConfig } from "./types";
4
4
  export * from "./kubernetes";
5
5
  export * from "./types";
6
6
  export * from "./utils";
7
7
  export declare type DeployTypes = { [type in DeployConfig["type"]]: {
8
- jobs: (context: Context) => GitlabJobs;
8
+ jobs: (context: Context) => CatladderJob[];
9
9
  defaults: () => Partial<Extract<DeployConfig, {
10
10
  type: type;
11
11
  }>>;
@@ -1,3 +1,3 @@
1
- import { GitlabJobs } from "../../types/gitlab-types";
2
1
  import { Context } from "../../types/context";
3
- export declare const createKubernetesDeployJobs: (context: Context) => GitlabJobs;
2
+ import { CatladderJob } from "../../types/jobs";
3
+ export declare const createKubernetesDeployJobs: (context: Context) => CatladderJob[];
@@ -52,23 +52,23 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
52
52
  exports.__esModule = true;
53
53
  exports.createKubernetesDeployJobs = void 0;
54
54
 
55
- var types_1 = require("../types");
55
+ var js_yaml_1 = require("js-yaml");
56
56
 
57
- var runner_1 = require("../../runner");
57
+ var lodash_1 = require("lodash");
58
58
 
59
- var base_1 = require("../base");
59
+ var __1 = require("../..");
60
60
 
61
- var lodash_1 = require("lodash");
61
+ var runner_1 = require("../../runner");
62
62
 
63
- var js_yaml_1 = require("js-yaml");
63
+ var utils_1 = require("../../utils");
64
64
 
65
- var mongodb_1 = require("./mongodb");
65
+ var base_1 = require("../base");
66
66
 
67
- var cloudsql_1 = require("./cloudsql");
67
+ var types_1 = require("../types");
68
68
 
69
- var __1 = require("../..");
69
+ var cloudsql_1 = require("./cloudsql");
70
70
 
71
- var utils_1 = require("../../utils");
71
+ var mongodb_1 = require("./mongodb");
72
72
 
73
73
  var createKubernetesDeployJobs = function (context) {
74
74
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
@@ -140,43 +140,37 @@ var createKubernetesDeployJobs = function (context) {
140
140
  namespace: context.environment.envVars.KUBE_NAMESPACE
141
141
  };
142
142
  var shared = {
143
- job: {
144
- image: (0, runner_1.getRunnerImage)("kubernetes"),
145
- variables: __assign(__assign({}, context.environment.envVars), {
146
- HELM_EXPERIMENTAL_OCI: "1",
147
- IMAGE_PULL_SECRET: "gitlab-registry-".concat(context.componentName),
148
- KUBE_VALUES: (0, js_yaml_1.dump)(kubeValues, {
149
- lineWidth: -1,
150
- quotingType: "'",
151
- forceQuotes: true
152
- }),
153
- HELM_GITLAB_CHART_NAME: "the-panter-chart",
154
- HELM_ARGS: __spreadArray(__spreadArray([], __read(deployConfig.debug ? ["--debug"] : []), false), __read((_p = deployConfig.additionalHelmArgs) !== null && _p !== void 0 ? _p : []), false).join(" "),
155
- COMPONENT_NAME: context.componentName,
156
- BUILD_ID: (_q = context.commitInfo) === null || _q === void 0 ? void 0 : _q.buildId,
157
- // TODO: unify with docker build stage
158
- IMAGE_NAME: context.environment.shortName + "/" + context.componentName,
159
- IMAGE_TAG: "$CI_COMMIT_SHA"
160
- })
161
- }
143
+ image: (0, runner_1.getRunnerImage)("kubernetes"),
144
+ variables: __assign(__assign({}, context.environment.envVars), {
145
+ HELM_EXPERIMENTAL_OCI: "1",
146
+ IMAGE_PULL_SECRET: "gitlab-registry-".concat(context.componentName),
147
+ KUBE_VALUES: (0, js_yaml_1.dump)(kubeValues, {
148
+ lineWidth: -1,
149
+ quotingType: "'",
150
+ forceQuotes: true
151
+ }),
152
+ HELM_GITLAB_CHART_NAME: "the-panter-chart",
153
+ HELM_ARGS: __spreadArray(__spreadArray([], __read(deployConfig.debug ? ["--debug"] : []), false), __read((_p = deployConfig.additionalHelmArgs) !== null && _p !== void 0 ? _p : []), false).join(" "),
154
+ COMPONENT_NAME: context.componentName,
155
+ BUILD_ID: (_q = context.commitInfo) === null || _q === void 0 ? void 0 : _q.buildId,
156
+ // TODO: unify with docker build stage
157
+ IMAGE_NAME: context.environment.shortName + "/" + context.componentName,
158
+ IMAGE_TAG: "$CI_COMMIT_SHA"
159
+ })
162
160
  };
163
161
  var baseDeploymentJob = (0, base_1.getBaseDeploymentJob)(context);
164
162
  var baseStopJob = (0, base_1.getBaseDeploymentStopJob)(context);
165
163
  var clusterName = "kube-".concat(context.environment.fullName);
166
164
  var connectContext = ["kubectl config set-cluster \"".concat(clusterName, "\" --server=\"$").concat((0, __1.getSecretVarNameForContext)(context, "KUBE_URL"), "\" --certificate-authority <(echo $").concat((0, __1.getSecretVarNameForContext)(context, "KUBE_CA_PEM"), " | base64 -d) --embed-certs=true"), "kubectl config set-credentials \"".concat(clusterName, "\" --token=\"$").concat((0, __1.getSecretVarNameForContext)(context, "KUBE_TOKEN"), "\""), "kubectl config set-context \"".concat(clusterName, "\" --cluster=\"").concat(clusterName, "\" --user=\"").concat(clusterName, "\" --namespace=\"").concat(context.environment.envVars.KUBE_NAMESPACE, "\""), "kubectl config use-context \"".concat(clusterName, "\"")];
167
165
  return [(0, lodash_1.merge)({}, baseDeploymentJob, shared, {
168
- job: {
169
- script: __spreadArray(__spreadArray([], __read(connectContext), false), ["kubernetesCreateSecret", "kubernetesDeploy", "echo deployment successful 😻"], false),
170
- environment: {
171
- kubernetes: kubernetesEnvironment
172
- }
166
+ script: __spreadArray(__spreadArray([], __read(connectContext), false), ["kubernetesCreateSecret", "kubernetesDeploy", "echo deployment successful 😻"], false),
167
+ environment: {
168
+ kubernetes: kubernetesEnvironment
173
169
  }
174
170
  }), (0, lodash_1.merge)({}, baseStopJob, shared, {
175
- job: {
176
- script: __spreadArray(__spreadArray([], __read(connectContext), false), ["kubernetesDelete"], false),
177
- environment: {
178
- kubernetes: kubernetesEnvironment
179
- }
171
+ script: __spreadArray(__spreadArray([], __read(connectContext), false), ["kubernetesDelete"], false),
172
+ environment: {
173
+ kubernetes: kubernetesEnvironment
180
174
  }
181
175
  })];
182
176
  };
@@ -1,12 +1,3 @@
1
+ import { Pipeline } from "../types";
1
2
  import { Config, PipelineTrigger } from "../types/config";
2
- import { GitlabJobDef } from "../types/gitlab-types";
3
- export declare const createChildPipeline: (trigger: PipelineTrigger, config: Config) => Promise<{
4
- image: string;
5
- variables: {
6
- FF_USE_FASTZIP: string;
7
- };
8
- workflow: {
9
- rules: import("../types/gitlab-types").GitlabRule[];
10
- };
11
- stages: string[];
12
- } & Record<string, GitlabJobDef>>;
3
+ export declare const createChildPipeline: <T extends "gitlab">(type: T, trigger: PipelineTrigger, config: Config) => Promise<Pipeline<T>>;
@@ -195,17 +195,17 @@ exports.createChildPipeline = void 0;
195
195
 
196
196
  var config_1 = require("../config");
197
197
 
198
- var createJobs_1 = require("./createJobs");
199
-
200
198
  var rules_1 = require("../rules");
201
199
 
202
200
  var runner_1 = require("../runner");
203
201
 
202
+ var createJobs_1 = require("./createJobs");
203
+
204
204
  var baseStages = ["setup", "test", "build", "deploy", "verify", "stop"];
205
205
 
206
- var createChildPipeline = function (trigger, config) {
206
+ var createChildPipeline = function (type, trigger, config) {
207
207
  return __awaiter(void 0, void 0, void 0, function () {
208
- var components, jobs, allEnvs, stages, childPipeline;
208
+ var components, jobs, allEnvs, stages, pipeline;
209
209
  return __generator(this, function (_a) {
210
210
  switch (_a.label) {
211
211
  case 0:
@@ -229,7 +229,7 @@ var createChildPipeline = function (trigger, config) {
229
229
  _b = [__assign.apply(void 0, _a.concat([_c.sent()]))];
230
230
  return [4
231
231
  /*yield*/
232
- , (0, createJobs_1.createJobs)(envs, config, componentName, trigger)];
232
+ , (0, createJobs_1.createJobs)(type, envs, config, componentName, trigger)];
233
233
 
234
234
  case 2:
235
235
  return [2
@@ -248,19 +248,25 @@ var createChildPipeline = function (trigger, config) {
248
248
  return "".concat(baseStage, " ").concat(e);
249
249
  })), false);
250
250
  }, []);
251
- childPipeline = __assign({
252
- image: (0, runner_1.getRunnerImage)("jobs-default"),
253
- variables: {
254
- FF_USE_FASTZIP: "true"
255
- },
256
- workflow: {
257
- rules: rules_1.RULES_ALWAYS
258
- },
259
- stages: stages
260
- }, jobs);
261
- return [2
262
- /*return*/
263
- , childPipeline];
251
+
252
+ if (type === "gitlab") {
253
+ pipeline = {
254
+ image: (0, runner_1.getRunnerImage)("jobs-default"),
255
+ variables: {
256
+ FF_USE_FASTZIP: "true"
257
+ },
258
+ workflow: {
259
+ rules: rules_1.RULES_ALWAYS
260
+ },
261
+ stages: stages,
262
+ jobs: jobs
263
+ };
264
+ return [2
265
+ /*return*/
266
+ , pipeline];
267
+ }
268
+
269
+ throw new Error("".concat(type, " is not supported"));
264
270
  }
265
271
  });
266
272
  });
@@ -141,17 +141,6 @@ var __generator = this && this.__generator || function (thisArg, body) {
141
141
  }
142
142
  };
143
143
 
144
- var __rest = this && this.__rest || function (s, e) {
145
- var t = {};
146
-
147
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
148
-
149
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
150
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
151
- }
152
- return t;
153
- };
154
-
155
144
  exports.__esModule = true;
156
145
 
157
146
  var createChildPipeline_1 = require("./createChildPipeline");
@@ -181,17 +170,17 @@ describe("createChildPipeline", function () {
181
170
  };
182
171
  it("creates a pipeline for a single app on the main branch", function () {
183
172
  return __awaiter(void 0, void 0, void 0, function () {
184
- var _a, image, stages, workflow, jobs;
173
+ var _a, image, jobs;
185
174
 
186
175
  return __generator(this, function (_b) {
187
176
  switch (_b.label) {
188
177
  case 0:
189
178
  return [4
190
179
  /*yield*/
191
- , (0, createChildPipeline_1.createChildPipeline)("mainBranch", config)];
180
+ , (0, createChildPipeline_1.createChildPipeline)("gitlab", "mainBranch", config)];
192
181
 
193
182
  case 1:
194
- _a = _b.sent(), image = _a.image, stages = _a.stages, workflow = _a.workflow, jobs = __rest(_a, ["image", "stages", "workflow"]);
183
+ _a = _b.sent(), image = _a.image, jobs = _a.jobs;
195
184
  expect(image).toEqual("git.panter.ch:5001/catladder/catladder/base-pipeline:");
196
185
  expect(Object.keys(jobs)).toEqual(["my-app audit", "my-app lint", "my-app test", "dev my-app app-build", "dev my-app docker-build", "dev my-app deploy-to-kubernetes", "dev my-app kubernetes-stop"]);
197
186
  return [2
@@ -1,3 +1,3 @@
1
+ import { PipelineJob } from "../types";
1
2
  import { Config, PipelineTrigger } from "../types/config";
2
- import { GitlabJobDef } from "../types/gitlab-types";
3
- export declare const createJobs: (envs: string[], config: Config, componentName: string, trigger: PipelineTrigger) => Promise<Record<string, GitlabJobDef>>;
3
+ export declare const createJobs: <T extends "gitlab">(type: T, envs: string[], config: Config, componentName: string, trigger: PipelineTrigger) => Promise<Record<string, PipelineJob<T>>>;
@@ -205,7 +205,9 @@ var deploy_1 = require("../deploy");
205
205
 
206
206
  var utils_1 = require("../utils");
207
207
 
208
- var yarnInfo_1 = require("./yarnInfo");
208
+ var makeGitlabJob_1 = require("./gitlab/makeGitlabJob");
209
+
210
+ var packageManager_1 = require("./packageManager");
209
211
 
210
212
  var createRawJobs = function (context) {
211
213
  if (context.componentConfig.deploy === false) {
@@ -241,24 +243,20 @@ var getFullReferencedJobName = function (referencedJobName, componentName, env,
241
243
 
242
244
 
243
245
  var replaceReferences = function (job, componentName, env, allRawJobs) {
244
- var _a, _b, _c;
246
+ var _a, _b;
245
247
 
246
- var def = job.job;
247
- var stage = job.envMode === "stagePerEnv" ? "".concat(def.stage, " ").concat(env) : def.stage;
248
- return __assign(__assign({}, def), {
248
+ var stage = job.envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
249
+ return __assign(__assign({}, job), {
249
250
  stage: stage,
250
- needs: (_a = def.needs) === null || _a === void 0 ? void 0 : _a.map(function (n) {
251
+ needs: (_a = job.needs) === null || _a === void 0 ? void 0 : _a.map(function (n) {
251
252
  return (0, lodash_1.isObject)(n) ? {
252
253
  job: getFullReferencedJobName(n.job, componentName, env, allRawJobs),
253
254
  artifacts: n.artifacts
254
255
  } : getFullReferencedJobName(n, componentName, env, allRawJobs);
255
256
  }),
256
- environment: ((_b = def.environment) === null || _b === void 0 ? void 0 : _b.on_stop) ? __assign(__assign({}, def.environment), {
257
- on_stop: getFullReferencedJobName(def.environment.on_stop, componentName, env, allRawJobs)
258
- }) : def.environment,
259
- dependencies: (_c = def.dependencies) === null || _c === void 0 ? void 0 : _c.map(function (n) {
260
- return getFullReferencedJobName(n, componentName, env, allRawJobs);
261
- })
257
+ environment: ((_b = job.environment) === null || _b === void 0 ? void 0 : _b.on_stop) ? __assign(__assign({}, job.environment), {
258
+ on_stop: getFullReferencedJobName(job.environment.on_stop, componentName, env, allRawJobs)
259
+ }) : job.environment
262
260
  });
263
261
  }; // this can be removed once https://gitlab.com/gitlab-org/gitlab/-/issues/220758 is resolved
264
262
 
@@ -276,7 +274,7 @@ var addStageNeeds = function (jobs) {
276
274
  var _a, _b;
277
275
 
278
276
  var neededStage = (_a = job.needsStages) === null || _a === void 0 ? void 0 : _a.find(function (s) {
279
- return j.job.stage === s.stage;
277
+ return j.stage === s.stage;
280
278
  });
281
279
 
282
280
  if (neededStage) {
@@ -287,16 +285,14 @@ var addStageNeeds = function (jobs) {
287
285
  }
288
286
  }).filter(utils_1.notNil);
289
287
  return __assign(__assign({}, job), {
290
- job: __assign(__assign({}, job.job), {
291
- needs: __spreadArray(__spreadArray([], __read((_a = job.job.needs) !== null && _a !== void 0 ? _a : []), false), __read(neededJobs), false)
292
- })
288
+ needs: __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read(neededJobs), false)
293
289
  });
294
290
  });
295
291
  };
296
292
 
297
- var createJobs = function (envs, config, componentName, trigger) {
293
+ var createJobs = function (type, envs, config, componentName, trigger) {
298
294
  return __awaiter(void 0, void 0, void 0, function () {
299
- var commitInfo, yarnInfo;
295
+ var commitInfo, packageManagerInfo;
300
296
 
301
297
  var _a;
302
298
 
@@ -320,20 +316,30 @@ var createJobs = function (envs, config, componentName, trigger) {
320
316
  commitInfo = (_a.buildId = _d.sent(), _a.trigger = trigger, _a);
321
317
  return [4
322
318
  /*yield*/
323
- , (0, yarnInfo_1.getYarnInfo)(config, componentName)];
319
+ , (0, packageManager_1.getPackageManagerInfo)(config, componentName)];
324
320
 
325
321
  case 2:
326
- yarnInfo = _d.sent();
322
+ packageManagerInfo = _d.sent();
327
323
  return [2
328
324
  /*return*/
329
325
  , envs.reduce(function (acc, env) {
330
- var context = (0, context_1.createContext)(config, componentName, env, commitInfo, yarnInfo);
326
+ var context = (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo);
331
327
  var jobs = addStageNeeds(createRawJobs(context));
332
- return __assign(__assign({}, acc), jobs.reduce(function (acc, job) {
328
+
329
+ var result = __assign(__assign({}, acc), jobs.reduce(function (acc, job) {
333
330
  var _a;
334
331
 
335
- return __assign(__assign({}, acc), (_a = {}, _a[getFullJobName(job.name, componentName, job.envMode !== "none" ? env : undefined)] = replaceReferences(job, componentName, env, jobs), _a));
332
+ var jobWithResolvedReferences = replaceReferences(job, componentName, env, jobs);
333
+ var jobName = getFullJobName(job.name, componentName, job.envMode !== "none" ? env : undefined);
334
+
335
+ if (type === "gitlab") {
336
+ return __assign(__assign({}, acc), (_a = {}, _a[jobName] = (0, makeGitlabJob_1.makeGitlabJob)(jobWithResolvedReferences), _a));
337
+ }
338
+
339
+ throw new Error("not supported");
336
340
  }, {}));
341
+
342
+ return result;
337
343
  }, {})];
338
344
  }
339
345
  });
@@ -0,0 +1,8 @@
1
+ import { GitlabJobDef } from "../../types";
2
+ import { CatladderJob } from "../../types/jobs";
3
+ export declare const makeGitlabJob: ({
4
+ envMode,
5
+ needsStages,
6
+ name,
7
+ ...rest
8
+ }: CatladderJob<string>) => GitlabJobDef;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+
8
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
9
+ }
10
+
11
+ return t;
12
+ };
13
+
14
+ return __assign.apply(this, arguments);
15
+ };
16
+
17
+ var __rest = this && this.__rest || function (s, e) {
18
+ var t = {};
19
+
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
21
+
22
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
23
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
24
+ }
25
+ return t;
26
+ };
27
+
28
+ exports.__esModule = true;
29
+ exports.makeGitlabJob = void 0;
30
+
31
+ var defaults_1 = require("../../defaults");
32
+
33
+ var makeGitlabJob = function (_a) {
34
+ var envMode = _a.envMode,
35
+ needsStages = _a.needsStages,
36
+ name = _a.name,
37
+ rest = __rest(_a, ["envMode", "needsStages", "name"]);
38
+
39
+ return __assign(__assign({}, rest), {
40
+ retry: defaults_1.BASE_RETRY,
41
+ interruptible: true
42
+ });
43
+ };
44
+
45
+ exports.makeGitlabJob = makeGitlabJob;
@@ -0,0 +1,2 @@
1
+ import { Config, PackageManagerInfo } from "../types";
2
+ export declare const getPackageManagerInfo: (config: Config, componentName: string) => Promise<PackageManagerInfo>;