feat(core): Added smarttime dependency and improved changelog generation
This commit is contained in:
parent
e8372effc7
commit
a060cd1a03
@ -1,5 +1,14 @@
|
||||
# Changelog
|
||||
|
||||
```markdown
|
||||
## [1.2.4]
|
||||
### Fixed
|
||||
- Refactor logger initialization to use commitinfo data
|
||||
|
||||
## 1.3.0
|
||||
feat(core): Added smarttime dependency and improved changelog generation
|
||||
```
|
||||
|
||||
## [1.2.4] - 1.2.4
|
||||
fix(logging): Refactor logger initialization to use commitinfo data
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
"@push.rocks/smartlog-destination-local": "^9.0.2",
|
||||
"@push.rocks/smartpath": "^5.0.18",
|
||||
"@push.rocks/smartshell": "^3.0.5",
|
||||
"@push.rocks/smarttime": "^4.0.6",
|
||||
"typedoc": "^0.26.0",
|
||||
"typescript": "^5.5.2"
|
||||
},
|
||||
|
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@ -47,6 +47,9 @@ importers:
|
||||
'@push.rocks/smartshell':
|
||||
specifier: ^3.0.5
|
||||
version: 3.0.5
|
||||
'@push.rocks/smarttime':
|
||||
specifier: ^4.0.6
|
||||
version: 4.0.6
|
||||
typedoc:
|
||||
specifier: ^0.26.0
|
||||
version: 0.26.0(typescript@5.5.2)
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@git.zone/tsdoc',
|
||||
version: '1.2.4',
|
||||
version: '1.3.0',
|
||||
description: 'An advanced TypeScript documentation tool using AI to generate and enhance documentation for TypeScript projects.'
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import * as smartlog from '@push.rocks/smartlog';
|
||||
import * as smartlogDestinationLocal from '@push.rocks/smartlog-destination-local';
|
||||
import * as smartpath from '@push.rocks/smartpath';
|
||||
import * as smartshell from '@push.rocks/smartshell';
|
||||
import * as smarttime from '@push.rocks/smarttime';
|
||||
|
||||
export {
|
||||
npmextra,
|
||||
@ -30,6 +31,7 @@ export {
|
||||
smartlogDestinationLocal,
|
||||
smartpath,
|
||||
smartshell,
|
||||
smarttime,
|
||||
};
|
||||
|
||||
// third party scope
|
||||
|
Loading…
Reference in New Issue
Block a user