@clickview/ship-it 0.0.32 → 0.0.33
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/Dockerfile +33 -33
- package/README.md +48 -48
- package/config.json +19 -19
- package/lib/config.json +20 -20
- package/lib/src/api-clients/git-lab/GitLabApiClient.js +439 -439
- package/lib/src/api-clients/git-lab/GitLabMapper.js +82 -82
- package/lib/src/api-clients/index.js +20 -20
- package/lib/src/api-clients/slack/SlackApiClient.js +206 -206
- package/lib/src/api-clients/team-city/TeamCityApiClient.js +100 -100
- package/lib/src/api-clients/trello/TrelloApiClient.js +145 -145
- package/lib/src/commands/BumpPackagesCommand.js +84 -84
- package/lib/src/commands/CreateBranchCommand.js +100 -100
- package/lib/src/commands/CreateMergeRequestCommand.js +107 -107
- package/lib/src/commands/CreateNotesAuditCommand.js +84 -84
- package/lib/src/commands/CreateReleaseNotesCommand.js +95 -95
- package/lib/src/commands/CreateTrelloCardsCommand.js +77 -77
- package/lib/src/commands/InstallPackagesCommand.js +76 -76
- package/lib/src/commands/ListProjectsCommand.js +76 -76
- package/lib/src/commands/ReleaseCommand.js +129 -129
- package/lib/src/commands/StartProjectBuildsCommand.js +76 -76
- package/lib/src/commands/StatusCommand.js +88 -88
- package/lib/src/commands/TagMasterCommand.js +76 -76
- package/lib/src/commands/ValidateMergeRequestCommand.js +76 -76
- package/lib/src/commands/VersionCommand.js +76 -76
- package/lib/src/commands/index.js +30 -30
- package/lib/src/constants/CommandTypeMapping.js +20 -20
- package/lib/src/constants/GitLabMemberIds.js +6 -6
- package/lib/src/constants/MonorepoPackageJsonFiles.js +17 -17
- package/lib/src/constants/MonorepoProjectNames.js +16 -16
- package/lib/src/constants/ProjectNames.js +68 -68
- package/lib/src/constants/SlackUserEmailList.js +13 -13
- package/lib/src/constants/TeamCityBuildIDs.js +45 -45
- package/lib/src/constants/index.js +19 -19
- package/lib/src/errors/ShipItError.js +32 -32
- package/lib/src/errors/index.js +17 -17
- package/lib/src/index.js +18 -18
- package/lib/src/interfaces/Config.js +2 -2
- package/lib/src/interfaces/MergeRequestState.js +2 -2
- package/lib/src/interfaces/ProjectNames.js +2 -2
- package/lib/src/interfaces/ShipItCommand.js +2 -2
- package/lib/src/interfaces/ShipItTask.js +2 -2
- package/lib/src/interfaces/VersionType.js +2 -2
- package/lib/src/interfaces/command-cli-options/MilestoneCommandCliOptions.js +2 -2
- package/lib/src/interfaces/command-cli-options/ReleaseCommandCliOptions.js +2 -2
- package/lib/src/interfaces/command-cli-options/StatusCommandCliOptions.js +2 -2
- package/lib/src/interfaces/command-cli-options/index.js +19 -19
- package/lib/src/interfaces/command-options/BaseCommandOptions.js +2 -2
- package/lib/src/interfaces/command-options/BumpPackagesCommandOptions.js +2 -2
- package/lib/src/interfaces/command-options/DockerMilestoneCommandOptions.js +2 -2
- package/lib/src/interfaces/command-options/MilestoneCommandOptions.js +2 -2
- package/lib/src/interfaces/command-options/ReleaseCommandOptions.js +2 -2
- package/lib/src/interfaces/command-options/StatusCommandOptions.js +2 -2
- package/lib/src/interfaces/command-options/ValidateMRCommandOptions.js +2 -2
- package/lib/src/interfaces/command-options/index.js +22 -22
- package/lib/src/interfaces/index.js +26 -26
- package/lib/src/interfaces/models/Branch.js +2 -2
- package/lib/src/interfaces/models/Commit.js +2 -2
- package/lib/src/interfaces/models/CommitFile.js +2 -2
- package/lib/src/interfaces/models/File.js +2 -2
- package/lib/src/interfaces/models/Label.js +2 -2
- package/lib/src/interfaces/models/MergeRequest.js +2 -2
- package/lib/src/interfaces/models/Milestone.js +2 -2
- package/lib/src/interfaces/models/Project.js +2 -2
- package/lib/src/interfaces/models/ProjectConfig.js +9 -9
- package/lib/src/interfaces/models/Release.js +2 -2
- package/lib/src/interfaces/models/Tag.js +2 -2
- package/lib/src/interfaces/models/index.js +26 -26
- package/lib/src/interfaces/view-models/MilestoneProject.js +2 -2
- package/lib/src/interfaces/view-models/index.js +17 -17
- package/lib/src/inversify.config.js +75 -75
- package/lib/src/services/GitLabService.js +508 -508
- package/lib/src/services/SlackService.js +142 -142
- package/lib/src/services/TeamCityService.js +37 -37
- package/lib/src/services/TrelloService.js +84 -84
- package/lib/src/services/index.js +20 -20
- package/lib/src/startup/AddMilestoneCommand.js +96 -96
- package/lib/src/startup/GetAction.js +68 -68
- package/lib/src/startup/SetupCommands.js +168 -168
- package/lib/src/tasks/BumpPackagesTask.js +229 -229
- package/lib/src/tasks/BumpVersionTxtTask.js +110 -110
- package/lib/src/tasks/CommitPackageVersionsTask.js +116 -116
- package/lib/src/tasks/CreateBranchTask.js +104 -104
- package/lib/src/tasks/CreateMergeRequestTask.js +118 -118
- package/lib/src/tasks/CreateNotesAuditTask.js +140 -140
- package/lib/src/tasks/CreateReleaseNotesTask.js +144 -144
- package/lib/src/tasks/InstallPackagesTask.js +407 -407
- package/lib/src/tasks/ListProjectsTask.js +87 -87
- package/lib/src/tasks/PopulateTrelloBoardTask.js +140 -140
- package/lib/src/tasks/StartMonorepoBuildTask.js +109 -109
- package/lib/src/tasks/StartProjectBuildsTask.js +170 -170
- package/lib/src/tasks/TagMasterTask.js +186 -186
- package/lib/src/tasks/ValidateCommitsTask.js +143 -143
- package/lib/src/tasks/ValidateDescriptionsTask.js +178 -178
- package/lib/src/tasks/ValidateMergeRequestTask.js +115 -115
- package/lib/src/tasks/ValidateTask.js +419 -419
- package/lib/src/tasks/VersionTask.js +98 -98
- package/lib/src/tasks/index.js +34 -34
- package/lib/src/types.js +57 -57
- package/lib/src/utils/BranchNames.js +11 -11
- package/lib/src/utils/Commits.js +55 -55
- package/lib/src/utils/Csv.js +54 -54
- package/lib/src/utils/Descriptions.js +274 -274
- package/lib/src/utils/GroupIds.js +6 -6
- package/lib/src/utils/Logger.js +62 -62
- package/lib/src/utils/ProjectIds.js +47 -47
- package/lib/src/utils/Versions.js +20 -20
- package/lib/src/utils/index.js +22 -22
- package/package.json +50 -50
- package/dist/F1/Analytics Web.md +0 -8
- package/dist/F1/AutoCaptions.md +0 -30
- package/dist/F1/Classroom.Api.md +0 -23
- package/dist/F1/ClickView Online.md +0 -17
- package/dist/F1/ClickView.Curator.md +0 -100
- package/dist/F1/ClickView.EmailService.md +0 -53
- package/dist/F1/ClickView.OnlineApi.md +0 -13
- package/dist/F1/Clients.md +0 -19
- package/dist/F1/Domain.Api.md +0 -23
- package/dist/F1/Exchange.Web.md +0 -8
- package/dist/F1/Image.Api.md +0 -8
- package/dist/F1/Integrations.Api.md +0 -23
- package/dist/F1/Krakend.md +0 -8
- package/dist/F1/Library Editor.md +0 -0
- package/dist/F1/Lite.md +0 -60
- package/dist/F1/Master.Api.md +0 -58
- package/dist/F1/Master.Auth.md +0 -22
- package/dist/F1/Objects.Api.md +0 -12
- package/dist/F1/Permissions.Api.md +0 -12
- package/dist/F1/RealtimeSalesforceSync.md +0 -14
- package/dist/F1/Release Notes.md +0 -990
- package/dist/F1/Search.Api.md +0 -12
- package/dist/F1/StreamableLearning.Web.md +0 -35
- package/dist/F1/Users.Api.md +0 -13
- package/dist/F1/VideoProcessorService.md +0 -23
- package/dist/F1/clickview.md +0 -321
- package/dist/F2/Analytics Web.md +0 -7
- package/dist/F2/Batch.Api.md +0 -27
- package/dist/F2/ClickView Online.md +0 -12
- package/dist/F2/ClickView.Curator.md +0 -166
- package/dist/F2/Clients.md +0 -14
- package/dist/F2/CurriculumIngestion.Api.md +0 -13
- package/dist/F2/Discover.Api.md +0 -64
- package/dist/F2/Domain.Api.md +0 -16
- package/dist/F2/Exchange.Web.md +0 -7
- package/dist/F2/Krakend.md +0 -12
- package/dist/F2/Library Editor.md +0 -11
- package/dist/F2/Lite.md +0 -30
- package/dist/F2/Objects.Api.md +0 -12
- package/dist/F2/Release Notes.md +0 -759
- package/dist/F2/Search.Api.md +0 -30
- package/dist/F2/Share.Api.md +0 -12
- package/dist/F2/StreamableLearning.Web.md +0 -14
- package/dist/F2/Subjects.API.md +0 -12
- package/dist/F2/Tv.Web.md +0 -8
- package/dist/F2/Users.Api.md +0 -21
- package/dist/F2/clickview.md +0 -200
- package/dist/F2/shortcode-api.md +0 -8
- package/dist/F3.1/Analytics Web.md +0 -8
- package/dist/F3.1/ClickView.Curator.md +0 -14
- package/dist/F3.1/Discover.Api.md +0 -14
- package/dist/F3.1/Domain.Api.md +0 -7
- package/dist/F3.1/Exchange.Web.md +0 -8
- package/dist/F3.1/Library Editor.md +0 -8
- package/dist/F3.1/Lite.md +0 -8
- package/dist/F3.1/Objects.Api.md +0 -7
- package/dist/F3.1/Release Notes.md +0 -207
- package/dist/F3.1/Search.Api.md +0 -14
- package/dist/F3.1/Share.Api.md +0 -10
- package/dist/F3.1/Subjects.API.md +0 -35
- package/dist/F3.1/VideoViews.Api.md +0 -7
- package/dist/F3.1/clickview.md +0 -28
- package/lib/src/commands/CreateTestingNotesCommand.js +0 -84
- package/lib/src/commands/StartConsumingProjectBuildsCommand.js +0 -76
- package/lib/src/tasks/CreateTestingNotesTask.js +0 -135
- package/lib/src/tasks/MergeMasterToDevTask.js +0 -147
- package/lib/src/tasks/StartConsumingProjectBuildsTask.js +0 -149
|
@@ -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
|
+
};
|