UNPKG

@catladder/cli

Version:

Panter cli tool for cloud CI/CD and DevOps

52 lines 2.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createBuildJobArtifacts = void 0; const path_1 = require("path"); const types_1 = require("../../types"); const lodash_1 = require("lodash"); const writeDotEnv_1 = require("../base/writeDotEnv"); const createBuildJobArtifacts = (context) => { var _a, _b; const paths = context.type === "workspace" ? context.components.flatMap((c) => getArtifactsPathForComponent(c)) : getArtifactsPathForComponent(context, ["__build_info.json"]); // esxclude .env files if generated const exclude = context.type === "workspace" ? context.components.flatMap((c) => getDotEnvPathsForComponent(c)) : getDotEnvPathsForComponent(context); return { paths: (0, lodash_1.uniq)(paths).sort((a, b) => a.localeCompare(b)), ...(exclude.length > 0 ? { 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((p) => (0, path_1.join)(context.build.dir, p)), } : {}, }; }; exports.createBuildJobArtifacts = createBuildJobArtifacts; const getArtifactsPathForComponent = (c, additionalPaths) => { var _a, _b; return (_b = [ ...(c.build.type !== "disabled" ? ((_a = c.build.config.artifactsPaths) !== null && _a !== void 0 ? _a : []) : []), ...(additionalPaths !== null && additionalPaths !== void 0 ? additionalPaths : []), ]) === null || _b === void 0 ? void 0 : _b.flatMap((artifact) => 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((cDir) => (0, path_1.join)(cDir, artifact))); }; const getDotEnvPathsForComponent = (c) => { if ((0, writeDotEnv_1.componentContextNeedsBuildTimeDotEnv)(c)) { return [(0, path_1.join)(c.build.dir, ".env")]; } return []; }; //# sourceMappingURL=createBuildJobArtifact.js.map