@repo-toolkit/confluence 0.21.0 → 0.23.0

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 (3) hide show
  1. package/cli.js +23 -11
  2. package/index.js +23 -11
  3. package/package.json +2 -2
package/cli.js CHANGED
@@ -1761,11 +1761,7 @@ function renderParentSummary(input) {
1761
1761
  if (input.repositoryUrl) {
1762
1762
  const url = escapeXmlAttribute(input.repositoryUrl);
1763
1763
  const text = escapeHtml(input.repositoryUrl);
1764
- lines.push(
1765
- `<p><em>This documentation subtree is synced from <a href="${url}">${text}</a> and maintained by <code>repo-toolkit-confluence</code>.</em></p>`
1766
- );
1767
- } else {
1768
- lines.push("<p><em>This documentation subtree is maintained by <code>repo-toolkit-confluence</code>.</em></p>");
1764
+ lines.push(`<p><em>This documentation subtree is synced from <a href="${url}">${text}</a>.</em></p>`);
1769
1765
  }
1770
1766
  lines.push("<h3>Statistics</h3>");
1771
1767
  lines.push("<ul>");
@@ -1782,10 +1778,6 @@ function renderParentSummary(input) {
1782
1778
  } else {
1783
1779
  lines.push(renderTree(input.pages));
1784
1780
  }
1785
- lines.push("<h3>Ownership</h3>");
1786
- lines.push(
1787
- `<p>All generated pages carry the <code>${CONFLUENCE_MANAGED_LABEL}</code> label. On default sync, stale labeled pages not in the local tree are pruned; unlabeled pages are preserved. Use <code>clean: true</code> to move all safely deletable page descendants to trash before recreation.</p>`
1788
- );
1789
1781
  lines.push(PARENT_SUMMARY_END_MARKER);
1790
1782
  return lines.join("\n");
1791
1783
  }
@@ -1823,7 +1815,7 @@ function renderTree(pages) {
1823
1815
  const kindLabel = rec.kind === "directory" ? "directory" : "page";
1824
1816
  const pathCode = `<code>${escapeHtml(rec.relativePath)}</code>`;
1825
1817
  const childrenHtml = renderNode(child);
1826
- html += `<li>${link} \u2014 ${pathCode} <em>(${kindLabel})</em>${childrenHtml}</li>`;
1818
+ html += `<li>${link} ${pathCode} <em>(${kindLabel})</em>${childrenHtml}</li>`;
1827
1819
  } else {
1828
1820
  const childrenHtml = renderNode(child);
1829
1821
  html += `<li>${escapeHtml(child.key)}${childrenHtml}</li>`;
@@ -1853,7 +1845,8 @@ function validateLocalSync(entries, plan) {
1853
1845
  const { html, mermaidBlocks } = markdownToStorage(markdown, {
1854
1846
  renderHtmlBlocks: plan.renderHtmlBlocks
1855
1847
  });
1856
- const body = appendRepositoryNotice(html, plan.repositoryUrl);
1848
+ const fileRepositoryUrl = repositoryFileUrl(plan, entry.segments);
1849
+ const body = appendRepositoryNotice(html, fileRepositoryUrl);
1857
1850
  const markdownDir = dirname(entry.absolute);
1858
1851
  const hasLocalImages = hasLocalImagePlaceholder(body);
1859
1852
  const hasMermaidBlocks = mermaidBlocks.length > 0;
@@ -2522,6 +2515,25 @@ function repositoryNoticeUrl(repositoryUrl, cwd, folder) {
2522
2515
  }
2523
2516
  return trimmedUrl + "/" + encodedFolder;
2524
2517
  }
2518
+ function repositoryFileUrl(plan, segments) {
2519
+ if (plan.repositoryUrl.length === 0) {
2520
+ return "";
2521
+ }
2522
+ const encodedSegments = segments.map(encodeURIComponent).join("/");
2523
+ if (plan.repositoryUrl.includes("/tree/HEAD/") || plan.repositoryUrl.includes("/blob/HEAD/")) {
2524
+ const baseBlob = plan.repositoryUrl.replace("/tree/HEAD/", "/blob/HEAD/");
2525
+ return baseBlob.replace(/\/+$/, "") + "/" + encodedSegments;
2526
+ }
2527
+ const folderPath = repositoryFolderPath(plan.cwd, plan.folder);
2528
+ const trimmedBase = plan.repositoryUrl.replace(/\/+$/, "").replace(/\.git$/, "");
2529
+ const isGithub = /^https?:\/\/github\.com\//i.test(trimmedBase);
2530
+ if (isGithub) {
2531
+ const fullPath = folderPath ? folderPath + "/" + segments.join("/") : segments.join("/");
2532
+ const encodedFull = fullPath.split("/").map(encodeURIComponent).join("/");
2533
+ return trimmedBase + "/blob/HEAD/" + encodedFull;
2534
+ }
2535
+ return plan.repositoryUrl.replace(/\/+$/, "") + "/" + encodedSegments;
2536
+ }
2525
2537
  function repositoryFolderPath(cwd, folder) {
2526
2538
  if (folder.length === 0) {
2527
2539
  return "";
package/index.js CHANGED
@@ -1747,11 +1747,7 @@ function renderParentSummary(input) {
1747
1747
  if (input.repositoryUrl) {
1748
1748
  const url = escapeXmlAttribute(input.repositoryUrl);
1749
1749
  const text = escapeHtml(input.repositoryUrl);
1750
- lines.push(
1751
- `<p><em>This documentation subtree is synced from <a href="${url}">${text}</a> and maintained by <code>repo-toolkit-confluence</code>.</em></p>`
1752
- );
1753
- } else {
1754
- lines.push("<p><em>This documentation subtree is maintained by <code>repo-toolkit-confluence</code>.</em></p>");
1750
+ lines.push(`<p><em>This documentation subtree is synced from <a href="${url}">${text}</a>.</em></p>`);
1755
1751
  }
1756
1752
  lines.push("<h3>Statistics</h3>");
1757
1753
  lines.push("<ul>");
@@ -1768,10 +1764,6 @@ function renderParentSummary(input) {
1768
1764
  } else {
1769
1765
  lines.push(renderTree(input.pages));
1770
1766
  }
1771
- lines.push("<h3>Ownership</h3>");
1772
- lines.push(
1773
- `<p>All generated pages carry the <code>${CONFLUENCE_MANAGED_LABEL}</code> label. On default sync, stale labeled pages not in the local tree are pruned; unlabeled pages are preserved. Use <code>clean: true</code> to move all safely deletable page descendants to trash before recreation.</p>`
1774
- );
1775
1767
  lines.push(PARENT_SUMMARY_END_MARKER);
1776
1768
  return lines.join("\n");
1777
1769
  }
@@ -1809,7 +1801,7 @@ function renderTree(pages) {
1809
1801
  const kindLabel = rec.kind === "directory" ? "directory" : "page";
1810
1802
  const pathCode = `<code>${escapeHtml(rec.relativePath)}</code>`;
1811
1803
  const childrenHtml = renderNode(child);
1812
- html += `<li>${link} \u2014 ${pathCode} <em>(${kindLabel})</em>${childrenHtml}</li>`;
1804
+ html += `<li>${link} ${pathCode} <em>(${kindLabel})</em>${childrenHtml}</li>`;
1813
1805
  } else {
1814
1806
  const childrenHtml = renderNode(child);
1815
1807
  html += `<li>${escapeHtml(child.key)}${childrenHtml}</li>`;
@@ -1840,7 +1832,8 @@ function validateLocalSync(entries, plan) {
1840
1832
  const { html, mermaidBlocks } = markdownToStorage(markdown, {
1841
1833
  renderHtmlBlocks: plan.renderHtmlBlocks
1842
1834
  });
1843
- const body = appendRepositoryNotice(html, plan.repositoryUrl);
1835
+ const fileRepositoryUrl = repositoryFileUrl(plan, entry.segments);
1836
+ const body = appendRepositoryNotice(html, fileRepositoryUrl);
1844
1837
  const markdownDir = dirname(entry.absolute);
1845
1838
  const hasLocalImages = hasLocalImagePlaceholder(body);
1846
1839
  const hasMermaidBlocks = mermaidBlocks.length > 0;
@@ -2509,6 +2502,25 @@ function repositoryNoticeUrl(repositoryUrl, cwd, folder) {
2509
2502
  }
2510
2503
  return trimmedUrl + "/" + encodedFolder;
2511
2504
  }
2505
+ function repositoryFileUrl(plan, segments) {
2506
+ if (plan.repositoryUrl.length === 0) {
2507
+ return "";
2508
+ }
2509
+ const encodedSegments = segments.map(encodeURIComponent).join("/");
2510
+ if (plan.repositoryUrl.includes("/tree/HEAD/") || plan.repositoryUrl.includes("/blob/HEAD/")) {
2511
+ const baseBlob = plan.repositoryUrl.replace("/tree/HEAD/", "/blob/HEAD/");
2512
+ return baseBlob.replace(/\/+$/, "") + "/" + encodedSegments;
2513
+ }
2514
+ const folderPath = repositoryFolderPath(plan.cwd, plan.folder);
2515
+ const trimmedBase = plan.repositoryUrl.replace(/\/+$/, "").replace(/\.git$/, "");
2516
+ const isGithub = /^https?:\/\/github\.com\//i.test(trimmedBase);
2517
+ if (isGithub) {
2518
+ const fullPath = folderPath ? folderPath + "/" + segments.join("/") : segments.join("/");
2519
+ const encodedFull = fullPath.split("/").map(encodeURIComponent).join("/");
2520
+ return trimmedBase + "/blob/HEAD/" + encodedFull;
2521
+ }
2522
+ return plan.repositoryUrl.replace(/\/+$/, "") + "/" + encodedSegments;
2523
+ }
2512
2524
  function repositoryFolderPath(cwd, folder) {
2513
2525
  if (folder.length === 0) {
2514
2526
  return "";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@repo-toolkit/confluence",
3
3
  "description": "Sync a folder of markdown docs to Confluence pages and attachments (GitHub Action compatible)",
4
- "version": "0.21.0",
4
+ "version": "0.23.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "keywords": [
@@ -27,7 +27,7 @@
27
27
  "node": ">=20"
28
28
  },
29
29
  "dependencies": {
30
- "@repo-toolkit/publish-package": "0.21.0"
30
+ "@repo-toolkit/publish-package": "0.23.0"
31
31
  },
32
32
  "files": [
33
33
  "**/*",