From 85554639e88187919a8d56aeb88f27c8bbe1f336 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 30 Mar 2024 15:56:00 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Simplify=20source=20c?= =?UTF-8?q?ode=20structure=20(#9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description - Simplify source code structure ## Type of change - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas --- .../linters/.powershell-psscriptanalyzer.psd1 | 17 ++++++++++ README.md | 2 +- src/PublicIP/PublicIP.psm1 | 32 ------------------- src/{PublicIP/PublicIP.psd1 => manifest.psd1} | 4 +-- src/{PublicIP => }/private/common.ps1 | 0 src/{PublicIP => }/public/Get-PublicIP.ps1 | 0 6 files changed, 19 insertions(+), 36 deletions(-) create mode 100644 .github/linters/.powershell-psscriptanalyzer.psd1 delete mode 100644 src/PublicIP/PublicIP.psm1 rename src/{PublicIP/PublicIP.psd1 => manifest.psd1} (79%) rename src/{PublicIP => }/private/common.ps1 (100%) rename src/{PublicIP => }/public/Get-PublicIP.ps1 (100%) diff --git a/.github/linters/.powershell-psscriptanalyzer.psd1 b/.github/linters/.powershell-psscriptanalyzer.psd1 new file mode 100644 index 0000000..570ac0d --- /dev/null +++ b/.github/linters/.powershell-psscriptanalyzer.psd1 @@ -0,0 +1,17 @@ +#Documentation: https://github.com/PowerShell/PSScriptAnalyzer/blob/master/docs/Cmdlets/Invoke-ScriptAnalyzer.md#-settings +@{ + #CustomRulePath='path\to\CustomRuleModule.psm1' + #RecurseCustomRulePath='path\of\customrules' + #Severity = @( + # 'Error' + # 'Warning' + #) + #IncludeDefaultRules=${true} + ExcludeRules = @( + 'PSMissingModuleManifestField' + ) + #IncludeRules = @( + # 'PSAvoidUsingWriteHost', + # 'MyCustomRuleName' + #) +} diff --git a/README.md b/README.md index e1c740e..e45a02e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Fonts +# PublicIP This is a PowerShell module for getting information about your public IP. It uses the APIs of [IPInfo](https://ipinfo.io) and [MyIP](https://www.myip.com/) to get this data. diff --git a/src/PublicIP/PublicIP.psm1 b/src/PublicIP/PublicIP.psm1 deleted file mode 100644 index 573c80d..0000000 --- a/src/PublicIP/PublicIP.psm1 +++ /dev/null @@ -1,32 +0,0 @@ -[Cmdletbinding()] -param() - -Write-Verbose 'Importing subcomponents' -$Folders = 'classes', 'private', 'public' -# Import everything in these folders -Foreach ($Folder in $Folders) { - $Root = Join-Path -Path $PSScriptRoot -ChildPath $Folder - Write-Verbose "Processing folder: $Root" - if (Test-Path -Path $Root) { - Write-Verbose "Getting all files in $Root" - $Files = $null - $Files = Get-ChildItem -Path $Root -Include '*.ps1', '*.psm1' -Recurse - # dot source each file - foreach ($File in $Files) { - Write-Verbose "Importing $($File)" - Import-Module $File - Write-Verbose "Importing $($File): Done" - } - } -} - -$Param = @{ - Function = (Get-ChildItem -Path "$PSScriptRoot\public" -Include '*.ps1' -Recurse).BaseName - Variable = '*' - Cmdlet = '*' - Alias = '*' -} - -Write-Verbose 'Exporting module members' - -Export-ModuleMember @Param -Verbose diff --git a/src/PublicIP/PublicIP.psd1 b/src/manifest.psd1 similarity index 79% rename from src/PublicIP/PublicIP.psd1 rename to src/manifest.psd1 index cd3acd4..f9978df 100644 --- a/src/PublicIP/PublicIP.psd1 +++ b/src/manifest.psd1 @@ -1,6 +1,5 @@ @{ - ModuleVersion = '0.0.1' - PrivateData = @{ + PrivateData = @{ PSData = @{ Tags = @( 'PublicIP' @@ -12,4 +11,3 @@ } } } - diff --git a/src/PublicIP/private/common.ps1 b/src/private/common.ps1 similarity index 100% rename from src/PublicIP/private/common.ps1 rename to src/private/common.ps1 diff --git a/src/PublicIP/public/Get-PublicIP.ps1 b/src/public/Get-PublicIP.ps1 similarity index 100% rename from src/PublicIP/public/Get-PublicIP.ps1 rename to src/public/Get-PublicIP.ps1