azdo-cli 0.13.0 → 0.14.0-032-fix-code-generics.576
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 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1230,14 +1230,34 @@ function isHtml(content) {
|
|
|
1230
1230
|
}
|
|
1231
1231
|
|
|
1232
1232
|
// src/services/md-convert.ts
|
|
1233
|
+
var PLT = "@@PLT@@";
|
|
1234
|
+
var PGT = "@@PGT@@";
|
|
1235
|
+
function escapeAnglesInCodeElements(html) {
|
|
1236
|
+
return html.replace(/<code([^>]*)>([\s\S]*?)<\/code>/gi, (_, attrs, content) => {
|
|
1237
|
+
const safe = content.split("<").join(PLT).split(">").join(PGT).replaceAll("<", "<").replaceAll(">", ">").split(PLT).join("<").split(PGT).join(">");
|
|
1238
|
+
return `<code${attrs}>${safe}</code>`;
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
function escapeAnglesInMarkdownCodeSpans(markdown) {
|
|
1242
|
+
return markdown.replace(/(?<!`)`([^`\n]+)`(?!`)/g, (_, inner) => {
|
|
1243
|
+
const safe = inner.split("<").join(PLT).split(">").join(PGT).replaceAll("<", "<").replaceAll(">", ">").split(PLT).join("<").split(PGT).join(">");
|
|
1244
|
+
return "`" + safe + "`";
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
function decodeEntitiesInMarkdownCodeSpans(text) {
|
|
1248
|
+
return text.replace(/(?<!`)`([^`\n]+)`(?!`)/g, (_, inner) => {
|
|
1249
|
+
const decoded = inner.replaceAll("<", "<").replaceAll(">", ">");
|
|
1250
|
+
return "`" + decoded + "`";
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1233
1253
|
function htmlToMarkdown(html) {
|
|
1234
|
-
return NodeHtmlMarkdown.translate(html);
|
|
1254
|
+
return NodeHtmlMarkdown.translate(escapeAnglesInCodeElements(html));
|
|
1235
1255
|
}
|
|
1236
1256
|
function toMarkdown(content) {
|
|
1237
1257
|
if (isHtml(content)) {
|
|
1238
1258
|
return htmlToMarkdown(content);
|
|
1239
1259
|
}
|
|
1240
|
-
return content;
|
|
1260
|
+
return decodeEntitiesInMarkdownCodeSpans(content);
|
|
1241
1261
|
}
|
|
1242
1262
|
|
|
1243
1263
|
// src/services/command-helpers.ts
|
|
@@ -2675,8 +2695,9 @@ function createSetMdFieldCommand() {
|
|
|
2675
2695
|
try {
|
|
2676
2696
|
context = resolveContext(options);
|
|
2677
2697
|
const credential = await requireAuthCredential(context.org);
|
|
2698
|
+
const safeContent = escapeAnglesInMarkdownCodeSpans(content);
|
|
2678
2699
|
const operations = [
|
|
2679
|
-
{ op: "add", path: `/fields/${field}`, value:
|
|
2700
|
+
{ op: "add", path: `/fields/${field}`, value: safeContent },
|
|
2680
2701
|
{ op: "add", path: `/multilineFieldsFormat/${field}`, value: "Markdown" }
|
|
2681
2702
|
];
|
|
2682
2703
|
const result = await updateWorkItem(context, id, credential, field, operations);
|
|
@@ -5074,10 +5095,10 @@ async function addWorkItemRelation(context, cred, type, id1, id2) {
|
|
|
5074
5095
|
const relType = await resolveRelationType(context, cred, type);
|
|
5075
5096
|
const workItem = await getWorkItemWithRelations(context, cred, id1);
|
|
5076
5097
|
const targetUrl = `https://dev.azure.com/${encodeURIComponent(context.org)}/_apis/wit/workItems/${id2}`;
|
|
5077
|
-
const
|
|
5078
|
-
(r) => r.rel === relType.referenceName && r.url
|
|
5098
|
+
const exists = (workItem.relations ?? []).some(
|
|
5099
|
+
(r) => r.rel === relType.referenceName && parseTargetId(r.url) === id2
|
|
5079
5100
|
);
|
|
5080
|
-
if (
|
|
5101
|
+
if (exists) {
|
|
5081
5102
|
return { status: "already_exists", type: relType.name, referenceName: relType.referenceName, id1, id2 };
|
|
5082
5103
|
}
|
|
5083
5104
|
const patchUrl = buildWorkItemUrl2(context, id1);
|