Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* dev:
  Add new version notes
  Increment version
  Update helper function name and add tests in module scope
  Update helper function name
  Removed as no longer needed
  Update text case of referenced files
  Change language to en-US
  Fix typo
  Update module template and add PSDepend
  Add module build options and IB tasks
  Add code to test for running as administrator
  Remove duplication of build helpers output
  • Loading branch information
pauby committed Feb 13, 2020
2 parents ecb93bc + 07fd5a5 commit aa691a2
Show file tree
Hide file tree
Showing 25 changed files with 279 additions and 276 deletions.
16 changes: 14 additions & 2 deletions .pstodotxt.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Import-Module PowerShellBuild -force
. PowerShellBuild.IB.Tasks

$PSBPreference.Build.CompileModule = $true
$PSBPreference.Build.CompileHeader = "Set-StrictMode -Version Latest`n"
$PSBPreference.Build.CompileScriptFooter = "`n"
# $PSBPreference.Build.Dependencies = 'StageFiles', 'BuildHelp'
$PSBPreference.Test.Enabled = $true
$PSBPreference.Test.CodeCoverage.Enabled = $true
Expand All @@ -22,15 +24,15 @@ task LocalDeploy {
Copy-Item -Path $sourcePath -Destination $destPath -Recurse -Force
}

