Skip to content

Commit 7da041b

Browse files
committed
template updates
template updates
1 parent 7f50acf commit 7da041b

13 files changed

Lines changed: 177 additions & 121 deletions

File tree

‎templates/PSFProject-sheldonh/build/functions/Update-Version.ps1‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,8 @@ function Update-Version
7777
}
7878
if ($PSD1FullName)
7979
{
80-
#[version]$ModuleCurrentVersion = '1.0.0.1'
81-
$moduleInformation = Import-PowershellDataFile $PSD1FullName | ConvertHashtableTo-Object
82-
#[Version]$ModuleOriginalVersion = [version]::parse($Moduleinformation.ModuleVersion)
83-
#[version]::TryParse(('{0}.{1}.{2}.0' -f $moduleInformation.Version.Major, $moduleInformation.Version.Minor, $moduleInformation.Version.Patch), [ref]$ModuleCurrentVersion)
80+
81+
$ModInfo = (Get-Content $PSD1FullName -Raw) | Invoke-Expression #Take content of psd1/aka hashtable, and just create object from it. Easy!
8482
try
8583
{
8684
$SplatMe = @{
@@ -90,11 +88,11 @@ function Update-Version
9088
ErrorAction = 'continue'
9189
}
9290
Update-ModuleManifest @SplatMe
93-
Write-PSFMessage -Level Verbose -Message "$ModuleName -- psd1 --$($ModuleOriginalVersion) vs $NewVersion"
91+
Write-PSFMessage -Level Verbose -Message "$ModuleName -- psd1 --$($ModInfo.ModuleVersion) vs $NewVersion"
9492
}
9593
catch
9694
{
97-
Write-PSFMessage -Level Warning -Message "FAILED: $ModuleName -- psd1 --$($ModuleOriginalVersion) vs $NewVersion" -Exception $_.Exception
95+
Write-PSFMessage -Level Warning -Message "FAILED: $ModuleName -- psd1 --$($ModInfo.ModuleVersion) vs $NewVersion" -Exception $_.Exception
9896
}
9997
}
10098

‎templates/PSFProject-sheldonh/build/vsts-documentation.ps1‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ Write-Host " Importing platyPS"
1515
Import-Module -Name platyPS -Force
1616
Write-Host "###############################################################"
1717

18+
#SYSTEM_DEFAULTWORKINGDIRECTORY is supposed to be the root folder that contains both the build folder, C# project if included, and the Module folder(same name as project)
19+
#Documentation will be generated at the root directory
1820

1921
$env:SYSTEM_DEFAULTWORKINGDIRECTORY = (($env:SYSTEM_DEFAULTWORKINGDIRECTORY|Resolve-Path -ea 0|Split-Path -Parent|Split-Path -Parent).Path, ($PSScriptRoot|Split-path -parent|Split-Path -Parent) -ne $null)[0]
2022
$commandReferenceBasePath = "$($env:SYSTEM_DEFAULTWORKINGDIRECTORY)\documentation\commands"
21-
#get-command -module platyps | out-gridview -PassThru -Title 'Select Command to View Help' | get-help -showWindow
2223

2324
#region module
2425
Write-Host " Importing þnameþ" -ForegroundColor Green
@@ -62,6 +63,7 @@ Write-Host " - "
6263
$branch = $env:BUILD_SOURCEBRANCHNAME
6364
Write-PSFMessage -Level Host -Message "Applying documentation to repository"
6465
set-location $env:SYSTEM_DEFAULTWORKINGDIRECTORY -Verbose
66+
6567
git config credential.interactive never
6668
git config credential.authority NTLM
6769
git config user.name ""

‎templates/PSFProject-sheldonh/þnameþ/tests/general/PSScriptAnalyzer.Tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if ($env:BUILD_BUILDURI -like "vstfs*") { Install-Module PSScriptAnalyzer -Force
1414
$list = New-Object System.Collections.ArrayList
1515

1616
Describe 'Invoking PSScriptAnalyzer against commandbase' {
17-
$commandFiles = Get-ChildItem -Path $CommandPath -Recurse -Filter "*.ps1"
17+
$commandFiles = Get-ChildItem -Path $CommandPath -Recurse -Filter "*.ps1" | Where-Object {$_.FullName -notmatch 'ps_modules'}
1818
$scriptAnalyzerRules = Get-ScriptAnalyzerRule
1919

2020
foreach ($file in $commandFiles)

‎templates/PSFProject-vsts-task/build/functions/Update-Version.ps1‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,8 @@ function Update-Version
7777
}
7878
if ($PSD1FullName)
7979
{
80-
#[version]$ModuleCurrentVersion = '1.0.0.1'
81-
$moduleInformation = Import-PowershellDataFile $PSD1FullName | ConvertHashtableTo-Object
82-
#[Version]$ModuleOriginalVersion = [version]::parse($Moduleinformation.ModuleVersion)
83-
#[version]::TryParse(('{0}.{1}.{2}.0' -f $moduleInformation.Version.Major, $moduleInformation.Version.Minor, $moduleInformation.Version.Patch), [ref]$ModuleCurrentVersion)
80+
81+
$ModInfo = (Get-Content $PSD1FullName -Raw) | Invoke-Expression #Take content of psd1/aka hashtable, and just create object from it. Easy!
8482
try
8583
{
8684
$SplatMe = @{
@@ -90,11 +88,11 @@ function Update-Version
9088
ErrorAction = 'continue'
9189
}
9290
Update-ModuleManifest @SplatMe
93-
Write-PSFMessage -Level Verbose -Message "$ModuleName -- psd1 --$($Moduleinformation.ModuleVersion) vs $NewVersion"
91+
Write-PSFMessage -Level Verbose -Message "$ModuleName -- psd1 --$($ModInfo.ModuleVersion) vs $NewVersion"
9492
}
9593
catch
9694
{
97-
Write-PSFMessage -Level Warning -Message "FAILED: $ModuleName -- psd1 --$($Moduleinformation.ModuleVersion) vs $NewVersion" -Exception $_.Exception
95+
Write-PSFMessage -Level Warning -Message "FAILED: $ModuleName -- psd1 --$($ModInfo.ModuleVersion) vs $NewVersion" -Exception $_.Exception
9896
}
9997
}
10098

‎templates/PSFProject-vsts-task/build/vsts-build.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Insert any build steps you may need to take before publishing it here.
1313
1414
PS> tfx login --service-url {TFSURL}/DefaultCollection -token MyTokenFromTFS
1515
The first time you do this on a system, you need to cache your credential for the tfx cli
16-
1716
#>
1817
param (
1918
[string]$ApiKey = (Get-PSFConfigValue 'API.ProgetApiKey' -Fallback $ENV:INPUT_APIKEY)
@@ -59,6 +58,7 @@ else
5958
}
6059
Publish-Module @SplatArgs
6160

61+
6262
set-location $env:SYSTEM_DEFAULTWORKINGDIRECTORY -Verbose
6363
git config credential.interactive never
6464
git config credential.authority NTLM

‎templates/PSFProject-vsts-task/build/vsts-documentation.ps1‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ Write-Host " Importing platyPS"
1515
Import-Module -Name platyPS -Force
1616
Write-Host "###############################################################"
1717

18+
#SYSTEM_DEFAULTWORKINGDIRECTORY is supposed to be the root folder that contains both the build folder, C# project if included, and the Module folder(same name as project)
19+
#Documentation will be generated at the root directory
1820

1921
$env:SYSTEM_DEFAULTWORKINGDIRECTORY = (($env:SYSTEM_DEFAULTWORKINGDIRECTORY|Resolve-Path -ea 0|Split-Path -Parent|Split-Path -Parent).Path, ($PSScriptRoot|Split-path -parent|Split-Path -Parent) -ne $null)[0]
2022
$commandReferenceBasePath = "$($env:SYSTEM_DEFAULTWORKINGDIRECTORY)\documentation\commands"
21-
#get-command -module platyps | out-gridview -PassThru -Title 'Select Command to View Help' | get-help -showWindow
2223

23-
#region þnameþ
24+
#region module
2425
Write-Host " Importing þnameþ" -ForegroundColor Green
2526
$moduleName = "þnameþ"
2627
Import-Module "$($env:SYSTEM_DEFAULTWORKINGDIRECTORY)\$ModuleName\$ModuleName\$ModuleName.psd1" -force
@@ -53,7 +54,7 @@ foreach ($command in $commands) {
5354
Add-Content -Path "$($commandReferenceBasePath)\$($moduleName).md" -Value " - [$command]($($moduleName)/$command.md)"
5455
}
5556
Write-PSFMessage -Level Host -Message "Finished processing $moduleName"
56-
#endregion þnameþ
57+
#endregion module
5758

5859
Write-Host " - "
5960
Write-Host "###############################################################"
@@ -62,6 +63,9 @@ Write-Host " - "
6263
$branch = $env:BUILD_SOURCEBRANCHNAME
6364
Write-PSFMessage -Level Host -Message "Applying documentation to repository"
6465
set-location $env:SYSTEM_DEFAULTWORKINGDIRECTORY -Verbose
66+
67+
git config credential.interactive never
68+
git config credential.authority NTLM
6569
git config user.name ""
6670
git config user.email ""
6771
git add documentation

‎templates/PSFProject-vsts-task/þnameþ/TFS-þnameþ.ps1‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@ Write-PSFMessage -Level Output -Message ( "{0:hh\:mm\:ss\.fff} {1}: starting" -f
2323

2424
Import-Module -Name "$PSScriptRoot\þnameþ.psd1" -force
2525

26-
[string]$SqlInstance = Get-VstsInput -Name SqlInstance -verbose -Require
27-
[string]$Database = Get-VstsInput -Name Database -verbose -Require
28-
26+
[string]$SqlInstance = Get-PSFConfigValue -FullName 'þnameþ.SqlInstance' -FallBack (Get-VstsInput -Name SqlInstance -verbose)
27+
[string]$Database = Get-PSFConfigValue -FullName 'þnameþ.Database' -FallBack (Get-VstsInput -Name Database -verbose)
2928

29+
Write-PSFMessage -Level Debug -Message "---þnameþ current variables---`n$(Get-PSFConfig -Fullname 'þnameþ.*' | Format-Table -AutoSize -Wrap | Out-String)"
3030
try
3131
{
3232
$TFSStopwatchProcess = [diagnostics.stopwatch]::StartNew()
3333
Write-PSFMessage -Level Output -Message ( "{0:hh\:mm\:ss\.fff} {1}: task start" -f $TFSStopwatchProcess.Elapsed, 'TFS-þnameþ')
3434

3535
#TASKS HERE
36+
Set-PSFConfig -FullName 'þnameþ.Output.' -Value '' -Initialize -Validation 'string' -Handler { } -Description "Output results" -PassThru -Verbose | Register-PSFConfig -Scope FileSystem -Verbose
3637

3738

3839
Write-PSFMessage -Level Output -Message ( "{0:hh\:mm\:ss\.fff} {1}: task end" -f $TFSStopwatchProcess.Elapsed, 'TFS-þnameþ')
Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1-
TOPIC
2-
about_þnameþ
3-
4-
SHORT DESCRIPTION
5-
Explains how to use the þnameþ powershell module
6-
7-
LONG DESCRIPTION
8-
<Insert Content here>
9-
10-
KEYWORDS
11-
þnameþ
1+
# þnameþ
2+
## about_þnameþ
3+
4+
## SHORT DESCRIPTION
5+
What þnameþ powershell module does
6+
7+
## LONG DESCRIPTION
8+
More detail if required here
9+
10+
## EXAMPLES
11+
12+
`PS> Import-Module þnameþ`
13+
Import the module.
14+
15+
`PS> þFunctionNameþ`
16+
þdescription of functionþ
17+
18+
# TROUBLESHOOTING NOTE
19+
20+
# SEE ALSO
21+
22+
# KEYWORDS
23+
- þnameþ

‎templates/PSFProject-vsts-task/þnameþ/functions/þFunctionNameþ.ps1‎

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,37 @@
11
<#
2-
.description
2+
.SYNOPSIS
3+
A brief description of the function or script. This keyword can be used only once in each topic.
4+
.DESCRIPTION
35
þdescription of functionþ
6+
.PARAMETER Foo
7+
Description
8+
.PARAMETER Foo
9+
Description
10+
.PARAMETER Foo
11+
Description
412
5-
.example
6-
# To Return
7-
þFunctionNameþ
13+
.EXAMPLE
14+
PS> þFunctionNameþ
15+
Runs þFunctionNameþ
816
17+
###### OPTIONAL ######
18+
.LINK
19+
The name of a related topic. The value appears on the line below the ".LINK" keyword and must be preceded by a comment symbol # or included in the comment block.
20+
.NOTES
21+
Additional information about the function or script.
22+
.INPUTS
23+
The Microsoft .NET Framework types of objects that can be piped to the function or script. You can also include a description of the input objects.
24+
.OUTPUTS
25+
The .NET Framework type of the objects that the cmdlet returns. You can also include a description of the returned objects.
26+
.EXTERNALHELP
27+
Specifies an XML-based help file for the script or function.
28+
###### ENDOPTIONAL ######
929
1030
#>
1131
function þFunctionNameþ
1232
{
1333
[CmdletBinding()]
34+
#[OutputType([pscustomobject[]])]
1435
Param (
1536

1637
)
@@ -25,9 +46,9 @@ function þFunctionNameþ
2546
try
2647
{
2748
$StopwatchProcess = [diagnostics.stopwatch]::StartNew()
28-
Write-PSFMessage -Level Output -Message ( "{0:hh\:mm\:ss\.fff} {1}: process start" -f $StopwatchProcess.Elapsed, 'þFunctionNameþ')
49+
Write-PSFMessage -Level Debug -Message ( "{0:hh\:mm\:ss\.fff} {1}: process start" -f $StopwatchProcess.Elapsed, 'þFunctionNameþ')
2950

30-
Write-PSFMessage -Level Output -Message ( "{0:hh\:mm\:ss\.fff} {1}: process end" -f $StopwatchProcess.Elapsed, 'þFunctionNameþ')
51+
Write-PSFMessage -Level Debug -Message ( "{0:hh\:mm\:ss\.fff} {1}: process end" -f $StopwatchProcess.Elapsed, 'þFunctionNameþ')
3152
}
3253
catch
3354
{

‎templates/PSFProject-vsts-task/þnameþ/tests/functions/þFunctionNameþ.tests.ps1‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ $CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
22
Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan
33
. (resolve-path "$PSScriptRoot\..\constants.ps1")
44

5-
65
Describe 'þFunctionNameþ' -Tags 'Integration' {
76

87
BeforeAll {
@@ -15,10 +14,9 @@ Describe 'þFunctionNameþ' -Tags 'Integration' {
1514
Remove-Item $script:PesterWorkingDirectory -Recurse -ErrorAction SilentlyContinue -Verbose:$false
1615
}
1716

18-
Context 'running þFunctionNameþ' {
19-
It 'þItDescriptionþ' {
20-
{þFunctionNameþ} | Should -Not -Throw
17+
Context 'runs þFunctionNameþ' {
18+
It 'it throws þFunctionNameþ when no arguments passed in' {
19+
{þFunctionNameþ} | Should -Throw
2120
}
2221
}
23-
2422
}

0 commit comments

Comments
 (0)