azdo-cli 0.2.0-develop.92 → 0.2.0-develop.93
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 +27 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -60,7 +60,7 @@ function buildExtraFields(fields, requested) {
|
|
|
60
60
|
for (const name of requested) {
|
|
61
61
|
const val = fields[name];
|
|
62
62
|
if (val !== void 0 && val !== null) {
|
|
63
|
-
result[name] = String(val);
|
|
63
|
+
result[name] = typeof val === "object" ? JSON.stringify(val) : String(val);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
return Object.keys(result).length > 0 ? result : null;
|
|
@@ -119,7 +119,7 @@ async function getWorkItem(context, id, pat, extraFields) {
|
|
|
119
119
|
}
|
|
120
120
|
let combinedDescription = null;
|
|
121
121
|
if (descriptionParts.length === 1) {
|
|
122
|
-
combinedDescription = descriptionParts
|
|
122
|
+
combinedDescription = descriptionParts.at(0)?.value ?? null;
|
|
123
123
|
} else if (descriptionParts.length > 1) {
|
|
124
124
|
combinedDescription = descriptionParts.map((p) => `<h3>${p.label}</h3>${p.value}`).join("");
|
|
125
125
|
}
|
|
@@ -313,7 +313,7 @@ var patterns = [
|
|
|
313
313
|
];
|
|
314
314
|
function parseAzdoRemote(url) {
|
|
315
315
|
for (const pattern of patterns) {
|
|
316
|
-
const match =
|
|
316
|
+
const match = pattern.exec(url);
|
|
317
317
|
if (match) {
|
|
318
318
|
const project = match[2];
|
|
319
319
|
if (/^DefaultCollection$/i.test(project)) {
|
|
@@ -609,18 +609,18 @@ function parseRequestedFields(raw) {
|
|
|
609
609
|
}
|
|
610
610
|
function stripHtml(html) {
|
|
611
611
|
let text = html;
|
|
612
|
-
text = text.
|
|
613
|
-
text = text.
|
|
614
|
-
text = text.
|
|
615
|
-
text = text.
|
|
616
|
-
text = text.
|
|
617
|
-
text = text.
|
|
618
|
-
text = text.
|
|
619
|
-
text = text.
|
|
620
|
-
text = text.
|
|
621
|
-
text = text.
|
|
622
|
-
text = text.
|
|
623
|
-
text = text.
|
|
612
|
+
text = text.replaceAll(/<h[1-6][^>]*>(.*?)<\/h[1-6]>/gi, "\n--- $1 ---\n");
|
|
613
|
+
text = text.replaceAll(/<br\s*\/?>/gi, "\n");
|
|
614
|
+
text = text.replaceAll(/<\/?(p|div)>/gi, "\n");
|
|
615
|
+
text = text.replaceAll(/<li>/gi, "\n");
|
|
616
|
+
text = text.replaceAll(/<[^>]*>/g, "");
|
|
617
|
+
text = text.replaceAll("&", "&");
|
|
618
|
+
text = text.replaceAll("<", "<");
|
|
619
|
+
text = text.replaceAll(">", ">");
|
|
620
|
+
text = text.replaceAll(""", '"');
|
|
621
|
+
text = text.replaceAll("'", "'");
|
|
622
|
+
text = text.replaceAll(" ", " ");
|
|
623
|
+
text = text.replaceAll(/\n{3,}/g, "\n\n");
|
|
624
624
|
return text.trim();
|
|
625
625
|
}
|
|
626
626
|
function convertRichText(html, markdown) {
|
|
@@ -641,16 +641,19 @@ function summarizeDescription(text, label) {
|
|
|
641
641
|
return [`${label("Description:")}${firstThree.join("\n")}${suffix}`];
|
|
642
642
|
}
|
|
643
643
|
function formatWorkItem(workItem, short, markdown = false) {
|
|
644
|
-
const lines = [];
|
|
645
644
|
const label = (name) => name.padEnd(13);
|
|
646
|
-
lines
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
645
|
+
const lines = [
|
|
646
|
+
`${label("ID:")}${workItem.id}`,
|
|
647
|
+
`${label("Type:")}${workItem.type}`,
|
|
648
|
+
`${label("Title:")}${workItem.title}`,
|
|
649
|
+
`${label("State:")}${workItem.state}`,
|
|
650
|
+
`${label("Assigned To:")}${workItem.assignedTo ?? "Unassigned"}`
|
|
651
|
+
];
|
|
651
652
|
if (!short) {
|
|
652
|
-
lines.push(
|
|
653
|
-
|
|
653
|
+
lines.push(
|
|
654
|
+
`${label("Area:")}${workItem.areaPath}`,
|
|
655
|
+
`${label("Iteration:")}${workItem.iterationPath}`
|
|
656
|
+
);
|
|
654
657
|
}
|
|
655
658
|
lines.push(`${label("URL:")}${workItem.url}`);
|
|
656
659
|
if (workItem.extraFields) {
|
|
@@ -676,7 +679,7 @@ function createGetItemCommand() {
|
|
|
676
679
|
try {
|
|
677
680
|
context = resolveContext(options);
|
|
678
681
|
const credential = await resolvePat();
|
|
679
|
-
const fieldsList = options.fields
|
|
682
|
+
const fieldsList = options.fields === void 0 ? parseRequestedFields(loadConfig().fields) : parseRequestedFields(options.fields);
|
|
680
683
|
const workItem = await getWorkItem(context, id, credential.pat, fieldsList);
|
|
681
684
|
const markdownEnabled = options.markdown ?? loadConfig().markdown ?? false;
|
|
682
685
|
const output = formatWorkItem(workItem, options.short ?? false, markdownEnabled);
|