Skip to content

Commit 80f417c

Browse files
authored
Docs (#5)
* fix: Update task key and enhance work item fetching logic; add JSON output functionality * fix: Update task key and add HTML output for release notes * fix: Update output file names in task.json and README.md for consistency * fix: Update output section in README.md to clarify default markdown and HTML templates * fix: Correct output section header and improve local testing instructions in README.md
1 parent 1523e9a commit 80f417c

File tree

9 files changed

+28
-1595
lines changed

9 files changed

+28
-1595
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,4 @@ Tools/**/*.js.map
225225

226226
!jest.config.js
227227
output/release-notes.md
228+
output/release-notes.html
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
30435434-173e-4a63-8c43-9a886bd70284
1+
8540612f-cbf9-4737-b3b4-6f49e7425db8

CommitRangeReleaseNotesTask/task/dist/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const fs = require("fs");
1515
const CommitUtils_1 = require("./utils/CommitUtils");
1616
const PRUtils_1 = require("./utils/PRUtils");
1717
const TemplateUtils_1 = require("./utils/TemplateUtils");
18+
const JsonOutput_1 = require("./utils/JsonOutput");
1819
(0, TemplateUtils_1.registerHelpers)();
1920
function GenerateReleaseNotes(startCommit, endCommit, outputFileMarkdown, outputFileHtml, repoRoot, systemAccessToken, project, apiUrl, repositoryId, templateFileMarkdown, templateFileHtml) {
2021
return __awaiter(this, void 0, void 0, function* () {
@@ -157,7 +158,7 @@ function GenerateReleaseNotes(startCommit, endCommit, outputFileMarkdown, output
157158
repositoryId,
158159
project
159160
};
160-
//printJson(releaseData);
161+
(0, JsonOutput_1.printJson)(releaseData);
161162
(0, TemplateUtils_1.GenerateMarkdownReleaseNotes)(releaseData, outputFileMarkdown, templateFileMarkdown);
162163
(0, TemplateUtils_1.GenerateHtmlReleaseNotes)(releaseData, outputFileHtml, templateFileHtml);
163164
});

CommitRangeReleaseNotesTask/task/dist/utils/TemplateUtils.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const Handlebars = __importStar(require("handlebars"));
2828
const fs = require("fs");
2929
const path = require("path");
3030
const tl = require("azure-pipelines-task-lib/task");
31-
const JsonOutput_1 = require("./JsonOutput");
3231
function registerHelpers() {
3332
// GroupBy helper
3433
Handlebars.registerHelper('groupBy', function (items, field, options) {
@@ -104,72 +103,45 @@ function GenerateMarkdownReleaseNotes(data, outputFile, templateFile) {
104103
}
105104
exports.GenerateMarkdownReleaseNotes = GenerateMarkdownReleaseNotes;
106105
function GenerateHtmlReleaseNotes(data, outputFile, templateFile) {
107-
var _a, _b;
108106
console.log('Starting HTML release notes generation...');
109107
// Convert PR descriptions from markdown to HTML
110108
const { marked } = require('marked');
111-
console.log(`Found ${((_a = data.pullRequests) === null || _a === void 0 ? void 0 : _a.length) || 0} pull requests`);
112-
console.log(`Found ${((_b = data.commits) === null || _b === void 0 ? void 0 : _b.length) || 0} commits`);
113109
// Convert descriptions in the pullRequests array
114110
if (Array.isArray(data.pullRequests) && data.pullRequests.length > 0) {
115-
console.log(`Processing ${data.pullRequests.length} pull requests`);
116111
data.pullRequests = data.pullRequests.map(pr => {
117-
console.log(`Checking PR ${pr.id}: has description = ${!!pr.description}, type = ${typeof pr.description}`);
118112
if (pr && pr.description != null && typeof pr.description === 'string' && pr.description.trim() !== '') {
119-
console.log(`Converting PR ${pr.id} description from markdown to HTML`);
120-
console.log(`Original (first 200 chars): ${pr.description.substring(0, 200)}`);
121113
try {
122114
const converted = marked(pr.description);
123-
console.log(`Converted (first 200 chars): ${converted.substring(0, 200)}`);
124115
return Object.assign(Object.assign({}, pr), { description: converted });
125116
}
126117
catch (error) {
127118
console.warn(`Failed to convert markdown for PR: ${pr.id || 'unknown'}`, error);
128119
return pr;
129120
}
130121
}
131-
else {
132-
console.log(`Skipping PR ${pr.id} - no valid description`);
133-
}
134122
return pr;
135123
});
136124
}
137-
else {
138-
console.log('No pull requests to process');
139-
}
140125
// Convert descriptions in commits.pullRequest objects
141126
if (Array.isArray(data.commits) && data.commits.length > 0) {
142-
console.log(`Processing ${data.commits.length} commits`);
143127
data.commits = data.commits.map(commit => {
144128
if (commit && commit.pullRequest) {
145-
console.log(`Checking commit PR ${commit.pullRequest.id}: has description = ${!!commit.pullRequest.description}, type = ${typeof commit.pullRequest.description}`);
146129
if (commit.pullRequest.description != null &&
147130
typeof commit.pullRequest.description === 'string' &&
148131
commit.pullRequest.description.trim() !== '') {
149-
console.log(`Converting commit PR ${commit.pullRequest.id} description from markdown to HTML`);
150-
console.log(`Original (first 200 chars): ${commit.pullRequest.description.substring(0, 200)}`);
151132
try {
152133
const converted = marked(commit.pullRequest.description);
153-
console.log(`Converted (first 200 chars): ${converted.substring(0, 200)}`);
154134
return Object.assign(Object.assign({}, commit), { pullRequest: Object.assign(Object.assign({}, commit.pullRequest), { description: converted }) });
155135
}
156136
catch (error) {
157137
console.warn(`Failed to convert markdown for commit PR: ${commit.pullRequest.id || 'unknown'}`, error);
158138
return commit;
159139
}
160140
}
161-
else {
162-
console.log(`Skipping commit PR ${commit.pullRequest.id} - no valid description`);
163-
}
164141
}
165142
return commit;
166143
});
167144
}
168-
else {
169-
console.log('No commits to process');
170-
}
171-
console.log('Markdown conversion complete, proceeding with template generation...');
172-
(0, JsonOutput_1.printJson)(data);
173145
// Get template
174146
let template;
175147
try {

CommitRangeReleaseNotesTask/task/dist/utils/WorkItemUtils.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ exports.getWorkItem = void 0;
1313
function getWorkItem(workItemId, apiUrl, project, accessToken) {
1414
var _a, _b, _c, _d;
1515
return __awaiter(this, void 0, void 0, function* () {
16-
const fields = [
17-
"System.Title",
18-
"System.WorkItemType",
19-
"System.AssignedTo",
20-
"System.Description"
21-
];
22-
// fields=${fields.join(',')}&
2316
const url = `${apiUrl}/${project}/_apis/wit/workitems/${workItemId}?api-version=7.1&$expand=ALL`;
2417
console.log(`Fetching work item ${workItemId} from ${url}`);
2518
try {

CommitRangeReleaseNotesTask/task/task.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@
3333
"name": "outputFileMarkdown",
3434
"type": "filePath",
3535
"label": "Output File - Markdown",
36-
"defaultValue": "$(Build.ArtifactStagingDirectory)/ReleaseNotes.md",
36+
"defaultValue": "$(Build.ArtifactStagingDirectory)/release-notes.md",
3737
"required": true,
3838
"helpMarkDown": "Path where the generated release notes will be saved"
3939
},
4040
{
4141
"name": "outputFileHtml",
4242
"type": "filePath",
4343
"label": "Output File - HTML",
44-
"defaultValue": "$(Build.ArtifactStagingDirectory)/ReleaseNotes.html",
44+
"defaultValue": "$(Build.ArtifactStagingDirectory)/release-notes.html",
4545
"required": true,
4646
"helpMarkDown": "Path where the generated release notes will be saved"
4747
},

CommitRangeReleaseNotesTask/task/utils/WorkItemUtils.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,6 @@ export async function getWorkItem(
3636
project: string,
3737
accessToken: string
3838
): Promise<WorkItem | null> {
39-
const fields = [
40-
"System.Title",
41-
"System.WorkItemType",
42-
"System.AssignedTo",
43-
"System.Description"
44-
];
45-
46-
// fields=${fields.join(',')}&
4739
const url = `${apiUrl}/${project}/_apis/wit/workitems/${workItemId}?api-version=7.1&$expand=ALL`;
4840
console.log(`Fetching work item ${workItemId} from ${url}`);
4941

README.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ The extension analyses Git commits in a specified range, looking for merge commi
2424
inputs:
2525
startCommit: 'v1.0.0'
2626
endCommit: 'HEAD'
27-
outputFile: '$(Build.ArtifactStagingDirectory)/ReleaseNotes.md'
27+
outputFileMarkdown: '$(Build.ArtifactStagingDirectory)/release-notes.md'
28+
outputFileHtml: '$(Build.ArtifactStagingDirectory)/release-notes.html'
2829
```
2930
3031
### With Custom Template
@@ -33,25 +34,27 @@ The extension analyses Git commits in a specified range, looking for merge commi
3334
inputs:
3435
startCommit: 'v1.0.0'
3536
endCommit: 'v1.1.0'
36-
outputFile: 'release-notes.md'
37-
templateFile: 'templates/custom-release-notes.hbs'
37+
outputFileMarkdown: '$(Build.ArtifactStagingDirectory)/release-notes.md'
38+
outputFileHtml: '$(Build.ArtifactStagingDirectory)/release-notes.html'
39+
templateFileMarkdown: 'templates/custom-release-notes.hbs'
40+
templateFileHtml: 'templates/custom-release-notes.hbs'
3841
```
3942
4043
## Parameters
4144
| Parameter | Description | Required | Default |
4245
|-----------|-------------|----------|---------|
4346
| `startCommit` | Commit reference for the start of the range (exclusive). Can be a commit hash, git tag, or a ref like `HEAD` or `HEAD~xx` | ✅ | - |
4447
| `endCommit` | Commit reference for the end of the range (inclusive). Can be a commit hash, git tag, or a ref like `HEAD` or `HEAD~xx` | ✅ | `HEAD` |
45-
| `outputFile` | Path where generated release notes will be saved | ✅ | `$(Build.ArtifactStagingDirectory)/ReleaseNotes.md` |
46-
| `templateFile` | Path to custom Handlebars template file | ❌ | Built-in template |
48+
| `outputFileMarkdown` and `outputFileHtml` | Path where generated release notes will be saved | ✅ | `$(Build.ArtifactStagingDirectory)/release-notes.html` and `$(Build.ArtifactStagingDirectory)/release-notes.html` |
49+
| `templateFileMarkdown` and `templateFileHtml` | Path to custom Handlebars template file | ❌ | Built-in template |
4750

4851
### Supported commit reference formats for `startCommit` and `endCommit`
4952
- Commit hash (e.g., `a1b2c3d`)
5053
- Git tag (e.g., `v1.0.0`)
5154
- `HEAD` or `HEAD~xx` (where `xx` is the number of commits before HEAD)
5255

53-
## Sample Output
54-
The [default template](https://github.com/IeuanWalker/AzureDevops-GenerateReleaseNotes/blob/master/CommitRangeReleaseNotesTask/task/defaultTemplate.hbs) outputs the following format -
56+
## Output
57+
The [default markdown template](https://github.com/IeuanWalker/AzureDevops-GenerateReleaseNotes/blob/master/CommitRangeReleaseNotesTask/task/defaultTemplateMarkdown.hbs) outputs the following format -
5558
```markdown
5659
## 📊 Summary
5760
- **3** Pull Requests
@@ -85,6 +88,8 @@ The [default template](https://github.com/IeuanWalker/AzureDevops-GenerateReleas
8588
| [44](https://dev.azure.com/org/project/_git/pullrequest/44) | Bug fixes and improvements | Bob Wilson |
8689
```
8790

91+
It also generates an interactive html version using this [template.](https://github.com/IeuanWalker/AzureDevops-GenerateReleaseNotes/blob/master/CommitRangeReleaseNotesTask/task/defaultTemplateHtml.hbs)
92+
8893
## Template Customisation
8994
The task uses Handlebars templates to format output. You can provide a custom template file or use the built-in default template.
9095

@@ -192,21 +197,22 @@ interface WorkItemList {
192197
{{/if}}
193198
```
194199

195-
## Console Usage
200+
## Local testing
196201
The task can also be run from the command line for testing.
197202

198203
- Clone the repo
199204
- Run `npm run build`, in the `CommitRangeReleaseNotesTask` folder
200205
- Run the following command from the folder `CommitRangeReleaseNotesTask\task\dist`
201206
```cmd
202-
node ./mainConsole.js \
203-
--startCommit "v1.0.0" \
204-
--endCommit "HEAD" \
205-
--outputFile "C:\release-notes.md" \
206-
--repoRoot "\path\to\repo" \
207-
--systemAccessToken "your-token" \
208-
--project "your-project" \
209-
--repositoryId "your-repo" \
207+
node ./mainConsole.js
208+
--startCommit "v1.0.0"
209+
--endCommit "HEAD"
210+
--outputFileMarkdown "C:\release-notes.md"
211+
--outputFileHtml "C:\release-notes.html"
212+
--repoRoot "\path\to\repo"
213+
--systemAccessToken "your-token"
214+
--project "your-project"
215+
--repositoryId "your-repo"
210216
--apiUrl "https://dev.azure.com/your-org"
211217
```
212218
> To test locally, the `systemAccessToken` will need to be a [Personal Access Token (PAT)](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows).

0 commit comments

Comments
 (0)