@catladder/pipeline 1.170.0 → 2.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 (194) hide show
  1. package/dist/bash/BashExpression.d.ts +2 -6
  2. package/dist/bash/BashExpression.js +5 -15
  3. package/dist/bash/bashEscape.d.ts +34 -0
  4. package/dist/bash/bashEscape.js +114 -0
  5. package/dist/bash/bashYaml.js +25 -2
  6. package/dist/bash/getInjectVarsScript.js +4 -2
  7. package/dist/bash/index.d.ts +2 -0
  8. package/dist/bash/index.js +26 -0
  9. package/dist/build/base/createAppBuildJob.js +3 -3
  10. package/dist/build/base/writeDotEnv.js +6 -4
  11. package/dist/build/custom/testJob.js +12 -12
  12. package/dist/build/docker.d.ts +3 -3
  13. package/dist/build/node/buildJob.js +1 -1
  14. package/dist/build/node/cache.d.ts +2 -4
  15. package/dist/build/node/cache.js +3 -24
  16. package/dist/build/node/testJob.js +11 -11
  17. package/dist/build/rails/build.js +1 -1
  18. package/dist/build/rails/test.js +8 -8
  19. package/dist/build/types.d.ts +0 -10
  20. package/dist/constants.js +1 -1
  21. package/dist/context/createComponentContext.js +0 -1
  22. package/dist/context/getEnvConfig.js +2 -1
  23. package/dist/context/getEnvironment.js +1 -2
  24. package/dist/context/getEnvironmentVariables.d.ts +5 -6
  25. package/dist/context/getEnvironmentVariables.js +50 -38
  26. package/dist/deploy/base/deploy.js +3 -3
  27. package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +2 -2
  28. package/dist/deploy/cloudRun/index.js +2 -2
  29. package/dist/deploy/cloudRun/utils/getServiceName.d.ts +1 -1
  30. package/dist/deploy/kubernetes/cloudSql/index.d.ts +2 -2
  31. package/dist/deploy/kubernetes/cloudSql/index.js +3 -14
  32. package/dist/deploy/kubernetes/deployJob.js +1 -3
  33. package/dist/deploy/kubernetes/index.js +2 -2
  34. package/dist/deploy/kubernetes/kubeEnv.d.ts +3 -3
  35. package/dist/deploy/kubernetes/kubeValues.d.ts +3 -4
  36. package/dist/deploy/kubernetes/kubeValues.js +2 -3
  37. package/dist/deploy/types/base.d.ts +0 -6
  38. package/dist/deploy/types/kubernetes.d.ts +1 -34
  39. package/dist/globalScriptFunctions/index.d.ts +14 -0
  40. package/dist/globalScriptFunctions/index.js +37 -0
  41. package/dist/index.d.ts +3 -1
  42. package/dist/index.js +3 -1
  43. package/dist/pipeline/gitlab/createGitlabJobs.js +3 -5
  44. package/dist/pipeline/gitlab/createGitlabPipeline.d.ts +1 -0
  45. package/dist/pipeline/gitlab/createGitlabPipeline.js +38 -2
  46. package/dist/pipeline/packageManager.js +1 -1
  47. package/dist/runner/index.d.ts +1 -1
  48. package/dist/tsconfig.tsbuildinfo +1 -1
  49. package/dist/types/config.d.ts +6 -9
  50. package/dist/types/context.d.ts +2 -9
  51. package/dist/types/gitlab-types.d.ts +1 -0
  52. package/dist/types/jobs.d.ts +0 -8
  53. package/dist/utils/gitlab.js +4 -1
  54. package/dist/utils/writeFiles.js +1 -7
  55. package/dist/variables/VariableValue.d.ts +3 -0
  56. package/dist/variables/VariableValue.js +5 -0
  57. package/dist/variables/VariableValueContainingReferences.d.ts +24 -0
  58. package/dist/variables/VariableValueContainingReferences.js +97 -0
  59. package/dist/variables/__tests__/resolveAllReferences.test.js +219 -0
  60. package/dist/variables/__tests__/resolveAllReferencesOnce.test.d.ts +1 -0
  61. package/dist/variables/__tests__/resolveAllReferencesOnce.test.js +171 -0
  62. package/dist/variables/__tests__/resolveReferencesOnce.test.d.ts +1 -0
  63. package/dist/variables/__tests__/resolveReferencesOnce.test.js +202 -0
  64. package/dist/variables/__tests__/variableValue.test.d.ts +1 -0
  65. package/dist/variables/__tests__/variableValue.test.js +36 -0
  66. package/dist/variables/resolveAllReferences.d.ts +3 -0
  67. package/dist/{bash/replaceAsync.js → variables/resolveAllReferences.js} +60 -41
  68. package/dist/variables/resolveAllReferencesOnce.d.ts +5 -0
  69. package/dist/variables/resolveAllReferencesOnce.js +191 -0
  70. package/dist/variables/resolveReferencesOnce.d.ts +8 -0
  71. package/dist/variables/resolveReferencesOnce.js +22 -0
  72. package/examples/__snapshots__/cloud-run-http2.test.ts.snap +312 -238
  73. package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +312 -238
  74. package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +312 -222
  75. package/examples/__snapshots__/cloud-run-nextjs.test.ts.snap +1436 -0
  76. package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +312 -238
  77. package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +316 -238
  78. package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +312 -238
  79. package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +313 -238
  80. package/examples/__snapshots__/cloud-run-service-custom-vpc-connector.test.ts.snap +312 -238
  81. package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +312 -238
  82. package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +312 -238
  83. package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +312 -238
  84. package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +316 -238
  85. package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +294 -220
  86. package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +312 -238
  87. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +652 -486
  88. package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +282 -288
  89. package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +312 -238
  90. package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +284 -194
  91. package/examples/__snapshots__/custom-build-job.test.ts.snap +278 -188
  92. package/examples/__snapshots__/custom-deploy.test.ts.snap +220 -154
  93. package/examples/__snapshots__/custom-envs.test.ts.snap +216 -126
  94. package/examples/__snapshots__/custom-sbom-java.test.ts.snap +278 -188
  95. package/examples/__snapshots__/git-submodule.test.ts.snap +312 -238
  96. package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +231 -253
  97. package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +240 -262
  98. package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +504 -506
  99. package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +239 -261
  100. package/examples/__snapshots__/local-dot-env.test.ts.snap +236 -238
  101. package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +236 -242
  102. package/examples/__snapshots__/multiline-var.test.ts.snap +1355 -973
  103. package/examples/__snapshots__/native-app.test.ts.snap +438 -392
  104. package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +312 -238
  105. package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +312 -238
  106. package/examples/__snapshots__/rails-k8s-with-worker-dockerfile.test.ts.snap +186 -188
  107. package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +162 -164
  108. package/examples/__snapshots__/referencing-other-vars.test.ts.snap +4741 -0
  109. package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +330 -228
  110. package/examples/__snapshots__/{workspace-api-www-custom-cache.test.ts.snap → workspace-api-www-turbo-cache.test.ts.snap} +457 -499
  111. package/examples/__snapshots__/workspace-api-www.test.ts.snap +452 -482
  112. package/examples/{workspace-api-www-custom-cache.test.ts → cloud-run-nextjs.test.ts} +2 -2
  113. package/examples/cloud-run-nextjs.ts +28 -0
  114. package/examples/cloud-run-with-sql.ts +0 -1
  115. package/examples/kubernetes-application-customization.ts +1 -0
  116. package/examples/kubernetes-with-cloud-sql.ts +1 -0
  117. package/examples/kubernetes-with-jobs.ts +1 -0
  118. package/examples/kubernetes-with-mongodb.ts +1 -0
  119. package/examples/meteor-kubernetes.ts +1 -1
  120. package/examples/native-app.ts +10 -7
  121. package/examples/rails-k8s-with-worker.ts +7 -1
  122. package/examples/{kubernetes-with-cloud-sql-legacy.test.ts → referencing-other-vars.test.ts} +2 -2
  123. package/examples/referencing-other-vars.ts +83 -0
  124. package/examples/workspace-api-www-turbo-cache.test.ts +11 -0
  125. package/examples/{workspace-api-www-custom-cache.ts → workspace-api-www-turbo-cache.ts} +4 -3
  126. package/examples/workspace-api-www.ts +3 -2
  127. package/package.json +2 -6
  128. package/src/bash/BashExpression.ts +10 -13
  129. package/src/bash/bashEscape.ts +158 -0
  130. package/src/bash/bashYaml.ts +36 -2
  131. package/src/bash/getInjectVarsScript.ts +11 -2
  132. package/src/bash/index.ts +2 -0
  133. package/src/build/base/createAppBuildJob.ts +0 -1
  134. package/src/build/base/writeDotEnv.ts +6 -6
  135. package/src/build/custom/testJob.ts +0 -1
  136. package/src/build/node/buildJob.ts +2 -2
  137. package/src/build/node/cache.ts +0 -29
  138. package/src/build/node/testJob.ts +0 -1
  139. package/src/build/rails/build.ts +0 -1
  140. package/src/build/rails/test.ts +0 -1
  141. package/src/build/types.ts +0 -13
  142. package/src/context/createComponentContext.ts +0 -1
  143. package/src/context/getEnvConfig.ts +2 -2
  144. package/src/context/getEnvironment.ts +1 -1
  145. package/src/context/getEnvironmentContext.ts +1 -1
  146. package/src/context/getEnvironmentVariables.ts +44 -51
  147. package/src/deploy/base/deploy.ts +1 -1
  148. package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +4 -12
  149. package/src/deploy/cloudRun/index.ts +2 -2
  150. package/src/deploy/kubernetes/cloudSql/index.ts +3 -16
  151. package/src/deploy/kubernetes/deployJob.ts +0 -2
  152. package/src/deploy/kubernetes/index.ts +2 -2
  153. package/src/deploy/kubernetes/kubeEnv.ts +3 -3
  154. package/src/deploy/kubernetes/kubeValues.ts +5 -8
  155. package/src/deploy/types/base.ts +0 -6
  156. package/src/deploy/types/kubernetes.ts +1 -36
  157. package/src/globalScriptFunctions/index.ts +30 -0
  158. package/src/index.ts +2 -0
  159. package/src/pipeline/gitlab/createGitlabJobs.ts +1 -4
  160. package/src/pipeline/gitlab/createGitlabPipeline.ts +8 -1
  161. package/src/pipeline/packageManager.ts +7 -5
  162. package/src/runner/index.ts +0 -1
  163. package/src/types/config.ts +6 -9
  164. package/src/types/context.ts +3 -9
  165. package/src/types/gitlab-types.ts +1 -0
  166. package/src/types/jobs.ts +0 -8
  167. package/src/utils/gitlab.ts +19 -2
  168. package/src/utils/writeFiles.ts +1 -2
  169. package/src/variables/VariableValue.ts +6 -0
  170. package/src/variables/VariableValueContainingReferences.ts +89 -0
  171. package/src/variables/__tests__/resolveAllReferences.test.ts +110 -0
  172. package/src/variables/__tests__/resolveAllReferencesOnce.test.ts +64 -0
  173. package/src/variables/__tests__/resolveReferencesOnce.test.ts +117 -0
  174. package/src/variables/__tests__/variableValue.test.ts +73 -0
  175. package/src/variables/resolveAllReferences.ts +46 -0
  176. package/src/variables/resolveAllReferencesOnce.ts +44 -0
  177. package/src/variables/resolveReferencesOnce.ts +29 -0
  178. package/bin/catladder-gitlab-dev.js +0 -3
  179. package/bin/catladder-gitlab.js +0 -3
  180. package/dist/bash/replaceAsync.d.ts +0 -2
  181. package/dist/bundles/catladder-gitlab/index.js +0 -15
  182. package/dist/context/__tests__/resolveReferences.test.js +0 -368
  183. package/dist/context/resolveReferences.d.ts +0 -6
  184. package/dist/context/resolveReferences.js +0 -286
  185. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +0 -85
  186. package/dist/deploy/kubernetes/processSecretsAsFiles.js +0 -33
  187. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.test.ts.snap +0 -1795
  188. package/examples/kubernetes-with-cloud-sql-legacy.ts +0 -35
  189. package/scripts/bundle +0 -2
  190. package/src/bash/replaceAsync.ts +0 -54
  191. package/src/context/__tests__/resolveReferences.test.ts +0 -148
  192. package/src/context/resolveReferences.ts +0 -93
  193. package/src/deploy/kubernetes/processSecretsAsFiles.ts +0 -35
  194. /package/dist/{context/__tests__/resolveReferences.test.d.ts → variables/__tests__/resolveAllReferences.test.d.ts} +0 -0
