azdo-cli 0.8.0-develop.169 → 0.8.0-develop.176
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +12 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -263,8 +263,10 @@ async function listWorkItemComments(context, id, pat) {
|
|
|
263
263
|
comments
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
|
-
async function addWorkItemComment(context, id, pat, text) {
|
|
267
|
-
const
|
|
266
|
+
async function addWorkItemComment(context, id, pat, text, format = "html") {
|
|
267
|
+
const url = buildWorkItemCommentsUrl(context, id);
|
|
268
|
+
url.searchParams.set("format", format);
|
|
269
|
+
const response = await fetchWithErrors(url.toString(), {
|
|
268
270
|
method: "POST",
|
|
269
271
|
headers: {
|
|
270
272
|
...authHeaders(pat),
|
|
@@ -2098,16 +2100,17 @@ function formatCommentHeader(comment) {
|
|
|
2098
2100
|
const timestamp = comment.modifiedAt ?? comment.createdAt ?? "Unknown time";
|
|
2099
2101
|
return `Comment #${comment.id} by ${author} at ${timestamp}`;
|
|
2100
2102
|
}
|
|
2101
|
-
function formatComments(result) {
|
|
2103
|
+
function formatComments(result, convertMarkdown) {
|
|
2102
2104
|
const lines = [`Comments for work item #${result.workItemId}`];
|
|
2103
2105
|
for (const comment of result.comments) {
|
|
2104
|
-
|
|
2106
|
+
const text = convertMarkdown ? toMarkdown(comment.text) : comment.text;
|
|
2107
|
+
lines.push("", formatCommentHeader(comment), text);
|
|
2105
2108
|
}
|
|
2106
2109
|
return lines.join("\n");
|
|
2107
2110
|
}
|
|
2108
2111
|
function createCommentsListCommand() {
|
|
2109
2112
|
const command = new Command12("list");
|
|
2110
|
-
command.description("List visible comments for a work item").argument("<id>", "work item ID").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--json", "output JSON").action(async (idStr, options) => {
|
|
2113
|
+
command.description("List visible comments for a work item").argument("<id>", "work item ID").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--json", "output JSON").option("--markdown", "convert HTML comment bodies to markdown").action(async (idStr, options) => {
|
|
2111
2114
|
validateOrgProjectPair(options);
|
|
2112
2115
|
const id = parseWorkItemId(idStr);
|
|
2113
2116
|
let context;
|
|
@@ -2125,7 +2128,7 @@ function createCommentsListCommand() {
|
|
|
2125
2128
|
`);
|
|
2126
2129
|
return;
|
|
2127
2130
|
}
|
|
2128
|
-
process.stdout.write(`${formatComments(result)}
|
|
2131
|
+
process.stdout.write(`${formatComments(result, options.markdown === true)}
|
|
2129
2132
|
`);
|
|
2130
2133
|
} catch (err) {
|
|
2131
2134
|
handleCommandError(err, id, context, "read");
|
|
@@ -2135,7 +2138,7 @@ function createCommentsListCommand() {
|
|
|
2135
2138
|
}
|
|
2136
2139
|
function createCommentsAddCommand() {
|
|
2137
2140
|
const command = new Command12("add");
|
|
2138
|
-
command.description("Add a comment to a work item").argument("<id>", "work item ID").argument("<text>", "comment text").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--json", "output JSON").action(async (idStr, text, options) => {
|
|
2141
|
+
command.description("Add a comment to a work item").argument("<id>", "work item ID").argument("<text>", "comment text").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--json", "output JSON").option("--markdown", "post comment as markdown").action(async (idStr, text, options) => {
|
|
2139
2142
|
validateOrgProjectPair(options);
|
|
2140
2143
|
const id = parseWorkItemId(idStr);
|
|
2141
2144
|
if (text.trim() === "") {
|
|
@@ -2145,7 +2148,8 @@ function createCommentsAddCommand() {
|
|
|
2145
2148
|
try {
|
|
2146
2149
|
context = resolveContext(options);
|
|
2147
2150
|
const credential = await resolvePat();
|
|
2148
|
-
const
|
|
2151
|
+
const format = options.markdown === true ? "markdown" : "html";
|
|
2152
|
+
const result = await addWorkItemComment(context, id, credential.pat, text, format);
|
|
2149
2153
|
if (options.json) {
|
|
2150
2154
|
process.stdout.write(`${JSON.stringify(result, null, 2)}
|
|
2151
2155
|
`);
|