Release Notes Manager
Loading...
Searching...
No Matches
Config Class Reference

A class for loading and validating the JSON external configuration values This class allows the script to be easily customizable without opening any source code files. More...

#include <Config.h>

Public Member Functions

void load (const string &configFileName)
 

Public Attributes

string markdownOutputFileName
 
string htmlOutputFileName
 
string githubUrl
 
string githubReposApiUrl
 
string githubMarkdownApiUrl
 
string repoIssuesUrl
 
string repoCommitsUrl
 
string repoPullRequestsApiUrl
 
int commitTypesCount
 
string commitTypes [50][2]
 2d array storing conventional commit types and their corresponding markdown titles The first dimension is 50 to give it enough space to store as many types as the user enters in the release_config.json
 
string commitMessagesSourceCliInputName
 
string commitMessagesSourceGithubActionsInputName
 
string pullRequestsSourceCliInputName
 
string pullRequestsSourceGithubActionsInputName
 
string shortModeCliInputName
 
string shortModeGithubActionsInputName
 
string fullModeCliInputName
 
string fullModeGithubActionsInputName
 
string singlePullRequestSourceCliInputName
 
string markdownReleaseNotePrefix
 
string markdownFullModeReleaseNotePrefix
 
string noReleaseNotesSourceError
 
string incorrectReleaseNotesSourceError
 
string noReleaseNotesModeError
 
string incorrectReleaseNotesModeError
 
string noGithubTokenError
 
string noReleaseStartReferenceError
 
string noReleaseEndReferenceError
 
string noPullRequestNumberError
 
string noGithubRepositoryError
 
string githubApiRateLimitExceededError
 
string githubApiUnauthorizedAccessError
 
string githubApiBadRequestError
 
string githubApiUnableToMakeRequestError
 
string githubApiLibcurlError
 
string gitLogError
 
string markdownFileError
 
string htmlFileError
 
string expectedSyntaxMessage
 
string generatingReleaseNotesMessage
 
string failedToGenerateReleaseNotesMessage
 
string emptyReleaseNotesMessage
 

Detailed Description

A class for loading and validating the JSON external configuration values This class allows the script to be easily customizable without opening any source code files.

Member Function Documentation

◆ load()

