NN.PwshHelper.psm1
#Region '.\Private\Get-NuGetAccessToken.ps1' 0 function Get-NuGetAccessToken { param ( [string]$accessTokenPath = "$env:USERPROFILE\.creds\NuGet\nuGetAccessToken.xml" ) if (!(Test-Path $accessTokenPath)) { New-NuGetAccessToken } Import-Clixml $accessTokenPath | ConvertFrom-SecureString -AsPlainText } #EndRegion '.\Private\Get-NuGetAccessToken.ps1' 11 #Region '.\Private\New-NuGetAccessToken.ps1' 0 function New-NuGetAccessToken { param ( [string]$accessTokenPath = "$env:USERPROFILE\.creds\NuGet\nuGetAccessToken.xml" ) $apiKey = Read-Host "Enter NuGet API key" -AsSecureString #Create parent folders of the access token file $accessTokenDir = $accessTokenPath.Substring(0, $accessTokenPath.lastIndexOf('\')) if (!(Test-Path $accessTokenDir)) { $null = New-Item -ItemType Directory $accessTokenDir } #Create access token file $apiKey | Export-Clixml $accessTokenPath } #EndRegion '.\Private\New-NuGetAccessToken.ps1' 16 #Region '.\Public\Invoke-PwshPublishModule.ps1' 0 function Invoke-PwshPublishModule { param ( [Parameter(Mandatory)][string]$moduleName, [Parameter(Mandatory)][string]$modulePath ) $allPsModulePath = ($env:PSModulePath -split ";")[0] $null = New-Item -ItemType Directory -Name $moduleName -Path $allPsModulePath -Force $newFolderPath = "$allPsModulePath\$moduleName" (Get-ChildItem $modulePath).FullName | ForEach-Object { Copy-Item -Destination $newFolderPath -Path $_ } Publish-Module -Path $newFolderPath -NuGetApiKey $(Get-NuGetAccessToken) Remove-Item -Path $newFolderPath -Recurse } #EndRegion '.\Public\Invoke-PwshPublishModule.ps1' 17 #Region '.\Public\Write-Log.ps1' 0 function Write-Log { param ( [Parameter(Mandatory)][string]$Message, [Parameter(Mandatory)][string]$Path ) $logDir = $logPath.Substring(0, $logPath.lastIndexOf('\')) if (!(Test-Path $logDir)) { New-Item -ItemType Directory $logDir | Out-Null } $timeStamp = Get-Date -Format "dd/MM/yy hh:mm:ss" Add-Content -Path $logPath -Value "$timeStamp $message" } #EndRegion '.\Public\Write-Log.ps1' 13 |