@catladder/pipeline 1.0.0 → 1.0.4

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 (86) hide show
  1. package/package.json +1 -1
  2. package/src/build/docker.ts +7 -3
  3. package/src/deploy/kubernetes/deployJob.ts +1 -0
  4. package/dist/build/base/constants.d.ts +0 -7
  5. package/dist/build/base/constants.js +0 -11
  6. package/dist/build/base/createBuildJob.d.ts +0 -5
  7. package/dist/build/base/createBuildJob.js +0 -99
  8. package/dist/build/docker.d.ts +0 -5
  9. package/dist/build/docker.js +0 -95
  10. package/dist/build/index.d.ts +0 -12
  11. package/dist/build/index.js +0 -63
  12. package/dist/build/node/buildJob.d.ts +0 -3
  13. package/dist/build/node/buildJob.js +0 -97
  14. package/dist/build/node/cache.d.ts +0 -4
  15. package/dist/build/node/cache.js +0 -67
  16. package/dist/build/node/constants.d.ts +0 -6
  17. package/dist/build/node/constants.js +0 -10
  18. package/dist/build/node/index.d.ts +0 -5
  19. package/dist/build/node/index.js +0 -63
  20. package/dist/build/node/meteor.d.ts +0 -3
  21. package/dist/build/node/meteor.js +0 -103
  22. package/dist/build/node/testJob.d.ts +0 -3
  23. package/dist/build/node/testJob.js +0 -112
  24. package/dist/build/node/yarn.d.ts +0 -2
  25. package/dist/build/node/yarn.js +0 -12
  26. package/dist/build/tests/storybook.test.d.ts +0 -1
  27. package/dist/build/tests/storybook.test.js +0 -221
  28. package/dist/build/types.d.ts +0 -63
  29. package/dist/build/types.js +0 -16
  30. package/dist/catladder-gitlab.d.ts +0 -1
  31. package/dist/catladder-gitlab.js +0 -44
  32. package/dist/config/configruedEnvs.d.ts +0 -4
  33. package/dist/config/configruedEnvs.js +0 -86
  34. package/dist/config/configruedEnvs.test.d.ts +0 -1
  35. package/dist/config/configruedEnvs.test.js +0 -103
  36. package/dist/config/index.d.ts +0 -2
  37. package/dist/config/index.js +0 -24
  38. package/dist/config/readConfig.d.ts +0 -2
  39. package/dist/config/readConfig.js +0 -47
  40. package/dist/constants.d.ts +0 -2
  41. package/dist/constants.js +0 -6
  42. package/dist/context/index.d.ts +0 -5
  43. package/dist/context/index.js +0 -211
  44. package/dist/defaults/index.d.ts +0 -2
  45. package/dist/defaults/index.js +0 -8
  46. package/dist/deploy/base.d.ts +0 -9
  47. package/dist/deploy/base.js +0 -94
  48. package/dist/deploy/index.d.ts +0 -11
  49. package/dist/deploy/index.js +0 -34
  50. package/dist/deploy/kubernetes/cloudsql.d.ts +0 -6
  51. package/dist/deploy/kubernetes/cloudsql.js +0 -16
  52. package/dist/deploy/kubernetes/deployJob.d.ts +0 -3
  53. package/dist/deploy/kubernetes/deployJob.js +0 -148
  54. package/dist/deploy/kubernetes/index.d.ts +0 -1
  55. package/dist/deploy/kubernetes/index.js +0 -22
  56. package/dist/deploy/kubernetes/mongodb.d.ts +0 -15
  57. package/dist/deploy/kubernetes/mongodb.js +0 -23
  58. package/dist/deploy/types.d.ts +0 -92
  59. package/dist/deploy/types.js +0 -16
  60. package/dist/index.d.ts +0 -8
  61. package/dist/index.js +0 -36
  62. package/dist/pipeline/createChildPipeline.d.ts +0 -9
  63. package/dist/pipeline/createChildPipeline.js +0 -266
  64. package/dist/pipeline/createChildPipeline.test.d.ts +0 -1
  65. package/dist/pipeline/createChildPipeline.test.js +0 -199
  66. package/dist/pipeline/createJobs.d.ts +0 -3
  67. package/dist/pipeline/createJobs.js +0 -331
  68. package/dist/pipeline/index.d.ts +0 -2
  69. package/dist/pipeline/index.js +0 -24
  70. package/dist/pipeline/yarnInfo.d.ts +0 -2
  71. package/dist/pipeline/yarnInfo.js +0 -296
  72. package/dist/rules/index.d.ts +0 -3
  73. package/dist/rules/index.js +0 -27
  74. package/dist/runner/index.d.ts +0 -3
  75. package/dist/runner/index.js +0 -12
  76. package/dist/tsconfig.tsbuildinfo +0 -1
  77. package/dist/types/config.d.ts +0 -73
  78. package/dist/types/config.js +0 -80
  79. package/dist/types/context.d.ts +0 -36
  80. package/dist/types/context.js +0 -3
  81. package/dist/types/gitlab-types.d.ts +0 -86
  82. package/dist/types/gitlab-types.js +0 -5
  83. package/dist/types/index.d.ts +0 -3
  84. package/dist/types/index.js +0 -26
  85. package/dist/utils/index.d.ts +0 -2
  86. package/dist/utils/index.js +0 -18
@@ -1,199 +0,0 @@
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
- });
@@ -1,3 +0,0 @@
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>>;
@@ -1,331 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- export * from "./createChildPipeline";
2
- export * from "./createJobs";
@@ -1,24 +0,0 @@
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);
@@ -1,2 +0,0 @@
1
- import { Config, YarnInfo } from "../types";
2
- export declare const getYarnInfo: (config: Config, componentName: string) => Promise<YarnInfo>;