11param (
2+ # Set this to true before releasing the module
23 [Parameter (Mandatory = $false , HelpMessage = " Enter the version number of this release" )]
34 [string ]$Version = " 1.0.0" ,
5+ # Fix this
46 [Parameter (Mandatory = $false , HelpMessage = " ." )]
57 [string ]$preRelease = " Alpha" ,
68 [Parameter (Mandatory = $false , HelpMessage = " Use this switch to publish this module on PSGallery" )]
79 [bool ]$Publish = $false ,
10+ # Validate so if $Publish is true this is needed
811 [Parameter (Mandatory = $false , HelpMessage = " Enter API key for PSGallery" )]
912 [string ]$apiKey
1013)
1114
12- # THIS IS A BETA FILE DONT USE THIS FILE! ILL RELEASE A ALPHA VERSION OF THIS LATER ON!
13-
1415# Requires -Modules PSScriptAnalyzer
16+ Import-Module - Name EasyModuleBuild - Force
1517
1618# Creating ArrayList for use later in the script
1719[System.Collections.ArrayList ]$FunctionPSD = @ ()
@@ -29,6 +31,7 @@ $outPSDFile = Join-Path -Path $ModuleFolderPath -ChildPath "$($ModuleName).psd1"
2931$psdTemplate = Join-Path - Path $srcPath - ChildPath " $ ( $ModuleName ) .psd1.source"
3032$psmLicensPath = Join-Path - Path $srcPath - ChildPath " License"
3133$TestPath = Join-Path - Path $scriptPath - ChildPath " test"
34+ # $EMBSourceFiles = "$($env:PSModulePath)/EasyModuleBuild/source_files"
3235
3336Write-OutPut " `n == Building module $ ( $ModuleName ) ==`n "
3437Write-OutPut " Starting to build the module, please wait..."
@@ -94,6 +97,7 @@ Copy-Item -Path $psdTemplate -Destination $outPSDFile -Force
9497Write-Verbose " Getting the content from file $ ( $outPSDFile ) "
9598$PSDfileContent = Get-Content - Path $outPSDFile
9699
100+ # Changing version, preReleaseTag and function in the .psd1 file
97101Write-Verbose " Replacing the placeholders in the $ ( $outPSDFile ) file"
98102$PSDfileContent = $PSDfileContent -replace ' {{manifestDate}}' , $TodaysDate
99103$PSDfileContent = $PSDfileContent -replace ' {{moduleName}}' , $ModuleName
@@ -112,23 +116,27 @@ else {
112116Write-Verbose " Setting the placeholders for $ ( $outPSDFile ) "
113117Set-Content - Path $outPSDFile - Value $PSDfileContent - Force
114118
115- Write-Output " Running PSScriptAnalyzer on the .psd1 $ ( $outPSDFile ) ..."
116- # If no issue are found that should be written in the outfile
117- $PSAnalyzerPSD = Invoke-ScriptAnalyzer - Path $outPSDFile - ReportSummary
118- if ($null -ne $PSAnalyzerPSD ) {
119- $PSAnalyzerPSD | select-object * | Out-File - Encoding UTF8BOM - FilePath $ (Join-Path - Path $TestPath - ChildPath " PSScriptAnalyzer_psd1_$ ( $TodaysDate ) .md" )
120- }
121- else {
122- Write-Output " 0 rule violations found." | Out-File - Encoding UTF8BOM - FilePath $ (Join-Path - Path $TestPath - ChildPath " PSScriptAnalyzer_psd1_$ ( $TodaysDate ) .md" )
119+ foreach ($ps1 in $MigrateFunction ) {
120+ Write-Output " Running PSScriptAnalyzer on $ ( $ps1 ) ..."
121+ $PSAnalyzerPS1 = Invoke-ScriptAnalyzer - Path $ps1 - ReportSummary
122+ if ($null -ne $PSAnalyzerPS1 ) {
123+ $PSAnalyzerPS1 | select-object * | Out-File - Encoding UTF8BOM - FilePath $ (Join-Path - Path $TestPath - ChildPath " PSScriptAnalyzer_$ ( $ps1.Name ) _$ ( $TodaysDate ) .md" )
124+ }
125+ else {
126+ Write-Output " 0 rule violations found." | Out-File - Encoding UTF8BOM - FilePath $ (Join-Path - Path $TestPath - ChildPath " PSScriptAnalyzer_$ ( $ps1.Name ) _$ ( $TodaysDate ) .md" )
127+ }
123128}
124129
125- Write-Output " Running PSScriptAnalyzer on all .ps1 files in $ ( $srcPublicFunctionPath ) ..."
126- $PSAnalyzer = Invoke-ScriptAnalyzer - Path $srcPublicFunctionPath - Recurse - ReportSummary
127- if ($null -ne $PSAnalyzer ) {
128- $PSAnalyzer | select-object * | Out-File - Encoding UTF8BOM - FilePath $ (Join-Path - Path $TestPath - ChildPath " PSScriptAnalyzer_ps1_$ ( $TodaysDate ) .md" )
129- }
130- else {
131- Write-Output " 0 rule violations found." | Out-File - Encoding UTF8BOM - FilePath $ (Join-Path - Path $TestPath - ChildPath " PSScriptAnalyzer_ps1_$ ( $TodaysDate ) .md" )
130+ $CheckPSA = @ ($outPSDFile , $outPSMFile )
131+ foreach ($file in $CheckPSA ) {
132+ Write-Output " Running PSScriptAnalyzer on the $ ( $file ) "
133+ $PSAnalyzer = Invoke-ScriptAnalyzer - Path $file - ReportSummary
134+ if ($null -ne $PSAnalyzer ) {
135+ $PSAnalyzer | select-object * | Out-File - Encoding UTF8BOM - FilePath $ (Join-Path - Path $TestPath - ChildPath " PSScriptAnalyzer_$ ( $file -split " /" | Select-Object - Last 1 ) _$ ( $TodaysDate ) .md" )
136+ }
137+ else {
138+ Write-Output " 0 rule violations found." | Out-File - Encoding UTF8BOM - FilePath $ (Join-Path - Path $TestPath - ChildPath " PSScriptAnalyzer_$ ( $file -split " /" | Select-Object - Last 1 ) _$ ( $TodaysDate ) .md" )
139+ }
132140}
133141
134142# Import the module and save the Get-Help files to the $HelpPath for the module, files get saved in .md format
@@ -144,7 +152,7 @@ foreach ($m in $mCommands) {
144152 }
145153}
146154
147- if ($PSAnalyzer.Severity -contains " Warning" -or $PSAnalyzerPSD -contains " Warning" ) {
155+ if ($PSAnalyzer.Severity -contains " Warning" -or $PSAnalyzerPS1 -contains " Warning" ) {
148156 $PSAnalyzer
149157 Write-Error " PSAnalyzer severity did contain Warning, please fix this and run the RSModuleBuilder again. You can se the results from PSAnalyzer above this row."
150158 Break
0 commit comments