gitlab-radiator 3.4.0 → 3.4.1

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.
@@ -1,53 +1,169 @@
1
- import _ from 'lodash'
2
- import {fetchLatestPipelines} from './pipelines'
3
- import {fetchProjects} from './projects'
4
-
5
- export async function update(config) {
6
- const projectsWithPipelines = await loadProjectsWithPipelines(config)
7
- return projectsWithPipelines
8
- .filter(project => project.pipelines.length > 0)
9
- }
10
-
11
- async function loadProjectsWithPipelines(config) {
12
- const allProjectsWithPipelines = []
13
- await Promise.all(config.gitlabs.map(async (gitlab) => {
14
- const projects = await fetchProjects(gitlab)
15
- projects.forEach((project) => {
16
- project.maxNonFailedJobsVisible = gitlab.maxNonFailedJobsVisible
17
- })
18
- const projectsWithPipelines = await Promise.all(projects.map(project => projectWithPipelines(project, gitlab)))
19
- allProjectsWithPipelines.push(...projectsWithPipelines)
20
- }))
21
- return allProjectsWithPipelines
22
- }
23
-
24
- async function projectWithPipelines(project, config) {
25
- const pipelines = filterOutEmpty(await fetchLatestPipelines(project.id, config))
26
- .filter(excludePipelineStatusFilter(config))
27
- const status = defaultBranchStatus(project, pipelines)
28
- return {
29
- ...project,
30
- pipelines,
31
- status
32
- }
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.update = update;
9
+
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
+
16
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
17
+
18
+ var _lodash = _interopRequireDefault(require("lodash"));
19
+
20
+ var _pipelines = require("./pipelines");
21
+
22
+ var _projects = require("./projects");
23
+
24
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
+
26
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
+
28
+ function update(_x) {
29
+ return _update.apply(this, arguments);
30
+ }
31
+
32
+ function _update() {
33
+ _update = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(config) {
34
+ var projectsWithPipelines;
35
+ return _regenerator.default.wrap(function _callee$(_context) {
36
+ while (1) {
37
+ switch (_context.prev = _context.next) {
38
+ case 0:
39
+ _context.next = 2;
40
+ return loadProjectsWithPipelines(config);
41
+
42
+ case 2:
43
+ projectsWithPipelines = _context.sent;
44
+ return _context.abrupt("return", projectsWithPipelines.filter(project => project.pipelines.length > 0));
45
+
46
+ case 4:
47
+ case "end":
48
+ return _context.stop();
49
+ }
50
+ }
51
+ }, _callee);
52
+ }));
53
+ return _update.apply(this, arguments);
54
+ }
55
+
56
+ function loadProjectsWithPipelines(_x2) {
57
+ return _loadProjectsWithPipelines.apply(this, arguments);
58
+ }
59
+
60
+ function _loadProjectsWithPipelines() {
61
+ _loadProjectsWithPipelines = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(config) {
62
+ var allProjectsWithPipelines;
63
+ return _regenerator.default.wrap(function _callee3$(_context3) {
64
+ while (1) {
65
+ switch (_context3.prev = _context3.next) {
66
+ case 0:
67
+ allProjectsWithPipelines = [];
68
+ _context3.next = 3;
69
+ return Promise.all(config.gitlabs.map( /*#__PURE__*/function () {
70
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(gitlab) {
71
+ var projects, projectsWithPipelines;
72
+ return _regenerator.default.wrap(function _callee2$(_context2) {
73
+ while (1) {
74
+ switch (_context2.prev = _context2.next) {
75
+ case 0:
76
+ _context2.next = 2;
77
+ return (0, _projects.fetchProjects)(gitlab);
78
+
79
+ case 2:
80
+ projects = _context2.sent;
81
+ projects.forEach(project => {
82
+ project.maxNonFailedJobsVisible = gitlab.maxNonFailedJobsVisible;
83
+ });
84
+ _context2.next = 6;
85
+ return Promise.all(projects.map(project => projectWithPipelines(project, gitlab)));
86
+
87
+ case 6:
88
+ projectsWithPipelines = _context2.sent;
89
+ allProjectsWithPipelines.push.apply(allProjectsWithPipelines, (0, _toConsumableArray2.default)(projectsWithPipelines));
90
+
91
+ case 8:
92
+ case "end":
93
+ return _context2.stop();
94
+ }
95
+ }
96
+ }, _callee2);
97
+ }));
98
+
99
+ return function (_x5) {
100
+ return _ref.apply(this, arguments);
101
+ };
102
+ }()));
103
+
104
+ case 3:
105
+ return _context3.abrupt("return", allProjectsWithPipelines);
106
+
107
+ case 4:
108
+ case "end":
109
+ return _context3.stop();
110
+ }
111
+ }
112
+ }, _callee3);
113
+ }));
114
+ return _loadProjectsWithPipelines.apply(this, arguments);
115
+ }
116
+
117
+ function projectWithPipelines(_x3, _x4) {
118
+ return _projectWithPipelines.apply(this, arguments);
119
+ }
120
+
121
+ function _projectWithPipelines() {
122
+ _projectWithPipelines = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(project, config) {
123
+ var pipelines, status;
124
+ return _regenerator.default.wrap(function _callee4$(_context4) {
125
+ while (1) {
126
+ switch (_context4.prev = _context4.next) {
127
+ case 0:
128
+ _context4.t0 = filterOutEmpty;
129
+ _context4.next = 3;
130
+ return (0, _pipelines.fetchLatestPipelines)(project.id, config);
131
+
132
+ case 3:
133
+ _context4.t1 = _context4.sent;
134
+ pipelines = (0, _context4.t0)(_context4.t1).filter(excludePipelineStatusFilter(config));
135
+ status = defaultBranchStatus(project, pipelines);
136
+ return _context4.abrupt("return", _objectSpread(_objectSpread({}, project), {}, {
137
+ pipelines,
138
+ status
139
+ }));
140
+
141
+ case 7:
142
+ case "end":
143
+ return _context4.stop();
144
+ }
145
+ }
146
+ }, _callee4);
147
+ }));
148
+ return _projectWithPipelines.apply(this, arguments);
33
149
  }
34
150
 
35
151
  function defaultBranchStatus(project, pipelines) {
36
- return _(pipelines)
37
- .filter({ref: project.default_branch})
38
- .map('status')
39
- .head()
152
+ return (0, _lodash.default)(pipelines).filter({
153
+ ref: project.default_branch
154
+ }).map('status').head();
40
155
  }
41
156
 
42
157
  function filterOutEmpty(pipelines) {
43
- return pipelines.filter(pipeline => pipeline.stages)
158
+ return pipelines.filter(pipeline => pipeline.stages);
44
159
  }
45
160
 
46
161
  function excludePipelineStatusFilter(config) {
47
162
  return pipeline => {
48
163
  if (config.projects && config.projects.excludePipelineStatus) {
49
- return !config.projects.excludePipelineStatus.includes(pipeline.status)
164
+ return !config.projects.excludePipelineStatus.includes(pipeline.status);
50
165
  }
51
- return true
52
- }
53
- }
166
+
167
+ return true;
168
+ };
169
+ }