@catladder/pipeline 3.47.1 → 4.0.0
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/createBuildJobDefinition.js +1 -1
- package/dist/build/custom/buildJob.js +1 -1
- package/dist/build/index.d.ts +2 -2
- package/dist/build/node/buildJob.d.ts +3 -3
- package/dist/build/node/buildJob.js +185 -26
- package/dist/build/node/cache.d.ts +3 -3
- package/dist/build/node/cache.js +199 -36
- package/dist/build/node/index.d.ts +3 -3
- package/dist/build/node/index.js +151 -3
- package/dist/build/node/meteor.d.ts +1 -1
- package/dist/build/node/meteor.js +162 -27
- package/dist/build/node/testJob.d.ts +1 -1
- package/dist/build/node/testJob.js +174 -49
- package/dist/build/node/yarn.d.ts +2 -2
- package/dist/build/node/yarn.js +168 -21
- package/dist/build/types.d.ts +2 -2
- package/dist/constants.js +1 -1
- package/dist/context/createComponentContext.js +10 -12
- package/dist/context/createWorkspaceContext.js +29 -34
- package/dist/deploy/custom/deployJob.d.ts +1 -1
- package/dist/deploy/custom/deployJob.js +147 -23
- package/dist/deploy/index.d.ts +1 -1
- package/dist/pipeline/createAllJobs.js +30 -14
- package/dist/pipeline/createJobsForComponent.d.ts +1 -1
- package/dist/pipeline/createJobsForComponent.js +128 -4
- package/dist/pipeline/createJobsForWorkspace.d.ts +1 -1
- package/dist/pipeline/createJobsForWorkspace.js +127 -2
- package/dist/pipeline/yarn/yarnUtils.js +61 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/context.d.ts +3 -3
- package/examples/__snapshots__/automatic-releases.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-execute-script-on-deploy.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-health-check-defaults.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-health-check-only-startup.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-health-check.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-http2.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-nextjs.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-service-custom-vpc-connector.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-session-affinity.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-with-agents.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-with-gpu.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-with-sql-legacy-jobs.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-with-sql-multiple-dbs.test.ts.snap +18 -30
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +14 -22
- package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +9 -13
- package/examples/__snapshots__/cloud-run-worker-pool.test.ts.snap +9 -13
- package/examples/__snapshots__/custom-deploy.test.ts.snap +9 -13
- package/examples/__snapshots__/custom-docker-file.test.ts.snap +9 -13
- package/examples/__snapshots__/custom-envs.test.ts.snap +14 -22
- package/examples/__snapshots__/custom-verify-job.test.ts.snap +9 -13
- package/examples/__snapshots__/git-submodule.test.ts.snap +9 -13
- package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +9 -13
- package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +9 -13
- package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +14 -22
- package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +9 -13
- package/examples/__snapshots__/local-dot-env.test.ts.snap +9 -13
- package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +9 -13
- package/examples/__snapshots__/modify-generated-files.test.ts.snap +9 -13
- package/examples/__snapshots__/modify-generated-yaml.test.ts.snap +9 -13
- package/examples/__snapshots__/multiline-var.test.ts.snap +18 -30
- package/examples/__snapshots__/native-app.test.ts.snap +14 -22
- package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +9 -13
- package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +9 -13
- package/examples/__snapshots__/override-secrets.test.ts.snap +9 -13
- package/examples/__snapshots__/referencing-other-vars.test.ts.snap +18 -30
- package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +14 -22
- package/examples/__snapshots__/workspace-api-www-turbo-cache.test.ts.snap +9 -13
- package/examples/__snapshots__/workspace-api-www.test.ts.snap +9 -13
- package/package.json +1 -1
- package/src/build/base/createBuildJobDefinition.ts +2 -1
- package/src/build/custom/buildJob.ts +1 -1
- package/src/build/index.ts +6 -2
- package/src/build/node/buildJob.ts +26 -17
- package/src/build/node/cache.ts +18 -15
- package/src/build/node/index.ts +17 -9
- package/src/build/node/meteor.ts +17 -12
- package/src/build/node/testJob.ts +10 -6
- package/src/build/node/yarn.ts +10 -8
- package/src/build/types.ts +2 -2
- package/src/context/createComponentContext.ts +6 -3
- package/src/context/createWorkspaceContext.ts +1 -1
- package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +3 -1
- package/src/deploy/custom/deployJob.ts +3 -3
- package/src/deploy/index.ts +1 -1
- package/src/pipeline/createAllJobs.ts +9 -7
- package/src/pipeline/createJobsForComponent.ts +6 -6
- package/src/pipeline/createJobsForWorkspace.ts +3 -3
- package/src/pipeline/yarn/yarnUtils.ts +34 -0
- package/src/types/context.ts +3 -3
package/dist/build/node/yarn.js
CHANGED
|
@@ -1,5 +1,120 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) {
|
|
5
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
6
|
+
resolve(value);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.next(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function rejected(value) {
|
|
18
|
+
try {
|
|
19
|
+
step(generator["throw"](value));
|
|
20
|
+
} catch (e) {
|
|
21
|
+
reject(e);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function step(result) {
|
|
25
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
26
|
+
}
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __generator = this && this.__generator || function (thisArg, body) {
|
|
31
|
+
var _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function () {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
},
|
|
40
|
+
f,
|
|
41
|
+
y,
|
|
42
|
+
t,
|
|
43
|
+
g;
|
|
44
|
+
return g = {
|
|
45
|
+
next: verb(0),
|
|
46
|
+
"throw": verb(1),
|
|
47
|
+
"return": verb(2)
|
|
48
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
49
|
+
return this;
|
|
50
|
+
}), g;
|
|
51
|
+
function verb(n) {
|
|
52
|
+
return function (v) {
|
|
53
|
+
return step([n, v]);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function step(op) {
|
|
57
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
58
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
59
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
60
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
61
|
+
switch (op[0]) {
|
|
62
|
+
case 0:
|
|
63
|
+
case 1:
|
|
64
|
+
t = op;
|
|
65
|
+
break;
|
|
66
|
+
case 4:
|
|
67
|
+
_.label++;
|
|
68
|
+
return {
|
|
69
|
+
value: op[1],
|
|
70
|
+
done: false
|
|
71
|
+
};
|
|
72
|
+
case 5:
|
|
73
|
+
_.label++;
|
|
74
|
+
y = op[1];
|
|
75
|
+
op = [0];
|
|
76
|
+
continue;
|
|
77
|
+
case 7:
|
|
78
|
+
op = _.ops.pop();
|
|
79
|
+
_.trys.pop();
|
|
80
|
+
continue;
|
|
81
|
+
default:
|
|
82
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
+
_ = 0;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
+
_.label = op[1];
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
+
_.label = t[1];
|
|
92
|
+
t = op;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (t && _.label < t[2]) {
|
|
96
|
+
_.label = t[2];
|
|
97
|
+
_.ops.push(op);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (t[2]) _.ops.pop();
|
|
101
|
+
_.trys.pop();
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
op = body.call(thisArg, _);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
op = [6, e];
|
|
107
|
+
y = 0;
|
|
108
|
+
} finally {
|
|
109
|
+
f = t = 0;
|
|
110
|
+
}
|
|
111
|
+
if (op[0] & 5) throw op[1];
|
|
112
|
+
return {
|
|
113
|
+
value: op[0] ? op[1] : void 0,
|
|
114
|
+
done: true
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
};
|
|
3
118
|
var __read = this && this.__read || function (o, n) {
|
|
4
119
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5
120
|
if (!m) return o;
|
|
@@ -43,37 +158,69 @@ var YARN_BERRY_PROD_INSTALL = "yarn workspaces focus --production";
|
|
|
43
158
|
// FIXME: check why and when rebuild is needed
|
|
44
159
|
var YARN_BERRY_PROD_REBUILD = "yarn rebuild";
|
|
45
160
|
var getYarnInstallCommand = function (context) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
161
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
162
|
+
var packageManagerInfo;
|
|
163
|
+
return __generator(this, function (_a) {
|
|
164
|
+
switch (_a.label) {
|
|
165
|
+
case 0:
|
|
166
|
+
return [4 /*yield*/, context.packageManagerInfo];
|
|
167
|
+
case 1:
|
|
168
|
+
packageManagerInfo = _a.sent();
|
|
169
|
+
if (packageManagerInfo.isClassic) {
|
|
170
|
+
return [2 /*return*/, YARN_INSTALL_CLASSIC];
|
|
171
|
+
}
|
|
172
|
+
// inline builds make debugging easier as it prints it out in the logs, instead of writing it in temp files
|
|
173
|
+
return [2 /*return*/, "yarn install --immutable --inline-builds"];
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
});
|
|
51
177
|
};
|
|
52
178
|
var ensureNodeVersion = function (context) {
|
|
53
179
|
return (0, gitlab_1.collapseableSection)("nodeinstall", "Ensure node version")(["if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi", "if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi"]);
|
|
54
180
|
};
|
|
55
181
|
exports.ensureNodeVersion = ensureNodeVersion;
|
|
56
182
|
var getYarnInstall = function (context, options) {
|
|
57
|
-
|
|
58
|
-
|
|
183
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
184
|
+
var postInstall, _a, _b;
|
|
185
|
+
return __generator(this, function (_c) {
|
|
186
|
+
switch (_c.label) {
|
|
187
|
+
case 0:
|
|
188
|
+
postInstall = context.type !== "workspace" && context.build.type !== "disabled" && "postInstall" in context.build.config ? context.build.config.postInstall : null;
|
|
189
|
+
_a = [__spreadArray([], __read((0, exports.ensureNodeVersion)(context)), false)];
|
|
190
|
+
_b = (0, gitlab_1.collapseableSection)("yarninstall", "Yarn install");
|
|
191
|
+
return [4 /*yield*/, getYarnInstallCommand(context)];
|
|
192
|
+
case 1:
|
|
193
|
+
return [2 /*return*/, __spreadArray.apply(void 0, [__spreadArray.apply(void 0, _a.concat([__read.apply(void 0, [_b.apply(void 0, [[_c.sent()]])]), false])), __read(postInstall && !(options === null || options === void 0 ? void 0 : options.noCustomPostInstall) ? (0, gitlab_1.collapseableSection)("postinstall", "Custom post install")((0, utils_1.ensureArray)(postInstall)) : []), false])];
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
});
|
|
59
197
|
};
|
|
60
198
|
exports.getYarnInstall = getYarnInstall;
|
|
61
199
|
var DOCKER_COPY_FILES = "COPY --chown=node:node $APP_DIR .";
|
|
62
200
|
var getDockerAppCopyAndBuildScript = function (context) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
201
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
202
|
+
var packageManagerInfo, yarnRebuildEnabledDefault, yarnRebuildEnabled, doesNotShipWithBuiltInPlugins, maybeAddWorkspaceToolsCommand;
|
|
203
|
+
var _a, _b, _c;
|
|
204
|
+
return __generator(this, function (_d) {
|
|
205
|
+
switch (_d.label) {
|
|
206
|
+
case 0:
|
|
207
|
+
return [4 /*yield*/, context.packageManagerInfo];
|
|
208
|
+
case 1:
|
|
209
|
+
packageManagerInfo = _d.sent();
|
|
210
|
+
if (packageManagerInfo.isClassic) {
|
|
211
|
+
return [2 /*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())];
|
|
212
|
+
}
|
|
213
|
+
yarnRebuildEnabledDefault = context.build.type === "fromWorkspace" ? (_b = (_a = context.build.workspaceBuildConfig.dockerDefaults) === null || _a === void 0 ? void 0 : _a.yarnRebuildEnabled) !== null && _b !== void 0 ? _b : true : true;
|
|
214
|
+
yarnRebuildEnabled = "docker" in context.build.config && context.build.config.docker && "yarnRebuildEnabled" in context.build.config.docker ? (_c = context.build.config.docker.yarnRebuildEnabled) !== null && _c !== void 0 ? _c : yarnRebuildEnabledDefault : yarnRebuildEnabledDefault;
|
|
215
|
+
doesNotShipWithBuiltInPlugins = ["2", "3"].some(function (v) {
|
|
216
|
+
return packageManagerInfo.version.startsWith(v);
|
|
217
|
+
});
|
|
218
|
+
maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins ? "RUN yarn plugin import workspace-tools" : "";
|
|
219
|
+
// copy first everything and then install
|
|
220
|
+
// rebuild first does not work as it will run postinstall and that might require files in the app
|
|
221
|
+
return [2 /*return*/, new BashExpression_1.BashExpression("\n ENV YARN_ENABLE_INLINE_BUILDS=1\n".concat(DOCKER_COPY_FILES, "\n").concat(maybeAddWorkspaceToolsCommand, "\nRUN ").concat(YARN_BERRY_PROD_INSTALL, "\n").concat(yarnRebuildEnabled ? "RUN ".concat(YARN_BERRY_PROD_REBUILD) : "", "\n\n ").trim())];
|
|
222
|
+
}
|
|
223
|
+
});
|
|
73
224
|
});
|
|
74
|
-
var maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins ? "RUN yarn plugin import workspace-tools" : "";
|
|
75
|
-
// copy first everything and then install
|
|
76
|
-
// rebuild first does not work as it will run postinstall and that might require files in the app
|
|
77
|
-
return new BashExpression_1.BashExpression("\n ENV YARN_ENABLE_INLINE_BUILDS=1\n".concat(DOCKER_COPY_FILES, "\n").concat(maybeAddWorkspaceToolsCommand, "\nRUN ").concat(YARN_BERRY_PROD_INSTALL, "\n").concat(yarnRebuildEnabled ? "RUN ".concat(YARN_BERRY_PROD_REBUILD) : "", "\n\n ").trim());
|
|
78
225
|
};
|
|
79
226
|
exports.getDockerAppCopyAndBuildScript = getDockerAppCopyAndBuildScript;
|
package/dist/build/types.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ export type BuildConfigBase = {
|
|
|
91
91
|
/**
|
|
92
92
|
* define the build command
|
|
93
93
|
*/
|
|
94
|
-
buildCommand?: string | string[] | null;
|
|
94
|
+
buildCommand?: string | string[] | null | false;
|
|
95
95
|
/**
|
|
96
96
|
* customize lint, set false to disable
|
|
97
97
|
*/
|
|
@@ -355,7 +355,7 @@ export type WorkspaceBuildConfigBase = {
|
|
|
355
355
|
} & WithCacheConfig;
|
|
356
356
|
export type WorkspaceBuildConfigNode = {
|
|
357
357
|
type: "node";
|
|
358
|
-
buildCommand?: string | string[];
|
|
358
|
+
buildCommand?: string | string[] | null | false;
|
|
359
359
|
/**
|
|
360
360
|
* set docker config defaults for the node build type.
|
|
361
361
|
* Currently not all options are supported.
|
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 = "
|
|
7
|
+
exports.PIPELINE_IMAGE_TAG = "v4-0-0-8a1e42bd" || "latest";
|
|
8
8
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";
|
|
@@ -169,20 +169,18 @@ var getEnvironment_1 = require("./getEnvironment");
|
|
|
169
169
|
var getEnvironmentContext_1 = require("./getEnvironmentContext");
|
|
170
170
|
var createComponentContext = function (ctx) {
|
|
171
171
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
172
|
-
var
|
|
173
|
-
var
|
|
174
|
-
return __generator(this, function (
|
|
175
|
-
switch (
|
|
172
|
+
var packageManagerInfoPromise, envContext, componentConfigWithoutDefaults, resolvedBuildType, defaults, componentConfig, _a, environment, packageManagerInfo, deploy, build, customJobs, dir, getComponentDirs, _getBuildContext, buildContext, context, resolvedCustomJobs;
|
|
173
|
+
var _b;
|
|
174
|
+
return __generator(this, function (_c) {
|
|
175
|
+
switch (_c.label) {
|
|
176
176
|
case 0:
|
|
177
177
|
if (!/^[a-z0-9-]+$/.test(ctx.componentName)) {
|
|
178
178
|
throw new Error("componentName may only contain lower case letters, numbers and -");
|
|
179
179
|
}
|
|
180
|
-
|
|
181
|
-
case 1:
|
|
182
|
-
packageManagerInfo = _b.sent();
|
|
180
|
+
packageManagerInfoPromise = (0, packageManager_1.getPackageManagerInfoForComponent)(ctx.config, ctx.componentName);
|
|
183
181
|
envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(ctx);
|
|
184
182
|
componentConfigWithoutDefaults = envContext.envConfigRaw;
|
|
185
|
-
resolvedBuildType = componentConfigWithoutDefaults.build === false ? false : (0, build_1.isStandaloneBuildConfig)(componentConfigWithoutDefaults.build) ? componentConfigWithoutDefaults.build.type : (
|
|
183
|
+
resolvedBuildType = componentConfigWithoutDefaults.build === false ? false : (0, build_1.isStandaloneBuildConfig)(componentConfigWithoutDefaults.build) ? componentConfigWithoutDefaults.build.type : (_b = ctx.config.builds) === null || _b === void 0 ? void 0 : _b[componentConfigWithoutDefaults.build.from].type;
|
|
186
184
|
if (resolvedBuildType === undefined) {
|
|
187
185
|
throw new Error("build type not found, is the build config correct?");
|
|
188
186
|
}
|
|
@@ -194,9 +192,9 @@ var createComponentContext = function (ctx) {
|
|
|
194
192
|
deploy: {}
|
|
195
193
|
};
|
|
196
194
|
componentConfig = (0, utils_1.mergeWithMergingArrays)(defaults, componentConfigWithoutDefaults);
|
|
197
|
-
return [4 /*yield*/, (0, getEnvironment_1.getEnvironment)(ctx)];
|
|
198
|
-
case
|
|
199
|
-
|
|
195
|
+
return [4 /*yield*/, Promise.all([(0, getEnvironment_1.getEnvironment)(ctx), packageManagerInfoPromise])];
|
|
196
|
+
case 1:
|
|
197
|
+
_a = __read.apply(void 0, [_c.sent(), 2]), environment = _a[0], packageManagerInfo = _a[1];
|
|
200
198
|
deploy = componentConfig.deploy, build = componentConfig.build, customJobs = componentConfig.customJobs, dir = componentConfig.dir;
|
|
201
199
|
getComponentDirs = function (mode) {
|
|
202
200
|
var _a;
|
|
@@ -247,7 +245,7 @@ var createComponentContext = function (ctx) {
|
|
|
247
245
|
config: deploy
|
|
248
246
|
} : null,
|
|
249
247
|
environment: environment,
|
|
250
|
-
packageManagerInfo:
|
|
248
|
+
packageManagerInfo: packageManagerInfoPromise,
|
|
251
249
|
pipelineType: ctx.pipelineType,
|
|
252
250
|
trigger: ctx.trigger
|
|
253
251
|
};
|
|
@@ -126,47 +126,42 @@ var lodash_1 = require("lodash");
|
|
|
126
126
|
function createWorkspaceContext(_a) {
|
|
127
127
|
return __awaiter(this, arguments, void 0, function (_b) {
|
|
128
128
|
var workspaceConfigRaw, defaults, workspaceConfig;
|
|
129
|
-
var _c;
|
|
130
|
-
var _d, _e;
|
|
129
|
+
var _c, _d;
|
|
131
130
|
var env = _b.env,
|
|
132
131
|
components = _b.components,
|
|
133
132
|
workspaceName = _b.workspaceName,
|
|
134
133
|
config = _b.config,
|
|
135
134
|
pipelineType = _b.pipelineType,
|
|
136
135
|
trigger = _b.trigger;
|
|
137
|
-
return __generator(this, function (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (!workspaceConfigRaw) {
|
|
142
|
-
throw new Error("Workspace ".concat(workspaceName, " not found in config"));
|
|
143
|
-
}
|
|
144
|
-
defaults = __1.WORKSPACE_BUILD_TYPES[workspaceConfigRaw.type].defaults();
|
|
145
|
-
workspaceConfig = (0, utils_1.mergeWithMergingArrays)(defaults, workspaceConfigRaw);
|
|
146
|
-
_c = {
|
|
147
|
-
name: workspaceName,
|
|
148
|
-
pipelineType: pipelineType,
|
|
149
|
-
trigger: trigger,
|
|
150
|
-
type: "workspace",
|
|
151
|
-
workspaceConfig: workspaceConfig,
|
|
152
|
-
env: env,
|
|
153
|
-
components: components,
|
|
154
|
-
fullConfig: config
|
|
155
|
-
};
|
|
156
|
-
return [4 /*yield*/, (0, packageManager_1.getPackageManagerInfoBase)()];
|
|
157
|
-
case 1:
|
|
158
|
-
return [2 /*return*/, (_c.packageManagerInfo = _f.sent(), _c.build = {
|
|
159
|
-
type: "workspace",
|
|
160
|
-
dir: (_e = workspaceConfig.dir) !== null && _e !== void 0 ? _e : ".",
|
|
161
|
-
getComponentDirs: function (mode) {
|
|
162
|
-
return (0, lodash_1.uniq)(components.flatMap(function (c) {
|
|
163
|
-
return c.build.getComponentDirs(mode);
|
|
164
|
-
}));
|
|
165
|
-
},
|
|
166
|
-
buildType: workspaceConfig.type,
|
|
167
|
-
config: workspaceConfig
|
|
168
|
-
}, _c)];
|
|
136
|
+
return __generator(this, function (_e) {
|
|
137
|
+
workspaceConfigRaw = (_c = config.builds) === null || _c === void 0 ? void 0 : _c[workspaceName];
|
|
138
|
+
if (!workspaceConfigRaw) {
|
|
139
|
+
throw new Error("Workspace ".concat(workspaceName, " not found in config"));
|
|
169
140
|
}
|
|
141
|
+
defaults = __1.WORKSPACE_BUILD_TYPES[workspaceConfigRaw.type].defaults();
|
|
142
|
+
workspaceConfig = (0, utils_1.mergeWithMergingArrays)(defaults, workspaceConfigRaw);
|
|
143
|
+
return [2 /*return*/, {
|
|
144
|
+
name: workspaceName,
|
|
145
|
+
pipelineType: pipelineType,
|
|
146
|
+
trigger: trigger,
|
|
147
|
+
type: "workspace",
|
|
148
|
+
workspaceConfig: workspaceConfig,
|
|
149
|
+
env: env,
|
|
150
|
+
components: components,
|
|
151
|
+
fullConfig: config,
|
|
152
|
+
packageManagerInfo: (0, packageManager_1.getPackageManagerInfoBase)(),
|
|
153
|
+
build: {
|
|
154
|
+
type: "workspace",
|
|
155
|
+
dir: (_d = workspaceConfig.dir) !== null && _d !== void 0 ? _d : ".",
|
|
156
|
+
getComponentDirs: function (mode) {
|
|
157
|
+
return (0, lodash_1.uniq)(components.flatMap(function (c) {
|
|
158
|
+
return c.build.getComponentDirs(mode);
|
|
159
|
+
}));
|
|
160
|
+
},
|
|
161
|
+
buildType: workspaceConfig.type,
|
|
162
|
+
config: workspaceConfig
|
|
163
|
+
}
|
|
164
|
+
}];
|
|
170
165
|
});
|
|
171
166
|
});
|
|
172
167
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ComponentContext } from "../../types/context";
|
|
2
2
|
import type { CatladderJob } from "../../types/jobs";
|
|
3
|
-
export declare const createCustomDeployJobs: (context: ComponentContext) => CatladderJob[]
|
|
3
|
+
export declare const createCustomDeployJobs: (context: ComponentContext) => Promise<CatladderJob[]>;
|
|
@@ -1,5 +1,120 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) {
|
|
5
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
6
|
+
resolve(value);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.next(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function rejected(value) {
|
|
18
|
+
try {
|
|
19
|
+
step(generator["throw"](value));
|
|
20
|
+
} catch (e) {
|
|
21
|
+
reject(e);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function step(result) {
|
|
25
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
26
|
+
}
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __generator = this && this.__generator || function (thisArg, body) {
|
|
31
|
+
var _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function () {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
},
|
|
40
|
+
f,
|
|
41
|
+
y,
|
|
42
|
+
t,
|
|
43
|
+
g;
|
|
44
|
+
return g = {
|
|
45
|
+
next: verb(0),
|
|
46
|
+
"throw": verb(1),
|
|
47
|
+
"return": verb(2)
|
|
48
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
49
|
+
return this;
|
|
50
|
+
}), g;
|
|
51
|
+
function verb(n) {
|
|
52
|
+
return function (v) {
|
|
53
|
+
return step([n, v]);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function step(op) {
|
|
57
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
58
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
59
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
60
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
61
|
+
switch (op[0]) {
|
|
62
|
+
case 0:
|
|
63
|
+
case 1:
|
|
64
|
+
t = op;
|
|
65
|
+
break;
|
|
66
|
+
case 4:
|
|
67
|
+
_.label++;
|
|
68
|
+
return {
|
|
69
|
+
value: op[1],
|
|
70
|
+
done: false
|
|
71
|
+
};
|
|
72
|
+
case 5:
|
|
73
|
+
_.label++;
|
|
74
|
+
y = op[1];
|
|
75
|
+
op = [0];
|
|
76
|
+
continue;
|
|
77
|
+
case 7:
|
|
78
|
+
op = _.ops.pop();
|
|
79
|
+
_.trys.pop();
|
|
80
|
+
continue;
|
|
81
|
+
default:
|
|
82
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
+
_ = 0;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
+
_.label = op[1];
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
+
_.label = t[1];
|
|
92
|
+
t = op;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (t && _.label < t[2]) {
|
|
96
|
+
_.label = t[2];
|
|
97
|
+
_.ops.push(op);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (t[2]) _.ops.pop();
|
|
101
|
+
_.trys.pop();
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
op = body.call(thisArg, _);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
op = [6, e];
|
|
107
|
+
y = 0;
|
|
108
|
+
} finally {
|
|
109
|
+
f = t = 0;
|
|
110
|
+
}
|
|
111
|
+
if (op[0] & 5) throw op[1];
|
|
112
|
+
return {
|
|
113
|
+
value: op[0] ? op[1] : void 0,
|
|
114
|
+
done: true
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
};
|
|
3
118
|
var __read = this && this.__read || function (o, n) {
|
|
4
119
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5
120
|
if (!m) return o;
|
|
@@ -41,29 +156,38 @@ var runner_1 = require("../../runner");
|
|
|
41
156
|
var base_1 = require("../base");
|
|
42
157
|
var types_1 = require("../types");
|
|
43
158
|
var createCustomDeployJobs = function (context) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
159
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
160
|
+
var deployConfig, yarnInstall, result;
|
|
161
|
+
var _a, _b, _c;
|
|
162
|
+
return __generator(this, function (_d) {
|
|
163
|
+
switch (_d.label) {
|
|
164
|
+
case 0:
|
|
165
|
+
deployConfig = (_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config;
|
|
166
|
+
if (!(0, types_1.isOfDeployType)(deployConfig, "custom")) {
|
|
167
|
+
// should not happen
|
|
168
|
+
throw new Error("deploy config is not custom");
|
|
169
|
+
}
|
|
170
|
+
return [4 /*yield*/, (0, yarn_1.getYarnInstall)(context, {
|
|
171
|
+
noCustomPostInstall: true
|
|
172
|
+
})];
|
|
173
|
+
case 1:
|
|
174
|
+
yarnInstall = _d.sent();
|
|
175
|
+
result = (0, base_1.createDeployementJobs)(context, {
|
|
176
|
+
deploy: {
|
|
177
|
+
image: (_b = deployConfig.jobImage) !== null && _b !== void 0 ? _b : (0, runner_1.getRunnerImage)("jobs-default"),
|
|
178
|
+
cache: (0, getAllCacheConfigsFromConfig_1.getAllCacheConfigsFromConfig)(context, deployConfig),
|
|
179
|
+
script: __spreadArray(__spreadArray(["cd ".concat(context.build.dir)], __read(deployConfig.requiresYarnInstall ? yarnInstall : []), false), __read(deployConfig.script), false),
|
|
180
|
+
variables: {}
|
|
181
|
+
},
|
|
182
|
+
stop: deployConfig.stopScript ? {
|
|
183
|
+
image: (_c = deployConfig.jobImage) !== null && _c !== void 0 ? _c : (0, runner_1.getRunnerImage)("jobs-default"),
|
|
184
|
+
script: __spreadArray([], __read(deployConfig.stopScript), false),
|
|
185
|
+
variables: {}
|
|
186
|
+
} : undefined
|
|
187
|
+
});
|
|
188
|
+
return [2 /*return*/, result];
|
|
189
|
+
}
|
|
190
|
+
});
|
|
66
191
|
});
|
|
67
|
-
return result;
|
|
68
192
|
};
|
|
69
193
|
exports.createCustomDeployJobs = createCustomDeployJobs;
|
package/dist/deploy/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export * from "./kubernetes";
|
|
|
10
10
|
export * from "./types";
|
|
11
11
|
export * from "./utils";
|
|
12
12
|
export type DeployTypeDefinition<D extends DeployConfig> = {
|
|
13
|
-
jobs: (context: ComponentContext) => CatladderJob[]
|
|
13
|
+
jobs: (context: ComponentContext) => CatladderJob[] | Promise<CatladderJob[]>;
|
|
14
14
|
defaults: (envContext: EnvironmentContext<BuildConfig, D>) => PartialDeep<D>;
|
|
15
15
|
additionalSecretKeys: (envContext: EnvironmentContext<BuildConfig, D>) => SecretEnvVar[];
|
|
16
16
|
getAdditionalEnvVars: (envContext: EnvironmentContext<BuildConfig, D>) => Record<string, string | BashExpression | undefined | null>;
|
|
@@ -192,8 +192,9 @@ var createAllJobs = function (_a) {
|
|
|
192
192
|
return [4 /*yield*/, Promise.all(allEnvs.map(function (env) {
|
|
193
193
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
194
194
|
var workspaceContext;
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
var _a;
|
|
196
|
+
return __generator(this, function (_b) {
|
|
197
|
+
switch (_b.label) {
|
|
197
198
|
case 0:
|
|
198
199
|
return [4 /*yield*/, (0, createWorkspaceContext_1.createWorkspaceContext)({
|
|
199
200
|
components: componentsInAllEnvs.filter(function (_a) {
|
|
@@ -207,11 +208,13 @@ var createAllJobs = function (_a) {
|
|
|
207
208
|
env: env
|
|
208
209
|
})];
|
|
209
210
|
case 1:
|
|
210
|
-
workspaceContext =
|
|
211
|
-
|
|
212
|
-
context: workspaceContext
|
|
213
|
-
|
|
214
|
-
|
|
211
|
+
workspaceContext = _b.sent();
|
|
212
|
+
_a = {
|
|
213
|
+
context: workspaceContext
|
|
214
|
+
};
|
|
215
|
+
return [4 /*yield*/, (0, createJobsForWorkspace_1.createJobsForWorkspace)(workspaceContext)];
|
|
216
|
+
case 2:
|
|
217
|
+
return [2 /*return*/, (_a.jobs = _b.sent(), _a)];
|
|
215
218
|
}
|
|
216
219
|
});
|
|
217
220
|
});
|
|
@@ -225,12 +228,25 @@ var createAllJobs = function (_a) {
|
|
|
225
228
|
return f.flat();
|
|
226
229
|
})];
|
|
227
230
|
case 2:
|
|
228
|
-
_c.workspaces = _f.sent()
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
_c.workspaces = _f.sent();
|
|
232
|
+
return [4 /*yield*/, Promise.all(allComponentsContext.map(function (context) {
|
|
233
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
234
|
+
var _a;
|
|
235
|
+
return __generator(this, function (_b) {
|
|
236
|
+
switch (_b.label) {
|
|
237
|
+
case 0:
|
|
238
|
+
_a = {
|
|
239
|
+
context: context
|
|
240
|
+
};
|
|
241
|
+
return [4 /*yield*/, (0, createJobsForComponent_1.createJobsForComponentContext)(context)];
|
|
242
|
+
case 1:
|
|
243
|
+
return [2 /*return*/, (_a.jobs = _b.sent(), _a)];
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
}))];
|
|
248
|
+
case 3:
|
|
249
|
+
_c.components = _f.sent();
|
|
234
250
|
return [4 /*yield*/, Promise.all(Object.keys((_e = config.agents) !== null && _e !== void 0 ? _e : {}).map(function (agentName) {
|
|
235
251
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
236
252
|
var context;
|
|
@@ -253,7 +269,7 @@ var createAllJobs = function (_a) {
|
|
|
253
269
|
})).then(function (f) {
|
|
254
270
|
return f.flat();
|
|
255
271
|
})];
|
|
256
|
-
case
|
|
272
|
+
case 4:
|
|
257
273
|
return [2 /*return*/, (_c.agents = _f.sent(), _c)];
|
|
258
274
|
}
|
|
259
275
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ComponentContext } from "../types/context";
|
|
2
2
|
import type { CatladderJob } from "../types/jobs";
|
|
3
|
-
export declare const createJobsForComponentContext: (context: ComponentContext) => CatladderJob[]
|
|
3
|
+
export declare const createJobsForComponentContext: (context: ComponentContext) => Promise<CatladderJob[]>;
|