-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGenerate-Module.ps1
More file actions
69 lines (53 loc) · 2.78 KB
/
Generate-Module.ps1
File metadata and controls
69 lines (53 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
if (Test-Path ".\deploy") {
Add-AppveyorMessage "Deleting previous deployment directory"
Remove-Item ".\deploy" -Force -Recurse
}
if (Test-Path ".\staging") {
Add-AppveyorMessage "Deleting previous staging directory"
Remove-Item ".\staging" -Force -Recurse
}
# Properties
$functionsToExport = $Env:FunctionsToExport -split ";"
$tags = $Env:Tags -split ";"
$stagingDirectory = New-Item ".\staging" -ItemType Directory -Force
Add-AppveyorMessage "Installing Formatter"
Install-Module PSScriptAnalyzer -Scope CurrentUser -Force
Add-AppveyorMessage "Copying and cleaning code"
Get-ChildItem -Path "src" -Filter "*.psm1" | ForEach-Object {Invoke-Formatter -ScriptDefinition (Get-Content $_.FullName -Raw) >> (Join-Path -Path $stagingDirectory.FullName $_.Name) }
$file = Get-ChildItem -Path $stagingDirectory -Filter "*.psm1"
if ($file -eq $null) {
throw "Could not find *.psm1"
}
Add-AppveyorMessage "Generating manifest"
$psdFile = Join-Path -Path $stagingDirectory -ChildPath "$($Env:ModuleName).psd1"
New-ModuleManifest -Path $psdFile -Description $Env:Description -Author $Env:Author -Copyright $Env:Copyright -CompanyName $Env:Company -ModuleVersion $Env:APPVEYOR_BUILD_VERSION -RootModule $file.Name -FunctionsToExport $functionsToExport -ProjectUri $Env:ProjectUri -LicenseUri $Env:LicenseUri -Tags $tags
Add-AppveyorMessage "Copying misc files"
Copy-Item -Path "LICENSE" -Destination $stagingDirectory
Copy-Item -Path "README.md" -Destination $stagingDirectory
# Add-AppveyorMessage "Generating documentation"
# Install-Module -Name platyPS -Scope CurrentUser -Force
# New-ExternalHelp .\docs -OutputPath en-GB\
# Copy-Item -Path "en-GB" -Destination $stagingDirectory
# Removed because Install-Module fails with an unsigned catalog
# Add-AppveyorMessage "Generating catalog"
# New-FileCatalog -Path $stagingDirectory -CatalogFilePath (Join-Path -Path $stagingDirectory -ChildPath "$($Env:ModuleName).cat")
$tempNugetRepo = New-Item -ItemType Directory ".\nuget-feed\nuget\v2"
$deploymentDirectory = New-Item -ItemType Directory ".\deploy"
try
{
Add-AppveyorMessage "Bootstrapping NuGet"
Get-PackageProvider -Name NuGet -ForceBootstrap | Out-Null
Add-AppveyorMessage "Registering temp repository"
Register-PSRepository -Name "temp" -SourceLocation $tempNugetRepo.FullName
Add-AppveyorMessage "Publishing module to temp repository"
Publish-Module -Name $psdFile -Repository "temp"
$package = Get-ChildItem -Filter "*.nupkg" -Recurse
Add-AppveyorMessage "Moving package to output"
Move-Item -Path $package.FullName -Destination $deploymentDirectory.FullName
}
finally
{
Add-AppveyorMessage "Deleting temp resources"
Unregister-PSRepository "temp" -ErrorAction SilentlyContinue
Remove-Item -Path (Get-Item "nuget-feed") -Recurse -Force
}