@catladder/pipeline 0.0.7 → 1.0.2

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 (211) hide show
  1. package/babel-inline.json +11 -0
  2. package/bin/catladder-gitlab.js +3 -0
  3. package/dist/build/base/constants.d.ts +7 -0
  4. package/dist/build/base/constants.js +11 -0
  5. package/dist/build/base/createBuildJob.d.ts +5 -0
  6. package/dist/build/base/createBuildJob.js +99 -0
  7. package/dist/build/docker.d.ts +5 -0
  8. package/dist/build/docker.js +95 -0
  9. package/dist/build/index.d.ts +12 -0
  10. package/dist/build/index.js +63 -0
  11. package/dist/build/node/buildJob.d.ts +3 -0
  12. package/dist/build/node/buildJob.js +97 -0
  13. package/dist/build/node/cache.d.ts +4 -0
  14. package/dist/build/node/cache.js +67 -0
  15. package/dist/build/node/constants.d.ts +6 -0
  16. package/dist/build/node/constants.js +10 -0
  17. package/dist/build/node/index.d.ts +5 -0
  18. package/dist/build/node/index.js +63 -0
  19. package/dist/build/node/meteor.d.ts +3 -0
  20. package/dist/build/node/meteor.js +103 -0
  21. package/dist/build/node/testJob.d.ts +3 -0
  22. package/dist/build/node/testJob.js +112 -0
  23. package/dist/build/node/yarn.d.ts +2 -0
  24. package/dist/build/node/yarn.js +12 -0
  25. package/dist/build/tests/storybook.test.d.ts +1 -0
  26. package/dist/build/tests/storybook.test.js +221 -0
  27. package/dist/build/types.d.ts +63 -0
  28. package/dist/build/types.js +16 -0
  29. package/dist/catladder-gitlab.d.ts +1 -0
  30. package/dist/catladder-gitlab.js +44 -0
  31. package/dist/config/configruedEnvs.d.ts +4 -0
  32. package/dist/config/configruedEnvs.js +86 -0
  33. package/dist/config/configruedEnvs.test.d.ts +1 -0
  34. package/dist/config/configruedEnvs.test.js +103 -0
  35. package/dist/config/index.d.ts +2 -0
  36. package/dist/config/index.js +24 -0
  37. package/dist/config/readConfig.d.ts +2 -0
  38. package/dist/config/readConfig.js +47 -0
  39. package/dist/constants.d.ts +2 -0
  40. package/dist/constants.js +6 -0
  41. package/dist/context/index.d.ts +5 -0
  42. package/dist/context/index.js +211 -0
  43. package/dist/defaults/index.d.ts +2 -0
  44. package/dist/defaults/index.js +8 -0
  45. package/dist/deploy/base.d.ts +9 -0
  46. package/dist/deploy/base.js +94 -0
  47. package/dist/deploy/index.d.ts +11 -0
  48. package/dist/deploy/index.js +34 -0
  49. package/dist/deploy/kubernetes/cloudsql.d.ts +6 -0
  50. package/dist/deploy/kubernetes/cloudsql.js +16 -0
  51. package/dist/deploy/kubernetes/deployJob.d.ts +3 -0
  52. package/dist/deploy/kubernetes/deployJob.js +148 -0
  53. package/dist/deploy/kubernetes/index.d.ts +1 -0
  54. package/dist/deploy/kubernetes/index.js +22 -0
  55. package/dist/deploy/kubernetes/mongodb.d.ts +15 -0
  56. package/dist/deploy/kubernetes/mongodb.js +23 -0
  57. package/dist/deploy/types.d.ts +92 -0
  58. package/dist/deploy/types.js +16 -0
  59. package/dist/index.d.ts +8 -0
  60. package/dist/index.js +36 -0
  61. package/dist/pipeline/createChildPipeline.d.ts +9 -0
  62. package/dist/pipeline/createChildPipeline.js +266 -0
  63. package/dist/pipeline/createChildPipeline.test.d.ts +1 -0
  64. package/dist/pipeline/createChildPipeline.test.js +199 -0
  65. package/dist/pipeline/createJobs.d.ts +3 -0
  66. package/dist/pipeline/createJobs.js +331 -0
  67. package/dist/pipeline/index.d.ts +2 -0
  68. package/dist/pipeline/index.js +24 -0
  69. package/dist/pipeline/yarnInfo.d.ts +2 -0
  70. package/dist/pipeline/yarnInfo.js +296 -0
  71. package/dist/rules/index.d.ts +3 -0
  72. package/dist/rules/index.js +27 -0
  73. package/dist/runner/index.d.ts +3 -0
  74. package/dist/runner/index.js +12 -0
  75. package/dist/tsconfig.tsbuildinfo +1 -0
  76. package/dist/types/config.d.ts +73 -0
  77. package/dist/types/config.js +80 -0
  78. package/dist/types/context.d.ts +36 -0
  79. package/dist/types/context.js +3 -0
  80. package/dist/types/gitlab-types.d.ts +86 -0
  81. package/dist/types/gitlab-types.js +5 -0
  82. package/dist/{scripts/magic/types → types}/index.d.ts +1 -1
  83. package/dist/types/index.js +26 -0
  84. package/dist/utils/index.d.ts +2 -0
  85. package/dist/utils/index.js +18 -0
  86. package/package.json +30 -9
  87. package/src/build/base/constants.ts +7 -0
  88. package/src/build/base/createBuildJob.ts +46 -0
  89. package/{scripts/magic → src}/build/docker.ts +15 -2
  90. package/src/build/index.ts +42 -0
  91. package/src/build/node/buildJob.ts +54 -0
  92. package/src/build/node/cache.ts +36 -0
  93. package/src/build/node/constants.ts +6 -0
  94. package/src/build/node/index.ts +17 -0
  95. package/src/build/node/meteor.ts +75 -0
  96. package/src/build/node/testJob.ts +80 -0
  97. package/src/build/node/yarn.ts +8 -0
  98. package/src/build/tests/storybook.test.ts +46 -0
  99. package/src/build/types.ts +75 -0
  100. package/src/catladder-gitlab.ts +52 -0
  101. package/src/config/configruedEnvs.test.ts +97 -0
  102. package/src/config/configruedEnvs.ts +56 -0
  103. package/src/config/index.ts +2 -0
  104. package/src/config/readConfig.ts +36 -0
  105. package/src/constants.ts +2 -0
  106. package/src/context/index.ts +194 -0
  107. package/src/defaults/index.ts +6 -0
  108. package/src/deploy/base.ts +101 -0
  109. package/src/deploy/index.ts +19 -0
  110. package/src/deploy/kubernetes/cloudsql.ts +13 -0
  111. package/src/deploy/kubernetes/deployJob.ts +116 -0
  112. package/src/deploy/kubernetes/index.ts +1 -0
  113. package/src/deploy/kubernetes/mongodb.ts +20 -0
  114. package/src/deploy/types.ts +60 -0
  115. package/src/index.ts +8 -0
  116. package/{scripts/magic/tests/createPipeline.test.ts → src/pipeline/createChildPipeline.test.ts} +5 -4
  117. package/src/pipeline/createChildPipeline.ts +51 -0
  118. package/src/pipeline/createJobs.ts +158 -0
  119. package/src/pipeline/index.ts +2 -0
  120. package/src/pipeline/yarnInfo.ts +54 -0
  121. package/src/rules/index.ts +37 -0
  122. package/src/runner/index.ts +10 -0
  123. package/src/types/config.ts +88 -0
  124. package/src/types/context.ts +36 -0
  125. package/src/types/gitlab-types.ts +94 -0
  126. package/{scripts/magic → src}/types/index.ts +0 -0
  127. package/src/utils/index.ts +10 -0
  128. package/tsconfig.json +4 -2
  129. package/Dockerfile +0 -84
  130. package/dist/scripts/createSamplePipeline.d.ts +0 -2
  131. package/dist/scripts/createSamplePipeline.js +0 -14
  132. package/dist/scripts/magic/build/docker.d.ts +0 -2
  133. package/dist/scripts/magic/build/docker.js +0 -68
  134. package/dist/scripts/magic/build/index.d.ts +0 -9
  135. package/dist/scripts/magic/build/index.js +0 -12
  136. package/dist/scripts/magic/build/node.d.ts +0 -6
  137. package/dist/scripts/magic/build/node.js +0 -150
  138. package/dist/scripts/magic/build/types.d.ts +0 -18
  139. package/dist/scripts/magic/build/types.js +0 -7
  140. package/dist/scripts/magic/context/index.d.ts +0 -3
  141. package/dist/scripts/magic/context/index.js +0 -122
  142. package/dist/scripts/magic/createChildPipeline/index.d.ts +0 -3
  143. package/dist/scripts/magic/createChildPipeline/index.js +0 -68
  144. package/dist/scripts/magic/createPipeline.d.ts +0 -14
  145. package/dist/scripts/magic/createPipeline.js +0 -80
  146. package/dist/scripts/magic/deploy/index.d.ts +0 -9
  147. package/dist/scripts/magic/deploy/index.js +0 -12
  148. package/dist/scripts/magic/deploy/kubernetes.d.ts +0 -5
  149. package/dist/scripts/magic/deploy/kubernetes.js +0 -62
  150. package/dist/scripts/magic/deploy/types.d.ts +0 -41
  151. package/dist/scripts/magic/deploy/types.js +0 -7
  152. package/dist/scripts/magic/index.d.ts +0 -2
  153. package/dist/scripts/magic/index.js +0 -16
  154. package/dist/scripts/magic/sample-config.d.ts +0 -3
  155. package/dist/scripts/magic/sample-config.js +0 -77
  156. package/dist/scripts/magic/tests/createPipeline.test.d.ts +0 -1
  157. package/dist/scripts/magic/tests/createPipeline.test.js +0 -89
  158. package/dist/scripts/magic/types/config.d.ts +0 -49
  159. package/dist/scripts/magic/types/config.js +0 -17
  160. package/dist/scripts/magic/types/context.d.ts +0 -19
  161. package/dist/scripts/magic/types/context.js +0 -2
  162. package/dist/scripts/magic/types/gitlab-types.d.ts +0 -57
  163. package/dist/scripts/magic/types/gitlab-types.js +0 -2
  164. package/dist/scripts/magic/types/index.js +0 -15
  165. package/dist/scripts/magic.d.ts +0 -2
  166. package/dist/scripts/magic.js +0 -43
  167. package/dist/scripts/monorepoGenerate.d.ts +0 -2
  168. package/dist/scripts/monorepoGenerate.js +0 -164
  169. package/dist/scripts/printAllValues.d.ts +0 -2
  170. package/dist/scripts/printAllValues.js +0 -58
  171. package/dist/scripts/printBuildEnv.d.ts +0 -2
  172. package/dist/scripts/printBuildEnv.js +0 -77
  173. package/dist/scripts/utils/extractAllValues.d.ts +0 -1
  174. package/dist/scripts/utils/extractAllValues.js +0 -78
  175. package/dist/scripts/utils/extractBuildEnv.d.ts +0 -5
  176. package/dist/scripts/utils/extractBuildEnv.js +0 -152
  177. package/dist/scripts/utils/extractValuesFromEnvVars.d.ts +0 -2
  178. package/dist/scripts/utils/extractValuesFromEnvVars.js +0 -63
  179. package/dist/scripts/utils/extractValuesFromMr.d.ts +0 -2
  180. package/dist/scripts/utils/extractValuesFromMr.js +0 -86
  181. package/dist/tests/extractValuesFromMr.test.d.ts +0 -1
  182. package/dist/tests/extractValuesFromMr.test.js +0 -68
  183. package/scripts/createSamplePipeline.ts +0 -10
  184. package/scripts/getCommitInfo +0 -11
  185. package/scripts/kubernetesCreateSecret +0 -9
  186. package/scripts/kubernetesDelete +0 -4
  187. package/scripts/kubernetesDeploy +0 -55
  188. package/scripts/kubernetesEnsureNamespace +0 -3
  189. package/scripts/magic/build/index.ts +0 -18
  190. package/scripts/magic/build/node.ts +0 -143
  191. package/scripts/magic/build/types.ts +0 -21
  192. package/scripts/magic/context/index.ts +0 -127
  193. package/scripts/magic/createChildPipeline/index.ts +0 -60
  194. package/scripts/magic/createPipeline.ts +0 -52
  195. package/scripts/magic/deploy/index.ts +0 -19
  196. package/scripts/magic/deploy/kubernetes.ts +0 -65
  197. package/scripts/magic/deploy/types.ts +0 -29
  198. package/scripts/magic/index.ts +0 -2
  199. package/scripts/magic/sample-config.ts +0 -78
  200. package/scripts/magic/types/config.ts +0 -54
  201. package/scripts/magic/types/context.ts +0 -21
  202. package/scripts/magic/types/gitlab-types.ts +0 -69
  203. package/scripts/magic.ts +0 -51
  204. package/scripts/monorepoGenerate.ts +0 -104
  205. package/scripts/printAllValues.ts +0 -17
  206. package/scripts/printBuildEnv.ts +0 -22
  207. package/scripts/utils/extractAllValues.ts +0 -32
  208. package/scripts/utils/extractBuildEnv.ts +0 -94
  209. package/scripts/utils/extractValuesFromEnvVars.ts +0 -21
  210. package/scripts/utils/extractValuesFromMr.ts +0 -39
  211. package/tests/extractValuesFromMr.test.ts +0 -156
