@repo-toolkit/confluence 0.22.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.
- package/cli.js +21 -1
- package/index.js +21 -1
- package/package.json +2 -2
package/cli.js
CHANGED
|
@@ -1845,7 +1845,8 @@ function validateLocalSync(entries, plan) {
|
|
|
1845
1845
|
const { html, mermaidBlocks } = markdownToStorage(markdown, {
|
|
1846
1846
|
renderHtmlBlocks: plan.renderHtmlBlocks
|
|
1847
1847
|
});
|
|
1848
|
-
const
|
|
1848
|
+
const fileRepositoryUrl = repositoryFileUrl(plan, entry.segments);
|
|
1849
|
+
const body = appendRepositoryNotice(html, fileRepositoryUrl);
|
|
1849
1850
|
const markdownDir = dirname(entry.absolute);
|
|
1850
1851
|
const hasLocalImages = hasLocalImagePlaceholder(body);
|
|
1851
1852
|
const hasMermaidBlocks = mermaidBlocks.length > 0;
|
|
@@ -2514,6 +2515,25 @@ function repositoryNoticeUrl(repositoryUrl, cwd, folder) {
|
|
|
2514
2515
|
}
|
|
2515
2516
|
return trimmedUrl + "/" + encodedFolder;
|
|
2516
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
|
+
}
|
|
2517
2537
|
function repositoryFolderPath(cwd, folder) {
|
|
2518
2538
|
if (folder.length === 0) {
|
|
2519
2539
|
return "";
|
package/index.js
CHANGED
|
@@ -1832,7 +1832,8 @@ function validateLocalSync(entries, plan) {
|
|
|
1832
1832
|
const { html, mermaidBlocks } = markdownToStorage(markdown, {
|
|
1833
1833
|
renderHtmlBlocks: plan.renderHtmlBlocks
|
|
1834
1834
|
});
|
|
1835
|
-
const
|
|
1835
|
+
const fileRepositoryUrl = repositoryFileUrl(plan, entry.segments);
|
|
1836
|
+
const body = appendRepositoryNotice(html, fileRepositoryUrl);
|
|
1836
1837
|
const markdownDir = dirname(entry.absolute);
|
|
1837
1838
|
const hasLocalImages = hasLocalImagePlaceholder(body);
|
|
1838
1839
|
const hasMermaidBlocks = mermaidBlocks.length > 0;
|
|
@@ -2501,6 +2502,25 @@ function repositoryNoticeUrl(repositoryUrl, cwd, folder) {
|
|
|
2501
2502
|
}
|
|
2502
2503
|
return trimmedUrl + "/" + encodedFolder;
|
|
2503
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
|
+
}
|
|
2504
2524
|
function repositoryFolderPath(cwd, folder) {
|
|
2505
2525
|
if (folder.length === 0) {
|
|
2506
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.
|
|
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.
|
|
30
|
+
"@repo-toolkit/publish-package": "0.23.0"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"**/*",
|