ai-project-manage-cli 3.0.8 → 3.0.9

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.
Files changed (2) hide show
  1. package/dist/index.js +21 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -516,6 +516,26 @@ function tasksForStatusYaml(tasks) {
516
516
  executor: t.executorType
517
517
  }));
518
518
  }
519
+ function escapeForCdata(text) {
520
+ return text.replace(/\]\]>/g, "]]]]><![CDATA[>");
521
+ }
522
+ function defectsToXml(defects) {
523
+ const sorted = [...defects].sort(
524
+ (a, b) => new Date(a.createdAt ?? 0).getTime() - new Date(b.createdAt ?? 0).getTime()
525
+ );
526
+ const lines = ["<defects>"];
527
+ for (const d of sorted) {
528
+ lines.push(` <defect id="${xmlEscape(d.id)}">`);
529
+ lines.push(` <status>${xmlEscape(d.status)}</status>`);
530
+ lines.push(` <current><![CDATA[${escapeForCdata(d.currentState ?? "")}]]></current>`);
531
+ lines.push(
532
+ ` <expected><![CDATA[${escapeForCdata(d.expectedEffect ?? "")}]]></expected>`
533
+ );
534
+ lines.push(` </defect>`);
535
+ }
536
+ lines.push("</defects>", "");
537
+ return lines.join("\n");
538
+ }
519
539
  async function runPull(requirementId) {
520
540
  const cfg = await ensureLoggedConfig();
521
541
  const api = createApmApiClient(cfg);
@@ -560,7 +580,7 @@ async function runPull(requirementId) {
560
580
  ""
561
581
  ].join("\n");
562
582
  writeFileSync3(join4(WORKITEMS_DIR, "reviews.xml"), reviewsXml, "utf8");
563
- const defectsXml = unknownArrayToXml("defects", "defect", data.defects ?? []);
583
+ const defectsXml = defectsToXml(data.defects ?? []);
564
584
  writeFileSync3(join4(WORKITEMS_DIR, "defect.xml"), defectsXml, "utf8");
565
585
  const testCasesXml = unknownArrayToXml(
566
586
  "testcases",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "3.0.8",
3
+ "version": "3.0.9",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,