@catladder/pipeline 0.0.0-next-e7541a00 → 0.0.0-next-16388362
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.
- package/dist/backends/index.d.ts +7 -2
- package/dist/backends/index.js +21 -2
- package/dist/constants.js +1 -1
- package/dist/pipeline/generatePipelineFiles.d.ts +6 -1
- package/dist/pipeline/generatePipelineFiles.js +67 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +20 -0
- package/examples/__snapshots__/pipelines-config.test.ts.snap +1505 -0
- package/examples/pipelines-config.test.ts +12 -0
- package/examples/pipelines-config.ts +34 -0
- package/package.json +1 -1
- package/src/backends/__tests__/getEnabledPipelineTypes.test.ts +39 -0
- package/src/backends/index.ts +20 -1
- package/src/pipeline/generatePipelineFiles.ts +21 -4
- package/src/types/config.ts +24 -0
package/dist/backends/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import type { PipelineType } from "../types";
|
|
1
|
+
import type { Config, PipelineType } from "../types";
|
|
2
2
|
import type { PipelineBackend } from "./types";
|
|
3
3
|
export * from "./types";
|
|
4
4
|
export * from "./gitlab";
|
|
5
|
-
export declare const getPipelineBackend: (type: PipelineType) => PipelineBackend;
|
|
5
|
+
export declare const getPipelineBackend: (type: PipelineType) => PipelineBackend;
|
|
6
|
+
/**
|
|
7
|
+
* the pipeline types enabled for this config. Multiple types can be
|
|
8
|
+
* enabled at once (parallel generation, e.g. during a CI migration).
|
|
9
|
+
*/
|
|
10
|
+
export declare const getEnabledPipelineTypes: (config: Config) => PipelineType[];
|
package/dist/backends/index.js
CHANGED
|
@@ -22,7 +22,7 @@ var __exportStar = this && this.__exportStar || function (m, exports) {
|
|
|
22
22
|
Object.defineProperty(exports, "__esModule", {
|
|
23
23
|
value: true
|
|
24
24
|
});
|
|
25
|
-
exports.getPipelineBackend = void 0;
|
|
25
|
+
exports.getEnabledPipelineTypes = exports.getPipelineBackend = void 0;
|
|
26
26
|
var gitlab_1 = require("./gitlab");
|
|
27
27
|
__exportStar(require("./types"), exports);
|
|
28
28
|
__exportStar(require("./gitlab"), exports);
|
|
@@ -38,4 +38,23 @@ var getPipelineBackend = function (type) {
|
|
|
38
38
|
}
|
|
39
39
|
return createBackend();
|
|
40
40
|
};
|
|
41
|
-
exports.getPipelineBackend = getPipelineBackend;
|
|
41
|
+
exports.getPipelineBackend = getPipelineBackend;
|
|
42
|
+
/**
|
|
43
|
+
* the pipeline types enabled for this config. Multiple types can be
|
|
44
|
+
* enabled at once (parallel generation, e.g. during a CI migration).
|
|
45
|
+
*/
|
|
46
|
+
var getEnabledPipelineTypes = function (config) {
|
|
47
|
+
var _a;
|
|
48
|
+
if (config.pipelines) {
|
|
49
|
+
var enabled = Object.keys(BACKENDS).filter(function (type) {
|
|
50
|
+
var _a;
|
|
51
|
+
return (_a = config.pipelines) === null || _a === void 0 ? void 0 : _a[type];
|
|
52
|
+
});
|
|
53
|
+
if (enabled.length === 0) {
|
|
54
|
+
throw new Error("`pipelines` is configured, but no pipeline type is enabled");
|
|
55
|
+
}
|
|
56
|
+
return enabled;
|
|
57
|
+
}
|
|
58
|
+
return [(_a = config.pipelineType) !== null && _a !== void 0 ? _a : "gitlab"];
|
|
59
|
+
};
|
|
60
|
+
exports.getEnabledPipelineTypes = getEnabledPipelineTypes;
|
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 = "next-
|
|
7
|
+
exports.PIPELINE_IMAGE_TAG = "next-16388362" || "latest";
|
|
8
8
|
exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "git.panter.ch:5001/catladder/catladder";
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { Config, PipelineType } from "../types";
|
|
2
2
|
import type { CatenvContext } from "../catenv";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* generates the pipeline files of all pipeline types enabled in the
|
|
5
|
+
* config (see `pipelines`). Pass an explicit `pipelineType` to generate
|
|
6
|
+
* only that one.
|
|
7
|
+
*/
|
|
8
|
+
export declare function generatePipelineFiles(context: CatenvContext, pipelineType?: PipelineType): Promise<void>;
|
|
4
9
|
/**
|
|
5
10
|
*
|
|
6
11
|
* for testing purposes
|
|
@@ -115,6 +115,22 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
|
+
var __values = this && this.__values || function (o) {
|
|
119
|
+
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
120
|
+
m = s && o[s],
|
|
121
|
+
i = 0;
|
|
122
|
+
if (m) return m.call(o);
|
|
123
|
+
if (o && typeof o.length === "number") return {
|
|
124
|
+
next: function () {
|
|
125
|
+
if (o && i >= o.length) o = void 0;
|
|
126
|
+
return {
|
|
127
|
+
value: o && o[i++],
|
|
128
|
+
done: !o
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
133
|
+
};
|
|
118
134
|
Object.defineProperty(exports, "__esModule", {
|
|
119
135
|
value: true
|
|
120
136
|
});
|
|
@@ -123,14 +139,63 @@ var promises_1 = require("fs/promises");
|
|
|
123
139
|
var path_1 = require("path");
|
|
124
140
|
var backends_1 = require("../backends");
|
|
125
141
|
var gitlab_1 = require("../backends/gitlab");
|
|
142
|
+
/**
|
|
143
|
+
* generates the pipeline files of all pipeline types enabled in the
|
|
144
|
+
* config (see `pipelines`). Pass an explicit `pipelineType` to generate
|
|
145
|
+
* only that one.
|
|
146
|
+
*/
|
|
126
147
|
function generatePipelineFiles(context, pipelineType) {
|
|
127
148
|
return __awaiter(this, void 0, void 0, function () {
|
|
128
|
-
var
|
|
149
|
+
var pipelineTypes, pipelineTypes_1, pipelineTypes_1_1, type, e_1_1;
|
|
150
|
+
var e_1, _a;
|
|
151
|
+
return __generator(this, function (_b) {
|
|
152
|
+
switch (_b.label) {
|
|
153
|
+
case 0:
|
|
154
|
+
pipelineTypes = pipelineType ? [pipelineType] : (0, backends_1.getEnabledPipelineTypes)(context.config);
|
|
155
|
+
_b.label = 1;
|
|
156
|
+
case 1:
|
|
157
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
158
|
+
pipelineTypes_1 = __values(pipelineTypes), pipelineTypes_1_1 = pipelineTypes_1.next();
|
|
159
|
+
_b.label = 2;
|
|
160
|
+
case 2:
|
|
161
|
+
if (!!pipelineTypes_1_1.done) return [3 /*break*/, 5];
|
|
162
|
+
type = pipelineTypes_1_1.value;
|
|
163
|
+
return [4 /*yield*/, generatePipelineFilesForBackend(context, (0, backends_1.getPipelineBackend)(type))];
|
|
164
|
+
case 3:
|
|
165
|
+
_b.sent();
|
|
166
|
+
_b.label = 4;
|
|
167
|
+
case 4:
|
|
168
|
+
pipelineTypes_1_1 = pipelineTypes_1.next();
|
|
169
|
+
return [3 /*break*/, 2];
|
|
170
|
+
case 5:
|
|
171
|
+
return [3 /*break*/, 8];
|
|
172
|
+
case 6:
|
|
173
|
+
e_1_1 = _b.sent();
|
|
174
|
+
e_1 = {
|
|
175
|
+
error: e_1_1
|
|
176
|
+
};
|
|
177
|
+
return [3 /*break*/, 8];
|
|
178
|
+
case 7:
|
|
179
|
+
try {
|
|
180
|
+
if (pipelineTypes_1_1 && !pipelineTypes_1_1.done && (_a = pipelineTypes_1.return)) _a.call(pipelineTypes_1);
|
|
181
|
+
} finally {
|
|
182
|
+
if (e_1) throw e_1.error;
|
|
183
|
+
}
|
|
184
|
+
return [7 /*endfinally*/];
|
|
185
|
+
case 8:
|
|
186
|
+
return [2 /*return*/];
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
exports.generatePipelineFiles = generatePipelineFiles;
|
|
192
|
+
function generatePipelineFilesForBackend(context, backend) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
194
|
+
var files;
|
|
129
195
|
var _this = this;
|
|
130
196
|
return __generator(this, function (_a) {
|
|
131
197
|
switch (_a.label) {
|
|
132
198
|
case 0:
|
|
133
|
-
backend = (0, backends_1.getPipelineBackend)(pipelineType);
|
|
134
199
|
return [4 /*yield*/, backend.createFiles(context.config)];
|
|
135
200
|
case 1:
|
|
136
201
|
files = _a.sent();
|
|
@@ -171,7 +236,6 @@ function generatePipelineFiles(context, pipelineType) {
|
|
|
171
236
|
});
|
|
172
237
|
});
|
|
173
238
|
}
|
|
174
|
-
exports.generatePipelineFiles = generatePipelineFiles;
|
|
175
239
|
/**
|
|
176
240
|
*
|
|
177
241
|
* for testing purposes
|