void Config::load ( const string & configFileName)
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")) {
32 markdownOutputFileName = externalConfigData["markdownOutputFileName"];
33
34 if (markdownOutputFileName.find(".md") == string::npos) {
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")) {
44 htmlOutputFileName = externalConfigData["htmlOutputFileName"];
45
46 if (htmlOutputFileName.find(".html") == string::npos) {
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")) {
56 githubReposApiUrl = externalConfigData["githubReposApiUrl"];
57 }
58 else {
59 throw runtime_error("Key 'githubReposApiUrl' not found in " + configFileName);
60 }
61
62 if (externalConfigData.contains("githubMarkdownApiUrl")) {
63 githubMarkdownApiUrl = externalConfigData["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")) {
77 commitTypesCount = externalConfigData["commitTypesCount"];
78
79 if (commitTypesCount < 1) {
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")) {
88 commitMessagesSourceCliInputName = externalConfigData["commitMessagesSourceCliInputName"];
89 }
90 else {
91 throw runtime_error("Key 'commitMessagesSourceCliInputName' not found in " + configFileName);
92 }
93
94 if (externalConfigData.contains("commitMessagesSourceGithubActionsInputName")) {
95 commitMessagesSourceGithubActionsInputName = externalConfigData["commitMessagesSourceGithubActionsInputName"];
96 }
97 else {
98 throw runtime_error("Key 'commitMessagesSourceGithubActionsInputName' not found in " + configFileName);
99 }
100
101 if (externalConfigData.contains("pullRequestsSourceCliInputName")) {
102 pullRequestsSourceCliInputName = externalConfigData["pullRequestsSourceCliInputName"];
103 }
104 else {
105 throw runtime_error("Key 'pullRequestsSourceCliInputName' not found in " + configFileName);
106 }
107
108 if (externalConfigData.contains("pullRequestsSourceGithubActionsInputName")) {
109 pullRequestsSourceGithubActionsInputName = externalConfigData["pullRequestsSourceGithubActionsInputName"];
110 }
111 else {
112 throw runtime_error("Key 'pullRequestsSourceGithubActionsInputName' not found in " + configFileName);
113 }
114
115 if (externalConfigData.contains("shortModeCliInputName")) {
116 shortModeCliInputName = externalConfigData["shortModeCliInputName"];
117 }
118 else {
119 throw runtime_error("Key 'shortModeCliInputName' not found in " + configFileName);
120 }
121
122 if (externalConfigData.contains("shortModeGithubActionsInputName")) {
123 shortModeGithubActionsInputName = externalConfigData["shortModeGithubActionsInputName"];
124 }
125 else {
126 throw runtime_error("Key 'shortModeGithubActionsInputName' not found in " + configFileName);
127 }
128
129 if (externalConfigData.contains("fullModeCliInputName")) {
130 fullModeCliInputName = externalConfigData["fullModeCliInputName"];
131 }
132 else {
133 throw runtime_error("Key 'fullModeCliInputName' not found in " + configFileName);
134 }
135
136 if (externalConfigData.contains("fullModeGithubActionsInputName")) {
137 fullModeGithubActionsInputName = externalConfigData["fullModeGithubActionsInputName"];
138 }
139 else {
140 throw runtime_error("Key 'fullModeGithubActionsInputName' not found in " + configFileName);
141 }
142
143 if (externalConfigData.contains("singlePullRequestSourceCliInputName")) {
144 singlePullRequestSourceCliInputName = externalConfigData["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
156 if (commitTypesCount != commitTypesArray.size()) {
157 throw runtime_error("'commitTypesCount' does not match the size of the 'commitTypes' array in " + configFileName);
158 }
159
160 for (int i = 0; i < commitTypesCount; i++)
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")) {
174 markdownReleaseNotePrefix = externalConfigData["markdownReleaseNotePrefix"];
175 }
176 else {
177 throw runtime_error("Key 'markdownReleaseNotePrefix' not found in " + configFileName);
178 }
179
180 if (externalConfigData.contains("markdownFullModeReleaseNotePrefix")) {
181 markdownFullModeReleaseNotePrefix = externalConfigData["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")) {
191 noReleaseNotesSourceError = outputMessages["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")) {
198 incorrectReleaseNotesSourceError = outputMessages["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")) {
205 noReleaseNotesModeError = outputMessages["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")) {
212 incorrectReleaseNotesModeError = outputMessages["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")) {
219 noGithubTokenError = outputMessages["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")) {
226 noReleaseStartReferenceError = outputMessages["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")) {
233 noReleaseEndReferenceError = outputMessages["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")) {
240 noPullRequestNumberError = outputMessages["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")) {
247 noGithubRepositoryError = outputMessages["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")) {
254 expectedSyntaxMessage = outputMessages["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")) {
261 githubApiRateLimitExceededError = outputMessages["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")) {
268 githubApiUnauthorizedAccessError = outputMessages["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")) {
275 githubApiBadRequestError = outputMessages["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")) {
282 githubApiUnableToMakeRequestError = outputMessages["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")) {
289 githubApiLibcurlError = outputMessages["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")) {
296 gitLogError = outputMessages["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")) {
303 generatingReleaseNotesMessage = outputMessages["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")) {
310 failedToGenerateReleaseNotesMessage = outputMessages["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")) {
317 markdownFileError = outputMessages["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")) {
324 htmlFileError = outputMessages["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")) {
331 emptyReleaseNotesMessage = outputMessages["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

Member Data Documentation

◆ commitMessagesSourceCliInputName

string Config::commitMessagesSourceCliInputName

◆ commitMessagesSourceGithubActionsInputName

string Config::commitMessagesSourceGithubActionsInputName

◆ commitTypes

string Config::commitTypes[50][2]

2d array storing conventional commit types and their corresponding markdown titles The first dimension is 50 to give it enough space to store as many types as the user enters in the release_config.json

◆ commitTypesCount

int Config::commitTypesCount

◆ emptyReleaseNotesMessage

string Config::emptyReleaseNotesMessage

◆ expectedSyntaxMessage

string Config::expectedSyntaxMessage

◆ failedToGenerateReleaseNotesMessage

string Config::failedToGenerateReleaseNotesMessage

◆ fullModeCliInputName

string Config::fullModeCliInputName

◆ fullModeGithubActionsInputName

string Config::fullModeGithubActionsInputName

◆ generatingReleaseNotesMessage

string Config::generatingReleaseNotesMessage

◆ githubApiBadRequestError

string Config::githubApiBadRequestError

◆ githubApiLibcurlError

string Config::githubApiLibcurlError

◆ githubApiRateLimitExceededError

string Config::githubApiRateLimitExceededError

◆ githubApiUnableToMakeRequestError

string Config::githubApiUnableToMakeRequestError

◆ githubApiUnauthorizedAccessError

string Config::githubApiUnauthorizedAccessError

◆ githubMarkdownApiUrl

string Config::githubMarkdownApiUrl

◆ githubReposApiUrl

string Config::githubReposApiUrl

◆ githubUrl

string Config::githubUrl

◆ gitLogError

string Config::gitLogError

◆ htmlFileError

string Config::htmlFileError

◆ htmlOutputFileName

string Config::htmlOutputFileName

◆ incorrectReleaseNotesModeError

string Config::incorrectReleaseNotesModeError

◆ incorrectReleaseNotesSourceError

string Config::incorrectReleaseNotesSourceError

◆ markdownFileError

string Config::markdownFileError

◆ markdownFullModeReleaseNotePrefix

string Config::markdownFullModeReleaseNotePrefix

◆ markdownOutputFileName

string Config::markdownOutputFileName

◆ markdownReleaseNotePrefix

string Config::markdownReleaseNotePrefix

◆ noGithubRepositoryError

string Config::noGithubRepositoryError

◆ noGithubTokenError

string Config::noGithubTokenError

◆ noPullRequestNumberError

string Config::noPullRequestNumberError

◆ noReleaseEndReferenceError

string Config::noReleaseEndReferenceError

◆ noReleaseNotesModeError

string Config::noReleaseNotesModeError

◆ noReleaseNotesSourceError

string Config::noReleaseNotesSourceError

◆ noReleaseStartReferenceError

string Config::noReleaseStartReferenceError

◆ pullRequestsSourceCliInputName

string Config::pullRequestsSourceCliInputName

◆ pullRequestsSourceGithubActionsInputName

string Config::pullRequestsSourceGithubActionsInputName

◆ repoCommitsUrl

string Config::repoCommitsUrl

◆ repoIssuesUrl

string Config::repoIssuesUrl

◆ repoPullRequestsApiUrl

string Config::repoPullRequestsApiUrl

◆ shortModeCliInputName

string Config::shortModeCliInputName

◆ shortModeGithubActionsInputName

string Config::shortModeGithubActionsInputName

◆ singlePullRequestSourceCliInputName

string Config::singlePullRequestSourceCliInputName

The documentation for this class was generated from the following files: