feat(samples): expand sample to include full publishing

This commit is contained in:
Rodweil, Theodor 2023-08-14 03:39:49 +02:00
parent 496d70360b
commit 4b458df7c1
No known key found for this signature in database
GPG key ID: F8BC1B0EB1F9CCF5
4 changed files with 152 additions and 39 deletions

View file

@ -2,12 +2,20 @@
"Pages": [ "Pages": [
{ {
"Title": "Default Sample~", "Title": "Default Sample~",
"Hash": "4E4884BA3DEB5FE39C86E41507F3335C37A6D12895236D673BFA1C101ADAF6FF",
"Id": "789703362",
"Version": 1,
"_Ref": "pages/Default+Sample~.xml",
"Ref": "pages/Default+Sample~.xml" "Ref": "pages/Default+Sample~.xml"
}, },
{ {
"Title": "Cats", "Title": "Cats",
"Ref": "pages/Cats.xml", "AncestorTitle": "Default Sample~",
"AncestorTitle": "Default Sample~" "Hash": "7AC678181A472E7F1B962566E9F9CACA1B5C35C055775692970A101B3C70985A",
"Id": "789703374",
"Version": 2,
"_Ref": "pages/Cats.xml",
"Ref": "pages/Cats.xml"
} }
], ],
"Attachments": [ "Attachments": [
@ -15,19 +23,31 @@
"Name": "pexels-just-a-couple-photos-3777622.jpg", "Name": "pexels-just-a-couple-photos-3777622.jpg",
"ContainerPageTitle": "Cats", "ContainerPageTitle": "Cats",
"MimeType": "image/jpeg", "MimeType": "image/jpeg",
"Ref": "attachments/Cats/pexels-just-a-couple-photos-3777622.jpg" "_Ref": "attachments/Cats/pexels-just-a-couple-photos-3777622.jpg",
"Ref": "attachments/Cats/pexels-just-a-couple-photos-3777622.jpg",
"Id": null,
"Version": null,
"Hash": "FF90EF756F8C28433CF74AA039ABC0681FAE17D7A925498F00ACB9774AC8FF31"
}, },
{ {
"Name": "pexels-sami-aksu-14356302.jpg", "Name": "pexels-sami-aksu-14356302.jpg",
"ContainerPageTitle": "Cats", "ContainerPageTitle": "Cats",
"MimeType": "image/jpeg", "MimeType": "image/jpeg",
"Ref": "attachments/Cats/pexels-sami-aksu-14356302.jpg" "_Ref": "attachments/Cats/pexels-sami-aksu-14356302.jpg",
"Ref": "attachments/Cats/pexels-sami-aksu-14356302.jpg",
"Id": null,
"Version": null,
"Hash": "4A0DF56CAC53F413371CDB7FA1A8F66455B0060D0B5F9D41B2468DE08D11C7EF"
}, },
{ {
"Name": "objects.inv", "Name": "objects.inv",
"ContainerPageTitle": "Default Sample~", "ContainerPageTitle": "Default Sample~",
"MimeType": "application/octet-stream", "MimeType": "application/octet-stream",
"Ref": "attachments/Default+Sample~/objects.inv" "_Ref": "attachments/Default+Sample~/objects.inv",
"Ref": "attachments/Default+Sample~/objects.inv",
"Id": null,
"Version": null,
"Hash": "24FD5FA3627643C373552861775BF930B7AF5195376E481F9919FB08E06C0CA6"
} }
] ]
} }

View file

