diff --git a/.gitignore b/.gitignore index ac25485..e992d25 100755 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,11 @@ + +.DS_Store +/test-reports/ +/dist/ + +# FAT stuff (in a filesystem sense) /_* /._* -.DS_Store #vim cache *.swp diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..f092929 --- /dev/null +++ b/LICENSE @@ -0,0 +1,41 @@ +DL-DE->BY-2.0 +Datenlizenz Deutschland – Namensnennung – Version 2.0 + +(1) Jede Nutzung ist unter den Bedingungen dieser „Datenlizenz Deutschland – Namensnennung – Version 2.0" zulässig. + +Die bereitgestellten Daten und Metadaten dürfen für die kommerzielle und nicht kommerzielle Nutzung insbesondere + + vervielfältigt, ausgedruckt, präsentiert, verändert, bearbeitet sowie an Dritte übermittelt werden; + mit eigenen Daten und Daten Anderer zusammengeführt und zu selbständigen neuen Datensätzen verbunden werden; + in interne und externe Geschäftsprozesse, Produkte und Anwendungen in öffentlichen und nicht öffentlichen elektronischen Netzwerken eingebunden werden. + +(2) Bei der Nutzung ist sicherzustellen, dass folgende Angaben als Quellenvermerk enthalten sind: + + Bezeichnung des Bereitstellers nach dessen Maßgabe, + der Vermerk „Datenlizenz Deutschland – Namensnennung – Version 2.0" oder „dl-de/by-2-0" mit Verweis auf den Lizenztext unter www.govdata.de/dl-de/by-2-0 sowie + einen Verweis auf den Datensatz (URI). + +Dies gilt nur soweit die datenhaltende Stelle die Angaben 1. bis 3. zum Quellenvermerk bereitstellt. + +(3) Veränderungen, Bearbeitungen, neue Gestaltungen oder sonstige Abwandlungen sind im Quellenvermerk mit dem Hinweis zu versehen, dass die Daten geändert wurden. + + +Data licence Germany – attribution – version 2.0 + +(1) Any use will be permitted provided it fulfils the requirements of this "Data licence Germany – attribution – Version 2.0". + +The data and meta-data provided may, for commercial and non-commercial use, in particular + + be copied, printed, presented, altered, processed and transmitted to third parties; + be merged with own data and with the data of others and be combined to form new and independent datasets; + be integrated in internal and external business processes, products and applications in public and non-public electronic networks. + +(2) The user must ensure that the source note contains the following information: + + the name of the provider, + the annotation "Data licence Germany – attribution – Version 2.0" or "dl-de/by-2-0" referring to the licence text available at www.govdata.de/dl-de/by-2-0, and + a reference to the dataset (URI). + +This applies only if the entity keeping the data provides the pieces of information 1-3 for the source note. + +(3) Changes, editing, new designs or other amendments must be marked as such in the source note. diff --git a/PSConfluencePublisher.nuspec b/PSConfluencePublisher.nuspec index e7d0244..d05d7ad 100755 --- a/PSConfluencePublisher.nuspec +++ b/PSConfluencePublisher.nuspec @@ -1,14 +1,19 @@ - PSConfluencePublisher + victorykit.PSConfluencePublisher + victorykit.PSConfluencePublisher 1.1.0 standalone publisher for xconfluencebuilder - theodor.rodweil@victory-k.it + Victory Karma IT Theodor Rodweil DL-DE-BY-2.0 - README.md + .\README.md Victory Karma IT - Powershell Confluence Publisher + PowerShell + + + + diff --git a/samples/default/README.md b/samples/default/README.md new file mode 100755 index 0000000..a3735e4 --- /dev/null +++ b/samples/default/README.md @@ -0,0 +1,31 @@ +# Default Sample + +This is a sample/reference implementation for showing the usage of +PSConfluencePublisher. + +The sample provides sample data, which was generated by a sample of the +[victorykit-xconfluencebuilder](https://bitbucket.org/victorykit/xconfluencebuilder). +The data can be found inside the `data/` directory. + +## Usage + +To get started, first identify your Confluence instance and make sure you have +the following data at hand: + +* Hostname of Confluence instance +* URL of parent/root page to publish to (you can copy it directly from your + browser) +* personal access token + +Next, make sure you changed your working directory to this directory +(`samples/default/`, navigating from the root of the repository). + +Now, import the module by executing the following: + +``` +Import-Module ../../tools/PSConfluencePublisher.psd1 +``` + +``` +$manifest = Get-Manifest -File data/manifest.json +``` diff --git a/samples/default/confluence.out/._.DS_Store b/samples/default/data/._.DS_Store similarity index 100% rename from samples/default/confluence.out/._.DS_Store rename to samples/default/data/._.DS_Store diff --git a/samples/default/confluence.out/._manifest.json b/samples/default/data/._manifest.json similarity index 100% rename from samples/default/confluence.out/._manifest.json rename to samples/default/data/._manifest.json diff --git a/samples/default/confluence.out/attachments/._pexels-just-a-couple-photos-3777622.jpg b/samples/default/data/attachments/._pexels-just-a-couple-photos-3777622.jpg similarity index 100% rename from samples/default/confluence.out/attachments/._pexels-just-a-couple-photos-3777622.jpg rename to samples/default/data/attachments/._pexels-just-a-couple-photos-3777622.jpg diff --git a/samples/default/confluence.out/attachments/._pexels-sami-aksu-14356302.jpg b/samples/default/data/attachments/._pexels-sami-aksu-14356302.jpg similarity index 100% rename from samples/default/confluence.out/attachments/._pexels-sami-aksu-14356302.jpg rename to samples/default/data/attachments/._pexels-sami-aksu-14356302.jpg diff --git a/samples/default/confluence.out/attachments/objects.inv b/samples/default/data/attachments/objects.inv similarity index 100% rename from samples/default/confluence.out/attachments/objects.inv rename to samples/default/data/attachments/objects.inv diff --git a/samples/default/confluence.out/attachments/pexels-just-a-couple-photos-3777622.jpg b/samples/default/data/attachments/pexels-just-a-couple-photos-3777622.jpg similarity index 100% rename from samples/default/confluence.out/attachments/pexels-just-a-couple-photos-3777622.jpg rename to samples/default/data/attachments/pexels-just-a-couple-photos-3777622.jpg diff --git a/samples/default/confluence.out/attachments/pexels-sami-aksu-14356302.jpg b/samples/default/data/attachments/pexels-sami-aksu-14356302.jpg similarity index 100% rename from samples/default/confluence.out/attachments/pexels-sami-aksu-14356302.jpg rename to samples/default/data/attachments/pexels-sami-aksu-14356302.jpg diff --git a/samples/default/confluence.out/manifest.json b/samples/default/data/manifest.json similarity index 100% rename from samples/default/confluence.out/manifest.json rename to samples/default/data/manifest.json diff --git a/samples/default/confluence.out/pages/Cats.xml b/samples/default/data/pages/Cats.xml similarity index 100% rename from samples/default/confluence.out/pages/Cats.xml rename to samples/default/data/pages/Cats.xml diff --git a/samples/default/confluence.out/pages/Default+Sample~.xml b/samples/default/data/pages/Default+Sample~.xml similarity index 100% rename from samples/default/confluence.out/pages/Default+Sample~.xml rename to samples/default/data/pages/Default+Sample~.xml diff --git a/scripts/._analyze.ps1 b/scripts/._analyze.ps1 new file mode 100755 index 0000000..056a38b Binary files /dev/null and b/scripts/._analyze.ps1 differ diff --git a/scripts/._clean.ps1 b/scripts/._clean.ps1 new file mode 100755 index 0000000..056a38b Binary files /dev/null and b/scripts/._clean.ps1 differ diff --git a/scripts/._test.ps1 b/scripts/._test.ps1 new file mode 100755 index 0000000..056a38b Binary files /dev/null and b/scripts/._test.ps1 differ diff --git a/scripts/analyze.ps1 b/scripts/analyze.ps1 new file mode 100755 index 0000000..471faac --- /dev/null +++ b/scripts/analyze.ps1 @@ -0,0 +1,16 @@ +#! /usr/bin/pwsh + +Set-StrictMode -Version Latest + +$ErrorActionPreference = 'Stop' + +$ErrorView = "NormalView" + +$basePath = Join-Path $PSScriptRoot '..' + +Import-Module PSScriptAnalyzer -ErrorAction Stop -Force + +Invoke-ScriptAnalyzer ` + -Path (Join-Path -Path $basePath 'src') ` + -Settings PSGallery ` + -Recurse diff --git a/scripts/clean.ps1 b/scripts/clean.ps1 new file mode 100755 index 0000000..6cb668a --- /dev/null +++ b/scripts/clean.ps1 @@ -0,0 +1,22 @@ +#! /usr/bin/pwsh + +Set-StrictMode -Version Latest + +$ErrorActionPreference = 'Stop' + +$ErrorView = "NormalView" + +$basePath = Join-Path $PSScriptRoot '..' + +@( + 'dist', + 'test-reports' +) | ForEach { + $path = Join-Path $basePath $_ + + If (-Not (Test-Path $path)) {return} + + Write-Host "rm: $(Resolve-Path $path)" + + Remove-Item -Recurse -Force ($path) +} diff --git a/scripts/pack.ps1 b/scripts/pack.ps1 new file mode 100755 index 0000000..ddd90e9 --- /dev/null +++ b/scripts/pack.ps1 @@ -0,0 +1,12 @@ +#! /usr/bin/pwsh + +Set-StrictMode -Version Latest + +$ErrorActionPreference = 'Stop' + +$ErrorView = "NormalView" + +$basePath = Join-Path $PSScriptRoot '..' + +nuget pack (Join-Path $basePath 'PSConfluencePublisher.nuspec') ` + -OutputDirectory (Join-Path $basePath 'dist') diff --git a/scripts/test.ps1 b/scripts/test.ps1 new file mode 100755 index 0000000..9ce45d9 --- /dev/null +++ b/scripts/test.ps1 @@ -0,0 +1,36 @@ +#! /usr/bin/pwsh + +Set-StrictMode -Version Latest + +$ErrorActionPreference = 'Stop' + +$ErrorView = "NormalView" + +Import-Module Pester -ErrorAction Stop -Force + +Invoke-Pester -Configuration @{ + 'Debug' = @{ + 'ShowFullErrors' = $false + 'ShowNavigationMarkers' = $false + 'WriteDebugMessagesFrom' = 'CodeCoverage' + } + 'Output' = @{ + 'Verbosity' = 'Normal' + } + 'Run' = @{ + 'Path' = Join-Path $PSScriptRoot '..' 'tests' '*' + 'Exit' = $true + 'PassThru' = $true + } + 'CodeCoverage' = @{ + 'Enabled' = $true + 'Path' = Join-Path $PSScriptRoot '..' 'src' '*' + 'OutputPath' = Join-Path $PSScriptRoot '..' 'test-reports' ` + 'coverage.xml' + } + 'TestResult' = @{ + 'Enabled' = $true + 'OutputPath' = Join-Path $PSScriptRoot '..' 'test-reports' 'testResults.xml' + } +} + diff --git a/src/._PSConfluencePublisher.psd1 b/src/._PSConfluencePublisher.psd1 new file mode 100755 index 0000000..e72da3a Binary files /dev/null and b/src/._PSConfluencePublisher.psd1 differ diff --git a/tools/Connection.psm1 b/src/Connection.psm1 similarity index 100% rename from tools/Connection.psm1 rename to src/Connection.psm1 diff --git a/tools/Manifest.psm1 b/src/Manifest.psm1 similarity index 98% rename from tools/Manifest.psm1 rename to src/Manifest.psm1 index e331ec5..d5627ea 100755 --- a/tools/Manifest.psm1 +++ b/src/Manifest.psm1 @@ -3,7 +3,7 @@ $ErrorActionPreference = "Stop" $script:schema = Get-Content ( - Join-Path $PSScriptRoot 'manifest.schema.json' + Join-Path -Path $PSScriptRoot 'schemas' 'manifest.schema.json' ) | Out-String @@ -32,12 +32,12 @@ function Get-Manifest { Write-Debug $_ - $raw = '{"pages":{}, "attachments": {}}' + $raw = '{"Pages":[], "attachments": []}' } $raw | Test-JSON -Schema $script:schema | Out-Null - $data = $raw | ConvertFrom-JSON + $raw | ConvertFrom-JSON } } diff --git a/tools/PSConfluencePublisher.psd1 b/src/PSConfluencePublisher.psd1 similarity index 99% rename from tools/PSConfluencePublisher.psd1 rename to src/PSConfluencePublisher.psd1 index 9c57f25..5fab2db 100755 --- a/tools/PSConfluencePublisher.psd1 +++ b/src/PSConfluencePublisher.psd1 @@ -65,7 +65,7 @@ RootModule = 'PSConfluencePublisher.psm1' 'Manifest.psm1', 'Page.psm1', 'PageMeta.psm1', - 'String.psm1' + 'StringHelper.psm1' ) # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. diff --git a/tools/PSConfluencePublisher.psm1 b/src/PSConfluencePublisher.psm1 similarity index 100% rename from tools/PSConfluencePublisher.psm1 rename to src/PSConfluencePublisher.psm1 diff --git a/tools/Page.psm1 b/src/Page.psm1 similarity index 100% rename from tools/Page.psm1 rename to src/Page.psm1 diff --git a/tools/PageMeta.psm1 b/src/PageMeta.psm1 similarity index 98% rename from tools/PageMeta.psm1 rename to src/PageMeta.psm1 index 21e0a8a..cb998ba 100755 --- a/tools/PageMeta.psm1 +++ b/src/PageMeta.psm1 @@ -122,7 +122,7 @@ function Get-PageMeta { Update-PageMeta ` -Id $results[0].id ` - -Version ($results[0]._expandable | Select -ExpandProperty 'version') ` + -Version $results[0]._expandable.version ` -Title $Title ` -Manifest $Manifest } diff --git a/tools/PersonalAccessToken.psm1 b/src/PersonalAccessToken.psm1 similarity index 100% rename from tools/PersonalAccessToken.psm1 rename to src/PersonalAccessToken.psm1 diff --git a/tools/String.psm1 b/src/StringHelper.psm1 similarity index 100% rename from tools/String.psm1 rename to src/StringHelper.psm1 diff --git a/tools/manifest.schema.json b/src/schemas/manifest.schema.json similarity index 100% rename from tools/manifest.schema.json rename to src/schemas/manifest.schema.json diff --git a/tools/Connection.Tests.ps1 b/tests/Connection.Tests.ps1 similarity index 95% rename from tools/Connection.Tests.ps1 rename to tests/Connection.Tests.ps1 index 5a44249..ec93a5d 100755 --- a/tools/Connection.Tests.ps1 +++ b/tests/Connection.Tests.ps1 @@ -2,7 +2,8 @@ $ErrorActionPreference = "Stop" BeforeAll { - Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') + Import-Module (Join-Path $PSScriptRoot '..' 'src' ` + 'PSConfluencePublisher.psd1') } diff --git a/tools/Manifest.Tests.ps1 b/tests/Manifest.Tests.ps1 similarity index 96% rename from tools/Manifest.Tests.ps1 rename to tests/Manifest.Tests.ps1 index fc658f9..e360df2 100755 --- a/tools/Manifest.Tests.ps1 +++ b/tests/Manifest.Tests.ps1 @@ -2,7 +2,9 @@ $ErrorActionPreference = "Stop" BeforeAll { - Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') + Import-Module (Join-Path $PSScriptRoot '..' 'src' ` + 'PSConfluencePublisher.psd1') + } @@ -20,7 +22,7 @@ Describe 'Get-Manifest' ` InModuleScope Manifest ` { Mock Get-Content { - return '{"pages":[], "attachments": []}' + return '{"Pages":[], "Attachments": []}' } #mocking Get-Content, therefore file name can be bogus @@ -53,8 +55,8 @@ Describe 'Set-Manifest' ` InModuleScope Manifest ` { $mockManifest = @{ - 'pages' = @() - 'attachments' = @() + 'Pages' = @() + 'Attachments' = @() } Mock Set-Content { @@ -98,8 +100,8 @@ Describe 'Set-Manifest' ` InModuleScope Manifest ` { $mockManifest = @{ - 'pages' = @() - 'attachments' = @() + 'Pages' = @() + 'Attachments' = @() } Mock Set-Content { @@ -129,8 +131,8 @@ Describe 'Set-Manifest' ` InModuleScope Manifest ` { $mockManifest = @{ - 'pages' = @() - 'attachments' = @() + 'Pages' = @() + 'Attachments' = @() } Mock Set-Content { diff --git a/tools/Page.Tests.ps1 b/tests/Page.Tests.ps1 similarity index 98% rename from tools/Page.Tests.ps1 rename to tests/Page.Tests.ps1 index 8720c04..a0df663 100755 --- a/tools/Page.Tests.ps1 +++ b/tests/Page.Tests.ps1 @@ -3,7 +3,8 @@ $ErrorActionPreference = "Stop" BeforeAll { - Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') + Import-Module (Join-Path $PSScriptRoot '..' 'src' ` + 'PSConfluencePublisher.psd1') } diff --git a/tools/PageMeta.Tests.ps1 b/tests/PageMeta.Tests.ps1 similarity index 98% rename from tools/PageMeta.Tests.ps1 rename to tests/PageMeta.Tests.ps1 index 1030979..4e18344 100755 --- a/tools/PageMeta.Tests.ps1 +++ b/tests/PageMeta.Tests.ps1 @@ -2,7 +2,9 @@ $ErrorActionPreference = "Stop" BeforeAll { - Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') + Import-Module (Join-Path $PSScriptRoot '..' 'src' ` + 'PSConfluencePublisher.psd1') + } diff --git a/tools/PersonalAccessToken.Tests.ps1 b/tests/PersonalAccessToken.Tests.ps1 similarity index 91% rename from tools/PersonalAccessToken.Tests.ps1 rename to tests/PersonalAccessToken.Tests.ps1 index 7f4ab9b..7563c7d 100755 --- a/tools/PersonalAccessToken.Tests.ps1 +++ b/tests/PersonalAccessToken.Tests.ps1 @@ -2,7 +2,8 @@ $ErrorActionPreference = "Stop" BeforeAll { - Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') + Import-Module (Join-Path $PSScriptRoot '..' 'src' ` + 'PSConfluencePublisher.psd1') $mockHost = 'confluence.contoso.com' diff --git a/tools/String.Tests.ps1 b/tests/StringHelper.Tests.ps1 similarity index 76% rename from tools/String.Tests.ps1 rename to tests/StringHelper.Tests.ps1 index 9eaadfd..00170d4 100755 --- a/tools/String.Tests.ps1 +++ b/tests/StringHelper.Tests.ps1 @@ -2,7 +2,9 @@ $ErrorActionPreference = "Stop" BeforeAll { - Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') + Import-Module (Join-Path $PSScriptRoot '..' 'src' ` + 'PSConfluencePublisher.psd1') + } Describe 'Get-StringHash' ` diff --git a/tools/scripts.deps.json b/tools/scripts.deps.json deleted file mode 100755 index adc9bd7..0000000 --- a/tools/scripts.deps.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "runtimeTarget": { - "name": ".NETStandard,Version=v2.0/", - "signature": "" - }, - "compilationOptions": {}, - "targets": { - ".NETStandard,Version=v2.0": {}, - ".NETStandard,Version=v2.0/": { - "PSConfluencePublisher/1.0.0": { - "dependencies": { - "NETStandard.Library": "2.0.3" - }, - "runtime": {} - } - } - }, - "libraries": {} -} \ No newline at end of file