mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-15 02:35:46 +00:00
Fix PSSA deploy(.ps1) warning (#26)
* Deploy: fix indent (remove trailing whitespace) * Deploy(.ps1): Remove PSSA warning about don't use Write-host * Deploy(.ps1): Remove PSSA warning unused variable false positive (it is used for ParameterSet...)
This commit is contained in:
parent
e8a5fdf15d
commit
a608d6ebd7
1 changed files with 21 additions and 19 deletions
40
deploy.ps1
40
deploy.ps1
|
|
@ -1,19 +1,19 @@
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Concatenate files into single PSM1 and PSD1 files
|
Concatenate files into single PSM1 and PSD1 files
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Concatenate all ps1 files in the Functions directory, plus the root PSM1,
|
Concatenate all ps1 files in the Functions directory, plus the root PSM1,
|
||||||
into a single PSM1 file in the NetboxPS directory.
|
into a single PSM1 file in the NetboxPS directory.
|
||||||
|
|
||||||
By default, this script will increment version by 0.0.1
|
By default, this script will increment version by 0.0.1
|
||||||
|
|
||||||
.PARAMETER SkipVersion
|
.PARAMETER SkipVersion
|
||||||
Do not increment the version.
|
Do not increment the version.
|
||||||
|
|
||||||
.PARAMETER VersionIncrease
|
.PARAMETER VersionIncrease
|
||||||
Increase the version by a user defined amount
|
Increase the version by a user defined amount
|
||||||
|
|
||||||
.PARAMETER NewVersion
|
.PARAMETER NewVersion
|
||||||
Override the new version with this version
|
Override the new version with this version
|
||||||
|
|
||||||
|
|
@ -37,14 +37,16 @@
|
||||||
===========================================================================
|
===========================================================================
|
||||||
#>
|
#>
|
||||||
[CmdletBinding(DefaultParameterSetName = 'IncreaseVersion')]
|
[CmdletBinding(DefaultParameterSetName = 'IncreaseVersion')]
|
||||||
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "")]
|
||||||
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "")]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'SkipVersion')]
|
[Parameter(ParameterSetName = 'SkipVersion')]
|
||||||
[switch]$SkipVersion,
|
[switch]$SkipVersion,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'IncreaseVersion')]
|
[Parameter(ParameterSetName = 'IncreaseVersion')]
|
||||||
[version]$VersionIncrease = "0.0.1",
|
[version]$VersionIncrease = "0.0.1",
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'SetVersion')]
|
[Parameter(ParameterSetName = 'SetVersion')]
|
||||||
[version]$NewVersion
|
[version]$NewVersion
|
||||||
)
|
)
|
||||||
|
|
@ -68,14 +70,14 @@ $Counter = 0
|
||||||
Write-Host "Concatenating [$($PS1Files.Count)] PS1 files from $FunctionPath"
|
Write-Host "Concatenating [$($PS1Files.Count)] PS1 files from $FunctionPath"
|
||||||
foreach ($File in $PS1Files) {
|
foreach ($File in $PS1Files) {
|
||||||
$Counter++
|
$Counter++
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Write-Host (" Adding file {0:D2}/{1:D2}: $($File.Name)" -f $Counter, $PS1Files.Count)
|
Write-Host (" Adding file {0:D2}/{1:D2}: $($File.Name)" -f $Counter, $PS1Files.Count)
|
||||||
|
|
||||||
"`r`n#region File $($File.Name)`r`n" | Out-File -FilePath $ConcatenatedFilePath -Encoding utf8 -Append -ErrorAction Stop
|
"`r`n#region File $($File.Name)`r`n" | Out-File -FilePath $ConcatenatedFilePath -Encoding utf8 -Append -ErrorAction Stop
|
||||||
|
|
||||||
Get-Content $File.FullName -Encoding UTF8 -ErrorAction Stop | Out-File -FilePath $ConcatenatedFilePath -Encoding utf8 -Append -ErrorAction Stop
|
Get-Content $File.FullName -Encoding UTF8 -ErrorAction Stop | Out-File -FilePath $ConcatenatedFilePath -Encoding utf8 -Append -ErrorAction Stop
|
||||||
|
|
||||||
"`r`n#endregion" | Out-File -FilePath $ConcatenatedFilePath -Encoding utf8 -Append -ErrorAction Stop
|
"`r`n#endregion" | Out-File -FilePath $ConcatenatedFilePath -Encoding utf8 -Append -ErrorAction Stop
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host "FAILED TO WRITE CONCATENATED FILE: $($_.Exception.Message): $($_.TargetObject)" -ForegroundColor Red
|
Write-Host "FAILED TO WRITE CONCATENATED FILE: $($_.Exception.Message): $($_.TargetObject)" -ForegroundColor Red
|
||||||
|
|
@ -98,30 +100,30 @@ switch ($PSCmdlet.ParameterSetName) {
|
||||||
"SkipVersion" {
|
"SkipVersion" {
|
||||||
# Dont do anything with the PSD
|
# Dont do anything with the PSD
|
||||||
Write-Host " Skipping version update, maintaining version [$CurrentVersion]"
|
Write-Host " Skipping version update, maintaining version [$CurrentVersion]"
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
"IncreaseVersion" {
|
"IncreaseVersion" {
|
||||||
# Calculate the new version
|
# Calculate the new version
|
||||||
[version]$NewVersion = "{0}.{1}.{2}" -f ($CurrentVersion.Major + $VersionIncrease.Major), ($CurrentVersion.Minor + $VersionIncrease.Minor), ($CurrentVersion.Build + $VersionIncrease.Build)
|
[version]$NewVersion = "{0}.{1}.{2}" -f ($CurrentVersion.Major + $VersionIncrease.Major), ($CurrentVersion.Minor + $VersionIncrease.Minor), ($CurrentVersion.Build + $VersionIncrease.Build)
|
||||||
|
|
||||||
Write-Host " Updating version in PSD1 from [$CurrentVersion] to [$NewVersion]"
|
Write-Host " Updating version in PSD1 from [$CurrentVersion] to [$NewVersion]"
|
||||||
|
|
||||||
# Replace the version number in the content
|
# Replace the version number in the content
|
||||||
#$PSDContent -replace $CurrentVersion, $NewVersion | Out-File $PSScriptRoot\$ModuleName.psd1 -Encoding UTF8
|
#$PSDContent -replace $CurrentVersion, $NewVersion | Out-File $PSScriptRoot\$ModuleName.psd1 -Encoding UTF8
|
||||||
Update-ModuleManifest -Path "$PSScriptRoot\$ModuleName.psd1" -ModuleVersion $NewVersion
|
Update-ModuleManifest -Path "$PSScriptRoot\$ModuleName.psd1" -ModuleVersion $NewVersion
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
"SetVersion" {
|
"SetVersion" {
|
||||||
Write-Host " Updating version in PSD1 from [$CurrentVersion] to [$NewVersion]"
|
Write-Host " Updating version in PSD1 from [$CurrentVersion] to [$NewVersion]"
|
||||||
|
|
||||||
# Replace the version number in the content
|
# Replace the version number in the content
|
||||||
#$PSDContent -replace $CurrentVersion, $NewVersion | Out-File $PSScriptRoot\$ModuleName.psd1 -Encoding UTF8
|
#$PSDContent -replace $CurrentVersion, $NewVersion | Out-File $PSScriptRoot\$ModuleName.psd1 -Encoding UTF8
|
||||||
Update-ModuleManifest -Path "$PSScriptRoot\$ModuleName.psd1" -ModuleVersion $NewVersion
|
Update-ModuleManifest -Path "$PSScriptRoot\$ModuleName.psd1" -ModuleVersion $NewVersion
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue