refactor: make this a valid nuget package for Powershell gallery

feat: add build environment scripts
This commit is contained in:
Rodweil, Theodor 2023-08-07 20:56:50 +02:00
parent 69c2684ee7
commit 46b1b7c83f
No known key found for this signature in database
GPG key ID: F8BC1B0EB1F9CCF5
38 changed files with 200 additions and 42 deletions

7
.gitignore vendored
View file

@ -1,6 +1,11 @@
.DS_Store
/test-reports/
/dist/
# FAT stuff (in a filesystem sense)
/_* /_*
/._* /._*
.DS_Store
#vim cache #vim cache
*.swp *.swp

41
LICENSE Executable file
View file

@ -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.

View file

@ -1,14 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata> <metadata>
<id>PSConfluencePublisher</id> <id>victorykit.PSConfluencePublisher</id>
<title>victorykit.PSConfluencePublisher</title>
<version>1.1.0</version> <version>1.1.0</version>
<description>standalone publisher for xconfluencebuilder</description> <description>standalone publisher for xconfluencebuilder</description>
<authors>theodor.rodweil@victory-k.it</authors> <authors>Victory Karma IT</authors>
<owners>Theodor Rodweil</owners> <owners>Theodor Rodweil</owners>
<license type="expression">DL-DE-BY-2.0</license> <license type="expression">DL-DE-BY-2.0</license>
<readme>README.md</readme> <readme>.\README.md</readme>
<copyright>Victory Karma IT</copyright> <copyright>Victory Karma IT</copyright>
<title>Powershell Confluence Publisher</title> <tags>PowerShell</tags>
</metadata> </metadata>
<files>
<file src="src\**\*" target="."/>
<file src="README.md" target="." />
</files>
</package> </package>

31
samples/default/README.md Executable file
View file

@ -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
```

View file

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

Before After
Before After

BIN
scripts/._analyze.ps1 Executable file

Binary file not shown.

BIN
scripts/._clean.ps1 Executable file

Binary file not shown.

BIN
scripts/._test.ps1 Executable file

Binary file not shown.

16
scripts/analyze.ps1 Executable file
View file

@ -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

22
scripts/clean.ps1 Executable file
View file

@ -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)
}

12
scripts/pack.ps1 Executable file
View file

@ -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')

36
scripts/test.ps1 Executable file
View file

@ -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'
}
}

BIN
src/._PSConfluencePublisher.psd1 Executable file

Binary file not shown.

View file

@ -3,7 +3,7 @@ $ErrorActionPreference = "Stop"
$script:schema = Get-Content ( $script:schema = Get-Content (
Join-Path $PSScriptRoot 'manifest.schema.json' Join-Path -Path $PSScriptRoot 'schemas' 'manifest.schema.json'
) | Out-String ) | Out-String
@ -32,12 +32,12 @@ function Get-Manifest
{ {
Write-Debug $_ Write-Debug $_
$raw = '{"pages":{}, "attachments": {}}' $raw = '{"Pages":[], "attachments": []}'
} }
$raw | Test-JSON -Schema $script:schema | Out-Null $raw | Test-JSON -Schema $script:schema | Out-Null
$data = $raw | ConvertFrom-JSON $raw | ConvertFrom-JSON
} }
} }

View file

@ -65,7 +65,7 @@ RootModule = 'PSConfluencePublisher.psm1'
'Manifest.psm1', 'Manifest.psm1',
'Page.psm1', 'Page.psm1',
'PageMeta.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. # 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.

View file

@ -122,7 +122,7 @@ function Get-PageMeta
{ {
Update-PageMeta ` Update-PageMeta `
-Id $results[0].id ` -Id $results[0].id `
-Version ($results[0]._expandable | Select -ExpandProperty 'version') ` -Version $results[0]._expandable.version `
-Title $Title ` -Title $Title `
-Manifest $Manifest -Manifest $Manifest
} }

View file

@ -2,7 +2,8 @@
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
BeforeAll { BeforeAll {
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') Import-Module (Join-Path $PSScriptRoot '..' 'src' `
'PSConfluencePublisher.psd1')
} }

View file

@ -2,7 +2,9 @@
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
BeforeAll { 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 ` InModuleScope Manifest `
{ {
Mock Get-Content { Mock Get-Content {
return '{"pages":[], "attachments": []}' return '{"Pages":[], "Attachments": []}'
} }
#mocking Get-Content, therefore file name can be bogus #mocking Get-Content, therefore file name can be bogus
@ -53,8 +55,8 @@ Describe 'Set-Manifest' `
InModuleScope Manifest ` InModuleScope Manifest `
{ {
$mockManifest = @{ $mockManifest = @{
'pages' = @() 'Pages' = @()
'attachments' = @() 'Attachments' = @()
} }
Mock Set-Content { Mock Set-Content {
@ -98,8 +100,8 @@ Describe 'Set-Manifest' `
InModuleScope Manifest ` InModuleScope Manifest `
{ {
$mockManifest = @{ $mockManifest = @{
'pages' = @() 'Pages' = @()
'attachments' = @() 'Attachments' = @()
} }
Mock Set-Content { Mock Set-Content {
@ -129,8 +131,8 @@ Describe 'Set-Manifest' `
InModuleScope Manifest ` InModuleScope Manifest `
{ {
$mockManifest = @{ $mockManifest = @{
'pages' = @() 'Pages' = @()
'attachments' = @() 'Attachments' = @()
} }
Mock Set-Content { Mock Set-Content {

View file

@ -3,7 +3,8 @@ $ErrorActionPreference = "Stop"
BeforeAll { BeforeAll {
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') Import-Module (Join-Path $PSScriptRoot '..' 'src' `
'PSConfluencePublisher.psd1')
} }

View file

@ -2,7 +2,9 @@
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
BeforeAll { BeforeAll {
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') Import-Module (Join-Path $PSScriptRoot '..' 'src' `
'PSConfluencePublisher.psd1')
} }

View file

@ -2,7 +2,8 @@
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
BeforeAll { BeforeAll {
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') Import-Module (Join-Path $PSScriptRoot '..' 'src' `
'PSConfluencePublisher.psd1')
$mockHost = 'confluence.contoso.com' $mockHost = 'confluence.contoso.com'

View file

@ -2,7 +2,9 @@
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
BeforeAll { BeforeAll {
Import-Module (Join-Path $PSScriptRoot 'PSConfluencePublisher.psd1') Import-Module (Join-Path $PSScriptRoot '..' 'src' `
'PSConfluencePublisher.psd1')
} }
Describe 'Get-StringHash' ` Describe 'Get-StringHash' `

View file

@ -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": {}
}