@clickview/ship-it 0.0.33 → 0.0.35-dev.0

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 (108) hide show
  1. package/Dockerfile +33 -33
  2. package/README.md +48 -48
  3. package/config.json +19 -19
  4. package/lib/config.json +20 -20
  5. package/lib/src/api-clients/git-lab/GitLabApiClient.js +439 -439
  6. package/lib/src/api-clients/git-lab/GitLabMapper.js +82 -82
  7. package/lib/src/api-clients/index.js +20 -20
  8. package/lib/src/api-clients/slack/SlackApiClient.js +206 -206
  9. package/lib/src/api-clients/team-city/TeamCityApiClient.js +100 -100
  10. package/lib/src/api-clients/trello/TrelloApiClient.js +145 -145
  11. package/lib/src/commands/BumpPackagesCommand.js +84 -84
  12. package/lib/src/commands/CreateBranchCommand.js +100 -100
  13. package/lib/src/commands/CreateMergeRequestCommand.js +107 -107
  14. package/lib/src/commands/CreateNotesAuditCommand.js +84 -84
  15. package/lib/src/commands/CreateReleaseNotesCommand.js +95 -95
  16. package/lib/src/commands/CreateTrelloCardsCommand.js +77 -77
  17. package/lib/src/commands/InstallPackagesCommand.js +76 -76
  18. package/lib/src/commands/ListProjectsCommand.js +76 -76
  19. package/lib/src/commands/ReleaseCommand.js +129 -129
  20. package/lib/src/commands/StartProjectBuildsCommand.js +76 -76
  21. package/lib/src/commands/StatusCommand.js +88 -88
  22. package/lib/src/commands/TagMasterCommand.js +76 -76
  23. package/lib/src/commands/ValidateMergeRequestCommand.js +76 -76
  24. package/lib/src/commands/VersionCommand.js +76 -76
  25. package/lib/src/commands/index.js +30 -30
  26. package/lib/src/constants/CommandTypeMapping.js +20 -20
  27. package/lib/src/constants/GitLabMemberIds.js +6 -6
  28. package/lib/src/constants/MonorepoPackageJsonFiles.js +17 -17
  29. package/lib/src/constants/MonorepoProjectNames.js +16 -16
  30. package/lib/src/constants/ProjectNames.js +68 -68
  31. package/lib/src/constants/SlackUserEmailList.js +13 -13
  32. package/lib/src/constants/TeamCityBuildIDs.js +45 -45
  33. package/lib/src/constants/index.js +19 -19
  34. package/lib/src/errors/ShipItError.js +32 -32
  35. package/lib/src/errors/index.js +17 -17
  36. package/lib/src/index.js +18 -18
  37. package/lib/src/interfaces/Config.js +2 -2
  38. package/lib/src/interfaces/MergeRequestState.js +2 -2
  39. package/lib/src/interfaces/ProjectNames.js +2 -2
  40. package/lib/src/interfaces/ShipItCommand.js +2 -2
  41. package/lib/src/interfaces/ShipItTask.js +2 -2
  42. package/lib/src/interfaces/VersionType.js +2 -2
  43. package/lib/src/interfaces/command-cli-options/MilestoneCommandCliOptions.js +2 -2
  44. package/lib/src/interfaces/command-cli-options/ReleaseCommandCliOptions.js +2 -2
  45. package/lib/src/interfaces/command-cli-options/StatusCommandCliOptions.js +2 -2
  46. package/lib/src/interfaces/command-cli-options/index.js +19 -19
  47. package/lib/src/interfaces/command-options/BaseCommandOptions.js +2 -2
  48. package/lib/src/interfaces/command-options/BumpPackagesCommandOptions.js +2 -2
  49. package/lib/src/interfaces/command-options/DockerMilestoneCommandOptions.js +2 -2
  50. package/lib/src/interfaces/command-options/MilestoneCommandOptions.js +2 -2
  51. package/lib/src/interfaces/command-options/ReleaseCommandOptions.js +2 -2
  52. package/lib/src/interfaces/command-options/StatusCommandOptions.js +2 -2
  53. package/lib/src/interfaces/command-options/ValidateMRCommandOptions.js +2 -2
  54. package/lib/src/interfaces/command-options/index.js +22 -22
  55. package/lib/src/interfaces/index.js +26 -26
  56. package/lib/src/interfaces/models/Branch.js +2 -2
  57. package/lib/src/interfaces/models/Commit.js +2 -2
  58. package/lib/src/interfaces/models/CommitFile.js +2 -2
  59. package/lib/src/interfaces/models/File.js +2 -2
  60. package/lib/src/interfaces/models/Label.js +2 -2
  61. package/lib/src/interfaces/models/MergeRequest.js +2 -2
  62. package/lib/src/interfaces/models/Milestone.js +2 -2
  63. package/lib/src/interfaces/models/Project.js +2 -2
  64. package/lib/src/interfaces/models/ProjectConfig.js +9 -9
  65. package/lib/src/interfaces/models/Release.js +2 -2
  66. package/lib/src/interfaces/models/Tag.js +2 -2
  67. package/lib/src/interfaces/models/index.js +26 -26
  68. package/lib/src/interfaces/view-models/MilestoneProject.js +2 -2
  69. package/lib/src/interfaces/view-models/index.js +17 -17
  70. package/lib/src/inversify.config.js +75 -75
  71. package/lib/src/services/GitLabService.js +510 -508
  72. package/lib/src/services/SlackService.js +142 -142
  73. package/lib/src/services/TeamCityService.js +37 -37
  74. package/lib/src/services/TrelloService.js +84 -84
  75. package/lib/src/services/index.js +20 -20
  76. package/lib/src/startup/AddMilestoneCommand.js +96 -96
  77. package/lib/src/startup/GetAction.js +68 -68
  78. package/lib/src/startup/SetupCommands.js +168 -168
  79. package/lib/src/tasks/BumpPackagesTask.js +229 -229
  80. package/lib/src/tasks/BumpVersionTxtTask.js +110 -110
  81. package/lib/src/tasks/CommitPackageVersionsTask.js +116 -116
  82. package/lib/src/tasks/CreateBranchTask.js +104 -104
  83. package/lib/src/tasks/CreateMergeRequestTask.js +118 -118
  84. package/lib/src/tasks/CreateNotesAuditTask.js +140 -140
  85. package/lib/src/tasks/CreateReleaseNotesTask.js +144 -144
  86. package/lib/src/tasks/InstallPackagesTask.js +407 -407
  87. package/lib/src/tasks/ListProjectsTask.js +87 -87
  88. package/lib/src/tasks/PopulateTrelloBoardTask.js +140 -140
  89. package/lib/src/tasks/StartMonorepoBuildTask.js +109 -109
  90. package/lib/src/tasks/StartProjectBuildsTask.js +170 -170
  91. package/lib/src/tasks/TagMasterTask.js +186 -186
  92. package/lib/src/tasks/ValidateCommitsTask.js +143 -143
  93. package/lib/src/tasks/ValidateDescriptionsTask.js +178 -178
  94. package/lib/src/tasks/ValidateMergeRequestTask.js +115 -115
  95. package/lib/src/tasks/ValidateTask.js +419 -419
  96. package/lib/src/tasks/VersionTask.js +98 -98
  97. package/lib/src/tasks/index.js +34 -34
  98. package/lib/src/types.js +57 -57
  99. package/lib/src/utils/BranchNames.js +11 -11
  100. package/lib/src/utils/Commits.js +55 -55
  101. package/lib/src/utils/Csv.js +54 -54
  102. package/lib/src/utils/Descriptions.js +274 -274
  103. package/lib/src/utils/GroupIds.js +6 -6
  104. package/lib/src/utils/Logger.js +62 -62
  105. package/lib/src/utils/ProjectIds.js +47 -47
  106. package/lib/src/utils/Versions.js +20 -20
  107. package/lib/src/utils/index.js +22 -22
  108. package/package.json +50 -50
