@catladder/pipeline 1.153.1 → 1.154.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.
- package/dist/build/artifacts/createBuildJobArtifact.d.ts +3 -0
- package/dist/build/artifacts/createBuildJobArtifact.js +97 -0
- package/dist/build/base/createAppBuildJob.d.ts +3 -3
- package/dist/build/base/createAppBuildJob.js +9 -15
- package/dist/build/base/index.d.ts +6 -2
- package/dist/build/base/index.js +14 -5
- package/dist/build/base/writeDotEnv.js +2 -1
- package/dist/build/custom/__tests__/testJob.test.js +1 -1
- package/dist/build/custom/buildJob.js +3 -10
- package/dist/build/docker.js +3 -3
- package/dist/build/index.d.ts +13 -6
- package/dist/build/index.js +29 -7
- package/dist/build/node/buildJob.d.ts +7 -2
- package/dist/build/node/buildJob.js +40 -33
- package/dist/build/node/cache.d.ts +2 -2
- package/dist/build/node/cache.js +8 -4
- package/dist/build/node/index.d.ts +2 -2
- package/dist/build/node/meteor.js +3 -6
- package/dist/build/node/testJob.d.ts +3 -2
- package/dist/build/node/testJob.js +9 -4
- package/dist/build/node/yarn.js +1 -1
- package/dist/build/rails/build.d.ts +1 -1
- package/dist/build/rails/build.js +7 -2
- package/dist/build/rails/test.d.ts +1 -1
- package/dist/build/rails/test.js +5 -0
- package/dist/build/sbom.js +3 -2
- package/dist/build/types.d.ts +48 -4
- package/dist/build/types.js +7 -1
- package/dist/bundles/catladder-gitlab/index.js +2 -2
- package/dist/constants.js +1 -1
- package/dist/context/createAllComponentsContext.d.ts +12 -0
- package/dist/context/createAllComponentsContext.js +159 -0
- package/dist/context/createComponentContext.d.ts +1 -5
- package/dist/context/createComponentContext.js +82 -20
- package/dist/context/createWorkspaceContext.d.ts +16 -0
- package/dist/context/createWorkspaceContext.js +173 -0
- package/dist/context/getBuildInfoVariables.d.ts +1 -1
- package/dist/context/getEnvironmentContext.d.ts +1 -1
- package/dist/context/getEnvironmentVariables.d.ts +2 -2
- package/dist/context/getEnvironmentVariables.js +5 -4
- package/dist/context/getLabels.js +4 -4
- package/dist/deploy/base/deploy.d.ts +1 -1
- package/dist/deploy/base/deploy.js +18 -5
- package/dist/deploy/cloudRun/artifactsRegistry.js +2 -2
- package/dist/deploy/cloudRun/createJobs/common.d.ts +4 -4
- package/dist/deploy/cloudRun/index.d.ts +2 -2
- package/dist/deploy/custom/index.d.ts +2 -2
- package/dist/deploy/dockerTag/index.d.ts +2 -2
- package/dist/deploy/index.d.ts +7 -7
- package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +3 -1
- package/dist/deploy/kubernetes/cloudSql/index.js +1 -1
- package/dist/deploy/kubernetes/deployJob.js +2 -2
- package/dist/deploy/kubernetes/index.d.ts +2 -2
- package/dist/deploy/sbom.d.ts +1 -1
- package/dist/deploy/sbom.js +4 -3
- package/dist/deploy/types/index.d.ts +3 -3
- package/dist/pipeline/createAllJobs.d.ts +12 -10
- package/dist/pipeline/createAllJobs.js +94 -51
- package/dist/pipeline/createJobsForComponent.js +2 -3
- package/dist/pipeline/createJobsForWorkspace.d.ts +3 -0
- package/dist/pipeline/createJobsForWorkspace.js +12 -0
- package/dist/pipeline/createMainPipeline.js +26 -6
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +3 -16
- package/dist/pipeline/gitlab/createGitlabJobs.js +191 -73
- package/dist/pipeline/packageManager.d.ts +3 -2
- package/dist/pipeline/packageManager.js +43 -15
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +5 -4
- package/dist/types/context.d.ts +77 -12
- package/dist/types/context.js +10 -1
- package/dist/types/environmentContext.d.ts +5 -6
- package/dist/types/jobs.d.ts +5 -0
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-meteor-with-worker.ts.snap +8 -0
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-no-service.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-post-stop-job.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-service-gen2.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-service-increase-timout.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-service-with-volumes.ts.snap +8 -8
- package/examples/__snapshots__/cloud-run-storybook.ts.snap +4 -8
- package/examples/__snapshots__/cloud-run-with-ngnix.ts.snap +4 -8
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +16 -16
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +589 -1097
- package/examples/__snapshots__/cloud-run-with-worker.ts.snap +8 -8
- package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +4 -0
- package/examples/__snapshots__/custom-build-job.ts.snap +4 -0
- package/examples/__snapshots__/custom-deploy.ts.snap +8 -8
- package/examples/__snapshots__/custom-envs.ts.snap +18 -12
- package/examples/__snapshots__/custom-sbom-java.ts.snap +4 -0
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +8 -8
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +8 -8
- package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +8 -8
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +16 -16
- package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +8 -8
- package/examples/__snapshots__/local-dot-env.ts.snap +8 -8
- package/examples/__snapshots__/meteor-kubernetes.ts.snap +8 -0
- package/examples/__snapshots__/multiline-var.ts.snap +16 -16
- package/examples/__snapshots__/native-app.ts.snap +24 -16
- package/examples/__snapshots__/node-build-with-custom-image.ts.snap +8 -8
- package/examples/__snapshots__/node-build-with-docker-additions.ts.snap +8 -8
- package/examples/__snapshots__/wait-for-other-deploy.ts.snap +16 -16
- package/examples/cloud-run-with-sql.ts +9 -2
- package/package.json +1 -1
- package/src/build/artifacts/createBuildJobArtifact.ts +61 -0
- package/src/build/base/createAppBuildJob.ts +26 -22
- package/src/build/base/index.ts +31 -4
- package/src/build/base/writeDotEnv.ts +6 -2
- package/src/build/custom/__tests__/testJob.test.ts +4 -4
- package/src/build/custom/buildJob.ts +2 -13
- package/src/build/docker.ts +6 -7
- package/src/build/index.ts +39 -7
- package/src/build/node/buildJob.ts +68 -56
- package/src/build/node/cache.ts +17 -8
- package/src/build/node/index.ts +4 -2
- package/src/build/node/meteor.ts +3 -9
- package/src/build/node/testJob.ts +21 -7
- package/src/build/node/yarn.ts +2 -2
- package/src/build/rails/build.ts +14 -4
- package/src/build/rails/test.ts +9 -1
- package/src/build/sbom.ts +7 -2
- package/src/build/types.ts +68 -4
- package/src/context/createAllComponentsContext.ts +31 -0
- package/src/context/createComponentContext.ts +59 -20
- package/src/context/createWorkspaceContext.ts +56 -0
- package/src/context/getBuildInfoVariables.ts +2 -1
- package/src/context/getEnvironmentContext.ts +2 -2
- package/src/context/getEnvironmentVariables.ts +12 -6
- package/src/context/getLabels.ts +2 -2
- package/src/deploy/base/deploy.ts +33 -7
- package/src/deploy/cloudRun/artifactsRegistry.ts +2 -3
- package/src/deploy/cloudRun/createJobs/common.ts +4 -4
- package/src/deploy/cloudRun/index.ts +68 -67
- package/src/deploy/custom/index.ts +2 -2
- package/src/deploy/dockerTag/index.ts +8 -7
- package/src/deploy/index.ts +11 -9
- package/src/deploy/kubernetes/additionalSecretKeys.ts +3 -1
- package/src/deploy/kubernetes/cloudSql/index.ts +1 -1
- package/src/deploy/kubernetes/deployJob.ts +2 -2
- package/src/deploy/kubernetes/index.ts +42 -41
- package/src/deploy/sbom.ts +9 -4
- package/src/pipeline/createAllJobs.ts +56 -55
- package/src/pipeline/createChildPipeline.ts +1 -0
- package/src/pipeline/createJobsForComponent.ts +5 -4
- package/src/pipeline/createJobsForWorkspace.ts +12 -0
- package/src/pipeline/createMainPipeline.ts +38 -23
- package/src/pipeline/gitlab/createGitlabJobs.ts +283 -119
- package/src/pipeline/packageManager.ts +25 -9
- package/src/types/config.ts +4 -1
- package/src/types/context.ts +105 -11
- package/src/types/environmentContext.ts +6 -7
- package/src/types/jobs.ts +3 -1
|
@@ -175,16 +175,24 @@ var utils_1 = require("../../utils");
|
|
|
175
175
|
var gitlab_1 = require("../../utils/gitlab");
|
|
176
176
|
var removeUndefined_1 = require("../../utils/removeUndefined");
|
|
177
177
|
exports.GITLAB_ENVIRONMENT_URL_VARIABLE = "CL_GITLAB_ENVIRONMENT_URL";
|
|
178
|
-
var getFullJobName = function (
|
|
178
|
+
var getFullJobName = function (_a) {
|
|
179
|
+
var type = _a.type,
|
|
180
|
+
name = _a.name,
|
|
181
|
+
baseName = _a.baseName,
|
|
182
|
+
allJobs = _a.allJobs,
|
|
183
|
+
env = _a.env;
|
|
184
|
+
var shouldAddIcon = allJobs.workspaces.length > 0;
|
|
185
|
+
var icon = type === "component" ? "🔹" : "🔸";
|
|
186
|
+
var prefix = shouldAddIcon ? icon + " " : "";
|
|
179
187
|
if (env) {
|
|
180
|
-
return "".concat(
|
|
188
|
+
return "".concat(prefix).concat(baseName, " ").concat(name, " | ").concat(env, " ");
|
|
181
189
|
}
|
|
182
|
-
return "".concat(
|
|
190
|
+
return "".concat(prefix).concat(baseName, " ").concat(name);
|
|
183
191
|
};
|
|
184
|
-
var
|
|
192
|
+
var getFullReferencedJobNameFromComponent = function (referencedJobName, componentName, env, allJobs) {
|
|
185
193
|
var _a, _b;
|
|
186
|
-
var referencedJob = (_b = (_a = allJobs.find(function (j) {
|
|
187
|
-
return j.context.
|
|
194
|
+
var referencedJob = (_b = (_a = allJobs.components.find(function (j) {
|
|
195
|
+
return j.context.name === componentName && j.context.env === env;
|
|
188
196
|
})) === null || _a === void 0 ? void 0 : _a.jobs) === null || _b === void 0 ? void 0 : _b.find(function (j) {
|
|
189
197
|
return j.name === referencedJobName;
|
|
190
198
|
});
|
|
@@ -192,61 +200,59 @@ var getFullReferencedJobName = function (referencedJobName, componentName, env,
|
|
|
192
200
|
throw new Error("unknown job referenced: '".concat(referencedJobName, "' from '").concat(env, ":").concat(componentName, "'"));
|
|
193
201
|
}
|
|
194
202
|
var envToSet = referencedJob.envMode !== "none" ? env : null;
|
|
195
|
-
return getFullJobName(
|
|
203
|
+
return getFullJobName({
|
|
204
|
+
type: "component",
|
|
205
|
+
name: referencedJobName,
|
|
206
|
+
baseName: componentName,
|
|
207
|
+
env: envToSet,
|
|
208
|
+
allJobs: allJobs
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
var getFullReferencedJobNameFromWorkspace = function (referencedJobName, workspaceName, env, allJobs) {
|
|
212
|
+
var _a, _b;
|
|
213
|
+
var referencedJob = (_b = (_a = allJobs.workspaces.find(function (w) {
|
|
214
|
+
return w.context.name === workspaceName;
|
|
215
|
+
})) === null || _a === void 0 ? void 0 : _a.jobs) === null || _b === void 0 ? void 0 : _b.find(function (j) {
|
|
216
|
+
return j.name === referencedJobName;
|
|
217
|
+
});
|
|
218
|
+
if (!referencedJob) {
|
|
219
|
+
throw new Error("unknown job referenced: '".concat(referencedJobName, "' from workspace ").concat(env, ":").concat(workspaceName, "'"));
|
|
220
|
+
}
|
|
221
|
+
var envToSet = referencedJob.envMode !== "none" ? env : null;
|
|
222
|
+
return getFullJobName({
|
|
223
|
+
type: "workspace",
|
|
224
|
+
name: referencedJobName,
|
|
225
|
+
baseName: workspaceName,
|
|
226
|
+
env: envToSet,
|
|
227
|
+
allJobs: allJobs
|
|
228
|
+
});
|
|
196
229
|
};
|
|
197
230
|
var getJobName = function (need) {
|
|
198
231
|
return (0, lodash_1.isObject)(need) ? need.job : need;
|
|
199
232
|
};
|
|
200
|
-
var makeGitlabJob = function (context,
|
|
201
|
-
var
|
|
202
|
-
var environment =
|
|
203
|
-
envMode =
|
|
204
|
-
needsStages =
|
|
205
|
-
needsOtherComponent =
|
|
206
|
-
name =
|
|
207
|
-
needs =
|
|
208
|
-
jobTags =
|
|
209
|
-
script =
|
|
210
|
-
variables =
|
|
211
|
-
runnerVariables =
|
|
212
|
-
when =
|
|
213
|
-
|
|
233
|
+
var makeGitlabJob = function (context, job, allJobs, baseRules) {
|
|
234
|
+
var _a, _b;
|
|
235
|
+
var environment = job.environment,
|
|
236
|
+
envMode = job.envMode,
|
|
237
|
+
needsStages = job.needsStages,
|
|
238
|
+
needsOtherComponent = job.needsOtherComponent,
|
|
239
|
+
name = job.name,
|
|
240
|
+
needs = job.needs,
|
|
241
|
+
jobTags = job.jobTags,
|
|
242
|
+
script = job.script,
|
|
243
|
+
variables = job.variables,
|
|
244
|
+
runnerVariables = job.runnerVariables,
|
|
245
|
+
when = job.when,
|
|
246
|
+
rest = __rest(job, ["environment", "envMode", "needsStages", "needsOtherComponent", "name", "needs", "jobTags", "script", "variables", "runnerVariables", "when"]);
|
|
214
247
|
var stage = envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(context.env) : job.stage;
|
|
215
|
-
var
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
})) === null || _a === void 0 ? void 0 : _a.filter(function (j) {
|
|
223
|
-
return j.stage === n.stage;
|
|
224
|
-
})) === null || _b === void 0 ? void 0 : _b.map(function (j) {
|
|
225
|
-
return j.name;
|
|
226
|
-
})) !== null && _c !== void 0 ? _c : [];
|
|
227
|
-
return allJobNamesFromThatStage.map(function (job) {
|
|
228
|
-
var _a;
|
|
229
|
-
return {
|
|
230
|
-
job: job,
|
|
231
|
-
artifacts: (_a = n.artifacts) !== null && _a !== void 0 ? _a : false,
|
|
232
|
-
componentName: referencedComponentName
|
|
233
|
-
};
|
|
234
|
-
});
|
|
248
|
+
var deduplicatedGitlabNeeds = getGitlabNeeds(context, job, allJobs);
|
|
249
|
+
var fullJobName = getFullJobName({
|
|
250
|
+
type: context.type,
|
|
251
|
+
name: name,
|
|
252
|
+
baseName: context.name,
|
|
253
|
+
env: envMode !== "none" ? context.env : undefined,
|
|
254
|
+
allJobs: allJobs
|
|
235
255
|
});
|
|
236
|
-
var cleanedNeeds = __spreadArray(__spreadArray(__spreadArray([], __read(needsFromStages !== null && needsFromStages !== void 0 ? needsFromStages : []), false), __read(needs !== null && needs !== void 0 ? needs : []), false), __read(needsOtherComponent !== null && needsOtherComponent !== void 0 ? needsOtherComponent : []), false);
|
|
237
|
-
var gitlabNeeds = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
|
|
238
|
-
var _a;
|
|
239
|
-
return (0, lodash_1.isObject)(n) ? {
|
|
240
|
-
job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : context.componentName, context.env, allJobs),
|
|
241
|
-
artifacts: n.artifacts
|
|
242
|
-
} : getFullReferencedJobName(n, context.componentName, context.env, allJobs);
|
|
243
|
-
}).sort(function (a, b) {
|
|
244
|
-
return getJobName(a).localeCompare(getJobName(b));
|
|
245
|
-
});
|
|
246
|
-
var deduplicatedGitlabNeeds = __spreadArray([], __read(new Map(gitlabNeeds.map(function (n) {
|
|
247
|
-
return [(0, lodash_1.isObject)(n) ? n.job : n, n];
|
|
248
|
-
})).values()), false);
|
|
249
|
-
var fullJobName = getFullJobName(name, context.componentName, envMode !== "none" ? context.env : undefined);
|
|
250
256
|
// backwards compatibility, some may still use KUBERNETES_CPU_REQUEST, KUBERNETES_MEMORY_REQUEST, etc. in variables.
|
|
251
257
|
// those should now be set in the runnerVariables as they don't work in the variables key of the catladder job, becuase those get injected
|
|
252
258
|
var PIPELINE_RUNNER_VARIABLES = ["KUBERNETES_CPU_REQUEST", "KUBERNETES_MEMORY_REQUEST", "KUBERNETES_CPU_LIMIT", "KUBERNETES_MEMORY_LIMIT"];
|
|
@@ -266,51 +272,56 @@ var makeGitlabJob = function (context, _a, allJobs, baseRules) {
|
|
|
266
272
|
if (Object.keys(legacyRunnerVariables).length > 0) {
|
|
267
273
|
console.warn("Legacy variables detected in ".concat(fullJobName, ": ").concat(Object.keys(legacyRunnerVariables).join(", "), ". Please move them to the runnerVariables key."));
|
|
268
274
|
}
|
|
269
|
-
var rules = __spreadArray(__spreadArray([], __read((
|
|
275
|
+
var rules = __spreadArray(__spreadArray([], __read((_a = job.rules) !== null && _a !== void 0 ? _a : []), false), __read(baseRules ? baseRules.map(function (rule) {
|
|
270
276
|
return __assign({
|
|
271
277
|
when: when
|
|
272
278
|
}, rule);
|
|
273
279
|
}) : when ? [{
|
|
274
280
|
when: when
|
|
275
281
|
}] : []), false);
|
|
276
|
-
var
|
|
282
|
+
var gitlabJob = __assign(__assign({}, rest), {
|
|
277
283
|
rules: rules.length > 0 ? rules : undefined,
|
|
278
284
|
variables: __assign(__assign({}, legacyRunnerVariables), runnerVariables),
|
|
279
|
-
script: __spreadArray(__spreadArray([], __read(varsInjectScripts), false), __read((
|
|
285
|
+
script: __spreadArray(__spreadArray([], __read(varsInjectScripts), false), __read((_b = script === null || script === void 0 ? void 0 : script.filter(utils_1.notNil)) !== null && _b !== void 0 ? _b : []), false),
|
|
280
286
|
tags: jobTags,
|
|
281
287
|
stage: stage,
|
|
282
288
|
// sort in a predictable manner for snapshot tests
|
|
283
289
|
needs: deduplicatedGitlabNeeds,
|
|
284
290
|
retry: defaults_1.BASE_RETRY,
|
|
285
291
|
interruptible: true
|
|
286
|
-
})
|
|
292
|
+
});
|
|
293
|
+
var modified = addGitlabEnvironment(context, environment, gitlabJob, allJobs);
|
|
287
294
|
return [fullJobName, (0, removeUndefined_1.removeUndefined)(modified)];
|
|
288
295
|
};
|
|
289
296
|
exports.makeGitlabJob = makeGitlabJob;
|
|
290
|
-
var addGitlabEnvironment = function (context,
|
|
291
|
-
// TODO: we could actually pull this from contxt
|
|
292
|
-
allJobs) {
|
|
297
|
+
var addGitlabEnvironment = function (context, catladderJobEnvironment, job, allJobs) {
|
|
293
298
|
var _a, _b;
|
|
294
|
-
if (!
|
|
299
|
+
if (!catladderJobEnvironment) {
|
|
300
|
+
return job;
|
|
301
|
+
}
|
|
302
|
+
if (context.type !== "component") {
|
|
303
|
+
// don't add enviornment for workspace jobs atm.
|
|
295
304
|
return job;
|
|
296
305
|
}
|
|
297
|
-
var
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
var
|
|
301
|
-
|
|
306
|
+
var env = context.env,
|
|
307
|
+
name = context.name,
|
|
308
|
+
environment = context.environment;
|
|
309
|
+
var url = environment.url,
|
|
310
|
+
envType = environment.envType;
|
|
311
|
+
var on_stop = catladderJobEnvironment.on_stop,
|
|
312
|
+
restEnvironment = __rest(catladderJobEnvironment, ["on_stop"]);
|
|
302
313
|
// those can be dynamic, so we therefore have to do this: https://docs.gitlab.com/ee/ci/environments/#set-a-dynamic-environment-url
|
|
303
314
|
var dotEnvFile = "gitlab_environment.env";
|
|
304
315
|
var scriptToAdd = ["echo \"".concat(exports.GITLAB_ENVIRONMENT_URL_VARIABLE, "=").concat(url, "\" >> ").concat(dotEnvFile)];
|
|
305
316
|
// this is NOT a bashVariable since it NEEDS to be used as a string in gitlab
|
|
306
|
-
var gitlabEnvironmentName = envType === "review" ? "".concat(env, "/$CI_COMMIT_REF_NAME/").concat(
|
|
307
|
-
: "".concat(env, "/").concat(
|
|
317
|
+
var gitlabEnvironmentName = envType === "review" ? "".concat(env, "/$CI_COMMIT_REF_NAME/").concat(name) // FIXME: should be replaced with mr name as well
|
|
318
|
+
: "".concat(env, "/").concat(name);
|
|
308
319
|
return __assign(__assign({}, job), {
|
|
309
320
|
environment: __assign(__assign({
|
|
310
321
|
name: gitlabEnvironmentName,
|
|
311
322
|
url: "$".concat(exports.GITLAB_ENVIRONMENT_URL_VARIABLE)
|
|
312
323
|
}, on_stop ? {
|
|
313
|
-
on_stop:
|
|
324
|
+
on_stop: getFullReferencedJobNameFromComponent(on_stop, name, env, allJobs)
|
|
314
325
|
} : {}), restEnvironment),
|
|
315
326
|
artifacts: (0, lodash_1.merge)((_a = job.artifacts) !== null && _a !== void 0 ? _a : {}, {
|
|
316
327
|
reports: {
|
|
@@ -323,7 +334,8 @@ allJobs) {
|
|
|
323
334
|
var createGitlabJobs = function (allJobs, baseRules) {
|
|
324
335
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
325
336
|
return __generator(this, function (_a) {
|
|
326
|
-
|
|
337
|
+
// TODO: add workspace jobs
|
|
338
|
+
return [2 /*return*/, __spreadArray(__spreadArray([], __read(allJobs.workspaces), false), __read(allJobs.components), false).flatMap(function (_a) {
|
|
327
339
|
var context = _a.context,
|
|
328
340
|
jobs = _a.jobs;
|
|
329
341
|
return jobs.map(function (job) {
|
|
@@ -340,4 +352,110 @@ var createGitlabJobs = function (allJobs, baseRules) {
|
|
|
340
352
|
});
|
|
341
353
|
});
|
|
342
354
|
};
|
|
343
|
-
exports.createGitlabJobs = createGitlabJobs;
|
|
355
|
+
exports.createGitlabJobs = createGitlabJobs;
|
|
356
|
+
function getGitlabNeeds(context, job, allJobs) {
|
|
357
|
+
var needs = context.type === "workspace" ? getGitlabNeedsForWorkspaceJob(context, job, allJobs) : getGitlabNeedsForComponentJob(context, job, allJobs);
|
|
358
|
+
return deduplicateNeeds(needs);
|
|
359
|
+
}
|
|
360
|
+
function deduplicateNeeds(needs) {
|
|
361
|
+
return needs ? __spreadArray([], __read(new Map(needs.map(function (n) {
|
|
362
|
+
return [(0, lodash_1.isObject)(n) ? n.job : n, n];
|
|
363
|
+
})).values()), false) : undefined;
|
|
364
|
+
}
|
|
365
|
+
function getGitlabNeedsForComponentJob(context, _a, allJobs) {
|
|
366
|
+
var needsStages = _a.needsStages,
|
|
367
|
+
needs = _a.needs,
|
|
368
|
+
needsOtherComponent = _a.needsOtherComponent;
|
|
369
|
+
var needsFromStages = needsStages === null || needsStages === void 0 ? void 0 : needsStages.flatMap(function (n) {
|
|
370
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
371
|
+
var componentName = context.name;
|
|
372
|
+
if (!n.workspaceName) {
|
|
373
|
+
var allJobNamesFromThatStage = (_c = (_b = (_a = allJobs.components.filter(function (j) {
|
|
374
|
+
return j.context.name === componentName && j.context.env === context.env;
|
|
375
|
+
}).flatMap(function (j) {
|
|
376
|
+
return j.jobs;
|
|
377
|
+
})) === null || _a === void 0 ? void 0 : _a.filter(function (j) {
|
|
378
|
+
return j.stage === n.stage;
|
|
379
|
+
})) === null || _b === void 0 ? void 0 : _b.map(function (j) {
|
|
380
|
+
return j.name;
|
|
381
|
+
})) !== null && _c !== void 0 ? _c : [];
|
|
382
|
+
return allJobNamesFromThatStage.map(function (job) {
|
|
383
|
+
var _a;
|
|
384
|
+
return {
|
|
385
|
+
job: job,
|
|
386
|
+
artifacts: (_a = n.artifacts) !== null && _a !== void 0 ? _a : false,
|
|
387
|
+
componentName: componentName
|
|
388
|
+
};
|
|
389
|
+
});
|
|
390
|
+
} else {
|
|
391
|
+
var allJobNamesFromThatStage = (_h = (_g = (_f = (_e = (_d = allJobs.workspaces.find(function (w) {
|
|
392
|
+
return w.context.name === n.workspaceName && w.context.env === context.env;
|
|
393
|
+
})) === null || _d === void 0 ? void 0 : _d.jobs) === null || _e === void 0 ? void 0 : _e.flatMap(function (j) {
|
|
394
|
+
return j;
|
|
395
|
+
})) === null || _f === void 0 ? void 0 : _f.filter(function (j) {
|
|
396
|
+
return j.stage === n.stage;
|
|
397
|
+
})) === null || _g === void 0 ? void 0 : _g.map(function (j) {
|
|
398
|
+
return j.name;
|
|
399
|
+
})) !== null && _h !== void 0 ? _h : [];
|
|
400
|
+
return allJobNamesFromThatStage.map(function (job) {
|
|
401
|
+
var _a;
|
|
402
|
+
return {
|
|
403
|
+
job: job,
|
|
404
|
+
artifacts: (_a = n.artifacts) !== null && _a !== void 0 ? _a : false,
|
|
405
|
+
workspaceName: n.workspaceName
|
|
406
|
+
};
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
var cleanedNeeds = __spreadArray(__spreadArray(__spreadArray([], __read(needsFromStages !== null && needsFromStages !== void 0 ? needsFromStages : []), false), __read(needs !== null && needs !== void 0 ? needs : []), false), __read(needsOtherComponent !== null && needsOtherComponent !== void 0 ? needsOtherComponent : []), false);
|
|
411
|
+
return cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
|
|
412
|
+
var _a;
|
|
413
|
+
return (0, lodash_1.isObject)(n) ? "workspaceName" in n ? {
|
|
414
|
+
job: getFullReferencedJobNameFromWorkspace(n.job, n.workspaceName, context.env, allJobs),
|
|
415
|
+
artifacts: n.artifacts
|
|
416
|
+
} : {
|
|
417
|
+
job: getFullReferencedJobNameFromComponent(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : context.name, context.env, allJobs),
|
|
418
|
+
artifacts: n.artifacts
|
|
419
|
+
} : getFullReferencedJobNameFromComponent(n, context.name, context.env, allJobs);
|
|
420
|
+
}).sort(function (a, b) {
|
|
421
|
+
return getJobName(a).localeCompare(getJobName(b));
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
*
|
|
426
|
+
*unclear whether we actually need this. So far jobs in a workspace don't have needs to other jobs from the same workspace
|
|
427
|
+
*/
|
|
428
|
+
function getGitlabNeedsForWorkspaceJob(context, _a, allJobs) {
|
|
429
|
+
var needsStages = _a.needsStages,
|
|
430
|
+
needs = _a.needs;
|
|
431
|
+
var needsFromStages = needsStages === null || needsStages === void 0 ? void 0 : needsStages.flatMap(function (n) {
|
|
432
|
+
var _a, _b, _c, _d;
|
|
433
|
+
var workspaceName = (_a = n.workspaceName) !== null && _a !== void 0 ? _a : context.name;
|
|
434
|
+
var allJobNamesFromThatStage = (_d = (_c = (_b = allJobs.workspaces.filter(function (j) {
|
|
435
|
+
return j.context.name === workspaceName && j.context.env === context.env;
|
|
436
|
+
}).flatMap(function (j) {
|
|
437
|
+
return j.jobs;
|
|
438
|
+
})) === null || _b === void 0 ? void 0 : _b.filter(function (j) {
|
|
439
|
+
return j.stage === n.stage;
|
|
440
|
+
})) === null || _c === void 0 ? void 0 : _c.map(function (j) {
|
|
441
|
+
return j.name;
|
|
442
|
+
})) !== null && _d !== void 0 ? _d : [];
|
|
443
|
+
return allJobNamesFromThatStage.map(function (job) {
|
|
444
|
+
var _a;
|
|
445
|
+
return {
|
|
446
|
+
job: job,
|
|
447
|
+
artifacts: (_a = n.artifacts) !== null && _a !== void 0 ? _a : false,
|
|
448
|
+
workspaceName: workspaceName
|
|
449
|
+
};
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
var cleanedNeeds = __spreadArray(__spreadArray([], __read(needsFromStages !== null && needsFromStages !== void 0 ? needsFromStages : []), false), __read(needs !== null && needs !== void 0 ? needs : []), false);
|
|
453
|
+
return cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
|
|
454
|
+
return (0, lodash_1.isObject)(n) ? {
|
|
455
|
+
job: getFullReferencedJobNameFromWorkspace(n.job, "workspaceName" in n && n.workspaceName ? n.workspaceName : context.name, context.env, allJobs),
|
|
456
|
+
artifacts: n.artifacts
|
|
457
|
+
} : getFullReferencedJobNameFromWorkspace(n, context.name, context.env, allJobs);
|
|
458
|
+
}).sort(function (a, b) {
|
|
459
|
+
return getJobName(a).localeCompare(getJobName(b));
|
|
460
|
+
});
|
|
461
|
+
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type { Config, PackageManagerInfoComponent } from "../types";
|
|
2
|
-
export declare const getPackageManagerInfoForComponent: (config: Config, componentName: string) => Promise<PackageManagerInfoComponent>;
|
|
1
|
+
import type { Config, PackageManagerInfoBase, PackageManagerInfoComponent } from "../types";
|
|
2
|
+
export declare const getPackageManagerInfoForComponent: (config: Config, componentName: string) => Promise<PackageManagerInfoComponent>;
|
|
3
|
+
export declare const getPackageManagerInfoBase: () => Promise<PackageManagerInfoBase>;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __assign = this && this.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
3
13
|
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
4
14
|
function adopt(value) {
|
|
5
15
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -149,26 +159,22 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
149
159
|
Object.defineProperty(exports, "__esModule", {
|
|
150
160
|
value: true
|
|
151
161
|
});
|
|
152
|
-
exports.getPackageManagerInfoForComponent = void 0;
|
|
162
|
+
exports.getPackageManagerInfoBase = exports.getPackageManagerInfoForComponent = void 0;
|
|
153
163
|
var fs_1 = require("fs");
|
|
154
164
|
var path_1 = require("path");
|
|
155
165
|
var path_equal_1 = require("path-equal");
|
|
156
166
|
var yarnUtils_1 = require("./yarn/yarnUtils");
|
|
157
167
|
var getPackageManagerInfoForComponent = function (config, componentName) {
|
|
158
168
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
159
|
-
var
|
|
169
|
+
var baseInfo, workspaces, component, currentWorkspace, componentIsInWorkspace, workspaceRoot, packageJson, workspacePackageJson, lockFile, configFiles, configFilePaths, currentWorkspaceDependencies, pathsToCopyInDocker;
|
|
160
170
|
return __generator(this, function (_a) {
|
|
161
171
|
switch (_a.label) {
|
|
162
172
|
case 0:
|
|
163
|
-
return [4 /*yield*/, (0,
|
|
173
|
+
return [4 /*yield*/, (0, exports.getPackageManagerInfoBase)()];
|
|
164
174
|
case 1:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
isClassic = version.startsWith("1");
|
|
175
|
+
baseInfo = _a.sent();
|
|
176
|
+
workspaces = baseInfo.workspaces;
|
|
168
177
|
component = config.components[componentName];
|
|
169
|
-
return [4 /*yield*/, (0, yarnUtils_1.getWorkspaces)(isClassic)];
|
|
170
|
-
case 2:
|
|
171
|
-
workspaces = _a.sent();
|
|
172
178
|
currentWorkspace = workspaces.find(function (w) {
|
|
173
179
|
return (0, path_equal_1.pathEqual)(component.dir, w.location);
|
|
174
180
|
});
|
|
@@ -185,18 +191,40 @@ var getPackageManagerInfoForComponent = function (config, componentName) {
|
|
|
185
191
|
});
|
|
186
192
|
currentWorkspaceDependencies = currentWorkspace ? (0, yarnUtils_1.getWorkspaceDependencies)(currentWorkspace, workspaces) : [];
|
|
187
193
|
pathsToCopyInDocker = __spreadArray(__spreadArray(__spreadArray(__spreadArray([packageJson], __read(workspacePackageJson ? [workspacePackageJson] : []), false), [lockFile], false), __read(configFilePaths), false), __read(currentWorkspaceDependencies), false);
|
|
188
|
-
return [2 /*return*/, {
|
|
189
|
-
type: "yarn",
|
|
190
|
-
workspaces: workspaces,
|
|
191
|
-
version: version,
|
|
192
|
-
isClassic: isClassic,
|
|
194
|
+
return [2 /*return*/, __assign(__assign({}, baseInfo), {
|
|
193
195
|
currentWorkspace: currentWorkspace,
|
|
194
196
|
currentWorkspaceDependencies: currentWorkspaceDependencies,
|
|
195
197
|
componentIsInWorkspace: componentIsInWorkspace,
|
|
196
198
|
pathsToCopyInDocker: pathsToCopyInDocker
|
|
199
|
+
})];
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
exports.getPackageManagerInfoForComponent = getPackageManagerInfoForComponent;
|
|
205
|
+
// TODO: memoizee
|
|
206
|
+
var getPackageManagerInfoBase = function () {
|
|
207
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
208
|
+
var version, isClassic, workspaces;
|
|
209
|
+
return __generator(this, function (_a) {
|
|
210
|
+
switch (_a.label) {
|
|
211
|
+
case 0:
|
|
212
|
+
return [4 /*yield*/, (0, yarnUtils_1.getYarnVersion)()];
|
|
213
|
+
case 1:
|
|
214
|
+
version = _a.sent();
|
|
215
|
+
if (!version) throw new Error("could not get yarn version");
|
|
216
|
+
isClassic = version.startsWith("1");
|
|
217
|
+
return [4 /*yield*/, (0, yarnUtils_1.getWorkspaces)(isClassic)];
|
|
218
|
+
case 2:
|
|
219
|
+
workspaces = _a.sent();
|
|
220
|
+
return [2 /*return*/, {
|
|
221
|
+
type: "yarn",
|
|
222
|
+
workspaces: workspaces,
|
|
223
|
+
version: version,
|
|
224
|
+
isClassic: isClassic
|
|
197
225
|
}];
|
|
198
226
|
}
|
|
199
227
|
});
|
|
200
228
|
});
|
|
201
229
|
};
|
|
202
|
-
exports.
|
|
230
|
+
exports.getPackageManagerInfoBase = getPackageManagerInfoBase;
|