@ -0,0 +1,53 @@
{
"Pages": [
{
"Title": "Default Sample~",
"Hash": "4E4884BA3DEB5FE39C86E41507F3335C37A6D12895236D673BFA1C101ADAF6FF",
"Id": "789703362",
"Version": 1,
"_Ref": "pages/Default+Sample~.xml",
"Ref": "pages/Default+Sample~.xml"
},
{
"Title": "Cats",
"AncestorTitle": "Default Sample~",
"Hash": "7AC678181A472E7F1B962566E9F9CACA1B5C35C055775692970A101B3C70985A",
"Id": "789703374",
"Version": 2,
"_Ref": "pages/Cats.xml",
"Ref": "pages/Cats.xml"
}
],
"Attachments": [
{
"Name": "pexels-just-a-couple-photos-3777622.jpg",
"ContainerPageTitle": "Cats",
"MimeType": "image/jpeg",
"_Ref": "attachments/Cats/pexels-just-a-couple-photos-3777622.jpg",
"Ref": "attachments/Cats/pexels-just-a-couple-photos-3777622.jpg",
"Id": null,
"Version": null,
"Hash": "FF90EF756F8C28433CF74AA039ABC0681FAE17D7A925498F00ACB9774AC8FF31"
},
{
"Name": "pexels-sami-aksu-14356302.jpg",
"ContainerPageTitle": "Cats",
"MimeType": "image/jpeg",
"_Ref": "attachments/Cats/pexels-sami-aksu-14356302.jpg",
"Ref": "attachments/Cats/pexels-sami-aksu-14356302.jpg",
"Id": null,
"Version": null,
"Hash": "4A0DF56CAC53F413371CDB7FA1A8F66455B0060D0B5F9D41B2468DE08D11C7EF"
},
{
"Name": "objects.inv",
"ContainerPageTitle": "Default Sample~",
"MimeType": "application/octet-stream",
"_Ref": "attachments/Default+Sample~/objects.inv",
"Ref": "attachments/Default+Sample~/objects.inv",
"Id": null,
"Version": null,
"Hash": "24FD5FA3627643C373552861775BF930B7AF5195376E481F9919FB08E06C0CA6"
}
]
}

View file

@ -12,29 +12,69 @@ Param(
[Parameter(Mandatory)] [String] $Hostname, [Parameter(Mandatory)] [String] $Hostname,
[Parameter(Mandatory)] [String] $Space, [Parameter(Mandatory)] [String] $Space,
[Parameter(Mandatory)] [String] $PersonalAccessToken, [Parameter(Mandatory)] [String] $PersonalAccessToken,
[Parameter()] [String] $ManifestFile = 'data/manifest.json' [Parameter()] [String] $ManifestFile = "$PSScriptRoot/data/manifest.json"
) )
$ErrorActionPreference = "Stop"
$DebugPreference = 'Continue'
Import-Module "$PSScriptRoot/../../src/PSConfluencePublisher.psd1" Import-Module "$PSScriptRoot/../../src/PSConfluencePublisher.psd1"
# create a high-level manifest pseudo-object Write-Host "initializing manifest..."
# create a high-level manifest pseudo-object. As mentioned, this is just a
# pseduo-object to organize things a little better.
$manifest = Initialize-Manifest -Path $ManifestFile $manifest = Initialize-Manifest -Path $ManifestFile
# create a high-level connection pseudo-object Write-Host "initializing and testing connectivity..."
# create a high-level connection pseudo-object. As mentioned, this is just a
# pseduo-object to organize things a little better.
$connection = Initialize-Connection ` $connection = Initialize-Connection `
-Host $Hostname ` -Host $Hostname `
-Space $Space ` -Space $Space `
-PersonalAccessToken $PersonalAccessToken -PersonalAccessToken $PersonalAccessToken
Write-Host "fetching pages metadata..."
# unidirectionally synchronize all remote metadata to local (in-memory) manifest # unidirectionally synchronize all remote metadata to local (in-memory) manifest
$manifest.Manifest.Pages = Get-PageMeta ` $manifest.Manifest.Pages = Get-PageMeta `
-Host $Hostname ` -Host $Hostname `
-Manifest $manifest.Manifest.Pages ` -Manifest $manifest.Manifest.Pages `
-Space $Space ` -Space $Space `
Write-Host "publishing pages ($($manifest.Manifest.Pages.Count))..."
# publish all pages listed in manifest
Publish-Pages `
-Manifest $manifest `
-Connection $connection
Write-Host "fetching attachments metadata..."
# unidirectionally synchronize all remote attachment metadata to local
# (in-memory) manifest
$manifest.Manifest.Attachments = Get-AttachmentMeta `
-Host $Hostname `
-Manifest $manifest.Manifest.Attachments `
-Index $manifest.Index.Attachments `
-PagesManifest $manifest.Manifest.Pages `
-PagesIndex $manifest.Index.Pages `
-Space $Space `
-Force -Force
Write-Host "publishing attachments ($($manifest.Manifest.Attachments.Count))..."
# publish all pages listed in manifest
Publish-Attachments `
-Manifest $manifest `
-Connection $connection
Write-Host "dumping manifest to filesystem..."
# write back to disk # write back to disk
Set-Manifest ` Set-Manifest `
-Manifest $manifest.Manifest ` -Manifest $manifest.Manifest `
-File $manifest.Path ` -File $manifest.Path `
-Backup $true -Backup $true | Out-Null