|
|
|
@ -6,6 +6,7 @@ export interface INextCommitObject {
|
|
|
|
|
recommendedNextVersionLevel: 'fix' | 'feat' | 'BREAKING CHANGE'; // the recommended next version level of the project
|
|
|
|
|
recommendedNextVersionScope: string; // the recommended scope name of the next version, like "core" or "cli", or specific class names.
|
|
|
|
|
recommendedNextVersionMessage: string; // the commit message. Don't put fix() feat() or BREAKING CHANGE in the message. Please just the message itself.
|
|
|
|
|
recommendedNextVersionDetauls: string[]; // detailed bullet points for the changelog
|
|
|
|
|
recommendedNextVersion: string; // the recommended next version of the project, x.x.x
|
|
|
|
|
changelog?: string; // the changelog for the next version
|
|
|
|
|
}
|
|
|
|
@ -49,10 +50,12 @@ Important: Answer only in valid JSON.
|
|
|
|
|
Your answer should be parseable with JSON.parse() without modifying anything.
|
|
|
|
|
|
|
|
|
|
Here is the structure of the JSON you should return:
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
interface {
|
|
|
|
|
recommendedNextVersionLevel: 'fix' | 'feat' | 'BREAKING CHANGE'; // the recommended next version level of the project
|
|
|
|
|
recommendedNextVersionScope: string; // the recommended scope name of the next version, like "core" or "cli", or specific class names.
|
|
|
|
|
recommendedNextVersionMessage: string; // the commit message. Don't put fix() feat() or BREAKING CHANGE in the message. Please just the message itself.
|
|
|
|
|
recommendedNextVersionDetails: string[]; // detailed bullet points for the changelog
|
|
|
|
|
recommendedNextVersion: string; // the recommended next version of the project, x.x.x
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -76,40 +79,43 @@ Also you are given a diff
|
|
|
|
|
if (await plugins.smartfile.fs.fileExists(previousChangelogPath)) {
|
|
|
|
|
previousChangelog = await plugins.smartfile.SmartFile.fromFilePath(previousChangelogPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!previousChangelog) {
|
|
|
|
|
let result2 = await this.aiDocsRef.openaiInstance.chat({
|
|
|
|
|
messageHistory: [],
|
|
|
|
|
systemMessage: `
|
|
|
|
|
You are building a changelog file for the projext.
|
|
|
|
|
You are building a changelog.md file for the project.
|
|
|
|
|
Omit commits and versions that lack relevant changes.
|
|
|
|
|
|
|
|
|
|
You are given
|
|
|
|
|
* the previous changelog file (if available)
|
|
|
|
|
A changelog entry should look like this:
|
|
|
|
|
|
|
|
|
|
## yyyy-mm-dd - x.x.x - scope here
|
|
|
|
|
main descriptiom here
|
|
|
|
|
- detailed bullet points follow
|
|
|
|
|
|
|
|
|
|
You are given:
|
|
|
|
|
* the commit messages of the project
|
|
|
|
|
|
|
|
|
|
Only return the changelog file, so it can be written directly to changelog.md
|
|
|
|
|
|
|
|
|
|
For the latest version, that is not yet part of the commit messages, add a placeholder entry that uses {{nextVersion}} and {{nextVersionMessage}} as variables to filled later.
|
|
|
|
|
Only output newer versions and their changes compared to ones already mentioned. We take of appending your output later.
|
|
|
|
|
If there is no previous changelog file, generate a complete changelog from commit messages with heading and everything + the placeholder section mentioned above.
|
|
|
|
|
`,
|
|
|
|
|
Only return the changelog file, so it can be written directly to changelog.md`,
|
|
|
|
|
userMessage: `
|
|
|
|
|
The previous changelog file is:
|
|
|
|
|
${!previousChangelog ? 'No previous changelog file found' : previousChangelog.contents.toString()}
|
|
|
|
|
Here are the commit messages:
|
|
|
|
|
|
|
|
|
|
Here are the commit messages so far:
|
|
|
|
|
|
|
|
|
|
${commitMessages.join('\n\n')}
|
|
|
|
|
`,
|
|
|
|
|
${commitMessages.join('\n')}
|
|
|
|
|
`,
|
|
|
|
|
});
|
|
|
|
|
if (previousChangelog) {
|
|
|
|
|
let newChangelog = result2.message;
|
|
|
|
|
newChangelog = newChangelog.replace('# Changelog\n\n', '');
|
|
|
|
|
let oldChangelog = previousChangelog.contents.toString().replace('# Changelog\n\n', '');
|
|
|
|
|
newChangelog = `# Changelog\n\n${newChangelog}\n\n${oldChangelog}`;
|
|
|
|
|
resultObject.changelog = newChangelog;
|
|
|
|
|
} else {
|
|
|
|
|
resultObject.changelog = result2.message;
|
|
|
|
|
|
|
|
|
|
previousChangelog = await plugins.smartfile.SmartFile.fromString(previousChangelogPath, result2.message, 'utf8');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let oldChangelog = previousChangelog.contents.toString().replace('# Changelog\n\n', '');
|
|
|
|
|
let newDateString = new plugins.smarttime.ExtendedDate().exportToEuropeanDate();
|
|
|
|
|
let newChangelog = `# Changelog\n\n${
|
|
|
|
|
`## ${newDateString} - {{nextVersion}} - {{nextVersionScope}}
|
|
|
|
|
{{nextVersionMessage}}
|
|
|
|
|
{{nextVersionDetails}}
|
|
|
|
|
`}\n\n${oldChangelog}\n`;
|
|
|
|
|
resultObject.changelog = newChangelog;
|
|
|
|
|
|
|
|
|
|
return resultObject;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|