@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.
Files changed (101) hide show
  1. package/dist/build/base/createBuildJobDefinition.js +1 -1
  2. package/dist/build/custom/buildJob.js +1 -1
  3. package/dist/build/index.d.ts +2 -2
  4. package/dist/build/node/buildJob.d.ts +3 -3
  5. package/dist/build/node/buildJob.js +185 -26
  6. package/dist/build/node/cache.d.ts +3 -3
  7. package/dist/build/node/cache.js +199 -36
  8. package/dist/build/node/index.d.ts +3 -3
  9. package/dist/build/node/index.js +151 -3
  10. package/dist/build/node/meteor.d.ts +1 -1
  11. package/dist/build/node/meteor.js +162 -27
  12. package/dist/build/node/testJob.d.ts +1 -1
  13. package/dist/build/node/testJob.js +174 -49
  14. package/dist/build/node/yarn.d.ts +2 -2
  15. package/dist/build/node/yarn.js +168 -21
  16. package/dist/build/types.d.ts +2 -2
  17. package/dist/constants.js +1 -1
  18. package/dist/context/createComponentContext.js +10 -12
  19. package/dist/context/createWorkspaceContext.js +29 -34
  20. package/dist/deploy/custom/deployJob.d.ts +1 -1
  21. package/dist/deploy/custom/deployJob.js +147 -23
  22. package/dist/deploy/index.d.ts +1 -1
  23. package/dist/pipeline/createAllJobs.js +30 -14
  24. package/dist/pipeline/createJobsForComponent.d.ts +1 -1
  25. package/dist/pipeline/createJobsForComponent.js +128 -4
  26. package/dist/pipeline/createJobsForWorkspace.d.ts +1 -1
  27. package/dist/pipeline/createJobsForWorkspace.js +127 -2
  28. package/dist/pipeline/yarn/yarnUtils.js +61 -1
  29. package/dist/tsconfig.tsbuildinfo +1 -1
  30. package/dist/types/context.d.ts +3 -3
  31. package/examples/__snapshots__/automatic-releases.test.ts.snap +9 -13
  32. package/examples/__snapshots__/cloud-run-execute-script-on-deploy.test.ts.snap +9 -13
  33. package/examples/__snapshots__/cloud-run-health-check-defaults.test.ts.snap +9 -13
  34. package/examples/__snapshots__/cloud-run-health-check-only-startup.test.ts.snap +9 -13
  35. package/examples/__snapshots__/cloud-run-health-check.test.ts.snap +9 -13
  36. package/examples/__snapshots__/cloud-run-http2.test.ts.snap +9 -13
  37. package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +9 -13
  38. package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +9 -13
  39. package/examples/__snapshots__/cloud-run-nextjs.test.ts.snap +9 -13
  40. package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +9 -13
  41. package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +9 -13
  42. package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +9 -13
  43. package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +9 -13
  44. package/examples/__snapshots__/cloud-run-service-custom-vpc-connector.test.ts.snap +9 -13
  45. package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +9 -13
  46. package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +9 -13
  47. package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +9 -13
  48. package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +9 -13
  49. package/examples/__snapshots__/cloud-run-session-affinity.test.ts.snap +9 -13
  50. package/examples/__snapshots__/cloud-run-with-agents.test.ts.snap +9 -13
  51. package/examples/__snapshots__/cloud-run-with-gpu.test.ts.snap +9 -13
  52. package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +9 -13
  53. package/examples/__snapshots__/cloud-run-with-sql-legacy-jobs.test.ts.snap +9 -13
  54. package/examples/__snapshots__/cloud-run-with-sql-multiple-dbs.test.ts.snap +18 -30
  55. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +14 -22
  56. package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +9 -13
  57. package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +9 -13
  58. package/examples/__snapshots__/cloud-run-worker-pool.test.ts.snap +9 -13
  59. package/examples/__snapshots__/custom-deploy.test.ts.snap +9 -13
  60. package/examples/__snapshots__/custom-docker-file.test.ts.snap +9 -13
  61. package/examples/__snapshots__/custom-envs.test.ts.snap +14 -22
  62. package/examples/__snapshots__/custom-verify-job.test.ts.snap +9 -13
  63. package/examples/__snapshots__/git-submodule.test.ts.snap +9 -13
  64. package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +9 -13
  65. package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +9 -13
  66. package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +14 -22
  67. package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +9 -13
  68. package/examples/__snapshots__/local-dot-env.test.ts.snap +9 -13
  69. package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +9 -13
  70. package/examples/__snapshots__/modify-generated-files.test.ts.snap +9 -13
  71. package/examples/__snapshots__/modify-generated-yaml.test.ts.snap +9 -13
  72. package/examples/__snapshots__/multiline-var.test.ts.snap +18 -30
  73. package/examples/__snapshots__/native-app.test.ts.snap +14 -22
  74. package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +9 -13
  75. package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +9 -13
  76. package/examples/__snapshots__/override-secrets.test.ts.snap +9 -13
  77. package/examples/__snapshots__/referencing-other-vars.test.ts.snap +18 -30
  78. package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +14 -22
  79. package/examples/__snapshots__/workspace-api-www-turbo-cache.test.ts.snap +9 -13
  80. package/examples/__snapshots__/workspace-api-www.test.ts.snap +9 -13
  81. package/package.json +1 -1
  82. package/src/build/base/createBuildJobDefinition.ts +2 -1
  83. package/src/build/custom/buildJob.ts +1 -1
  84. package/src/build/index.ts +6 -2
  85. package/src/build/node/buildJob.ts +26 -17
  86. package/src/build/node/cache.ts +18 -15
  87. package/src/build/node/index.ts +17 -9
  88. package/src/build/node/meteor.ts +17 -12
  89. package/src/build/node/testJob.ts +10 -6
  90. package/src/build/node/yarn.ts +10 -8
  91. package/src/build/types.ts +2 -2
  92. package/src/context/createComponentContext.ts +6 -3
  93. package/src/context/createWorkspaceContext.ts +1 -1
  94. package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +3 -1
  95. package/src/deploy/custom/deployJob.ts +3 -3
  96. package/src/deploy/index.ts +1 -1
  97. package/src/pipeline/createAllJobs.ts +9 -7
  98. package/src/pipeline/createJobsForComponent.ts +6 -6
  99. package/src/pipeline/createJobsForWorkspace.ts +3 -3
  100. package/src/pipeline/yarn/yarnUtils.ts +34 -0
  101. package/src/types/context.ts +3 -3
@@ -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
- if (context.packageManagerInfo.isClassic) {
47
- return YARN_INSTALL_CLASSIC;
48
- }
49
- // inline builds make debugging easier as it prints it out in the logs, instead of writing it in temp files
50
- return "yarn install --immutable --inline-builds";
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
- var postInstall = context.type !== "workspace" && context.build.type !== "disabled" && "postInstall" in context.build.config ? context.build.config.postInstall : null;
58
- return __spreadArray(__spreadArray(__spreadArray([], __read((0, exports.ensureNodeVersion)(context)), false), __read((0, gitlab_1.collapseableSection)("yarninstall", "Yarn install")([getYarnInstallCommand(context)])), 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);
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
- var _a, _b, _c;
64
- if (context.packageManagerInfo.isClassic) {
65
- 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
- }
67
- var 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;
68
- var 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;
69
- // yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
70
- // trying to import those fail on this version
71
- var doesNotShipWithBuiltInPlugins = ["2", "3"].some(function (v) {
72
- return context.packageManagerInfo.version.startsWith(v);
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;
@@ -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 = "v3-47-1-5a14ca1f" || "latest";
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 packageManagerInfo, envContext, componentConfigWithoutDefaults, resolvedBuildType, defaults, componentConfig, environment, deploy, build, customJobs, dir, getComponentDirs, _getBuildContext, buildContext, context, resolvedCustomJobs;
173
- var _a;
174
- return __generator(this, function (_b) {
175
- switch (_b.label) {
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
- return [4 /*yield*/, (0, packageManager_1.getPackageManagerInfoForComponent)(ctx.config, ctx.componentName)];
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 : (_a = ctx.config.builds) === null || _a === void 0 ? void 0 : _a[componentConfigWithoutDefaults.build.from].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 2:
199
- environment = _b.sent();
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: 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 (_f) {
138
- switch (_f.label) {
139
- case 0:
140
- workspaceConfigRaw = (_d = config.builds) === null || _d === void 0 ? void 0 : _d[workspaceName];
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
- var _a, _b, _c;
45
- var deployConfig = (_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config;
46
- if (!(0, types_1.isOfDeployType)(deployConfig, "custom")) {
47
- // should not happen
48
- throw new Error("deploy config is not custom");
49
- }
50
- // FIXME: custom deploy currently assumes yarn-based project
51
- var yarnInstall = (0, yarn_1.getYarnInstall)(context, {
52
- noCustomPostInstall: true
53
- });
54
- var result = (0, base_1.createDeployementJobs)(context, {
55
- deploy: {
56
- image: (_b = deployConfig.jobImage) !== null && _b !== void 0 ? _b : (0, runner_1.getRunnerImage)("jobs-default"),
57
- cache: (0, getAllCacheConfigsFromConfig_1.getAllCacheConfigsFromConfig)(context, deployConfig),
58
- script: __spreadArray(__spreadArray(["cd ".concat(context.build.dir)], __read(deployConfig.requiresYarnInstall ? yarnInstall : []), false), __read(deployConfig.script), false),
59
- variables: {}
60
- },
61
- stop: deployConfig.stopScript ? {
62
- image: (_c = deployConfig.jobImage) !== null && _c !== void 0 ? _c : (0, runner_1.getRunnerImage)("jobs-default"),
63
- script: __spreadArray([], __read(deployConfig.stopScript), false),
64
- variables: {}
65
- } : undefined
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;
@@ -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
- return __generator(this, function (_a) {
196
- switch (_a.label) {
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 = _a.sent();
211
- return [2 /*return*/, {
212
- context: workspaceContext,
213
- jobs: (0, createJobsForWorkspace_1.createJobsForWorkspace)(workspaceContext)
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(), _c.components = allComponentsContext.map(function (context) {
229
- return {
230
- context: context,
231
- jobs: (0, createJobsForComponent_1.createJobsForComponentContext)(context)
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 3:
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[]>;