UNPKG

@catladder/pipeline

Version:

Panter workflow for cloud CI/CD and DevOps

89 lines (88 loc) 4.04 kB
"use strict"; var __assign = this && this.__assign || function () { __assign = Object.assign || function (t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __rest = this && this.__rest || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; var __read = this && this.__read || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spreadArray = this && this.__spreadArray || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createAppBuildJob = void 0; var lodash_1 = require("lodash"); var __1 = require("../.."); var utils_1 = require("../../utils"); var createBuildJobArtifact_1 = require("../artifacts/createBuildJobArtifact"); var createJobCache_1 = require("../cache/createJobCache"); var yarn_1 = require("../node/yarn"); var constants_1 = require("./constants"); var writeBuildInfo_1 = require("./writeBuildInfo"); var writeDotEnv_1 = require("./writeDotEnv"); var createAppBuildJob = function (context, _a) { var _b; var script = _a.script, variables = _a.variables, runnerVariables = _a.runnerVariables, cache = _a.cache, def = __rest(_a, ["script", "variables", "runnerVariables", "cache"]); return (0, lodash_1.merge)({ name: constants_1.APP_BUILD_JOB_NAME, envMode: "jobPerEnv", stage: "build", image: (0, __1.getRunnerImage)("jobs-default"), needs: [], cache: cache ? (0, createJobCache_1.createJobCacheFromCacheConfigs)(context, cache) : undefined, variables: __assign(__assign({}, variables !== null && variables !== void 0 ? variables : {}), context.type === "component" ? __assign(__assign({}, context.environment.envVars), context.environment.jobOnlyVars.build.envVars) : {}), runnerVariables: __assign(__assign(__assign({}, constants_1.RUNNER_BUILD_RESOURCE_VARIABLES), runnerVariables !== null && runnerVariables !== void 0 ? runnerVariables : {}), (_b = context.build.config.runnerVariables) !== null && _b !== void 0 ? _b : {}), script: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(context.type === "component" ? (0, writeDotEnv_1.componentContextNeedsBuildTimeDotEnv)(context) ? (0, writeDotEnv_1.writeDotEnv)(context) : [] : context.type === "workspace" ? context.components.filter(function (c) { return (0, writeDotEnv_1.componentContextNeedsBuildTimeDotEnv)(c); }).flatMap(function (c) { return (0, writeDotEnv_1.writeDotEnv)(c); }) : []), false), __read(context.type === "component" ? (0, writeBuildInfo_1.writeBuildInfo)(context) : []), false), __read((0, yarn_1.ensureNodeVersion)(context)), false), ["cd ".concat(context.build.dir)], false), __read((0, utils_1.ensureArray)(script)), false), artifacts: (0, createBuildJobArtifact_1.createBuildJobArtifacts)(context) }, def); }; exports.createAppBuildJob = createAppBuildJob;