Skip to content

Commit dd95e1a

Browse files
committed
0.1.9 Release
1 parent 44fe930 commit dd95e1a

614 files changed

Lines changed: 102093 additions & 1058 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ModuleBuild.build.ps1

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if (Test-Path $BuildFile) {
3333
. $BuildFile
3434
}
3535
else {
36-
throw "Without a build environment file we are at a loss as to what to do!"
36+
throw "Without a build environment file we are at a loss as to what to qdo!"
3737
}
3838

3939
if ($Script:BuildEnv.OptionTranscriptEnabled) {
@@ -144,6 +144,34 @@ task VersionCheck LoadModuleManifest, {
144144
}
145145
}
146146

147+
#Synopsis: Create a CodeHealthReport of your existing code
148+
task CodeHealthReport -if {$Script:BuildEnv.OptionCodeHealthReport} ValidateRequirements, LoadRequiredModules, {
149+
$BuildReportsFolder = Join-Path $BuildRoot $Script:BuildEnv.BuildReportsFolder
150+
Write-Description White "Creating a prebuild code health report of your public functions to $($Script:BuildEnv.BuildReportsFolder)" -accent
151+
152+
if (-not (Test-Path $BuildReportsFolder)) {
153+
New-Item -Path $BuildReportsFolder -ItemType:Directory
154+
}
155+
156+
Write-Description White 'Creating a code health report of your public functions' -level 2
157+
$CodeHealthScanPathPublic = Join-Path $BuildRoot $Script:BuildEnv.PublicFunctionSource
158+
$CodeHealthReportPublic = Join-Path $BuildReportsFolder 'CodeHealthReport-Public.html'
159+
Invoke-PSCodeHealth -Path $CodeHealthScanPathPublic -HtmlReportPath $CodeHealthReportPublic
160+
161+
if (Test-Path $CodeHealthReportPublic) {
162+
(Get-Content -Path $CodeHealthReportPublic -raw) -replace [regex]::escape((Resolve-Path $CodeHealthScanPathPublic)), $Script:BuildEnv.PublicFunctionSource | Out-File -FilePath $CodeHealthReportPublic -Encoding $Script:BuildEnv.Encoding -Force
163+
}
164+
165+
Write-Description White 'Creating a code health report of your private functions' -level 2
166+
$CodeHealthScanPathPrivate = Join-Path $BuildRoot $Script:BuildEnv.PrivateFunctionSource
167+
$CodeHealthReportPrivate = Join-Path $BuildReportsFolder 'CodeHealthReport-Private.html'
168+
Invoke-PSCodeHealth -Path $CodeHealthScanPathPrivate -HtmlReportPath $CodeHealthReportPrivate
169+
170+
if (Test-Path $CodeHealthReportPrivate) {
171+
(Get-Content -Path $CodeHealthReportPrivate -raw) -replace [regex]::escape((Resolve-Path $CodeHealthScanPathPrivate)), $Script:BuildEnv.PrivateFunctionSource | Out-File -FilePath $CodeHealthReportPrivate -Encoding $Script:BuildEnv.Encoding -Force
172+
}
173+
}
174+
147175
#Synopsis: Validate script requirements are met, load required modules, load project manifest and module, and load additional build tools.
148176
task Configure ValidateRequirements, PreBuildTasks, LoadRequiredModules, LoadModuleManifest, LoadModule, VersionCheck, LoadBuildTools, {
149177
# If we made it this far then we are configured!
@@ -786,6 +814,18 @@ task PreBuildTasks {
786814
}
787815
}
788816

817+
# Synopsis: Run pre-build scripts (such as other builds)
818+
task PostBuildTasks {
819+
Write-Description White 'Running any Post-Build scripts' -accent
820+
$BuildToolPath = Join-Path $BuildRoot $Script:BuildEnv.BuildToolFolder
821+
$CleanupPath = Join-Path $BuildToolPath 'shutdown'
822+
# Dot source any post build cleanup scripts.
823+
Get-ChildItem -Path $CleanupPath -Recurse -Filter "*.ps1" -File | Foreach {
824+
Write-Description White "Dot sourcing shutdown script file: $($_.Name)" -Level 3
825+
. $_.FullName
826+
}
827+
}
828+
789829
# Synopsis: Remove session artifacts like loaded modules and variables
790830
task BuildSessionCleanup {
791831
Write-Description White 'Cleaning up the build session' -accent
@@ -801,13 +841,6 @@ task BuildSessionCleanup {
801841
Write-Description White "Removing $($Script:BuildEnv.ModuleToBuild) module (if loaded)." -Level 3
802842
Remove-Module $Script:BuildEnv.ModuleToBuild -Erroraction Ignore
803843

804-
# Dot source any post build cleanup scripts.
805-
Write-Description White "Runing post-build scripts" -Level 2
806-
$CleanupPath = Join-Path $BuildToolPath 'shutdown'
807-
Get-ChildItem -Path $CleanupPath -Recurse -Filter "*.ps1" -File | Foreach {
808-
Write-Description White "Dot sourcing shutdown script file: $($_.Name)" -Level 3
809-
. $_.FullName
810-
}
811844
if ($Script:BuildEnv.OptionTranscriptEnabled) {
812845
Stop-Transcript -WarningAction:Ignore
813846
}
@@ -838,16 +871,16 @@ task GithubPush VersionCheck, {
838871
}
839872

840873
# Synopsis: Build the module
841-
task . Configure, Clean, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, BuildSessionCleanup
874+
task . Configure, CodeHealthReport, Clean, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, PostBuildTasks, BuildSessionCleanup
842875

843876
# Synopsis: Install and test load the module.
844877
task InstallAndTestModule InstallModule, TestInstalledModule
845878

846879
# Synopsis: Build, Install, and Test the module
847-
task BuildInstallAndTestModule Configure, Clean, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, InstallModule, TestInstalledModule, BuildSessionCleanup
880+
task BuildInstallAndTestModule Configure, CodeHealthReport, Clean, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, InstallModule, TestInstalledModule, PostBuildTasks, BuildSessionCleanup
848881

849882
# Synopsis: Build, Install, Test, and Publish the module
850-
task BuildInstallTestAndPublishModule Configure, Clean, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, InstallModule, TestInstalledModule, PublishPSGallery, BuildSessionCleanup
883+
task BuildInstallTestAndPublishModule Configure, CodeHealthReport, Clean, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, InstallModule, TestInstalledModule, PublishPSGallery, PostBuildTasks, BuildSessionCleanup
851884

852885
# Synopsis: Instert Comment Based Help where it doesn't already exist (output to scratch directory)
853886
task InsertMissingCBH Configure, Clean, UpdateCBHtoScratch, BuildSessionCleanup

ModuleBuild.psd1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Zachary Loeber
55
#
6-
# Generated on: 9/24/2017
6+
# Generated on: 10/9/2017
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
RootModule = 'ModuleBuild.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.1.8'
15+
ModuleVersion = '0.1.10'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -107,7 +107,7 @@ PrivateData = @{
107107
IconUri = 'https://github.com/zloeber/ModuleBuild/raw/master/src/other/powershell-project.png'
108108

109109
# ReleaseNotes of this module
110-
ReleaseNotes = '0.1.8 release'
110+
ReleaseNotes = '0.1.10 release'
111111

112112
# External dependent modules of this module
113113
# ExternalModuleDependencies = ''

build/ModuleBuild.buildenvironment.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ if ((Get-Variable 'BuildEnv' -ErrorAction:SilentlyContinue) -eq $null) {
2828

2929
# Options - These affect how your eventual build will be run.
3030
OptionAnalyzeCode = $True
31+
OptionCodeHealthReport = $True
3132
OptionCombineFiles = $True
3233
OptionTranscriptEnabled = $false
3334
OptionTranscriptLogFile = 'BuildTranscript.Log'
@@ -46,7 +47,7 @@ if ((Get-Variable 'BuildEnv' -ErrorAction:SilentlyContinue) -eq $null) {
4647
OptionUpdateVersionAfterPublishing = $true
4748

4849
# Additional paths in the source module which should be copied over to the final build release
49-
AdditionalModulePaths = '.\plaster' -split ','
50+
AdditionalModulePaths = @('plaster','plugins')
5051
# Generate a yml file in the root folder of this project for readthedocs.org integration
5152
OptionGenerateReadTheDocs = $True
5253
# Most of the following options you probably don't need to change
@@ -55,6 +56,7 @@ if ((Get-Variable 'BuildEnv' -ErrorAction:SilentlyContinue) -eq $null) {
5556
PrivateFunctionSource = "src\private" # Private function source
5657
OtherModuleSource = "src\other" # Other module source
5758
BaseReleaseFolder = 'release' # Releases directory.
59+
BuildReportsFolder = 'buildreports'
5860
BuildToolFolder = 'build' # Build tool path (these scripts are dot sourced)
5961
ScratchFolder = 'temp' # Scratch path - this is where all our scratch work occurs. It will be cleared out at every run.
6062
FunctionTemplates = "src\templates" # Location of function template files (*.tem)
@@ -129,4 +131,8 @@ if ((Get-Variable 'BuildEnv' -ErrorAction:SilentlyContinue) -eq $null) {
129131
$RequiredModules += 'Powershell-YAML'
130132
}
131133

134+
if ($Script:BuildEnv.OptionCodeHealthReport) {
135+
$RequiredModules += 'PSCodeHealth'
136+
}
137+
132138
}

build/docs/Additional/Acknowledgements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This project owes some acknowlegement to other projects. Here are some other aut
88

99
[Plaster](https://github.com/PowerShell/Plaster) - Used for the code scaffolding portion of this project.
1010

11-
[Haroopad](http://pad.haroopress.com/) - Sweet Markdown Editor.
11+
[PSCodeHealth](https://github.com/MathieuBuisson/PSCodeHealth) - PowerShell code health reporting.
1212

1313
[Hitchhikers Guide to the PowerShell Pipeline](https://xainey.github.io/2017/powershell-module-pipeline/)
1414

build/docs/Additional/ChangeLog.md

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,32 @@
22

33
Project Site: [https://github.com/zloeber/ModuleBuild](https://github.com/zloeber/ModuleBuild)
44

5-
## Version 0.0.1
6-
- Initial release
5+
## Version 0.1.9
6+
- Removed plaster option to choose to combine the module source at build time (and simply made that behavior the default that can be changed later via Set-BuildEnvironment -OptionCombineFiles $false)
7+
- Added option to run a code health report (via PSCodeHealth) against your public and private function directories prior to starting the build
8+
- Added 'Module plugin' capability. This adds base functionality to the module project itself. The first included module plugin is the nlogmodule logging functionality.
79

8-
## Version 0.0.2
9-
- Structural changes
10+
## Version 0.1.6
11+
- Added New-PublicFunction to module along with a template folder and basic function template to start with. Any src\templates\\\<template_name\>.tem file is able to be used for this new feature and any build environment variable surrounded by double percentage symbols will be automatically replaced (ie. %%ModuleName%%).
12+
- Fixed ReadTheDocs yml creation issue with the licensing link.
1013

11-
## Version 0.0.3
12-
- Eliminated all '-Before' and '-After' in task definitions
13-
- Added 'Write-Description' helper function and converted all write-build lines to use it instead (for a quick indented output that is easier on the eyes)
14-
- Eliminated a large number of global variables in favor of simply redefining them in local tasks when required
15-
- Setup readthedocs.net yml file generation to fail with warning if the file already exists.
16-
- Fixed the version check to automatically fail if the build you are running already exists in the powershell gallery.
17-
- Applied the -force flag to several tasks where it made sense to do so (need to manually build with Invoke-Build and the -force parameter to use)
18-
- Fixed up Visual Studio Code tasks.json settings
19-
- Added a prebuild folder for processing dependant/separate scripts prior to starting your build
20-
- Updated much of the documentation.
14+
## Version 0.1.5
15+
- Fixed awful .gitignore settings included in the default scaffolding
16+
- Fixed documentation links to be self-referencing
17+
- Removed AdditionalModulePaths from initial plaster manifest (can just set this with set-buildenvironment after creation)
2118

22-
## Version 0.0.4
23-
- fixes to psgallery upload
19+
## Version 0.1.4
20+
- Fixed invalid mkdocs.yml license link reference
21+
- Fixed invalid reference to acknowledgements folder in plaster manifest (thanks Roberto Desideri!)
2422

25-
## Version 0.0.5
26-
- fixes to plaster template creation
23+
## Version 0.1.3
24+
- Fixes to mkdocs.yml formatting
25+
- Fixed temp build directory exclusion in .gitignore file
2726

28-
## Version 0.0.6
29-
- Changed all template files from .ps1 or psm1 to .template and changed the plaster manifest accordingly
30-
- Change all .<filename> files to remove the period so uploads to the gallery will work properly
31-
- Combined the UpdateRelease and NewVersion tasks and made both promptable
32-
- Fixed git version tag issue with the build script for the plaster manifest file.
33-
- Removed options to prompt for different folder names (like public/private/other/temp) and updated all template files and plaster manifest file accordinly.
27+
## Version 0.1.2
28+
- Updated vs code task names
29+
- Fixed an issue with a null build environment variable causing dynamic parameters in set-buildenvironment to fail
30+
- Several small scaffolding clean ups.
3431

3532
## Version 0.1.1
3633
- Removed prompts for the nuget api key when running initialize-modulebuild.
@@ -44,24 +41,32 @@ Project Site: [https://github.com/zloeber/ModuleBuild](https://github.com/zloebe
4441
- Added setting 'OptionUpdateVersionAfterPublishing' to ensure that this gets done after publishing to the gallery.
4542
- Fixed initial sensitive term settings generation to work on non-domain joined machines.
4643

47-
## Version 0.1.2
48-
- Updated vs code task names
49-
- Fixed an issue with a null build environment variable causing dynamic parameters in set-buildenvironment to fail
50-
- Several small scaffolding clean ups.
44+
## Version 0.0.6
45+
- Changed all template files from .ps1 or psm1 to .template and changed the plaster manifest accordingly
46+
- Change all .<filename> files to remove the period so uploads to the gallery will work properly
47+
- Combined the UpdateRelease and NewVersion tasks and made both promptable
48+
- Fixed git version tag issue with the build script for the plaster manifest file.
49+
- Removed options to prompt for different folder names (like public/private/other/temp) and updated all template files and plaster manifest file accordinly.
5150

52-
## Version 0.1.3
53-
- Fixes to mkdocs.yml formatting
54-
- Fixed temp build directory exclusion in .gitignore file
51+
## Version 0.0.5
52+
- fixes to plaster template creation
5553

56-
## Version 0.1.4
57-
- Fixed invalid mkdocs.yml license link reference
58-
- Fixed invalid reference to acknowledgements folder in plaster manifest (thanks Roberto Desideri!)
54+
## Version 0.0.4
55+
- fixes to psgallery upload
5956

60-
## Version 0.1.5
61-
- Fixed awful .gitignore settings included in the default scaffolding
62-
- Fixed documentation links to be self-referencing
63-
- Removed AdditionalModulePaths from initial plaster manifest (can just set this with set-buildenvironment after creation)
57+
## Version 0.0.3
58+
- Eliminated all '-Before' and '-After' in task definitions
59+
- Added 'Write-Description' helper function and converted all write-build lines to use it instead (for a quick indented output that is easier on the eyes)
60+
- Eliminated a large number of global variables in favor of simply redefining them in local tasks when required
61+
- Setup readthedocs.net yml file generation to fail with warning if the file already exists.
62+
- Fixed the version check to automatically fail if the build you are running already exists in the powershell gallery.
63+
- Applied the -force flag to several tasks where it made sense to do so (need to manually build with Invoke-Build and the -force parameter to use)
64+
- Fixed up Visual Studio Code tasks.json settings
65+
- Added a prebuild folder for processing dependant/separate scripts prior to starting your build
66+
- Updated much of the documentation.
6467

65-
## Version 0.1.6
66-
- Added New-PublicFunction to module along with a template folder and basic function template to start with. Any src\templates\*.tem file is able to be used for this new feature and any build environment variable surrounded by double percentage symbols will be automatically replaced (ie. %%ModuleName%%).
67-
- Fixed ReadTheDocs yml creation issue with the licensing link.
68+
## Version 0.0.2
69+
- Structural changes
70+
71+
## Version 0.0.1
72+
- Initial release

build/docs/ReadTheDocs/Usage/11 - Module Plugins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ This includes all the code needed to automatically log all of the following comm
1616

1717
The log file will automatically be written to the loading user's $ENV:TEMP\<modulename>.log file when the module is loaded (and stop when the module is unloaded).
1818

19-
Be careful with this one as **ALL** output from the commands mentioned will be logged. This may not be your intent.
19+
Be careful with this one as **ALL** output from the commands mentioned will be logged. This may not be your intent. You can alter the behavior of this plugin as you see fit by changing the code in plugins\NLog\Load.ps1 and plugins\NLog\UnLoad.ps1.

0 commit comments

Comments
 (0)