@@ -1,274 +1,274 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Descriptions = void 0;
4
- var Headings = {
5
- BeforeRelease: 'Before release',
6
- Dependencies: 'Dependencies',
7
- CodeChanges: 'Code changes',
8
- CustomerChanges: 'Customer changes',
9
- Testing: 'Testing',
10
- Notes: 'Notes'
11
- };
12
- var BASE_VALID_HEADINGS = [
13
- Headings.BeforeRelease,
14
- Headings.Dependencies,
15
- Headings.Testing,
16
- Headings.Notes
17
- ];
18
- var PROJECT_VALID_HEADINGS = BASE_VALID_HEADINGS.concat([
19
- Headings.CustomerChanges,
20
- Headings.CodeChanges
21
- ]);
22
- var PROJECT_REQUIRED_HEADINGS = [
23
- Headings.Testing
24
- ];
25
- var HEADING_ORDER = [
26
- Headings.BeforeRelease,
27
- Headings.Dependencies,
28
- Headings.CustomerChanges,
29
- Headings.CodeChanges,
30
- '*',
31
- Headings.Testing,
32
- Headings.Notes,
33
- ];
34
- function headingTransformer(heading) {
35
- // Fix casing of known headings
36
- var lowerHeading = heading.toLowerCase();
37
- for (var i = 0; i < PROJECT_VALID_HEADINGS.length; i++) {
38
- if (PROJECT_VALID_HEADINGS[i].toLowerCase() === lowerHeading)
39
- return PROJECT_VALID_HEADINGS[i];
40
- }
41
- // No transform
42
- return heading;
43
- }
44
- function toObject(lines, headingPrefix) {
45
- var obj = {};
46
- var currentHeading = 'other';
47
- for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
48
- var line = lines_1[_i];
49
- // Skip empty lines
50
- if (!line.trim() || line === '/n')
51
- continue;
52
- if (line.startsWith(headingPrefix + ' ')) {
53
- // TODO: Potentially add heading transforms to capture multiple variants
54
- currentHeading = headingTransformer(line.replace(headingPrefix, '').trim());
55
- continue;
56
- }
57
- if (!obj[currentHeading])
58
- obj[currentHeading] = '';
59
- /**
60
- * Our images need an extra line return so they don't get squished against our dot points
61
- */
62
- if (line.startsWith('!'))
63
- obj[currentHeading] += '\n';
64
- /**
65
- * Skip the line if the dev is opting out by adding n/a
66
- */
67
- if (line.toLowerCase().trim() !== 'n/a')
68
- obj[currentHeading] += line + '\n';
69
- }
70
- return obj;
71
- }
72
- /**
73
- * I can't read this code but it came from here and it works: https://stackoverflow.com/a/63457487/14258157
74
- * - Josh
75
- */
76
- function orderDescriptionHeadings(headings) {
77
- // Get the index of our wildcard where we put all the other headings into
78
- var starIndex = HEADING_ORDER.indexOf('*');
79
- if (starIndex === -1)
80
- starIndex = HEADING_ORDER.length;
81
- return headings.sort(function (a, b) {
82
- var aIndex = HEADING_ORDER.indexOf(a);
83
- var bIndex = HEADING_ORDER.indexOf(b);
84
- // Do normal sort logic if both are missing from heading order
85
- if (aIndex === -1 && bIndex === -1) {
86
- if (a < b)
87
- return -1;
88
- if (a > b)
89
- return 1;
90
- return 0;
91
- }
92
- if (aIndex === -1)
93
- aIndex = starIndex;
94
- if (bIndex === -1)
95
- bIndex = starIndex;
96
- return aIndex - bIndex;
97
- });
98
- }
99
- exports.Descriptions = {
100
- validate: function (description, projectConfig) {
101
- var validHeadings;
102
- // If we are a monorepo, add in the valid sub project headings
103
- if (projectConfig.monorepo.enabled) {
104
- var subProjects = projectConfig.monorepo.validSubProjects;
105
- validHeadings = BASE_VALID_HEADINGS.concat(subProjects);
106
- }
107
- else {
108
- validHeadings = PROJECT_VALID_HEADINGS;
109
- }
110
- // Parse description
111
- var obj = toObject(description.split('\n'), '#');
112
- var errors = this.validateProject(obj, {
113
- validSections: validHeadings,
114
- requiredSections: PROJECT_REQUIRED_HEADINGS
115
- });
116
- if (!projectConfig.monorepo.enabled)
117
- return errors;
118
- var _loop_1 = function (subProject) {
119
- // Ignore known headings
120
- if (PROJECT_VALID_HEADINGS.indexOf(subProject) !== -1)
121
- return "continue";
122
- var subObj = toObject(obj[subProject].split('\n'), '##');
123
- var subErrors = this_1.validateProject(subObj, {
124
- validSections: PROJECT_VALID_HEADINGS,
125
- requiredSections: []
126
- });
127
- errors = errors.concat(subErrors.map(function (x) { return "[".concat(subProject, "] ") + x; }));
128
- };
129
- var this_1 = this;
130
- // If monorepo we need to check the sub projects are valid
131
- for (var subProject in obj) {
132
- _loop_1(subProject);
133
- }
134
- return errors;
135
- },
136
- validateProject: function (parsedDescription, options) {
137
- // Parse description
138
- var headings = Object.keys(parsedDescription);
139
- // Must have at least one heading
140
- if (headings.length < 1)
141
- return ['Must have at least one section'];
142
- var errors = [];
143
- // Ensure all the headings are valid
144
- for (var _i = 0, headings_1 = headings; _i < headings_1.length; _i++) {
145
- var heading = headings_1[_i];
146
- if (options.validSections.indexOf(heading) === -1)
147
- errors.push("Invalid section: ".concat(heading));
148
- }
149
- // Ensure we have all required headings
150
- for (var _a = 0, _b = options.requiredSections; _a < _b.length; _a++) {
151
- var requiredSection = _b[_a];
152
- if (parsedDescription[requiredSection] === undefined)
153
- errors.push("Missing section: ".concat(requiredSection));
154
- }
155
- return errors;
156
- },
157
- getCombinedDescription: function (mergeRequests, headingPrefix) {
158
- if (headingPrefix === void 0) { headingPrefix = '#'; }
159
- var descriptionObjs = mergeRequests
160
- .filter(function (mr) { return mr.status === 'merged'; })
161
- .map(function (mr) { return toObject(mr.description.split('\n'), headingPrefix); });
162
- var obj = {};
163
- var _loop_2 = function (descriptionObj) {
164
- Object.keys(descriptionObj).forEach(function (key) {
165
- if (!obj[key])
166
- obj[key] = '';
167
- obj[key] += descriptionObj[key] + '\n';
168
- });
169
- };
170
- for (var _i = 0, descriptionObjs_1 = descriptionObjs; _i < descriptionObjs_1.length; _i++) {
171
- var descriptionObj = descriptionObjs_1[_i];
172
- _loop_2(descriptionObj);
173
- }
174
- var description = '';
175
- var orderedHeadings = orderDescriptionHeadings(Object.keys(obj));
176
- orderedHeadings.forEach(function (key) {
177
- if (key === Headings.Notes)
178
- return;
179
- if (!obj[key])
180
- return;
181
- description += '\n' + headingPrefix + ' ' + key + '\n';
182
- description += obj[key];
183
- });
184
- return description;
185
- },
186
- getDescriptionSection: function (heading, mergeRequest) {
187
- var descriptionObj = toObject(mergeRequest.description.split('\n'), '#');
188
- var obj = {};
189
- Object.keys(descriptionObj).forEach(function (key) {
190
- if (!obj[key])
191
- obj[key] = '';
192
- obj[key] += descriptionObj[key] + '\n';
193
- });
194
- return obj[Headings[heading]];
195
- },
196
- // TODO: This isn't readable, it needs to be refactored
197
- getMonorepoCombinedDescription: function (mergeRequests) {
198
- // Get an object where H1s are properties
199
- var descriptionObjs = mergeRequests
200
- .filter(function (mr) { return mr.status === 'merged'; })
201
- .map(function (mr) { return toObject(mr.description.split('\n'), '#'); });
202
- var combinedObj = {};
203
- var _loop_3 = function (descriptionObj) {
204
- Object.keys(descriptionObj).forEach(function (key) {
205
- if (!combinedObj[key])
206
- combinedObj[key] = {};
207
- var combinedSubObj = toObject(descriptionObj[key].split('\n'), '##');
208
- var orderedHeadings = orderDescriptionHeadings(Object.keys(combinedSubObj));
209
- orderedHeadings.forEach(function (subKey) {
210
- if (!combinedObj[key][subKey])
211
- combinedObj[key][subKey] = '';
212
- combinedObj[key][subKey] += combinedSubObj[subKey];
213
- });
214
- });
215
- };
216
- // For each property in each MR object, calculate it's H2 heading objects
217
- for (var _i = 0, descriptionObjs_2 = descriptionObjs; _i < descriptionObjs_2.length; _i++) {
218
- var descriptionObj = descriptionObjs_2[_i];
219
- _loop_3(descriptionObj);
220
- }
221
- var orderedHeadings = orderDescriptionHeadings(Object.keys(combinedObj));
222
- // Build our description
223
- var description = '';
224
- orderedHeadings.forEach(function (key) {
225
- if (key === Headings.Notes)
226
- return;
227
- description += '\n# ' + key + '\n';
228
- Object.keys(combinedObj[key]).forEach(function (subKey) {
229
- if (key !== Headings.Dependencies && key !== Headings.Testing)
230
- description += '\n## ' + subKey + '\n';
231
- description += combinedObj[key][subKey];
232
- });
233
- });
234
- return description;
235
- },
236
- getMonorepoDescriptionSection: function (subHeading, mergeRequest) {
237
- var descriptionObj = toObject(mergeRequest.description.split('\n'), '#');
238
- var obj = {};
239
- Object.keys(descriptionObj).forEach(function (key) {
240
- if (!obj[key])
241
- obj[key] = {};
242
- var combinedSubObj = toObject(descriptionObj[key].split('\n'), '##');
243
- Object.keys(combinedSubObj).forEach(function (subKey) {
244
- if (!obj[key][subKey])
245
- obj[key][subKey] = '';
246
- obj[key][subKey] += combinedSubObj[subKey];
247
- });
248
- });
249
- // Build our description
250
- var description = '';
251
- Object.keys(obj).forEach(function (key) {
252
- if (key === Headings.Notes)
253
- return;
254
- Object.keys(obj[key]).forEach(function (subKey) {
255
- if (subKey !== Headings[subHeading])
256
- return;
257
- description += '\n# ' + key + '\n';
258
- description += obj[key][subKey];
259
- });
260
- });
261
- return description;
262
- },
263
- bumpHeadings: function (description) {
264
- var lines = description.split('\n');
265
- var bumpedDescription = '';
266
- lines.forEach(function (line) {
267
- if (line.startsWith('#'))
268
- bumpedDescription += '#' + line + '\n';
269
- else
270
- bumpedDescription += line + '\n';
271
- });
272
- return bumpedDescription;
273
- }
274
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Descriptions = void 0;
4
+ var Headings = {
5
+ BeforeRelease: 'Before release',
6
+ Dependencies: 'Dependencies',
7
+ CodeChanges: 'Code changes',
8
+ CustomerChanges: 'Customer changes',
9
+ Testing: 'Testing',
10
+ Notes: 'Notes'
11
+ };
12
+ var BASE_VALID_HEADINGS = [
13
+ Headings.BeforeRelease,
14
+ Headings.Dependencies,
15
+ Headings.Testing,
16
+ Headings.Notes
17
+ ];
18
+ var PROJECT_VALID_HEADINGS = BASE_VALID_HEADINGS.concat([
19
+ Headings.CustomerChanges,
20
+ Headings.CodeChanges
21
+ ]);
22
+ var PROJECT_REQUIRED_HEADINGS = [
23
+ Headings.Testing
24
+ ];
25
+ var HEADING_ORDER = [
26
+ Headings.BeforeRelease,
27
+ Headings.Dependencies,
28
+ Headings.CustomerChanges,
29
+ Headings.CodeChanges,
30
+ '*',
31
+ Headings.Testing,
32
+ Headings.Notes,
33
+ ];
34
+ function headingTransformer(heading) {
35
+ // Fix casing of known headings
36
+ var lowerHeading = heading.toLowerCase();
37
+ for (var i = 0; i < PROJECT_VALID_HEADINGS.length; i++) {
38
+ if (PROJECT_VALID_HEADINGS[i].toLowerCase() === lowerHeading)
39
+ return PROJECT_VALID_HEADINGS[i];
40
+ }
41
+ // No transform
42
+ return heading;
43
+ }
44
+ function toObject(lines, headingPrefix) {
45
+ var obj = {};
46
+ var currentHeading = 'other';
47
+ for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
48
+ var line = lines_1[_i];
49
+ // Skip empty lines
50
+ if (!line.trim() || line === '/n')
51
+ continue;
52
+ if (line.startsWith(headingPrefix + ' ')) {
53
+ // TODO: Potentially add heading transforms to capture multiple variants
54
+ currentHeading = headingTransformer(line.replace(headingPrefix, '').trim());
55
+ continue;
56
+ }
57
+ if (!obj[currentHeading])
58
+ obj[currentHeading] = '';
59
+ /**
60
+ * Our images need an extra line return so they don't get squished against our dot points
61
+ */
62
+ if (line.startsWith('!'))
63
+ obj[currentHeading] += '\n';
64
+ /**
65
+ * Skip the line if the dev is opting out by adding n/a
66
+ */
67
+ if (line.toLowerCase().trim() !== 'n/a')
68
+ obj[currentHeading] += line + '\n';
69
+ }
70
+ return obj;
71
+ }
72
+ /**
73
+ * I can't read this code but it came from here and it works: https://stackoverflow.com/a/63457487/14258157
74
+ * - Josh
75
+ */
76
+ function orderDescriptionHeadings(headings) {
77
+ // Get the index of our wildcard where we put all the other headings into
78
+ var starIndex = HEADING_ORDER.indexOf('*');
79
+ if (starIndex === -1)
80
+ starIndex = HEADING_ORDER.length;
81
+ return headings.sort(function (a, b) {
82
+ var aIndex = HEADING_ORDER.indexOf(a);
83
+ var bIndex = HEADING_ORDER.indexOf(b);
84
+ // Do normal sort logic if both are missing from heading order
85
+ if (aIndex === -1 && bIndex === -1) {
86
+ if (a < b)
87
+ return -1;
88
+ if (a > b)
89
+ return 1;
90
+ return 0;
91
+ }
92
+ if (aIndex === -1)
93
+ aIndex = starIndex;
94
+ if (bIndex === -1)
95
+ bIndex = starIndex;
96
+ return aIndex - bIndex;
97
+ });
98
+ }
99
+ exports.Descriptions = {
100
+ validate: function (description, projectConfig) {
101
+ var validHeadings;
102
+ // If we are a monorepo, add in the valid sub project headings
103
+ if (projectConfig.monorepo.enabled) {
104
+ var subProjects = projectConfig.monorepo.validSubProjects;
105
+ validHeadings = BASE_VALID_HEADINGS.concat(subProjects);
106
+ }
107
+ else {
108
+ validHeadings = PROJECT_VALID_HEADINGS;
109
+ }
110
+ // Parse description
111
+ var obj = toObject(description.split('\n'), '#');
112
+ var errors = this.validateProject(obj, {
113
+ validSections: validHeadings,
114
+ requiredSections: PROJECT_REQUIRED_HEADINGS
115
+ });
116
+ if (!projectConfig.monorepo.enabled)
117
+ return errors;
118
+ var _loop_1 = function (subProject) {
119
+ // Ignore known headings
120
+ if (PROJECT_VALID_HEADINGS.indexOf(subProject) !== -1)
121
+ return "continue";
122
+ var subObj = toObject(obj[subProject].split('\n'), '##');
123
+ var subErrors = this_1.validateProject(subObj, {
124
+ validSections: PROJECT_VALID_HEADINGS,
125
+ requiredSections: []
126
+ });
127
+ errors = errors.concat(subErrors.map(function (x) { return "[".concat(subProject, "] ") + x; }));
128
+ };
129
+ var this_1 = this;
130
+ // If monorepo we need to check the sub projects are valid
131
+ for (var subProject in obj) {
132
+ _loop_1(subProject);
133
+ }
134
+ return errors;
135
+ },
136
+ validateProject: function (parsedDescription, options) {
137
+ // Parse description
138
+ var headings = Object.keys(parsedDescription);
139
+ // Must have at least one heading
140
+ if (headings.length < 1)
141
+ return ['Must have at least one section'];
142
+ var errors = [];
143
+ // Ensure all the headings are valid
144
+ for (var _i = 0, headings_1 = headings; _i < headings_1.length; _i++) {
145
+ var heading = headings_1[_i];
146
+ if (options.validSections.indexOf(heading) === -1)
147
+ errors.push("Invalid section: ".concat(heading));
148
+ }
149
+ // Ensure we have all required headings
150
+ for (var _a = 0, _b = options.requiredSections; _a < _b.length; _a++) {
151
+ var requiredSection = _b[_a];
152
+ if (parsedDescription[requiredSection] === undefined)
153
+ errors.push("Missing section: ".concat(requiredSection));
154
+ }
155
+ return errors;
156
+ },
157
+ getCombinedDescription: function (mergeRequests, headingPrefix) {
158
+ if (headingPrefix === void 0) { headingPrefix = '#'; }
159
+ var descriptionObjs = mergeRequests
160
+ .filter(function (mr) { return mr.status === 'merged'; })
161
+ .map(function (mr) { return toObject(mr.description.split('\n'), headingPrefix); });
162
+ var obj = {};
163
+ var _loop_2 = function (descriptionObj) {
164
+ Object.keys(descriptionObj).forEach(function (key) {
165
+ if (!obj[key])
166
+ obj[key] = '';
167
+ obj[key] += descriptionObj[key] + '\n';
168
+ });
169
+ };
170
+ for (var _i = 0, descriptionObjs_1 = descriptionObjs; _i < descriptionObjs_1.length; _i++) {
171
+ var descriptionObj = descriptionObjs_1[_i];
172
+ _loop_2(descriptionObj);
173
+ }
174
+ var description = '';
175
+ var orderedHeadings = orderDescriptionHeadings(Object.keys(obj));
176
+ orderedHeadings.forEach(function (key) {
177
+ if (key === Headings.Notes)
178
+ return;
179
+ if (!obj[key])
180
+ return;
181
+ description += '\n' + headingPrefix + ' ' + key + '\n';
182
+ description += obj[key];
183
+ });
184
+ return description;
185
+ },
186
+ getDescriptionSection: function (heading, mergeRequest) {
187
+ var descriptionObj = toObject(mergeRequest.description.split('\n'), '#');
188
+ var obj = {};
189
+ Object.keys(descriptionObj).forEach(function (key) {
190
+ if (!obj[key])
191
+ obj[key] = '';
192
+ obj[key] += descriptionObj[key] + '\n';
193
+ });
194
+ return obj[Headings[heading]];
195
+ },
196
+ // TODO: This isn't readable, it needs to be refactored
197
+ getMonorepoCombinedDescription: function (mergeRequests) {
198
+ // Get an object where H1s are properties
199
+ var descriptionObjs = mergeRequests
200
+ .filter(function (mr) { return mr.status === 'merged'; })
201
+ .map(function (mr) { return toObject(mr.description.split('\n'), '#'); });
202
+ var combinedObj = {};
203
+ var _loop_3 = function (descriptionObj) {
204
+ Object.keys(descriptionObj).forEach(function (key) {
205
+ if (!combinedObj[key])
206
+ combinedObj[key] = {};
207
+ var combinedSubObj = toObject(descriptionObj[key].split('\n'), '##');
208
+ var orderedHeadings = orderDescriptionHeadings(Object.keys(combinedSubObj));
209
+ orderedHeadings.forEach(function (subKey) {
210
+ if (!combinedObj[key][subKey])
211
+ combinedObj[key][subKey] = '';
212
+ combinedObj[key][subKey] += combinedSubObj[subKey];
213
+ });
214
+ });
215
+ };
216
+ // For each property in each MR object, calculate it's H2 heading objects
217
+ for (var _i = 0, descriptionObjs_2 = descriptionObjs; _i < descriptionObjs_2.length; _i++) {
218
+ var descriptionObj = descriptionObjs_2[_i];
219
+ _loop_3(descriptionObj);
220
+ }
221
+ var orderedHeadings = orderDescriptionHeadings(Object.keys(combinedObj));
222
+ // Build our description
223
+ var description = '';
224
+ orderedHeadings.forEach(function (key) {
225
+ if (key === Headings.Notes)
226
+ return;
227
+ description += '\n# ' + key + '\n';
228
+ Object.keys(combinedObj[key]).forEach(function (subKey) {
229
+ if (key !== Headings.Dependencies && key !== Headings.Testing)
230
+ description += '\n## ' + subKey + '\n';
231
+ description += combinedObj[key][subKey];
232
+ });
233
+ });
234
+ return description;
235
+ },
236
+ getMonorepoDescriptionSection: function (subHeading, mergeRequest) {
237
+ var descriptionObj = toObject(mergeRequest.description.split('\n'), '#');
238
+ var obj = {};
239
+ Object.keys(descriptionObj).forEach(function (key) {
240
+ if (!obj[key])
241
+ obj[key] = {};
242
+ var combinedSubObj = toObject(descriptionObj[key].split('\n'), '##');
243
+ Object.keys(combinedSubObj).forEach(function (subKey) {
244
+ if (!obj[key][subKey])
245
+ obj[key][subKey] = '';
246
+ obj[key][subKey] += combinedSubObj[subKey];
247
+ });
248
+ });
249
+ // Build our description
250
+ var description = '';
251
+ Object.keys(obj).forEach(function (key) {
252
+ if (key === Headings.Notes)
253
+ return;
254
+ Object.keys(obj[key]).forEach(function (subKey) {
255
+ if (subKey !== Headings[subHeading])
256
+ return;
257
+ description += '\n# ' + key + '\n';
258
+ description += obj[key][subKey];
259
+ });
260
+ });
261
+ return description;
262
+ },
263
+ bumpHeadings: function (description) {
264
+ var lines = description.split('\n');
265
+ var bumpedDescription = '';
266
+ lines.forEach(function (line) {
267
+ if (line.startsWith('#'))
268
+ bumpedDescription += '#' + line + '\n';
269
+ else
270
+ bumpedDescription += line + '\n';
271
+ });
272
+ return bumpedDescription;
273
+ }
274
+ };
@@ -1,6 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GroupIds = void 0;
4
- exports.GroupIds = {
5
- CLICKVIEW: 1069
6
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GroupIds = void 0;
4
+ exports.GroupIds = {
5
+ CLICKVIEW: 1069
6
+ };