UNPKG

@catladder/pipeline

Version:

Panter workflow for cloud CI/CD and DevOps

97 lines (96 loc) 3.61 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 __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.createBuildJobArtifacts = void 0; var path_1 = require("path"); var types_1 = require("../../types"); var lodash_1 = require("lodash"); var writeDotEnv_1 = require("../base/writeDotEnv"); var createBuildJobArtifacts = function (context) { var _a, _b; var paths = context.type === "workspace" ? context.components.flatMap(function (c) { return getArtifactsPathForComponent(c); }) : getArtifactsPathForComponent(context, ["__build_info.json"]); // esxclude .env files if generated var exclude = context.type === "workspace" ? context.components.flatMap(function (c) { return getDotEnvPathsForComponent(c); }) : getDotEnvPathsForComponent(context); return __assign(__assign({ paths: (0, lodash_1.uniq)(paths).sort(function (a, b) { return a.localeCompare(b); }) }, exclude.length > 0 ? { exclude: exclude } : {}), { expire_in: "1 day", when: "always", reports: // TODO: support for junit reports in other builds context.type === "component" && (0, types_1.componentContextIsStandaloneBuild)(context) ? { junit: (_b = (_a = context.build.config.artifactsReports) === null || _a === void 0 ? void 0 : _a.junit) === null || _b === void 0 ? void 0 : _b.map(function (p) { return (0, path_1.join)(context.build.dir, p); }) } : {} }); }; exports.createBuildJobArtifacts = createBuildJobArtifacts; var getArtifactsPathForComponent = function (c, additionalPaths) { var _a, _b; return (_b = __spreadArray(__spreadArray([], __read(c.build.type !== "disabled" ? (_a = c.build.config.artifactsPaths) !== null && _a !== void 0 ? _a : [] : []), false), __read(additionalPaths !== null && additionalPaths !== void 0 ? additionalPaths : []), false)) === null || _b === void 0 ? void 0 : _b.flatMap(function (artifact) { return c.build // in theory, we only need "direct", // but in some cases project may have packages in the workspace that create build artifacts, which aren't components // this highly depends on the build tool. To be safe, we get all .getComponentDirs("all").flatMap(function (cDir) { return (0, path_1.join)(cDir, artifact); }); }); }; var getDotEnvPathsForComponent = function (c) { if ((0, writeDotEnv_1.componentContextNeedsBuildTimeDotEnv)(c)) { return [(0, path_1.join)(c.build.dir, ".env")]; } return []; };