From 3a5109c10ad549586c5a20fd2b3e5c5d5440f437 Mon Sep 17 00:00:00 2001 From: potatoqualitee Date: Mon, 18 Dec 2017 22:18:01 +0100 Subject: [PATCH] updates --- dbachecks.psd1 | 11 +++-- dbachecks.psm1 | 41 +++++++++++++++---- en-us/about_dbachecks.help.txt | 11 +++++ .../configurations/example-configuration.ps1 | 1 + internal/scripts/postimport.ps1 | 11 +++++ internal/scripts/preimport.ps1 | 1 + 6 files changed, 62 insertions(+), 14 deletions(-) create mode 100644 en-us/about_dbachecks.help.txt create mode 100644 internal/configurations/example-configuration.ps1 create mode 100644 internal/scripts/postimport.ps1 create mode 100644 internal/scripts/preimport.ps1 diff --git a/dbachecks.psd1 b/dbachecks.psd1 index a7f7c3ca..fd178e54 100644 --- a/dbachecks.psd1 +++ b/dbachecks.psd1 @@ -1,9 +1,9 @@ # # Module manifest for module 'dbachecks' # -# Generated by: You, you big playa! +# Generated by: Chrissy LeMaire # -# Generated on: 4/14/2017 +# Generated on: 12/18/2017 # @{ @@ -23,7 +23,7 @@ CompanyName = 'SQL Community Collaborative' # Copyright statement for this module - Copyright = '2017 dbatools' + Copyright = '(c) 2017. All rights reserved.' # Description of the functionality provided by this module Description = 'Automates testing for SQL Server stuff' @@ -73,8 +73,7 @@ # Functions to export from this module # This is the stuff in \enduser-functions FunctionsToExport = @( - 'Clear-AcmeSqlConnectionPool', - 'Test-AcmeSqlPath' + '' ) # Cmdlets to export from this module @@ -103,7 +102,7 @@ Category = "Databases" # Keyword tags to help users find this module via navigations and search. - Tags = @('sqlserver', 'sql', 'dba', 'databases', 'audits') + Tags = @('sqlserver', 'sql', 'dba', 'databases', 'audits','checklists') # The web address of an icon which can be used in galleries to represent this module IconUri = "https://dbatools.io/logo.png" diff --git a/dbachecks.psm1 b/dbachecks.psm1 index 78d4a33b..b0234fd8 100644 --- a/dbachecks.psm1 +++ b/dbachecks.psm1 @@ -1,12 +1,37 @@ -# All internal functions privately available within the toolset - for developers - smaller modules may not have any -# But basically, these are functions that are shared between the exported commands, that you don't nessarily want end users to use -foreach ($function in (Get-ChildItem "$PSScriptRoot\internal\*.ps1")) +$script:ModuleRoot = $PSScriptRoot + +function Import-ModuleFile +{ + [CmdletBinding()] + Param ( + [string] + $Path + ) + + if ($doDotSource) { . $Path } + else { $ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText($Path))), $null, $null) } +} + +# Detect whether at some level dotsourcing was enforced +$script:doDotSource = $false +if ($dbachecks_dotsourcemodule) { $script:doDotSource = $true } +if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsPowerShell\dbachecks\System" -Name "DoDotSource" -ErrorAction Ignore).DoDotSource) { $script:doDotSource = $true } +if ((Get-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\WindowsPowerShell\dbachecks\System" -Name "DoDotSource" -ErrorAction Ignore).DoDotSource) { $script:doDotSource = $true } + +# Execute Preimport actions +. Import-ModuleFile -Path "$ModuleRoot\internal\scripts\preimport.ps1" + +# Import all internal functions +foreach ($function in (Get-ChildItem "$ModuleRoot\internal\functions\*.ps1")) { - $ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText($function))), $null, $null) + . Import-ModuleFile -Path $function.FullName } -# All exported functions - for end users -foreach ($function in (Get-ChildItem "$PSScriptRoot\functions\*.ps1")) +# Import all public functions +foreach ($function in (Get-ChildItem "$ModuleRoot\functions\*.ps1")) { - $ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText($function))), $null, $null) -} \ No newline at end of file + . Import-ModuleFile -Path $function.FullName +} + +# Execute Postimport actions +. Import-ModuleFile -Path "$ModuleRoot\internal\scripts\postimport.ps1" diff --git a/en-us/about_dbachecks.help.txt b/en-us/about_dbachecks.help.txt new file mode 100644 index 00000000..d527e1d4 --- /dev/null +++ b/en-us/about_dbachecks.help.txt @@ -0,0 +1,11 @@ +TOPIC + about_dbachecks + +SHORT DESCRIPTION + Explains how to use the dbachecks powershell module + +LONG DESCRIPTION + + +KEYWORDS + dbachecks \ No newline at end of file diff --git a/internal/configurations/example-configuration.ps1 b/internal/configurations/example-configuration.ps1 new file mode 100644 index 00000000..ee02660f --- /dev/null +++ b/internal/configurations/example-configuration.ps1 @@ -0,0 +1 @@ +Set-PSFConfig -Module 'dbachecks' -Name 'Example.Setting' -Value 10 -Initialize -Validation 'integer' -Handler { } -Description "Example configuration setting. Your module can then use the setting using 'Get-PSFConfigValue'" \ No newline at end of file diff --git a/internal/scripts/postimport.ps1 b/internal/scripts/postimport.ps1 new file mode 100644 index 00000000..55dfb4c6 --- /dev/null +++ b/internal/scripts/postimport.ps1 @@ -0,0 +1,11 @@ +# Add all things you want to run after importing the main code + +# Load Configurations +foreach ($file in (Get-ChildItem "$ModuleRoot\internal\configurations\*.ps1")) { + . Import-ModuleFile -Path $file.FullName +} + +# Load Tab Expansion +foreach ($file in (Get-ChildItem "$ModuleRoot\internal\tepp\*.ps1")) { + . Import-ModuleFile -Path $file.FullName +} \ No newline at end of file diff --git a/internal/scripts/preimport.ps1 b/internal/scripts/preimport.ps1 new file mode 100644 index 00000000..09e0ce4b --- /dev/null +++ b/internal/scripts/preimport.ps1 @@ -0,0 +1 @@ +# Add all things you want to run before importing the main code \ No newline at end of file