gitlab-radiator 3.3.6 → 3.3.10
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/README.md +1 -7
- package/package.json +34 -34
- package/public/client.js +1 -1
- package/src/app.js +6 -8
- package/src/auth.js +2 -4
- package/src/config.js +2 -2
- package/src/gitlab/index.js +8 -14
- package/src/gitlab/pipelines.js +19 -41
- package/src/gitlab/projects.js +6 -9
- package/src/gitlab/runners.js +5 -9
package/src/app.js
CHANGED
|
@@ -54,9 +54,9 @@ app.disable('x-powered-by');
|
|
|
54
54
|
app.use((0, _lessMiddleware.default)("".concat(__dirname, "/../public"), {
|
|
55
55
|
dest: cacheDir,
|
|
56
56
|
preprocess: {
|
|
57
|
-
less:
|
|
57
|
+
less: src => {
|
|
58
58
|
var colorLess = '';
|
|
59
|
-
Object.keys(_config.config.colors).forEach(
|
|
59
|
+
Object.keys(_config.config.colors).forEach(stateName => {
|
|
60
60
|
colorLess += "@".concat(stateName, "-color:").concat(_config.config.colors[stateName], ";");
|
|
61
61
|
});
|
|
62
62
|
return src + colorLess;
|
|
@@ -67,7 +67,7 @@ app.use(_express.default.static(cacheDir));
|
|
|
67
67
|
app.use(_express.default.static("".concat(__dirname, "/../public")));
|
|
68
68
|
app.use((0, _compression.default)());
|
|
69
69
|
app.use((0, _auth.basicAuth)(_config.config.auth));
|
|
70
|
-
httpServer.listen(_config.config.port,
|
|
70
|
+
httpServer.listen(_config.config.port, () => {
|
|
71
71
|
// eslint-disable-next-line no-console
|
|
72
72
|
console.log("Listening on port *:".concat(_config.config.port));
|
|
73
73
|
});
|
|
@@ -79,7 +79,7 @@ var globalState = {
|
|
|
79
79
|
columns: _config.config.columns,
|
|
80
80
|
groupSuccessfulProjects: _config.config.groupSuccessfulProjects
|
|
81
81
|
};
|
|
82
|
-
socketIoServer.on('connection',
|
|
82
|
+
socketIoServer.on('connection', socket => {
|
|
83
83
|
socket.emit('state', withDate(globalState));
|
|
84
84
|
});
|
|
85
85
|
|
|
@@ -146,7 +146,7 @@ function _errorIfRunnerOffline() {
|
|
|
146
146
|
|
|
147
147
|
case 2:
|
|
148
148
|
offlineRunnersPerGitlab = _context2.sent;
|
|
149
|
-
_offlineRunnersPerGit = offlineRunnersPerGitlab.reduce(
|
|
149
|
+
_offlineRunnersPerGit = offlineRunnersPerGitlab.reduce((acc, runner) => {
|
|
150
150
|
return {
|
|
151
151
|
offline: acc.offline.concat(runner.offline),
|
|
152
152
|
totalCount: acc.totalCount + runner.totalCount
|
|
@@ -161,9 +161,7 @@ function _errorIfRunnerOffline() {
|
|
|
161
161
|
break;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
names = offline.map(
|
|
165
|
-
return r.name;
|
|
166
|
-
}).sort().join(', ');
|
|
164
|
+
names = offline.map(r => r.name).sort().join(', ');
|
|
167
165
|
counts = offline.length === totalCount ? 'All' : "".concat(offline.length, "/").concat(totalCount);
|
|
168
166
|
return _context2.abrupt("return", "".concat(counts, " runners offline: ").concat(names));
|
|
169
167
|
|
package/src/auth.js
CHANGED
|
@@ -13,14 +13,12 @@ function basicAuth(auth) {
|
|
|
13
13
|
if (!auth || !auth.username || !auth.password) {
|
|
14
14
|
// eslint-disable-next-line no-console
|
|
15
15
|
console.log('No authentication configured');
|
|
16
|
-
return
|
|
17
|
-
return next();
|
|
18
|
-
};
|
|
16
|
+
return (req, res, next) => next();
|
|
19
17
|
} // eslint-disable-next-line no-console
|
|
20
18
|
|
|
21
19
|
|
|
22
20
|
console.log('HTTP basic auth enabled');
|
|
23
|
-
return
|
|
21
|
+
return (req, res, next) => {
|
|
24
22
|
var _ref = (0, _basicAuth.default)(req) || {},
|
|
25
23
|
name = _ref.name,
|
|
26
24
|
pass = _ref.pass;
|
package/src/config.js
CHANGED
|
@@ -27,7 +27,7 @@ config.zoom = Number(config.zoom || 1.0);
|
|
|
27
27
|
config.columns = Number(config.columns || 1);
|
|
28
28
|
config.groupSuccessfulProjects = config.groupSuccessfulProjects || false;
|
|
29
29
|
config.projectsOrder = config.projectsOrder || ['name'];
|
|
30
|
-
config.gitlabs = config.gitlabs.map(
|
|
30
|
+
config.gitlabs = config.gitlabs.map(gitlab => {
|
|
31
31
|
return {
|
|
32
32
|
url: gitlab.url,
|
|
33
33
|
ignoreArchived: gitlab.ignoreArchived === undefined ? true : gitlab.ignoreArchived,
|
|
@@ -50,7 +50,7 @@ function expandTilde(path) {
|
|
|
50
50
|
function validate(cfg) {
|
|
51
51
|
_assert.default.ok(cfg.gitlabs, 'Mandatory gitlab properties missing from configuration file');
|
|
52
52
|
|
|
53
|
-
cfg.gitlabs.forEach(
|
|
53
|
+
cfg.gitlabs.forEach(gitlab => {
|
|
54
54
|
_assert.default.ok(gitlab.url, 'Mandatory gitlab url missing from configuration file');
|
|
55
55
|
|
|
56
56
|
_assert.default.ok(gitlab['access-token'] || process.env.GITLAB_ACCESS_TOKEN, 'Mandatory gitlab access token missing from configuration (and none present at GITLAB_ACCESS_TOKEN env variable)');
|
package/src/gitlab/index.js
CHANGED
|
@@ -41,9 +41,7 @@ function _update() {
|
|
|
41
41
|
|
|
42
42
|
case 2:
|
|
43
43
|
projectsWithPipelines = _context.sent;
|
|
44
|
-
return _context.abrupt("return", projectsWithPipelines.filter(
|
|
45
|
-
return project.pipelines.length > 0;
|
|
46
|
-
}));
|
|
44
|
+
return _context.abrupt("return", projectsWithPipelines.filter(project => project.pipelines.length > 0));
|
|
47
45
|
|
|
48
46
|
case 4:
|
|
49
47
|
case "end":
|
|
@@ -80,13 +78,11 @@ function _loadProjectsWithPipelines() {
|
|
|
80
78
|
|
|
81
79
|
case 2:
|
|
82
80
|
projects = _context2.sent;
|
|
83
|
-
projects.forEach(
|
|
81
|
+
projects.forEach(project => {
|
|
84
82
|
project.maxNonFailedJobsVisible = gitlab.maxNonFailedJobsVisible;
|
|
85
83
|
});
|
|
86
84
|
_context2.next = 6;
|
|
87
|
-
return Promise.all(projects.map(
|
|
88
|
-
return projectWithPipelines(project, gitlab);
|
|
89
|
-
}));
|
|
85
|
+
return Promise.all(projects.map(project => projectWithPipelines(project, gitlab)));
|
|
90
86
|
|
|
91
87
|
case 6:
|
|
92
88
|
projectsWithPipelines = _context2.sent;
|
|
@@ -136,7 +132,7 @@ function _projectWithPipelines() {
|
|
|
136
132
|
case 3:
|
|
137
133
|
_context4.t1 = _context4.sent;
|
|
138
134
|
pipelines = (0, _context4.t0)(_context4.t1).filter(excludePipelineStatusFilter(config));
|
|
139
|
-
status =
|
|
135
|
+
status = defaultBranchStatus(project, pipelines);
|
|
140
136
|
return _context4.abrupt("return", _objectSpread(_objectSpread({}, project), {}, {
|
|
141
137
|
pipelines,
|
|
142
138
|
status
|
|
@@ -152,20 +148,18 @@ function _projectWithPipelines() {
|
|
|
152
148
|
return _projectWithPipelines.apply(this, arguments);
|
|
153
149
|
}
|
|
154
150
|
|
|
155
|
-
function
|
|
151
|
+
function defaultBranchStatus(project, pipelines) {
|
|
156
152
|
return (0, _lodash.default)(pipelines).filter({
|
|
157
|
-
ref:
|
|
153
|
+
ref: project.default_branch
|
|
158
154
|
}).map('status').head();
|
|
159
155
|
}
|
|
160
156
|
|
|
161
157
|
function filterOutEmpty(pipelines) {
|
|
162
|
-
return pipelines.filter(
|
|
163
|
-
return pipeline.stages;
|
|
164
|
-
});
|
|
158
|
+
return pipelines.filter(pipeline => pipeline.stages);
|
|
165
159
|
}
|
|
166
160
|
|
|
167
161
|
function excludePipelineStatusFilter(config) {
|
|
168
|
-
return
|
|
162
|
+
return pipeline => {
|
|
169
163
|
if (config.projects && config.projects.excludePipelineStatus) {
|
|
170
164
|
return !config.projects.excludePipelineStatus.includes(pipeline.status);
|
|
171
165
|
}
|
package/src/gitlab/pipelines.js
CHANGED
|
@@ -44,7 +44,7 @@ function _fetchLatestPipelines() {
|
|
|
44
44
|
|
|
45
45
|
case 5:
|
|
46
46
|
jobsForPipelines = _context.sent;
|
|
47
|
-
return _context.abrupt("return", pipelines.map(
|
|
47
|
+
return _context.abrupt("return", pipelines.map(_ref3 => {
|
|
48
48
|
var id = _ref3.id,
|
|
49
49
|
ref = _ref3.ref,
|
|
50
50
|
status = _ref3.status;
|
|
@@ -146,9 +146,7 @@ function _fetchNonSkippedPipelines() {
|
|
|
146
146
|
case 2:
|
|
147
147
|
_yield$gitlabRequest = _context3.sent;
|
|
148
148
|
pipelines = _yield$gitlabRequest.data;
|
|
149
|
-
return _context3.abrupt("return", pipelines.filter(
|
|
150
|
-
return pipeline.status !== 'skipped';
|
|
151
|
-
}));
|
|
149
|
+
return _context3.abrupt("return", pipelines.filter(pipeline => pipeline.status !== 'skipped'));
|
|
152
150
|
|
|
153
151
|
case 5:
|
|
154
152
|
case "end":
|
|
@@ -172,12 +170,8 @@ function _fetchJobsForPipelines() {
|
|
|
172
170
|
while (1) {
|
|
173
171
|
switch (_context4.prev = _context4.next) {
|
|
174
172
|
case 0:
|
|
175
|
-
includedPipelineIds = pipelines.map(
|
|
176
|
-
|
|
177
|
-
});
|
|
178
|
-
_pipelines$map$sort = pipelines.map(function (pipeline) {
|
|
179
|
-
return pipeline.created_at;
|
|
180
|
-
}).sort(), _pipelines$map$sort2 = (0, _slicedToArray2.default)(_pipelines$map$sort, 1), oldestCreatedAt = _pipelines$map$sort2[0];
|
|
173
|
+
includedPipelineIds = pipelines.map(pipeline => pipeline.id);
|
|
174
|
+
_pipelines$map$sort = pipelines.map(pipeline => pipeline.created_at).sort(), _pipelines$map$sort2 = (0, _slicedToArray2.default)(_pipelines$map$sort, 1), oldestCreatedAt = _pipelines$map$sort2[0];
|
|
181
175
|
jobs = [];
|
|
182
176
|
SAFETY_MAX_PAGE = 10;
|
|
183
177
|
page = 1;
|
|
@@ -197,11 +191,7 @@ function _fetchJobsForPipelines() {
|
|
|
197
191
|
case 8:
|
|
198
192
|
_yield$gitlabRequest2 = _context4.sent;
|
|
199
193
|
jobsBatch = _yield$gitlabRequest2.data;
|
|
200
|
-
jobs.push(jobsBatch.filter(
|
|
201
|
-
return includedPipelineIds.includes(job.pipeline.id);
|
|
202
|
-
}).filter(function (job) {
|
|
203
|
-
return job.created_at >= oldestCreatedAt;
|
|
204
|
-
}));
|
|
194
|
+
jobs.push(jobsBatch.filter(job => includedPipelineIds.includes(job.pipeline.id)).filter(job => job.created_at >= oldestCreatedAt));
|
|
205
195
|
|
|
206
196
|
if (!(jobsBatch.length === 0 || jobsBatch[jobsBatch.length - 1].created_at < oldestCreatedAt)) {
|
|
207
197
|
_context4.next = 13;
|
|
@@ -229,26 +219,22 @@ function _fetchJobsForPipelines() {
|
|
|
229
219
|
}
|
|
230
220
|
|
|
231
221
|
function matchJobs(pipelineId, gitlabJobsForMultiplePipelines) {
|
|
232
|
-
var gitlabJobs = gitlabJobsForMultiplePipelines.filter(
|
|
233
|
-
return job.pipeline.id === pipelineId;
|
|
234
|
-
});
|
|
222
|
+
var gitlabJobs = gitlabJobsForMultiplePipelines.filter(job => job.pipeline.id === pipelineId);
|
|
235
223
|
|
|
236
224
|
if (gitlabJobs.length === 0) {
|
|
237
225
|
return {};
|
|
238
226
|
}
|
|
239
227
|
|
|
240
228
|
var commit = findCommit(gitlabJobs);
|
|
241
|
-
var stages = (0, _lodash.default)(gitlabJobs).map(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
};
|
|
251
|
-
}).orderBy('id').groupBy('stage').mapValues(mergeRetriedJobs).mapValues(cleanup).toPairs().map(function (_ref) {
|
|
229
|
+
var stages = (0, _lodash.default)(gitlabJobs).map(job => ({
|
|
230
|
+
id: job.id,
|
|
231
|
+
status: job.status,
|
|
232
|
+
stage: job.stage,
|
|
233
|
+
name: job.name,
|
|
234
|
+
startedAt: job.started_at,
|
|
235
|
+
finishedAt: job.finished_at,
|
|
236
|
+
url: job.web_url
|
|
237
|
+
})).orderBy('id').groupBy('stage').mapValues(mergeRetriedJobs).mapValues(cleanup).toPairs().map(_ref => {
|
|
252
238
|
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
253
239
|
name = _ref2[0],
|
|
254
240
|
jobs = _ref2[1];
|
|
@@ -265,9 +251,7 @@ function matchJobs(pipelineId, gitlabJobsForMultiplePipelines) {
|
|
|
265
251
|
}
|
|
266
252
|
|
|
267
253
|
function findCommit(jobs) {
|
|
268
|
-
var _jobs$filter = jobs.filter(
|
|
269
|
-
return j.commit;
|
|
270
|
-
}),
|
|
254
|
+
var _jobs$filter = jobs.filter(j => j.commit),
|
|
271
255
|
_jobs$filter2 = (0, _slicedToArray2.default)(_jobs$filter, 1),
|
|
272
256
|
job = _jobs$filter2[0];
|
|
273
257
|
|
|
@@ -282,10 +266,8 @@ function findCommit(jobs) {
|
|
|
282
266
|
}
|
|
283
267
|
|
|
284
268
|
function mergeRetriedJobs(jobs) {
|
|
285
|
-
return jobs.reduce(
|
|
286
|
-
var index = mergedJobs.findIndex(
|
|
287
|
-
return mergedJob.name === job.name;
|
|
288
|
-
});
|
|
269
|
+
return jobs.reduce((mergedJobs, job) => {
|
|
270
|
+
var index = mergedJobs.findIndex(mergedJob => mergedJob.name === job.name);
|
|
289
271
|
|
|
290
272
|
if (index >= 0) {
|
|
291
273
|
mergedJobs[index] = job;
|
|
@@ -298,9 +280,5 @@ function mergeRetriedJobs(jobs) {
|
|
|
298
280
|
}
|
|
299
281
|
|
|
300
282
|
function cleanup(jobs) {
|
|
301
|
-
return (0, _lodash.default)(jobs).map(
|
|
302
|
-
return _lodash.default.omitBy(job, _lodash.default.isNull);
|
|
303
|
-
}).map(function (job) {
|
|
304
|
-
return _lodash.default.omit(job, 'stage');
|
|
305
|
-
}).value();
|
|
283
|
+
return (0, _lodash.default)(jobs).map(job => _lodash.default.omitBy(job, _lodash.default.isNull)).map(job => _lodash.default.omit(job, 'stage')).value();
|
|
306
284
|
}
|
package/src/gitlab/projects.js
CHANGED
|
@@ -30,9 +30,7 @@ function _fetchProjects() {
|
|
|
30
30
|
case 2:
|
|
31
31
|
projects = _context.sent;
|
|
32
32
|
return _context.abrupt("return", projects // Ignore projects for which CI/CD is not enabled
|
|
33
|
-
.filter(
|
|
34
|
-
return project.jobs_enabled;
|
|
35
|
-
}).map(projectMapper).filter(includeRegexFilter(gitlab)).filter(excludeRegexFilter(gitlab)).filter(archivedFilter(gitlab)));
|
|
33
|
+
.filter(project => project.jobs_enabled).map(projectMapper).filter(includeRegexFilter(gitlab)).filter(excludeRegexFilter(gitlab)).filter(archivedFilter(gitlab)));
|
|
36
34
|
|
|
37
35
|
case 4:
|
|
38
36
|
case "end":
|
|
@@ -111,10 +109,9 @@ function projectMapper(project) {
|
|
|
111
109
|
nameWithoutNamespace: project.path,
|
|
112
110
|
group: getGroupName(project),
|
|
113
111
|
archived: project.archived,
|
|
112
|
+
default_branch: project.default_branch || 'master',
|
|
114
113
|
url: project.web_url,
|
|
115
|
-
tags: (project.tag_list || []).map(
|
|
116
|
-
return t.toLowerCase();
|
|
117
|
-
})
|
|
114
|
+
tags: (project.tag_list || []).map(t => t.toLowerCase())
|
|
118
115
|
};
|
|
119
116
|
}
|
|
120
117
|
|
|
@@ -124,7 +121,7 @@ function getGroupName(project) {
|
|
|
124
121
|
}
|
|
125
122
|
|
|
126
123
|
function includeRegexFilter(config) {
|
|
127
|
-
return
|
|
124
|
+
return project => {
|
|
128
125
|
if (config.projects && config.projects.include) {
|
|
129
126
|
var includeRegex = new RegExp(config.projects.include, "i");
|
|
130
127
|
return includeRegex.test(project.name);
|
|
@@ -135,7 +132,7 @@ function includeRegexFilter(config) {
|
|
|
135
132
|
}
|
|
136
133
|
|
|
137
134
|
function excludeRegexFilter(config) {
|
|
138
|
-
return
|
|
135
|
+
return project => {
|
|
139
136
|
if (config.projects && config.projects.exclude) {
|
|
140
137
|
var excludeRegex = new RegExp(config.projects.exclude, "i");
|
|
141
138
|
return !excludeRegex.test(project.name);
|
|
@@ -146,7 +143,7 @@ function excludeRegexFilter(config) {
|
|
|
146
143
|
}
|
|
147
144
|
|
|
148
145
|
function archivedFilter(config) {
|
|
149
|
-
return
|
|
146
|
+
return project => {
|
|
150
147
|
if (config.ignoreArchived) {
|
|
151
148
|
return !project.archived;
|
|
152
149
|
}
|
package/src/gitlab/runners.js
CHANGED
|
@@ -29,9 +29,7 @@ function _fetchOfflineRunners() {
|
|
|
29
29
|
|
|
30
30
|
case 2:
|
|
31
31
|
runners = _context.sent;
|
|
32
|
-
offline = runners.filter(
|
|
33
|
-
return r.status === 'offline';
|
|
34
|
-
});
|
|
32
|
+
offline = runners.filter(r => r.status === 'offline');
|
|
35
33
|
return _context.abrupt("return", {
|
|
36
34
|
offline,
|
|
37
35
|
totalCount: runners.length
|
|
@@ -65,12 +63,10 @@ function _fetchRunners() {
|
|
|
65
63
|
case 2:
|
|
66
64
|
_yield$gitlabRequest = _context2.sent;
|
|
67
65
|
runners = _yield$gitlabRequest.data;
|
|
68
|
-
return _context2.abrupt("return", runners.map(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
73
|
-
}));
|
|
66
|
+
return _context2.abrupt("return", runners.map(r => ({
|
|
67
|
+
name: r.description || r.id,
|
|
68
|
+
status: r.status
|
|
69
|
+
})));
|
|
74
70
|
|
|
75
71
|
case 5:
|
|
76
72
|
case "end":
|