@@ -73,12 +73,6 @@ export type BuildConfigBase = {
73
73
  * Can curently not reference other variables from other components
74
74
  */
75
75
  jobVars?: EnvVars;
76
- /**
77
- * additional env vars for the buid jobs
78
- *
79
- * @deprecated use jobVars or runnerVariables
80
- */
81
- extraVars?: Record<string, string>;
82
76
  /**
83
77
  * additional vars only for the runner.
84
78
  * Also if you use services: that require env vars, you need to set them here.
@@ -193,10 +187,6 @@ type BuildConfigDockerCustom = {
193
187
  buildContextLocation?: "root" | "component";
194
188
  };
195
189
  export type BuildConfigDocker = BuildConfigDockerBuiltIn | BuildConfigDockerCustom;
196
- /**
197
- * @deprecated this type is no longer used. Use {@link BuildConfigDocker} instead.
198
- */
199
- export type BuildConfigCustomDocker = BuildConfigDockerCustom | BuildConfigDockerBuiltInNgninx;
200
190
  export type BuildConfigCustom = Omit<BuildConfigBase, "lint" | "test" | "audit"> & {
201
191
  type: "custom";
202
192
  jobImage: GitlabJobImage;
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 = "v1-170-0-754de303" || "latest";
7
+ exports.PIPELINE_IMAGE_TAG = "v2-0-0-03e9a0a2" || "latest";
8
8
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";
@@ -232,7 +232,6 @@ var createComponentContext = function (ctx) {
232
232
  context = {
233
233
  type: "component",
234
234
  name: ctx.componentName,
235
- componentName: ctx.componentName,
236
235
  env: ctx.env,
237
236
  fullConfig: ctx.config,
238
237
  componentConfig: componentConfig,
@@ -13,7 +13,8 @@ var getEnvConfig = function (config, componentName, env) {
13
13
  }
14
14
  var envCustomizations = (_b = (_a = defaultConfig.env) === null || _a === void 0 ? void 0 : _a[env]) !== null && _b !== void 0 ? _b : {};
15
15
  if (envCustomizations === false) {
16
- throw new Error("env is disabled: " + env + ":" + componentName);
16
+ // env is disabled, still return the default config
17
+ return defaultConfig;
17
18
  }
18
19
  return (0, utils_1.mergeWithMergingArrays)(defaultConfig, envCustomizations);
19
20
  };
@@ -148,8 +148,7 @@ var getEnvironment = function (ctx) {
148
148
  fullName: envContext.fullName,
149
149
  slugPrefix: envContext.environmentSlugPrefix,
150
150
  reviewSlug: envContext.reviewSlug,
151
- slug: envContext.environmentSlug,
152
- shortName: env
151
+ slug: envContext.environmentSlug
153
152
  }, variables)];
154
153
  }
