@catladder/pipeline 1.101.4 → 1.103.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 (43) hide show
  1. package/dist/build/base/createBuildJob.js +3 -2
  2. package/dist/build/base/writeDotEnv.d.ts +7 -0
  3. package/dist/build/base/writeDotEnv.js +43 -0
  4. package/dist/build/custom/testJob.js +2 -2
  5. package/dist/build/node/testJob.js +2 -2
  6. package/dist/build/rails/build.js +11 -1
  7. package/dist/build/rails/test.js +1 -1
  8. package/dist/build/types.d.ts +8 -1
  9. package/dist/bundles/catladder-gitlab/index.js +3 -3
  10. package/dist/constants.js +1 -1
  11. package/dist/context/getEnvironment.js +18 -12
  12. package/dist/context/getEnvironmentVariables.d.ts +2 -7
  13. package/dist/context/getEnvironmentVariables.js +27 -31
  14. package/dist/context/transformJobOnlyVars.d.ts +10 -0
  15. package/dist/context/transformJobOnlyVars.js +160 -0
  16. package/dist/context/utils/envVars.d.ts +8 -0
  17. package/dist/context/utils/envVars.js +52 -0
  18. package/dist/deploy/base.js +3 -3
  19. package/dist/deploy/types/base.d.ts +8 -0
  20. package/dist/tsconfig.tsbuildinfo +1 -1
  21. package/dist/types/config.d.ts +6 -0
  22. package/dist/types/context.d.ts +16 -6
  23. package/examples/__snapshots__/custom-deploy.ts.snap +8 -0
  24. package/examples/__snapshots__/native-app.ts.snap +2958 -0
  25. package/examples/custom-deploy.ts +3 -0
  26. package/examples/native-app.ts +81 -0
  27. package/package.json +1 -1
  28. package/src/build/base/createBuildJob.ts +3 -0
  29. package/src/build/base/writeDotEnv.ts +21 -0
  30. package/src/build/custom/testJob.ts +1 -0
  31. package/src/build/node/testJob.ts +1 -0
  32. package/src/build/rails/build.ts +4 -1
  33. package/src/build/rails/test.ts +4 -1
  34. package/src/build/types.ts +9 -1
  35. package/src/context/getEnvironment.ts +9 -7
  36. package/src/context/getEnvironmentVariables.ts +36 -24
  37. package/src/context/transformJobOnlyVars.ts +42 -0
  38. package/src/context/utils/envVars.ts +26 -0
  39. package/src/deploy/base.ts +3 -0
  40. package/src/deploy/types/base.ts +10 -0
  41. package/src/types/config.ts +7 -0
  42. package/src/types/context.ts +18 -6
  43. package/tsconfig.json +1 -1
@@ -58,6 +58,7 @@ var utils_1 = require("../../utils");
58
58
  var yarn_1 = require("../node/yarn");
59
59
  var constants_1 = require("./constants");
60
60
  var writeBuildInfo_1 = require("./writeBuildInfo");
