-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from TheJumpCloud/JumpCloudModule_1.13.0
Jump cloud module 1.13.0
- Loading branch information
Showing
141 changed files
with
6,145 additions
and
781 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
. ($PSScriptRoot + '/' + 'Get-Config.ps1') | ||
########################################################################### | ||
Write-Host ('[status]Importing current module: ' + $ModuleName) | ||
Import-Module ($FilePath_psd1) -Force | ||
Write-Host ('[status]Installing module: PlatyPS') | ||
Install-Module -Name:('PlatyPS') -Force -Scope:('CurrentUser') | ||
Write-Host ('[status]Creating/Updating help files') | ||
$Functions_Public | ForEach-Object { | ||
$FunctionName = $_.BaseName | ||
$FilePath_Md = $FolderPath_Docs + '/' + $FunctionName + '.md' | ||
If (Test-Path -Path:($FilePath_Md)) | ||
{ | ||
# Write-Host ('Updating: ' + $FunctionName + '.md') | ||
Update-MarkdownHelp -Path:($FilePath_Md) -Force -ExcludeDontShow -UpdateInputOutput | ||
} | ||
Else | ||
{ | ||
# Write-Host ('Creating: ' + $FunctionName + '.md') | ||
New-MarkdownHelp -Command:($FunctionName) -OutputFolder:($FolderPath_Docs) -Force -ExcludeDontShow -OnlineVersionUrl:($GitHubWikiUrl + $FunctionName) | ||
} | ||
} | ||
# Create new ExternalHelp file. | ||
Write-Host ('[status]Creating new external help file') | ||
New-ExternalHelp -Path:($FolderPath_Docs) -OutputPath:($FolderPath_enUS) -Force | ||
|
||
# Create online versions of the help files in the support.wiki | ||
# Update docs with links to the online docs for 'Get-Help -online' commands | ||
|
||
# ##TODO | ||
# ### Add step check out support wiki | ||
# $PathToSupportWikiRepo = '' | ||
# $SupportRepoDocs = $PSScriptRoot + '/Docs' | ||
# $SupportWiki = $PathToSupportWikiRepo + '/support.wiki' | ||
# $Docs = Get-ChildItem -Path:($SupportRepoDocs + '/*.md') -Recurse | ||
# ForEach ($Doc In $Docs) | ||
# { | ||
# $DocName = $Doc.Name | ||
# $DocFullName = $Doc.FullName | ||
# $SupportWikiDocFullName = $SupportWiki + '/' + $DocName | ||
# $DocContent = Get-Content -Path:($DocFullName) | ||
# If (Test-Path -Path:($SupportWikiDocFullName)) | ||
# { | ||
# $SupportWikiDocContent = Get-Content -Path:($SupportWikiDocFullName) | ||
# $Diffs = Compare-Object -ReferenceObject:($DocContent) -DifferenceObject:($SupportWikiDocContent) | ||
# If ($Diffs) | ||
# { | ||
# Write-Warning -Message:('Diffs found in: ' + $DocName) | ||
# # are you sure you want to continue? | ||
# } | ||
# } | ||
# Else | ||
# { | ||
# Write-Warning -Message:('Creating new file: ' + $DocName) | ||
# } | ||
# $NewDocContent = If (($DocContent | Select-Object -First 1) -eq '---') | ||
# { | ||
# $DocContent | Select-Object -Skip:(7) | ||
# } | ||
# Else | ||
# { | ||
# $DocContent | ||
# } | ||
# Set-Content -Path:($SupportWikiDocFullName) -Value:($NewDocContent) -Force | ||
# } | ||
# ### Add step check in changes to support wiki |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
. ($PSScriptRoot + '/' + 'Get-Config.ps1') | ||
# Region Checking PowerShell Gallery module version | ||
Write-Host ('[status]Check PowerShell Gallery for module version info') | ||
$PSGalleryInfo = Get-PSGalleryModuleVersion -Name:($ModuleName) -ReleaseType:($RELEASETYPE) #('Major', 'Minor', 'Patch') | ||
$ModuleVersion = $PSGalleryInfo.NextVersion | ||
Write-Host ('[status]PowerShell Gallery Name:' + $PSGalleryInfo.Name + ';CurrentVersion:' + $PSGalleryInfo.Version + '; NextVersion:' + $ModuleVersion ) | ||
# EndRegion Checking PowerShell Gallery module version | ||
# Region Building New-JCModuleManifest | ||
Write-Host ('[status]Building New-JCModuleManifest') | ||
New-JCModuleManifest -Path:($FilePath_psd1) ` | ||
-FunctionsToExport:($Functions_Public.BaseName | Sort-Object) ` | ||
-RootModule:((Get-Item -Path:($FilePath_psm1)).Name) ` | ||
-ModuleVersion:($ModuleVersion) | ||
# EndRegion Building New-JCModuleManifest | ||
# Region Updating module banner | ||
Write-Host ('[status]Updating module banner: "' + $FilePath_ModuleBanner + '"') | ||
$ModuleBanner = Get-Content -Path:($FilePath_ModuleBanner) | ||
$NewModuleBannerRecord = New-ModuleBanner -LatestVersion:($ModuleVersion) -BannerCurrent:('{{Fill in the Banner Current}}') -BannerOld:('{{Fill in the Banner Old}}') | ||
If (!(($ModuleBanner | Select-Object -Index 3) -match $ModuleVersion)) | ||
{ | ||
$NewModuleBannerRecord.Trim() | Set-Content -Path:($FilePath_ModuleBanner) -Force | ||
} | ||
# EndRegion Updating module banner | ||
# Region Updating module change log | ||
Write-Host ('[status]Updating module change log: "' + $FilePath_ModuleChangelog + '"') | ||
$ModuleChangelog = Get-Content -Path:($FilePath_ModuleChangelog) | ||
$NewModuleChangelogRecord = New-ModuleChangelog -LatestVersion:($ModuleVersion) -ReleaseNotes:('{{Fill in the Release Notes}}') -Features:('{{Fill in the Features}}') -Improvements:('{{Fill in the Improvements}}') -BugFixes('{{Fill in the Bug Fixes}}') | ||
If (!(($ModuleChangelog | Select-Object -First 1) -match $ModuleVersion)) | ||
{ | ||
($NewModuleChangelogRecord + ($ModuleChangelog | Out-String)).Trim() | Set-Content -Path:($FilePath_ModuleChangelog) -Force | ||
} | ||
# EndRegion Updating module change log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
. ($PSScriptRoot + '/' + 'Get-Config.ps1') | ||
########################################################################### | ||
Write-Host ('[status]Creating files for Pester tests') | ||
$Files = $Functions_Public + $Functions_Private | ||
Foreach ($File in $Files) | ||
{ | ||
$NewDirectory = ([string]$File.Directory).Replace($ModuleFolderName, $ModuleFolderName + '/' + $FolderName_Tests) | ||
$NewName = $File.BaseName + '.Tests' + $File.Extension | ||
$NewFullName = $NewDirectory + '/' + $NewName | ||
If ( !( Test-Path -Path:($NewFullName) )) | ||
{ | ||
New-FolderRecursive -Path:($NewFullName) | ||
Write-Host ('[status]Create test files for new function') | ||
New-Item -ItemType:('File') -Path:($NewFullName) -Force | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
. ($PSScriptRoot + '/' + 'Get-Config.ps1') | ||
########################################################################### | ||
$CurrentLocation = Get-Location | ||
Set-Location -Path:($StagingDirectory) | ||
Invoke-GitClone -Repo:($GitSourceRepoWiki) | ||
|
||
### Add step check out support wiki | ||
# $PathToSupportWikiRepo = '' | ||
# $SupportRepoDocs = $PSScriptRoot + '/Docs' | ||
# $SupportWiki = $PathToSupportWikiRepo + '/support.wiki' | ||
# $Docs = Get-ChildItem -Path:($SupportRepoDocs + '/*.md') -Recurse | ||
# ForEach ($Doc In $Docs) | ||
# { | ||
# $DocName = $Doc.Name | ||
# $DocFullName = $Doc.FullName | ||
# $SupportWikiDocFullName = $SupportWiki + '/' + $DocName | ||
# $DocContent = Get-Content -Path:($DocFullName) | ||
# If (Test-Path -Path:($SupportWikiDocFullName)) | ||
# { | ||
# $SupportWikiDocContent = Get-Content -Path:($SupportWikiDocFullName) | ||
# $Diffs = Compare-Object -ReferenceObject:($DocContent) -DifferenceObject:($SupportWikiDocContent) | ||
# If ($Diffs) | ||
# { | ||
# Write-Warning -Message:('Diffs found in: ' + $DocName) | ||
# # are you sure you want to continue? | ||
# } | ||
# } | ||
# Else | ||
# { | ||
# Write-Warning -Message:('Creating new file: ' + $DocName) | ||
# } | ||
# $NewDocContent = If (($DocContent | Select-Object -First 1) -eq '---') | ||
# { | ||
# $DocContent | Select-Object -Skip:(7) | ||
# } | ||
# Else | ||
# { | ||
# $DocContent | ||
# } | ||
# Set-Content -Path:($SupportWikiDocFullName) -Value:($NewDocContent) -Force | ||
# } | ||
# ### Add step check in changes to support wiki | ||
|
||
Set-Location -Path:($CurrentLocation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
. ($PSScriptRoot + '/' + 'Get-Config.ps1') | ||
########################################################################### | ||
Write-Host ('[status]Commit changes to:' + $GitSourceBranch + ';') | ||
Invoke-GitCommit -BranchName:($GitSourceBranch) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
Function New-JCModuleManifest | ||
{ | ||
[cmdletbinding(SupportsShouldProcess = $True)] | ||
Param() | ||
DynamicParam | ||
{ | ||
$Params = @() | ||
$NewModuleManifestParameterSets = (Get-Command -Name:('New-ModuleManifest')).ParameterSets | ||
ForEach ($NewModuleManifestParameterSet In $NewModuleManifestParameterSets) | ||
{ | ||
ForEach ($NewModuleManifestParam In $NewModuleManifestParameterSet.Parameters) | ||
{ | ||
If ($NewModuleManifestParam.Name -notin @([System.Management.Automation.PSCmdlet]::CommonParameters + [System.Management.Automation.PSCmdlet]::OptionalCommonParameters)) | ||
{ | ||
$Params += @{ | ||
'ParameterSets' = $NewModuleManifestParameterSet.Name; | ||
'Name' = $NewModuleManifestParam.Name; | ||
'Type' = $NewModuleManifestParam.ParameterType.FullName; | ||
'Mandatory' = $NewModuleManifestParam.IsMandatory; | ||
'Position' = $NewModuleManifestParam.Position; | ||
'ValueFromPipeline' = $NewModuleManifestParam.ValueFromPipeline; | ||
'ValueFromPipelineByPropertyName' = $NewModuleManifestParam.ValueFromPipelineByPropertyName; | ||
'ValueFromRemainingArguments' = $NewModuleManifestParam.ValueFromRemainingArguments; | ||
# 'HelpMessage' = $NewModuleManifestParam.HelpMessage; | ||
'Alias' = $NewModuleManifestParam.Aliases; | ||
# 'DontShow' = ''; | ||
# 'ValidateNotNull' = ''; | ||
# 'ValidateNotNullOrEmpty' = ''; | ||
# 'AllowEmptyString' = ''; | ||
# 'AllowNull' = ''; | ||
# 'AllowEmptyCollection' = ''; | ||
# 'ValidateScript' = ''; | ||
# 'ValidateSet' = ''; | ||
# 'ValidateRange' = ''; | ||
# 'ValidateCount' = ''; | ||
# 'ValidateLength' = ''; | ||
# 'ValidatePattern' = ''; | ||
# 'RuntimeParameterDictionary' = ''; | ||
} | ||
} | ||
} | ||
} | ||
$Params | ForEach-Object { | ||
New-Object PSObject -Property $_ | ||
} | New-DynamicParameter | ||
} | ||
Begin | ||
{ | ||
# Create new variables for script | ||
$PsBoundParameters.GetEnumerator() | ForEach-Object { Set-Variable -Name:($_.Key) -Value:($_.Value) -Force } | ||
Write-Debug ('[CallFunction]' + $MyInvocation.MyCommand.Name + ' ' + ($PsBoundParameters.GetEnumerator() | Sort-Object Key | ForEach-Object { ('-' + $_.Key + ":('" + ($_.Value -join "','") + "')").Replace("'True'", '$True').Replace("'False'", '$False') }) ) | ||
If ($PSCmdlet.ParameterSetName -ne '__AllParameterSets') { Write-Verbose ('[ParameterSet]' + $MyInvocation.MyCommand.Name + ':' + $PSCmdlet.ParameterSetName) } | ||
$CurrentErrorActionPreference = $ErrorActionPreference | ||
$ErrorActionPreference = 'Stop' | ||
} | ||
Process | ||
{ | ||
# Create hash table to store variables | ||
$FunctionParameters = [ordered]@{ } | ||
If (Test-Path -Path:($Path)) | ||
{ | ||
$FilePath_psd1 = Get-Item -Path:($Path) | ||
$CurrentModuleManifest = Import-LocalizedData -BaseDirectory:($FilePath_psd1.DirectoryName) -FileName:($FilePath_psd1.BaseName) | ||
# Add input parameters from function in to hash table and filter out unnecessary parameters | ||
$CurrentModuleManifest.GetEnumerator() | ForEach-Object { $FunctionParameters.Add($_.Key, $_.Value) | Out-Null } | ||
$PrivateDataPSData = $CurrentModuleManifest['PrivateData']['PSData'] | ||
# New-ModuleManifest parameters that come from previous ModuleManifest PrivateData | ||
$PrivateDataPSData.GetEnumerator() | ForEach-Object { | ||
If ($FunctionParameters.Contains($_.Key)) | ||
{ | ||
$FunctionParameters[$_.Key] = $_.Value | ||
} | ||
Else | ||
{ | ||
$FunctionParameters.Add($_.Key, $_.Value) | Out-Null | ||
} | ||
} | ||
# Remove previous ModuleManifest PrivateData | ||
$FunctionParameters.Remove('PrivateData') | Out-Null | ||
# Update values with values passed in from function | ||
$PsBoundParameters.GetEnumerator() | ForEach-Object { | ||
If ($FunctionParameters.Contains($_.Key)) | ||
{ | ||
$FunctionParameters[$_.Key] = $_.Value | ||
} | ||
Else | ||
{ | ||
$FunctionParameters.Add($_.Key, $_.Value) | Out-Null | ||
} | ||
} | ||
} | ||
Else | ||
{ | ||
Write-Warning ('Creating new module manifest. Please populate empty fields: ' + $Path) | ||
New-ModuleManifest -Path:($Path) | ||
} | ||
Write-Debug ('Splatting Parameters'); | ||
If ($DebugPreference -ne 'SilentlyContinue') { $FunctionParameters } | ||
New-ModuleManifest @FunctionParameters | ||
} | ||
End | ||
{ | ||
# Validate that the module manifest is valid | ||
$ModuleValid = Test-ModuleManifest -Path:($FilePath_psd1.FullName) | ||
If ($ModuleValid) | ||
{ | ||
$ModuleValid | ||
} | ||
Else | ||
{ | ||
$ModuleValid | ||
Write-Error ('ModuleManifest is invalid!') | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
PowerShell/Deploy/Functions/Get-PSGalleryModuleVersion.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
Function Get-PSGalleryModuleVersion | ||
{ | ||
Param ( | ||
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)][ValidateNotNullOrEmpty()][string]$Name, | ||
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 1)][ValidateNotNullOrEmpty()][ValidateSet('Major', 'Minor', 'Patch')][string]$RELEASETYPE | ||
) | ||
# Check to see if module already exists to set version number | ||
$PowerShellGalleryModule = Find-Module -Name:($Name) -ErrorAction:('Ignore') | ||
If ([string]::IsNullOrEmpty($PowerShellGalleryModule)) | ||
{ | ||
$ModuleVersion = [PSCustomObject]@{ | ||
'Name' = $Name; | ||
'Version' = 'N/A'; | ||
'Major' = 'N/A'; | ||
'Minor' = 'N/A'; | ||
'Patch' = 'N/A'; | ||
} | ||
$NextVersion = Switch ($RELEASETYPE) | ||
{ | ||
'Major' { $ModuleVersion.Major = '1.0.0' } | ||
'Minor' { $ModuleVersion.Minor = '0.1.0' } | ||
'Patch' { $ModuleVersion.Patch = '0.0.1' } | ||
} | ||
} | ||
Else | ||
{ | ||
$ModuleVersion = [PSCustomObject]@{ | ||
'Name' = $PowerShellGalleryModule.Name; | ||
'Version' = $PowerShellGalleryModule.Version; | ||
'Major' = [int]($PowerShellGalleryModule.Version -split '\.')[0]; | ||
'Minor' = [int]($PowerShellGalleryModule.Version -split '\.')[1]; | ||
'Patch' = [int]($PowerShellGalleryModule.Version -split '\.')[2]; | ||
} | ||
Switch ($RELEASETYPE) | ||
{ | ||
'Major' | ||
{ | ||
$ModuleVersion.Major = $ModuleVersion.Major + 1 | ||
$ModuleVersion.Minor = 0 | ||
$ModuleVersion.Patch = 0 | ||
} | ||
'Minor' | ||
{ | ||
$ModuleVersion.Minor = $ModuleVersion.Minor + 1 | ||
$ModuleVersion.Patch = 0 | ||
} | ||
'Patch' { $ModuleVersion.Patch = $ModuleVersion.Patch + 1 } | ||
} | ||
|
||
} | ||
$NextVersion = ($ModuleVersion.Major, $ModuleVersion.Minor, $ModuleVersion.Patch) -join '.' | ||
Add-Member -InputObject:($ModuleVersion) -MemberType:('NoteProperty') -Name:('NextVersion') -Value:($NextVersion) | ||
Return $ModuleVersion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Function Invoke-Git | ||
{ | ||
Param($Arguments) | ||
If ([environment]::OSVersion.Platform -eq 'Win32NT') { $env:GIT_REDIRECT_STDERR = '2>&1' } | ||
$LASTEXITCODE = 0 | ||
$Error.Clear() | ||
$Command = 'git ' + $Arguments | ||
Write-Host ('[GitCommand]' + $Command) | ||
Invoke-Expression -Command:($Command) | ||
If ($LASTEXITCODE) | ||
{ | ||
Throw ('Git error, $LASTEXITCODE: ' + $LASTEXITCODE) | ||
} | ||
If ($Error) | ||
{ | ||
Throw ('Git error, $Error: ' + $Error) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Function Invoke-GitClone | ||
{ | ||
param ( | ||
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)][ValidateNotNullOrEmpty()][string]$Repo | ||
) | ||
# Logging | ||
$MyName = $MyInvocation.MyCommand.Name | ||
$ParentScriptName = (Get-PSCallStack | Where-Object { $_.Command -notin ($MyName, $MyName.Replace('.ps1', '')) }).Command -join ',' | ||
$UserEmail = 'AzurePipelines@FakeEmail.com' | ||
$UserName = 'AzurePipelines' | ||
Invoke-Git -Arguments:('config user.email "' + $UserEmail + '";') | ||
Invoke-Git -Arguments:('config user.name "' + $UserName + '";') | ||
Invoke-Git -Arguments:('clone ' + $Repo + ';') | ||
Invoke-Git -Arguments:('status;') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Function Invoke-GitCommit | ||
{ | ||
param ( | ||
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)][ValidateNotNullOrEmpty()][string]$BranchName | ||
) | ||
# Logging | ||
$MyName = $MyInvocation.MyCommand.Name | ||
$ParentScriptName = (Get-PSCallStack | Where-Object { $_.Command -notin ($MyName, $MyName.Replace('.ps1', '')) }).Command -join ',' | ||
$CommitMessage = 'Push to ' + $BranchName + '; Called by:' + $ParentScriptName + ';[skip ci]' | ||
$UserEmail = 'AzurePipelines@FakeEmail.com' | ||
$UserName = 'AzurePipelines' | ||
Invoke-Git -Arguments:('config user.email "' + $UserEmail + '";') | ||
Invoke-Git -Arguments:('config user.name "' + $UserName + '";') | ||
Invoke-Git -Arguments:('add -A;') | ||
Invoke-Git -Arguments:('status;') | ||
Invoke-Git -Arguments:('commit -m ' + '"' + $CommitMessage + '";') | ||
Invoke-Git -Arguments:('push origin HEAD:refs/heads/' + $BranchName + ';') | ||
} |
Oops, something went wrong.