@@ -10,13 +10,15 @@ Write-Host "[BUILD] [START] Launching Build Process" -ForegroundColor Green
1010# region prepare folders
1111$Current = (Split-Path - Path $MyInvocation.MyCommand.Path )
1212$Root = ((Get-Item $Current ).Parent).FullName
13- $BackupPath = Join-Path - Path $Root - ChildPath " Backup"
14- $TestsPath = Join-Path - Path $Root - ChildPath " Tests"
15- $CISourcePath = Join-Path - Path $Root - ChildPath " CI"
16- $CodeSourcePath = Join-Path - Path $Root - ChildPath " Code"
17- $TestsScript = Join-Path - Path $TestsPath - ChildPath " Functions.Tests.ps1"
18- $TestsFailures = Join-Path - Path $TestsPath - ChildPath " Failed.Tests.json"
19- $Settings = Join-Path - Path $CISourcePath - ChildPath " Module-Settings.json"
13+ $BackupPath = Join-Path - Path $Root - ChildPath ' Backup'
14+ $TestsPath = Join-Path - Path $Root - ChildPath ' Tests'
15+ $CISourcePath = Join-Path - Path $Root - ChildPath ' CI'
16+ $CodeSourcePath = Join-Path - Path $Root - ChildPath ' Code'
17+ $PrivatePath = Join-Path - Path $CodeSourcePath - ChildPath ' Private'
18+ $PublicPath = Join-Path - Path $CodeSourcePath - ChildPath ' Public'
19+ $TestsScript = Join-Path - Path $TestsPath - ChildPath ' Functions.Tests.ps1'
20+ $TestsFailures = Join-Path - Path $TestsPath - ChildPath ' Failed.Tests.json'
21+ $Settings = Join-Path - Path $CISourcePath - ChildPath ' Module-Settings.json'
2022# endregion
2123
2224# region Module-Settings
@@ -57,13 +59,18 @@ $ModuleName = $ModuleName.ToLower() -replace '\-', '.' # Lower-case
5759 ModulePrefix = $ModulePrefix
5860 LastChange = $LastChange
5961} | ConvertTo-Json | Out-File - FilePath $Settings - Encoding utf8
62+ # endregion
63+
64+ # region PRE-functions
65+ Copy-Item - Path $CodeSourcePath - Destination $BackupPath - Filter ' *-PRE*.ps1' - Recurse - Force - Confirm:$false
6066
61- Get-ChildItem - Path (Join-Path $CodeSourcePath - ChildPath ' Private' ) - Filter ' *-*.ps1' | ForEach-Object {
67+ # Rename private and public PRE-functions
68+ Get-ChildItem - Path $PrivatePath - Filter ' *-*.ps1' | ForEach-Object {
6269 $newname = $ ($_.Name -replace ' -PRE' , " -$ ( $ModulePrefix ) " )
6370 (Get-Content - Path $_.FullName ) -replace ' -PRE' , " -$ ( $ModulePrefix ) " | Set-Content - Path $_.FullName
6471 Rename-Item - Path $_.FullName - NewName $newname # -PassThru
6572}
66- Get-ChildItem - Path ( Join-Path $CodeSourcePath - ChildPath ' Public ' ) - Filter ' *-*.ps1' | ForEach-Object {
73+ Get-ChildItem - Path $PublicPath - Filter ' *-*.ps1' | ForEach-Object {
6774 $newname = $ ($_.Name -replace ' -PRE' , " -$ ( $ModulePrefix ) " )
6875 (Get-Content - Path $_.FullName ) -replace ' -PRE' , " -$ ( $ModulePrefix ) " | Set-Content - Path $_.FullName
6976 Rename-Item - Path $_.FullName - NewName $newname # -PassThru
@@ -83,20 +90,17 @@ Write-Host "[BUILD] [TEST] Running Function-Tests" -ForegroundColor Green
8390$TestsResult = Invoke-Pester - Script $TestsScript - Output Normal - PassThru
8491if ($TestsResult.FailedCount -eq 0 ){
8592
86- $ModuleFolderRootPath = Join-Path - Path $Root - ChildPath $ModuleName
87- $ModuleFolderPath = Join-Path - Path $ModuleFolderRootPath - ChildPath $ModuleVersion
88- # $ModuleFolderPath = $Root
93+ $ModuleFolderPath = Join-Path - Path $Root - ChildPath $ModuleName
94+
8995 if (-not (Test-Path - Path $ModuleFolderPath )){
9096 $null = New-Item - Path $ModuleFolderPath - ItemType Directory - Force
9197 }
92- # endregion
9398
9499 # region Update the Module-File
95- # Remove existent PSM1-File
100+ # Move existent PSM1-File to the backup-folder
96101 $ExportPath = Join-Path - Path $ModuleFolderPath - ChildPath " $ ( $ModuleName ) .psm1"
97102 if (Test-Path $ExportPath ){
98103 Write-Host " [BUILD] [PSM1 ] PSM1 file detected. Deleting..." - ForegroundColor Green
99- # Remove-Item -Path $ExportPath -Force
100104 Move-Item - Path $ExportPath - Destination $BackupPath - Force - Confirm:$false
101105 }
102106
@@ -170,4 +174,11 @@ else{
170174# region Module.Tests.ps1
171175Write-Host " `n "
172176Invoke-Pester - Script (Join-Path - Path $TestsPath - ChildPath " Module.Tests.ps1" ) - Output Detailed
173- # endregion
177+ # endregion
178+
179+ # region manually
180+ Write-Host " `n If you have dependencies to other modules, please fill in to the module manifest (psd1) as RequiredModules. See at " - ForegroundColor Cyan
181+ Write-Host " https://learn.microsoft.com/en-us/powershell/scripting/developer/module/how-to-write-a-powershell-module-manifest?view=powershell-7.3" - ForegroundColor Cyan
182+ Write-Host " `n Module Manifest:"
183+ Import-LocalizedData - BaseDirectory $ModuleFolderPath - FileName " $ ( $ModuleName ) .psd1"
184+ # endregion
0 commit comments