From 11fb272dcd4e2d4d2e516440b37de37fbe2cd471 Mon Sep 17 00:00:00 2001 From: justin-p Date: Thu, 3 Jan 2019 15:01:31 +0100 Subject: [PATCH 001/102] Ensure that the plaster manifest includes the entire NLog directory. --- plaster/PlasterContent.ps1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plaster/PlasterContent.ps1 b/plaster/PlasterContent.ps1 index 259a5ea..1801a9b 100644 --- a/plaster/PlasterContent.ps1 +++ b/plaster/PlasterContent.ps1 @@ -74,6 +74,24 @@ $Content = @( Destination = 'plugins\nlog\NLog\NLogModule' Condition = '$PLASTER_PARAM_PluginModuleLogging -eq "True"' }, + @{ + ContentType = 'file' + Source = 'scaffold\plugins\NLog\NLogModule\docs\*' + Destination = 'plugins\nlog\NLog\NLogModule\docs' + Condition = '$PLASTER_PARAM_PluginModuleLogging -eq "True"' + }, + @{ + ContentType = 'file' + Source = 'scaffold\plugins\NLog\NLogModule\en-US\*' + Destination = 'plugins\nlog\NLog\NLogModule\en-US' + Condition = '$PLASTER_PARAM_PluginModuleLogging -eq "True"' + }, + @{ + ContentType = 'file' + Source = 'scaffold\plugins\NLog\NLogModule\lib\*' + Destination = 'plugins\nlog\NLog\NLogModule\lib' + Condition = '$PLASTER_PARAM_PluginModuleLogging -eq "True"' + }, @{ ContentType = 'file' Source = 'scaffold\build\cleanup\*' From 393d5aead62396e66950143d8c4f635d19113233 Mon Sep 17 00:00:00 2001 From: justin-p Date: Thu, 3 Jan 2019 15:27:36 +0100 Subject: [PATCH 002/102] Ensure that NSLog subdirectorys are created and that the right path is used. --- plaster/PlasterContent.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plaster/PlasterContent.ps1 b/plaster/PlasterContent.ps1 index 1801a9b..5a72dda 100644 --- a/plaster/PlasterContent.ps1 +++ b/plaster/PlasterContent.ps1 @@ -71,25 +71,25 @@ $Content = @( @{ ContentType = 'file' Source = 'scaffold\plugins\NLog\NLogModule\*' - Destination = 'plugins\nlog\NLog\NLogModule' + Destination = 'plugins\nlog\NLogModule' Condition = '$PLASTER_PARAM_PluginModuleLogging -eq "True"' }, @{ ContentType = 'file' Source = 'scaffold\plugins\NLog\NLogModule\docs\*' - Destination = 'plugins\nlog\NLog\NLogModule\docs' + Destination = 'plugins\nlog\NLogModule\docs' Condition = '$PLASTER_PARAM_PluginModuleLogging -eq "True"' }, @{ ContentType = 'file' Source = 'scaffold\plugins\NLog\NLogModule\en-US\*' - Destination = 'plugins\nlog\NLog\NLogModule\en-US' + Destination = 'plugins\nlog\NLogModule\en-US' Condition = '$PLASTER_PARAM_PluginModuleLogging -eq "True"' }, @{ ContentType = 'file' Source = 'scaffold\plugins\NLog\NLogModule\lib\*' - Destination = 'plugins\nlog\NLog\NLogModule\lib' + Destination = 'plugins\nlog\NLogModule\lib' Condition = '$PLASTER_PARAM_PluginModuleLogging -eq "True"' }, @{ From e6b1b5951958ab34e2a876aee99887c2cb9fb33b Mon Sep 17 00:00:00 2001 From: justin-p Date: Fri, 4 Jan 2019 16:41:09 +0100 Subject: [PATCH 003/102] When adding PSCodeHealth to RequiredModules use the script scope --- ModuleBuild.build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ModuleBuild.build.ps1 b/ModuleBuild.build.ps1 index 5a8de8f..31b7b1a 100644 --- a/ModuleBuild.build.ps1 +++ b/ModuleBuild.build.ps1 @@ -66,7 +66,7 @@ task LoadRequiredModules { $Script:RequiredModules += 'Powershell-YAML' } if ($Script:BuildEnv.OptionCodeHealthReport) { - $RequiredModules += 'PSCodeHealth' + $Script:RequiredModules += 'PSCodeHealth' } $Script:RequiredModules | Foreach-Object { From abaa8e7c1ac7e24b7870290bf4f7b0ce5e9d19da Mon Sep 17 00:00:00 2001 From: justin-p Date: Fri, 4 Jan 2019 16:55:12 +0100 Subject: [PATCH 004/102] Plaster scaffold template should also be updated with the script scope. --- plaster/ModuleBuild/scaffold/modulename.build.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plaster/ModuleBuild/scaffold/modulename.build.template b/plaster/ModuleBuild/scaffold/modulename.build.template index d595536..77c617b 100644 --- a/plaster/ModuleBuild/scaffold/modulename.build.template +++ b/plaster/ModuleBuild/scaffold/modulename.build.template @@ -66,7 +66,7 @@ task LoadRequiredModules { $Script:RequiredModules += 'Powershell-YAML' } if ($Script:BuildEnv.OptionCodeHealthReport) { - $RequiredModules += 'PSCodeHealth' + $Script:RequiredModules += 'PSCodeHealth' } $Script:RequiredModules | Foreach-Object { if ((get-module $_ -ListAvailable) -eq $null) { From b64e65ae78ff50bfea0b5bd00f8782e0ff564e45 Mon Sep 17 00:00:00 2001 From: justin-p Date: Mon, 7 Jan 2019 11:03:36 +0100 Subject: [PATCH 005/102] Set Indentation to space and tabsize 4 by default --- plaster/ModuleBuild/scaffold/vscode/settings.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plaster/ModuleBuild/scaffold/vscode/settings.json b/plaster/ModuleBuild/scaffold/vscode/settings.json index 7a75585..8e62dee 100644 --- a/plaster/ModuleBuild/scaffold/vscode/settings.json +++ b/plaster/ModuleBuild/scaffold/vscode/settings.json @@ -9,6 +9,18 @@ "<%=$PLASTER_PARAM_ScratchFolder%>": true }, + //-------- Indentation -------- + + // The number of spaces a tab is equal to. This setting is overridden + // based on the file contents when `editor.detectIndentation` is true. + "editor.tabSize": 4, + // Insert spaces when pressing Tab. This setting is overriden + // based on the file contents when `editor.detectIndentation` is true. + "editor.insertSpaces": true, + // When opening a file, `editor.tabSize` and `editor.insertSpaces` + // will be detected based on the file contents. Set to false to keep + // the values you've explicitly set, above. + "editor.detectIndentation": false, //-------- PowerShell Configuration -------- // Use a custom PowerShell Script Analyzer settings file for this workspace. From 738b3e3365455aa959284dd4cf47e533222f1f8e Mon Sep 17 00:00:00 2001 From: justin-p Date: Tue, 8 Jan 2019 12:37:14 +0100 Subject: [PATCH 006/102] make now returns a result instead of git fatal error when there is no version/tag --- plaster/make.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plaster/make.ps1 b/plaster/make.ps1 index d33ebf5..4f1b13c 100644 --- a/plaster/make.ps1 +++ b/plaster/make.ps1 @@ -19,7 +19,7 @@ catch { . .\PlasterParams.ps1 . .\PlasterContent.ps1 -$version = (git describe --match "v[0-9]*") -replace 'v','' +$version = (git describe --tags --always --match "v[0-9]*") -replace 'v','' if ($null -eq $version) { $version = '0.0.1' } From 5a6c9afc875977b1634674e7d4b332aaff8ccea0 Mon Sep 17 00:00:00 2001 From: justin-p Date: Tue, 8 Jan 2019 12:56:10 +0100 Subject: [PATCH 007/102] LoadBuildTools on InstallAndTestModule for Get-SpecialPaths function --- plaster/ModuleBuild/scaffold/modulename.build.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plaster/ModuleBuild/scaffold/modulename.build.template b/plaster/ModuleBuild/scaffold/modulename.build.template index 77c617b..9724b0b 100644 --- a/plaster/ModuleBuild/scaffold/modulename.build.template +++ b/plaster/ModuleBuild/scaffold/modulename.build.template @@ -883,7 +883,7 @@ task GithubPush VersionCheck, { task . Configure, CodeHealthReport, Clean, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, PostBuildTasks, BuildSessionCleanup # Synopsis: Install and test load the module. -task InstallAndTestModule InstallModule, TestInstalledModule +task InstallAndTestModule LoadBuildTools, InstallModule, TestInstalledModule # Synopsis: Build, Install, and Test the module task BuildInstallAndTestModule Configure, CodeHealthReport, Clean, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, InstallModule, TestInstalledModule, PostBuildTasks, BuildSessionCleanup @@ -891,5 +891,5 @@ task BuildInstallAndTestModule Configure, CodeHealthReport, Clean, PrepareStage, # Synopsis: Build, Install, Test, and Publish the module task BuildInstallTestAndPublishModule Configure, CodeHealthReport, Clean, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, InstallModule, TestInstalledModule, PublishPSGallery, PostBuildTasks, BuildSessionCleanup -# Synopsis: Instert Comment Based Help where it doesn't already exist (output to scratch directory) +# Synopsis: Insert Comment Based Help where it doesn't already exist (output to scratch directory) task InsertMissingCBH Configure, Clean, UpdateCBHtoScratch, BuildSessionCleanup \ No newline at end of file From 2403aff399bda0b61b6512e46397dd2f592f8508 Mon Sep 17 00:00:00 2001 From: justin-p Date: Wed, 9 Jan 2019 11:30:05 +0100 Subject: [PATCH 008/102] Add PSScriptAnalyzerSettings.psd1 file --- ModuleBuild.build.ps1 | 28 +++++++---------- PSScriptAnalyzerSettings.psd1 | 4 +++ plaster/ModuleBuild/plasterManifest.xml | 19 ++++++++++-- .../scaffold/PSScriptAnalyzerSettings.psd1 | 26 ++++++++++++++++ .../scaffold/modulename.build.template | 31 ++++++++----------- .../scaffold/src/other/PostLoad.ps1 | 2 ++ plaster/PlasterContent.ps1 | 7 ++++- src/other/PostLoad.ps1 | 2 ++ 8 files changed, 81 insertions(+), 38 deletions(-) create mode 100644 PSScriptAnalyzerSettings.psd1 create mode 100644 plaster/ModuleBuild/scaffold/PSScriptAnalyzerSettings.psd1 diff --git a/ModuleBuild.build.ps1 b/ModuleBuild.build.ps1 index 31b7b1a..fdf0bcc 100644 --- a/ModuleBuild.build.ps1 +++ b/ModuleBuild.build.ps1 @@ -462,31 +462,25 @@ task UpdateCBH { task AnalyzeModuleRelease -if {$Script:BuildEnv.OptionAnalyzeCode} { Write-Description White 'Analyzing the project with ScriptAnalyzer' -accent $StageReleasePath = Join-Path (Join-Path $BuildRoot $Script:BuildEnv.ScratchFolder) $Script:BuildEnv.BaseReleaseFolder - $Analysis = Invoke-ScriptAnalyzer -Path $StageReleasePath - $AnalysisErrors = @($Analysis | Where-Object {@('Information', 'Warning') -notcontains $_.Severity}) - if ($AnalysisErrors.Count -ne 0) { - Write-Build White 'The following errors came up in the script analysis:' -level 2 - $AnalysisErrors - Write-Build - Write-Build White "Note that this was from the script analysis run against $StageReleasePath" -Level 2 - Prompt-ForBuildBreak -CustomError $AnalysisErrors + $Analysis = Invoke-ScriptAnalyzer -Path $StageReleasePath -Settings (Join-Path $BuildRoot "PSScriptAnalyzerSettings.psd1") + if ($Analysis.Count) { + Write-Description White "Note that this was from the script analysis run against $StageReleasePath" -level 2 + Write-Description Red "$($Analysis.Count) linting errors or warnings were found:" -level 2 + $Analysis | Format-Table -AutoSize + Write-Error "$($Analysis.Count) linting errors or warnings were found. The build cannot continue." -ErrorAction Stop } } # Synopsis: Run PSScriptAnalyzer against the public source files. task AnalyzePublic { - Write-Description White 'Analyzing the public source files with ScriptAnalyzer.' -accent - $Analysis = Invoke-ScriptAnalyzer -Path (Join-Path $BuildRoot $Script:BuildEnv.PublicFunctionSource) - $AnalysisErrors = @($Analysis | Where-Object {@('Information', 'Warning') -notcontains $_.Severity}) - - if ($AnalysisErrors.Count -ne 0) { - Write-Description White 'The following errors came up in the script analysis:' -level 2 - $AnalysisErrors - Write-Description + Write-Description White "Analyzing the public source files with ScriptAnalyzer." -accent + $Analysis = Invoke-ScriptAnalyzer -Path (Join-Path $BuildRoot $Script:BuildEnv.PublicFunctionSource) -Settings (Join-Path $BuildRoot "PSScriptAnalyzerSettings.psd1") + if ($Analysis.Count) { Write-Description White "Note that this was from the script analysis run against $($Script:BuildEnv.PublicFunctionSource)" -level 2 + Write-Description Red "$($Analysis.Count) linting errors or warnings were found:" -level 2 + $Analysis | Format-Table -AutoSize } } - # Synopsis: Build help files for module task CreateHelp CreateMarkdownHelp, CreateExternalHelp, CreateUpdateableHelpCAB, CreateProjectHelp, AddAdditionalDocFiles diff --git a/PSScriptAnalyzerSettings.psd1 b/PSScriptAnalyzerSettings.psd1 new file mode 100644 index 0000000..80bfffb --- /dev/null +++ b/PSScriptAnalyzerSettings.psd1 @@ -0,0 +1,4 @@ +@{ + IncludeRules=@('PSProvideCommentHelp', + 'PSAvoidUsingWriteHost') +} \ No newline at end of file diff --git a/plaster/ModuleBuild/plasterManifest.xml b/plaster/ModuleBuild/plasterManifest.xml index f603fe9..e04e5e0 100644 --- a/plaster/ModuleBuild/plasterManifest.xml +++ b/plaster/ModuleBuild/plasterManifest.xml @@ -4,7 +4,7 @@ templateType="Project" xmlns="http://www.microsoft.com/schemas/PowerShell/Plaster/v1"> ModuleBuild - c0ce518c-f894-4114-91f9-d49945d9dfb1 + 4b283342-b625-4db2-99c7-cf85de213289 0.0.1 New ModuleBuild Project Create a new PowerShell Module with a ModuleBuild wrapper @@ -194,7 +194,19 @@ condition="$PLASTER_PARAM_PluginModuleLogging -eq "True"" /> + + + + \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/PSScriptAnalyzerSettings.psd1 b/plaster/ModuleBuild/scaffold/PSScriptAnalyzerSettings.psd1 new file mode 100644 index 0000000..bde2636 --- /dev/null +++ b/plaster/ModuleBuild/scaffold/PSScriptAnalyzerSettings.psd1 @@ -0,0 +1,26 @@ +@{ + IncludeRules=@('PSUseApprovedVerbs', + 'PSReservedCmdletChar', + 'PSReservedParams', + 'PSShouldProcess', + 'PSUseShouldProcessForStateChangingFunctions', + 'PSUseSingularNouns', + 'PSMissingModuleManifestField', + 'PSAvoidDefaultValueSwitchParameter', + 'PSAvoidUsingCmdletAliases', + 'PSAvoidUsingWMICmdlet', + 'PSAvoidUsingEmptyCatchBlock', + 'PSUseCmdletCorrectly', + 'PSUseShouldProcessForStateChangingFunctions', + 'PSAvoidUsingPositionalParameters', + 'PSAvoidGlobalVars', + 'PSUseDeclaredVarsMoreThanAssignments', + 'PSAvoidUsingInvokeExpression', + 'PSAvoidUsingPlainTextForPassword', + 'PSAvoidUsingComputerNameHardcoded', + 'PSAvoidUsingConvertToSecureStringWithPlainText', + 'PSUsePSCredentialType', + 'PSAvoidUsingUserNameAndPasswordParams', + 'PSDSC*' + ) +} \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/modulename.build.template b/plaster/ModuleBuild/scaffold/modulename.build.template index 9724b0b..78693e6 100644 --- a/plaster/ModuleBuild/scaffold/modulename.build.template +++ b/plaster/ModuleBuild/scaffold/modulename.build.template @@ -465,28 +465,23 @@ task UpdateCBH { task AnalyzeModuleRelease -if {$Script:BuildEnv.OptionAnalyzeCode} { Write-Description White 'Analyzing the project with ScriptAnalyzer' -accent $StageReleasePath = Join-Path (Join-Path $BuildRoot $Script:BuildEnv.ScratchFolder) $Script:BuildEnv.BaseReleaseFolder - $Analysis = Invoke-ScriptAnalyzer -Path $StageReleasePath - $AnalysisErrors = @($Analysis | Where-Object {@('Information', 'Warning') -notcontains $_.Severity}) - if ($AnalysisErrors.Count -ne 0) { - Write-Build White 'The following errors came up in the script analysis:' -level 2 - $AnalysisErrors - Write-Build - Write-Build White "Note that this was from the script analysis run against $StageReleasePath" -Level 2 - Prompt-ForBuildBreak -CustomError $AnalysisErrors + $Analysis = Invoke-ScriptAnalyzer -Path $StageReleasePath -Settings (Join-Path $BuildRoot "PSScriptAnalyzerSettings.psd1") + if ($Analysis.Count) { + Write-Description White "Note that this was from the script analysis run against $StageReleasePath" -level 2 + Write-Description Red "$($Analysis.Count) linting errors or warnings were found:" -level 2 + $Analysis | Format-Table -AutoSize + Write-Error "$($Analysis.Count) linting errors or warnings were found. The build cannot continue." -ErrorAction Stop } } # Synopsis: Run PSScriptAnalyzer against the public source files. task AnalyzePublic { - Write-Description White 'Analyzing the public source files with ScriptAnalyzer.' -accent - $Analysis = Invoke-ScriptAnalyzer -Path (Join-Path $BuildRoot $Script:BuildEnv.PublicFunctionSource) - $AnalysisErrors = @($Analysis | Where-Object {@('Information', 'Warning') -notcontains $_.Severity}) - - if ($AnalysisErrors.Count -ne 0) { - Write-Description White 'The following errors came up in the script analysis:' -level 2 - $AnalysisErrors - Write-Description + Write-Description White "Analyzing the public source files with ScriptAnalyzer." -accent + $Analysis = Invoke-ScriptAnalyzer -Path (Join-Path $BuildRoot $Script:BuildEnv.PublicFunctionSource) -Settings (Join-Path $BuildRoot "PSScriptAnalyzerSettings.psd1") + if ($Analysis.Count) { Write-Description White "Note that this was from the script analysis run against $($Script:BuildEnv.PublicFunctionSource)" -level 2 + Write-Description Red "$($Analysis.Count) linting errors or warnings were found:" -level 2 + $Analysis | Format-Table -AutoSize } } @@ -883,7 +878,7 @@ task GithubPush VersionCheck, { task . Configure, CodeHealthReport, Clean, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, PostBuildTasks, BuildSessionCleanup # Synopsis: Install and test load the module. -task InstallAndTestModule LoadBuildTools, InstallModule, TestInstalledModule +task InstallAndTestModule InstallModule, TestInstalledModule # Synopsis: Build, Install, and Test the module task BuildInstallAndTestModule Configure, CodeHealthReport, Clean, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, InstallModule, TestInstalledModule, PostBuildTasks, BuildSessionCleanup @@ -891,5 +886,5 @@ task BuildInstallAndTestModule Configure, CodeHealthReport, Clean, PrepareStage, # Synopsis: Build, Install, Test, and Publish the module task BuildInstallTestAndPublishModule Configure, CodeHealthReport, Clean, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, InstallModule, TestInstalledModule, PublishPSGallery, PostBuildTasks, BuildSessionCleanup -# Synopsis: Insert Comment Based Help where it doesn't already exist (output to scratch directory) +# Synopsis: Instert Comment Based Help where it doesn't already exist (output to scratch directory) task InsertMissingCBH Configure, Clean, UpdateCBHtoScratch, BuildSessionCleanup \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/src/other/PostLoad.ps1 b/plaster/ModuleBuild/scaffold/src/other/PostLoad.ps1 index 5b5e3b3..2bad7d1 100644 --- a/plaster/ModuleBuild/scaffold/src/other/PostLoad.ps1 +++ b/plaster/ModuleBuild/scaffold/src/other/PostLoad.ps1 @@ -53,7 +53,9 @@ $null = Register-EngineEvent -SourceIdentifier ( [System.Management.Automation.P } # Use this in your scripts to check if the function is being called from your module or independantly. +# Call it immediately to avoid PSScriptAnalyzer 'PSUseDeclaredVarsMoreThanAssignments' $ThisModuleLoaded = $true +$ThisModuleLoaded # Non-function exported public module members might go here. #Export-ModuleMember -Variable SomeVariable -Function * \ No newline at end of file diff --git a/plaster/PlasterContent.ps1 b/plaster/PlasterContent.ps1 index 5a72dda..2451742 100644 --- a/plaster/PlasterContent.ps1 +++ b/plaster/PlasterContent.ps1 @@ -26,7 +26,7 @@ $Content = @( ContentType = 'file' Source = 'scaffold\gitattributes' Destination = '.gitattributes' - }, + }, @{ ContentType = 'templateFile' Source = 'scaffold\vscode\*' @@ -190,5 +190,10 @@ $Content = @( ContentType = 'templateFile' Source = 'scaffold\build\docs\ReadTheDocs\*' Destination = 'build\docs\ReadTheDocs' + }, + @{ + ContentType = 'file' + Source = 'scaffold\PSScriptAnalyzerSettings.psd1' + Destination = 'PSScriptAnalyzerSettings.psd1' } ) \ No newline at end of file diff --git a/src/other/PostLoad.ps1 b/src/other/PostLoad.ps1 index e1c530c..d43deb2 100644 --- a/src/other/PostLoad.ps1 +++ b/src/other/PostLoad.ps1 @@ -54,7 +54,9 @@ $null = Register-EngineEvent -SourceIdentifier ( [System.Management.Automation.P } # Use this in your scripts to check if the function is being called from your module or independantly. +# Call it immediately to avoid PSScriptAnalyzer 'PSUseDeclaredVarsMoreThanAssignments' $ThisModuleLoaded = $true +$ThisModuleLoaded # Non-function exported public module members might go here. #Export-ModuleMember -Variable SomeVariable -Function * From 72d6eeec18ea8d2bf49cca4af5c44779e39f9d9b Mon Sep 17 00:00:00 2001 From: justin-p Date: Wed, 9 Jan 2019 15:27:59 +0100 Subject: [PATCH 009/102] Fix -SourceModule on Initialize-ModuleBuild --- plaster/ModuleBuild/plasterManifest.xml | 10 +++++++--- plaster/PlasterContent.ps1 | 4 ++-- plaster/PlasterParams.ps1 | 5 +++++ src/public/Initialize-ModuleBuild.ps1 | 23 +++++++++++++++-------- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/plaster/ModuleBuild/plasterManifest.xml b/plaster/ModuleBuild/plasterManifest.xml index e04e5e0..36a4e46 100644 --- a/plaster/ModuleBuild/plasterManifest.xml +++ b/plaster/ModuleBuild/plasterManifest.xml @@ -4,7 +4,7 @@ templateType="Project" xmlns="http://www.microsoft.com/schemas/PowerShell/Plaster/v1"> ModuleBuild - 4b283342-b625-4db2-99c7-cf85de213289 + 3fd34e00-75da-4e7d-96c4-64009f3790e2 0.0.1 New ModuleBuild Project Create a new PowerShell Module with a ModuleBuild wrapper @@ -24,6 +24,10 @@ name="ModuleAuthor" type="text" prompt="Enter a module author" /> + Date: Wed, 9 Jan 2019 16:20:44 +0100 Subject: [PATCH 010/102] VSCode should use the included PSScriptAnalyzerSettings.psd1 --- .vscode/settings.json | 2 +- plaster/ModuleBuild/scaffold/vscode/settings.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 87ffc11..9c38760 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,5 +13,5 @@ // Use a custom PowerShell Script Analyzer settings file for this workspace. // Relative paths for this setting are always relative to the workspace root dir. - "powershell.scriptAnalysis.settingsPath": "ScriptAnalyzerSettings.psd1" + "powershell.scriptAnalysis.settingsPath": "PSScriptAnalyzerSettings.psd1" } \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/vscode/settings.json b/plaster/ModuleBuild/scaffold/vscode/settings.json index 8e62dee..8e2471c 100644 --- a/plaster/ModuleBuild/scaffold/vscode/settings.json +++ b/plaster/ModuleBuild/scaffold/vscode/settings.json @@ -15,15 +15,15 @@ // based on the file contents when `editor.detectIndentation` is true. "editor.tabSize": 4, // Insert spaces when pressing Tab. This setting is overriden - // based on the file contents when `editor.detectIndentation` is true. + // based on the file contents when `editor.detectIndentation` is true. "editor.insertSpaces": true, // When opening a file, `editor.tabSize` and `editor.insertSpaces` // will be detected based on the file contents. Set to false to keep - // the values you've explicitly set, above. + // the values you've explicitly set, above. "editor.detectIndentation": false, //-------- PowerShell Configuration -------- // Use a custom PowerShell Script Analyzer settings file for this workspace. // Relative paths for this setting are always relative to the workspace root dir. - "powershell.scriptAnalysis.settingsPath": "ScriptAnalyzerSettings.psd1" + "powershell.scriptAnalysis.settingsPath": "PSScriptAnalyzerSettings.psd1" } \ No newline at end of file From 742dfefda3f6d722d25d912b6dc5a12ebd758f44 Mon Sep 17 00:00:00 2001 From: justin-p Date: Thu, 10 Jan 2019 16:36:17 +0100 Subject: [PATCH 011/102] Removed duplicated test folder in scaffold. Removed meta subfolder since its not used. Also refrences a repo that doenst exists anymore. `claudiospizzi/PowerShellModuleBase` Move tests folder out of src. Make test folder match src folder. Differentiate between Unit and Intergration tests. readme.md in plaster scaffold does not reflect what module does and can do. .\Build.ps1 -test does not work. There is no such task. .\Build.ps1 -test C:\_git\github\ModuleBuild\Build.ps1 : A parameter cannot be found that matches parameter name 'test'. At line:1 char:13 + .\Build.ps1 -test + ~~~~~ + CategoryInfo : InvalidArgument: (:) [Build.ps1], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Build.ps1 It does not download something from `claudiospizzi/PowerShellModuleBase`. It wouldn't be able to anyhow since doesn't exists anymore. --- PSScriptAnalyzerSettings.psd1 | 24 +- plaster/ModuleBuild/plasterManifest.xml | 24 +- .../build/docs/Additional/Acknowledgements.md | 4 +- plaster/ModuleBuild/scaffold/readme.md | 9 +- .../scaffold/src/tests/FunctionCBH.Tests.ps1 | 60 --- .../src/tests/ModuleManifest.Tests.ps1 | 205 ---------- .../src/tests/ScriptAnalyzer.Tests.ps1 | 32 -- .../src/tests/SensitiveTermScan.Tests.ps1 | 28 -- .../src/tests/meta/Autoload.Tests.ps1 | 23 -- .../src/tests/meta/FileContent.Tests.ps1 | 349 ------------------ .../src/tests/meta/FileEncoding.Tests.ps1 | 54 --- .../src/tests/meta/FileFormatting.Tests.ps1 | 96 ----- .../src/tests/meta/ProjectStructure.Tests.ps1 | 152 -------- .../src/tests/meta/ScriptAnalyzer.Tests.ps1 | 37 -- .../scaffold/tests/FunctionCBH.Tests.ps1 | 60 --- .../scaffold/tests/ModuleManifest.Tests.ps1 | 205 ---------- .../scaffold/tests/ScriptAnalyzer.Tests.ps1 | 32 -- .../tests/SensitiveTermScan.Tests.ps1 | 28 -- .../tests/intergration/other/readme.md | 1 + .../tests/intergration/private/readme.md | 1 + .../tests/intergration/public/readme.md | 1 + .../scaffold/tests/meta/Autoload.Tests.ps1 | 23 -- .../scaffold/tests/meta/FileContent.Tests.ps1 | 349 ------------------ .../tests/meta/FileEncoding.Tests.ps1 | 54 --- .../tests/meta/FileFormatting.Tests.ps1 | 96 ----- .../tests/meta/ProjectStructure.Tests.ps1 | 152 -------- .../tests/meta/ScriptAnalyzer.Tests.ps1 | 37 -- .../scaffold/tests/unit/other/readme.md | 1 + .../scaffold/tests/unit/private/readme.md | 1 + .../scaffold/tests/unit/public/readme.md | 1 + plaster/PlasterContent.ps1 | 36 +- src/tests/FunctionCBH.Tests.ps1 | 60 --- src/tests/ModuleManifest.Tests.ps1 | 205 ---------- src/tests/ScriptAnalyzer.Tests.ps1 | 32 -- src/tests/SensitiveTermScan.Tests.ps1 | 28 -- tests/intergration/private/readme.md | 1 + tests/intergration/public/readme.md | 1 + tests/unit/private/readme.md | 1 + tests/unit/public/readme.md | 1 + 39 files changed, 93 insertions(+), 2411 deletions(-) delete mode 100644 plaster/ModuleBuild/scaffold/src/tests/FunctionCBH.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/src/tests/ModuleManifest.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/src/tests/ScriptAnalyzer.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/src/tests/SensitiveTermScan.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/src/tests/meta/Autoload.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/src/tests/meta/FileContent.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/src/tests/meta/FileEncoding.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/src/tests/meta/FileFormatting.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/src/tests/meta/ProjectStructure.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/src/tests/meta/ScriptAnalyzer.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/tests/FunctionCBH.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/tests/ModuleManifest.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/tests/ScriptAnalyzer.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/tests/SensitiveTermScan.Tests.ps1 create mode 100644 plaster/ModuleBuild/scaffold/tests/intergration/other/readme.md create mode 100644 plaster/ModuleBuild/scaffold/tests/intergration/private/readme.md create mode 100644 plaster/ModuleBuild/scaffold/tests/intergration/public/readme.md delete mode 100644 plaster/ModuleBuild/scaffold/tests/meta/Autoload.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/tests/meta/FileContent.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/tests/meta/FileEncoding.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/tests/meta/FileFormatting.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/tests/meta/ProjectStructure.Tests.ps1 delete mode 100644 plaster/ModuleBuild/scaffold/tests/meta/ScriptAnalyzer.Tests.ps1 create mode 100644 plaster/ModuleBuild/scaffold/tests/unit/other/readme.md create mode 100644 plaster/ModuleBuild/scaffold/tests/unit/private/readme.md create mode 100644 plaster/ModuleBuild/scaffold/tests/unit/public/readme.md delete mode 100644 src/tests/FunctionCBH.Tests.ps1 delete mode 100644 src/tests/ModuleManifest.Tests.ps1 delete mode 100644 src/tests/ScriptAnalyzer.Tests.ps1 delete mode 100644 src/tests/SensitiveTermScan.Tests.ps1 create mode 100644 tests/intergration/private/readme.md create mode 100644 tests/intergration/public/readme.md create mode 100644 tests/unit/private/readme.md create mode 100644 tests/unit/public/readme.md diff --git a/PSScriptAnalyzerSettings.psd1 b/PSScriptAnalyzerSettings.psd1 index 80bfffb..bcc0a92 100644 --- a/PSScriptAnalyzerSettings.psd1 +++ b/PSScriptAnalyzerSettings.psd1 @@ -1,4 +1,24 @@ @{ - IncludeRules=@('PSProvideCommentHelp', - 'PSAvoidUsingWriteHost') + IncludeRules=@('PSUseApprovedVerbs', + 'PSReservedCmdletChar', + 'PSReservedParams', + 'PSShouldProcess', + 'PSUseShouldProcessForStateChangingFunctions', + 'PSUseSingularNouns', + 'PSMissingModuleManifestField', + 'PSAvoidDefaultValueSwitchParameter', + 'PSAvoidUsingCmdletAliases', + 'PSAvoidUsingWMICmdlet', + 'PSAvoidUsingEmptyCatchBlock', + 'PSUseCmdletCorrectly', + 'PSUseShouldProcessForStateChangingFunctions', + 'PSAvoidUsingPositionalParameters', + 'PSAvoidGlobalVars', + 'PSUseDeclaredVarsMoreThanAssignments', + 'PSAvoidUsingInvokeExpression', + 'PSAvoidUsingPlainTextForPassword', + 'PSAvoidUsingComputerNameHardcoded', + 'PSUsePSCredentialType', + 'PSDSC*' + ) } \ No newline at end of file diff --git a/plaster/ModuleBuild/plasterManifest.xml b/plaster/ModuleBuild/plasterManifest.xml index 36a4e46..d95627c 100644 --- a/plaster/ModuleBuild/plasterManifest.xml +++ b/plaster/ModuleBuild/plasterManifest.xml @@ -4,7 +4,7 @@ templateType="Project" xmlns="http://www.microsoft.com/schemas/PowerShell/Plaster/v1"> ModuleBuild - 3fd34e00-75da-4e7d-96c4-64009f3790e2 + 4794ac4a-1fbc-49f4-973f-9ece24eaa1d9 0.0.1 New ModuleBuild Project Create a new PowerShell Module with a ModuleBuild wrapper @@ -190,8 +190,26 @@ source="scaffold\src\templates\*" destination="src\templates" /> + source="scaffold\tests\" + destination="tests" /> + + + + + + ](<%=$PLASTER_PARAM_ModuleWebsite%>) -This project owes some acknowlegement to other projects. Here are some other authors or projects which have made this project possible. If you believe you or a project should be included in this list please let us know. +This project owes some acknowledgements to other projects. Here are some other authors or projects which have made this project possible. If you believe you or a project should be included in this list please let us know. -[ModuleBuild](https://github.com/zloeber/ModuleBuild) - A PowerShell module build framwork. \ No newline at end of file +[ModuleBuild](https://github.com/zloeber/ModuleBuild) - A PowerShell module build framework. \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/readme.md b/plaster/ModuleBuild/scaffold/readme.md index 9720b6f..087d0f7 100644 --- a/plaster/ModuleBuild/scaffold/readme.md +++ b/plaster/ModuleBuild/scaffold/readme.md @@ -36,10 +36,11 @@ Studio Code and ensure that the PowerShell extension is installed. * [Visual Studio Code] * [PowerShell Extension] -This module is tested with the PowerShell testing framework Pester. To run all -tests, just start the included test script `.\Build.ps1 -test` or invoke Pester -directly with the `Invoke-Pester` cmdlet in the tests directory. The tests will automatically download -the latest meta test from the claudiospizzi/PowerShellModuleBase repository. +// This module is tested with the PowerShell testing framework Pester. To run all +// tests, just start the included test script `.\Build.ps1 -test` or invoke Pester +// directly with the `Invoke-Pester` cmdlet in the tests directory. + +// Not true at the moment. ## Other Information diff --git a/plaster/ModuleBuild/scaffold/src/tests/FunctionCBH.Tests.ps1 b/plaster/ModuleBuild/scaffold/src/tests/FunctionCBH.Tests.ps1 deleted file mode 100644 index 0f418c3..0000000 --- a/plaster/ModuleBuild/scaffold/src/tests/FunctionCBH.Tests.ps1 +++ /dev/null @@ -1,60 +0,0 @@ -#Requires -Modules Pester -<# - This pester test verifies the module's public functions all have proper comment based help required for building documentation via PlatyPS. - - Example: - PS> Invoke-Pester -Script @{Path = '.\src\tests\FuncitonCBH.Tests.ps1'; Parameters = @{ ModuleName = MyModule}} -#> - -[CmdletBinding()] -Param( - [Parameter(HelpMessage = 'Module to scan.')] - [string]$ModuleName -) - -If (($ModuleName -like '*.psd1') -and (test-path $ModuleName)) { - $Module = (Split-Path $ModuleName -Leaf) -replace '.psd1','' -} -else { - $Module = $ModuleName -} - -if (-not (Get-Module $Module)) { - try { - Import-Module $ModuleName -force - } - catch { - throw "$Module is not loaded." - } -} - -Describe "Comment Based Help tests for $Module" -Tags Build { - - $functions = Get-Command -Module $Module -CommandType Function - foreach($Function in $Functions){ - $help = Get-Help $Function.name - Context $help.name { - it "Has a HelpUri" { - $Function.HelpUri | Should Not BeNullOrEmpty - } - It "Has related Links" { - $help.relatedLinks.navigationLink.uri.count | Should BeGreaterThan 0 - } - it "Has a description" { - $help.description | Should Not BeNullOrEmpty - } - it "Has an example" { - $help.examples | Should Not BeNullOrEmpty - } - foreach($parameter in $help.parameters.parameter) - { - if($parameter -notmatch 'whatif|confirm') - { - it "Has a Parameter description for '$($parameter.name)'" { - $parameter.Description.text | Should Not BeNullOrEmpty - } - } - } - } - } -} \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/src/tests/ModuleManifest.Tests.ps1 b/plaster/ModuleBuild/scaffold/src/tests/ModuleManifest.Tests.ps1 deleted file mode 100644 index c6bf56f..0000000 --- a/plaster/ModuleBuild/scaffold/src/tests/ModuleManifest.Tests.ps1 +++ /dev/null @@ -1,205 +0,0 @@ -#Requires -Modules Pester - -<# - This pester test verifies the PowerShell module manifest file has valid content that will be required to - upload to the PowerShell Gallary. - - .EXAMPLE - PS> Invoke-Pester -Script @{Path = '.\src\tests\ModuleManifest.Tests.ps1'; Parameters = @{ ManifestPath = 'C:\Users\zloeber\Dropbox\Zach_Docs\Projects\Git\PSAD'; Author = 'Zachary Loeber'; Website = 'https://github.com/zloeber/PSAD'; Tags = @('ADSI', 'Active_Directory', 'DC') }} - - Runs some standard tests and a few manual validations (Tags, Author, and Website). - .EXAMPLE - PS> Invoke-Pester -Script @{Path = '.\src\tests\ModuleManifest.Tests.ps1'; Parameters = @{ ManifestPath = '.\PSAD.psd1'}} - - Runs several generic tests against the PSAD.psd1 manifest to ensure all required values for uploading to the PowerShell Gallery simply exist. -#> - -[CmdLetBinding(DefaultParameterSetName='Default')] -Param( - [Parameter(Mandatory = $True, ParameterSetName='Default')] - [Parameter(Mandatory = $True, ParameterSetName='Manual')] - [Parameter(Mandatory = $True, ParameterSetName='ModuleBuild')] - [string]$ManifestPath, - [Parameter(Mandatory = $True, ParameterSetName='ModuleBuild')] - [string]$ModuleBuildJSONPath, - [Parameter(ParameterSetName='Manual')] - [string]$Author, - [Parameter(ParameterSetName='Manual')] - [string]$Copyright, - [Parameter(ParameterSetName='Manual')] - [string]$Website, - [Parameter(ParameterSetName='Manual')] - [string]$LicenseURI, - [Parameter(ParameterSetName='Manual')] - [string]$Version, - [Parameter(ParameterSetName='Manual')] - [string[]]$Tags -) - -if (($ManifestPath.EndsWith('psd1')) -and (Test-Path $ManifestPath)) { - # Grab the short module name - $ModuleName = (Split-Path $ManifestPath -Leaf).Split('.')[0] - - Describe 'Module Manifest - Standard Tests' { - Context "Testing $ManifestPath" { - It 'should be a valid module manifest file' { - { - $Script:Manifest = Test-ModuleManifest -Path $ManifestPath -ErrorAction Stop -WarningAction SilentlyContinue - } | Should Not Throw - } - - It 'should have a valid RootModule value' { - $Script:Manifest.RootModule | Should Be "$ModuleName.psm1" - } - - It 'should have a valid GUID' { - ($Script:Manifest.Guid).Guid | Should BeLike '????????-????-????-????-????????????' - } - - It 'should have a valid PowerShellVersion value' { - $Script:Manifest.PowerShellVersion | Should Not BeNullOrEmpty - } - } - } - - switch ($PSCmdlet.ParameterSetName) { - 'Default' { - # Passed just a module manifest file name with no other information to validate - # This will check for several entries that they simply exist. - Describe 'Module Manifest - Generic Tests' { - Context "Testing $ManifestPath" { - It 'should have a valid Module version' { - ($Script:Manifest.Version).ToString() -as [Version] | Should Not BeNullOrEmpty - } - - It 'should have a valid module description' { - $Script:Manifest.Description | Should Not BeNullOrEmpty - } - - It 'should have a valid module author' { - $Script:Manifest.Author | Should Not BeNullOrEmpty - } - - It 'should have a valid module project website' { - $Script:Manifest.ProjectUri.OriginalString | Should Not BeNullOrEmpty - } - - It 'should have a valid license URL' { - $Script:Manifest.LicenseUri | Should Not BeNullOrEmpty - } - - It 'should have some tags' { - @($Script:Manifest.PrivateData.PSData.Tags).Count -gt 0 | Should Be $true - } - } - } - } - 'Manual' { - # Passed a manifest name and several manual entries to validate - Describe 'Module Manifest - Manual Tests' { - Context "Testing $ManifestPath" { - if (-not [string]::IsNullOrEmpty($Version)) { - It "should be module version '$Version'" { - ($Script:Manifest.Version).ToString() -as [Version] | Should Be $Version - } - } - if (-not [string]::IsNullOrEmpty($Description)) { - It "should have a module description of '$Description'" { - $Script:Manifest.Description | Should Be $Description - } - } - - if (-not [string]::IsNullOrEmpty($Author)) { - It "should have the module author of '$Author'" { - $Script:Manifest.Author | Should Be $Author - } - } - - if (-not [string]::IsNullOrEmpty($Copyright)) { - It "should have a Copyright of '$Copyright'" { - $Script:Manifest.Copyright | Should Be $Copyright - } - } - - if (-not [string]::IsNullOrEmpty($Website)) { - It "should have the project website of '$Website'" { - $Script:Manifest.ProjectUri.OriginalString | Should Be $Website - } - } - - if (-not [string]::IsNullOrEmpty($LicenseURI)) { - It "should have the license URI of '$LicenseURI'" { - $Script:Manifest.LicenseUri | Should Be $LicenseURI - } - } - if ($Tags.Count -gt 0) { - It "should have these tags: $($Tags -join ',')" { - Compare-Object $Script:Manifest.PrivateData.PSData.Tags $Tags | Should Be $Null - } - } - } - } - } - 'ModuleBuild' { - # Passed a manifest name and a ModuleBuild json configuration file to validate - if (($ModuleBuildJSONPath.EndsWith('psd1')) -and (Test-Path $ModuleBuildJSONPath)) { - try { - $ModuleInfo = get-content $ModuleBuildJSONPath | ConvertFrom-Json - } - catch { - throw "$ModuleBuildJSONPath either does not exist or is not a json file!" - } - } - else { - throw "$ModuleBuildJSONPath either does not exist or is not a json file!" - } - # Passed a manifest name and several manual entries to validate - Describe 'Module Manifest - ModuleBuild Tests' { - Context "Testing $ManifestPath" { - if (-not [string]::IsNullOrEmpty($Version)) { - It "should be module version '$Version'" { - ($Script:Manifest.Version).ToString() -as [Version] | Should Be $ModuleInfo.ModuleVersion - } - } - if (-not [string]::IsNullOrEmpty($Description)) { - It "should have a module description of '$Description'" { - $Script:Manifest.Description | Should Be $ModuleInfo.ModuleDescription - } - } - - if (-not [string]::IsNullOrEmpty($Author)) { - It "should have the module author of '$Author'" { - $Script:Manifest.Author | Should Be $ModuleInfo.ModuleAuthor - } - } - - if (-not [string]::IsNullOrEmpty($Copyright)) { - It "should have a Copyright of '$Copyright'" { - $Script:Manifest.Copyright | Should Be $ModuleInfo.ModuleCopyright - } - } - - if (-not [string]::IsNullOrEmpty($Website)) { - It "should have the project website of '$Website'" { - $Script:Manifest.ProjectUri.OriginalString | Should Be $ModuleInfo.ModuleWebsite - } - } - - if (-not [string]::IsNullOrEmpty($LicenseURI)) { - It "should have the license URI of '$LicenseURI'" { - $Script:Manifest.LicenseUri | Should Be $ModuleInfo.ModuleLicenseURI - } - } - if ($Tags.Count -gt 0) { - It "should have these tags: $($ModuleInfo.ModuleTags -join ',')" { - Compare-Object $Script:Manifest.PrivateData.PSData.Tags $ModuleInfo.ModuleTags | Should Be $Null - } - } - } - } - } - } -} -else { - Write-Error "$ManifestPath was not found!" -} \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/src/tests/ScriptAnalyzer.Tests.ps1 b/plaster/ModuleBuild/scaffold/src/tests/ScriptAnalyzer.Tests.ps1 deleted file mode 100644 index b96ff54..0000000 --- a/plaster/ModuleBuild/scaffold/src/tests/ScriptAnalyzer.Tests.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -#Requires -Modules Pester -<# - This pester test verifies the files in the specified path do not contain sensitive information. - - Example: - Invoke-Pester -Script @{Path = '.\src\tests\ScriptAnalyzer.Tests.ps1'; Parameters = @{ Path = 'C:\Users\zloeber\Dropbox\Zach_Docs\Projects\Git\PSAD' }} -#> - -[CmdletBinding()] -Param( - [Parameter(HelpMessage = 'Path to the files to scan.')] - [string]$Path -) - -if (-not (Get-Item $Path -ErrorAction:SilentlyContinue).PSIsContainer) { - throw "Either $Path is not a directory or does not exist" -} - -Describe 'Testing against PSSA rules' { - Context 'PSSA Standard Rules' { - $analysis = Invoke-ScriptAnalyzer -Path $Path - $scriptAnalyzerRules = Get-ScriptAnalyzerRule - forEach ($rule in $scriptAnalyzerRules) { - It "Should pass $rule" { - If ($analysis.RuleName -contains $rule) { - $analysis | Where RuleName -EQ $rule -outvariable failures | Out-Default - $failures.Count | Should Be 0 - } - } - } - } -} \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/src/tests/SensitiveTermScan.Tests.ps1 b/plaster/ModuleBuild/scaffold/src/tests/SensitiveTermScan.Tests.ps1 deleted file mode 100644 index 7e5553a..0000000 --- a/plaster/ModuleBuild/scaffold/src/tests/SensitiveTermScan.Tests.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -#Requires -Modules Pester -<# - This pester test verifies the files in the specified path do not contain sensitive information. - - Example: - Invoke-Pester -Script @{Path = '.\src\tests\SensitiveTermScan.Tests.ps1'; Parameters = @{ Path = 'C:\Users\zloeber\Dropbox\Zach_Docs\Projects\Git\PSAD'; Terms = @('mydomainname.com', 'myservername') }} -#> - -[CmdletBinding()] -Param( - [Parameter(HelpMessage = 'Path to the files to scan.')] - [string]$Path, - [Parameter(HelpMessage = 'Terms to scan for.')] - [string[]]$Terms -) - -if (Test-Path $Path) { - Describe 'Scan for sensitive terms.' { - foreach ($Term in $Terms) { - $TermSearch = @(Get-ChildItem -Recurse -Path $Path | Select-String -Pattern $Term) - Context "Files in $Path" { - It "should not contain the term $Term" { - $TermSearch.Count -gt 0 | Should Be $false - } - } - } - } -} \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/src/tests/meta/Autoload.Tests.ps1 b/plaster/ModuleBuild/scaffold/src/tests/meta/Autoload.Tests.ps1 deleted file mode 100644 index 5d0549c..0000000 --- a/plaster/ModuleBuild/scaffold/src/tests/meta/Autoload.Tests.ps1 +++ /dev/null @@ -1,23 +0,0 @@ - -<# - Use this tests to verify, if the latest meta tests are available in this - repository, compared to the claudiospizzi/PowerShellModuleBase repository. -#> - -Describe 'Meta Autoload' { - - $baseApi = 'https://api.github.com/repos/claudiospizzi/PowerShellModuleBase/contents/Tests/Meta' - - $files = Invoke-RestMethod -Method Get -Uri $baseApi - - foreach ($file in $files) - { - if ($file.name -ne 'Autoload.Tests.ps1') - { - It "should download the latest version of \$($file.path.Replace('/', '\'))" { - - { Invoke-WebRequest -Uri $file.download_url -OutFile "$PSScriptRoot\$($file.name)" -Headers @{ 'Cache-Control' = 'no-cache' } -UseBasicParsing -ErrorAction Stop } | Should Not Throw - } - } - } -} diff --git a/plaster/ModuleBuild/scaffold/src/tests/meta/FileContent.Tests.ps1 b/plaster/ModuleBuild/scaffold/src/tests/meta/FileContent.Tests.ps1 deleted file mode 100644 index d05bd76..0000000 --- a/plaster/ModuleBuild/scaffold/src/tests/meta/FileContent.Tests.ps1 +++ /dev/null @@ -1,349 +0,0 @@ - -<# - This meta tests verify, if the PowerShell module core project file have a - valid content. -#> - -$ModulePath = Resolve-Path -Path "$PSScriptRoot\..\..\Modules" | ForEach-Object Path -$ModuleName = Get-ChildItem -Path $ModulePath | Select-Object -First 1 -ExpandProperty BaseName - -Remove-Module -Name $ModuleName -Force -ErrorAction SilentlyContinue -Import-Module -Name "$ModulePath\$ModuleName" -Force - -Describe 'Meta File Content' { - - $rootPath = Resolve-Path -Path "$PSScriptRoot\..\.." | ForEach-Object Path - - Context '\README.md' { - - $content = Get-Content -Path "$rootPath\README.md" - - It 'should have 4 badges at the top' { - - # Arrange - $expectAppVeyorMaster = "[![AppVeyor - master](https://img.shields.io/appveyor/ci/claudiospizzi/$ModuleName/master.svg)](https://ci.appveyor.com/project/claudiospizzi/$ModuleName/branch/master)" - $expectAppVeyorMaster = "[![AppVeyor - dev](https://img.shields.io/appveyor/ci/claudiospizzi/$ModuleName/dev.svg)](https://ci.appveyor.com/project/claudiospizzi/$ModuleName/branch/dev)" - $expectGitHubRelease = "[![GitHub - Release](https://img.shields.io/github/release/claudiospizzi/$ModuleName.svg)](https://github.com/claudiospizzi/$ModuleName/releases)" - $expectPowerShellGallery = "[![PowerShell Gallery - $ModuleName](https://img.shields.io/badge/PowerShell_Gallery-$ModuleName-0072C6.svg)](https://www.powershellgallery.com/packages/$ModuleName)" - - # Act - $actualAppVeyorMaster = $content[0] - $actualAppVeyorMaster = $content[1] - $actualGitHubRelease = $content[2] - $actualPowerShellGallery = $content[3] - - # Assert - $actualAppVeyorMaster | Should BeExactly $expectAppVeyorMaster - $actualAppVeyorMaster | Should BeExactly $expectAppVeyorMaster - $actualGitHubRelease | Should BeExactly $expectGitHubRelease - $actualPowerShellGallery | Should BeExactly $expectPowerShellGallery - } - - It 'should have one main title' { - - # Arrange - $expectCount = 1 - $expectTitle = "# $ModuleName PowerShell Module" - - # Act - $actualTitle = @() - $isCodeBlock = $false - foreach ($line in $content) - { - if ($line -like '``````*') - { - $isCodeBlock = -not $isCodeBlock - } - if (($line -like '# *') -and (-not $isCodeBlock)) - { - $actualTitle += $line - } - } - - # Assert - $actualTitle.Count | Should Be $expectCount - $actualTitle[0] | Should BeExactly $expectTitle - } - - It 'should have a all subtitles' { - - # Arrange - $expectCount = 6 - $expectSubtitles = "## Introduction", "## Requirements", "## Installation", "## Features", "## Versions", "## Contribute" - - # Act - $actualSubtitles = @($content | Where-Object { $_ -like '## *' }) - - # Assert - $actualSubtitles.Count | Should Be $expectCount - $actualSubtitles[0] | Should BeExactly $expectSubtitles[0] - $actualSubtitles[1] | Should BeExactly $expectSubtitles[1] - $actualSubtitles[2] | Should BeExactly $expectSubtitles[2] - $actualSubtitles[3] | Should BeExactly $expectSubtitles[3] - $actualSubtitles[4] | Should BeExactly $expectSubtitles[4] - $actualSubtitles[5] | Should BeExactly $expectSubtitles[5] - } - - It 'should cover every function in the features capture' { - - # Arrange - $expectFunctions = @(Get-ChildItem -Path "$ModulePath\$ModuleName\Functions" | ForEach-Object { '* **' + $_.BaseName + '** ' } | Sort-Object) - - # Act - $actualFunctions = @($content | Where-Object { $_ -like '`* `*`**`*`* ' } | Sort-Object) - - # Assert - $actualFunctions.Count | Should Not Be 0 - $actualFunctions.Count | Should Be $expectFunctions.Count - for ($i = 0; $i -lt $expectFunctions.Count; $i++) - { - $actualFunctions[$i] | Should BeExactly $expectFunctions[$i] - } - } - - It 'should contain an installation capture' { - - # Arrange - $expectLines = @( - 'With PowerShell 5.0, the new [PowerShell Gallery] was introduced. Additionally,' - 'the new module [PowerShellGet] was added to the default WMF 5.0 installation.' - 'With the cmdlet `Install-Module`, a published module from the PowerShell Gallery' - 'can be downloaded and installed directly within the PowerShell host, optionally' - 'with the scope definition:' - '' - '```powershell' - "Install-Module $ModuleName [-Scope {CurrentUser | AllUsers}]" - '```' - '' - 'Alternatively, download the latest release from GitHub and install the module' - 'manually on your local system:' - '' - '1. Download the latest release from GitHub as a ZIP file: [GitHub Releases]' - '2. Extract the module and install it: [Installing a PowerShell Module]' - ) - - # Act - $lineIndex = $content.IndexOf($expectLines[0]) - - # Assert - $lineIndex | Should Not Be -1 - for ($i = 0; $i -lt $expectLines.Count; $i++) - { - $actual = '{{{0}}}{1}' -f $i, $content[$i + $lineIndex] - $expect = '{{{0}}}{1}' -f $i, $expectLines[$i] - - $actual | Should BeExactly $expect - } - } - - It 'should contain an contribute capture' { - - # Arrange - $expectLines = @( - '## Contribute' - '' - 'Please feel free to contribute by opening new issues or providing pull requests.' - 'For the best development experience, open this project as a folder in Visual' - 'Studio Code and ensure that the PowerShell extension is installed.' - '' - '* [Visual Studio Code]' - '* [PowerShell Extension]' - '' - 'This module is tested with the PowerShell testing framework Pester. To run all' - 'tests, just start the included test script `.\Scripts\test.ps1` or invoke Pester' - 'directly with the `Invoke-Pester` cmdlet. The tests will automatically download' - 'the latest meta test from the claudiospizzi/PowerShellModuleBase repository.' - '' - 'To debug the module, just copy the existing `.\Scripts\debug.default.ps1` file' - 'to `.\Scripts\debug.ps1`, which is ignored by git. Now add the command to the' - 'debug file and start it.' - ) - - # Act - $lineIndex = $content.IndexOf($expectLines[0]) - - # Assert - $lineIndex | Should Not Be -1 - for ($i = 0; $i -lt $expectLines.Count; $i++) - { - $actual = '{{{0}}}{1}' -f $i, $content[$i + $lineIndex] - $expect = '{{{0}}}{1}' -f $i, $expectLines[$i] - - $actual | Should BeExactly $expect - } - } - } - - Context '\.gitignore' { - - $content = Get-Content -Path "$rootPath\.gitignore" - - It 'should have entries for all test and debug files' { - - # Arrange - $expect = @( - 'Scripts/debug.ps1' - 'Tests/Meta/FileContent.Tests.ps1' - 'Tests/Meta/FileEncoding.Tests.ps1' - 'Tests/Meta/FileFormatting.Tests.ps1' - 'Tests/Meta/ProjectStructure.Tests.ps1' - 'Tests/Meta/ScriptAnalyzer.Tests.ps1' - ) - - # Act - - # Assert - foreach ($expectLine in $expect) - { - $content -contains $expectLine | Should Be $true - } - } - } - - Context ".\Modules\$ModuleName\$ModuleName.psd1" { - - $data = Import-PowerShellDataFile -Path "$rootPath\Modules\$ModuleName\$ModuleName.psd1" - - It 'should have a valid RootModule value' { - - # Arrange - $expect = "$ModuleName.psm1" - - # Act - $actual = $data.RootModule - - # Assert - $actual | Should BeExactly $expect - } - - It 'should have a valid ModuleVersion value' { - - # Arrange - $expect = '*.*.*' - - # Act - $actual = $data.ModuleVersion - - # Assert - $actual | Should BeLike $expect - } - - It 'should have a valid GUID value' { - - # Arrange - $expect = '????????-????-????-????-????????????' - - # Act - $actual = $data.GUID - - # Assert - $actual | Should BeLike $expect - } - - It 'should have a valid Author value' { - - # Arrange - $expect = 'Claudio Spizzi' - - # Act - $actual = $data.Author - - # Assert - $actual | Should BeExactly $expect - } - - It 'should have a valid Copyright value' { - - # Arrange - - # Act - $actual = $data.Copyright - - # Assert - $actual | Should Not BeNullOrEmpty - } - - It 'should have a valid Description value' { - - # Arrange - - # Act - $actual = $data.Description - - # Assert - $actual | Should Not BeNullOrEmpty - } - - It 'should have a valid PowerShellVersion value' { - - # Arrange - - # Act - $actual = $data.PowerShellVersion - - # Assert - $actual | Should Not BeNullOrEmpty - } - - It 'should have valid TypesToProcess values' { - - # Arrange - $expect = @( - "Resources\$ModuleName.Types.ps1xml" - ) - - # Act - $actual = $data.TypesToProcess - - # Assert - $actual.Count | Should Be 1 - $actual[0] | Should BeExactly $expect[0] - } - - It 'should have valid FormatsToProcess values' { - - # Arrange - $expect = @( - "Resources\$ModuleName.Formats.ps1xml" - ) - - # Act - $actual = $data.FormatsToProcess - - # Assert - $actual.Count | Should Be 1 - $actual[0] | Should BeExactly $expect[0] - } - - It 'should have valid FunctionsToExport values' { - - # Arrange - $expect = @(Get-ChildItem -Path "$ModulePath\$ModuleName\Functions" | ForEach-Object BaseName | Sort-Object) - - # Act - $actual = @($data.FunctionsToExport | Sort-Object) - - # Assert - $actual.Count | Should Be $expect.Count - for ($i = 0; $i -lt $expect.Count; $i++) - { - $actual[$i] | Should BeExactly $expect[$i] - } - } - - It 'should have valid PrivateData hash table' { - - # Arrange - $expectLicenseUri = "https://raw.githubusercontent.com/claudiospizzi/$ModuleName/master/LICENSE" - $expectProjectUri = "https://github.com/claudiospizzi/$ModuleName" - - # Act - $actual = $data.PrivateData - - # Assert - $actual.PSData.Tags -contains 'PSModule' | Should Be $true - $actual.PSData.LicenseUri | Should BeExactly $expectLicenseUri - $actual.PSData.ProjectUri | Should BeExactly $expectProjectUri - } - } -} diff --git a/plaster/ModuleBuild/scaffold/src/tests/meta/FileEncoding.Tests.ps1 b/plaster/ModuleBuild/scaffold/src/tests/meta/FileEncoding.Tests.ps1 deleted file mode 100644 index 9ad1edd..0000000 --- a/plaster/ModuleBuild/scaffold/src/tests/meta/FileEncoding.Tests.ps1 +++ /dev/null @@ -1,54 +0,0 @@ - -<# - Check if the encoding of all text files in the PowerShell module is valid, - this means no Unicode or UTF-8 with BOM files. -#> - -$ModulePath = Resolve-Path -Path "$PSScriptRoot\..\..\Modules" | ForEach-Object Path -$ModuleName = Get-ChildItem -Path $ModulePath | Select-Object -First 1 -ExpandProperty BaseName - -Remove-Module -Name $ModuleName -Force -ErrorAction SilentlyContinue -Import-Module -Name "$ModulePath\$ModuleName" -Force - -Describe 'Meta File Encoding' { - - $fileExtensions = '.ps1', '.psm1', '.psd1', '.ps1xml', '.txt', '.xml', - '.cmd', '.json', '.md', '.csv', '.yml', '.log', - '.gitignore', '.gitattributes' - - $rootPath = Resolve-Path -Path "$PSScriptRoot\..\.." | ForEach-Object Path - $textFiles = Get-ChildItem -Path $rootPath -File -Recurse | - Where-Object { -not $_.FullName.StartsWith("$rootPath\Sources\") } | - Where-Object { $fileExtensions -contains $_.Extension } | - ForEach-Object { $_.FullName.Replace($rootPath, '') } - - Context 'No Unicode encoding' { - - foreach ($textFile in $textFiles) - { - # To check, if the file is encoded in Unicode, check for 0x00 byte - # characters. In a Unicode file, every second charcter is normally - # a 0x00 character, because to majority of chars don't use more than - # the first byte. - It "should not use Unicode encoding for $textFile" { - - @([System.IO.File]::ReadAllBytes("$rootPath\$textFile") -eq 0).Length -eq 0 | Should Be $true - } - } - } - - Context 'No UTF-8 with BOM encoding' { - - foreach ($textFile in $textFiles) - { - # We use UTF-8 encoding with byte order mask (BOM). Therefore we - # check if the file starts with the bytes 0xEF, 0xBB, 0xBF. - It "should not use BOM for UTF-8 encoding for $textFile" { - - $bytes = [System.IO.File]::ReadAllBytes("$rootPath\$textFile") - - ($bytes.Length -ge 3 -and $bytes[0] -eq 239 -and $bytes[1] -eq 187 -and $bytes[2] -eq 191) | Should Be $false - } - } - } -} diff --git a/plaster/ModuleBuild/scaffold/src/tests/meta/FileFormatting.Tests.ps1 b/plaster/ModuleBuild/scaffold/src/tests/meta/FileFormatting.Tests.ps1 deleted file mode 100644 index 690cb2f..0000000 --- a/plaster/ModuleBuild/scaffold/src/tests/meta/FileFormatting.Tests.ps1 +++ /dev/null @@ -1,96 +0,0 @@ - -<# - Verify that the file content if formatted property. It will verify the - following criterias: Use spaces instead of tabs for indentation, no trailing - spaces for lines and should end with a new line. -#> - -$ModulePath = Resolve-Path -Path "$PSScriptRoot\..\..\Modules" | ForEach-Object Path -$ModuleName = Get-ChildItem -Path $ModulePath | Select-Object -First 1 -ExpandProperty BaseName - -Remove-Module -Name $ModuleName -Force -ErrorAction SilentlyContinue -Import-Module -Name "$ModulePath\$ModuleName" -Force - -Describe 'Meta File Formatting' { - - $fileExtensions = '.ps1', '.psm1', '.psd1', '.ps1xml', '.txt', '.xml', - '.cmd', '.json', '.md', '.csv', '.yml', '.log', - '.gitignore', '.gitattributes' - - $rootPath = Resolve-Path -Path "$PSScriptRoot\..\.." | ForEach-Object Path - $textFiles = Get-ChildItem -Path $rootPath -File -Recurse | - Where-Object { -not $_.FullName.StartsWith("$rootPath\Sources\") } | - Where-Object { $fileExtensions -contains $_.Extension } | - ForEach-Object { $_.FullName.Replace($rootPath, '') } - - Context 'Space Indentation' { - - foreach ($textFile in $textFiles) - { - It "should use spaces and not tabs for indentation in $textFile" { - - $errorLines = @() - - $content = @(Get-Content -Path "$rootPath$textFile") - - for ($line = 0; $line -lt $content.Length; $line++) - { - if(($content[$line] | Select-String "`t" | Measure-Object).Count -ne 0) - { - $errorLines += $line + 1 - - Write-Warning "There are tabs instead of spaces in $textFile`:$($line + 1)" - } - } - - $errorLines.Count | Should Be 0 - } - } - } - - Context 'No Trailing Spaces' { - - # Do not test markdown files for trailing spaces. - $textFilesFiltered = $textFiles | Where-Object { $_ -notlike '*.md' } - - foreach ($textFile in $textFilesFiltered) - { - It "should not have trailing spaces in $textFile" { - - $errorLines = @() - - $content = @(Get-Content -Path "$rootPath$textFile") - - for ($line = 0; $line -lt $content.Length; $line++) - { - if($content[$Line].ToString().TrimEnd() -ne $content[$Line]) - { - $errorLines += $line + 1 - - Write-Warning "There are trailing spaces in $textFile`:$($line + 1)" - } - } - - $errorLines.Count | Should Be 0 - } - } - } - - Context 'New Line Termination' { - - # Do not test files in .vscode for trailing spaces. - $textFilesFiltered = $textFiles | Where-Object { $_ -notlike '*\.vscode\*' } - - foreach ($textFile in $textFilesFiltered) - { - - It "should terminate with a new line in $textFile" { - - $content = Get-Content -Path "$rootPath$textFile" -Raw - - $content.Length | Should Not Be 0 - $content[-1] | Should Be "`n" - } - } - } -} diff --git a/plaster/ModuleBuild/scaffold/src/tests/meta/ProjectStructure.Tests.ps1 b/plaster/ModuleBuild/scaffold/src/tests/meta/ProjectStructure.Tests.ps1 deleted file mode 100644 index c120da7..0000000 --- a/plaster/ModuleBuild/scaffold/src/tests/meta/ProjectStructure.Tests.ps1 +++ /dev/null @@ -1,152 +0,0 @@ - -<# - This meta tests verify, if the PowerShell module project structure is - adhered to the best practices. -#> - -$ModulePath = Resolve-Path -Path "$PSScriptRoot\..\..\Modules" | ForEach-Object Path -$ModuleName = Get-ChildItem -Path $ModulePath | Select-Object -First 1 -ExpandProperty BaseName - -Remove-Module -Name $ModuleName -Force -ErrorAction SilentlyContinue -Import-Module -Name "$ModulePath\$ModuleName" -Force - -Describe 'Meta Project Structure' { - - $rootPath = Resolve-Path -Path "$PSScriptRoot\..\.." | ForEach-Object Path - - Context 'Folders' { - - $requiredFolders = @( - '\Scripts' - '\Modules' - "\Modules\$ModuleName" - "\Modules\$ModuleName\en-US" - "\Modules\$ModuleName\Functions" - "\Modules\$ModuleName\Resources" - '\Tests' - '\Tests\Meta' - '\Tests\Unit' - ) - - $optionalFolders = @( - "\Modules\$ModuleName\Helpers" - '\Sources' - "\Sources\$ModuleName" - '\Tests\Integration' - ) - - foreach ($requiredFolder in $requiredFolders) - { - It "should contain the folder $requiredFolder" { - - Test-Path -Path "$rootPath$requiredFolder" | Should Be $true - } - } - - foreach ($optionalFolder in $optionalFolders) - { - It "can contain the folder $optionalFolder" { - - if ((Test-Path -Path "$rootPath$optionalFolder")) - { - Test-Path -Path "$rootPath$optionalFolder" | Should Be $true - } - else - { - Set-TestInconclusive -Message "Optional folder $optionalFolder not found!" - } - } - } - } - - Context 'Files' { - - $requiredFiles = @( - '\appveyor.yml' - '\LICENSE' - '\README.md' - '\Scripts\build.ps1' - '\Scripts\debug.default.ps1' - '\Scripts\release.ps1' - '\Scripts\test.ps1' - "\Modules\$ModuleName\en-US\about_$ModuleName.help.txt" - "\Modules\$ModuleName\Resources\$ModuleName.Formats.ps1xml" - "\Modules\$ModuleName\Resources\$ModuleName.Types.ps1xml" - "\Modules\$ModuleName\$ModuleName.psd1" - "\Modules\$ModuleName\$ModuleName.psm1" - '\Tests\Meta\Autoload.Tests.ps1' - ) - - $optionalFiles = @( - "\Sources\$ModuleName.sln" - ) - - foreach ($requiredFile in $requiredFiles) - { - It "should contain the file $requiredFile" { - - Test-Path -Path "$rootPath\$requiredFile" | Should Be $true - } - } - - foreach ($optionalFile in $optionalFiles) - { - It "can contain the file $optionalFile" { - - if ((Test-Path -Path "$rootPath$optionalFile")) - { - Test-Path -Path "$rootPath$optionalFile" | Should Be $true - } - else - { - Set-TestInconclusive -Message "Optional file $optionalFile not found!" - } - } - } - } - - Context 'Version' { - - # Arrange - $requiredVersion = (Import-PowerShellDataFile -Path "$rootPath\Modules\$ModuleName\$ModuleName.psd1")['ModuleVersion'] - - It "should have version $requiredVersion in README.md" { - - # Act - $versionHeadline = @(Get-Content -Path "$rootPath\README.md" | Where-Object { $_ -eq "### $requiredVersion" }) - - # Assert - $versionHeadline.Count | Should Be 1 - $versionHeadline[0] | Should BeExactly "### $requiredVersion" - } - - It "should have version $requiredVersion in $ModuleName.psd1" { - - # Act - $moduleDefinition = Import-PowerShellDataFile -Path "$rootPath\Modules\$ModuleName\$ModuleName.psd1" - - # Assert - $moduleDefinition.ModuleVersion | Should Be $requiredVersion - } - - if ((Test-Path -Path "$rootPath\Sources\$ModuleName")) - { - It "should have version $requiredVersion in $ModuleName.dll" { - - if ((Test-Path -Path "$rootPath\Modules\$ModuleName\$ModuleName.dll")) - { - # Act - $moduleAssembly = Get-Item -Path "$rootPath\Modules\$ModuleName\$ModuleName.dll" - - # Assert - $moduleAssembly.VersionInfo.ProductVersion | Should Be $requiredVersion - $moduleAssembly.VersionInfo.FileVersion | Should Be $requiredVersion - } - else - { - Set-TestInconclusive -Message "$ModuleName.dll file was not found!" - } - } - } - } -} diff --git a/plaster/ModuleBuild/scaffold/src/tests/meta/ScriptAnalyzer.Tests.ps1 b/plaster/ModuleBuild/scaffold/src/tests/meta/ScriptAnalyzer.Tests.ps1 deleted file mode 100644 index 18a2d69..0000000 --- a/plaster/ModuleBuild/scaffold/src/tests/meta/ScriptAnalyzer.Tests.ps1 +++ /dev/null @@ -1,37 +0,0 @@ - -<# - Check all scripts files in the sources folder against all script analyzer - rules. It should comply with all rules. -#> - -$ModulePath = Resolve-Path -Path "$PSScriptRoot\..\..\Modules" | ForEach-Object Path -$ModuleName = Get-ChildItem -Path $ModulePath | Select-Object -First 1 -ExpandProperty BaseName - -Remove-Module -Name $ModuleName -Force -ErrorAction SilentlyContinue -Import-Module -Name "$ModulePath\$ModuleName" -Force - -Describe 'Meta Script Analyzer' { - - foreach ($severity in 'Information', 'Warning', 'Error') - { - Context "$severity Rules" { - - $scriptAnalyzerRules = Get-ScriptAnalyzerRule -Severity $severity - - foreach ($scriptAnalyzerRule in $scriptAnalyzerRules) - { - It "should conform the rule $($scriptAnalyzerRule.RuleName)" { - - $scriptAnalyzerResults = @(Invoke-ScriptAnalyzer -Path $ModulePath -IncludeRule $scriptAnalyzerRule -Recurse) - - foreach ($scriptAnalyzerResult in $scriptAnalyzerResults) - { - Write-Warning ('{0}, line {1}: {2}' -f $scriptAnalyzerResult.ScriptPath.Replace("$ModulePath", 'Modules'), $scriptAnalyzerResult.Line, $scriptAnalyzerResult.Message) - } - - $scriptAnalyzerResults.Count | Should Be 0 - } - } - } - } -} diff --git a/plaster/ModuleBuild/scaffold/tests/FunctionCBH.Tests.ps1 b/plaster/ModuleBuild/scaffold/tests/FunctionCBH.Tests.ps1 deleted file mode 100644 index 0f418c3..0000000 --- a/plaster/ModuleBuild/scaffold/tests/FunctionCBH.Tests.ps1 +++ /dev/null @@ -1,60 +0,0 @@ -#Requires -Modules Pester -<# - This pester test verifies the module's public functions all have proper comment based help required for building documentation via PlatyPS. - - Example: - PS> Invoke-Pester -Script @{Path = '.\src\tests\FuncitonCBH.Tests.ps1'; Parameters = @{ ModuleName = MyModule}} -#> - -[CmdletBinding()] -Param( - [Parameter(HelpMessage = 'Module to scan.')] - [string]$ModuleName -) - -If (($ModuleName -like '*.psd1') -and (test-path $ModuleName)) { - $Module = (Split-Path $ModuleName -Leaf) -replace '.psd1','' -} -else { - $Module = $ModuleName -} - -if (-not (Get-Module $Module)) { - try { - Import-Module $ModuleName -force - } - catch { - throw "$Module is not loaded." - } -} - -Describe "Comment Based Help tests for $Module" -Tags Build { - - $functions = Get-Command -Module $Module -CommandType Function - foreach($Function in $Functions){ - $help = Get-Help $Function.name - Context $help.name { - it "Has a HelpUri" { - $Function.HelpUri | Should Not BeNullOrEmpty - } - It "Has related Links" { - $help.relatedLinks.navigationLink.uri.count | Should BeGreaterThan 0 - } - it "Has a description" { - $help.description | Should Not BeNullOrEmpty - } - it "Has an example" { - $help.examples | Should Not BeNullOrEmpty - } - foreach($parameter in $help.parameters.parameter) - { - if($parameter -notmatch 'whatif|confirm') - { - it "Has a Parameter description for '$($parameter.name)'" { - $parameter.Description.text | Should Not BeNullOrEmpty - } - } - } - } - } -} \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/tests/ModuleManifest.Tests.ps1 b/plaster/ModuleBuild/scaffold/tests/ModuleManifest.Tests.ps1 deleted file mode 100644 index c6bf56f..0000000 --- a/plaster/ModuleBuild/scaffold/tests/ModuleManifest.Tests.ps1 +++ /dev/null @@ -1,205 +0,0 @@ -#Requires -Modules Pester - -<# - This pester test verifies the PowerShell module manifest file has valid content that will be required to - upload to the PowerShell Gallary. - - .EXAMPLE - PS> Invoke-Pester -Script @{Path = '.\src\tests\ModuleManifest.Tests.ps1'; Parameters = @{ ManifestPath = 'C:\Users\zloeber\Dropbox\Zach_Docs\Projects\Git\PSAD'; Author = 'Zachary Loeber'; Website = 'https://github.com/zloeber/PSAD'; Tags = @('ADSI', 'Active_Directory', 'DC') }} - - Runs some standard tests and a few manual validations (Tags, Author, and Website). - .EXAMPLE - PS> Invoke-Pester -Script @{Path = '.\src\tests\ModuleManifest.Tests.ps1'; Parameters = @{ ManifestPath = '.\PSAD.psd1'}} - - Runs several generic tests against the PSAD.psd1 manifest to ensure all required values for uploading to the PowerShell Gallery simply exist. -#> - -[CmdLetBinding(DefaultParameterSetName='Default')] -Param( - [Parameter(Mandatory = $True, ParameterSetName='Default')] - [Parameter(Mandatory = $True, ParameterSetName='Manual')] - [Parameter(Mandatory = $True, ParameterSetName='ModuleBuild')] - [string]$ManifestPath, - [Parameter(Mandatory = $True, ParameterSetName='ModuleBuild')] - [string]$ModuleBuildJSONPath, - [Parameter(ParameterSetName='Manual')] - [string]$Author, - [Parameter(ParameterSetName='Manual')] - [string]$Copyright, - [Parameter(ParameterSetName='Manual')] - [string]$Website, - [Parameter(ParameterSetName='Manual')] - [string]$LicenseURI, - [Parameter(ParameterSetName='Manual')] - [string]$Version, - [Parameter(ParameterSetName='Manual')] - [string[]]$Tags -) - -if (($ManifestPath.EndsWith('psd1')) -and (Test-Path $ManifestPath)) { - # Grab the short module name - $ModuleName = (Split-Path $ManifestPath -Leaf).Split('.')[0] - - Describe 'Module Manifest - Standard Tests' { - Context "Testing $ManifestPath" { - It 'should be a valid module manifest file' { - { - $Script:Manifest = Test-ModuleManifest -Path $ManifestPath -ErrorAction Stop -WarningAction SilentlyContinue - } | Should Not Throw - } - - It 'should have a valid RootModule value' { - $Script:Manifest.RootModule | Should Be "$ModuleName.psm1" - } - - It 'should have a valid GUID' { - ($Script:Manifest.Guid).Guid | Should BeLike '????????-????-????-????-????????????' - } - - It 'should have a valid PowerShellVersion value' { - $Script:Manifest.PowerShellVersion | Should Not BeNullOrEmpty - } - } - } - - switch ($PSCmdlet.ParameterSetName) { - 'Default' { - # Passed just a module manifest file name with no other information to validate - # This will check for several entries that they simply exist. - Describe 'Module Manifest - Generic Tests' { - Context "Testing $ManifestPath" { - It 'should have a valid Module version' { - ($Script:Manifest.Version).ToString() -as [Version] | Should Not BeNullOrEmpty - } - - It 'should have a valid module description' { - $Script:Manifest.Description | Should Not BeNullOrEmpty - } - - It 'should have a valid module author' { - $Script:Manifest.Author | Should Not BeNullOrEmpty - } - - It 'should have a valid module project website' { - $Script:Manifest.ProjectUri.OriginalString | Should Not BeNullOrEmpty - } - - It 'should have a valid license URL' { - $Script:Manifest.LicenseUri | Should Not BeNullOrEmpty - } - - It 'should have some tags' { - @($Script:Manifest.PrivateData.PSData.Tags).Count -gt 0 | Should Be $true - } - } - } - } - 'Manual' { - # Passed a manifest name and several manual entries to validate - Describe 'Module Manifest - Manual Tests' { - Context "Testing $ManifestPath" { - if (-not [string]::IsNullOrEmpty($Version)) { - It "should be module version '$Version'" { - ($Script:Manifest.Version).ToString() -as [Version] | Should Be $Version - } - } - if (-not [string]::IsNullOrEmpty($Description)) { - It "should have a module description of '$Description'" { - $Script:Manifest.Description | Should Be $Description - } - } - - if (-not [string]::IsNullOrEmpty($Author)) { - It "should have the module author of '$Author'" { - $Script:Manifest.Author | Should Be $Author - } - } - - if (-not [string]::IsNullOrEmpty($Copyright)) { - It "should have a Copyright of '$Copyright'" { - $Script:Manifest.Copyright | Should Be $Copyright - } - } - - if (-not [string]::IsNullOrEmpty($Website)) { - It "should have the project website of '$Website'" { - $Script:Manifest.ProjectUri.OriginalString | Should Be $Website - } - } - - if (-not [string]::IsNullOrEmpty($LicenseURI)) { - It "should have the license URI of '$LicenseURI'" { - $Script:Manifest.LicenseUri | Should Be $LicenseURI - } - } - if ($Tags.Count -gt 0) { - It "should have these tags: $($Tags -join ',')" { - Compare-Object $Script:Manifest.PrivateData.PSData.Tags $Tags | Should Be $Null - } - } - } - } - } - 'ModuleBuild' { - # Passed a manifest name and a ModuleBuild json configuration file to validate - if (($ModuleBuildJSONPath.EndsWith('psd1')) -and (Test-Path $ModuleBuildJSONPath)) { - try { - $ModuleInfo = get-content $ModuleBuildJSONPath | ConvertFrom-Json - } - catch { - throw "$ModuleBuildJSONPath either does not exist or is not a json file!" - } - } - else { - throw "$ModuleBuildJSONPath either does not exist or is not a json file!" - } - # Passed a manifest name and several manual entries to validate - Describe 'Module Manifest - ModuleBuild Tests' { - Context "Testing $ManifestPath" { - if (-not [string]::IsNullOrEmpty($Version)) { - It "should be module version '$Version'" { - ($Script:Manifest.Version).ToString() -as [Version] | Should Be $ModuleInfo.ModuleVersion - } - } - if (-not [string]::IsNullOrEmpty($Description)) { - It "should have a module description of '$Description'" { - $Script:Manifest.Description | Should Be $ModuleInfo.ModuleDescription - } - } - - if (-not [string]::IsNullOrEmpty($Author)) { - It "should have the module author of '$Author'" { - $Script:Manifest.Author | Should Be $ModuleInfo.ModuleAuthor - } - } - - if (-not [string]::IsNullOrEmpty($Copyright)) { - It "should have a Copyright of '$Copyright'" { - $Script:Manifest.Copyright | Should Be $ModuleInfo.ModuleCopyright - } - } - - if (-not [string]::IsNullOrEmpty($Website)) { - It "should have the project website of '$Website'" { - $Script:Manifest.ProjectUri.OriginalString | Should Be $ModuleInfo.ModuleWebsite - } - } - - if (-not [string]::IsNullOrEmpty($LicenseURI)) { - It "should have the license URI of '$LicenseURI'" { - $Script:Manifest.LicenseUri | Should Be $ModuleInfo.ModuleLicenseURI - } - } - if ($Tags.Count -gt 0) { - It "should have these tags: $($ModuleInfo.ModuleTags -join ',')" { - Compare-Object $Script:Manifest.PrivateData.PSData.Tags $ModuleInfo.ModuleTags | Should Be $Null - } - } - } - } - } - } -} -else { - Write-Error "$ManifestPath was not found!" -} \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/tests/ScriptAnalyzer.Tests.ps1 b/plaster/ModuleBuild/scaffold/tests/ScriptAnalyzer.Tests.ps1 deleted file mode 100644 index b96ff54..0000000 --- a/plaster/ModuleBuild/scaffold/tests/ScriptAnalyzer.Tests.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -#Requires -Modules Pester -<# - This pester test verifies the files in the specified path do not contain sensitive information. - - Example: - Invoke-Pester -Script @{Path = '.\src\tests\ScriptAnalyzer.Tests.ps1'; Parameters = @{ Path = 'C:\Users\zloeber\Dropbox\Zach_Docs\Projects\Git\PSAD' }} -#> - -[CmdletBinding()] -Param( - [Parameter(HelpMessage = 'Path to the files to scan.')] - [string]$Path -) - -if (-not (Get-Item $Path -ErrorAction:SilentlyContinue).PSIsContainer) { - throw "Either $Path is not a directory or does not exist" -} - -Describe 'Testing against PSSA rules' { - Context 'PSSA Standard Rules' { - $analysis = Invoke-ScriptAnalyzer -Path $Path - $scriptAnalyzerRules = Get-ScriptAnalyzerRule - forEach ($rule in $scriptAnalyzerRules) { - It "Should pass $rule" { - If ($analysis.RuleName -contains $rule) { - $analysis | Where RuleName -EQ $rule -outvariable failures | Out-Default - $failures.Count | Should Be 0 - } - } - } - } -} \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/tests/SensitiveTermScan.Tests.ps1 b/plaster/ModuleBuild/scaffold/tests/SensitiveTermScan.Tests.ps1 deleted file mode 100644 index 7e5553a..0000000 --- a/plaster/ModuleBuild/scaffold/tests/SensitiveTermScan.Tests.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -#Requires -Modules Pester -<# - This pester test verifies the files in the specified path do not contain sensitive information. - - Example: - Invoke-Pester -Script @{Path = '.\src\tests\SensitiveTermScan.Tests.ps1'; Parameters = @{ Path = 'C:\Users\zloeber\Dropbox\Zach_Docs\Projects\Git\PSAD'; Terms = @('mydomainname.com', 'myservername') }} -#> - -[CmdletBinding()] -Param( - [Parameter(HelpMessage = 'Path to the files to scan.')] - [string]$Path, - [Parameter(HelpMessage = 'Terms to scan for.')] - [string[]]$Terms -) - -if (Test-Path $Path) { - Describe 'Scan for sensitive terms.' { - foreach ($Term in $Terms) { - $TermSearch = @(Get-ChildItem -Recurse -Path $Path | Select-String -Pattern $Term) - Context "Files in $Path" { - It "should not contain the term $Term" { - $TermSearch.Count -gt 0 | Should Be $false - } - } - } - } -} \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/tests/intergration/other/readme.md b/plaster/ModuleBuild/scaffold/tests/intergration/other/readme.md new file mode 100644 index 0000000..536a744 --- /dev/null +++ b/plaster/ModuleBuild/scaffold/tests/intergration/other/readme.md @@ -0,0 +1 @@ +Intergration tests for scripts in other folder go here \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/tests/intergration/private/readme.md b/plaster/ModuleBuild/scaffold/tests/intergration/private/readme.md new file mode 100644 index 0000000..1f6dba4 --- /dev/null +++ b/plaster/ModuleBuild/scaffold/tests/intergration/private/readme.md @@ -0,0 +1 @@ +Intergration tests for private functions go here \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/tests/intergration/public/readme.md b/plaster/ModuleBuild/scaffold/tests/intergration/public/readme.md new file mode 100644 index 0000000..5cf9b73 --- /dev/null +++ b/plaster/ModuleBuild/scaffold/tests/intergration/public/readme.md @@ -0,0 +1 @@ +Intergration tests for public functions go here \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/tests/meta/Autoload.Tests.ps1 b/plaster/ModuleBuild/scaffold/tests/meta/Autoload.Tests.ps1 deleted file mode 100644 index 5d0549c..0000000 --- a/plaster/ModuleBuild/scaffold/tests/meta/Autoload.Tests.ps1 +++ /dev/null @@ -1,23 +0,0 @@ - -<# - Use this tests to verify, if the latest meta tests are available in this - repository, compared to the claudiospizzi/PowerShellModuleBase repository. -#> - -Describe 'Meta Autoload' { - - $baseApi = 'https://api.github.com/repos/claudiospizzi/PowerShellModuleBase/contents/Tests/Meta' - - $files = Invoke-RestMethod -Method Get -Uri $baseApi - - foreach ($file in $files) - { - if ($file.name -ne 'Autoload.Tests.ps1') - { - It "should download the latest version of \$($file.path.Replace('/', '\'))" { - - { Invoke-WebRequest -Uri $file.download_url -OutFile "$PSScriptRoot\$($file.name)" -Headers @{ 'Cache-Control' = 'no-cache' } -UseBasicParsing -ErrorAction Stop } | Should Not Throw - } - } - } -} diff --git a/plaster/ModuleBuild/scaffold/tests/meta/FileContent.Tests.ps1 b/plaster/ModuleBuild/scaffold/tests/meta/FileContent.Tests.ps1 deleted file mode 100644 index d05bd76..0000000 --- a/plaster/ModuleBuild/scaffold/tests/meta/FileContent.Tests.ps1 +++ /dev/null @@ -1,349 +0,0 @@ - -<# - This meta tests verify, if the PowerShell module core project file have a - valid content. -#> - -$ModulePath = Resolve-Path -Path "$PSScriptRoot\..\..\Modules" | ForEach-Object Path -$ModuleName = Get-ChildItem -Path $ModulePath | Select-Object -First 1 -ExpandProperty BaseName - -Remove-Module -Name $ModuleName -Force -ErrorAction SilentlyContinue -Import-Module -Name "$ModulePath\$ModuleName" -Force - -Describe 'Meta File Content' { - - $rootPath = Resolve-Path -Path "$PSScriptRoot\..\.." | ForEach-Object Path - - Context '\README.md' { - - $content = Get-Content -Path "$rootPath\README.md" - - It 'should have 4 badges at the top' { - - # Arrange - $expectAppVeyorMaster = "[![AppVeyor - master](https://img.shields.io/appveyor/ci/claudiospizzi/$ModuleName/master.svg)](https://ci.appveyor.com/project/claudiospizzi/$ModuleName/branch/master)" - $expectAppVeyorMaster = "[![AppVeyor - dev](https://img.shields.io/appveyor/ci/claudiospizzi/$ModuleName/dev.svg)](https://ci.appveyor.com/project/claudiospizzi/$ModuleName/branch/dev)" - $expectGitHubRelease = "[![GitHub - Release](https://img.shields.io/github/release/claudiospizzi/$ModuleName.svg)](https://github.com/claudiospizzi/$ModuleName/releases)" - $expectPowerShellGallery = "[![PowerShell Gallery - $ModuleName](https://img.shields.io/badge/PowerShell_Gallery-$ModuleName-0072C6.svg)](https://www.powershellgallery.com/packages/$ModuleName)" - - # Act - $actualAppVeyorMaster = $content[0] - $actualAppVeyorMaster = $content[1] - $actualGitHubRelease = $content[2] - $actualPowerShellGallery = $content[3] - - # Assert - $actualAppVeyorMaster | Should BeExactly $expectAppVeyorMaster - $actualAppVeyorMaster | Should BeExactly $expectAppVeyorMaster - $actualGitHubRelease | Should BeExactly $expectGitHubRelease - $actualPowerShellGallery | Should BeExactly $expectPowerShellGallery - } - - It 'should have one main title' { - - # Arrange - $expectCount = 1 - $expectTitle = "# $ModuleName PowerShell Module" - - # Act - $actualTitle = @() - $isCodeBlock = $false - foreach ($line in $content) - { - if ($line -like '``````*') - { - $isCodeBlock = -not $isCodeBlock - } - if (($line -like '# *') -and (-not $isCodeBlock)) - { - $actualTitle += $line - } - } - - # Assert - $actualTitle.Count | Should Be $expectCount - $actualTitle[0] | Should BeExactly $expectTitle - } - - It 'should have a all subtitles' { - - # Arrange - $expectCount = 6 - $expectSubtitles = "## Introduction", "## Requirements", "## Installation", "## Features", "## Versions", "## Contribute" - - # Act - $actualSubtitles = @($content | Where-Object { $_ -like '## *' }) - - # Assert - $actualSubtitles.Count | Should Be $expectCount - $actualSubtitles[0] | Should BeExactly $expectSubtitles[0] - $actualSubtitles[1] | Should BeExactly $expectSubtitles[1] - $actualSubtitles[2] | Should BeExactly $expectSubtitles[2] - $actualSubtitles[3] | Should BeExactly $expectSubtitles[3] - $actualSubtitles[4] | Should BeExactly $expectSubtitles[4] - $actualSubtitles[5] | Should BeExactly $expectSubtitles[5] - } - - It 'should cover every function in the features capture' { - - # Arrange - $expectFunctions = @(Get-ChildItem -Path "$ModulePath\$ModuleName\Functions" | ForEach-Object { '* **' + $_.BaseName + '** ' } | Sort-Object) - - # Act - $actualFunctions = @($content | Where-Object { $_ -like '`* `*`**`*`* ' } | Sort-Object) - - # Assert - $actualFunctions.Count | Should Not Be 0 - $actualFunctions.Count | Should Be $expectFunctions.Count - for ($i = 0; $i -lt $expectFunctions.Count; $i++) - { - $actualFunctions[$i] | Should BeExactly $expectFunctions[$i] - } - } - - It 'should contain an installation capture' { - - # Arrange - $expectLines = @( - 'With PowerShell 5.0, the new [PowerShell Gallery] was introduced. Additionally,' - 'the new module [PowerShellGet] was added to the default WMF 5.0 installation.' - 'With the cmdlet `Install-Module`, a published module from the PowerShell Gallery' - 'can be downloaded and installed directly within the PowerShell host, optionally' - 'with the scope definition:' - '' - '```powershell' - "Install-Module $ModuleName [-Scope {CurrentUser | AllUsers}]" - '```' - '' - 'Alternatively, download the latest release from GitHub and install the module' - 'manually on your local system:' - '' - '1. Download the latest release from GitHub as a ZIP file: [GitHub Releases]' - '2. Extract the module and install it: [Installing a PowerShell Module]' - ) - - # Act - $lineIndex = $content.IndexOf($expectLines[0]) - - # Assert - $lineIndex | Should Not Be -1 - for ($i = 0; $i -lt $expectLines.Count; $i++) - { - $actual = '{{{0}}}{1}' -f $i, $content[$i + $lineIndex] - $expect = '{{{0}}}{1}' -f $i, $expectLines[$i] - - $actual | Should BeExactly $expect - } - } - - It 'should contain an contribute capture' { - - # Arrange - $expectLines = @( - '## Contribute' - '' - 'Please feel free to contribute by opening new issues or providing pull requests.' - 'For the best development experience, open this project as a folder in Visual' - 'Studio Code and ensure that the PowerShell extension is installed.' - '' - '* [Visual Studio Code]' - '* [PowerShell Extension]' - '' - 'This module is tested with the PowerShell testing framework Pester. To run all' - 'tests, just start the included test script `.\Scripts\test.ps1` or invoke Pester' - 'directly with the `Invoke-Pester` cmdlet. The tests will automatically download' - 'the latest meta test from the claudiospizzi/PowerShellModuleBase repository.' - '' - 'To debug the module, just copy the existing `.\Scripts\debug.default.ps1` file' - 'to `.\Scripts\debug.ps1`, which is ignored by git. Now add the command to the' - 'debug file and start it.' - ) - - # Act - $lineIndex = $content.IndexOf($expectLines[0]) - - # Assert - $lineIndex | Should Not Be -1 - for ($i = 0; $i -lt $expectLines.Count; $i++) - { - $actual = '{{{0}}}{1}' -f $i, $content[$i + $lineIndex] - $expect = '{{{0}}}{1}' -f $i, $expectLines[$i] - - $actual | Should BeExactly $expect - } - } - } - - Context '\.gitignore' { - - $content = Get-Content -Path "$rootPath\.gitignore" - - It 'should have entries for all test and debug files' { - - # Arrange - $expect = @( - 'Scripts/debug.ps1' - 'Tests/Meta/FileContent.Tests.ps1' - 'Tests/Meta/FileEncoding.Tests.ps1' - 'Tests/Meta/FileFormatting.Tests.ps1' - 'Tests/Meta/ProjectStructure.Tests.ps1' - 'Tests/Meta/ScriptAnalyzer.Tests.ps1' - ) - - # Act - - # Assert - foreach ($expectLine in $expect) - { - $content -contains $expectLine | Should Be $true - } - } - } - - Context ".\Modules\$ModuleName\$ModuleName.psd1" { - - $data = Import-PowerShellDataFile -Path "$rootPath\Modules\$ModuleName\$ModuleName.psd1" - - It 'should have a valid RootModule value' { - - # Arrange - $expect = "$ModuleName.psm1" - - # Act - $actual = $data.RootModule - - # Assert - $actual | Should BeExactly $expect - } - - It 'should have a valid ModuleVersion value' { - - # Arrange - $expect = '*.*.*' - - # Act - $actual = $data.ModuleVersion - - # Assert - $actual | Should BeLike $expect - } - - It 'should have a valid GUID value' { - - # Arrange - $expect = '????????-????-????-????-????????????' - - # Act - $actual = $data.GUID - - # Assert - $actual | Should BeLike $expect - } - - It 'should have a valid Author value' { - - # Arrange - $expect = 'Claudio Spizzi' - - # Act - $actual = $data.Author - - # Assert - $actual | Should BeExactly $expect - } - - It 'should have a valid Copyright value' { - - # Arrange - - # Act - $actual = $data.Copyright - - # Assert - $actual | Should Not BeNullOrEmpty - } - - It 'should have a valid Description value' { - - # Arrange - - # Act - $actual = $data.Description - - # Assert - $actual | Should Not BeNullOrEmpty - } - - It 'should have a valid PowerShellVersion value' { - - # Arrange - - # Act - $actual = $data.PowerShellVersion - - # Assert - $actual | Should Not BeNullOrEmpty - } - - It 'should have valid TypesToProcess values' { - - # Arrange - $expect = @( - "Resources\$ModuleName.Types.ps1xml" - ) - - # Act - $actual = $data.TypesToProcess - - # Assert - $actual.Count | Should Be 1 - $actual[0] | Should BeExactly $expect[0] - } - - It 'should have valid FormatsToProcess values' { - - # Arrange - $expect = @( - "Resources\$ModuleName.Formats.ps1xml" - ) - - # Act - $actual = $data.FormatsToProcess - - # Assert - $actual.Count | Should Be 1 - $actual[0] | Should BeExactly $expect[0] - } - - It 'should have valid FunctionsToExport values' { - - # Arrange - $expect = @(Get-ChildItem -Path "$ModulePath\$ModuleName\Functions" | ForEach-Object BaseName | Sort-Object) - - # Act - $actual = @($data.FunctionsToExport | Sort-Object) - - # Assert - $actual.Count | Should Be $expect.Count - for ($i = 0; $i -lt $expect.Count; $i++) - { - $actual[$i] | Should BeExactly $expect[$i] - } - } - - It 'should have valid PrivateData hash table' { - - # Arrange - $expectLicenseUri = "https://raw.githubusercontent.com/claudiospizzi/$ModuleName/master/LICENSE" - $expectProjectUri = "https://github.com/claudiospizzi/$ModuleName" - - # Act - $actual = $data.PrivateData - - # Assert - $actual.PSData.Tags -contains 'PSModule' | Should Be $true - $actual.PSData.LicenseUri | Should BeExactly $expectLicenseUri - $actual.PSData.ProjectUri | Should BeExactly $expectProjectUri - } - } -} diff --git a/plaster/ModuleBuild/scaffold/tests/meta/FileEncoding.Tests.ps1 b/plaster/ModuleBuild/scaffold/tests/meta/FileEncoding.Tests.ps1 deleted file mode 100644 index 9ad1edd..0000000 --- a/plaster/ModuleBuild/scaffold/tests/meta/FileEncoding.Tests.ps1 +++ /dev/null @@ -1,54 +0,0 @@ - -<# - Check if the encoding of all text files in the PowerShell module is valid, - this means no Unicode or UTF-8 with BOM files. -#> - -$ModulePath = Resolve-Path -Path "$PSScriptRoot\..\..\Modules" | ForEach-Object Path -$ModuleName = Get-ChildItem -Path $ModulePath | Select-Object -First 1 -ExpandProperty BaseName - -Remove-Module -Name $ModuleName -Force -ErrorAction SilentlyContinue -Import-Module -Name "$ModulePath\$ModuleName" -Force - -Describe 'Meta File Encoding' { - - $fileExtensions = '.ps1', '.psm1', '.psd1', '.ps1xml', '.txt', '.xml', - '.cmd', '.json', '.md', '.csv', '.yml', '.log', - '.gitignore', '.gitattributes' - - $rootPath = Resolve-Path -Path "$PSScriptRoot\..\.." | ForEach-Object Path - $textFiles = Get-ChildItem -Path $rootPath -File -Recurse | - Where-Object { -not $_.FullName.StartsWith("$rootPath\Sources\") } | - Where-Object { $fileExtensions -contains $_.Extension } | - ForEach-Object { $_.FullName.Replace($rootPath, '') } - - Context 'No Unicode encoding' { - - foreach ($textFile in $textFiles) - { - # To check, if the file is encoded in Unicode, check for 0x00 byte - # characters. In a Unicode file, every second charcter is normally - # a 0x00 character, because to majority of chars don't use more than - # the first byte. - It "should not use Unicode encoding for $textFile" { - - @([System.IO.File]::ReadAllBytes("$rootPath\$textFile") -eq 0).Length -eq 0 | Should Be $true - } - } - } - - Context 'No UTF-8 with BOM encoding' { - - foreach ($textFile in $textFiles) - { - # We use UTF-8 encoding with byte order mask (BOM). Therefore we - # check if the file starts with the bytes 0xEF, 0xBB, 0xBF. - It "should not use BOM for UTF-8 encoding for $textFile" { - - $bytes = [System.IO.File]::ReadAllBytes("$rootPath\$textFile") - - ($bytes.Length -ge 3 -and $bytes[0] -eq 239 -and $bytes[1] -eq 187 -and $bytes[2] -eq 191) | Should Be $false - } - } - } -} diff --git a/plaster/ModuleBuild/scaffold/tests/meta/FileFormatting.Tests.ps1 b/plaster/ModuleBuild/scaffold/tests/meta/FileFormatting.Tests.ps1 deleted file mode 100644 index 690cb2f..0000000 --- a/plaster/ModuleBuild/scaffold/tests/meta/FileFormatting.Tests.ps1 +++ /dev/null @@ -1,96 +0,0 @@ - -<# - Verify that the file content if formatted property. It will verify the - following criterias: Use spaces instead of tabs for indentation, no trailing - spaces for lines and should end with a new line. -#> - -$ModulePath = Resolve-Path -Path "$PSScriptRoot\..\..\Modules" | ForEach-Object Path -$ModuleName = Get-ChildItem -Path $ModulePath | Select-Object -First 1 -ExpandProperty BaseName - -Remove-Module -Name $ModuleName -Force -ErrorAction SilentlyContinue -Import-Module -Name "$ModulePath\$ModuleName" -Force - -Describe 'Meta File Formatting' { - - $fileExtensions = '.ps1', '.psm1', '.psd1', '.ps1xml', '.txt', '.xml', - '.cmd', '.json', '.md', '.csv', '.yml', '.log', - '.gitignore', '.gitattributes' - - $rootPath = Resolve-Path -Path "$PSScriptRoot\..\.." | ForEach-Object Path - $textFiles = Get-ChildItem -Path $rootPath -File -Recurse | - Where-Object { -not $_.FullName.StartsWith("$rootPath\Sources\") } | - Where-Object { $fileExtensions -contains $_.Extension } | - ForEach-Object { $_.FullName.Replace($rootPath, '') } - - Context 'Space Indentation' { - - foreach ($textFile in $textFiles) - { - It "should use spaces and not tabs for indentation in $textFile" { - - $errorLines = @() - - $content = @(Get-Content -Path "$rootPath$textFile") - - for ($line = 0; $line -lt $content.Length; $line++) - { - if(($content[$line] | Select-String "`t" | Measure-Object).Count -ne 0) - { - $errorLines += $line + 1 - - Write-Warning "There are tabs instead of spaces in $textFile`:$($line + 1)" - } - } - - $errorLines.Count | Should Be 0 - } - } - } - - Context 'No Trailing Spaces' { - - # Do not test markdown files for trailing spaces. - $textFilesFiltered = $textFiles | Where-Object { $_ -notlike '*.md' } - - foreach ($textFile in $textFilesFiltered) - { - It "should not have trailing spaces in $textFile" { - - $errorLines = @() - - $content = @(Get-Content -Path "$rootPath$textFile") - - for ($line = 0; $line -lt $content.Length; $line++) - { - if($content[$Line].ToString().TrimEnd() -ne $content[$Line]) - { - $errorLines += $line + 1 - - Write-Warning "There are trailing spaces in $textFile`:$($line + 1)" - } - } - - $errorLines.Count | Should Be 0 - } - } - } - - Context 'New Line Termination' { - - # Do not test files in .vscode for trailing spaces. - $textFilesFiltered = $textFiles | Where-Object { $_ -notlike '*\.vscode\*' } - - foreach ($textFile in $textFilesFiltered) - { - - It "should terminate with a new line in $textFile" { - - $content = Get-Content -Path "$rootPath$textFile" -Raw - - $content.Length | Should Not Be 0 - $content[-1] | Should Be "`n" - } - } - } -} diff --git a/plaster/ModuleBuild/scaffold/tests/meta/ProjectStructure.Tests.ps1 b/plaster/ModuleBuild/scaffold/tests/meta/ProjectStructure.Tests.ps1 deleted file mode 100644 index c120da7..0000000 --- a/plaster/ModuleBuild/scaffold/tests/meta/ProjectStructure.Tests.ps1 +++ /dev/null @@ -1,152 +0,0 @@ - -<# - This meta tests verify, if the PowerShell module project structure is - adhered to the best practices. -#> - -$ModulePath = Resolve-Path -Path "$PSScriptRoot\..\..\Modules" | ForEach-Object Path -$ModuleName = Get-ChildItem -Path $ModulePath | Select-Object -First 1 -ExpandProperty BaseName - -Remove-Module -Name $ModuleName -Force -ErrorAction SilentlyContinue -Import-Module -Name "$ModulePath\$ModuleName" -Force - -Describe 'Meta Project Structure' { - - $rootPath = Resolve-Path -Path "$PSScriptRoot\..\.." | ForEach-Object Path - - Context 'Folders' { - - $requiredFolders = @( - '\Scripts' - '\Modules' - "\Modules\$ModuleName" - "\Modules\$ModuleName\en-US" - "\Modules\$ModuleName\Functions" - "\Modules\$ModuleName\Resources" - '\Tests' - '\Tests\Meta' - '\Tests\Unit' - ) - - $optionalFolders = @( - "\Modules\$ModuleName\Helpers" - '\Sources' - "\Sources\$ModuleName" - '\Tests\Integration' - ) - - foreach ($requiredFolder in $requiredFolders) - { - It "should contain the folder $requiredFolder" { - - Test-Path -Path "$rootPath$requiredFolder" | Should Be $true - } - } - - foreach ($optionalFolder in $optionalFolders) - { - It "can contain the folder $optionalFolder" { - - if ((Test-Path -Path "$rootPath$optionalFolder")) - { - Test-Path -Path "$rootPath$optionalFolder" | Should Be $true - } - else - { - Set-TestInconclusive -Message "Optional folder $optionalFolder not found!" - } - } - } - } - - Context 'Files' { - - $requiredFiles = @( - '\appveyor.yml' - '\LICENSE' - '\README.md' - '\Scripts\build.ps1' - '\Scripts\debug.default.ps1' - '\Scripts\release.ps1' - '\Scripts\test.ps1' - "\Modules\$ModuleName\en-US\about_$ModuleName.help.txt" - "\Modules\$ModuleName\Resources\$ModuleName.Formats.ps1xml" - "\Modules\$ModuleName\Resources\$ModuleName.Types.ps1xml" - "\Modules\$ModuleName\$ModuleName.psd1" - "\Modules\$ModuleName\$ModuleName.psm1" - '\Tests\Meta\Autoload.Tests.ps1' - ) - - $optionalFiles = @( - "\Sources\$ModuleName.sln" - ) - - foreach ($requiredFile in $requiredFiles) - { - It "should contain the file $requiredFile" { - - Test-Path -Path "$rootPath\$requiredFile" | Should Be $true - } - } - - foreach ($optionalFile in $optionalFiles) - { - It "can contain the file $optionalFile" { - - if ((Test-Path -Path "$rootPath$optionalFile")) - { - Test-Path -Path "$rootPath$optionalFile" | Should Be $true - } - else - { - Set-TestInconclusive -Message "Optional file $optionalFile not found!" - } - } - } - } - - Context 'Version' { - - # Arrange - $requiredVersion = (Import-PowerShellDataFile -Path "$rootPath\Modules\$ModuleName\$ModuleName.psd1")['ModuleVersion'] - - It "should have version $requiredVersion in README.md" { - - # Act - $versionHeadline = @(Get-Content -Path "$rootPath\README.md" | Where-Object { $_ -eq "### $requiredVersion" }) - - # Assert - $versionHeadline.Count | Should Be 1 - $versionHeadline[0] | Should BeExactly "### $requiredVersion" - } - - It "should have version $requiredVersion in $ModuleName.psd1" { - - # Act - $moduleDefinition = Import-PowerShellDataFile -Path "$rootPath\Modules\$ModuleName\$ModuleName.psd1" - - # Assert - $moduleDefinition.ModuleVersion | Should Be $requiredVersion - } - - if ((Test-Path -Path "$rootPath\Sources\$ModuleName")) - { - It "should have version $requiredVersion in $ModuleName.dll" { - - if ((Test-Path -Path "$rootPath\Modules\$ModuleName\$ModuleName.dll")) - { - # Act - $moduleAssembly = Get-Item -Path "$rootPath\Modules\$ModuleName\$ModuleName.dll" - - # Assert - $moduleAssembly.VersionInfo.ProductVersion | Should Be $requiredVersion - $moduleAssembly.VersionInfo.FileVersion | Should Be $requiredVersion - } - else - { - Set-TestInconclusive -Message "$ModuleName.dll file was not found!" - } - } - } - } -} diff --git a/plaster/ModuleBuild/scaffold/tests/meta/ScriptAnalyzer.Tests.ps1 b/plaster/ModuleBuild/scaffold/tests/meta/ScriptAnalyzer.Tests.ps1 deleted file mode 100644 index 805027d..0000000 --- a/plaster/ModuleBuild/scaffold/tests/meta/ScriptAnalyzer.Tests.ps1 +++ /dev/null @@ -1,37 +0,0 @@ -# Requires -Modules Pester -<# - Check all scripts files in the sources folder against all script analyzer - rules. It should comply with all rules. -#> - -$ModulePath = Resolve-Path -Path "$PSScriptRoot\..\..\Modules" | ForEach-Object Path -$ModuleName = Get-ChildItem -Path $ModulePath | Select-Object -First 1 -ExpandProperty BaseName - -Remove-Module -Name $ModuleName -Force -ErrorAction SilentlyContinue -Import-Module -Name "$ModulePath\$ModuleName" -Force - -Describe 'Meta Script Analyzer' { - - foreach ($severity in 'Information', 'Warning', 'Error') - { - Context "$severity Rules" { - - $scriptAnalyzerRules = Get-ScriptAnalyzerRule -Severity $severity - - foreach ($scriptAnalyzerRule in $scriptAnalyzerRules) - { - It "should conform the rule $($scriptAnalyzerRule.RuleName)" { - - $scriptAnalyzerResults = @(Invoke-ScriptAnalyzer -Path $ModulePath -IncludeRule $scriptAnalyzerRule -Recurse) - - foreach ($scriptAnalyzerResult in $scriptAnalyzerResults) - { - Write-Warning ('{0}, line {1}: {2}' -f $scriptAnalyzerResult.ScriptPath.Replace("$ModulePath", 'Modules'), $scriptAnalyzerResult.Line, $scriptAnalyzerResult.Message) - } - - $scriptAnalyzerResults.Count | Should Be 0 - } - } - } - } -} diff --git a/plaster/ModuleBuild/scaffold/tests/unit/other/readme.md b/plaster/ModuleBuild/scaffold/tests/unit/other/readme.md new file mode 100644 index 0000000..0f8a083 --- /dev/null +++ b/plaster/ModuleBuild/scaffold/tests/unit/other/readme.md @@ -0,0 +1 @@ +Unit tests for scripts in other folder go here \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/tests/unit/private/readme.md b/plaster/ModuleBuild/scaffold/tests/unit/private/readme.md new file mode 100644 index 0000000..f5215b7 --- /dev/null +++ b/plaster/ModuleBuild/scaffold/tests/unit/private/readme.md @@ -0,0 +1 @@ +Unit tests for private functions go here \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/tests/unit/public/readme.md b/plaster/ModuleBuild/scaffold/tests/unit/public/readme.md new file mode 100644 index 0000000..b082d23 --- /dev/null +++ b/plaster/ModuleBuild/scaffold/tests/unit/public/readme.md @@ -0,0 +1 @@ +Unit tests for public functions go here \ No newline at end of file diff --git a/plaster/PlasterContent.ps1 b/plaster/PlasterContent.ps1 index 44633db..87b1a64 100644 --- a/plaster/PlasterContent.ps1 +++ b/plaster/PlasterContent.ps1 @@ -26,7 +26,7 @@ $Content = @( ContentType = 'file' Source = 'scaffold\gitattributes' Destination = '.gitattributes' - }, + }, @{ ContentType = 'templateFile' Source = 'scaffold\vscode\*' @@ -59,8 +59,38 @@ $Content = @( }, @{ ContentType = 'file' - Source = 'scaffold\tests\*' - Destination = 'src\tests' + Source = 'scaffold\tests\' + Destination = 'tests' + }, + @{ + ContentType = 'file' + Source = 'scaffold\tests\intergration' + Destination = 'tests\intergration' + }, + @{ + ContentType = 'file' + Source = 'scaffold\tests\unit' + Destination = 'tests\unit' + }, + @{ + ContentType = 'file' + Source = 'scaffold\tests\intergration\private\*' + Destination = 'tests\intergration\private' + }, + @{ + ContentType = 'file' + Source = 'scaffold\tests\intergration\public\*' + Destination = 'tests\intergration\public' + }, + @{ + ContentType = 'file' + Source = 'scaffold\tests\unit\private\*' + Destination = 'tests\unit\private' + }, + @{ + ContentType = 'file' + Source = 'scaffold\tests\unit\public\*' + Destination = 'tests\unit\public' }, @{ ContentType = 'templateFile' diff --git a/src/tests/FunctionCBH.Tests.ps1 b/src/tests/FunctionCBH.Tests.ps1 deleted file mode 100644 index 0f418c3..0000000 --- a/src/tests/FunctionCBH.Tests.ps1 +++ /dev/null @@ -1,60 +0,0 @@ -#Requires -Modules Pester -<# - This pester test verifies the module's public functions all have proper comment based help required for building documentation via PlatyPS. - - Example: - PS> Invoke-Pester -Script @{Path = '.\src\tests\FuncitonCBH.Tests.ps1'; Parameters = @{ ModuleName = MyModule}} -#> - -[CmdletBinding()] -Param( - [Parameter(HelpMessage = 'Module to scan.')] - [string]$ModuleName -) - -If (($ModuleName -like '*.psd1') -and (test-path $ModuleName)) { - $Module = (Split-Path $ModuleName -Leaf) -replace '.psd1','' -} -else { - $Module = $ModuleName -} - -if (-not (Get-Module $Module)) { - try { - Import-Module $ModuleName -force - } - catch { - throw "$Module is not loaded." - } -} - -Describe "Comment Based Help tests for $Module" -Tags Build { - - $functions = Get-Command -Module $Module -CommandType Function - foreach($Function in $Functions){ - $help = Get-Help $Function.name - Context $help.name { - it "Has a HelpUri" { - $Function.HelpUri | Should Not BeNullOrEmpty - } - It "Has related Links" { - $help.relatedLinks.navigationLink.uri.count | Should BeGreaterThan 0 - } - it "Has a description" { - $help.description | Should Not BeNullOrEmpty - } - it "Has an example" { - $help.examples | Should Not BeNullOrEmpty - } - foreach($parameter in $help.parameters.parameter) - { - if($parameter -notmatch 'whatif|confirm') - { - it "Has a Parameter description for '$($parameter.name)'" { - $parameter.Description.text | Should Not BeNullOrEmpty - } - } - } - } - } -} \ No newline at end of file diff --git a/src/tests/ModuleManifest.Tests.ps1 b/src/tests/ModuleManifest.Tests.ps1 deleted file mode 100644 index c6bf56f..0000000 --- a/src/tests/ModuleManifest.Tests.ps1 +++ /dev/null @@ -1,205 +0,0 @@ -#Requires -Modules Pester - -<# - This pester test verifies the PowerShell module manifest file has valid content that will be required to - upload to the PowerShell Gallary. - - .EXAMPLE - PS> Invoke-Pester -Script @{Path = '.\src\tests\ModuleManifest.Tests.ps1'; Parameters = @{ ManifestPath = 'C:\Users\zloeber\Dropbox\Zach_Docs\Projects\Git\PSAD'; Author = 'Zachary Loeber'; Website = 'https://github.com/zloeber/PSAD'; Tags = @('ADSI', 'Active_Directory', 'DC') }} - - Runs some standard tests and a few manual validations (Tags, Author, and Website). - .EXAMPLE - PS> Invoke-Pester -Script @{Path = '.\src\tests\ModuleManifest.Tests.ps1'; Parameters = @{ ManifestPath = '.\PSAD.psd1'}} - - Runs several generic tests against the PSAD.psd1 manifest to ensure all required values for uploading to the PowerShell Gallery simply exist. -#> - -[CmdLetBinding(DefaultParameterSetName='Default')] -Param( - [Parameter(Mandatory = $True, ParameterSetName='Default')] - [Parameter(Mandatory = $True, ParameterSetName='Manual')] - [Parameter(Mandatory = $True, ParameterSetName='ModuleBuild')] - [string]$ManifestPath, - [Parameter(Mandatory = $True, ParameterSetName='ModuleBuild')] - [string]$ModuleBuildJSONPath, - [Parameter(ParameterSetName='Manual')] - [string]$Author, - [Parameter(ParameterSetName='Manual')] - [string]$Copyright, - [Parameter(ParameterSetName='Manual')] - [string]$Website, - [Parameter(ParameterSetName='Manual')] - [string]$LicenseURI, - [Parameter(ParameterSetName='Manual')] - [string]$Version, - [Parameter(ParameterSetName='Manual')] - [string[]]$Tags -) - -if (($ManifestPath.EndsWith('psd1')) -and (Test-Path $ManifestPath)) { - # Grab the short module name - $ModuleName = (Split-Path $ManifestPath -Leaf).Split('.')[0] - - Describe 'Module Manifest - Standard Tests' { - Context "Testing $ManifestPath" { - It 'should be a valid module manifest file' { - { - $Script:Manifest = Test-ModuleManifest -Path $ManifestPath -ErrorAction Stop -WarningAction SilentlyContinue - } | Should Not Throw - } - - It 'should have a valid RootModule value' { - $Script:Manifest.RootModule | Should Be "$ModuleName.psm1" - } - - It 'should have a valid GUID' { - ($Script:Manifest.Guid).Guid | Should BeLike '????????-????-????-????-????????????' - } - - It 'should have a valid PowerShellVersion value' { - $Script:Manifest.PowerShellVersion | Should Not BeNullOrEmpty - } - } - } - - switch ($PSCmdlet.ParameterSetName) { - 'Default' { - # Passed just a module manifest file name with no other information to validate - # This will check for several entries that they simply exist. - Describe 'Module Manifest - Generic Tests' { - Context "Testing $ManifestPath" { - It 'should have a valid Module version' { - ($Script:Manifest.Version).ToString() -as [Version] | Should Not BeNullOrEmpty - } - - It 'should have a valid module description' { - $Script:Manifest.Description | Should Not BeNullOrEmpty - } - - It 'should have a valid module author' { - $Script:Manifest.Author | Should Not BeNullOrEmpty - } - - It 'should have a valid module project website' { - $Script:Manifest.ProjectUri.OriginalString | Should Not BeNullOrEmpty - } - - It 'should have a valid license URL' { - $Script:Manifest.LicenseUri | Should Not BeNullOrEmpty - } - - It 'should have some tags' { - @($Script:Manifest.PrivateData.PSData.Tags).Count -gt 0 | Should Be $true - } - } - } - } - 'Manual' { - # Passed a manifest name and several manual entries to validate - Describe 'Module Manifest - Manual Tests' { - Context "Testing $ManifestPath" { - if (-not [string]::IsNullOrEmpty($Version)) { - It "should be module version '$Version'" { - ($Script:Manifest.Version).ToString() -as [Version] | Should Be $Version - } - } - if (-not [string]::IsNullOrEmpty($Description)) { - It "should have a module description of '$Description'" { - $Script:Manifest.Description | Should Be $Description - } - } - - if (-not [string]::IsNullOrEmpty($Author)) { - It "should have the module author of '$Author'" { - $Script:Manifest.Author | Should Be $Author - } - } - - if (-not [string]::IsNullOrEmpty($Copyright)) { - It "should have a Copyright of '$Copyright'" { - $Script:Manifest.Copyright | Should Be $Copyright - } - } - - if (-not [string]::IsNullOrEmpty($Website)) { - It "should have the project website of '$Website'" { - $Script:Manifest.ProjectUri.OriginalString | Should Be $Website - } - } - - if (-not [string]::IsNullOrEmpty($LicenseURI)) { - It "should have the license URI of '$LicenseURI'" { - $Script:Manifest.LicenseUri | Should Be $LicenseURI - } - } - if ($Tags.Count -gt 0) { - It "should have these tags: $($Tags -join ',')" { - Compare-Object $Script:Manifest.PrivateData.PSData.Tags $Tags | Should Be $Null - } - } - } - } - } - 'ModuleBuild' { - # Passed a manifest name and a ModuleBuild json configuration file to validate - if (($ModuleBuildJSONPath.EndsWith('psd1')) -and (Test-Path $ModuleBuildJSONPath)) { - try { - $ModuleInfo = get-content $ModuleBuildJSONPath | ConvertFrom-Json - } - catch { - throw "$ModuleBuildJSONPath either does not exist or is not a json file!" - } - } - else { - throw "$ModuleBuildJSONPath either does not exist or is not a json file!" - } - # Passed a manifest name and several manual entries to validate - Describe 'Module Manifest - ModuleBuild Tests' { - Context "Testing $ManifestPath" { - if (-not [string]::IsNullOrEmpty($Version)) { - It "should be module version '$Version'" { - ($Script:Manifest.Version).ToString() -as [Version] | Should Be $ModuleInfo.ModuleVersion - } - } - if (-not [string]::IsNullOrEmpty($Description)) { - It "should have a module description of '$Description'" { - $Script:Manifest.Description | Should Be $ModuleInfo.ModuleDescription - } - } - - if (-not [string]::IsNullOrEmpty($Author)) { - It "should have the module author of '$Author'" { - $Script:Manifest.Author | Should Be $ModuleInfo.ModuleAuthor - } - } - - if (-not [string]::IsNullOrEmpty($Copyright)) { - It "should have a Copyright of '$Copyright'" { - $Script:Manifest.Copyright | Should Be $ModuleInfo.ModuleCopyright - } - } - - if (-not [string]::IsNullOrEmpty($Website)) { - It "should have the project website of '$Website'" { - $Script:Manifest.ProjectUri.OriginalString | Should Be $ModuleInfo.ModuleWebsite - } - } - - if (-not [string]::IsNullOrEmpty($LicenseURI)) { - It "should have the license URI of '$LicenseURI'" { - $Script:Manifest.LicenseUri | Should Be $ModuleInfo.ModuleLicenseURI - } - } - if ($Tags.Count -gt 0) { - It "should have these tags: $($ModuleInfo.ModuleTags -join ',')" { - Compare-Object $Script:Manifest.PrivateData.PSData.Tags $ModuleInfo.ModuleTags | Should Be $Null - } - } - } - } - } - } -} -else { - Write-Error "$ManifestPath was not found!" -} \ No newline at end of file diff --git a/src/tests/ScriptAnalyzer.Tests.ps1 b/src/tests/ScriptAnalyzer.Tests.ps1 deleted file mode 100644 index b96ff54..0000000 --- a/src/tests/ScriptAnalyzer.Tests.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -#Requires -Modules Pester -<# - This pester test verifies the files in the specified path do not contain sensitive information. - - Example: - Invoke-Pester -Script @{Path = '.\src\tests\ScriptAnalyzer.Tests.ps1'; Parameters = @{ Path = 'C:\Users\zloeber\Dropbox\Zach_Docs\Projects\Git\PSAD' }} -#> - -[CmdletBinding()] -Param( - [Parameter(HelpMessage = 'Path to the files to scan.')] - [string]$Path -) - -if (-not (Get-Item $Path -ErrorAction:SilentlyContinue).PSIsContainer) { - throw "Either $Path is not a directory or does not exist" -} - -Describe 'Testing against PSSA rules' { - Context 'PSSA Standard Rules' { - $analysis = Invoke-ScriptAnalyzer -Path $Path - $scriptAnalyzerRules = Get-ScriptAnalyzerRule - forEach ($rule in $scriptAnalyzerRules) { - It "Should pass $rule" { - If ($analysis.RuleName -contains $rule) { - $analysis | Where RuleName -EQ $rule -outvariable failures | Out-Default - $failures.Count | Should Be 0 - } - } - } - } -} \ No newline at end of file diff --git a/src/tests/SensitiveTermScan.Tests.ps1 b/src/tests/SensitiveTermScan.Tests.ps1 deleted file mode 100644 index 7e5553a..0000000 --- a/src/tests/SensitiveTermScan.Tests.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -#Requires -Modules Pester -<# - This pester test verifies the files in the specified path do not contain sensitive information. - - Example: - Invoke-Pester -Script @{Path = '.\src\tests\SensitiveTermScan.Tests.ps1'; Parameters = @{ Path = 'C:\Users\zloeber\Dropbox\Zach_Docs\Projects\Git\PSAD'; Terms = @('mydomainname.com', 'myservername') }} -#> - -[CmdletBinding()] -Param( - [Parameter(HelpMessage = 'Path to the files to scan.')] - [string]$Path, - [Parameter(HelpMessage = 'Terms to scan for.')] - [string[]]$Terms -) - -if (Test-Path $Path) { - Describe 'Scan for sensitive terms.' { - foreach ($Term in $Terms) { - $TermSearch = @(Get-ChildItem -Recurse -Path $Path | Select-String -Pattern $Term) - Context "Files in $Path" { - It "should not contain the term $Term" { - $TermSearch.Count -gt 0 | Should Be $false - } - } - } - } -} \ No newline at end of file diff --git a/tests/intergration/private/readme.md b/tests/intergration/private/readme.md new file mode 100644 index 0000000..1f6dba4 --- /dev/null +++ b/tests/intergration/private/readme.md @@ -0,0 +1 @@ +Intergration tests for private functions go here \ No newline at end of file diff --git a/tests/intergration/public/readme.md b/tests/intergration/public/readme.md new file mode 100644 index 0000000..5cf9b73 --- /dev/null +++ b/tests/intergration/public/readme.md @@ -0,0 +1 @@ +Intergration tests for public functions go here \ No newline at end of file diff --git a/tests/unit/private/readme.md b/tests/unit/private/readme.md new file mode 100644 index 0000000..f5215b7 --- /dev/null +++ b/tests/unit/private/readme.md @@ -0,0 +1 @@ +Unit tests for private functions go here \ No newline at end of file diff --git a/tests/unit/public/readme.md b/tests/unit/public/readme.md new file mode 100644 index 0000000..b082d23 --- /dev/null +++ b/tests/unit/public/readme.md @@ -0,0 +1 @@ +Unit tests for public functions go here \ No newline at end of file From d4e78a8308dd7f1c48d48327315760b2c482f8f7 Mon Sep 17 00:00:00 2001 From: justin-p Date: Thu, 10 Jan 2019 16:40:23 +0100 Subject: [PATCH 012/102] removed other folder --- plaster/ModuleBuild/plasterManifest.xml | 2 +- plaster/ModuleBuild/scaffold/tests/intergration/other/readme.md | 1 - plaster/ModuleBuild/scaffold/tests/unit/other/readme.md | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 plaster/ModuleBuild/scaffold/tests/intergration/other/readme.md delete mode 100644 plaster/ModuleBuild/scaffold/tests/unit/other/readme.md diff --git a/plaster/ModuleBuild/plasterManifest.xml b/plaster/ModuleBuild/plasterManifest.xml index d95627c..629ea61 100644 --- a/plaster/ModuleBuild/plasterManifest.xml +++ b/plaster/ModuleBuild/plasterManifest.xml @@ -4,7 +4,7 @@ templateType="Project" xmlns="http://www.microsoft.com/schemas/PowerShell/Plaster/v1"> ModuleBuild - 4794ac4a-1fbc-49f4-973f-9ece24eaa1d9 + fc5c0ee0-65ae-4cc0-b8af-85c2598ed8ef 0.0.1 New ModuleBuild Project Create a new PowerShell Module with a ModuleBuild wrapper diff --git a/plaster/ModuleBuild/scaffold/tests/intergration/other/readme.md b/plaster/ModuleBuild/scaffold/tests/intergration/other/readme.md deleted file mode 100644 index 536a744..0000000 --- a/plaster/ModuleBuild/scaffold/tests/intergration/other/readme.md +++ /dev/null @@ -1 +0,0 @@ -Intergration tests for scripts in other folder go here \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/tests/unit/other/readme.md b/plaster/ModuleBuild/scaffold/tests/unit/other/readme.md deleted file mode 100644 index 0f8a083..0000000 --- a/plaster/ModuleBuild/scaffold/tests/unit/other/readme.md +++ /dev/null @@ -1 +0,0 @@ -Unit tests for scripts in other folder go here \ No newline at end of file From d84b024feedd9e808b3962092539d81124b53864 Mon Sep 17 00:00:00 2001 From: justin-p Date: Fri, 11 Jan 2019 13:51:01 +0100 Subject: [PATCH 013/102] PSAvoidUsingCmdletAliases --- PSScriptAnalyzerSettings.psd1 | 26 ++++++++++++++++++++++++-- src/private/Convert-ArrayToRegex.ps1 | 2 +- src/private/Get-BuildFilePath.ps1 | 2 +- src/private/Get-FunctionParameter.ps1 | 6 +++--- src/private/New-CommentBasedHelp.ps1 | 4 ++-- src/public/Add-PublicFunction.ps1 | 4 ++-- 6 files changed, 33 insertions(+), 11 deletions(-) diff --git a/PSScriptAnalyzerSettings.psd1 b/PSScriptAnalyzerSettings.psd1 index 80bfffb..bde2636 100644 --- a/PSScriptAnalyzerSettings.psd1 +++ b/PSScriptAnalyzerSettings.psd1 @@ -1,4 +1,26 @@ @{ - IncludeRules=@('PSProvideCommentHelp', - 'PSAvoidUsingWriteHost') + IncludeRules=@('PSUseApprovedVerbs', + 'PSReservedCmdletChar', + 'PSReservedParams', + 'PSShouldProcess', + 'PSUseShouldProcessForStateChangingFunctions', + 'PSUseSingularNouns', + 'PSMissingModuleManifestField', + 'PSAvoidDefaultValueSwitchParameter', + 'PSAvoidUsingCmdletAliases', + 'PSAvoidUsingWMICmdlet', + 'PSAvoidUsingEmptyCatchBlock', + 'PSUseCmdletCorrectly', + 'PSUseShouldProcessForStateChangingFunctions', + 'PSAvoidUsingPositionalParameters', + 'PSAvoidGlobalVars', + 'PSUseDeclaredVarsMoreThanAssignments', + 'PSAvoidUsingInvokeExpression', + 'PSAvoidUsingPlainTextForPassword', + 'PSAvoidUsingComputerNameHardcoded', + 'PSAvoidUsingConvertToSecureStringWithPlainText', + 'PSUsePSCredentialType', + 'PSAvoidUsingUserNameAndPasswordParams', + 'PSDSC*' + ) } \ No newline at end of file diff --git a/src/private/Convert-ArrayToRegex.ps1 b/src/private/Convert-ArrayToRegex.ps1 index 3160a9c..96d6040 100644 --- a/src/private/Convert-ArrayToRegex.ps1 +++ b/src/private/Convert-ArrayToRegex.ps1 @@ -19,7 +19,7 @@ function Convert-ArrayToRegex { '^(' + ($Items -join '|') + ')$' } else { - '^(' + (($Items | %{[regex]::Escape($_)}) -join '|') + ')$' + '^(' + (($Items | ForEach-Object{[regex]::Escape($_)}) -join '|') + ')$' } } else { diff --git a/src/private/Get-BuildFilePath.ps1 b/src/private/Get-BuildFilePath.ps1 index 217402c..0814360 100644 --- a/src/private/Get-BuildFilePath.ps1 +++ b/src/private/Get-BuildFilePath.ps1 @@ -1,3 +1,3 @@ function Get-BuildFilePath { - $BuildPath = (Get-ChildItem -File -Filter "*.buildenvironment.json" -Path '.\','..\','.\build\' -ErrorAction:SilentlyContinue | select -First 1).FullName + $BuildPath = (Get-ChildItem -File -Filter "*.buildenvironment.json" -Path '.\','..\','.\build\' -ErrorAction:SilentlyContinue | Select-Object -First 1).FullName } \ No newline at end of file diff --git a/src/private/Get-FunctionParameter.ps1 b/src/private/Get-FunctionParameter.ps1 index 4ab6fe6..c9d7875 100644 --- a/src/private/Get-FunctionParameter.ps1 +++ b/src/private/Get-FunctionParameter.ps1 @@ -78,7 +78,7 @@ function Get-FunctionParameter { $functions = $CodeBlock | Get-Function -Name $Name if (-not $IncludeEmbedded) { Write-Verbose "$($FunctionName): Not including embedded functions." - $functions = $functions | where {-not $_.IsEmbedded} + $functions = $functions | Where-Object {-not $_.IsEmbedded} } Foreach ($f in $functions) { @@ -93,7 +93,7 @@ function Get-FunctionParameter { 'ParameterType' = $ParamType[0].typeName.FullName } # This will add in any other parameter attributes if they are specified (default attributes are thus not included and output may not be normalized) - $p.FindAll($paramattributes, $true) | Foreach { + $p.FindAll($paramattributes, $true) | ForEach-Object { $OutProps.($_.ArgumentName) = $_.Argument.Value } $Output += New-Object -TypeName PSObject -Property $OutProps @@ -114,7 +114,7 @@ function Get-FunctionParameter { 'ParameterType' = $ParamType[0].typeName.FullName } # This will add in any other parameter attributes if they are specified (default attributes are thus not included and output may not be normalized) - $p.FindAll($paramattributes, $true) | Foreach { + $p.FindAll($paramattributes, $true) | ForEach-Object { $OutProps.($_.ArgumentName) = $_.Argument.Value } $Output += New-Object -TypeName PSObject -Property $OutProps diff --git a/src/private/New-CommentBasedHelp.ps1 b/src/private/New-CommentBasedHelp.ps1 index 9c9ad1a..adcc908 100644 --- a/src/private/New-CommentBasedHelp.ps1 +++ b/src/private/New-CommentBasedHelp.ps1 @@ -78,9 +78,9 @@ $OutCBH = @{} $OutCBH.FunctionName = $f [string]$OutParams = '' - $fparams = @($AllParams | Where {$_.FunctionName -eq $f} | Sort-Object -Property Position) + $fparams = @($AllParams | Where-Object {$_.FunctionName -eq $f} | Sort-Object -Property Position) if ($fparams.count -gt 0) { - $fparams | foreach { + $fparams | ForEach-Object { $ParamHelpMessage = if ([string]::IsNullOrEmpty($_.HelpMessage)) { $_.ParameterName + " explanation`n`r`n`r"} else {$_.HelpMessage + "`n`r`n`r"} $OutParams += $CBH_PARAM -replace '%%PARAM%%',$_.ParameterName -replace '%%PARAMHELP%%',$ParamHelpMessage diff --git a/src/public/Add-PublicFunction.ps1 b/src/public/Add-PublicFunction.ps1 index 5f24a88..a3478f8 100644 --- a/src/public/Add-PublicFunction.ps1 +++ b/src/public/Add-PublicFunction.ps1 @@ -66,7 +66,7 @@ function Add-PublicFunction { $PublicFunctionSrc = Join-Path $BuildEnvPath $BuildEnvInfo.PublicFunctionSource $TemplatePath = Join-Path $BuildEnvPath $BuildEnvInfo.FunctionTemplates $TemplateLookup = @{} - Get-ChildItem -Path $TemplatePath -Filter '*.tem' | Foreach { + Get-ChildItem -Path $TemplatePath -Filter '*.tem' | ForEach-Object { $TemplateLookup.($_.BaseName) = $_.FullName } $BuildEnvVars = (Get-Member -Type 'NoteProperty' -InputObject $LoadedBuildEnv).Name @@ -101,7 +101,7 @@ function Add-PublicFunction { $NewFunctionOutput = $TemplateData -replace '%%FunctionName%%', $FunctionName # Next replace any other variables found in our build environment file that exist in the template. - $BuildEnvVars | Foreach { + $BuildEnvVars | ForEach-Object { Write-Verbose " Replacing %%$($_)%% with $($BuildEnvInfo.$_) if found in template..." $NewFunctionOutput = $NewFunctionOutput -replace "%%$($_)%%", ($BuildEnvInfo.$_ -join ',') } From 008b23bccd5f48bedcb281c17289bcb42cadad2e Mon Sep 17 00:00:00 2001 From: justin-p Date: Fri, 11 Jan 2019 16:47:28 +0100 Subject: [PATCH 014/102] PSAvoidUsingInvokeExpression --- src/public/Initialize-ModuleBuild.ps1 | 28 +++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/public/Initialize-ModuleBuild.ps1 b/src/public/Initialize-ModuleBuild.ps1 index d35542b..9697e51 100644 --- a/src/public/Initialize-ModuleBuild.ps1 +++ b/src/public/Initialize-ModuleBuild.ps1 @@ -1,4 +1,4 @@ -function Initialize-ModuleBuild { +function Initialize-ModuleBuildTesting { <# .SYNOPSIS Set up the framework for a ModuleBuild project. @@ -47,7 +47,7 @@ function Initialize-ModuleBuild { } } process { - $CustomPlasterModulePath = Join-Path $MyModulePath 'plaster\PlasterModule\Plaster.psd1' + $CustomPlasterModulePath = 'C:\_git\github\ModuleBuild\plaster\PlasterModule\Plaster.psd1' $PostInitMessage = @' A few items to consider doing next: @@ -68,7 +68,7 @@ Enjoy! '@ if (-not [string]::IsNullOrEmpty($SourceModule)) { - if (-not [string]::IsNullOrEmpty($SourceModule)) + if (-not [string]::IsNullOrEmpty($SourceModule)) { if (-not (test-path $SourceModule) -or ((Get-Item $SourceModule).Extension -notmatch '.psd1')) { throw "$($SourceModule) was not found or is not a psd1 module manifest file!" @@ -76,7 +76,7 @@ Enjoy! Write-Verbose "$($SourceModule) Matched to .psd1 file" } } - + $ExistingModuleManifest = Test-ModuleManifest $SourceModule $PlasterParams = @{ @@ -91,12 +91,12 @@ Enjoy! } } else { $PlasterParams = @{ - TemplatePath = Join-Path $MyModulePath 'plaster\ModuleBuild\' - } + TemplatePath = 'C:\_git\github\ModuleBuild\plaster\ModuleBuild\' + } } if (-not [string]::IsNullOrEmpty($Path)) { $PlasterParams.DestinationPath = $Path - } + } if (get-module Plaster) { Write-Output 'Removing already loaded version of Plaster as we need to use our custom version instead..' @@ -114,10 +114,13 @@ Enjoy! # Get the newly created buildenvironment file and run it the first time to create the first export file. $BuildDefinition = Get-ChildItem (Join-Path $PlasterResults.DestinationPath 'build') -Filter '*.buildenvironment.ps1' - $strCommand = "powershell -noprofile -WindowStyle hidden -file '$($BuildDefinition.FullName)'" - - try { - Invoke-Expression $strCommand + powershell -noprofile -WindowStyle hidden -file $($BuildDefinition.FullName) + Try { + if ((Test-Path -Path ($BuildDefinition.FullName -replace '.ps1','.json')) -eq 'True') { + Write-Verbose 'Found JSON file.' + } Else { + Write-Error 'Could not find JSON file' -ErrorAction Stop + } } catch { throw $_ @@ -130,4 +133,5 @@ Enjoy! Remove-Module Plaster -Force } -} \ No newline at end of file +} +Initialize-ModuleBuildTesting -Path C:\temp\test \ No newline at end of file From 3492e6b3ea9b481dff007f4c8122fcf6dfc1a63e Mon Sep 17 00:00:00 2001 From: justin-p Date: Fri, 11 Jan 2019 16:56:48 +0100 Subject: [PATCH 015/102] PSUseApprovedVerbs --- .vscode/tasks.json | 6 +- Build.ps1 | 6 +- ModuleBuild.build.ps1 | 42 +++++------ build/docs/Additional/ChangeLog.md | 2 +- build/docs/Additional/Contributing.md | 4 +- docs/Contributing.md | 2 +- plaster/ModuleBuild/scaffold/Build.template | 6 +- .../build/docs/Additional/Contributing.md | 2 +- .../scaffold/modulename.build.template | 2 +- .../ModuleBuild/scaffold/vscode/tasks.json | 6 +- src/private/Insert-MissingCBH.ps1 | 72 ------------------- src/public/Import-ModulePrivateFunction.ps1 | 8 +-- src/public/Import-ModulePublicFunction.ps1 | 8 +-- 13 files changed, 48 insertions(+), 118 deletions(-) delete mode 100644 src/private/Insert-MissingCBH.ps1 diff --git a/.vscode/tasks.json b/.vscode/tasks.json index f9689b9..3a84922 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -80,13 +80,13 @@ "label": "Insert Missing Comment Based Help", "type": "shell", "windows": { - "command": "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File ${workspaceRoot}\\Build.ps1 -InsertMissingCBH" + "command": "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File ${workspaceRoot}\\Build.ps1 -AddMissingCBH" }, "linux": { - "command": "/usr/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -InsertMissingCBH" + "command": "/usr/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -AddMissingCBH" }, "osx": { - "command": "/usr/local/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -InsertMissingCBH" + "command": "/usr/local/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -AddMissingCBH" }, "group": { "kind": "build", diff --git a/Build.ps1 b/Build.ps1 index 5a466c0..a836e8d 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -12,7 +12,7 @@ param ( [parameter(Position = 5, ParameterSetName = 'Build')] [string]$ReleaseNotes, [parameter(Position = 6, ParameterSetName = 'CBH')] - [switch]$InsertCBH + [switch]$AddCBH ) function PrerequisitesLoaded { @@ -53,9 +53,9 @@ if (-not (PrerequisitesLoaded)) { switch ($psCmdlet.ParameterSetName) { 'CBH' { - if ($InsertCBH) { + if ($AddCBH) { try { - Invoke-Build -Task InsertMissingCBH + Invoke-Build -Task AddMissingCBH } catch { throw diff --git a/ModuleBuild.build.ps1 b/ModuleBuild.build.ps1 index fdf0bcc..dd9aa3f 100644 --- a/ModuleBuild.build.ps1 +++ b/ModuleBuild.build.ps1 @@ -1,3 +1,4 @@ + param ( [parameter(Position = 0)] [string]$BuildFile = @(Get-ChildItem 'build\*.buildenvironment.ps1')[0].FullName, @@ -176,12 +177,6 @@ task CodeHealthReport -if {$Script:BuildEnv.OptionCodeHealthReport} ValidateRequ } } -#Synopsis: Validate script requirements are met, load required modules, load project manifest and module, and load additional build tools. -task Configure ValidateRequirements, PreBuildTasks, LoadRequiredModules, LoadModuleManifest, LoadModule, VersionCheck, LoadBuildTools, { - # If we made it this far then we are configured! - Write-Description White 'Configuring build environment' -accent -} - # Synopsis: Set a new version of the module task NewVersion LoadBuildTools, LoadModuleManifest, { Write-Description White 'Updating module build version' -accent @@ -241,9 +236,6 @@ task UpdateRelease LoadBuildTools, LoadModuleManifest, { } } -# Synopsis: Update the current working module version and release notes -task UpdateVersion NewVersion, UpdateRelease - # Synopsis: Regenerate scratch staging directory task Clean { Write-Description White "Clean up our scratch/staging directory $($Script:BuildEnv.ScratchFolder)" -accent @@ -481,8 +473,6 @@ task AnalyzePublic { $Analysis | Format-Table -AutoSize } } -# Synopsis: Build help files for module -task CreateHelp CreateMarkdownHelp, CreateExternalHelp, CreateUpdateableHelpCAB, CreateProjectHelp, AddAdditionalDocFiles # Synopsis: Build the markdown help files with PlatyPS task CreateMarkdownHelp GetPublicFunctions, { @@ -558,11 +548,6 @@ task CreateUpdateableHelpCAB { $null = New-ExternalHelpCab -CabFilesFolder "$($StageReleasePath)\en-US\" -LandingPagePath $LandingPage -OutputFolder "$($StageReleasePath)\en-US\" @PlatyPSVerbose } -# Synopsis: Build help files for module and ignore missing section errors -task TestCreateHelp Configure, CreateMarkdownHelp, CreateExternalHelp, CreateUpdateableHelpCAB, { - Write-Description White 'Create help files' -accent -} - # Synopsis: Create a new version release directory for our release and copy our contents to it task PushVersionRelease { Write-Description White "Attempting to push a version release of the module" -accent @@ -709,9 +694,6 @@ task CreateReadTheDocsYML -if {$Script:BuildEnv.OptionGenerateReadTheDocs} Confi } } -# Synopsis: Put together all the various projecet help files -task CreateProjectHelp BuildProjectHelpFiles, AddAdditionalDocFiles, UpdateReadTheDocs, CreateReadTheDocsYML - # Synopsis: Push the current release of the project to PSScriptGallery task PublishPSGallery LoadBuildTools, InstallModule, { Write-Description White 'Publishing recent module release to the PowerShell Gallery' -accent @@ -871,6 +853,26 @@ task GithubPush VersionCheck, { assert (-not $changes) "Please, commit changes." } +#Synopsis: Validate script requirements are met, load required modules, load project manifest and module, and load additional build tools. +task Configure ValidateRequirements, PreBuildTasks, LoadRequiredModules, LoadModuleManifest, LoadModule, VersionCheck, LoadBuildTools, { + # If we made it this far then we are configured! + Write-Description White 'Configuring build environment' -accent +} + +# Synopsis: Build help files for module and ignore missing section errors +task TestCreateHelp Configure, CreateMarkdownHelp, CreateExternalHelp, CreateUpdateableHelpCAB, { + Write-Description White 'Create help files' -accent +} + +# Synopsis: Update the current working module version and release notes +task UpdateVersion NewVersion, UpdateRelease + +# Synopsis: Put together all the various projecet help files +task CreateProjectHelp BuildProjectHelpFiles, AddAdditionalDocFiles, UpdateReadTheDocs, CreateReadTheDocsYML + +# Synopsis: Build help files for module +task CreateHelp CreateMarkdownHelp, CreateExternalHelp, CreateUpdateableHelpCAB, CreateProjectHelp, AddAdditionalDocFiles + # Synopsis: Build the module task . Configure, CodeHealthReport, Clean, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, PostBuildTasks, BuildSessionCleanup @@ -884,4 +886,4 @@ task BuildInstallAndTestModule Configure, CodeHealthReport, Clean, PrepareStage, task BuildInstallTestAndPublishModule Configure, CodeHealthReport, Clean, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, InstallModule, TestInstalledModule, PublishPSGallery, PostBuildTasks, BuildSessionCleanup # Synopsis: Instert Comment Based Help where it doesn't already exist (output to scratch directory) -task InsertMissingCBH Configure, Clean, UpdateCBHtoScratch, BuildSessionCleanup \ No newline at end of file +task AddMissingCBH Configure, Clean, UpdateCBHtoScratch, BuildSessionCleanup \ No newline at end of file diff --git a/build/docs/Additional/ChangeLog.md b/build/docs/Additional/ChangeLog.md index bfdc27c..c932196 100644 --- a/build/docs/Additional/ChangeLog.md +++ b/build/docs/Additional/ChangeLog.md @@ -19,7 +19,7 @@ Project Site: [https://github.com/zloeber/ModuleBuild](https://github.com/zloebe - Fixed improper spelling of 'license' in license creation templating. ## Version 0.1.10 -- Fixed the -InsertCBH build task. +- Fixed the -AddCBH build task. - Fixed the missing documentation platyps output to show the actual found line that indicates missing CBH. ## Version 0.1.9 diff --git a/build/docs/Additional/Contributing.md b/build/docs/Additional/Contributing.md index 93d7595..c68e4ca 100644 --- a/build/docs/Additional/Contributing.md +++ b/build/docs/Additional/Contributing.md @@ -10,12 +10,12 @@ All base project documentation changes should be made against the .\build\docs\A Finally, the Function documentation gets generated automatically based on the comment based help on each public/exported function. The function documentation markdown automatically gets populated within the .\docs\Functions folder as well as with the module release under its own docs folder. Private function CBH is not required but is encouraged. ## Development Environment -While any text editor will work well there are included task and setting json files explicitly for Visual Studio Code included with this project. I used VS Code Insiders edition but standard edition should be fine as ewll. The following tasks have been defined to make things a bit easier. First access the 'Pallette' (Shift+Ctrl+P or Shift+Cmd+P) and start typing in any of the following tasks to find and run them: +While any text editor will work well there are included task and setting json files explicitly for Visual Studio Code included with this project. I used VS Code Insiders edition but standard edition should be fine as well. The following tasks have been defined to make things a bit easier. First access the 'Pallette' (Shift+Ctrl+P or Shift+Cmd+P) and start typing in any of the following tasks to find and run them: - Build -> Runs the Build task (also can use Shift+Ctrl+B or Shift+Cmd+B) - Analyze -> Runs PSScriptAnalyzer against the src/public files. - CreateProjectHelp - Creates the project level help. -- InsertMissingCBH - Analyzes the existing public functions and inserts a template CBH if no CBH already exists and saves it into your scratch folder. +- AddMissingCBH - Analyzes the existing public functions and inserts a template CBH if no CBH already exists and saves it into your scratch folder. The plaster manifest file gets automatically recreated at build time so all you need to do is update the plasterparams.ps1 and/or plastercontent.ps1 in the plaster directory to include any required changes you need to make. diff --git a/docs/Contributing.md b/docs/Contributing.md index 93d7595..99240bf 100644 --- a/docs/Contributing.md +++ b/docs/Contributing.md @@ -15,7 +15,7 @@ While any text editor will work well there are included task and setting json fi - Build -> Runs the Build task (also can use Shift+Ctrl+B or Shift+Cmd+B) - Analyze -> Runs PSScriptAnalyzer against the src/public files. - CreateProjectHelp - Creates the project level help. -- InsertMissingCBH - Analyzes the existing public functions and inserts a template CBH if no CBH already exists and saves it into your scratch folder. +- AddMissingCBH - Analyzes the existing public functions and inserts a template CBH if no CBH already exists and saves it into your scratch folder. The plaster manifest file gets automatically recreated at build time so all you need to do is update the plasterparams.ps1 and/or plastercontent.ps1 in the plaster directory to include any required changes you need to make. diff --git a/plaster/ModuleBuild/scaffold/Build.template b/plaster/ModuleBuild/scaffold/Build.template index 5a466c0..a836e8d 100644 --- a/plaster/ModuleBuild/scaffold/Build.template +++ b/plaster/ModuleBuild/scaffold/Build.template @@ -12,7 +12,7 @@ param ( [parameter(Position = 5, ParameterSetName = 'Build')] [string]$ReleaseNotes, [parameter(Position = 6, ParameterSetName = 'CBH')] - [switch]$InsertCBH + [switch]$AddCBH ) function PrerequisitesLoaded { @@ -53,9 +53,9 @@ if (-not (PrerequisitesLoaded)) { switch ($psCmdlet.ParameterSetName) { 'CBH' { - if ($InsertCBH) { + if ($AddCBH) { try { - Invoke-Build -Task InsertMissingCBH + Invoke-Build -Task AddMissingCBH } catch { throw diff --git a/plaster/ModuleBuild/scaffold/build/docs/Additional/Contributing.md b/plaster/ModuleBuild/scaffold/build/docs/Additional/Contributing.md index e5b285a..446d166 100644 --- a/plaster/ModuleBuild/scaffold/build/docs/Additional/Contributing.md +++ b/plaster/ModuleBuild/scaffold/build/docs/Additional/Contributing.md @@ -17,4 +17,4 @@ While any text editor will work well there are included task and setting json fi - Analyze -> Runs PSScriptAnalyzer against the src/public files. - CreateProjectHelp - Creates the project level help. - Test - Runs Pester tests. -- InsertMissingCBH - Analyzes the existing public functions and inserts a template CBH if no CBH already exists and saves it into your scratch folder. \ No newline at end of file +- AddMissingCBH - Analyzes the existing public functions and inserts a template CBH if no CBH already exists and saves it into your scratch folder. \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/modulename.build.template b/plaster/ModuleBuild/scaffold/modulename.build.template index 78693e6..9fc4f77 100644 --- a/plaster/ModuleBuild/scaffold/modulename.build.template +++ b/plaster/ModuleBuild/scaffold/modulename.build.template @@ -887,4 +887,4 @@ task BuildInstallAndTestModule Configure, CodeHealthReport, Clean, PrepareStage, task BuildInstallTestAndPublishModule Configure, CodeHealthReport, Clean, PrepareStage, GetPublicFunctions, SanitizeCode, CreateHelp, CreateModulePSM1, CreateModuleManifest, AnalyzeModuleRelease, PushVersionRelease, PushCurrentRelease, CreateProjectHelp, InstallModule, TestInstalledModule, PublishPSGallery, PostBuildTasks, BuildSessionCleanup # Synopsis: Instert Comment Based Help where it doesn't already exist (output to scratch directory) -task InsertMissingCBH Configure, Clean, UpdateCBHtoScratch, BuildSessionCleanup \ No newline at end of file +task AddMissingCBH Configure, Clean, UpdateCBHtoScratch, BuildSessionCleanup \ No newline at end of file diff --git a/plaster/ModuleBuild/scaffold/vscode/tasks.json b/plaster/ModuleBuild/scaffold/vscode/tasks.json index f70a8df..1b0be5b 100644 --- a/plaster/ModuleBuild/scaffold/vscode/tasks.json +++ b/plaster/ModuleBuild/scaffold/vscode/tasks.json @@ -78,13 +78,13 @@ "label": "Insert Missing Comment Based Help", "type": "shell", "windows": { - "command": "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File ${workspaceRoot}\\Build.ps1 -InsertMissingCBH" + "command": "powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File ${workspaceRoot}\\Build.ps1 -AddMissingCBH" }, "linux": { - "command": "/usr/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -InsertMissingCBH" + "command": "/usr/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -AddMissingCBH" }, "osx": { - "command": "/usr/local/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -InsertMissingCBH" + "command": "/usr/local/bin/powershell -NoProfile -File ${workspaceRoot}\\Build.ps1 -AddMissingCBH" }, "group": { "kind": "build", diff --git a/src/private/Insert-MissingCBH.ps1 b/src/private/Insert-MissingCBH.ps1 deleted file mode 100644 index 440e24b..0000000 --- a/src/private/Insert-MissingCBH.ps1 +++ /dev/null @@ -1,72 +0,0 @@ -Function Insert-MissingCBH { - <# - .SYNOPSIS - Create comment based help for a function. - .DESCRIPTION - Create comment based help for a function. - .PARAMETER Code - Multi-line or piped lines of code to process. - .EXAMPLE - PS > $test = Get-Content 'C:\temp\test.ps1' -raw - PS > $test | Insert-MissingCBH | clip - - Takes C:\temp\test.ps1 as input, creates basic comment based help and puts the result in the clipboard - to be pasted elsewhere for review. - .NOTES - Author: Zachary Loeber - Site: http://www.the-little-things.net/ - Requires: Powershell 3.0 - - Version History - 1.0.0 - Initial release - 1.0.1 - Updated for ModuleBuild - #> - [CmdletBinding()] - param( - [parameter(Position=0, ValueFromPipeline=$true, HelpMessage='Lines of code to process.')] - [string[]]$Code - ) - - begin { - # CBH pattern that tells us CBH likely already exists - $CBHPattern = "(?ms)(^\s*\<#.*[\.SYNOPSIS|\.DESCRIPTION|\.PARAMETER|\.EXAMPLE|\.NOTES|\.LINK].*?#>)" - $Codeblock = @() - } - process { - $Codeblock += $Code - } - end { - $ScriptText = ($Codeblock | Out-String).trim("`r`n") - # If no sign of CBH exists then try to generate and insert it - if ($ScriptText -notmatch $CBHPattern) { - $CBH = @($ScriptText | New-CommentBasedHelp) - - if ($CBH.Count -gt 1) { - throw 'Too many functions are defined in the input string!' - } - - if ($CBH.Count -ne 0) { - try { - $currscriptblock = [scriptblock]::Create($ScriptText) - . $currscriptblock - $currfunct = get-command $CBH.FunctionName - } - catch { - throw $_ - } - - $UpdatedFunct = 'Function ' + $currfunct.Name + ' {' + "`r`n" + $CBH.CBH + "`r`n" + $currfunct.definition + "`r`n" + '}' - - $UpdatedFunct - } - else { - Write-Warning 'Unable to generate CBH for the script text!' - $ScriptText - } - } - else { - Write-Verbose "Comment based help already exists - skipping CBH insertion and returning original script." - $ScriptText - } - } -} \ No newline at end of file diff --git a/src/public/Import-ModulePrivateFunction.ps1 b/src/public/Import-ModulePrivateFunction.ps1 index 878bd8c..74519ce 100644 --- a/src/public/Import-ModulePrivateFunction.ps1 +++ b/src/public/Import-ModulePrivateFunction.ps1 @@ -15,7 +15,7 @@ function Import-ModulePrivateFunction { .PARAMETER Name Function name to import. If none are specified then all functions will be imported. - .PARAMETER DoNotInsertCBH + .PARAMETER DoNotAddCBH Do not attempt to find and insert comment based help into the function. Default for private functions is to skip CBH insertion. .PARAMETER ExcludePaths @@ -45,7 +45,7 @@ function Import-ModulePrivateFunction { [parameter(Position = 2)] [String]$Name = '*', [parameter(Position = 3)] - [Switch]$DoNotInsertCBH = $true, + [Switch]$DoNotAddCBH = $true, [parameter(Position = 4)] [string[]]$ExcludePaths = @('temp','build','.git','.vscode','docs','release','plaster'), [parameter(Position = 5)] @@ -127,13 +127,13 @@ function Import-ModulePrivateFunction { # Only attempt to copy over new function files, skip if the name already exists in the destination path if (-not (Test-Path $DestPath)) { if ($pscmdlet.ShouldProcess("$($PrivFunc.Name) from file $($PrivFunc.SourcePath)", "Import private function $($PrivFunc.Name) to the project $($LoadedBuildEnv.ModuleToBuild)?")) { - if ($DoNotInsertCBH) { + if ($DoNotAddCBH) { # Skipping comment based help insertion $PrivFunc.definition | Out-File -FilePath $DestPath -Encoding:utf8 -Confirm:$false } else { # inserting comment based help if it doesn't already exist. - $PrivFunc.definition | Insert-MissingCBH | Out-File -FilePath $DestPath -Encoding:utf8 -Confirm:$false + $PrivFunc.definition | Add-MissingCBH | Out-File -FilePath $DestPath -Encoding:utf8 -Confirm:$false } } } diff --git a/src/public/Import-ModulePublicFunction.ps1 b/src/public/Import-ModulePublicFunction.ps1 index 3cef6e5..c2789d5 100644 --- a/src/public/Import-ModulePublicFunction.ps1 +++ b/src/public/Import-ModulePublicFunction.ps1 @@ -15,7 +15,7 @@ function Import-ModulePublicFunction { .PARAMETER Name Function name to import. If none are specified then all functions will be imported. - .PARAMETER DoNotInsertCBH + .PARAMETER DoNotAddCBH Do not attempt to find and insert comment based help into the function. .LINK @@ -39,7 +39,7 @@ function Import-ModulePublicFunction { [parameter(Position = 2)] [String]$Name = '*', [parameter(Position = 3)] - [Switch]$DoNotInsertCBH + [Switch]$DoNotAddCBH ) begin { if ($script:ThisModuleLoaded -eq $true) { @@ -89,7 +89,7 @@ function Import-ModulePublicFunction { $NewScript += '}' if ($pscmdlet.ShouldProcess("$($LoadedFunction.Name)", "Import public function $($LoadedFunction.Name) to the project $($LoadedBuildEnv.ModuleToBuild)?")) { - if ($DoNotInsertCBH) { + if ($DoNotAddCBH) { try { Write-Verbose "Writing public script file to $NewScriptFile" $NewScript | Out-File -FilePath $NewScriptFile -Encoding:utf8 -Confirm:$false @@ -100,7 +100,7 @@ function Import-ModulePublicFunction { } else { try { - $NewScript | Insert-MissingCBH | Out-File -FilePath $NewScriptFile -Encoding:utf8 -Confirm:$false + $NewScript | Add-MissingCBH | Out-File -FilePath $NewScriptFile -Encoding:utf8 -Confirm:$false } catch { throw $_ From 031b214b14c733da7c2a8b2f8391306d74ef4d3c Mon Sep 17 00:00:00 2001 From: justin-p Date: Fri, 11 Jan 2019 16:57:26 +0100 Subject: [PATCH 016/102] PSUseApprovedVerbs --- src/private/Add-MissingCBH.ps1 | 72 ++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/private/Add-MissingCBH.ps1 diff --git a/src/private/Add-MissingCBH.ps1 b/src/private/Add-MissingCBH.ps1 new file mode 100644 index 0000000..842c071 --- /dev/null +++ b/src/private/Add-MissingCBH.ps1 @@ -0,0 +1,72 @@ +Function Add-MissingCBH { + <# + .SYNOPSIS + Create comment based help for a function. + .DESCRIPTION + Create comment based help for a function. + .PARAMETER Code + Multi-line or piped lines of code to process. + .EXAMPLE + PS > $test = Get-Content 'C:\temp\test.ps1' -raw + PS > $test | Add-MissingCBH | clip + + Takes C:\temp\test.ps1 as input, creates basic comment based help and puts the result in the clipboard + to be pasted elsewhere for review. + .NOTES + Author: Zachary Loeber + Site: http://www.the-little-things.net/ + Requires: Powershell 3.0 + + Version History + 1.0.0 - Initial release + 1.0.1 - Updated for ModuleBuild + #> + [CmdletBinding()] + param( + [parameter(Position=0, ValueFromPipeline=$true, HelpMessage='Lines of code to process.')] + [string[]]$Code + ) + + begin { + # CBH pattern that tells us CBH likely already exists + $CBHPattern = "(?ms)(^\s*\<#.*[\.SYNOPSIS|\.DESCRIPTION|\.PARAMETER|\.EXAMPLE|\.NOTES|\.LINK].*?#>)" + $Codeblock = @() + } + process { + $Codeblock += $Code + } + end { + $ScriptText = ($Codeblock | Out-String).trim("`r`n") + # If no sign of CBH exists then try to generate and insert it + if ($ScriptText -notmatch $CBHPattern) { + $CBH = @($ScriptText | New-CommentBasedHelp) + + if ($CBH.Count -gt 1) { + throw 'Too many functions are defined in the input string!' + } + + if ($CBH.Count -ne 0) { + try { + $currscriptblock = [scriptblock]::Create($ScriptText) + . $currscriptblock + $currfunct = get-command $CBH.FunctionName + } + catch { + throw $_ + } + + $UpdatedFunct = 'Function ' + $currfunct.Name + ' {' + "`r`n" + $CBH.CBH + "`r`n" + $currfunct.definition + "`r`n" + '}' + + $UpdatedFunct + } + else { + Write-Warning 'Unable to generate CBH for the script text!' + $ScriptText + } + } + else { + Write-Verbose "Comment based help already exists - skipping CBH insertion and returning original script." + $ScriptText + } + } +} \ No newline at end of file From 20234a152b962ac5c9b17b8104db315a5d659661 Mon Sep 17 00:00:00 2001 From: justin-p Date: Fri, 11 Jan 2019 17:14:38 +0100 Subject: [PATCH 017/102] bugfix introduced in 008b23b --- src/public/Initialize-ModuleBuild.ps1 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/public/Initialize-ModuleBuild.ps1 b/src/public/Initialize-ModuleBuild.ps1 index 9697e51..73e6243 100644 --- a/src/public/Initialize-ModuleBuild.ps1 +++ b/src/public/Initialize-ModuleBuild.ps1 @@ -1,4 +1,4 @@ -function Initialize-ModuleBuildTesting { +function Initialize-ModuleBuild { <# .SYNOPSIS Set up the framework for a ModuleBuild project. @@ -47,7 +47,7 @@ function Initialize-ModuleBuildTesting { } } process { - $CustomPlasterModulePath = 'C:\_git\github\ModuleBuild\plaster\PlasterModule\Plaster.psd1' + $CustomPlasterModulePath = Join-Path $MyModulePath 'plaster\PlasterModule\Plaster.psd1' $PostInitMessage = @' A few items to consider doing next: @@ -91,7 +91,7 @@ Enjoy! } } else { $PlasterParams = @{ - TemplatePath = 'C:\_git\github\ModuleBuild\plaster\ModuleBuild\' + TemplatePath = Join-Path $MyModulePath 'plaster\ModuleBuild\' } } if (-not [string]::IsNullOrEmpty($Path)) { @@ -133,5 +133,4 @@ Enjoy! Remove-Module Plaster -Force } -} -Initialize-ModuleBuildTesting -Path C:\temp\test \ No newline at end of file +} \ No newline at end of file From 93d9cdf8515a23f97104e8190aae699b11c5d3dc Mon Sep 17 00:00:00 2001 From: justin-p Date: Fri, 11 Jan 2019 17:17:20 +0100 Subject: [PATCH 018/102] PSAvoidUsingCmdletAliases --- src/private/New-CommentBasedHelp.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/private/New-CommentBasedHelp.ps1 b/src/private/New-CommentBasedHelp.ps1 index adcc908..94a9a23 100644 --- a/src/private/New-CommentBasedHelp.ps1 +++ b/src/private/New-CommentBasedHelp.ps1 @@ -72,7 +72,7 @@ $FuncParams.ScriptParameters = $true } $AllParams = Get-FunctionParameter @FuncParams -Code $Codeblock | Sort-Object -Property FunctionName - $AllFunctions = @($AllParams.FunctionName | Select -unique) + $AllFunctions = @($AllParams.FunctionName | Select-Object -unique) foreach ($f in $AllFunctions) { $OutCBH = @{} From f6ac7a482ae80416946c28d4a51ab314fbe2a383 Mon Sep 17 00:00:00 2001 From: justin-p Date: Fri, 11 Jan 2019 17:19:51 +0100 Subject: [PATCH 019/102] PSUseSingularNouns --- src/private/Get-CommonParameters.ps1 | 2 +- src/private/Get-Function.ps1 | 2 +- src/private/Get-FunctionParameter.ps1 | 2 +- src/private/Get-ParentASTTypes.ps1 | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/private/Get-CommonParameters.ps1 b/src/private/Get-CommonParameters.ps1 index a01dec6..9881ef5 100644 --- a/src/private/Get-CommonParameters.ps1 +++ b/src/private/Get-CommonParameters.ps1 @@ -1,4 +1,4 @@ -function Get-CommonParameters { +function Get-CommonParameter { # Helper function to get all the automatically added parameters in an # advanced function function somefunct { diff --git a/src/private/Get-Function.ps1 b/src/private/Get-Function.ps1 index 2651afb..ee9016c 100644 --- a/src/private/Get-Function.ps1 +++ b/src/private/Get-Function.ps1 @@ -64,7 +64,7 @@ function Get-Function { AST = $Block } - if (@(Get-ParentASTTypes $Block) -contains 'FunctionDefinitionAst') { + if (@(Get-ParentASTType $Block) -contains 'FunctionDefinitionAst') { $FunctionProps.IsEmbedded = $true } diff --git a/src/private/Get-FunctionParameter.ps1 b/src/private/Get-FunctionParameter.ps1 index c9d7875..7dfa349 100644 --- a/src/private/Get-FunctionParameter.ps1 +++ b/src/private/Get-FunctionParameter.ps1 @@ -62,7 +62,7 @@ function Get-FunctionParameter { } process { $Codeblock += $Code - $CommonParams = Get-CommonParameters + $CommonParams = Get-CommonParameter } end { $ScriptText = ($Codeblock | Out-String).trim("`r`n") diff --git a/src/private/Get-ParentASTTypes.ps1 b/src/private/Get-ParentASTTypes.ps1 index f0e35e6..81be317 100644 --- a/src/private/Get-ParentASTTypes.ps1 +++ b/src/private/Get-ParentASTTypes.ps1 @@ -1,13 +1,13 @@ -function Get-ParentASTTypes { +function Get-ParentASTType { <# .SYNOPSIS Retrieves all parent types of a given AST element. .DESCRIPTION - + .PARAMETER Code Multiline or piped lines of code to process. .EXAMPLE - + Description ----------- From 9498936e1b6f17c5c5ca111438af8234d28b5127 Mon Sep 17 00:00:00 2001 From: justin-p Date: Fri, 11 Jan 2019 17:49:49 +0100 Subject: [PATCH 020/102] PSUseDeclaredVarsMoreThanAssignments supress --- src/other/PreLoad.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/other/PreLoad.ps1 b/src/other/PreLoad.ps1 index 1058703..2e8b367 100644 --- a/src/other/PreLoad.ps1 +++ b/src/other/PreLoad.ps1 @@ -1 +1,8 @@ +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "ModuleBuildLoggingEnabled")] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "BuildPath")] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "functionpredicate")] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "CommonParams")] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "ScriptText")] +param() + $ModuleBuildLoggingEnabled = $false # Set to true to enable nlog-based logging \ No newline at end of file From 56eb0a97251e043d731dfa5c2688e22e3d3cf4b4 Mon Sep 17 00:00:00 2001 From: justin-p Date: Mon, 14 Jan 2019 10:55:57 +0100 Subject: [PATCH 021/102] Script Analyzer fixes --- src/other/PreLoad.ps1 | 9 +++---- src/private/Get-BuildFilePath.ps1 | 1 + src/private/Get-CommonParameters.ps1 | 1 + src/private/Get-FunctionParameter.ps1 | 3 +++ src/private/New-CommentBasedHelp.ps1 | 3 +++ src/private/New-DynamicParameter.ps1 | 1 + src/public/Import-ModulePrivateFunction.ps1 | 2 +- src/public/Set-BuildEnvironment.ps1 | 28 +++++++++++---------- 8 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/other/PreLoad.ps1 b/src/other/PreLoad.ps1 index 2e8b367..717ff12 100644 --- a/src/other/PreLoad.ps1 +++ b/src/other/PreLoad.ps1 @@ -1,8 +1,5 @@ -[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "ModuleBuildLoggingEnabled")] -[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "BuildPath")] -[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "functionpredicate")] -[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "CommonParams")] -[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "ScriptText")] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "ModuleBuildLoggingEnabled",Justification="ModuleBuildLoggingEnabled is optional. It's used to enable Nlog-based logging.")] param() -$ModuleBuildLoggingEnabled = $false # Set to true to enable nlog-based logging \ No newline at end of file +$ModuleBuildLoggingEnabled = $false # Set to true to enable nlog-based logging + diff --git a/src/private/Get-BuildFilePath.ps1 b/src/private/Get-BuildFilePath.ps1 index 0814360..5c3cb06 100644 --- a/src/private/Get-BuildFilePath.ps1 +++ b/src/private/Get-BuildFilePath.ps1 @@ -1,3 +1,4 @@ function Get-BuildFilePath { $BuildPath = (Get-ChildItem -File -Filter "*.buildenvironment.json" -Path '.\','..\','.\build\' -ErrorAction:SilentlyContinue | Select-Object -First 1).FullName + Return $BuildPath } \ No newline at end of file diff --git a/src/private/Get-CommonParameters.ps1 b/src/private/Get-CommonParameters.ps1 index 9881ef5..20cb104 100644 --- a/src/private/Get-CommonParameters.ps1 +++ b/src/private/Get-CommonParameters.ps1 @@ -3,6 +3,7 @@ function Get-CommonParameter { # advanced function function somefunct { [CmdletBinding(SupportsShouldProcess = $true, SupportsPaging = $true, SupportsTransactions = $true)] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Scope="Function", Target="somefunct",Justification="This is a dummy function in order to get all CommonParameters without hardcoding them. There is no reason for it to actually use SupportsShouldProcess.")] param() } diff --git a/src/private/Get-FunctionParameter.ps1 b/src/private/Get-FunctionParameter.ps1 index 7dfa349..2f12fbc 100644 --- a/src/private/Get-FunctionParameter.ps1 +++ b/src/private/Get-FunctionParameter.ps1 @@ -30,7 +30,10 @@ function Get-FunctionParameter { 1.0.1 - Updated function name to remove plural format Added Name parameter and logic for getting script parameters if no function is defined. Added ScriptParameters parameter to include parameters for a script (not just ones associated with defined functions) + 1.0.2 - Added SuppressMessageAttribute for functionpredicate #> + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments","functionpredicate",Scope="Function",Target='Get-FunctionParameter',Justification="Unused AST filter")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments","CommonParams",Scope="Function",Target='Get-FunctionParameter',Justification="")] [CmdletBinding()] param( [parameter(ValueFromPipeline=$true, HelpMessage='Lines of code to process.')] diff --git a/src/private/New-CommentBasedHelp.ps1 b/src/private/New-CommentBasedHelp.ps1 index 94a9a23..38542d9 100644 --- a/src/private/New-CommentBasedHelp.ps1 +++ b/src/private/New-CommentBasedHelp.ps1 @@ -29,7 +29,10 @@ Version History 1.0.0 - Initial release 1.0.1 - Updated for ModuleBuild + 1.0.2 - Added SuppressMessageAttribute #> + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "ScriptText",Scope="Function",Target="New-CommentBasedHelp",Justification="Seems it's here since duo a copy paste from other functions (Add-MissingCBH,Get-Function,Get-FunctionParameter). Leaving it here since it doesn't do any harm.")] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions","",Scope="Function",Target="New-CommentBasedHelp",Justification="Function does not change system state. Simply outputs a obj with CommentBasedHelp.")] [CmdletBinding()] param( [parameter(Position=0, ValueFromPipeline=$true, HelpMessage='Lines of code to process.')] diff --git a/src/private/New-DynamicParameter.ps1 b/src/private/New-DynamicParameter.ps1 index 017ed78..cab1da1 100644 --- a/src/private/New-DynamicParameter.ps1 +++ b/src/private/New-DynamicParameter.ps1 @@ -415,6 +415,7 @@ function New-DynamicParameter { } } #> + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions","",Scope="Function",Target="New-DynamicParameter",Justification="Function does not change system state.")] [CmdletBinding(PositionalBinding = $false, DefaultParameterSetName = 'DynamicParameter')] Param ( diff --git a/src/public/Import-ModulePrivateFunction.ps1 b/src/public/Import-ModulePrivateFunction.ps1 index 74519ce..0d09276 100644 --- a/src/public/Import-ModulePrivateFunction.ps1 +++ b/src/public/Import-ModulePrivateFunction.ps1 @@ -35,7 +35,7 @@ function Import-ModulePrivateFunction { .NOTES This only applies to modules of the type 'Script'. Be very careful before importing everything as any wayward functions might get imported and bloat your resulting module needlessly. #> - + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidDefaultValueSwitchParameter", "",Scope="function",Target="Import-ModulePrivateFunction",Justification="Not adding CBH by default is actually useful.")] [CmdletBinding( SupportsShouldProcess = $True, ConfirmImpact = 'High' )] param( [parameter(Position = 0, ValueFromPipeline = $TRUE)] diff --git a/src/public/Set-BuildEnvironment.ps1 b/src/public/Set-BuildEnvironment.ps1 index 4acec4f..94e0cd9 100644 --- a/src/public/Set-BuildEnvironment.ps1 +++ b/src/public/Set-BuildEnvironment.ps1 @@ -17,7 +17,7 @@ function Set-BuildEnvironment { Set-BuildEnvironment -OptionSensitiveTerms @('myapikey','myname','password') #> - [CmdletBinding()] + [CmdletBinding(SupportsShouldProcess=$True)] param( [parameter(Position = 0, ValueFromPipeline = $TRUE)] [String]$Path @@ -50,7 +50,7 @@ function Set-BuildEnvironment { } } catch { - #throw "Unable to load the build file in $BuildPath" + throw "Unable to load the build file in $BuildPath" } } @@ -75,18 +75,20 @@ function Set-BuildEnvironment { New-DynamicParameter -CreateVariables -BoundParameters $PSBoundParameters if ((Test-Path $BuildPath) -and ($BuildPath -like "*.buildenvironment.json")) { - try { - $LoadedBuildEnv = Get-BuildEnvironment -Path $BuildPath - Foreach ($ParamKey in ($PSBoundParameters.Keys | Where-Object {$_ -ne 'Path'})) { - $LoadedBuildEnv.$ParamKey = $PSBoundParameters[$ParamKey] - Write-Output "Updating $ParamKey to be $($PSBoundParameters[$ParamKey])" + If ($PSCmdlet.ShouldProcess("Updating buildenvironment.json")) { + try { + $LoadedBuildEnv = Get-BuildEnvironment -Path $BuildPath + Foreach ($ParamKey in ($PSBoundParameters.Keys | Where-Object {$_ -ne 'Path'})) { + $LoadedBuildEnv.$ParamKey = $PSBoundParameters[$ParamKey] + Write-Output "Updating $ParamKey to be $($PSBoundParameters[$ParamKey])" + } + $LoadedBuildEnv.PSObject.Properties.remove('Path') + $LoadedBuildEnv | ConvertTo-Json | Out-File -FilePath $BuildPath -Encoding:utf8 -Force + Write-Output "Saved configuration file - $BuildPath" + } + catch { + throw "Unable to load the build file in $BuildPath" } - $LoadedBuildEnv.PSObject.Properties.remove('Path') - $LoadedBuildEnv | ConvertTo-Json | Out-File -FilePath $BuildPath -Encoding:utf8 -Force - Write-Output "Saved configuration file - $BuildPath" - } - catch { - throw "Unable to load the build file in $BuildPath" } } else { From e9fbae43b2fa4b888bbc8df88ae3b0e067874f94 Mon Sep 17 00:00:00 2001 From: justin-p Date: Mon, 14 Jan 2019 16:30:25 +0100 Subject: [PATCH 022/102] Fix for AddCBH when no params are added to function. New displays verbose messages and throws error pointing to CBH. --- .../scaffold/modulename.build.template | 26 +++++++------ src/private/Get-FunctionParameter.ps1 | 37 +++++++++++-------- src/private/New-CommentBasedHelp.ps1 | 36 ++++++++++-------- 3 files changed, 56 insertions(+), 43 deletions(-) diff --git a/plaster/ModuleBuild/scaffold/modulename.build.template b/plaster/ModuleBuild/scaffold/modulename.build.template index 9fc4f77..6827468 100644 --- a/plaster/ModuleBuild/scaffold/modulename.build.template +++ b/plaster/ModuleBuild/scaffold/modulename.build.template @@ -296,19 +296,21 @@ task UpdateCBHtoScratch { $CBH = $currscript | New-CommentBasedHelp $currscriptblock = [scriptblock]::Create($currscript) . $currscriptblock - $currfunct = get-command $CBH.FunctionName - - - if ($currfunct.definition -notmatch $CBHPattern) { - $CBHUpdates++ - Write-Description White "Inserting template CBH and writing to : $($Script:BuildEnv.ScratchFolder)\$($Script:BuildEnv.PublicFunctionSource)\$($FileName)" -Level 3 - $UpdatedFunct = 'Function ' + $currfunct.Name + ' {' + "`r`n" + $CBH.CBH + "`r`n" + $currfunct.definition + "`r`n" + '}' - $UpdatedFunct | Out-File "$($ScratchPath)\$($Script:BuildEnv.PublicFunctionSource)\$($FileName)" -Encoding $Script:BuildEnv.Encoding -force - } - else { - Write-Description Yellow 'Comment based help already exists!' -Level 2 + if([string]::IsNullOrEmpty($CBH)) + { + Write-Error "Could not Add CBH, possibly duo having no parameters in $filename" -ErrorAction Stop + } else { + $currfunct = get-command $CBH.FunctionName + if ($currfunct.definition -notmatch $CBHPattern) { + $CBHUpdates++ + Write-Description White "Inserting template CBH and writing to : $($Script:BuildEnv.ScratchFolder)\$($Script:BuildEnv.PublicFunctionSource)\$($FileName)" -Level 3 + $UpdatedFunct = 'Function ' + $currfunct.Name + ' {' + "`r`n" + $CBH.CBH + "`r`n" + $currfunct.definition + "`r`n" + '}' + $UpdatedFunct | Out-File "$($ScratchPath)\$($Script:BuildEnv.PublicFunctionSource)\$($FileName)" -Encoding $Script:BuildEnv.Encoding -force + } + else { + Write-Description Yellow 'Comment based help already exists!' -Level 2 + } } - Remove-Item Function:\$($currfunct.Name) } Write-Build White '' diff --git a/src/private/Get-FunctionParameter.ps1 b/src/private/Get-FunctionParameter.ps1 index 2f12fbc..13df5c0 100644 --- a/src/private/Get-FunctionParameter.ps1 +++ b/src/private/Get-FunctionParameter.ps1 @@ -83,23 +83,28 @@ function Get-FunctionParameter { Write-Verbose "$($FunctionName): Not including embedded functions." $functions = $functions | Where-Object {-not $_.IsEmbedded} } - - Foreach ($f in $functions) { - $function = $f.ast - $Parameters = $function.FindAll($parampredicate, $true) - foreach ($p in $Parameters) { - $ParamType = $p.FindAll($typepredicate, $true) - Write-Verbose "$($FunctionName): Processing Parameter of type [$($ParamType.typeName.FullName)] - $($p.Name.VariablePath.ToString())" - $OutProps = @{ - 'FunctionName' = $function.Name.ToString() - 'ParameterName' = $p.Name.VariablePath.ToString() - 'ParameterType' = $ParamType[0].typeName.FullName - } - # This will add in any other parameter attributes if they are specified (default attributes are thus not included and output may not be normalized) - $p.FindAll($paramattributes, $true) | ForEach-Object { - $OutProps.($_.ArgumentName) = $_.Argument.Value + If([string]::IsNullOrEmpty($functions)) + { + Write-Verbose "$($FunctionName): There were no script parameters found" + } else + { + Foreach ($f in $functions) { + $function = $f.ast + $Parameters = $function.FindAll($parampredicate, $true) + foreach ($p in $Parameters) { + $ParamType = $p.FindAll($typepredicate, $true) + Write-Verbose "$($FunctionName): Processing Parameter of type [$($ParamType.typeName.FullName)] - $($p.Name.VariablePath.ToString())" + $OutProps = @{ + 'FunctionName' = $function.Name.ToString() + 'ParameterName' = $p.Name.VariablePath.ToString() + 'ParameterType' = $ParamType[0].typeName.FullName + } + # This will add in any other parameter attributes if they are specified (default attributes are thus not included and output may not be normalized) + $p.FindAll($paramattributes, $true) | ForEach-Object { + $OutProps.($_.ArgumentName) = $_.Argument.Value + } + $Output += New-Object -TypeName PSObject -Property $OutProps } - $Output += New-Object -TypeName PSObject -Property $OutProps } } } diff --git a/src/private/New-CommentBasedHelp.ps1 b/src/private/New-CommentBasedHelp.ps1 index 38542d9..eebaf63 100644 --- a/src/private/New-CommentBasedHelp.ps1 +++ b/src/private/New-CommentBasedHelp.ps1 @@ -30,6 +30,7 @@ 1.0.0 - Initial release 1.0.1 - Updated for ModuleBuild 1.0.2 - Added SuppressMessageAttribute + 1.0.3 - Extra Verbose message to check if function had Params #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "ScriptText",Scope="Function",Target="New-CommentBasedHelp",Justification="Seems it's here since duo a copy paste from other functions (Add-MissingCBH,Get-Function,Get-FunctionParameter). Leaving it here since it doesn't do any harm.")] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions","",Scope="Function",Target="New-CommentBasedHelp",Justification="Function does not change system state. Simply outputs a obj with CommentBasedHelp.")] @@ -76,26 +77,31 @@ } $AllParams = Get-FunctionParameter @FuncParams -Code $Codeblock | Sort-Object -Property FunctionName $AllFunctions = @($AllParams.FunctionName | Select-Object -unique) + If([string]::IsNullOrEmpty($AllFunctions)) + { + Write-Verbose "$($FunctionName): Found no Params in function." + } else + { + foreach ($f in $AllFunctions) { + $OutCBH = @{} + $OutCBH.FunctionName = $f + [string]$OutParams = '' + $fparams = @($AllParams | Where-Object {$_.FunctionName -eq $f} | Sort-Object -Property Position) + if ($fparams.count -gt 0) { + $fparams | ForEach-Object { + $ParamHelpMessage = if ([string]::IsNullOrEmpty($_.HelpMessage)) { $_.ParameterName + " explanation`n`r`n`r"} else {$_.HelpMessage + "`n`r`n`r"} - foreach ($f in $AllFunctions) { - $OutCBH = @{} - $OutCBH.FunctionName = $f - [string]$OutParams = '' - $fparams = @($AllParams | Where-Object {$_.FunctionName -eq $f} | Sort-Object -Property Position) - if ($fparams.count -gt 0) { - $fparams | ForEach-Object { - $ParamHelpMessage = if ([string]::IsNullOrEmpty($_.HelpMessage)) { $_.ParameterName + " explanation`n`r`n`r"} else {$_.HelpMessage + "`n`r`n`r"} - - $OutParams += $CBH_PARAM -replace '%%PARAM%%',$_.ParameterName -replace '%%PARAMHELP%%',$ParamHelpMessage + $OutParams += $CBH_PARAM -replace '%%PARAM%%',$_.ParameterName -replace '%%PARAMHELP%%',$ParamHelpMessage + } } - } - else { + else { - } + } - $OutCBH.'CBH' = $CBHTemplate -replace '%%PARAMETER%%',$OutParams + $OutCBH.'CBH' = $CBHTemplate -replace '%%PARAMETER%%',$OutParams - New-Object PSObject -Property $OutCBH + New-Object PSObject -Property $OutCBH + } } Write-Verbose "$($FunctionName): End." From e53d8a1f83caf8ebbfc79a4715afcb04a2417bff Mon Sep 17 00:00:00 2001 From: justin-p Date: Tue, 15 Jan 2019 12:46:23 +0100 Subject: [PATCH 023/102] remove cleanup function from build.ps1 --- Build.ps1 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Build.ps1 b/Build.ps1 index a836e8d..a8b11b0 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -61,8 +61,6 @@ switch ($psCmdlet.ParameterSetName) { throw } } - - CleanUp } 'Build' { if ($NewVersion -ne $null) { @@ -104,7 +102,5 @@ switch ($psCmdlet.ParameterSetName) { throw 'Unable to upload project to the PowerShell Gallery!' } } - - CleanUp } } \ No newline at end of file From cb04c5f7ff8dd44818e8afdbdb6be7d2b4171ad3 Mon Sep 17 00:00:00 2001 From: justin-p Date: Tue, 15 Jan 2019 12:48:51 +0100 Subject: [PATCH 024/102] basic appveyor.yml and updated scaffold regarding last commit --- appveyor.yml | 14 ++++++++++++++ plaster/ModuleBuild/scaffold/Build.template | 4 ---- plaster/PlasterContent.ps1 | 5 +++++ 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..798271c --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,14 @@ +# See http://www.appveyor.com/docs/appveyor-yml for many more options +# Allow WMF5 (i.e. PowerShellGallery functionality) +os: WMF 5 + +# Skip on updates to the readme. +# We can force this by adding [skip ci] or [ci skip] anywhere in commit message +skip_commits: + message: /updated readme.*|update readme.*s/ + +build: false + +#Kick off the CI/CD pipeline +test_script: + - ps: . .\Build.ps1 -BuildModule diff --git a/plaster/ModuleBuild/scaffold/Build.template b/plaster/ModuleBuild/scaffold/Build.template index a836e8d..a8b11b0 100644 --- a/plaster/ModuleBuild/scaffold/Build.template +++ b/plaster/ModuleBuild/scaffold/Build.template @@ -61,8 +61,6 @@ switch ($psCmdlet.ParameterSetName) { throw } } - - CleanUp } 'Build' { if ($NewVersion -ne $null) { @@ -104,7 +102,5 @@ switch ($psCmdlet.ParameterSetName) { throw 'Unable to upload project to the PowerShell Gallery!' } } - - CleanUp } } \ No newline at end of file diff --git a/plaster/PlasterContent.ps1 b/plaster/PlasterContent.ps1 index 87b1a64..45e04de 100644 --- a/plaster/PlasterContent.ps1 +++ b/plaster/PlasterContent.ps1 @@ -226,4 +226,9 @@ $Content = @( Source = 'scaffold\PSScriptAnalyzerSettings.psd1' Destination = 'PSScriptAnalyzerSettings.psd1' } + @{ + ContentType = 'file' + Source = 'scaffold\appveyor.yml' + Destination = 'appveyor.yml' + } ) \ No newline at end of file From 991d73ddde09e823225f13d05d4229d36a0edb31 Mon Sep 17 00:00:00 2001 From: Justin Date: Tue, 15 Jan 2019 11:55:46 +0000 Subject: [PATCH 025/102] Delete appveyor.yml --- appveyor.yml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 798271c..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,14 +0,0 @@ -# See http://www.appveyor.com/docs/appveyor-yml for many more options -# Allow WMF5 (i.e. PowerShellGallery functionality) -os: WMF 5 - -# Skip on updates to the readme. -# We can force this by adding [skip ci] or [ci skip] anywhere in commit message -skip_commits: - message: /updated readme.*|update readme.*s/ - -build: false - -#Kick off the CI/CD pipeline -test_script: - - ps: . .\Build.ps1 -BuildModule From f247ab705db13d109e4f74b153386f8de18aade4 Mon Sep 17 00:00:00 2001 From: Schockaert Rudy Date: Tue, 14 May 2019 16:14:30 +0200 Subject: [PATCH 026/102] Switch 'AddMissingCBH' different in build.template --- plaster/ModuleBuild/scaffold/Build.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plaster/ModuleBuild/scaffold/Build.template b/plaster/ModuleBuild/scaffold/Build.template index a836e8d..ab97edd 100644 --- a/plaster/ModuleBuild/scaffold/Build.template +++ b/plaster/ModuleBuild/scaffold/Build.template @@ -12,7 +12,7 @@ param ( [parameter(Position = 5, ParameterSetName = 'Build')] [string]$ReleaseNotes, [parameter(Position = 6, ParameterSetName = 'CBH')] - [switch]$AddCBH + [switch]$AddMissingCBH ) function PrerequisitesLoaded { From 28b15b2056905bf2ae12ca48841eb8efb0ca1d81 Mon Sep 17 00:00:00 2001 From: Schockaert Rudy Date: Tue, 14 May 2019 16:20:26 +0200 Subject: [PATCH 027/102] Correct generation of ModulePage --- plaster/ModuleBuild/scaffold/modulename.build.template | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plaster/ModuleBuild/scaffold/modulename.build.template b/plaster/ModuleBuild/scaffold/modulename.build.template index 6827468..ca4a83a 100644 --- a/plaster/ModuleBuild/scaffold/modulename.build.template +++ b/plaster/ModuleBuild/scaffold/modulename.build.template @@ -503,20 +503,15 @@ task CreateMarkdownHelp GetPublicFunctions, { # Create the function .md files and the generic module page md as well for the distributable module $null = New-MarkdownHelp -module $Script:BuildEnv.ModuleToBuild -OutputFolder "$($StageReleasePath)\docs\" -Force -WithModulePage -Locale 'en-US' -FwLink $FwLink -HelpVersion $Script:BuildEnv.ModuleVersion -Encoding ([System.Text.Encoding]::($Script:BuildEnv.Encoding)) + $null = Update-MarkdownHelpModule -Path "$($StageReleasePath)\docs\" -Force -RefreshModulePage <# Replace each missing element we need for a proper generic module page .md file Also replace the blank Guid 00000000-0000-0000-0000-000000000000 with the actual module guid (PlatyPS won't know what this is as our module in memory is loaded from the psm1 file not the actual manifest file) #> $ModulePageFileContent = Get-Content -raw $ModulePage - $ModulePageFileContent = $ModulePageFileContent -replace '{{Manually Enter Description Here}}', $Script:Manifest.Description - $Script:FunctionsToExport | Foreach-Object { - Write-Description White "Updating definition for the following function: $($_)" -Level 2 - $TextToReplace = "{{Manually Enter $($_) Description Here}}" - $ReplacementText = (Get-Help -Detailed $_).Synopsis - $ModulePageFileContent = $ModulePageFileContent -replace $TextToReplace, $ReplacementText ` + $ModulePageFileContent = $ModulePageFileContent -replace '{{ Fill in the Description }}', $Script:Manifest.Description -replace '00000000-0000-0000-0000-000000000000', ($Script:Manifest.Guid).ToString() - } $ModulePageFileContent | Out-File $ModulePage -Force -Encoding $Script:BuildEnv.Encoding $MissingDocumentation = Select-String -Path "$($StageReleasePath)\docs\*.md" -Pattern "({{.*}})" From f8c71b21450bd3106f3d405767cb62139c080ffe Mon Sep 17 00:00:00 2001 From: Schockaert Rudy Date: Tue, 14 May 2019 16:31:55 +0200 Subject: [PATCH 028/102] Missing backtick --- plaster/ModuleBuild/scaffold/modulename.build.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plaster/ModuleBuild/scaffold/modulename.build.template b/plaster/ModuleBuild/scaffold/modulename.build.template index ca4a83a..eb374ac 100644 --- a/plaster/ModuleBuild/scaffold/modulename.build.template +++ b/plaster/ModuleBuild/scaffold/modulename.build.template @@ -510,7 +510,7 @@ task CreateMarkdownHelp GetPublicFunctions, { (PlatyPS won't know what this is as our module in memory is loaded from the psm1 file not the actual manifest file) #> $ModulePageFileContent = Get-Content -raw $ModulePage - $ModulePageFileContent = $ModulePageFileContent -replace '{{ Fill in the Description }}', $Script:Manifest.Description + $ModulePageFileContent = $ModulePageFileContent -replace '{{ Fill in the Description }}', $Script:Manifest.Description ` -replace '00000000-0000-0000-0000-000000000000', ($Script:Manifest.Guid).ToString() $ModulePageFileContent | Out-File $ModulePage -Force -Encoding $Script:BuildEnv.Encoding $MissingDocumentation = Select-String -Path "$($StageReleasePath)\docs\*.md" -Pattern "({{.*}})" From 26078e058481fd6049f4244c73eaff47b03f4daa Mon Sep 17 00:00:00 2001 From: Justin-p Date: Tue, 17 Dec 2019 10:11:36 +0100 Subject: [PATCH 029/102] missing links to VSCode and the PS Extension --- plaster/ModuleBuild/scaffold/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plaster/ModuleBuild/scaffold/readme.md b/plaster/ModuleBuild/scaffold/readme.md index 087d0f7..64d9f92 100644 --- a/plaster/ModuleBuild/scaffold/readme.md +++ b/plaster/ModuleBuild/scaffold/readme.md @@ -33,8 +33,8 @@ Please feel free to contribute by opening new issues or providing pull requests. For the best development experience, open this project as a folder in Visual Studio Code and ensure that the PowerShell extension is installed. -* [Visual Studio Code] -* [PowerShell Extension] +* [Visual Studio Code](https://code.visualstudio.com/) +* [PowerShell Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell) // This module is tested with the PowerShell testing framework Pester. To run all // tests, just start the included test script `.\Build.ps1 -test` or invoke Pester From 278c537b4c63341a3fd3f3222b82f21f13286123 Mon Sep 17 00:00:00 2001 From: Justin-p Date: Tue, 17 Dec 2019 10:15:53 +0100 Subject: [PATCH 030/102] Link to ChangeLog in index.md was plural --- plaster/ModuleBuild/scaffold/build/docs/Additional/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plaster/ModuleBuild/scaffold/build/docs/Additional/index.md b/plaster/ModuleBuild/scaffold/build/docs/Additional/index.md index 2307b7d..4c12c29 100644 --- a/plaster/ModuleBuild/scaffold/build/docs/Additional/index.md +++ b/plaster/ModuleBuild/scaffold/build/docs/Additional/index.md @@ -28,7 +28,7 @@ Install-Module -Name <%=$PLASTER_PARAM_ModuleName%> -Scope CurrentUser [Notes on contributing to this project](Contributing.md) ## Change Logs -[Change notes for each release](ChangeLogs.md) +[Change notes for each release](ChangeLog.md) ## Acknowledgements [Other projects or sources of inspiration](Acknowledgements.md) From 93c46877461abb1da07300d6e1d966ec560be9f6 Mon Sep 17 00:00:00 2001 From: Justin-p Date: Tue, 17 Dec 2019 11:05:19 +0100 Subject: [PATCH 031/102] Added CI/CD option to plaster. Added AppVeyor template to plaster. --- buildreports/CodeHealthReport-Private.html | 368 ++------ buildreports/CodeHealthReport-Public.html | 134 +-- docs/ChangeLog.md | 2 +- .../Functions/Import-ModulePrivateFunction.md | 4 +- docs/Functions/Import-ModulePublicFunction.md | 4 +- docs/Functions/Set-BuildEnvironment.md | 515 +---------- plaster/ModuleBuild/plasterManifest.xml | 20 +- plaster/ModuleBuild/scaffold/appveyor.yml | 14 + plaster/PlasterContent.ps1 | 1 + plaster/PlasterParams.ps1 | 18 + release/0.2.3/ModuleBuild.psd1 | 8 +- release/0.2.3/ModuleBuild.psm1 | 335 ++++--- .../docs/Import-ModulePrivateFunction.md | 4 +- .../0.2.3/docs/Import-ModulePublicFunction.md | 4 +- release/0.2.3/docs/ModuleBuild.md | 2 +- release/0.2.3/docs/Set-BuildEnvironment.md | 515 +---------- release/0.2.3/en-US/ModuleBuild-help.xml | 858 +----------------- ...49-a717-96d64a1cc5b3_en-US_HelpContent.cab | Bin 4701 -> 0 bytes ...49-a717-96d64a1cc5b3_en-US_HelpContent.zip | Bin 4961 -> 0 bytes ...-6411-4949-a717-96d64a1cc5b3_HelpInfo.xml} | 0 ...49-a717-96d64a1cc5b3_en-US_HelpContent.cab | Bin 0 -> 3430 bytes ...49-a717-96d64a1cc5b3_en-US_HelpContent.zip | Bin 0 -> 3683 bytes .../plaster/ModuleBuild/plasterManifest.xml | 67 +- .../ModuleBuild/scaffold/Build.template | 10 +- .../scaffold/PSScriptAnalyzerSettings.psd1 | 26 + .../plaster/ModuleBuild/scaffold/appveyor.yml | 14 + .../build/docs/Additional/Acknowledgements.md | 4 +- .../build/docs/Additional/Contributing.md | 2 +- .../scaffold/build/docs/Additional/Index.md | 2 +- .../scaffold/modulename.build.template | 57 +- .../plaster/ModuleBuild/scaffold/readme.md | 13 +- .../scaffold/src/other/PostLoad.ps1 | 2 + .../scaffold/src/tests/FunctionCBH.Tests.ps1 | 60 -- .../src/tests/ModuleManifest.Tests.ps1 | 205 ----- .../src/tests/ScriptAnalyzer.Tests.ps1 | 32 - .../src/tests/SensitiveTermScan.Tests.ps1 | 28 - .../src/tests/meta/Autoload.Tests.ps1 | 23 - .../src/tests/meta/FileContent.Tests.ps1 | 349 ------- .../src/tests/meta/FileEncoding.Tests.ps1 | 54 -- .../src/tests/meta/FileFormatting.Tests.ps1 | 96 -- .../src/tests/meta/ProjectStructure.Tests.ps1 | 152 ---- .../src/tests/meta/ScriptAnalyzer.Tests.ps1 | 37 - .../scaffold/tests/FunctionCBH.Tests.ps1 | 60 -- .../scaffold/tests/ModuleManifest.Tests.ps1 | 205 ----- .../scaffold/tests/ScriptAnalyzer.Tests.ps1 | 32 - .../tests/SensitiveTermScan.Tests.ps1 | 28 - .../tests/intergration/private/readme.md | 1 + .../tests/intergration/public/readme.md | 1 + .../scaffold/tests/meta/Autoload.Tests.ps1 | 23 - .../scaffold/tests/meta/FileContent.Tests.ps1 | 349 ------- .../tests/meta/FileEncoding.Tests.ps1 | 54 -- .../tests/meta/FileFormatting.Tests.ps1 | 96 -- .../tests/meta/ProjectStructure.Tests.ps1 | 152 ---- .../tests/meta/ScriptAnalyzer.Tests.ps1 | 37 - .../scaffold/tests/unit/private/readme.md | 1 + .../scaffold/tests/unit/public/readme.md | 1 + .../ModuleBuild/scaffold/vscode/settings.json | 14 +- .../ModuleBuild/scaffold/vscode/tasks.json | 6 +- release/0.2.3/plaster/PlasterContent.ps1 | 69 +- release/0.2.3/plaster/PlasterParams.ps1 | 23 + release/0.2.3/plaster/make.ps1 | 2 +- release/ModuleBuild-current.zip | Bin 983365 -> 958179 bytes release/ModuleBuild/ModuleBuild.psd1 | 8 +- release/ModuleBuild/ModuleBuild.psm1 | 335 ++++--- .../docs/Import-ModulePrivateFunction.md | 4 +- .../docs/Import-ModulePublicFunction.md | 4 +- release/ModuleBuild/docs/ModuleBuild.md | 2 +- .../ModuleBuild/docs/Set-BuildEnvironment.md | 515 +---------- .../ModuleBuild/en-US/ModuleBuild-help.xml | 858 +----------------- ...49-a717-96d64a1cc5b3_en-US_HelpContent.cab | Bin 4701 -> 0 bytes ...49-a717-96d64a1cc5b3_en-US_HelpContent.zip | Bin 4961 -> 0 bytes ...-6411-4949-a717-96d64a1cc5b3_HelpInfo.xml} | 0 ...49-a717-96d64a1cc5b3_en-US_HelpContent.cab | Bin 0 -> 3430 bytes ...49-a717-96d64a1cc5b3_en-US_HelpContent.zip | Bin 0 -> 3683 bytes .../plaster/ModuleBuild/plasterManifest.xml | 67 +- .../ModuleBuild/scaffold/Build.template | 10 +- .../scaffold/PSScriptAnalyzerSettings.psd1 | 26 + .../plaster/ModuleBuild/scaffold/appveyor.yml | 14 + .../build/docs/Additional/Acknowledgements.md | 4 +- .../build/docs/Additional/Contributing.md | 2 +- .../scaffold/build/docs/Additional/index.md | 2 +- .../scaffold/modulename.build.template | 57 +- .../plaster/ModuleBuild/scaffold/readme.md | 13 +- .../scaffold/src/other/PostLoad.ps1 | 2 + .../scaffold/src/tests/FunctionCBH.Tests.ps1 | 60 -- .../src/tests/ModuleManifest.Tests.ps1 | 205 ----- .../src/tests/ScriptAnalyzer.Tests.ps1 | 32 - .../src/tests/SensitiveTermScan.Tests.ps1 | 28 - .../src/tests/meta/Autoload.Tests.ps1 | 23 - .../src/tests/meta/FileContent.Tests.ps1 | 349 ------- .../src/tests/meta/FileEncoding.Tests.ps1 | 54 -- .../src/tests/meta/FileFormatting.Tests.ps1 | 96 -- .../src/tests/meta/ProjectStructure.Tests.ps1 | 152 ---- .../src/tests/meta/ScriptAnalyzer.Tests.ps1 | 37 - .../scaffold/tests/FunctionCBH.Tests.ps1 | 60 -- .../scaffold/tests/ModuleManifest.Tests.ps1 | 205 ----- .../scaffold/tests/ScriptAnalyzer.Tests.ps1 | 32 - .../tests/SensitiveTermScan.Tests.ps1 | 28 - .../tests/intergration/private/readme.md | 1 + .../tests/intergration/public/readme.md | 1 + .../scaffold/tests/meta/Autoload.Tests.ps1 | 23 - .../scaffold/tests/meta/FileContent.Tests.ps1 | 349 ------- .../tests/meta/FileEncoding.Tests.ps1 | 54 -- .../tests/meta/FileFormatting.Tests.ps1 | 96 -- .../tests/meta/ProjectStructure.Tests.ps1 | 152 ---- .../tests/meta/ScriptAnalyzer.Tests.ps1 | 37 - .../scaffold/tests/unit/private/readme.md | 1 + .../scaffold/tests/unit/public/readme.md | 1 + .../ModuleBuild/scaffold/vscode/settings.json | 14 +- .../ModuleBuild/scaffold/vscode/tasks.json | 6 +- .../ModuleBuild/plaster/PlasterContent.ps1 | 69 +- release/ModuleBuild/plaster/PlasterParams.ps1 | 23 + release/ModuleBuild/plaster/make.ps1 | 2 +- 113 files changed, 1170 insertions(+), 8136 deletions(-) create mode 100644 plaster/ModuleBuild/scaffold/appveyor.yml delete mode 100644 release/0.2.3/en-US/ModuleBuild_8f6090b4-6411-4949-a717-96d64a1cc5b3 8f6090b4-6411-4949-a717-96d64a1cc5b3_en-US_HelpContent.cab delete mode 100644 release/0.2.3/en-US/ModuleBuild_8f6090b4-6411-4949-a717-96d64a1cc5b3 8f6090b4-6411-4949-a717-96d64a1cc5b3_en-US_HelpContent.zip rename release/0.2.3/en-US/{ModuleBuild_8f6090b4-6411-4949-a717-96d64a1cc5b3 8f6090b4-6411-4949-a717-96d64a1cc5b3_HelpInfo.xml => ModuleBuild_8f6090b4-6411-4949-a717-96d64a1cc5b3_HelpInfo.xml} (100%) create mode 100644 release/0.2.3/en-US/ModuleBuild_8f6090b4-6411-4949-a717-96d64a1cc5b3_en-US_HelpContent.cab create mode 100644 release/0.2.3/en-US/ModuleBuild_8f6090b4-6411-4949-a717-96d64a1cc5b3_en-US_HelpContent.zip create mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/PSScriptAnalyzerSettings.psd1 create mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/appveyor.yml delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/src/tests/FunctionCBH.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/src/tests/ModuleManifest.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/src/tests/ScriptAnalyzer.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/src/tests/SensitiveTermScan.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/src/tests/meta/Autoload.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/src/tests/meta/FileContent.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/src/tests/meta/FileEncoding.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/src/tests/meta/FileFormatting.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/src/tests/meta/ProjectStructure.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/src/tests/meta/ScriptAnalyzer.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/tests/FunctionCBH.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/tests/ModuleManifest.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/tests/ScriptAnalyzer.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/tests/SensitiveTermScan.Tests.ps1 create mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/tests/intergration/private/readme.md create mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/tests/intergration/public/readme.md delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/tests/meta/Autoload.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/tests/meta/FileContent.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/tests/meta/FileEncoding.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/tests/meta/FileFormatting.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/tests/meta/ProjectStructure.Tests.ps1 delete mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/tests/meta/ScriptAnalyzer.Tests.ps1 create mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/tests/unit/private/readme.md create mode 100644 release/0.2.3/plaster/ModuleBuild/scaffold/tests/unit/public/readme.md delete mode 100644 release/ModuleBuild/en-US/ModuleBuild_8f6090b4-6411-4949-a717-96d64a1cc5b3 8f6090b4-6411-4949-a717-96d64a1cc5b3_en-US_HelpContent.cab delete mode 100644 release/ModuleBuild/en-US/ModuleBuild_8f6090b4-6411-4949-a717-96d64a1cc5b3 8f6090b4-6411-4949-a717-96d64a1cc5b3_en-US_HelpContent.zip rename release/ModuleBuild/en-US/{ModuleBuild_8f6090b4-6411-4949-a717-96d64a1cc5b3 8f6090b4-6411-4949-a717-96d64a1cc5b3_HelpInfo.xml => ModuleBuild_8f6090b4-6411-4949-a717-96d64a1cc5b3_HelpInfo.xml} (100%) create mode 100644 release/ModuleBuild/en-US/ModuleBuild_8f6090b4-6411-4949-a717-96d64a1cc5b3_en-US_HelpContent.cab create mode 100644 release/ModuleBuild/en-US/ModuleBuild_8f6090b4-6411-4949-a717-96d64a1cc5b3_en-US_HelpContent.zip create mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/PSScriptAnalyzerSettings.psd1 create mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/appveyor.yml delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/src/tests/FunctionCBH.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/src/tests/ModuleManifest.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/src/tests/ScriptAnalyzer.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/src/tests/SensitiveTermScan.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/src/tests/meta/Autoload.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/src/tests/meta/FileContent.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/src/tests/meta/FileEncoding.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/src/tests/meta/FileFormatting.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/src/tests/meta/ProjectStructure.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/src/tests/meta/ScriptAnalyzer.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/tests/FunctionCBH.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/tests/ModuleManifest.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/tests/ScriptAnalyzer.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/tests/SensitiveTermScan.Tests.ps1 create mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/tests/intergration/private/readme.md create mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/tests/intergration/public/readme.md delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/tests/meta/Autoload.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/tests/meta/FileContent.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/tests/meta/FileEncoding.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/tests/meta/FileFormatting.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/tests/meta/ProjectStructure.Tests.ps1 delete mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/tests/meta/ScriptAnalyzer.Tests.ps1 create mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/tests/unit/private/readme.md create mode 100644 release/ModuleBuild/plaster/ModuleBuild/scaffold/tests/unit/public/readme.md diff --git a/buildreports/CodeHealthReport-Private.html b/buildreports/CodeHealthReport-Private.html index a3defc8..77820ca 100644 --- a/buildreports/CodeHealthReport-Private.html +++ b/buildreports/CodeHealthReport-Private.html @@ -189,7 +189,7 @@

Analyzed path : src\private
- Analysis date : 2018-04-01 21:07:32Z + Analysis date : 2019-12-17 10:55:38Z
@@ -233,7 +233,7 @@

13

Lines of Code - Total

-

798

+

815

@@ -246,9 +246,9 @@