155
154
  });
@@ -13,15 +13,14 @@ declare const getBasePredefinedVariables: (ctx: EnvironmentContext) => {
13
13
  };
14
14
  type BasePredefinedVariables = ReturnType<typeof getBasePredefinedVariables>;
15
15
  export type PredefinedVariables = BasePredefinedVariables & {
16
- /**
17
- * undefined in rails, Rails before 6.1 (mis)uses the `HOST` environment variable to specify the IP to bind to
18
- */
19
- HOST?: StringOrBashExpression;
16
+ HOSTNAME?: StringOrBashExpression;
20
17
  ROOT_URL: StringOrBashExpression;
21
- HOST_INTERNAL: StringOrBashExpression;
18
+ HOSTNAME_INTERNAL: StringOrBashExpression;
22
19
  ROOT_URL_INTERNAL: StringOrBashExpression;
23
20
  };
24
- export declare const getEnvironmentVariables: (ctx: CreateComponentContextContext, alreadyVisited?: Record<string, Record<string, boolean>>) => Promise<EnvironmentVariables>;
21
+ export declare const getEnvironmentVariables: (ctx: CreateComponentContextContext, options?: {
22
+ shouldResolveReferences?: boolean;
23
+ }) => Promise<EnvironmentVariables>;
25
24
  export declare const getSecretVarName: (env: string, componentName: string, key: string) => string;
26
25
  export declare const getSecretVarNameForContext: (context: ComponentContext, key: string) => string;
27
26
  export {};
@@ -160,13 +160,13 @@ Object.defineProperty(exports, "__esModule", {
160
160
  value: true
161
161
  });
162
162
  exports.getSecretVarNameForContext = exports.getSecretVarName = exports.getEnvironmentVariables = void 0;
163
- var lodash_1 = require("lodash");
164
163
  var deploy_1 = require("../deploy");
165
164
  var BashExpression_1 = require("../bash/BashExpression");
166
165
  var types_1 = require("../build/types");
166
+ var VariableValueContainingReferences_1 = require("../variables/VariableValueContainingReferences");
167
+ var resolveAllReferences_1 = require("../variables/resolveAllReferences");
167
168
  var getBuildInfoVariables_1 = require("./getBuildInfoVariables");
168
169
  var getEnvironmentContext_1 = require("./getEnvironmentContext");
169
- var resolveReferences_1 = require("./resolveReferences");
170
170
  var transformJobOnlyVars_1 = require("./transformJobOnlyVars");
171
171
  var envVars_1 = require("./utils/envVars");