@@ -0,0 +1,199 @@
1
+ "use strict";
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
+
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) {
12
+ try {
13
+ step(generator.next(value));
14
+ } catch (e) {
15
+ reject(e);
16
+ }
17
+ }
18
+
19
+ function rejected(value) {
20
+ try {
21
+ step(generator["throw"](value));
22
+ } catch (e) {
23
+ reject(e);
24
+ }
25
+ }
26
+
27
+ function step(result) {
28
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
29
+ }
30
+
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+
35
+ var __generator = this && this.__generator || function (thisArg, body) {
36
+ var _ = {
37
+ label: 0,
38
+ sent: function () {
39
+ if (t[0] & 1) throw t[1];
40
+ return t[1];
41
+ },
42
+ trys: [],
43
+ ops: []
44
+ },
45
+ f,
46
+ y,
47
+ t,
48
+ g;
49
+ return g = {
50
+ next: verb(0),
51
+ "throw": verb(1),
52
+ "return": verb(2)
53
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
54
+ return this;
55
+ }), g;
56
+
57
+ function verb(n) {
58
+ return function (v) {
59
+ return step([n, v]);
60
+ };
61
+ }
62
+
63
+ function step(op) {
64
+ if (f) throw new TypeError("Generator is already executing.");
65
+
66
+ while (_) try {
67
+ 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;
68
+ if (y = 0, t) op = [op[0] & 2, t.value];
69
+
70
+ switch (op[0]) {
71
+ case 0:
72
+ case 1:
73
+ t = op;
74
+ break;
75
+
76
+ case 4:
77
+ _.label++;
78
+ return {
79
+ value: op[1],
80
+ done: false
81
+ };
82
+
83
+ case 5:
84
+ _.label++;
85
+ y = op[1];
86
+ op = [0];
87
+ continue;
88
+
89
+ case 7:
90
+ op = _.ops.pop();
91
+
92
+ _.trys.pop();
93
+
94
+ continue;
95
+
96
+ default:
97
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
98
+ _ = 0;
99
+ continue;
100
+ }
101
+
102
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
103
+ _.label = op[1];
104
+ break;
105
+ }
106
+
107
+ if (op[0] === 6 && _.label < t[1]) {
108
+ _.label = t[1];
109
+ t = op;
110
+ break;
111
+ }
112
+
113
+ if (t && _.label < t[2]) {
114
+ _.label = t[2];
115
+
116
+ _.ops.push(op);
117
+
118
+ break;
119
+ }
120
+
121
+ if (t[2]) _.ops.pop();
122
+
123
+ _.trys.pop();
124
+
125
+ continue;
126
+ }
127
+
128
+ op = body.call(thisArg, _);
129
+ } catch (e) {
130
+ op = [6, e];
131
+ y = 0;
132
+ } finally {
133
+ f = t = 0;
134
+ }
135
+
136
+ if (op[0] & 5) throw op[1];
137
+ return {
138
+ value: op[0] ? op[1] : void 0,
139
+ done: true
140
+ };
141
+ }
142
+ };
143
+
144
+ var __rest = this && this.__rest || function (s, e) {
145
+ var t = {};
146
+
147
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
148
+
149
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
150
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
151
+ }
152
+ return t;
153
+ };
154
+
155
+ exports.__esModule = true;
156
+
157
+ var createChildPipeline_1 = require("./createChildPipeline");
158
+
159
+ describe("createChildPipeline", function () {
160
+ describe("node-app to kuberntes", function () {
161
+ var config = {
162
+ appName: "test",
163
+ customerName: "pan",
164
+ components: {
165
+ "my-app": {
166
+ dir: "myapp",
167
+ build: {
168
+ type: "node"
169
+ },
170
+ deploy: {
171
+ type: "kubernetes"
172
+ }
173
+ }
174
+ }
175
+ };
176
+ it("creates a pipeline for a single app on the main branch", function () {
177
+ return __awaiter(void 0, void 0, void 0, function () {
178
+ var _a, image, stages, workflow, jobs;
179
+
180
+ return __generator(this, function (_b) {
181
+ switch (_b.label) {
182
+ case 0:
183
+ return [4
184
+ /*yield*/
185
+ , (0, createChildPipeline_1.createChildPipeline)("mainBranch", config)];
186
+
187
+ case 1:
188
+ _a = _b.sent(), image = _a.image, stages = _a.stages, workflow = _a.workflow, jobs = __rest(_a, ["image", "stages", "workflow"]);
189
+ expect(image).toEqual("git.panter.ch:5001/catladder/catladder/base-pipeline:");
190
+ expect(Object.keys(jobs)).toEqual(["my-app audit", "my-app lint", "my-app test", "dev my-app app-build", "dev my-app docker-build", "dev my-app deploy-to-kubernetes", "dev my-app kubernetes-stop"]);
191
+ return [2
192
+ /*return*/
193
+ ];
194
+ }
195
+ });
196
+ });
197
+ });
198
+ });
199
+ });
@@ -0,0 +1,3 @@
1
+ import { Config, PipelineTrigger } from "../types/config";
2
+ import { GitlabJobDef } from "../types/gitlab-types";
3
+ export declare const createJobs: (envs: string[], config: Config, componentName: string, trigger: PipelineTrigger) => Promise<Record<string, GitlabJobDef>>;
@@ -0,0 +1,331 @@
1
+ "use strict";
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
+
8
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
9
+ }
10
+
11
+ return t;
12
+ };
13
+
14
+ return __assign.apply(this, arguments);
15
+ };
16
+
17
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) {
19
+ return value instanceof P ? value : new P(function (resolve) {
20
+ resolve(value);
21
+ });
22
+ }
23
+
24
+ return new (P || (P = Promise))(function (resolve, reject) {
25
+ function fulfilled(value) {
26
+ try {
27
+ step(generator.next(value));
28
+ } catch (e) {
29
+ reject(e);
30
+ }
31
+ }
32
+
33
+ function rejected(value) {
34
+ try {
35
+ step(generator["throw"](value));
36
+ } catch (e) {
37
+ reject(e);
38
+ }
39
+ }
40
+
41
+ function step(result) {
42
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
43
+ }
44
+
45
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
46
+ });
47
+ };
48
+
49
+ var __generator = this && this.__generator || function (thisArg, body) {
50
+ var _ = {
51
+ label: 0,
52
+ sent: function () {
53
+ if (t[0] & 1) throw t[1];
54
+ return t[1];
55
+ },
56
+ trys: [],
57
+ ops: []
58
+ },
59
+ f,
60
+ y,
61
+ t,
62
+ g;
63
+ return g = {
64
+ next: verb(0),
65
+ "throw": verb(1),
66
+ "return": verb(2)
67
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
68
+ return this;
69
+ }), g;
70
+
71
+ function verb(n) {
72
+ return function (v) {
73
+ return step([n, v]);
74
+ };
75
+ }
76
+
77
+ function step(op) {
78
+ if (f) throw new TypeError("Generator is already executing.");
79
+
80
+ while (_) try {
81
+ 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;
82
+ if (y = 0, t) op = [op[0] & 2, t.value];
83
+
84
+ switch (op[0]) {
85
+ case 0:
86
+ case 1:
87
+ t = op;
88
+ break;
89
+
90
+ case 4:
91
+ _.label++;
92
+ return {
93
+ value: op[1],
94
+ done: false
95
+ };
96
+
97
+ case 5:
98
+ _.label++;
99
+ y = op[1];
100
+ op = [0];
101
+ continue;
102
+
103
+ case 7:
104
+ op = _.ops.pop();
105
+
106
+ _.trys.pop();
107
+
108
+ continue;
109
+
110
+ default:
111
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
112
+ _ = 0;
113
+ continue;
114
+ }
115
+
116
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
117
+ _.label = op[1];
118
+ break;
119
+ }
120
+
121
+ if (op[0] === 6 && _.label < t[1]) {
122
+ _.label = t[1];
123
+ t = op;
124
+ break;
125
+ }
126
+
127
+ if (t && _.label < t[2]) {
128
+ _.label = t[2];
129
+
130
+ _.ops.push(op);
131
+
132
+ break;
133
+ }
134
+
135
+ if (t[2]) _.ops.pop();
136
+
137
+ _.trys.pop();
138
+
139
+ continue;
140
+ }
141
+
142
+ op = body.call(thisArg, _);
143
+ } catch (e) {
144
+ op = [6, e];
145
+ y = 0;
146
+ } finally {
147
+ f = t = 0;
148
+ }
149
+
150
+ if (op[0] & 5) throw op[1];
151
+ return {
152
+ value: op[0] ? op[1] : void 0,
153
+ done: true
154
+ };
155
+ }
156
+ };
157
+
158
+ var __read = this && this.__read || function (o, n) {
159
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
160
+ if (!m) return o;
161
+ var i = m.call(o),
162
+ r,
163
+ ar = [],
164
+ e;
165
+
166
+ try {
167
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
168
+ } catch (error) {
169
+ e = {
170
+ error: error
171
+ };
172
+ } finally {
173
+ try {
174
+ if (r && !r.done && (m = i["return"])) m.call(i);
175
+ } finally {
176
+ if (e) throw e.error;
177
+ }
178
+ }
179
+
180
+ return ar;
181
+ };
182
+
183
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
184
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
185
+ if (ar || !(i in from)) {
186
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
187
+ ar[i] = from[i];
188
+ }
189
+ }
190
+ return to.concat(ar || Array.prototype.slice.call(from));
191
+ };
192
+
193
+ exports.__esModule = true;
194
+ exports.createJobs = void 0;
195
+
196
+ var lodash_1 = require("lodash");
197
+
198
+ var build_1 = require("../build");
199
+
200
+ var context_1 = require("../context");
201
+
202
+ var deploy_1 = require("../deploy");
203
+
204
+ var utils_1 = require("../utils");
205
+
206
+ var yarnInfo_1 = require("./yarnInfo");
207
+
208
+ var createRawJobs = function (context) {
209
+ if (context.componentConfig.deploy === false) {
210
+ return [];
211
+ }
212
+
213
+ var buildJobs = build_1.BUILD_TYPES[context.componentConfig.build.type].jobs(context);
214
+ var deployJobs = deploy_1.DEPLOY_TYPES[context.componentConfig.deploy.type].jobs(context);
215
+ return __spreadArray(__spreadArray([], __read(buildJobs), false), __read(deployJobs), false);
216
+ };
217
+
218
+ var getFullJobName = function (name, componentName, env) {
219
+ if (env) {
220
+ return "".concat(componentName, " ").concat(name, " | ").concat(env, " ");
221
+ }
222
+
223
+ return "".concat(componentName, " ").concat(name);
224
+ };
225
+
226
+ var getFullReferencedJobName = function (referencedJobName, componentName, env, allRawJobs) {
227
+ var referencedJob = allRawJobs.find(function (j) {
228
+ return j.name === referencedJobName;
229
+ });
230
+
231
+ if (!referencedJob) {
232
+ throw new Error("unknown job referenced: " + referencedJobName);
233
+ }
234
+
235
+ var envToSet = referencedJob.envMode !== "none" ? env : null;
236
+ return getFullJobName(referencedJobName, componentName, envToSet);
237
+ }; // replaces references to other jobs with the full name
238
+ // the full name contains the componentname and the env name (if any)
239
+
240
+
241
+ var replaceReferences = function (job, componentName, env, allRawJobs) {
242
+ var _a, _b, _c;
243
+
244
+ var def = job.job;
245
+ var stage = job.envMode === "stagePerEnv" ? "".concat(def.stage, " ").concat(env) : def.stage;
246
+ return __assign(__assign({}, def), {
247
+ stage: stage,
248
+ needs: (_a = def.needs) === null || _a === void 0 ? void 0 : _a.map(function (n) {
249
+ return (0, lodash_1.isObject)(n) ? {
250
+ job: getFullReferencedJobName(n.job, componentName, env, allRawJobs),
251
+ artifacts: n.artifacts
252
+ } : getFullReferencedJobName(n, componentName, env, allRawJobs);
253
+ }),
254
+ environment: ((_b = def.environment) === null || _b === void 0 ? void 0 : _b.on_stop) ? __assign(__assign({}, def.environment), {
255
+ on_stop: getFullReferencedJobName(def.environment.on_stop, componentName, env, allRawJobs)
256
+ }) : def.environment,
257
+ dependencies: (_c = def.dependencies) === null || _c === void 0 ? void 0 : _c.map(function (n) {
258
+ return getFullReferencedJobName(n, componentName, env, allRawJobs);
259
+ })
260
+ });
261
+ }; // this can be removed once https://gitlab.com/gitlab-org/gitlab/-/issues/220758 is resolved
262
+
263
+
264
+ var addStageNeeds = function (jobs) {
265
+ // when a job defines needsStages, we add these as needs
266
+ return jobs.map(function (job) {
267
+ var _a;
268
+
269
+ if (!job.needsStages || job.needsStages.length === 0) {
270
+ return job;
271
+ }
272
+
273
+ var neededJobs = jobs.map(function (j) {
274
+ var _a, _b;
275
+
276
+ var neededStage = (_a = job.needsStages) === null || _a === void 0 ? void 0 : _a.find(function (s) {
277
+ return j.job.stage === s.stage;
278
+ });
279
+
280
+ if (neededStage) {
281
+ return {
282
+ job: j.name,
283
+ artifacts: (_b = neededStage.artifacts) !== null && _b !== void 0 ? _b : false
284
+ };
285
+ }
286
+ }).filter(utils_1.notNil);
287
+ return __assign(__assign({}, job), {
288
+ job: __assign(__assign({}, job.job), {
289
+ needs: __spreadArray(__spreadArray([], __read((_a = job.job.needs) !== null && _a !== void 0 ? _a : []), false), __read(neededJobs), false)
290
+ })
291
+ });
292
+ });
293
+ };
294
+
295
+ var createJobs = function (envs, config, componentName, trigger) {
296
+ return __awaiter(void 0, void 0, void 0, function () {
297
+ var commitInfo, yarnInfo;
298
+
299
+ var _a, _b;
300
+
301
+ return __generator(this, function (_c) {
302
+ switch (_c.label) {
303
+ case 0:
304
+ commitInfo = {
305
+ refName: (_a = process.env.CI_COMMIT_REF_NAME) !== null && _a !== void 0 ? _a : "unknown",
306
+ refSlug: (_b = process.env.CI_COMMIT_REF_SLUG) !== null && _b !== void 0 ? _b : "unknown",
307
+ trigger: trigger
308
+ };
309
+ return [4
310
+ /*yield*/
311
+ , (0, yarnInfo_1.getYarnInfo)(config, componentName)];
312
+
313
+ case 1:
314
+ yarnInfo = _c.sent();
315
+ return [2
316
+ /*return*/
317
+ , envs.reduce(function (acc, env) {
318
+ var context = (0, context_1.createContext)(config, componentName, env, commitInfo, yarnInfo);
319
+ var jobs = addStageNeeds(createRawJobs(context));
320
+ return __assign(__assign({}, acc), jobs.reduce(function (acc, job) {
321
+ var _a;
322
+
323
+ return __assign(__assign({}, acc), (_a = {}, _a[getFullJobName(job.name, componentName, job.envMode !== "none" ? env : undefined)] = replaceReferences(job, componentName, env, jobs), _a));
324
+ }, {}));
325
+ }, {})];
326
+ }
327
+ });
328
+ });
329
+ };
330
+
331
+ exports.createJobs = createJobs;
@@ -0,0 +1,2 @@
1
+ export * from "./createChildPipeline";
2
+ export * from "./createJobs";
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ Object.defineProperty(o, k2, {
6
+ enumerable: true,
7
+ get: function () {
8
+ return m[k];
9
+ }
10
+ });
11
+ } : function (o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ });
15
+
16
+ var __exportStar = this && this.__exportStar || function (m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+
20
+ exports.__esModule = true;
21
+
22
+ __exportStar(require("./createChildPipeline"), exports);
23
+
24
+ __exportStar(require("./createJobs"), exports);
@@ -0,0 +1,2 @@
1
+ import { Config, YarnInfo } from "../types";
2
+ export declare const getYarnInfo: (config: Config, componentName: string) => Promise<YarnInfo>;