@catladder/pipeline 1.149.2 → 1.149.4

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.
@@ -76,8 +76,7 @@ var createAppBuildJob = function (context, _a) {
76
76
  cache: [],
77
77
  variables: __assign(__assign(__assign(__assign({}, variables !== null && variables !== void 0 ? variables : {}), context.environment.envVars), context.environment.jobOnlyVars.build.envVars), (_b = context.build.config.extraVars) !== null && _b !== void 0 ? _b : {}),
78
78
  runnerVariables: __assign(__assign(__assign({}, constants_1.RUNNER_BUILD_RESOURCE_VARIABLES), runnerVariables !== null && runnerVariables !== void 0 ? runnerVariables : {}), (_c = context.build.config.runnerVariables) !== null && _c !== void 0 ? _c : {}),
79
- script: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(context.componentConfig.dotEnv === true // don't build when set to `local`
80
- ? (0, writeDotEnv_1.writeDotEnv)(context) : []), false), __read((0, writeBuildInfo_1.writeBuildInfo)(context)), false), __read((0, yarn_1.ensureNodeVersion)(context.build)), false), ["cd ".concat(context.build.dir)], false), __read((_d = (0, utils_1.ensureArray)(script)) !== null && _d !== void 0 ? _d : []), false),
79
+ script: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, writeDotEnv_1.componentContextNeedsBuildTimeDotEnv)(context) ? (0, writeDotEnv_1.writeDotEnv)(context) : []), false), __read((0, writeBuildInfo_1.writeBuildInfo)(context)), false), __read((0, yarn_1.ensureNodeVersion)(context.build)), false), ["cd ".concat(context.build.dir)], false), __read((_d = (0, utils_1.ensureArray)(script)) !== null && _d !== void 0 ? _d : []), false),
81
80
  artifacts: {
82
81
  paths: [(0, path_1.join)(context.build.dir, "__build_info.json")],
83
82
  reports: {
@@ -4,4 +4,5 @@ import type { ComponentContext } from "../../types";
4
4
  * @param context
5
5
  * @returns
6
6
  */
7
- export declare const writeDotEnv: (context: ComponentContext) => string[];
7
+ export declare const writeDotEnv: (context: ComponentContext) => string[];
8
+ export declare const componentContextNeedsBuildTimeDotEnv: (context: ComponentContext) => boolean;
@@ -25,7 +25,7 @@ var __read = this && this.__read || function (o, n) {
25
25
  Object.defineProperty(exports, "__esModule", {
26
26
  value: true
27
27
  });
28
- exports.writeDotEnv = void 0;
28
+ exports.componentContextNeedsBuildTimeDotEnv = exports.writeDotEnv = void 0;
29
29
  var lodash_1 = require("lodash");
30
30
  /**
31
31
  * writes a .env file in the components folder
@@ -49,4 +49,9 @@ var writeDotEnv = function (context) {
49
49
  }).join("\n");
50
50
  return ["cat <<EOF > ".concat(context.build.dir, "/.env\n").concat(keyValueString, "\nEOF")];
51
51
  };
52
- exports.writeDotEnv = writeDotEnv;
52
+ exports.writeDotEnv = writeDotEnv;
53
+ var componentContextNeedsBuildTimeDotEnv = function (context) {
54
+ return context.componentConfig.dotEnv === true; // don't build when set to `local`
55
+ };
56
+
57
+ exports.componentContextNeedsBuildTimeDotEnv = componentContextNeedsBuildTimeDotEnv;
@@ -45,7 +45,7 @@ var cache_1 = require("./cache");
45
45
  var constants_1 = require("./constants");
46
46
  var yarn_1 = require("./yarn");
47
47
  var createNodeBuildJobs = function (context) {
48
- var _a, _b, _c, _d, _e, _f, _g;
48
+ var _a, _b, _c, _d, _e;
49
49
  var buildConfig = context.build.config;
50
50
  if (!(0, types_1.isOfBuildType)(buildConfig, "node", "node-static", "storybook")) {
51
51
  throw new Error("deploy config is not node, node-static or storybook");
@@ -59,7 +59,7 @@ var createNodeBuildJobs = function (context) {
59
59
  cache: __spreadArray(__spreadArray(__spreadArray([], __read((_b = (0, utils_1.ensureArray)(buildConfig.jobCache)) !== null && _b !== void 0 ? _b : []), false), __read((0, cache_1.getNodeCache)(context.build)), false), __read((0, cache_1.getNextCache)(context)), false),
60
60
  script: __spreadArray(__spreadArray([], __read(yarnInstall), false), __read((_c = (0, utils_1.ensureArray)(buildConfig.buildCommand)) !== null && _c !== void 0 ? _c : []), false),
61
61
  artifacts: {
62
- paths: __spreadArray([context.build.dir], __read((_e = (_d = context.build.packageManagerInfo) === null || _d === void 0 ? void 0 : _d.currentWorkspaceDependencies) !== null && _e !== void 0 ? _e : []), false).flatMap(function (dir) {
62
+ paths: __spreadArray([context.build.dir], __read((_d = context.build.packageManagerInfo.currentWorkspaceDependencies) !== null && _d !== void 0 ? _d : []), false).flatMap(function (dir) {
63
63
  var _a, _b;
64
64
  return __spreadArray([(0, path_1.join)(dir, "__build_info.json"), (0, path_1.join)(dir, "dist"), (0, path_1.join)(dir, ".next")], __read((_b = (_a = buildConfig.artifactsPaths) === null || _a === void 0 ? void 0 : _a.map(function (path) {
65
65
  return (0, path_1.join)(dir, path);
@@ -76,9 +76,9 @@ var createNodeBuildJobs = function (context) {
76
76
  variables: {
77
77
  // only required for non static
78
78
  DOCKER_COPY_AND_INSTALL_APP: (0, yarn_1.getDockerAppCopyAndBuildScript)(context.build),
79
- DOCKER_COPY_WORKSPACE_FILES: (_g = (_f = context.build.packageManagerInfo) === null || _f === void 0 ? void 0 : _f.pathsToCopyInDocker.map(function (dir) {
79
+ DOCKER_COPY_WORKSPACE_FILES: (_e = context.build.packageManagerInfo.pathsToCopyInDocker.map(function (dir) {
80
80
  return "COPY --chown=node:node ".concat(dir, " /app/").concat(dir);
81
- })) === null || _g === void 0 ? void 0 : _g.join("\n")
81
+ })) === null || _e === void 0 ? void 0 : _e.join("\n")
82
82
  }
83
83
  }
84
84
  });
@@ -44,11 +44,10 @@ var path_1 = require("path");
44
44
  var slugify_1 = __importDefault(require("slugify"));
45
45
  var lodash_1 = require("lodash");
46
46
  var getYarnCache = function (context, policy) {
47
- var _a;
48
47
  if (policy === void 0) {
49
48
  policy = "pull-push";
50
49
  }
51
- var componentIsInWorkspace = (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.componentIsInWorkspace;
50
+ var componentIsInWorkspace = context.packageManagerInfo.componentIsInWorkspace;
52
51
  return [componentIsInWorkspace ? {
53
52
  key: "yarn",
54
53
  policy: policy,
@@ -61,11 +60,11 @@ var getYarnCache = function (context, policy) {
61
60
  };
62
61
  exports.getYarnCache = getYarnCache;
63
62
  var getNodeModulesCache = function (context, policy) {
64
- var _a, _b, _c;
63
+ var _a;
65
64
  if (policy === void 0) {
66
65
  policy = "pull-push";
67
66
  }
68
- var componentIsInWorkspace = (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.componentIsInWorkspace;
67
+ var componentIsInWorkspace = context.packageManagerInfo.componentIsInWorkspace;
69
68
  // We intentionally do not use the contents of yarn.lock as a cache key, as yarn install should always guarantee that the files are updated, but it can still use part of the cache if not all packages are up-to-date.
70
69
  // It would slow down all pipelines whenever one adds a new dependency as it will need to download all node_modules again.
71
70
  return [{
@@ -73,9 +72,9 @@ var getNodeModulesCache = function (context, policy) {
73
72
  key: componentIsInWorkspace ? "node-modules-workspace" : (0, slugify_1.default)(context.dir) + "-node-modules",
74
73
  // we use the dirname, not the component name, because in certain cases we have two apps in the same directory and want to share the cache, e.g. when having storybook in the same package.json
75
74
  policy: policy,
76
- paths: __spreadArray([], __read(componentIsInWorkspace ? (0, lodash_1.uniq)(__spreadArray(["node_modules"], __read((_c = (_b = context.packageManagerInfo) === null || _b === void 0 ? void 0 : _b.workspaces.map(function (w) {
75
+ paths: __spreadArray([], __read(componentIsInWorkspace ? (0, lodash_1.uniq)(__spreadArray(["node_modules"], __read((_a = context.packageManagerInfo.workspaces.map(function (w) {
77
76
  return (0, path_1.join)(w.location, "node_modules");
78
- })) !== null && _c !== void 0 ? _c : []), false)) : [(0, path_1.join)(context.dir, "node_modules")]), false)
77
+ })) !== null && _a !== void 0 ? _a : []), false)) : [(0, path_1.join)(context.dir, "node_modules")]), false)
79
78
  }];
80
79
  };
81
80
  exports.getNodeModulesCache = getNodeModulesCache;
@@ -52,7 +52,7 @@ var constants_1 = require("./constants");
52
52
  var yarn_1 = require("./yarn");
53
53
  var createArtifactsConfig_1 = require("../base/createArtifactsConfig");
54
54
  var createNodeTestJobs = function (context) {
55
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
55
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
56
56
  // don't run tests after release
57
57
  // TODO: this will be replaced by using rules
58
58
  if (context.trigger === "taggedRelease") {
@@ -75,24 +75,24 @@ var createNodeTestJobs = function (context) {
75
75
  }, base), {
76
76
  image: (_c = (_b = buildConfig.audit) === null || _b === void 0 ? void 0 : _b.jobImage) !== null && _c !== void 0 ? _c : defaultImage,
77
77
  cache: undefined,
78
- script: __spreadArray(["cd ".concat(context.build.dir)], __read((_e = (0, utils_1.ensureArray)((_d = buildConfig.audit) === null || _d === void 0 ? void 0 : _d.command)) !== null && _e !== void 0 ? _e : [((_f = context.build.packageManagerInfo) === null || _f === void 0 ? void 0 : _f.isClassic) ? "yarn audit" : "yarn npm audit --environment production" // yarn 2
78
+ script: __spreadArray(["cd ".concat(context.build.dir)], __read((_e = (0, utils_1.ensureArray)((_d = buildConfig.audit) === null || _d === void 0 ? void 0 : _d.command)) !== null && _e !== void 0 ? _e : [context.build.packageManagerInfo.isClassic ? "yarn audit" : "yarn npm audit --environment production" // yarn 2
79
79
  ]), false),
80
80
  allow_failure: true
81
- }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_g = buildConfig.audit) === null || _g === void 0 ? void 0 : _g.artifactsReports, (_h = buildConfig.audit) === null || _h === void 0 ? void 0 : _h.artifacts)) : null;
81
+ }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_f = buildConfig.audit) === null || _f === void 0 ? void 0 : _f.artifactsReports, (_g = buildConfig.audit) === null || _g === void 0 ? void 0 : _g.artifacts)) : null;
82
82
  var lintJob = buildConfig.lint !== false ? __assign(__assign(__assign({
83
83
  name: "👮 lint"
84
84
  }, base), {
85
- image: (_k = (_j = buildConfig.lint) === null || _j === void 0 ? void 0 : _j.jobImage) !== null && _k !== void 0 ? _k : defaultImage,
85
+ image: (_j = (_h = buildConfig.lint) === null || _h === void 0 ? void 0 : _h.jobImage) !== null && _j !== void 0 ? _j : defaultImage,
86
86
  cache: (0, cache_1.getNodeCache)(context.build),
87
- script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, yarn_1.ensureNodeVersion)(context.build)), false), ["cd ".concat(context.build.dir)], false), __read(yarnInstall), false), __read((_m = (0, utils_1.ensureArray)((_l = buildConfig.lint) === null || _l === void 0 ? void 0 : _l.command)) !== null && _m !== void 0 ? _m : ["yarn lint"]), false)
88
- }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_o = buildConfig.lint) === null || _o === void 0 ? void 0 : _o.artifactsReports, (_p = buildConfig.lint) === null || _p === void 0 ? void 0 : _p.artifacts)) : null;
87
+ script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, yarn_1.ensureNodeVersion)(context.build)), false), ["cd ".concat(context.build.dir)], false), __read(yarnInstall), false), __read((_l = (0, utils_1.ensureArray)((_k = buildConfig.lint) === null || _k === void 0 ? void 0 : _k.command)) !== null && _l !== void 0 ? _l : ["yarn lint"]), false)
88
+ }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_m = buildConfig.lint) === null || _m === void 0 ? void 0 : _m.artifactsReports, (_o = buildConfig.lint) === null || _o === void 0 ? void 0 : _o.artifacts)) : null;
89
89
  var testJob = buildConfig.test !== false ? __assign(__assign(__assign({
90
90
  name: "🧪 test"
91
91
  }, base), {
92
- image: (_r = (_q = buildConfig.test) === null || _q === void 0 ? void 0 : _q.jobImage) !== null && _r !== void 0 ? _r : (0, runner_1.getRunnerImage)("jobs-testing-chrome"),
92
+ image: (_q = (_p = buildConfig.test) === null || _p === void 0 ? void 0 : _p.jobImage) !== null && _q !== void 0 ? _q : (0, runner_1.getRunnerImage)("jobs-testing-chrome"),
93
93
  cache: (0, cache_1.getNodeCache)(context.build),
94
- script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, yarn_1.ensureNodeVersion)(context.build)), false), ["cd ".concat(context.build.dir)], false), __read(yarnInstall), false), __read((_t = (0, utils_1.ensureArray)((_s = buildConfig.test) === null || _s === void 0 ? void 0 : _s.command)) !== null && _t !== void 0 ? _t : ["yarn test"]), false)
95
- }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_u = buildConfig.test) === null || _u === void 0 ? void 0 : _u.artifactsReports, (_v = buildConfig.test) === null || _v === void 0 ? void 0 : _v.artifacts)) : null;
94
+ script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, yarn_1.ensureNodeVersion)(context.build)), false), ["cd ".concat(context.build.dir)], false), __read(yarnInstall), false), __read((_s = (0, utils_1.ensureArray)((_r = buildConfig.test) === null || _r === void 0 ? void 0 : _r.command)) !== null && _s !== void 0 ? _s : ["yarn test"]), false)
95
+ }), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_t = buildConfig.test) === null || _t === void 0 ? void 0 : _t.artifactsReports, (_u = buildConfig.test) === null || _u === void 0 ? void 0 : _u.artifacts)) : null;
96
96
  return [auditJob, lintJob, testJob].filter(utils_1.notNil);
97
97
  };
98
98
  exports.createNodeTestJobs = createNodeTestJobs;
@@ -42,8 +42,7 @@ var YARN_INSTALL_CLASSIC = "yarn install --frozen-lockfile";
42
42
  // FIXME: check why and when rebuild is needed
43
43
  var YARN_BERRY_PROD_REBUILD = "yarn workspaces focus --production && yarn rebuild";
44
44
  var getYarnInstallCommand = function (context) {
45
- var _a;
46
- if ((_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.isClassic) {
45
+ if (context.packageManagerInfo.isClassic) {
47
46
  return YARN_INSTALL_CLASSIC;
48
47
  }
49
48
  return "yarn install --immutable";
@@ -60,15 +59,13 @@ var getYarnInstall = function (context, options) {
60
59
  exports.getYarnInstall = getYarnInstall;
61
60
  var DOCKER_COPY_FILES = "COPY --chown=node:node $APP_DIR .";
62
61
  var getDockerAppCopyAndBuildScript = function (context) {
63
- var _a;
64
- if ((_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.isClassic) {
62
+ if (context.packageManagerInfo.isClassic) {
65
63
  return new BashExpression_1.BashExpression("\nRUN ".concat(YARN_INSTALL_CLASSIC, " --production --ignore-scripts\n").concat(DOCKER_COPY_FILES, "\nRUN ").concat(YARN_INSTALL_CLASSIC, " --production \n ").trim());
66
64
  }
67
65
  // yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
68
66
  // trying to import those fail on this version
69
67
  var doesNotShipWithBuiltInPlugins = ["2", "3"].some(function (v) {
70
- var _a;
71
- return (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.version.startsWith(v);
68
+ return context.packageManagerInfo.version.startsWith(v);
72
69
  });
73
70
  var maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins ? "RUN yarn plugin import workspace-tools" : "";
74
71
  // copy first everything and then install
@@ -8,12 +8,12 @@ var utils_1 = require("../utils");
8
8
  exports.SBOM_BUILD_JOB_NAME = "🧾 sbom";
9
9
  exports.SBOM_FILE = "__sbom.json";
10
10
  var createSbomBuildJob = function (context) {
11
- var _a, _b, _c, _d, _e;
11
+ var _a, _b, _c, _d;
12
12
  var buildConfig = context.build.config;
13
13
  var defaultImage = "aquasec/trivy:0.38.3";
14
- var defaultScript = ["trivy fs --quiet --format cyclonedx --output \"".concat(exports.SBOM_FILE, "\" ").concat(((_a = context.build.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.componentIsInWorkspace) ? "." : context.build.dir)];
15
- var image = buildConfig.type === "custom" && buildConfig.sbom !== false ? (_c = (_b = buildConfig.sbom) === null || _b === void 0 ? void 0 : _b.jobImage) !== null && _c !== void 0 ? _c : defaultImage : defaultImage;
16
- var script = buildConfig.type === "custom" && buildConfig.sbom !== false ? (_e = (0, utils_1.ensureArray)((_d = buildConfig.sbom) === null || _d === void 0 ? void 0 : _d.command)) !== null && _e !== void 0 ? _e : defaultScript : defaultScript;
14
+ var defaultScript = ["trivy fs --quiet --format cyclonedx --output \"".concat(exports.SBOM_FILE, "\" ").concat(context.build.packageManagerInfo.componentIsInWorkspace ? "." : context.build.dir)];
15
+ var image = buildConfig.type === "custom" && buildConfig.sbom !== false ? (_b = (_a = buildConfig.sbom) === null || _a === void 0 ? void 0 : _a.jobImage) !== null && _b !== void 0 ? _b : defaultImage : defaultImage;
16
+ var script = buildConfig.type === "custom" && buildConfig.sbom !== false ? (_d = (0, utils_1.ensureArray)((_c = buildConfig.sbom) === null || _c === void 0 ? void 0 : _c.command)) !== null && _d !== void 0 ? _d : defaultScript : defaultScript;
17
17
  return {
18
18
  name: exports.SBOM_BUILD_JOB_NAME,
19
19
  stage: "build",