172
172
  var getBasePredefinedVariables = function (ctx) {
@@ -181,12 +181,12 @@ var getEnvironmentVariables = function (ctx_1) {
181
181
  for (var _i = 1; _i < arguments.length; _i++) {
182
182
  args_1[_i - 1] = arguments[_i];
183
183
  }
184
- return __awaiter(void 0, __spreadArray([ctx_1], __read(args_1), false), void 0, function (ctx, alreadyVisited) {
185
- var environmentContext, config, env, componentName, envConfigRaw, deployConfigRaw, buildConfigRaw, envType, basePredefinedVariables, predefinedVariables, host, url, devLocalConfig, port, additionalEnvVars, HOST_INTERNAL, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegacyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
186
- var _a, _b;
187
- var _c, _d, _e, _f, _g, _h, _j, _k, _l;
188
- if (alreadyVisited === void 0) {
189
- alreadyVisited = {};
184
+ return __awaiter(void 0, __spreadArray([ctx_1], __read(args_1), false), void 0, function (ctx, options) {
185
+ var environmentContext, config, env, componentName, envConfigRaw, deployConfigRaw, buildConfigRaw, envType, basePredefinedVariables, predefinedVariables, host, url, devLocalConfig, port, additionalEnvVars, HOSTNAME_INTERNAL, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, publicEnvVarsRawSanitized, publicEnvVarsUnresolved, publicEnvVars, _a, envVars;
186
+ var _b, _c;
187
+ var _d, _e, _f, _g, _h, _j, _k, _l;
188
+ if (options === void 0) {
189
+ options = {};
190
190
  }
191
191
  return __generator(this, function (_m) {
192
192
  switch (_m.label) {
@@ -197,43 +197,45 @@ var getEnvironmentVariables = function (ctx_1) {
197
197
  basePredefinedVariables = getBasePredefinedVariables(environmentContext);
198
198
  if (envType === "local") {
199
199
  devLocalConfig = envConfigRaw;
200
- port = (_c = devLocalConfig.port) !== null && _c !== void 0 ? _c : 3000;
200
+ port = (_d = devLocalConfig.port) !== null && _d !== void 0 ? _d : 3000;
201
201
  host = "localhost:" + port.toString();
202
202
  url = "http://" + host;
203
- predefinedVariables = __assign(__assign(__assign(__assign({}, basePredefinedVariables), {
203
+ predefinedVariables = __assign(__assign({}, basePredefinedVariables), {
204
204
  ENV_SHORT: "local",
205
- ROOT_URL: url
206
- }), (0, types_1.isStandaloneBuildConfig)(buildConfigRaw) && buildConfigRaw.type === "rails" ? {} : {
207
- HOST: host
208
- }), {
209
- HOST_INTERNAL: host,
205
+ ROOT_URL: url,
206
+ HOSTNAME: host,
207
+ HOSTNAME_INTERNAL: host,
210
208
  ROOT_URL_INTERNAL: "http://" + host,
211
209
  PORT: port.toString()
212
210
  });
213
211
  } else {
214
212
  additionalEnvVars = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].getAdditionalEnvVars(environmentContext) : {};
215
- HOST_INTERNAL = (_d = additionalEnvVars.HOST_INTERNAL) !== null && _d !== void 0 ? _d : "unknown-host.example.com";
216
- host = (_e = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _e !== void 0 ? _e : HOST_INTERNAL;
213
+ HOSTNAME_INTERNAL = (_e = additionalEnvVars.HOSTNAME_INTERNAL) !== null && _e !== void 0 ? _e : "unknown-host.example.com";
214
+ host = (_f = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _f !== void 0 ? _f : HOSTNAME_INTERNAL;
217
215
  url = (0, BashExpression_1.joinBashExpressions)(["https://", host]);
218
216
  predefinedVariables = __assign(__assign(__assign(__assign({}, basePredefinedVariables), (0, types_1.isStandaloneBuildConfig)(buildConfigRaw) && buildConfigRaw.type === "rails" ? {} : {
219
- HOST: host
217
+ HOSTNAME: host
220
218
  }), {
221
219
  ROOT_URL: url,
222
- HOST_INTERNAL: HOST_INTERNAL,
223
- /**@deprecated */
224
- HOST_CANONICAL: HOST_INTERNAL,
225
- ROOT_URL_INTERNAL: (0, BashExpression_1.joinBashExpressions)(["https://", HOST_INTERNAL])
220
+ HOSTNAME_INTERNAL: HOSTNAME_INTERNAL,
221
+ ROOT_URL_INTERNAL: (0, BashExpression_1.joinBashExpressions)(["https://", HOSTNAME_INTERNAL])
226
222
  }), additionalEnvVars);
227
223
  }
228
- publicEnvVarsRaw = (_g = (_f = envConfigRaw.vars) === null || _f === void 0 ? void 0 : _f.public) !== null && _g !== void 0 ? _g : {};
224
+ publicEnvVarsRaw = (_h = (_g = envConfigRaw.vars) === null || _g === void 0 ? void 0 : _g.public) !== null && _h !== void 0 ? _h : {};
229
225
  additionalSecretKeys = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].additionalSecretKeys(environmentContext) : [];
230
- secretEnvVarKeys = __spreadArray(__spreadArray([], __read((0, envVars_1.stringListToSecreteEnvVarList)((_j = (_h = envConfigRaw.vars) === null || _h === void 0 ? void 0 : _h.secret) !== null && _j !== void 0 ? _j : [])), false), __read(additionalSecretKeys), false);
226
+ secretEnvVarKeys = __spreadArray(__spreadArray([], __read((0, envVars_1.stringListToSecreteEnvVarList)((_k = (_j = envConfigRaw.vars) === null || _j === void 0 ? void 0 : _j.secret) !== null && _k !== void 0 ? _k : [])), false), __read(additionalSecretKeys), false);
231
227
  secretEnvVars = (0, envVars_1.makeSecretEnvVarMapping)(env, componentName, secretEnvVarKeys);
232
- legacyFromComponents = (_l = (_k = envConfigRaw.vars) === null || _k === void 0 ? void 0 : _k.fromComponents) !== null && _l !== void 0 ? _l : {};
233
- publicEnvVarsRawWithLegacyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
234
- publicEnvVarsRawSanitized = (0, envVars_1.stringifyValues)(publicEnvVarsRawWithLegacyFromComponents);
235
- envVarsRaw = addIndexVar(__assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized));
236
- return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (otherComponentName, alreadyVisited) {
228
+ publicEnvVarsRawSanitized = (0, envVars_1.stringifyValues)(publicEnvVarsRaw);
229
+ publicEnvVarsUnresolved = Object.fromEntries(Object.entries(publicEnvVarsRawSanitized).map(function (_a) {
230
+ var _b = __read(_a, 2),
231
+ key = _b[0],
232
+ value = _b[1];
233
+ return [key, (0, VariableValueContainingReferences_1.createVariableValueContainingReferencesFromString)(value, {
234
+ componentName: ctx.componentName
235
+ })];
236
+ }));
237
+ if (!((_l = options.shouldResolveReferences) !== null && _l !== void 0 ? _l : true)) return [3 /*break*/, 2];
238
+ return [4 /*yield*/, (0, resolveAllReferences_1.resolveAllReferences)(publicEnvVarsUnresolved, function (otherComponentName) {
237
239
  return __awaiter(void 0, void 0, void 0, function () {
238
240
  var otherEnvVars;
239
241
  return __generator(this, function (_a) {
@@ -241,27 +243,37 @@ var getEnvironmentVariables = function (ctx_1) {
241
243
  case 0:
242
244
  return [4 /*yield*/, (0, exports.getEnvironmentVariables)(__assign(__assign({}, ctx), {
243
245
  componentName: otherComponentName
244
- }), alreadyVisited)];
246
+ }), {
247
+ shouldResolveReferences: false // we already do this here with replaceAllReferences recursivly until re replaced all
248
+ })];
249
+
245
250
  case 1:
246
251
  otherEnvVars = _a.sent().envVars;
247
252
  return [2 /*return*/, otherEnvVars];
248
253
  }
249
254
  });
250
255
  });
251
- }, alreadyVisited)];
256
+ })];
252
257
  case 1:
253
- envVars = _m.sent();
254
- _a = {
258
+ _a = _m.sent();
259
+ return [3 /*break*/, 3];
260
+ case 2:
261
+ _a = publicEnvVarsUnresolved;
262
+ _m.label = 3;
263
+ case 3:
264
+ publicEnvVars = _a;
265
+ envVars = addIndexVar(__assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVars));
266
+ _b = {
255
267
  envVars: envVars,
256
268
  secretEnvVarKeys: secretEnvVarKeys
257
269
  };
258
- _b = {};
270
+ _c = {};
259
271
  return [4 /*yield*/, (0, transformJobOnlyVars_1.transformJobOnlyVars)(env, componentName, buildConfigRaw && (0, types_1.isStandaloneBuildConfig)(buildConfigRaw) && buildConfigRaw.jobVars || null)];
260
- case 2:
261
- _b.build = _m.sent();
272
+ case 4:
273
+ _c.build = _m.sent();
262
274
  return [4 /*yield*/, (0, transformJobOnlyVars_1.transformJobOnlyVars)(env, componentName, deployConfigRaw && deployConfigRaw.jobVars || null)];
263
- case 3:
264
- return [2 /*return*/, (_a.jobOnlyVars = (_b.deploy = _m.sent(), _b), _a.host = host, _a.url = url, _a)];
275
+ case 5:
276
+ return [2 /*return*/, (_b.jobOnlyVars = (_c.deploy = _m.sent(), _c), _b.host = host, _b.url = url, _b)];
265
277
  }
266
278
  });
267
279
  });
@@ -55,7 +55,7 @@ var stop_1 = require("./stop");
55
55
  var variables_1 = require("./variables");
56
56
  exports.DEPLOY_JOB_NAME = "🚀 Deploy";
57
57
  var createDeployJob = function (context, jobDefinition) {
58
- var _a, _b, _c, _d, _e, _f, _g;
58
+ var _a, _b, _c, _d, _e, _f;
59
59
  var hasDocker = (0, docker_1.requiresDockerBuild)(context);
60
60
  var isStoppable = (0, utils_1.contextIsStoppable)(context);
61
61
  var autoStop = context.environment.envType === "review" ? "1 week" : context.environment.envType === "dev" ? "4 weeks" : undefined;
@@ -110,8 +110,8 @@ var createDeployJob = function (context, jobDefinition) {
110
110
  when: whenDeploy === "auto" ? "on_success" : "manual",
111
111
  allow_failure: whenDeploy === "manual" ? true : false,
112
112
  stage: "deploy",
113
- variables: __assign(__assign(__assign(__assign(__assign({}, context.environment.envVars), hasDocker ? (0, docker_1.getDockerImageVariables)(context) : {}), context.environment.jobOnlyVars.deploy.envVars), deployConfig ? (_e = deployConfig.extraVars) !== null && _e !== void 0 ? _e : {} : {}), jobDefinition.variables),
114
- runnerVariables: __assign(__assign(__assign({}, variables_1.DEPLOY_RUNNER_VARIABLES), (_f = jobDefinition.runnerVariables) !== null && _f !== void 0 ? _f : {}), deployConfig ? (_g = deployConfig.runnerVariables) !== null && _g !== void 0 ? _g : {} : {}),
113
+ variables: __assign(__assign(__assign(__assign({}, context.environment.envVars), hasDocker ? (0, docker_1.getDockerImageVariables)(context) : {}), context.environment.jobOnlyVars.deploy.envVars), jobDefinition.variables),
114
+ runnerVariables: __assign(__assign(__assign({}, variables_1.DEPLOY_RUNNER_VARIABLES), (_e = jobDefinition.runnerVariables) !== null && _e !== void 0 ? _e : {}), deployConfig ? (_f = deployConfig.runnerVariables) !== null && _f !== void 0 ? _f : {} : {}),
115
115
  environment: isStoppable ? {
116
116
  on_stop: stop_1.STOP_JOB_NAME,
117
117
  auto_stop_in: autoStop
@@ -38,15 +38,15 @@ exports.getCloudRunDeployScripts = void 0;
38
38
  var lodash_1 = require("lodash");
39
39
  var gitlab_1 = require("../../../utils/gitlab");
40
40
  var sbom_1 = require("../../sbom");
41
+ var __1 = require("..");
42
+ var bashYaml_1 = require("../../../bash/bashYaml");
41
43
  var cleanup_1 = require("../cleanup");
42
44
  var database_1 = require("../utils/database");
43
45
  var gcloudServiceAccountLoginCommands_1 = require("../utils/gcloudServiceAccountLoginCommands");
44
46
  var cloudRunJobs_1 = require("./cloudRunJobs");
45
47
  var cloudRunServices_1 = require("./cloudRunServices");
46
48
  var common_1 = require("./common");
47
- var __1 = require("..");
48
49
  var constants_1 = require("./constants");
49
- var bashYaml_1 = require("../../../bash/bashYaml");
50
50
  function getCloudRunDeployScripts(context) {
51
51
  var _a;
52
52
  var deployConfig = (0, common_1.getCloudRunDeployConfig)(context);
@@ -111,7 +111,7 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
111
111
  env = ctx.env,
112
112
  componentName = ctx.componentName,
113
113
  deployConfigRaw = ctx.deployConfigRaw;
114
- var HOST_INTERNAL = (0, BashExpression_1.joinBashExpressions)([fullName, (0, BashExpression_1.getBashVariable)((0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX))], "-").toLowerCase();
114
+ var HOSTNAME_INTERNAL = (0, BashExpression_1.joinBashExpressions)([fullName, (0, BashExpression_1.getBashVariable)((0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX))], "-").toLowerCase();
115
115
  var jobTriggers = deployConfigRaw && deployConfigRaw.jobs ? Object.fromEntries(Object.entries(deployConfigRaw.jobs).map(function (_a) {
116
116
  var _b = __read(_a, 2),
117
117
  name = _b[0],
@@ -119,7 +119,7 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
119
119
  return ["CLOUD_RUN_JOB_TRIGGER_URL_" + (0, gitlab_1.sanitizeForBashVariable)(name), "https://".concat(deployConfigRaw.region, "-run.googleapis.com/apis/run.googleapis.com/v1/namespaces/").concat(deployConfigRaw.projectId, "/jobs/").concat((0, jobName_1.getCloudRunJobName)(fullName, name), ":run")];
120
120
  })) : {};
121
121
  return __assign(__assign(__assign({
122
- HOST_INTERNAL: HOST_INTERNAL
122
+ HOSTNAME_INTERNAL: HOSTNAME_INTERNAL
123
123
  }, getCloudSqlVariables(ctx)), jobTriggers), {
124
124
  DEPLOY_CLOUD_RUN_PROJECT_ID: deployConfigRaw ? deployConfigRaw.projectId : undefined,
125
125
  DEPLOY_CLOUD_RUN_REGION: deployConfigRaw ? deployConfigRaw.region : undefined
@@ -1,2 +1,2 @@
1
1
  import type { ComponentContext } from "../../../types/context";
2
- export declare const getServiceName: (context: ComponentContext) => string | import("../../../bash/BashExpression").BashExpression;
2
+ export declare const getServiceName: (context: ComponentContext) => string | import("../../..").BashExpression;
@@ -1,11 +1,11 @@
1
- import type { StringOrBashExpression } from "../../../bash/BashExpression";
2
1
  import type { ComponentContext } from "../../../types";
2
+ import type { VariableValue } from "../../../variables/VariableValue";
3
3
  export declare const hasKubernetesCloudSQL: (context: ComponentContext) => boolean | undefined;
4
4
  type CloudSqlValues = {
5
5
  enabled: boolean;
6
6
  proxyCredentials: string;
7
7
  instanceConnectionName: string;
8
- fullDbName: StringOrBashExpression;
8
+ fullDbName: VariableValue;
9
9
  dbUser: string;
10
10
  };
11
11
  export declare const createKubernetesCloudsqlBaseValues: (context: ComponentContext) => {
@@ -17,7 +17,7 @@ var hasKubernetesCloudSQL = function (context) {
17
17
  };
18
18
  exports.hasKubernetesCloudSQL = hasKubernetesCloudSQL;
19
19
  var createKubernetesCloudsqlBaseValues = function (context) {
20
- var _a, _b, _c, _d, _e, _f, _g;
20
+ var _a, _b, _c;
21
21
  var deployConfig = (_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config;
22
22
  if (!(0, types_1.isOfDeployType)(deployConfig, "kubernetes")) {
23
23
  throw new Error("cannot get cloud sql config");
@@ -27,22 +27,11 @@ var createKubernetesCloudsqlBaseValues = function (context) {
27
27
  throw new Error("cannot get cloud sql config");
28
28
  }
29
29
  var proxyCredentials = "$".concat((0, context_1.getSecretVarNameForContext)(context, "cloudsqlProxyCredentials"));
30
- if ((config === null || config === void 0 ? void 0 : config.type) !== "unmanaged") {
31
- var instanceConnectionName = "".concat((_c = config.projectId) !== null && _c !== void 0 ? _c : "skynet-164509", ":").concat((_d = config.region) !== null && _d !== void 0 ? _d : "europe-west6", ":").concat((_e = config.instanceId) !== null && _e !== void 0 ? _e : context.environment.envVars.KUBE_NAMESPACE);
32
- return {
33
- cloudsql: {
34
- enabled: config.enabled,
35
- dbUser: "postgres",
36
- instanceConnectionName: instanceConnectionName,
37
- proxyCredentials: proxyCredentials,
38
- fullDbName: (_f = context.environment.envVars.KUBE_APP_NAME) !== null && _f !== void 0 ? _f : ""
39
- }
40
- };
41
- } else if (config.type === "unmanaged") {
30
+ if (config.type === "unmanaged") {
42
31
  return {
43
32
  cloudsql: {
44
33
  enabled: config.enabled,
45
- dbUser: (_g = config.dbUser) !== null && _g !== void 0 ? _g : "postgres",
34
+ dbUser: (_c = config.dbUser) !== null && _c !== void 0 ? _c : "postgres",
46
35
  instanceConnectionName: config.instanceConnectionName,
47
36
  proxyCredentials: proxyCredentials,
48
37
  fullDbName: (0, utils_1.getFullDbName)(config, context.fullConfig, context.environment.slugPrefix, context.name)
@@ -77,9 +77,7 @@ var createKubernetesDeployJobs = function (context) {
77
77
  KUBE_DOCKER_IMAGE_PULL_SECRET: "gitlab-registry-".concat(context.name),
78
78
  HELM_GITLAB_CHART_NAME: (_b = deployConfig.chartName) !== null && _b !== void 0 ? _b : "/helm-charts/the-panter-chart",
79
79
  HELM_ARGS: __spreadArray(__spreadArray([], __read(deployConfig.debug ? ["--debug"] : []), false), __read((_c = deployConfig.additionalHelmArgs) !== null && _c !== void 0 ? _c : []), false).join(" "),
80
- COMPONENT_NAME: context.name,
81
- /** @deprecated */
82
- BUILD_ID: context.environment.envVars.BUILD_INFO_BUILD_ID
80
+ COMPONENT_NAME: context.name
83
81
  })
84
82
  });
85
83
  var clusterName = "kube-".concat(context.environment.fullName);
@@ -86,12 +86,12 @@ exports.KUBERNETES_DEPLOY_TYPE = {
86
86
  var domainCanonical = deployConfigRaw && ((_b = deployConfigRaw.cluster) === null || _b === void 0 ? void 0 : _b.domainCanonical) ||
87
87
  // for convenience, we allow clusters to define a canonical domain, because a cluster has a fixed ip and you will usually have a domain pointing to that cluster
88
88
  fullConfig.domainCanonical || "panter.cloud";
89
- var HOST_INTERNAL = (0, BashExpression_1.joinBashExpressions)(__spreadArray(__spreadArray([componentSlug], __read(envType === "review" && reviewSlug ? [reviewSlug] : []), false), [env, fullConfig.appName, fullConfig.customerName, domainCanonical], false), "."); // default for kubernetes and rest
89
+ var HOSTNAME_INTERNAL = (0, BashExpression_1.joinBashExpressions)(__spreadArray(__spreadArray([componentSlug], __read(envType === "review" && reviewSlug ? [reviewSlug] : []), false), [env, fullConfig.appName, fullConfig.customerName, domainCanonical], false), "."); // default for kubernetes and rest
90
90
  return {
91
91
  KUBE_NAMESPACE: KUBE_NAMESPACE,
92
92
  KUBE_APP_NAME: KUBE_APP_NAME,
93
93
  KUBE_APP_NAME_PREFIX: KUBE_APP_NAME_PREFIX,
94
- HOST_INTERNAL: HOST_INTERNAL
94
+ HOSTNAME_INTERNAL: HOSTNAME_INTERNAL
95
95
  };
96
96
  }
97
97
  };
@@ -1,10 +1,10 @@
1
- import type { StringOrBashExpression } from "../../bash/BashExpression";
2
1
  import type { ComponentContext } from "../../types";
2
+ import type { VariableValue } from "../../variables/VariableValue";
3
3
  /**
4
4
  * separate by secrets and public.
5
5
  * we evalulate the actual values later, but want to store the secrets in kubernetes secrets
6
6
  */
7
7
  export declare const createKubeEnv: (context: ComponentContext) => {
8
- secret: Record<string, StringOrBashExpression>;
9
- public: Record<string, StringOrBashExpression>;
8
+ secret: Record<string, VariableValue>;
9
+ public: Record<string, VariableValue>;
10
10
  };
@@ -1,8 +1,8 @@
1
1
  import type { ComponentContext } from "../../types/context";
2
2
  export declare const createKubeValues: (context: ComponentContext) => never[] | ({
3
3
  env: {
4
- secret: Record<string, import("../../bash/BashExpression").StringOrBashExpression>;
5
- public: Record<string, import("../../bash/BashExpression").StringOrBashExpression>;
4
+ secret: Record<string, import("../..").VariableValue>;
5
+ public: Record<string, import("../..").VariableValue>;
6
6
  };
7
7
  application: false | import("../types/base").AllowUnknownProps<{
8
8
  command?: string | undefined;
@@ -62,7 +62,7 @@ export declare const createKubeValues: (context: ComponentContext) => never[] |
62
62
  } | undefined;
63
63
  }> | undefined;
64
64
  } & {
65
- cloudsql?: import("../types").DeployConfigKubernetesValuesCloudSQL | undefined;
65
+ cloudsql?: import("../types").DeployConfigKubernetesValuesCloudSQLUnmanaged | undefined;
66
66
  mongodb?: import("../types").DeployConfigMongodb | undefined;
67
67
  mailhog?: {
68
68
  enabled: boolean;
@@ -73,7 +73,6 @@ export declare const createKubeValues: (context: ComponentContext) => never[] |
73
73
  mapServiceUrlToEnv?: {
74
74
  [envVar: string]: string;
75
75
  } | undefined;
76
- secretsAsFile?: string[] | undefined;
77
76
  jobs: {
78
77
  [k: string]: false | import("../types/base").AllowUnknownProps<{
79
78
  command: string;
@@ -50,7 +50,6 @@ var types_1 = require("../types");
50
50
  var cloudSql_1 = require("./cloudSql");
51
51
  var kubeEnv_1 = require("./kubeEnv");
52
52
  var mongodb_1 = require("./mongodb");
53
- var processSecretsAsFiles_1 = require("./processSecretsAsFiles");
54
53
  var createAppConfig = function (context, application) {
55
54
  if (application === false) {
56
55
  return {
@@ -114,10 +113,10 @@ var createKubeValues = function (context) {
114
113
  env: env,
115
114
  application: createAppConfig(context, application)
116
115
  }, (0, cloudSql_1.hasKubernetesCloudSQL)(context) ? (0, cloudSql_1.createKubernetesCloudsqlBaseValues)(context) : {}, ((_c = (_b = deployConfig.values) === null || _b === void 0 ? void 0 : _b.mongodb) === null || _c === void 0 ? void 0 : _c.enabled) ? (0, mongodb_1.createMongodbBaseConfig)(context) : {});
117
- var kubeValues = (0, processSecretsAsFiles_1.processSecretsAsFiles)((0, utils_1.mergeWithMergingArrays)(defaultKubeValues, __assign({
116
+ var kubeValues = (0, utils_1.mergeWithMergingArrays)(defaultKubeValues, __assign({
118
117
  jobs: removeFalsy(jobs),
119
118
  cronjobs: removeFalsy(cronjobs)
120
- }, rest)));
119
+ }, rest));
121
120
  return kubeValues;
122
121
  };
123
122
  exports.createKubeValues = createKubeValues;
@@ -20,12 +20,6 @@ export type DeployConfigBase = {
20
20
  * Can curently not reference other variables from other components
21
21
  */
22
22
  jobVars?: EnvVars;
23
- /**
24
- * additional env vars for the deploy job
25
- *
26
- * @deprecated use deploy.jobVars for deploy job specific variables
27
- */
28
- extraVars?: Record<string, string>;
29
23
  /**
30
24
  * additional vars only for the runner.
31
25
  * Also if you use services: that require env vars, you need to set them here.
@@ -152,32 +152,6 @@ export type DeployConfigMongodbReplicaset = {
152
152
  replicaCount?: number;
153
153
  };
154
154
  export type DeployConfigMongodb = DeployConfigMongodbBase & (DeployConfigMongodbStandalone | DeployConfigMongodbReplicaset);
155
- /**
156
- * @deprecated use config with instanceConnectionName
157
- */
158
- type DeployConfigKubernetesValuesCloudSQLLegacy = {
159
- enabled: boolean;
160
- /**
161
- * @deprecated use config with instanceConnectionName
162
- */
163
- instanceId?: string;
164
- /**
165
- * @deprecated use config with instanceConnectionName
166
- */
167
- projectId?: string;
168
- /**
169
- * @deprecated use config with instanceConnectionName
170
- */
171
- region?: string;
172
- /**
173
- * @deprecated use type "unmanaged".
174
- *
175
- * Be aware that "unmanaged" is not fully backward compatible with "legacy".
176
- *
177
- *
178
- */
179
- type?: "legacy";
180
- };
181
155
  export type DeployConfigKubernetesValuesCloudSQLUnmanaged = {
182
156
  enabled: boolean;
183
157
  instanceConnectionName: string;
@@ -204,7 +178,7 @@ export type DeployConfigKubernetesValuesCloudSQLUnmanaged = {
204
178
  */
205
179
  dbBaseName?: string;
206
180
  };
207
- export type DeployConfigKubernetesValuesCloudSQL = DeployConfigKubernetesValuesCloudSQLLegacy | DeployConfigKubernetesValuesCloudSQLUnmanaged;
181
+ export type DeployConfigKubernetesValuesCloudSQL = DeployConfigKubernetesValuesCloudSQLUnmanaged;
208
182
  export type DeployConfigKubernetesValues = AllowUnknownProps<{
209
183
  /**
210
184
  * enable cloudsql db. Currently you have to manually set it up
@@ -323,13 +297,6 @@ export type DeployConfigKubernetesValues = AllowUnknownProps<{
323
297
  mapServiceUrlToEnv?: {
324
298
  [envVar: string]: string;
325
299
  };
326
- /**
327
- * Mount secrets as files in the filesystem.
328
- * These secrets are still available as env vars, but will contain the path of the file instead
329
- *
330
- * @deprecated this will be removed in the future, because its very niche and not used
331
- */
332
- secretsAsFile?: string[];
333
300
  }>;
334
301
  export type DeployConfigKubernetes = {
335
302
  type: "kubernetes";
@@ -0,0 +1,14 @@
1
+ declare class GlobalScriptFunction {
2
+ name: string;
3
+ script: string;
4
+ constructor(name: string, script: string);
5
+ toBashFunction(): string;
6
+ invoke(...args: string[]): string;
7
+ }
8
+ export declare const globalScriptFunctions: Map<string, GlobalScriptFunction>;
9
+ /**
10
+ * registers a global script function
11
+ * only use that in top-level scopes as it will attach the function to the global scope
12
+ */
13
+ export declare const registerGlobalScriptFunction: (name: string, script: string) => GlobalScriptFunction;
14
+ export {};
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.registerGlobalScriptFunction = exports.globalScriptFunctions = void 0;
7
+ var GlobalScriptFunction = /** @class */function () {
8
+ function GlobalScriptFunction(name, script) {
9
+ this.name = name;
10
+ this.script = script;
11
+ }
12
+ GlobalScriptFunction.prototype.toBashFunction = function () {
13
+ return "function ".concat(this.name, " () {\n").concat(this.script.trim(), "\n}").trim();
14
+ };
15
+ GlobalScriptFunction.prototype.invoke = function () {
16
+ var args = [];
17
+ for (var _i = 0; _i < arguments.length; _i++) {
18
+ args[_i] = arguments[_i];
19
+ }
20
+ return "".concat(this.name, " ").concat(args.join(" "));
21
+ };
22
+ return GlobalScriptFunction;
23
+ }();
24
+ exports.globalScriptFunctions = new Map();
25
+ /**
26
+ * registers a global script function
27
+ * only use that in top-level scopes as it will attach the function to the global scope
28
+ */
29
+ var registerGlobalScriptFunction = function (name, script) {
30
+ if (exports.globalScriptFunctions.has(name)) {
31
+ throw new Error("Global script function ".concat(name, " already exists"));
32
+ }
33
+ var scriptFunction = new GlobalScriptFunction(name, script);
34
+ exports.globalScriptFunctions.set(name, scriptFunction);
35
+ return scriptFunction;
36
+ };
37
+ exports.registerGlobalScriptFunction = registerGlobalScriptFunction;
package/dist/index.d.ts CHANGED
@@ -6,4 +6,6 @@ export * from "./config";
6
6
  export * from "./context";
7
7
  export * from "./build";
8
8
  export * from "./deploy";
9
- export * from "./utils/writeFiles";
9
+ export * from "./utils/writeFiles";
10
+ export * from "./variables/VariableValue";
11
+ export * from "./bash";
package/dist/index.js CHANGED
@@ -30,4 +30,6 @@ __exportStar(require("./config"), exports);
30
30
  __exportStar(require("./context"), exports);
31
31
  __exportStar(require("./build"), exports);
32
32
  __exportStar(require("./deploy"), exports);
33
- __exportStar(require("./utils/writeFiles"), exports);
33
+ __exportStar(require("./utils/writeFiles"), exports);
34
+ __exportStar(require("./variables/VariableValue"), exports);
35
+ __exportStar(require("./bash"), exports);
@@ -235,7 +235,6 @@ var makeGitlabJob = function (context, job, allJobs, baseRules) {
235
235
  var environment = job.environment,
236
236
  envMode = job.envMode,
237
237
  needsStages = job.needsStages,
238
- needsOtherComponent = job.needsOtherComponent,
239
238
  name = job.name,
240
239
  needs = job.needs,
241
240
  jobTags = job.jobTags,
@@ -243,7 +242,7 @@ var makeGitlabJob = function (context, job, allJobs, baseRules) {
243
242
  variables = job.variables,
244
243
  runnerVariables = job.runnerVariables,
245
244
  when = job.when,
246
- rest = __rest(job, ["environment", "envMode", "needsStages", "needsOtherComponent", "name", "needs", "jobTags", "script", "variables", "runnerVariables", "when"]);
245
+ rest = __rest(job, ["environment", "envMode", "needsStages", "name", "needs", "jobTags", "script", "variables", "runnerVariables", "when"]);
247
246
  var stage = envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(context.env) : job.stage;
248
247
  var deduplicatedGitlabNeeds = getGitlabNeeds(context, job, allJobs);
249
248
  var fullJobName = getFullJobName({
@@ -364,8 +363,7 @@ function deduplicateNeeds(needs) {
364
363
  }
365
364
  function getGitlabNeedsForComponentJob(context, _a, allJobs) {
366
365
  var needsStages = _a.needsStages,
367
- needs = _a.needs,
368
- needsOtherComponent = _a.needsOtherComponent;
366
+ needs = _a.needs;
369
367
  var needsFromStages = needsStages === null || needsStages === void 0 ? void 0 : needsStages.flatMap(function (n) {
370
368
  var _a, _b, _c, _d, _e, _f, _g, _h;
371
369
  var componentName = context.name;
@@ -407,7 +405,7 @@ function getGitlabNeedsForComponentJob(context, _a, allJobs) {
407
405
  });
408
406
  }
409
407
  });
410
- var cleanedNeeds = __spreadArray(__spreadArray(__spreadArray([], __read(needsFromStages !== null && needsFromStages !== void 0 ? needsFromStages : []), false), __read(needs !== null && needs !== void 0 ? needs : []), false), __read(needsOtherComponent !== null && needsOtherComponent !== void 0 ? needsOtherComponent : []), false);
408
+ var cleanedNeeds = __spreadArray(__spreadArray([], __read(needsFromStages !== null && needsFromStages !== void 0 ? needsFromStages : []), false), __read(needs !== null && needs !== void 0 ? needs : []), false);
411
409
  return cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
412
410
  var _a;
413
411
  return (0, lodash_1.isObject)(n) ? "workspaceName" in n ? {
@@ -3,6 +3,7 @@ type PickRequired<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
3
3
  export declare const createGitlabPipelineWithDefaults: ({
4
4
  image,
5
5
  variables,
6
+ before_script,
6
7
  ...config
7
8
  }: PickRequired<Partial<Pipeline<"gitlab">>, "stages" | "jobs">) => Pipeline<"gitlab">;
8
9
  export {};