61
+ var writeDotEnv_1 = require("./writeDotEnv");
61
62
  var createBuildJob = function (context, _a) {
62
63
  var _b, _c, _d, _e;
63
64
  var script = _a.script,
@@ -70,8 +71,8 @@ var createBuildJob = function (context, _a) {
70
71
  image: (0, __1.getRunnerImage)("jobs-default"),
71
72
  needs: [],
72
73
  cache: [],
73
- variables: __assign(__assign(__assign(__assign({}, constants_1.RUNNER_BUILD_RESOURCE_VARIABLES), variables !== null && variables !== void 0 ? variables : {}), context.environment.envVars), (_b = context.componentConfig.build.extraVars) !== null && _b !== void 0 ? _b : {}),
74
- script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, writeBuildInfo_1.writeBuildInfo)(context)), false), __read((0, yarn_1.ensureNodeVersion)(context)), false), ["cd ".concat(context.componentConfig.dir)], false), __read((_c = (0, utils_1.ensureArray)(script)) !== null && _c !== void 0 ? _c : []), false),
74
+ variables: __assign(__assign(__assign(__assign(__assign({}, constants_1.RUNNER_BUILD_RESOURCE_VARIABLES), variables !== null && variables !== void 0 ? variables : {}), context.environment.envVars), context.environment.jobOnlyVars.build.envVars), (_b = context.componentConfig.build.extraVars) !== null && _b !== void 0 ? _b : {}),
75
+ script: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(context.componentConfig.dotEnv ? (0, writeDotEnv_1.writeDotEnv)(context) : []), false), __read((0, writeBuildInfo_1.writeBuildInfo)(context)), false), __read((0, yarn_1.ensureNodeVersion)(context)), false), ["cd ".concat(context.componentConfig.dir)], false), __read((_c = (0, utils_1.ensureArray)(script)) !== null && _c !== void 0 ? _c : []), false),
75
76
  artifacts: {
76
77
  paths: [(0, path_1.join)(context.componentConfig.dir, "__build_info.json")],
77
78
  reports: {
@@ -0,0 +1,7 @@
1
+ import type { Context } from "../../types";
2
+ /**
3
+ * writes a .env file in the components folder
4
+ * @param context
5
+ * @returns
6
+ */
7
+ export declare const writeDotEnv: (context: Context) => string[];
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var __read = this && this.__read || function (o, n) {
4
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
5
+ if (!m) return o;
6
+ var i = m.call(o),
7
+ r,
8
+ ar = [],
9
+ e;
10
+ try {
11
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12
+ } catch (error) {
13
+ e = {
14
+ error: error
15
+ };
16
+ } finally {
17
+ try {
18
+ if (r && !r.done && (m = i["return"])) m.call(i);
19
+ } finally {
20
+ if (e) throw e.error;
21
+ }
22
+ }
23
+ return ar;
24
+ };
25
+ exports.__esModule = true;
26
+ exports.writeDotEnv = void 0;
27
+ /**
28
+ * writes a .env file in the components folder
29
+ * @param context
30
+ * @returns
31
+ */
32
+ var writeDotEnv = function (context) {
33
+ var envVars = context.environment.envVars;
34
+ // make key=value and sanitize multiline
35
+ var keyValueString = Object.entries(envVars).map(function (_a) {
36
+ var _b = __read(_a, 2),
37
+ key = _b[0],
38
+ value = _b[1];
39
+ return "".concat(key, "=").concat(value.replaceAll("\n", "\\n"));
40
+ }).join("\n");
41
+ return ["cat <<EOF > ".concat(context.componentConfig.dir, "/.env\n").concat(keyValueString, "\nEOF")];
42
+ };
43
+ exports.writeDotEnv = writeDotEnv;
@@ -63,9 +63,9 @@ var createCustomTestJobs = function (context) {
63
63
  throw new Error("deploy config is not custom");
64
64
  }
65
65
  var base = {
66
- variables: __assign(__assign({
66
+ variables: __assign(__assign(__assign({
67
67
  APP_PATH: context.componentConfig.dir
68
- }, RUNNER_CUSTOM_TEST_VARIABLES), (_b = buildConfig.extraVars) !== null && _b !== void 0 ? _b : {}),
68
+ }, RUNNER_CUSTOM_TEST_VARIABLES), context.environment.jobOnlyVars.build.envVars), (_b = buildConfig.extraVars) !== null && _b !== void 0 ? _b : {}),
69
69
  services: buildConfig.jobServices,
70
70
  cache: buildConfig.jobCache,
71
71
  stage: "test",
@@ -56,9 +56,9 @@ var createNodeTestJobs = function (context) {
56
56
  }
57
57
  var buildConfig = context.componentConfig.build;
58
58
  var base = {
59
- variables: __assign(__assign({
59
+ variables: __assign(__assign(__assign({
60
60
  APP_PATH: context.componentConfig.dir
61
- }, constants_1.NODE_RUNNER_BUILD_VARIABLES), (_b = buildConfig.extraVars) !== null && _b !== void 0 ? _b : {}),
61
+ }, constants_1.NODE_RUNNER_BUILD_VARIABLES), context.environment.jobOnlyVars.build.envVars), (_b = buildConfig.extraVars) !== null && _b !== void 0 ? _b : {}),
62
62
  stage: "test",
63
63
  needs: [],
64
64
  envMode: "none"
@@ -1,5 +1,15 @@
1
1
  "use strict";
2
2
 
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
3
13
  var __read = this && this.__read || function (o, n) {
4
14
  var m = typeof Symbol === "function" && o[Symbol.iterator];
5
15
  if (!m) return o;
@@ -41,7 +51,7 @@ var createRailsBuildJobs = function (context) {
41
51
  return "--env '".concat(k).concat(v ? "=".concat(v) : "", "'");
42
52
  }).join(" ");
43
53
  return [(0, docker_1.createDockerBuildJobBase)(context, {
44
- variables: context.componentConfig.build.extraVars,
54
+ variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), context.componentConfig.build.extraVars),
45
55
  // custom script
46
56
  script: [docker_1.gitlabDockerLogin, "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
47
57
  // replace private git ssh gem sources with https to make bundler with credentials via env var work
@@ -52,7 +52,7 @@ var createRailsTestJobs = function (context) {
52
52
  }
53
53
  var buildConfig = context.componentConfig.build;
54
54
  var base = {
55
- variables: (_b = buildConfig.extraVars) !== null && _b !== void 0 ? _b : {},
55
+ variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), (_b = buildConfig.extraVars) !== null && _b !== void 0 ? _b : {}),
56
56
  stage: "test",
57
57
  needs: [],
58
58
  envMode: "none"
@@ -1,4 +1,4 @@
1
- import type { GitlabJobImage, GitlabJobService } from "../types";
1
+ import type { EnvVars, GitlabJobImage, GitlabJobService } from "../types";
2
2
  import type { CatladderJob } from "../types/jobs";
3
3
  export declare type BuildConfigArtifactsReports = {
4
4
  /**
@@ -14,8 +14,15 @@ export declare type BuildConfigBase = {
14
14
  * command to run on the image to start the app (e.g. yarn start)
15
15
  */
16
16
  startCommand?: string;
17
+ /**
18
+ * vars that only exist in the build jobs.
19
+ * Can curently not reference other variables from other components
20
+ */
21
+ jobVars?: EnvVars;
17
22
  /**
18
23
  * additional env vars for the buid jobs
24
+ *
25
+ * @deprecated use jobVars
19
26
  */
20
27
  extraVars?: Record<string, string>;
21
28
  /**