From 164820574409b15ad44b44b3a83638ef62e0ff24 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Thu, 12 May 2022 10:34:32 +0200 Subject: [PATCH] Fixes missing component import func on dev tools --- doc/100-General/10-Changelog.md | 1 + lib/core/dev/New-IcingaForWindowsComponent.psm1 | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index 105bcbd..1ec50b9 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -14,6 +14,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic [Issue and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/24?closed=1) * [#519](https://github.com/Icinga/icinga-powershell-framework/pull/519) Fixes missing loading of Icinga for Windows modules, which is required to ensure an Icinga for Windows environment is providing all commands and variables to a session, allowing other modules to access these information +* [#520](https://github.com/Icinga/icinga-powershell-framework/pull/520) Adds missing `Import-IcingaPowerShellComponent` function while creating new components by using the developer tools ## 1.9.0 (2022-05-03) diff --git a/lib/core/dev/New-IcingaForWindowsComponent.psm1 b/lib/core/dev/New-IcingaForWindowsComponent.psm1 index 452c712..5d6f646 100644 --- a/lib/core/dev/New-IcingaForWindowsComponent.psm1 +++ b/lib/core/dev/New-IcingaForWindowsComponent.psm1 @@ -71,6 +71,13 @@ function New-IcingaForWindowsComponent() New-Item -ItemType File -Path (Join-Path -Path $ModuleDir -ChildPath 'README.md') | Out-Null; New-Item -ItemType File -Path (Join-Path -Path $ModuleDir -ChildPath ([string]::Format('{0}.psm1', $ModuleName))) | Out-Null; + $ModuleMainFile = Join-Path -Path $ModuleDir -ChildPath ([string]::Format('{0}.psm1', $ModuleName)); + + Set-Content -Path $ModuleMainFile -Value ([string]::Format('function Import-IcingaPowerShellComponent{0}()', $TextInfo.ToTitleCase($Name))); + Add-Content -Path $ModuleMainFile -Value '{'; + Add-Content -Path $ModuleMainFile -Value ''; + Add-Content -Path $ModuleMainFile -Value '}'; + switch ($ComponentType) { 'plugins' { New-Item -ItemType Directory -Path (Join-Path -Path $ModuleDir -ChildPath 'plugins') | Out-Null;