17 {
18 ifstream externalConfigFile(configFileName);
19 if (!externalConfigFile.is_open()) {
20 throw runtime_error("Unable to open " + configFileName + ", please ensure that it exists in the same directory as the script");
21 }
22
23 json externalConfigData;
24 try {
25 externalConfigFile >> externalConfigData;
26 }
27 catch (json::parse_error& e) {
28 throw runtime_error("JSON parsing error: " + string(e.what()));
29 }
30
31 if (externalConfigData.contains("markdownOutputFileName")) {
33
35 throw invalid_argument("Key 'markdownOutputFileName' doesn't contain a correct value, enter a correct file name that ends in .md in "
36 + configFileName);
37 }
38 }
39 else {
40 throw runtime_error("Key 'markdownOutputFileName' not found in " + configFileName);
41 }
42
43 if (externalConfigData.contains("htmlOutputFileName")) {
45
47 throw invalid_argument("Key 'htmlOutputFileName' doesn't contain a correct value, enter a correct file name that ends in .html in "
48 + configFileName);
49 }
50 }
51 else {
52 throw runtime_error("Key 'htmlOutputFileName' not found in " + configFileName);
53 }
54
55 if (externalConfigData.contains("githubReposApiUrl")) {
57 }
58 else {
59 throw runtime_error("Key 'githubReposApiUrl' not found in " + configFileName);
60 }
61
62 if (externalConfigData.contains("githubMarkdownApiUrl")) {
64 }
65 else {
66 throw runtime_error("Key 'githubMarkdownApiUrl' not found in " + configFileName);
67 }
68
69 if (externalConfigData.contains("githubUrl")) {
70 githubUrl = externalConfigData[
"githubUrl"];
71 }
72 else {
73 throw runtime_error("Key 'githubUrl' not found in " + configFileName);
74 }
75
76 if (externalConfigData.contains("commitTypesCount")) {
78
80 throw invalid_argument("Key 'commitTypesCount' must contain a value bigger than 0 in " + configFileName);
81 }
82 }
83 else {
84 throw runtime_error("Key 'commitTypesCount' not found in " + configFileName);
85 }
86
87 if (externalConfigData.contains("commitMessagesSourceCliInputName")) {
89 }
90 else {
91 throw runtime_error("Key 'commitMessagesSourceCliInputName' not found in " + configFileName);
92 }
93
94 if (externalConfigData.contains("commitMessagesSourceGithubActionsInputName")) {
96 }
97 else {
98 throw runtime_error("Key 'commitMessagesSourceGithubActionsInputName' not found in " + configFileName);
99 }
100
101 if (externalConfigData.contains("pullRequestsSourceCliInputName")) {
103 }
104 else {
105 throw runtime_error("Key 'pullRequestsSourceCliInputName' not found in " + configFileName);
106 }
107
108 if (externalConfigData.contains("pullRequestsSourceGithubActionsInputName")) {
110 }
111 else {
112 throw runtime_error("Key 'pullRequestsSourceGithubActionsInputName' not found in " + configFileName);
113 }
114
115 if (externalConfigData.contains("shortModeCliInputName")) {
117 }
118 else {
119 throw runtime_error("Key 'shortModeCliInputName' not found in " + configFileName);
120 }
121
122 if (externalConfigData.contains("shortModeGithubActionsInputName")) {
124 }
125 else {
126 throw runtime_error("Key 'shortModeGithubActionsInputName' not found in " + configFileName);
127 }
128
129 if (externalConfigData.contains("fullModeCliInputName")) {
131 }
132 else {
133 throw runtime_error("Key 'fullModeCliInputName' not found in " + configFileName);
134 }
135
136 if (externalConfigData.contains("fullModeGithubActionsInputName")) {
138 }
139 else {
140 throw runtime_error("Key 'fullModeGithubActionsInputName' not found in " + configFileName);
141 }
142
143 if (externalConfigData.contains("singlePullRequestSourceCliInputName")) {
145 }
146 else {
147 throw runtime_error("Key 'singlePullRequestSourceCliInputName' not found in " + configFileName);
148 }
149
150 if (!externalConfigData.contains("commitTypes") || !externalConfigData["commitTypes"].is_array()) {
151 throw runtime_error("Key 'commitTypes' not found or is not an array in " + configFileName);
152 }
153
154 auto& commitTypesArray = externalConfigData["commitTypes"];
155
157 throw runtime_error("'commitTypesCount' does not match the size of the 'commitTypes' array in " + configFileName);
158 }
159
161 {
162 if (!commitTypesArray[i].contains("conventionalType")) {
163 throw runtime_error("Missing 'conventionalType' in commitTypes array at index " + to_string(i) + " (0-based) in " + configFileName);
164 }
165 else if (!commitTypesArray[i].contains("markdownTitle")) {
166 throw runtime_error("Missing 'markdownTitle' in commitTypes array at index " + to_string(i) + " (0-based) in " + configFileName);
167 }
168
169 commitTypes[i][0] = commitTypesArray[i][
"conventionalType"];
170 commitTypes[i][1] = commitTypesArray[i][
"markdownTitle"];
171 }
172
173 if (externalConfigData.contains("markdownReleaseNotePrefix")) {
175 }
176 else {
177 throw runtime_error("Key 'markdownReleaseNotePrefix' not found in " + configFileName);
178 }
179
180 if (externalConfigData.contains("markdownFullModeReleaseNotePrefix")) {
182 }
183 else {
184 throw runtime_error("Key 'markdownFullModeReleaseNotePrefix' not found in " + configFileName);
185 }
186
187 if (externalConfigData.contains("outputMessages")) {
188 auto& outputMessages = externalConfigData["outputMessages"];
189
190 if (outputMessages.contains("noReleaseNotesSourceError")) {
192 }
193 else {
194 throw runtime_error("Key 'noReleaseNotesSourceError' not found in the 'outputMessages' category in " + configFileName);
195 }
196
197 if (outputMessages.contains("incorrectReleaseNotesSourceError")) {
199 }
200 else {
201 throw runtime_error("Key 'incorrectReleaseNotesSourceError' not found in the 'outputMessages' category in " + configFileName);
202 }
203
204 if (outputMessages.contains("noReleaseNotesModeError")) {
206 }
207 else {
208 throw runtime_error("Key 'noReleaseNotesModeError' not found in the 'outputMessages' category in " + configFileName);
209 }
210
211 if (outputMessages.contains("incorrectReleaseNotesModeError")) {
213 }
214 else {
215 throw runtime_error("Key 'incorrectReleaseNotesModeError' not found in the 'outputMessages' category in " + configFileName);
216 }
217
218 if (outputMessages.contains("noGithubTokenError")) {
220 }
221 else {
222 throw runtime_error("Key 'noGithubTokenError' not found in the 'outputMessages' category in " + configFileName);
223 }
224
225 if (outputMessages.contains("noReleaseStartReferenceError")) {
227 }
228 else {
229 throw runtime_error("Key 'noReleaseStartReferenceError' not found in the 'outputMessages' category in " + configFileName);
230 }
231
232 if (outputMessages.contains("noReleaseEndReferenceError")) {
234 }
235 else {
236 throw runtime_error("Key 'noReleaseEndReferenceError' not found in the 'outputMessages' category in " + configFileName);
237 }
238
239 if (outputMessages.contains("noPullRequestNumberError")) {
241 }
242 else {
243 throw runtime_error("Key 'noPullRequestNumberError' not found in the 'outputMessages' category in " + configFileName);
244 }
245
246 if (outputMessages.contains("noGithubRepositoryError")) {
248 }
249 else {
250 throw runtime_error("Key 'noGithubRepositoryError' not found in the 'outputMessages' category in " + configFileName);
251 }
252
253 if (outputMessages.contains("expectedSyntaxMessage")) {
255 }
256 else {
257 throw runtime_error("Key 'expectedSyntaxMessage' not found in the 'outputMessages' category in " + configFileName);
258 }
259
260 if (outputMessages.contains("githubApiRateLimitExceededError")) {
262 }
263 else {
264 throw runtime_error("Key 'githubApiRateLimitExceededError' not found in the 'outputMessages' category in " + configFileName);
265 }
266
267 if (outputMessages.contains("githubApiUnauthorizedAccessError")) {
269 }
270 else {
271 throw runtime_error("Key 'githubApiUnauthorizedAccessError' not found in the 'outputMessages' category in " + configFileName);
272 }
273
274 if (outputMessages.contains("githubApiBadRequestError")) {
276 }
277 else {
278 throw runtime_error("Key 'githubApiBadRequestError' not found in the 'outputMessages' category in " + configFileName);
279 }
280
281 if (outputMessages.contains("githubApiUnableToMakeRequestError")) {
283 }
284 else {
285 throw runtime_error("Key 'githubApiUnableToMakeRequestError' not found in the 'outputMessages' category in " + configFileName);
286 }
287
288 if (outputMessages.contains("githubApiLibcurlError")) {
290 }
291 else {
292 throw runtime_error("Key 'githubApiLibcurlError' not found in the 'outputMessages' category in " + configFileName);
293 }
294
295 if (outputMessages.contains("gitLogError")) {
297 }
298 else {
299 throw runtime_error("Key 'gitLogError' not found in the 'outputMessages' category in " + configFileName);
300 }
301
302 if (outputMessages.contains("generatingReleaseNotesMessage")) {
304 }
305 else {
306 throw runtime_error("Key 'generatingReleaseNotesMessage' not found in the 'outputMessages' category in " + configFileName);
307 }
308
309 if (outputMessages.contains("failedToGenerateReleaseNotesMessage")) {
311 }
312 else {
313 throw runtime_error("Key 'failedToGenerateReleaseNotesMessage' not found in the 'outputMessages' category in " + configFileName);
314 }
315
316 if (outputMessages.contains("markdownFileError")) {
318 }
319 else {
320 throw runtime_error("Key 'markdownFileError' not found in the 'outputMessages' category in " + configFileName);
321 }
322
323 if (outputMessages.contains("htmlFileError")) {
325 }
326 else {
327 throw runtime_error("Key 'htmlFileError' not found in the 'outputMessages' category in " + configFileName);
328 }
329
330 if (outputMessages.contains("emptyReleaseNotesMessage")) {
332 }
333 else {
334 throw runtime_error("Key 'emptyReleaseNotesMessage' not found in the 'outputMessages' category in " + configFileName);
335 }
336 }
337 else {
338 throw runtime_error("Category 'outputMessages' not found in " + configFileName);
339 }
340}
string markdownFullModeReleaseNotePrefix
Definition Config.h:50
string gitLogError
Definition Config.h:67
string expectedSyntaxMessage
Definition Config.h:70
string githubUrl
Definition Config.h:20
string noPullRequestNumberError
Definition Config.h:60
string noReleaseNotesModeError
Definition Config.h:55
string pullRequestsSourceCliInputName
Definition Config.h:40
string pullRequestsSourceGithubActionsInputName
Definition Config.h:41
string noReleaseStartReferenceError
Definition Config.h:58
string incorrectReleaseNotesModeError
Definition Config.h:56
string incorrectReleaseNotesSourceError
Definition Config.h:54
string fullModeCliInputName
Definition Config.h:44
string githubReposApiUrl
Definition Config.h:21
string githubApiUnauthorizedAccessError
Definition Config.h:63
string githubApiRateLimitExceededError
Definition Config.h:62
int commitTypesCount
Definition Config.h:26
string noGithubRepositoryError
Definition Config.h:61
string singlePullRequestSourceCliInputName
Definition Config.h:46
string shortModeCliInputName
Definition Config.h:42
string githubMarkdownApiUrl
Definition Config.h:22
string markdownOutputFileName
Definition Config.h:18
string commitTypes[50][2]
2d array storing conventional commit types and their corresponding markdown titles The first dimensio...
Definition Config.h:31
string noReleaseEndReferenceError
Definition Config.h:59
string emptyReleaseNotesMessage
Definition Config.h:73
string shortModeGithubActionsInputName
Definition Config.h:43
string githubApiUnableToMakeRequestError
Definition Config.h:65
string noGithubTokenError
Definition Config.h:57
string generatingReleaseNotesMessage
Definition Config.h:71
string htmlOutputFileName
Definition Config.h:19
string fullModeGithubActionsInputName
Definition Config.h:45
string commitMessagesSourceGithubActionsInputName
Definition Config.h:39
string commitMessagesSourceCliInputName
Definition Config.h:38
string noReleaseNotesSourceError
Definition Config.h:53
string githubApiLibcurlError
Definition Config.h:66
string githubApiBadRequestError
Definition Config.h:64
string failedToGenerateReleaseNotesMessage
Definition Config.h:72
string markdownReleaseNotePrefix
Definition Config.h:49
string htmlFileError
Definition Config.h:69
string markdownFileError
Definition Config.h:68