Skip to content

Commit 3bb1a30

Browse files
author
Al Manning
committed
pass-through updates 2nd pass
1 parent 99e41e4 commit 3bb1a30

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

src/publish/confluence/confluence-helper.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ export const buildContentUpdate = (
260260
parent?: string,
261261
status: ContentStatusEnum = ContentStatusEnum.current,
262262
type: string = PAGE_TYPE,
263-
version: ContentVersion | null = null
263+
version: ContentVersion | null = null,
264+
ancestors: ContentAncestor[] | null = null
264265
): ContentUpdate => {
265266
return {
266267
contentChangeType: ContentChangeType.update,
@@ -269,7 +270,7 @@ export const buildContentUpdate = (
269270
title,
270271
type,
271272
status,
272-
ancestors: parent ? [{ id: parent }] : null,
273+
ancestors: parent ? [{ id: parent }] : ancestors,
273274
body,
274275
fileName,
275276
};
@@ -647,13 +648,28 @@ export const convertForSecondPass = (
647648
}
648649

649650
if (isContentCreate(change)) {
650-
const convertedUpdate = buildContentUpdate(
651-
"fake-id-fixme",
652-
change.title,
653-
change.body, //TODO convert link
654-
change.fileName ?? ""
655-
);
656-
accumulator = [...accumulator, convertedUpdate];
651+
const qmdFileName = change?.fileName?.replace(".xml", ".qmd") ?? "";
652+
const updateId = fileMetadataTable[qmdFileName]?.id;
653+
654+
console.log("change.fileName", change.fileName);
655+
console.log("change.ancestors", change.ancestors);
656+
console.log("fileMetadataTable", fileMetadataTable);
657+
if (updateId) {
658+
const convertedUpdate = buildContentUpdate(
659+
updateId,
660+
change.title,
661+
change.body, //TODO convert links
662+
change.fileName ?? "",
663+
"",
664+
ContentStatusEnum.current,
665+
PAGE_TYPE,
666+
null,
667+
change.ancestors
668+
);
669+
accumulator = [...accumulator, convertedUpdate];
670+
} else {
671+
console.warn("update ID not found for", change.fileName);
672+
}
657673
}
658674

659675
return accumulator;

src/publish/confluence/confluence.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,10 @@ async function publish(
727727
);
728728

729729
console.log("linkUpdateChanges", linkUpdateChanges);
730+
731+
for (let currentChange of linkUpdateChanges) {
732+
await doChange(currentChange);
733+
}
730734
}
731735

732736
const parentPage: Content = await client.getContent(parentId);

tests/unit/confluence.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3740,7 +3740,7 @@ const runConvertForSecondPass = () => {
37403740
parent
37413741
);
37423742
console.log("result", result);
3743-
// assertEquals(expected, result);
3743+
assertEquals(expected, result);
37443744
};
37453745

37463746
test(suiteLabel("no_files"), async () => {

0 commit comments

Comments
 (0)