$moduleVersion = (Get-Module -Name PowerShellBuild -ListAvailable | Sort-Object Version -Descending | Select -First 1).Version
$moduleVersion = (Get-Module -Name PowerShellBuild -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1).Version
if ($moduleVersion -le [version]"0.3.0") {
task Build {
#Write-Host "Setting env"
#[Environment]::SetEnvironmentVariable("BHBuildOutput", $PSBPreference.Build.ModuleOutDir, "machine")
}, StageFiles, BuildHelp

task Init {
Initialize-PSBuild -UseBuildHelpers
Initialize-PSBuild
Set-BuildEnvironment -BuildOutput $PSBPreference.Build.ModuleOutDir -Force
$nl = [System.Environment]::NewLine
"$nl`Environment variables:"
Expand All @@ -54,3 +56,13 @@ if ($moduleVersion -le [version]"0.3.0") {

# build-module @params
# }

Task Clean Init, {
Clear-PSBuildOutputFolder -Path $PSBPreference.Build.ModuleOutDir

# Remove docs folder
Remove-Item -Path $PSBPreference.Docs.RootDir -Recurse -Force -ErrorAction SilentlyContinue
}

Task Build StageFiles, BuildHelp
Task Test Pester
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.2.1 13 February 2020
* Fixed some filename casing issues that only appeared in Linux (Linux is case sensitive!);

## v1.2.0 7 August 2018
* Added new `-ParseOnly` parameter to ConvertTo-TodoTxt to only parse the todo text and not validate it;
* Made the Get-TodoTxtTodaysDate function public;
Expand Down
2 changes: 1 addition & 1 deletion Initialize-Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (-not (Get-Command -Name 'Get-PackageProvider' -ErrorAction SilentlyContinue)
Get-PackageProvider -Name NuGet -ForceBootstrap | Out-Null
}

Set-PSRepository -Name PSGallery -InstallationPOlicy Trusted
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted

$RequiredModule | ForEach-Object {
if (-not (Get-Module -Name $_.Name -ListAvailable)) {
Expand Down
101 changes: 69 additions & 32 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,48 +1,85 @@
[CmdletBinding()]
Param (
$Task = 'build'
$Task = 'build',

# skips the initialization of the environment, which can be slow, and jumps
# straight to the build script
[switch]
$Bootstrap
)

$dependModules = @(
@{
Name = 'InvokeBuild'
},
@{
Name = 'Configuration'
},
@{
Name = 'PowerShellBuild'
MinimumVersion = '0.3.0-beta'
AllowPrerelease = $true
},
@{
Name = 'Pester'
MinimumVersion = 4.4.3
function Test-Administrator {
if ($PSVersionTable.Platform -ne 'Unix') {
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
} else {
# TODO: We are running in Linux so assume (at this stage) we have root / Admin - this needs resolved
$true
}
@{
Name = 'PSScriptAnalyzer'
MinimumVersion = '1.17.1'
}

if ($Bootstrap.IsPresent) {

$dependencies = @{
InvokeBuild = 'latest'
Configuration = 'latest'
PowerShellBuild = 'latest'
Pester = 'latest'
PSScriptAnalyzer = 'latest'
PSPesterTestHelpers = 'latest' # I don't trust this Warren guy...
PSDeploy = 'latest' # Maybe pin the version in case he breaks this...
}

# dependencies
if (-not (Get-Command -Name 'Get-PackageProvider' -ErrorAction SilentlyContinue)) {
$null = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Write-Verbose 'Bootstrapping NuGet package provider.'
Get-PackageProvider -Name NuGet -ForceBootstrap | Out-Null
} elseif ((Get-PackageProvider).Name -notcontains 'nuget') {
Write-Verbose 'Bootstrapping NuGet package provider.'
Get-PackageProvider -Name NuGet -ForceBootstrap
}
)

.\Initialize-Build.ps1 -RequiredModule $dependModules -Verbose:$VerbosePreference
#. .\tests\TestHelpers.ps1
# Trust the PSGallery is needed
if ((Get-PSRepository -Name PSGallery).InstallationPolicy -ne 'Trusted') {
Write-Verbose "Trusting PowerShellGallery."
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
}

function global:Import-HelperModuleForTesting {
# build the filename
$moduleScript = "{0}\{1}.psm1" -f $env:BHBuildOutput, $env:BHProjectName
if (Test-Path -Path $moduleScript) {
Remove-Module -Name $moduleScript -ErrorAction SilentlyContinue
Import-Module -Name $moduleScript -Force -ErrorAction Stop
Install-Module -Name PSDepend

$importedModule = Get-Module -Name $env:BHProjectName
Write-Verbose "Imported module '$($importedModule.Path)'"
if (Test-Administrator) {
$dependencies | Invoke-PSDepend -Import -Install -Force
} else {
Write-Warning "Not running as Administrator - could not initialize build environment."
}
else {
throw "Module manifest '$moduleScript' does not exist!"

# Configure git
if ($null -eq (Invoke-Expression -Command 'git config --get user.email')) {
Write-Verbose 'Git is not configured so we need to configure it now.'
git config --global user.email "[email protected]"
git config --global user.name "pauby"
git config --global core.safecrlf false
}
}

# # Used in Pester tests to import the built module and not a module already installed on the system
# function global:Import-PTHBuildModule {
# # build the filename
# $moduleScript = "{0}\{1}.psm1" -f $env:BHBuildOutput, $env:BHProjectName
# if (Test-Path -Path $moduleScript) {
# Remove-Module -Name $moduleScript -ErrorAction SilentlyContinue
# Import-Module -Name $moduleScript -Force -ErrorAction Stop

# $importedModule = Get-Module -Name $env:BHProjectName
# Write-Verbose "Imported module '$($importedModule.Path)'"
# } else {
# throw "Module manifest '$moduleScript' does not exist!"
# }
# }

Write-Host "Tag : $($env:CI_COMMIT_TAG)`nBranch : $($env:CI_COMMIT_REF_NAME)"

Invoke-Build -File .\.pstodotxt.build.ps1 -Task $Task -Verbose:$VerbosePreference

Remove-Item function:Import-HelpersModuleForTesting -ErrorAction SilentlyContinue
31 changes: 0 additions & 31 deletions docs/en-GB/PSTodoTxt.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: pstodotxt-help.xml
Module Name: PSTodoTxt
external help file: PsTodoTxt-help.xml
Module Name: PsTodoTxt
online version: http://www.github.com/pauby/pstodotxt
schema: 2.0.0
---
Expand Down Expand Up @@ -46,7 +46,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: pstodotxt-help.xml
Module Name: PSTodoTxt
external help file: PsTodoTxt-help.xml
Module Name: PsTodoTxt
online version: http://www.github.com/pauby/pstodotxt
schema: 2.0.0
---
Expand Down Expand Up @@ -75,7 +75,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand Down
6 changes: 3 additions & 3 deletions docs/en-GB/Export-TodoTxt.md → docs/en-US/Export-TodoTxt.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: pstodotxt-help.xml
Module Name: PSTodoTxt
external help file: PsTodoTxt-help.xml
Module Name: PsTodoTxt
online version: https://www.github.com/pauby/pstodotxt
schema: 2.0.0
---
Expand Down Expand Up @@ -92,7 +92,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: pstodotxt-help.xml
Module Name: PSTodoTxt
external help file: PsTodoTxt-help.xml
Module Name: PsTodoTxt
online version: https://www.github.com/pauby/
schema: 2.0.0
---
Expand Down Expand Up @@ -31,7 +31,7 @@ Outputs todays date.
## PARAMETERS

### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

Expand Down
6 changes: 3 additions & 3 deletions docs/en-GB/Import-TodoTxt.md → docs/en-US/Import-TodoTxt.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: pstodotxt-help.xml
Module Name: PSTodoTxt
external help file: PsTodoTxt-help.xml
Module Name: PsTodoTxt
online version: https://www.github.com/pauby/pstodotxt
schema: 2.0.0
---
Expand Down Expand Up @@ -50,7 +50,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand Down
6 changes: 3 additions & 3 deletions docs/en-GB/Set-TodoTxt.md → docs/en-US/Set-TodoTxt.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
external help file: pstodotxt-help.xml
Module Name: PSTodoTxt
external help file: PsTodoTxt-help.xml
Module Name: PsTodoTxt
online version: https://www.github.com/pauby
schema: 2.0.0
---
Expand Down Expand Up @@ -206,7 +206,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand Down
8 changes: 4 additions & 4 deletions source/PsTodoTxt.psd1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Module manifest for module 'PSTodoTxt'
# Module manifest for module 'PsTodoTxt'
#
# Generated by: Paul Broadwith
#
Expand All @@ -9,10 +9,10 @@
@{

# Script module or binary module file associated with this manifest.
RootModule = 'pstodotxt.psm1'
RootModule = 'PsTodoTxt.psm1'

# Version number of this module.
ModuleVersion = '1.2.0'
ModuleVersion = '1.2.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -63,7 +63,7 @@ PowerShellVersion = '3.0'
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = 'PSTodoTxt.Format.ps1xml'
FormatsToProcess = 'PsTodoTxt.Format.ps1xml'

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()
Expand Down
2 changes: 1 addition & 1 deletion tests/PSTodoTxt.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import-HelperModuleForTesting
Import-PTHBuildModule

Describe "Integration Testing - PSTodoTxt" {

Expand Down
21 changes: 0 additions & 21 deletions tests/TestHelpers.ps1

This file was deleted.

2 changes: 1 addition & 1 deletion tests/private/Get-TodoTxtTodaysDate.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import-HelperModuleForTesting
Import-PTHBuildModule
$functionName = $MyInvocation.MyCommand -split '.tests.ps1'

Describe "Testing Function - $functionName" {
Expand Down
Loading

0 comments on commit aa691a2

Please sign in to comment.