@catladder/pipeline 0.0.0-main-e8632d85 → 0.0.0-main-bdf1fe37
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/base/createAppBuildJob.js +1 -2
- package/dist/build/base/writeDotEnv.d.ts +2 -1
- package/dist/build/base/writeDotEnv.js +7 -2
- package/dist/build/node/buildJob.js +4 -4
- package/dist/build/node/cache.js +5 -6
- package/dist/build/node/testJob.js +9 -9
- package/dist/build/node/yarn.js +3 -6
- package/dist/build/sbom.js +4 -4
- package/dist/bundles/catladder-gitlab/index.js +43 -45
- package/dist/constants.js +1 -1
- package/dist/context/createComponentContext.d.ts +1 -2
- package/dist/context/createComponentContext.js +8 -4
- package/dist/pipeline/createJobsForComponent.d.ts +1 -1
- package/dist/pipeline/createJobsForComponent.js +2 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/context.d.ts +2 -2
- package/package.json +1 -1
- package/src/build/base/createAppBuildJob.ts +5 -2
- package/src/build/base/writeDotEnv.ts +6 -0
- package/src/build/node/buildJob.ts +2 -2
- package/src/build/node/cache.ts +3 -3
- package/src/build/node/testJob.ts +1 -1
- package/src/build/node/yarn.ts +3 -3
- package/src/build/sbom.ts +1 -1
- package/src/context/createComponentContext.ts +9 -4
- package/src/pipeline/createJobsForComponent.ts +2 -12
- package/src/types/context.ts +2 -2
|
@@ -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.
|
|
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
|
|
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((
|
|
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: (
|
|
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 ||
|
|
81
|
+
})) === null || _e === void 0 ? void 0 : _e.join("\n")
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
});
|
package/dist/build/node/cache.js
CHANGED
|
@@ -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 =
|
|
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
|
|
63
|
+
var _a;
|
|
65
64
|
if (policy === void 0) {
|
|
66
65
|
policy = "pull-push";
|
|
67
66
|
}
|
|
68
|
-
var 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((
|
|
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 &&
|
|
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
|
|
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 : [
|
|
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, (
|
|
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: (
|
|
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((
|
|
88
|
-
}), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (
|
|
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: (
|
|
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((
|
|
95
|
-
}), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (
|
|
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;
|
package/dist/build/node/yarn.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
package/dist/build/sbom.js
CHANGED
|
@@ -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
|
|
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(
|
|
15
|
-
var image = buildConfig.type === "custom" && buildConfig.sbom !== false ? (
|
|
16
|
-
var script = buildConfig.type === "custom" && buildConfig.sbom !== false ? (
|
|
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",
|
|
@@ -23268,8 +23268,7 @@ var createAppBuildJob = function (context, _a) {
|
|
|
23268
23268
|
cache: [],
|
|
23269
23269
|
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 : {}),
|
|
23270
23270
|
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 : {}),
|
|
23271
|
-
script: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(context.
|
|
23272
|
-
? (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),
|
|
23271
|
+
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),
|
|
23273
23272
|
artifacts: {
|
|
23274
23273
|
paths: [(0, path_1.join)(context.build.dir, "__build_info.json")],
|
|
23275
23274
|
reports: {
|
|
@@ -23470,7 +23469,7 @@ var __read = this && this.__read || function (o, n) {
|
|
|
23470
23469
|
Object.defineProperty(exports, "__esModule", ({
|
|
23471
23470
|
value: true
|
|
23472
23471
|
}));
|
|
23473
|
-
exports.writeDotEnv = void 0;
|
|
23472
|
+
exports.componentContextNeedsBuildTimeDotEnv = exports.writeDotEnv = void 0;
|
|
23474
23473
|
var lodash_1 = __nccwpck_require__(3255);
|
|
23475
23474
|
/**
|
|
23476
23475
|
* writes a .env file in the components folder
|
|
@@ -23495,6 +23494,11 @@ var writeDotEnv = function (context) {
|
|
|
23495
23494
|
return ["cat <<EOF > ".concat(context.build.dir, "/.env\n").concat(keyValueString, "\nEOF")];
|
|
23496
23495
|
};
|
|
23497
23496
|
exports.writeDotEnv = writeDotEnv;
|
|
23497
|
+
var componentContextNeedsBuildTimeDotEnv = function (context) {
|
|
23498
|
+
return context.componentConfig.dotEnv === true; // don't build when set to `local`
|
|
23499
|
+
};
|
|
23500
|
+
|
|
23501
|
+
exports.componentContextNeedsBuildTimeDotEnv = componentContextNeedsBuildTimeDotEnv;
|
|
23498
23502
|
|
|
23499
23503
|
/***/ }),
|
|
23500
23504
|
|
|
@@ -24066,7 +24070,7 @@ var cache_1 = __nccwpck_require__(3646);
|
|
|
24066
24070
|
var constants_1 = __nccwpck_require__(4899);
|
|
24067
24071
|
var yarn_1 = __nccwpck_require__(312);
|
|
24068
24072
|
var createNodeBuildJobs = function (context) {
|
|
24069
|
-
var _a, _b, _c, _d, _e
|
|
24073
|
+
var _a, _b, _c, _d, _e;
|
|
24070
24074
|
var buildConfig = context.build.config;
|
|
24071
24075
|
if (!(0, types_1.isOfBuildType)(buildConfig, "node", "node-static", "storybook")) {
|
|
24072
24076
|
throw new Error("deploy config is not node, node-static or storybook");
|
|
@@ -24080,7 +24084,7 @@ var createNodeBuildJobs = function (context) {
|
|
|
24080
24084
|
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),
|
|
24081
24085
|
script: __spreadArray(__spreadArray([], __read(yarnInstall), false), __read((_c = (0, utils_1.ensureArray)(buildConfig.buildCommand)) !== null && _c !== void 0 ? _c : []), false),
|
|
24082
24086
|
artifacts: {
|
|
24083
|
-
paths: __spreadArray([context.build.dir], __read((
|
|
24087
|
+
paths: __spreadArray([context.build.dir], __read((_d = context.build.packageManagerInfo.currentWorkspaceDependencies) !== null && _d !== void 0 ? _d : []), false).flatMap(function (dir) {
|
|
24084
24088
|
var _a, _b;
|
|
24085
24089
|
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) {
|
|
24086
24090
|
return (0, path_1.join)(dir, path);
|
|
@@ -24097,9 +24101,9 @@ var createNodeBuildJobs = function (context) {
|
|
|
24097
24101
|
variables: {
|
|
24098
24102
|
// only required for non static
|
|
24099
24103
|
DOCKER_COPY_AND_INSTALL_APP: (0, yarn_1.getDockerAppCopyAndBuildScript)(context.build),
|
|
24100
|
-
DOCKER_COPY_WORKSPACE_FILES: (
|
|
24104
|
+
DOCKER_COPY_WORKSPACE_FILES: (_e = context.build.packageManagerInfo.pathsToCopyInDocker.map(function (dir) {
|
|
24101
24105
|
return "COPY --chown=node:node ".concat(dir, " /app/").concat(dir);
|
|
24102
|
-
})) === null ||
|
|
24106
|
+
})) === null || _e === void 0 ? void 0 : _e.join("\n")
|
|
24103
24107
|
}
|
|
24104
24108
|
}
|
|
24105
24109
|
});
|
|
@@ -24158,11 +24162,10 @@ var path_1 = __nccwpck_require__(1017);
|
|
|
24158
24162
|
var slugify_1 = __importDefault(__nccwpck_require__(4035));
|
|
24159
24163
|
var lodash_1 = __nccwpck_require__(3255);
|
|
24160
24164
|
var getYarnCache = function (context, policy) {
|
|
24161
|
-
var _a;
|
|
24162
24165
|
if (policy === void 0) {
|
|
24163
24166
|
policy = "pull-push";
|
|
24164
24167
|
}
|
|
24165
|
-
var componentIsInWorkspace =
|
|
24168
|
+
var componentIsInWorkspace = context.packageManagerInfo.componentIsInWorkspace;
|
|
24166
24169
|
return [componentIsInWorkspace ? {
|
|
24167
24170
|
key: "yarn",
|
|
24168
24171
|
policy: policy,
|
|
@@ -24175,11 +24178,11 @@ var getYarnCache = function (context, policy) {
|
|
|
24175
24178
|
};
|
|
24176
24179
|
exports.getYarnCache = getYarnCache;
|
|
24177
24180
|
var getNodeModulesCache = function (context, policy) {
|
|
24178
|
-
var _a
|
|
24181
|
+
var _a;
|
|
24179
24182
|
if (policy === void 0) {
|
|
24180
24183
|
policy = "pull-push";
|
|
24181
24184
|
}
|
|
24182
|
-
var componentIsInWorkspace =
|
|
24185
|
+
var componentIsInWorkspace = context.packageManagerInfo.componentIsInWorkspace;
|
|
24183
24186
|
// 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.
|
|
24184
24187
|
// It would slow down all pipelines whenever one adds a new dependency as it will need to download all node_modules again.
|
|
24185
24188
|
return [{
|
|
@@ -24187,9 +24190,9 @@ var getNodeModulesCache = function (context, policy) {
|
|
|
24187
24190
|
key: componentIsInWorkspace ? "node-modules-workspace" : (0, slugify_1.default)(context.dir) + "-node-modules",
|
|
24188
24191
|
// 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
|
|
24189
24192
|
policy: policy,
|
|
24190
|
-
paths: __spreadArray([], __read(componentIsInWorkspace ? (0, lodash_1.uniq)(__spreadArray(["node_modules"], __read((
|
|
24193
|
+
paths: __spreadArray([], __read(componentIsInWorkspace ? (0, lodash_1.uniq)(__spreadArray(["node_modules"], __read((_a = context.packageManagerInfo.workspaces.map(function (w) {
|
|
24191
24194
|
return (0, path_1.join)(w.location, "node_modules");
|
|
24192
|
-
})) !== null &&
|
|
24195
|
+
})) !== null && _a !== void 0 ? _a : []), false)) : [(0, path_1.join)(context.dir, "node_modules")]), false)
|
|
24193
24196
|
}];
|
|
24194
24197
|
};
|
|
24195
24198
|
exports.getNodeModulesCache = getNodeModulesCache;
|
|
@@ -24432,7 +24435,7 @@ var constants_1 = __nccwpck_require__(4899);
|
|
|
24432
24435
|
var yarn_1 = __nccwpck_require__(312);
|
|
24433
24436
|
var createArtifactsConfig_1 = __nccwpck_require__(1446);
|
|
24434
24437
|
var createNodeTestJobs = function (context) {
|
|
24435
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u
|
|
24438
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
24436
24439
|
// don't run tests after release
|
|
24437
24440
|
// TODO: this will be replaced by using rules
|
|
24438
24441
|
if (context.trigger === "taggedRelease") {
|
|
@@ -24455,24 +24458,24 @@ var createNodeTestJobs = function (context) {
|
|
|
24455
24458
|
}, base), {
|
|
24456
24459
|
image: (_c = (_b = buildConfig.audit) === null || _b === void 0 ? void 0 : _b.jobImage) !== null && _c !== void 0 ? _c : defaultImage,
|
|
24457
24460
|
cache: undefined,
|
|
24458
|
-
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 : [
|
|
24461
|
+
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
|
|
24459
24462
|
]), false),
|
|
24460
24463
|
allow_failure: true
|
|
24461
|
-
}), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (
|
|
24464
|
+
}), (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;
|
|
24462
24465
|
var lintJob = buildConfig.lint !== false ? __assign(__assign(__assign({
|
|
24463
24466
|
name: "👮 lint"
|
|
24464
24467
|
}, base), {
|
|
24465
|
-
image: (
|
|
24468
|
+
image: (_j = (_h = buildConfig.lint) === null || _h === void 0 ? void 0 : _h.jobImage) !== null && _j !== void 0 ? _j : defaultImage,
|
|
24466
24469
|
cache: (0, cache_1.getNodeCache)(context.build),
|
|
24467
|
-
script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, yarn_1.ensureNodeVersion)(context.build)), false), ["cd ".concat(context.build.dir)], false), __read(yarnInstall), false), __read((
|
|
24468
|
-
}), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (
|
|
24470
|
+
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)
|
|
24471
|
+
}), (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;
|
|
24469
24472
|
var testJob = buildConfig.test !== false ? __assign(__assign(__assign({
|
|
24470
24473
|
name: "🧪 test"
|
|
24471
24474
|
}, base), {
|
|
24472
|
-
image: (
|
|
24475
|
+
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"),
|
|
24473
24476
|
cache: (0, cache_1.getNodeCache)(context.build),
|
|
24474
|
-
script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, yarn_1.ensureNodeVersion)(context.build)), false), ["cd ".concat(context.build.dir)], false), __read(yarnInstall), false), __read((
|
|
24475
|
-
}), (0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (
|
|
24477
|
+
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)
|
|
24478
|
+
}), (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;
|
|
24476
24479
|
return [auditJob, lintJob, testJob].filter(utils_1.notNil);
|
|
24477
24480
|
};
|
|
24478
24481
|
exports.createNodeTestJobs = createNodeTestJobs;
|
|
@@ -24527,8 +24530,7 @@ var YARN_INSTALL_CLASSIC = "yarn install --frozen-lockfile";
|
|
|
24527
24530
|
// FIXME: check why and when rebuild is needed
|
|
24528
24531
|
var YARN_BERRY_PROD_REBUILD = "yarn workspaces focus --production && yarn rebuild";
|
|
24529
24532
|
var getYarnInstallCommand = function (context) {
|
|
24530
|
-
|
|
24531
|
-
if ((_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.isClassic) {
|
|
24533
|
+
if (context.packageManagerInfo.isClassic) {
|
|
24532
24534
|
return YARN_INSTALL_CLASSIC;
|
|
24533
24535
|
}
|
|
24534
24536
|
return "yarn install --immutable";
|
|
@@ -24545,15 +24547,13 @@ var getYarnInstall = function (context, options) {
|
|
|
24545
24547
|
exports.getYarnInstall = getYarnInstall;
|
|
24546
24548
|
var DOCKER_COPY_FILES = "COPY --chown=node:node $APP_DIR .";
|
|
24547
24549
|
var getDockerAppCopyAndBuildScript = function (context) {
|
|
24548
|
-
|
|
24549
|
-
if ((_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.isClassic) {
|
|
24550
|
+
if (context.packageManagerInfo.isClassic) {
|
|
24550
24551
|
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());
|
|
24551
24552
|
}
|
|
24552
24553
|
// yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
|
|
24553
24554
|
// trying to import those fail on this version
|
|
24554
24555
|
var doesNotShipWithBuiltInPlugins = ["2", "3"].some(function (v) {
|
|
24555
|
-
|
|
24556
|
-
return (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.version.startsWith(v);
|
|
24556
|
+
return context.packageManagerInfo.version.startsWith(v);
|
|
24557
24557
|
});
|
|
24558
24558
|
var maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins ? "RUN yarn plugin import workspace-tools" : "";
|
|
24559
24559
|
// copy first everything and then install
|
|
@@ -24825,12 +24825,12 @@ var utils_1 = __nccwpck_require__(1815);
|
|
|
24825
24825
|
exports.SBOM_BUILD_JOB_NAME = "🧾 sbom";
|
|
24826
24826
|
exports.SBOM_FILE = "__sbom.json";
|
|
24827
24827
|
var createSbomBuildJob = function (context) {
|
|
24828
|
-
var _a, _b, _c, _d
|
|
24828
|
+
var _a, _b, _c, _d;
|
|
24829
24829
|
var buildConfig = context.build.config;
|
|
24830
24830
|
var defaultImage = "aquasec/trivy:0.38.3";
|
|
24831
|
-
var defaultScript = ["trivy fs --quiet --format cyclonedx --output \"".concat(exports.SBOM_FILE, "\" ").concat(
|
|
24832
|
-
var image = buildConfig.type === "custom" && buildConfig.sbom !== false ? (
|
|
24833
|
-
var script = buildConfig.type === "custom" && buildConfig.sbom !== false ? (
|
|
24831
|
+
var defaultScript = ["trivy fs --quiet --format cyclonedx --output \"".concat(exports.SBOM_FILE, "\" ").concat(context.build.packageManagerInfo.componentIsInWorkspace ? "." : context.build.dir)];
|
|
24832
|
+
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;
|
|
24833
|
+
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;
|
|
24834
24834
|
return {
|
|
24835
24835
|
name: exports.SBOM_BUILD_JOB_NAME,
|
|
24836
24836
|
stage: "build",
|
|
@@ -25052,7 +25052,7 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
25052
25052
|
value: true
|
|
25053
25053
|
}));
|
|
25054
25054
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
25055
|
-
exports.PIPELINE_IMAGE_TAG = "main-
|
|
25055
|
+
exports.PIPELINE_IMAGE_TAG = "main-bdf1fe37" || 0;
|
|
25056
25056
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
|
|
25057
25057
|
|
|
25058
25058
|
/***/ }),
|
|
@@ -25198,15 +25198,19 @@ var deploy_1 = __nccwpck_require__(1264);
|
|
|
25198
25198
|
var utils_1 = __nccwpck_require__(1815);
|
|
25199
25199
|
var getEnvironment_1 = __nccwpck_require__(4029);
|
|
25200
25200
|
var getEnvironmentContext_1 = __nccwpck_require__(3817);
|
|
25201
|
+
var packageManager_1 = __nccwpck_require__(3214);
|
|
25201
25202
|
var createComponentContext = function (ctx) {
|
|
25202
25203
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
25203
|
-
var envContext, componentConfigWithoutDefaults, defaults, componentConfig, environment, deploy, build, customJobs, dir, context, resolvedCustomJobs;
|
|
25204
|
+
var packageManagerInfo, envContext, componentConfigWithoutDefaults, defaults, componentConfig, environment, deploy, build, customJobs, dir, context, resolvedCustomJobs;
|
|
25204
25205
|
return __generator(this, function (_a) {
|
|
25205
25206
|
switch (_a.label) {
|
|
25206
25207
|
case 0:
|
|
25207
25208
|
if (!/^[a-z0-9-]+$/.test(ctx.componentName)) {
|
|
25208
25209
|
throw new Error("componentName may only contain lower case letters, numbers and -");
|
|
25209
25210
|
}
|
|
25211
|
+
return [4 /*yield*/, (0, packageManager_1.getPackageManagerInfo)(ctx.config, ctx.componentName)];
|
|
25212
|
+
case 1:
|
|
25213
|
+
packageManagerInfo = _a.sent();
|
|
25210
25214
|
envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(ctx);
|
|
25211
25215
|
componentConfigWithoutDefaults = envContext.envConfigRaw;
|
|
25212
25216
|
defaults = componentConfigWithoutDefaults.deploy ? {
|
|
@@ -25218,7 +25222,7 @@ var createComponentContext = function (ctx) {
|
|
|
25218
25222
|
};
|
|
25219
25223
|
componentConfig = (0, utils_1.mergeWithMergingArrays)(defaults, componentConfigWithoutDefaults);
|
|
25220
25224
|
return [4 /*yield*/, (0, getEnvironment_1.getEnvironment)(ctx)];
|
|
25221
|
-
case
|
|
25225
|
+
case 2:
|
|
25222
25226
|
environment = _a.sent();
|
|
25223
25227
|
deploy = componentConfig.deploy, build = componentConfig.build, customJobs = componentConfig.customJobs, dir = componentConfig.dir;
|
|
25224
25228
|
context = {
|
|
@@ -25226,7 +25230,7 @@ var createComponentContext = function (ctx) {
|
|
|
25226
25230
|
componentConfig: componentConfig,
|
|
25227
25231
|
build: {
|
|
25228
25232
|
dir: dir,
|
|
25229
|
-
packageManagerInfo:
|
|
25233
|
+
packageManagerInfo: packageManagerInfo,
|
|
25230
25234
|
config: build
|
|
25231
25235
|
},
|
|
25232
25236
|
deploy: deploy ? {
|
|
@@ -25234,7 +25238,7 @@ var createComponentContext = function (ctx) {
|
|
|
25234
25238
|
} : null,
|
|
25235
25239
|
componentName: ctx.componentName,
|
|
25236
25240
|
environment: environment,
|
|
25237
|
-
packageManagerInfo:
|
|
25241
|
+
packageManagerInfo: packageManagerInfo,
|
|
25238
25242
|
pipelineType: ctx.pipelineType,
|
|
25239
25243
|
trigger: ctx.trigger
|
|
25240
25244
|
};
|
|
@@ -29770,7 +29774,6 @@ exports.createJobsForComponent = void 0;
|
|
|
29770
29774
|
var build_1 = __nccwpck_require__(2004);
|
|
29771
29775
|
var context_1 = __nccwpck_require__(7123);
|
|
29772
29776
|
var deploy_1 = __nccwpck_require__(1264);
|
|
29773
|
-
var packageManager_1 = __nccwpck_require__(3214);
|
|
29774
29777
|
var injectDefaultVarsInCustomJobs = function (context, jobs) {
|
|
29775
29778
|
return jobs.map(function (_a) {
|
|
29776
29779
|
var _b;
|
|
@@ -29797,17 +29800,12 @@ var createRawJobs = function (context) {
|
|
|
29797
29800
|
};
|
|
29798
29801
|
var createJobsForComponent = function (contextContext) {
|
|
29799
29802
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
29800
|
-
var
|
|
29803
|
+
var context;
|
|
29801
29804
|
return __generator(this, function (_a) {
|
|
29802
29805
|
switch (_a.label) {
|
|
29803
29806
|
case 0:
|
|
29804
|
-
return [4 /*yield*/, (0,
|
|
29807
|
+
return [4 /*yield*/, (0, context_1.createComponentContext)(contextContext)];
|
|
29805
29808
|
case 1:
|
|
29806
|
-
packageManagerInfo = _a.sent();
|
|
29807
|
-
return [4 /*yield*/, (0, context_1.createComponentContext)(__assign(__assign({}, contextContext), {
|
|
29808
|
-
packageManagerInfo: packageManagerInfo
|
|
29809
|
-
}))];
|
|
29810
|
-
case 2:
|
|
29811
29809
|
context = _a.sent();
|
|
29812
29810
|
return [2 /*return*/, createRawJobs(context).map(function (job) {
|
|
29813
29811
|
return __assign(__assign({}, job), {
|
package/dist/constants.js
CHANGED
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
|
|
7
|
-
exports.PIPELINE_IMAGE_TAG = "main-
|
|
7
|
+
exports.PIPELINE_IMAGE_TAG = "main-bdf1fe37" || "latest";
|
|
8
8
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { PipelineType } from "../types";
|
|
2
2
|
import type { Config, PipelineTrigger } from "../types/config";
|
|
3
|
-
import type { ComponentContext
|
|
3
|
+
import type { ComponentContext } from "../types/context";
|
|
4
4
|
export type CreateComponentContextContext = {
|
|
5
5
|
config: Config;
|
|
6
6
|
componentName: string;
|
|
7
7
|
env: string;
|
|
8
8
|
pipelineType?: PipelineType;
|
|
9
9
|
trigger?: PipelineTrigger;
|
|
10
|
-
packageManagerInfo?: PackageManagerInfo;
|
|
11
10
|
};
|
|
12
11
|
export declare const createComponentContext: (ctx: CreateComponentContextContext) => Promise<ComponentContext>;
|
|
13
12
|
/**
|
|
@@ -135,15 +135,19 @@ var deploy_1 = require("../deploy");
|
|
|
135
135
|
var utils_1 = require("../utils");
|
|
136
136
|
var getEnvironment_1 = require("./getEnvironment");
|
|
137
137
|
var getEnvironmentContext_1 = require("./getEnvironmentContext");
|
|
138
|
+
var packageManager_1 = require("../pipeline/packageManager");
|
|
138
139
|
var createComponentContext = function (ctx) {
|
|
139
140
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
140
|
-
var envContext, componentConfigWithoutDefaults, defaults, componentConfig, environment, deploy, build, customJobs, dir, context, resolvedCustomJobs;
|
|
141
|
+
var packageManagerInfo, envContext, componentConfigWithoutDefaults, defaults, componentConfig, environment, deploy, build, customJobs, dir, context, resolvedCustomJobs;
|
|
141
142
|
return __generator(this, function (_a) {
|
|
142
143
|
switch (_a.label) {
|
|
143
144
|
case 0:
|
|
144
145
|
if (!/^[a-z0-9-]+$/.test(ctx.componentName)) {
|
|
145
146
|
throw new Error("componentName may only contain lower case letters, numbers and -");
|
|
146
147
|
}
|
|
148
|
+
return [4 /*yield*/, (0, packageManager_1.getPackageManagerInfo)(ctx.config, ctx.componentName)];
|
|
149
|
+
case 1:
|
|
150
|
+
packageManagerInfo = _a.sent();
|
|
147
151
|
envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(ctx);
|
|
148
152
|
componentConfigWithoutDefaults = envContext.envConfigRaw;
|
|
149
153
|
defaults = componentConfigWithoutDefaults.deploy ? {
|
|
@@ -155,7 +159,7 @@ var createComponentContext = function (ctx) {
|
|
|
155
159
|
};
|
|
156
160
|
componentConfig = (0, utils_1.mergeWithMergingArrays)(defaults, componentConfigWithoutDefaults);
|
|
157
161
|
return [4 /*yield*/, (0, getEnvironment_1.getEnvironment)(ctx)];
|
|
158
|
-
case
|
|
162
|
+
case 2:
|
|
159
163
|
environment = _a.sent();
|
|
160
164
|
deploy = componentConfig.deploy, build = componentConfig.build, customJobs = componentConfig.customJobs, dir = componentConfig.dir;
|
|
161
165
|
context = {
|
|
@@ -163,7 +167,7 @@ var createComponentContext = function (ctx) {
|
|
|
163
167
|
componentConfig: componentConfig,
|
|
164
168
|
build: {
|
|
165
169
|
dir: dir,
|
|
166
|
-
packageManagerInfo:
|
|
170
|
+
packageManagerInfo: packageManagerInfo,
|
|
167
171
|
config: build
|
|
168
172
|
},
|
|
169
173
|
deploy: deploy ? {
|
|
@@ -171,7 +175,7 @@ var createComponentContext = function (ctx) {
|
|
|
171
175
|
} : null,
|
|
172
176
|
componentName: ctx.componentName,
|
|
173
177
|
environment: environment,
|
|
174
|
-
packageManagerInfo:
|
|
178
|
+
packageManagerInfo: packageManagerInfo,
|
|
175
179
|
pipelineType: ctx.pipelineType,
|
|
176
180
|
trigger: ctx.trigger
|
|
177
181
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CreateComponentContextContext } from "../context";
|
|
2
2
|
import type { CatladderJobWithContext } from "../types/context";
|
|
3
|
-
export declare const createJobsForComponent: (contextContext:
|
|
3
|
+
export declare const createJobsForComponent: (contextContext: CreateComponentContextContext) => Promise<Array<CatladderJobWithContext>>;
|
|
@@ -171,7 +171,6 @@ exports.createJobsForComponent = void 0;
|
|
|
171
171
|
var build_1 = require("../build");
|
|
172
172
|
var context_1 = require("../context");
|
|
173
173
|
var deploy_1 = require("../deploy");
|
|
174
|
-
var packageManager_1 = require("./packageManager");
|
|
175
174
|
var injectDefaultVarsInCustomJobs = function (context, jobs) {
|
|
176
175
|
return jobs.map(function (_a) {
|
|
177
176
|
var _b;
|
|
@@ -198,17 +197,12 @@ var createRawJobs = function (context) {
|
|
|
198
197
|
};
|
|
199
198
|
var createJobsForComponent = function (contextContext) {
|
|
200
199
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
201
|
-
var
|
|
200
|
+
var context;
|
|
202
201
|
return __generator(this, function (_a) {
|
|
203
202
|
switch (_a.label) {
|
|
204
203
|
case 0:
|
|
205
|
-
return [4 /*yield*/, (0,
|
|
204
|
+
return [4 /*yield*/, (0, context_1.createComponentContext)(contextContext)];
|
|
206
205
|
case 1:
|
|
207
|
-
packageManagerInfo = _a.sent();
|
|
208
|
-
return [4 /*yield*/, (0, context_1.createComponentContext)(__assign(__assign({}, contextContext), {
|
|
209
|
-
packageManagerInfo: packageManagerInfo
|
|
210
|
-
}))];
|
|
211
|
-
case 2:
|
|
212
206
|
context = _a.sent();
|
|
213
207
|
return [2 /*return*/, createRawJobs(context).map(function (job) {
|
|
214
208
|
return __assign(__assign({}, job), {
|