From 09f6f1e24fdff136592055adb0f197742c05c318 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 16 Feb 2025 20:59:09 +0100 Subject: [PATCH 01/49] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Remove=20unused?= =?UTF-8?q?=20module=20artifact=20input=20and=20upload=20step=20from=20act?= =?UTF-8?q?ion.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/action.yml b/action.yml index cb7314c..4cfdb8f 100644 --- a/action.yml +++ b/action.yml @@ -17,10 +17,6 @@ inputs: description: Path to the folder where the built modules are outputted. required: false default: outputs/modules - ModuleArtifactName: - description: Name of the module artifact to upload. - required: false - default: module Debug: description: Enable debug output. required: false @@ -54,11 +50,3 @@ runs: Script: | # Build-PSModule ${{ github.action_path }}\scripts\main.ps1 - - - name: Upload module artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ inputs.ModuleArtifactName }} - path: ${{ inputs.ModulesOutputPath }} - if-no-files-found: error - retention-days: 1 From b8e7877197325234660ca0481512881db1453f9d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 16 Feb 2025 21:00:51 +0100 Subject: [PATCH 02/49] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Remove=20`Modul?= =?UTF-8?q?eArtifactName`=20from=20workflow=20and=20documentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 1 - README.md | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 38a0954..bfd8e78 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -51,4 +51,3 @@ jobs: Name: PSModuleTest Path: tests/srcWithManifest ModulesOutputPath: tests/outputs/modules - ModuleArtifactName: moduleWithManifest diff --git a/README.md b/README.md index a504324..21e836b 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,6 @@ This step lets you add custom build logic to process or modify the module conten | `Name` | Name of the module to process. | `false` | | | `Path` | Path to the folder where the modules are located. | `false` | `src` | | `ModulesOutputPath` | Path to the folder where the built modules are outputted. | `false` | `outputs/modules` | -| `ModuleArtifactName` | Name of the module artifact to upload. | `false` | `module` | | `Debug` | Enable debug output. | `false` | `'false'` | | `Verbose` | Enable verbose output. | `false` | `'false'` | | `Version` | Specifies the version of the GitHub module to be installed. The value must be an exact version. | `false` | | From 0f421df36b73985fcf0869c23db42a49b208bd10 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 16 Feb 2025 21:07:16 +0100 Subject: [PATCH 03/49] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20OutputTyp?= =?UTF-8?q?e=20attribute=20to=20Build-PSModule=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build-PSModule.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/helpers/Build-PSModule.ps1 b/scripts/helpers/Build-PSModule.ps1 index ef5c67c..1df5e32 100644 --- a/scripts/helpers/Build-PSModule.ps1 +++ b/scripts/helpers/Build-PSModule.ps1 @@ -6,6 +6,7 @@ .DESCRIPTION Builds a module. #> + [OutputType([void])] [CmdletBinding()] #Requires -Modules @{ ModuleName = 'GitHub'; ModuleVersion = '0.13.2' } #Requires -Modules @{ ModuleName = 'Utilities'; ModuleVersion = '0.3.0' } From 1999d046d03f7c5b8738d49f4db08fe32d817b1d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 16 Feb 2025 21:18:04 +0100 Subject: [PATCH 04/49] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Ensure=20script?= =?UTF-8?q?=20exits=20cleanly=20after=20module=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index d831ebe..138fb24 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -52,3 +52,5 @@ $params = @{ } Build-PSModule @params + +exit 0 From dbe6e5f350cf00e241e939dc20f2771201b41fb9 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 24 Feb 2025 03:56:08 +0100 Subject: [PATCH 05/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20inp?= =?UTF-8?q?ut=20parameters=20and=20paths=20in=20action.yml=20and=20scripts?= =?UTF-8?q?=20for=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 21 ++++++++++++--------- scripts/helpers/Build-PSModule.ps1 | 12 +++--------- scripts/main.ps1 | 27 +++++++++++++-------------- 3 files changed, 28 insertions(+), 32 deletions(-) diff --git a/action.yml b/action.yml index 4cfdb8f..cf3ce66 100644 --- a/action.yml +++ b/action.yml @@ -12,11 +12,7 @@ inputs: Path: description: Path to the folder where the modules are located. required: false - default: src - ModulesOutputPath: - description: Path to the folder where the built modules are outputted. - required: false - default: outputs/modules + default: ${{ github.workspace }} Debug: description: Enable debug output. required: false @@ -36,12 +32,19 @@ inputs: runs: using: composite steps: + - name: Initialize environment + uses: PSModule/Initialize-PSModule@v1 + with: + Debug: ${{ inputs.Debug }} + Prerelease: ${{ inputs.Prerelease }} + Verbose: ${{ inputs.Verbose }} + Version: ${{ inputs.Version }} + - name: Run Build-PSModule uses: PSModule/GitHub-Script@v1 env: - GITHUB_ACTION_INPUT_Name: ${{ inputs.Name }} - GITHUB_ACTION_INPUT_Path: ${{ inputs.Path }} - GITHUB_ACTION_INPUT_ModulesOutputPath: ${{ inputs.ModulesOutputPath }} + PSMODULE_BUILD_PSMODULE_INPUT_Name: ${{ inputs.Name }} + PSMODULE_BUILD_PSMODULE_INPUT_Path: ${{ inputs.Path }} with: Debug: ${{ inputs.Debug }} Prerelease: ${{ inputs.Prerelease }} @@ -49,4 +52,4 @@ runs: Version: ${{ inputs.Version }} Script: | # Build-PSModule - ${{ github.action_path }}\scripts\main.ps1 + ${{ github.action_path }}/scripts/main.ps1 diff --git a/scripts/helpers/Build-PSModule.ps1 b/scripts/helpers/Build-PSModule.ps1 index 1df5e32..6f82e0e 100644 --- a/scripts/helpers/Build-PSModule.ps1 +++ b/scripts/helpers/Build-PSModule.ps1 @@ -29,26 +29,20 @@ # Path to the folder where the built modules are outputted. [Parameter(Mandatory)] - [string] $ModulesOutputFolderPath + [string] $ModuleOutputFolderPath ) LogGroup "Building module [$ModuleName]" { - Write-Host "Source path: [$ModuleSourceFolderPath]" - if (-not (Test-Path -Path $ModuleSourceFolderPath)) { - Write-Error "Source folder not found at [$ModuleSourceFolderPath]" - exit 1 - } $moduleSourceFolder = Get-Item -Path $ModuleSourceFolderPath Write-Host "Module source folder: [$moduleSourceFolder]" - - $moduleOutputFolder = New-Item -Path $ModulesOutputFolderPath -Name $ModuleName -ItemType Directory -Force + $moduleOutputFolder = New-Item -Path $ModuleOutputFolderPath -Name $ModuleName -ItemType Directory -Force Write-Host "Module output folder: [$moduleOutputFolder]" } Build-PSModuleBase -ModuleName $ModuleName -ModuleSourceFolder $moduleSourceFolder -ModuleOutputFolder $moduleOutputFolder Build-PSModuleManifest -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder Build-PSModuleRootModule -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder - Update-PSModuleManifestAliasesToExport -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder + Update-PSModuleManifestAliasesToExport -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder # TODO: Use AST to find aliases to export. LogGroup 'Build manifest file - Final Result' { $outputManifestPath = Join-Path -Path $ModuleOutputFolder -ChildPath "$ModuleName.psd1" diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 138fb24..0385f03 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -16,20 +16,20 @@ LogGroup "Loading helper scripts from [$path]" { } LogGroup 'Loading inputs' { - $moduleName = ($env:GITHUB_ACTION_INPUT_Name | IsNullOrEmpty) ? $env:GITHUB_REPOSITORY_NAME : $env:GITHUB_ACTION_INPUT_Name + $moduleName = if ([string]::IsNullOrEmpty($env:PSMODULE_BUILD_PSMODULE_INPUT_Name)) { + $env:GITHUB_REPOSITORY_NAME + } else { + $env:PSMODULE_BUILD_PSMODULE_INPUT_Name + } Write-Host "Module name: [$moduleName]" - $moduleSourceFolderPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath $env:GITHUB_ACTION_INPUT_Path/$moduleName - if (-not (Test-Path -Path $moduleSourceFolderPath)) { - $moduleSourceFolderPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath $env:GITHUB_ACTION_INPUT_Path - } - Write-Host "Source module path: [$moduleSourceFolderPath]" - if (-not (Test-Path -Path $moduleSourceFolderPath)) { - throw "Module path [$moduleSourceFolderPath] does not exist." + $sourceFolderPath = Join-Path -Path $env:PSMODULE_BUILD_PSMODULE_INPUT_Path -ChildPath 'src' + if (-not (Test-Path -Path $sourceFolderPath)) { + throw "Source folder path [$sourceFolderPath] does not exist." } - $modulesOutputFolderPath = Join-Path $env:GITHUB_WORKSPACE $env:GITHUB_ACTION_INPUT_ModulesOutputPath - Write-Host "Modules output path: [$modulesOutputFolderPath]" + $moduleOutputFolderPath = Join-Path $env:PSMODULE_BUILD_PSMODULE_INPUT_Path -ChildPath 'outputs/module' + Write-Host "Modules output path: [$moduleOutputFolderPath]" } LogGroup 'Build local scripts' { @@ -46,11 +46,10 @@ LogGroup 'Build local scripts' { } $params = @{ - ModuleName = $moduleName - ModuleSourceFolderPath = $moduleSourceFolderPath - ModulesOutputFolderPath = $modulesOutputFolderPath + ModuleName = $moduleName + ModuleSourceFolderPath = $sourceFolderPath + ModuleOutputFolderPath = $moduleOutputFolderPath } - Build-PSModule @params exit 0 From 48b0c502eaaa20b8e991b4df49ff7d279f155a06 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 24 Feb 2025 12:08:06 +0100 Subject: [PATCH 06/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Remove=20unu?= =?UTF-8?q?sed=20input=20parameters=20and=20clean=20up=20workflow=20steps?= =?UTF-8?q?=20in=20Action-Test.yml=20and=20action.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 4 ---- action.yml | 8 -------- 2 files changed, 12 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 6cdcd52..9dc22b2 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -33,7 +33,6 @@ jobs: with: Name: PSModuleTest Path: tests/src - ModulesOutputPath: tests/outputs/modules ActionTestMinimal: name: Action-Test - [Minimal] @@ -50,8 +49,6 @@ jobs: with: Name: PSModuleTest Path: tests/srcMinimal - ModulesOutputPath: tests/outputs/modules - ModuleArtifactName: moduleMinimal ActionTestWithManifest: name: Action-Test - [DefaultWithManifest] @@ -68,4 +65,3 @@ jobs: with: Name: PSModuleTest Path: tests/srcWithManifest - ModulesOutputPath: tests/outputs/modules diff --git a/action.yml b/action.yml index cf3ce66..adfcf1c 100644 --- a/action.yml +++ b/action.yml @@ -32,14 +32,6 @@ inputs: runs: using: composite steps: - - name: Initialize environment - uses: PSModule/Initialize-PSModule@v1 - with: - Debug: ${{ inputs.Debug }} - Prerelease: ${{ inputs.Prerelease }} - Verbose: ${{ inputs.Verbose }} - Version: ${{ inputs.Version }} - - name: Run Build-PSModule uses: PSModule/GitHub-Script@v1 env: From 3ad464641b7c4b7dc5a69ca07e8fb575385d4b33 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 24 Feb 2025 12:12:24 +0100 Subject: [PATCH 07/49] =?UTF-8?q?=F0=9F=A9=B9=20[Add]:=20Introduce=20new?= =?UTF-8?q?=20assemblies,=20configuration,=20and=20settings=20files=20for?= =?UTF-8?q?=20testing=20modules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/functions/public/Test-PSModuleTest.ps1 | 0 tests/{ => srcTestRepo}/src/assemblies/LsonLib.dll | Bin .../src/classes/private/SecretWriter.ps1 | 0 tests/{ => srcTestRepo}/src/classes/public/Book.ps1 | 0 tests/{ => srcTestRepo}/src/data/Config.psd1 | 0 tests/{ => srcTestRepo}/src/data/Settings.psd1 | 0 tests/{ => srcTestRepo}/src/finally.ps1 | 0 .../src/formats/CultureInfo.Format.ps1xml | 0 .../src/formats/Mygciview.Format.ps1xml | 0 .../src/functions/private/Get-InternalPSModule.ps1 | 0 .../src/functions/private/Set-InternalPSModule.ps1 | 0 .../functions/public/PSModule/Get-PSModuleTest.ps1 | 0 .../functions/public/PSModule/New-PSModuleTest.ps1 | 0 .../src/functions/public/PSModule/PSModule.md | 0 .../public/SomethingElse/Set-PSModuleTest.ps1 | 0 .../functions/public/SomethingElse/SomethingElse.md | 0 .../src}/functions/public/Test-PSModuleTest.ps1 | 0 tests/{ => srcTestRepo}/src/header.ps1 | 0 tests/{ => srcTestRepo}/src/init/initializer.ps1 | 0 .../src/modules/OtherPSModule.psm1 | 0 tests/{ => srcTestRepo}/src/scripts/loader.ps1 | 0 .../src/types/DirectoryInfo.Types.ps1xml | 0 .../src/types/FileInfo.Types.ps1xml | 0 .../src/variables/private/PrivateVariables.ps1 | 0 .../src/variables/public/Moons.ps1 | 0 .../src/variables/public/Planets.ps1 | 0 .../src/variables/public/SolarSystems.ps1 | 0 .../src}/assemblies/LsonLib.dll | Bin .../src}/data/Config.psd1 | 0 .../src}/data/Settings.psd1 | 0 .../src}/finally.ps1 | 0 .../src}/formats/CultureInfo.Format.ps1xml | 0 .../src}/formats/Mygciview.Format.ps1xml | 0 .../src}/functions/private/Get-InternalPSModule.ps1 | 0 .../src}/functions/private/Set-InternalPSModule.ps1 | 0 .../functions/public/PSModule/Get-PSModuleTest.ps1 | 0 .../functions/public/PSModule/New-PSModuleTest.ps1 | 0 .../src}/functions/public/PSModule/PSModule.md | 0 .../public/SomethingElse/Set-PSModuleTest.ps1 | 0 .../functions/public/SomethingElse/SomethingElse.md | 0 .../src}/functions/public/Test-PSModuleTest.ps1 | 0 .../src}/header.ps1 | 0 .../src}/init/initializer.ps1 | 0 .../src}/manifest.psd1 | 0 .../src}/modules/OtherPSModule.psm1 | 0 .../src}/scripts/loader.ps1 | 0 .../src}/types/DirectoryInfo.Types.ps1xml | 0 .../src}/types/FileInfo.Types.ps1xml | 0 .../src}/variables/private/PrivateVariables.ps1 | 0 .../src}/variables/public/Moons.ps1 | 0 .../src}/variables/public/Planets.ps1 | 0 .../src}/variables/public/SolarSystems.ps1 | 0 52 files changed, 0 insertions(+), 0 deletions(-) rename tests/{ => srcMinimalTestRepo}/src/functions/public/Test-PSModuleTest.ps1 (100%) rename tests/{ => srcTestRepo}/src/assemblies/LsonLib.dll (100%) rename tests/{ => srcTestRepo}/src/classes/private/SecretWriter.ps1 (100%) rename tests/{ => srcTestRepo}/src/classes/public/Book.ps1 (100%) rename tests/{ => srcTestRepo}/src/data/Config.psd1 (100%) rename tests/{ => srcTestRepo}/src/data/Settings.psd1 (100%) rename tests/{ => srcTestRepo}/src/finally.ps1 (100%) rename tests/{ => srcTestRepo}/src/formats/CultureInfo.Format.ps1xml (100%) rename tests/{ => srcTestRepo}/src/formats/Mygciview.Format.ps1xml (100%) rename tests/{ => srcTestRepo}/src/functions/private/Get-InternalPSModule.ps1 (100%) rename tests/{ => srcTestRepo}/src/functions/private/Set-InternalPSModule.ps1 (100%) rename tests/{ => srcTestRepo}/src/functions/public/PSModule/Get-PSModuleTest.ps1 (100%) rename tests/{ => srcTestRepo}/src/functions/public/PSModule/New-PSModuleTest.ps1 (100%) rename tests/{ => srcTestRepo}/src/functions/public/PSModule/PSModule.md (100%) rename tests/{ => srcTestRepo}/src/functions/public/SomethingElse/Set-PSModuleTest.ps1 (100%) rename tests/{ => srcTestRepo}/src/functions/public/SomethingElse/SomethingElse.md (100%) rename tests/{srcMinimal => srcTestRepo/src}/functions/public/Test-PSModuleTest.ps1 (100%) rename tests/{ => srcTestRepo}/src/header.ps1 (100%) rename tests/{ => srcTestRepo}/src/init/initializer.ps1 (100%) rename tests/{ => srcTestRepo}/src/modules/OtherPSModule.psm1 (100%) rename tests/{ => srcTestRepo}/src/scripts/loader.ps1 (100%) rename tests/{ => srcTestRepo}/src/types/DirectoryInfo.Types.ps1xml (100%) rename tests/{ => srcTestRepo}/src/types/FileInfo.Types.ps1xml (100%) rename tests/{ => srcTestRepo}/src/variables/private/PrivateVariables.ps1 (100%) rename tests/{ => srcTestRepo}/src/variables/public/Moons.ps1 (100%) rename tests/{ => srcTestRepo}/src/variables/public/Planets.ps1 (100%) rename tests/{ => srcTestRepo}/src/variables/public/SolarSystems.ps1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/assemblies/LsonLib.dll (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/data/Config.psd1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/data/Settings.psd1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/finally.ps1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/formats/CultureInfo.Format.ps1xml (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/formats/Mygciview.Format.ps1xml (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/functions/private/Get-InternalPSModule.ps1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/functions/private/Set-InternalPSModule.ps1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/functions/public/PSModule/Get-PSModuleTest.ps1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/functions/public/PSModule/New-PSModuleTest.ps1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/functions/public/PSModule/PSModule.md (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/functions/public/SomethingElse/Set-PSModuleTest.ps1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/functions/public/SomethingElse/SomethingElse.md (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/functions/public/Test-PSModuleTest.ps1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/header.ps1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/init/initializer.ps1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/manifest.psd1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/modules/OtherPSModule.psm1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/scripts/loader.ps1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/types/DirectoryInfo.Types.ps1xml (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/types/FileInfo.Types.ps1xml (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/variables/private/PrivateVariables.ps1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/variables/public/Moons.ps1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/variables/public/Planets.ps1 (100%) rename tests/{srcWithManifest => srcWithManifestTestRepo/src}/variables/public/SolarSystems.ps1 (100%) diff --git a/tests/src/functions/public/Test-PSModuleTest.ps1 b/tests/srcMinimalTestRepo/src/functions/public/Test-PSModuleTest.ps1 similarity index 100% rename from tests/src/functions/public/Test-PSModuleTest.ps1 rename to tests/srcMinimalTestRepo/src/functions/public/Test-PSModuleTest.ps1 diff --git a/tests/src/assemblies/LsonLib.dll b/tests/srcTestRepo/src/assemblies/LsonLib.dll similarity index 100% rename from tests/src/assemblies/LsonLib.dll rename to tests/srcTestRepo/src/assemblies/LsonLib.dll diff --git a/tests/src/classes/private/SecretWriter.ps1 b/tests/srcTestRepo/src/classes/private/SecretWriter.ps1 similarity index 100% rename from tests/src/classes/private/SecretWriter.ps1 rename to tests/srcTestRepo/src/classes/private/SecretWriter.ps1 diff --git a/tests/src/classes/public/Book.ps1 b/tests/srcTestRepo/src/classes/public/Book.ps1 similarity index 100% rename from tests/src/classes/public/Book.ps1 rename to tests/srcTestRepo/src/classes/public/Book.ps1 diff --git a/tests/src/data/Config.psd1 b/tests/srcTestRepo/src/data/Config.psd1 similarity index 100% rename from tests/src/data/Config.psd1 rename to tests/srcTestRepo/src/data/Config.psd1 diff --git a/tests/src/data/Settings.psd1 b/tests/srcTestRepo/src/data/Settings.psd1 similarity index 100% rename from tests/src/data/Settings.psd1 rename to tests/srcTestRepo/src/data/Settings.psd1 diff --git a/tests/src/finally.ps1 b/tests/srcTestRepo/src/finally.ps1 similarity index 100% rename from tests/src/finally.ps1 rename to tests/srcTestRepo/src/finally.ps1 diff --git a/tests/src/formats/CultureInfo.Format.ps1xml b/tests/srcTestRepo/src/formats/CultureInfo.Format.ps1xml similarity index 100% rename from tests/src/formats/CultureInfo.Format.ps1xml rename to tests/srcTestRepo/src/formats/CultureInfo.Format.ps1xml diff --git a/tests/src/formats/Mygciview.Format.ps1xml b/tests/srcTestRepo/src/formats/Mygciview.Format.ps1xml similarity index 100% rename from tests/src/formats/Mygciview.Format.ps1xml rename to tests/srcTestRepo/src/formats/Mygciview.Format.ps1xml diff --git a/tests/src/functions/private/Get-InternalPSModule.ps1 b/tests/srcTestRepo/src/functions/private/Get-InternalPSModule.ps1 similarity index 100% rename from tests/src/functions/private/Get-InternalPSModule.ps1 rename to tests/srcTestRepo/src/functions/private/Get-InternalPSModule.ps1 diff --git a/tests/src/functions/private/Set-InternalPSModule.ps1 b/tests/srcTestRepo/src/functions/private/Set-InternalPSModule.ps1 similarity index 100% rename from tests/src/functions/private/Set-InternalPSModule.ps1 rename to tests/srcTestRepo/src/functions/private/Set-InternalPSModule.ps1 diff --git a/tests/src/functions/public/PSModule/Get-PSModuleTest.ps1 b/tests/srcTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 similarity index 100% rename from tests/src/functions/public/PSModule/Get-PSModuleTest.ps1 rename to tests/srcTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 diff --git a/tests/src/functions/public/PSModule/New-PSModuleTest.ps1 b/tests/srcTestRepo/src/functions/public/PSModule/New-PSModuleTest.ps1 similarity index 100% rename from tests/src/functions/public/PSModule/New-PSModuleTest.ps1 rename to tests/srcTestRepo/src/functions/public/PSModule/New-PSModuleTest.ps1 diff --git a/tests/src/functions/public/PSModule/PSModule.md b/tests/srcTestRepo/src/functions/public/PSModule/PSModule.md similarity index 100% rename from tests/src/functions/public/PSModule/PSModule.md rename to tests/srcTestRepo/src/functions/public/PSModule/PSModule.md diff --git a/tests/src/functions/public/SomethingElse/Set-PSModuleTest.ps1 b/tests/srcTestRepo/src/functions/public/SomethingElse/Set-PSModuleTest.ps1 similarity index 100% rename from tests/src/functions/public/SomethingElse/Set-PSModuleTest.ps1 rename to tests/srcTestRepo/src/functions/public/SomethingElse/Set-PSModuleTest.ps1 diff --git a/tests/src/functions/public/SomethingElse/SomethingElse.md b/tests/srcTestRepo/src/functions/public/SomethingElse/SomethingElse.md similarity index 100% rename from tests/src/functions/public/SomethingElse/SomethingElse.md rename to tests/srcTestRepo/src/functions/public/SomethingElse/SomethingElse.md diff --git a/tests/srcMinimal/functions/public/Test-PSModuleTest.ps1 b/tests/srcTestRepo/src/functions/public/Test-PSModuleTest.ps1 similarity index 100% rename from tests/srcMinimal/functions/public/Test-PSModuleTest.ps1 rename to tests/srcTestRepo/src/functions/public/Test-PSModuleTest.ps1 diff --git a/tests/src/header.ps1 b/tests/srcTestRepo/src/header.ps1 similarity index 100% rename from tests/src/header.ps1 rename to tests/srcTestRepo/src/header.ps1 diff --git a/tests/src/init/initializer.ps1 b/tests/srcTestRepo/src/init/initializer.ps1 similarity index 100% rename from tests/src/init/initializer.ps1 rename to tests/srcTestRepo/src/init/initializer.ps1 diff --git a/tests/src/modules/OtherPSModule.psm1 b/tests/srcTestRepo/src/modules/OtherPSModule.psm1 similarity index 100% rename from tests/src/modules/OtherPSModule.psm1 rename to tests/srcTestRepo/src/modules/OtherPSModule.psm1 diff --git a/tests/src/scripts/loader.ps1 b/tests/srcTestRepo/src/scripts/loader.ps1 similarity index 100% rename from tests/src/scripts/loader.ps1 rename to tests/srcTestRepo/src/scripts/loader.ps1 diff --git a/tests/src/types/DirectoryInfo.Types.ps1xml b/tests/srcTestRepo/src/types/DirectoryInfo.Types.ps1xml similarity index 100% rename from tests/src/types/DirectoryInfo.Types.ps1xml rename to tests/srcTestRepo/src/types/DirectoryInfo.Types.ps1xml diff --git a/tests/src/types/FileInfo.Types.ps1xml b/tests/srcTestRepo/src/types/FileInfo.Types.ps1xml similarity index 100% rename from tests/src/types/FileInfo.Types.ps1xml rename to tests/srcTestRepo/src/types/FileInfo.Types.ps1xml diff --git a/tests/src/variables/private/PrivateVariables.ps1 b/tests/srcTestRepo/src/variables/private/PrivateVariables.ps1 similarity index 100% rename from tests/src/variables/private/PrivateVariables.ps1 rename to tests/srcTestRepo/src/variables/private/PrivateVariables.ps1 diff --git a/tests/src/variables/public/Moons.ps1 b/tests/srcTestRepo/src/variables/public/Moons.ps1 similarity index 100% rename from tests/src/variables/public/Moons.ps1 rename to tests/srcTestRepo/src/variables/public/Moons.ps1 diff --git a/tests/src/variables/public/Planets.ps1 b/tests/srcTestRepo/src/variables/public/Planets.ps1 similarity index 100% rename from tests/src/variables/public/Planets.ps1 rename to tests/srcTestRepo/src/variables/public/Planets.ps1 diff --git a/tests/src/variables/public/SolarSystems.ps1 b/tests/srcTestRepo/src/variables/public/SolarSystems.ps1 similarity index 100% rename from tests/src/variables/public/SolarSystems.ps1 rename to tests/srcTestRepo/src/variables/public/SolarSystems.ps1 diff --git a/tests/srcWithManifest/assemblies/LsonLib.dll b/tests/srcWithManifestTestRepo/src/assemblies/LsonLib.dll similarity index 100% rename from tests/srcWithManifest/assemblies/LsonLib.dll rename to tests/srcWithManifestTestRepo/src/assemblies/LsonLib.dll diff --git a/tests/srcWithManifest/data/Config.psd1 b/tests/srcWithManifestTestRepo/src/data/Config.psd1 similarity index 100% rename from tests/srcWithManifest/data/Config.psd1 rename to tests/srcWithManifestTestRepo/src/data/Config.psd1 diff --git a/tests/srcWithManifest/data/Settings.psd1 b/tests/srcWithManifestTestRepo/src/data/Settings.psd1 similarity index 100% rename from tests/srcWithManifest/data/Settings.psd1 rename to tests/srcWithManifestTestRepo/src/data/Settings.psd1 diff --git a/tests/srcWithManifest/finally.ps1 b/tests/srcWithManifestTestRepo/src/finally.ps1 similarity index 100% rename from tests/srcWithManifest/finally.ps1 rename to tests/srcWithManifestTestRepo/src/finally.ps1 diff --git a/tests/srcWithManifest/formats/CultureInfo.Format.ps1xml b/tests/srcWithManifestTestRepo/src/formats/CultureInfo.Format.ps1xml similarity index 100% rename from tests/srcWithManifest/formats/CultureInfo.Format.ps1xml rename to tests/srcWithManifestTestRepo/src/formats/CultureInfo.Format.ps1xml diff --git a/tests/srcWithManifest/formats/Mygciview.Format.ps1xml b/tests/srcWithManifestTestRepo/src/formats/Mygciview.Format.ps1xml similarity index 100% rename from tests/srcWithManifest/formats/Mygciview.Format.ps1xml rename to tests/srcWithManifestTestRepo/src/formats/Mygciview.Format.ps1xml diff --git a/tests/srcWithManifest/functions/private/Get-InternalPSModule.ps1 b/tests/srcWithManifestTestRepo/src/functions/private/Get-InternalPSModule.ps1 similarity index 100% rename from tests/srcWithManifest/functions/private/Get-InternalPSModule.ps1 rename to tests/srcWithManifestTestRepo/src/functions/private/Get-InternalPSModule.ps1 diff --git a/tests/srcWithManifest/functions/private/Set-InternalPSModule.ps1 b/tests/srcWithManifestTestRepo/src/functions/private/Set-InternalPSModule.ps1 similarity index 100% rename from tests/srcWithManifest/functions/private/Set-InternalPSModule.ps1 rename to tests/srcWithManifestTestRepo/src/functions/private/Set-InternalPSModule.ps1 diff --git a/tests/srcWithManifest/functions/public/PSModule/Get-PSModuleTest.ps1 b/tests/srcWithManifestTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 similarity index 100% rename from tests/srcWithManifest/functions/public/PSModule/Get-PSModuleTest.ps1 rename to tests/srcWithManifestTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 diff --git a/tests/srcWithManifest/functions/public/PSModule/New-PSModuleTest.ps1 b/tests/srcWithManifestTestRepo/src/functions/public/PSModule/New-PSModuleTest.ps1 similarity index 100% rename from tests/srcWithManifest/functions/public/PSModule/New-PSModuleTest.ps1 rename to tests/srcWithManifestTestRepo/src/functions/public/PSModule/New-PSModuleTest.ps1 diff --git a/tests/srcWithManifest/functions/public/PSModule/PSModule.md b/tests/srcWithManifestTestRepo/src/functions/public/PSModule/PSModule.md similarity index 100% rename from tests/srcWithManifest/functions/public/PSModule/PSModule.md rename to tests/srcWithManifestTestRepo/src/functions/public/PSModule/PSModule.md diff --git a/tests/srcWithManifest/functions/public/SomethingElse/Set-PSModuleTest.ps1 b/tests/srcWithManifestTestRepo/src/functions/public/SomethingElse/Set-PSModuleTest.ps1 similarity index 100% rename from tests/srcWithManifest/functions/public/SomethingElse/Set-PSModuleTest.ps1 rename to tests/srcWithManifestTestRepo/src/functions/public/SomethingElse/Set-PSModuleTest.ps1 diff --git a/tests/srcWithManifest/functions/public/SomethingElse/SomethingElse.md b/tests/srcWithManifestTestRepo/src/functions/public/SomethingElse/SomethingElse.md similarity index 100% rename from tests/srcWithManifest/functions/public/SomethingElse/SomethingElse.md rename to tests/srcWithManifestTestRepo/src/functions/public/SomethingElse/SomethingElse.md diff --git a/tests/srcWithManifest/functions/public/Test-PSModuleTest.ps1 b/tests/srcWithManifestTestRepo/src/functions/public/Test-PSModuleTest.ps1 similarity index 100% rename from tests/srcWithManifest/functions/public/Test-PSModuleTest.ps1 rename to tests/srcWithManifestTestRepo/src/functions/public/Test-PSModuleTest.ps1 diff --git a/tests/srcWithManifest/header.ps1 b/tests/srcWithManifestTestRepo/src/header.ps1 similarity index 100% rename from tests/srcWithManifest/header.ps1 rename to tests/srcWithManifestTestRepo/src/header.ps1 diff --git a/tests/srcWithManifest/init/initializer.ps1 b/tests/srcWithManifestTestRepo/src/init/initializer.ps1 similarity index 100% rename from tests/srcWithManifest/init/initializer.ps1 rename to tests/srcWithManifestTestRepo/src/init/initializer.ps1 diff --git a/tests/srcWithManifest/manifest.psd1 b/tests/srcWithManifestTestRepo/src/manifest.psd1 similarity index 100% rename from tests/srcWithManifest/manifest.psd1 rename to tests/srcWithManifestTestRepo/src/manifest.psd1 diff --git a/tests/srcWithManifest/modules/OtherPSModule.psm1 b/tests/srcWithManifestTestRepo/src/modules/OtherPSModule.psm1 similarity index 100% rename from tests/srcWithManifest/modules/OtherPSModule.psm1 rename to tests/srcWithManifestTestRepo/src/modules/OtherPSModule.psm1 diff --git a/tests/srcWithManifest/scripts/loader.ps1 b/tests/srcWithManifestTestRepo/src/scripts/loader.ps1 similarity index 100% rename from tests/srcWithManifest/scripts/loader.ps1 rename to tests/srcWithManifestTestRepo/src/scripts/loader.ps1 diff --git a/tests/srcWithManifest/types/DirectoryInfo.Types.ps1xml b/tests/srcWithManifestTestRepo/src/types/DirectoryInfo.Types.ps1xml similarity index 100% rename from tests/srcWithManifest/types/DirectoryInfo.Types.ps1xml rename to tests/srcWithManifestTestRepo/src/types/DirectoryInfo.Types.ps1xml diff --git a/tests/srcWithManifest/types/FileInfo.Types.ps1xml b/tests/srcWithManifestTestRepo/src/types/FileInfo.Types.ps1xml similarity index 100% rename from tests/srcWithManifest/types/FileInfo.Types.ps1xml rename to tests/srcWithManifestTestRepo/src/types/FileInfo.Types.ps1xml diff --git a/tests/srcWithManifest/variables/private/PrivateVariables.ps1 b/tests/srcWithManifestTestRepo/src/variables/private/PrivateVariables.ps1 similarity index 100% rename from tests/srcWithManifest/variables/private/PrivateVariables.ps1 rename to tests/srcWithManifestTestRepo/src/variables/private/PrivateVariables.ps1 diff --git a/tests/srcWithManifest/variables/public/Moons.ps1 b/tests/srcWithManifestTestRepo/src/variables/public/Moons.ps1 similarity index 100% rename from tests/srcWithManifest/variables/public/Moons.ps1 rename to tests/srcWithManifestTestRepo/src/variables/public/Moons.ps1 diff --git a/tests/srcWithManifest/variables/public/Planets.ps1 b/tests/srcWithManifestTestRepo/src/variables/public/Planets.ps1 similarity index 100% rename from tests/srcWithManifest/variables/public/Planets.ps1 rename to tests/srcWithManifestTestRepo/src/variables/public/Planets.ps1 diff --git a/tests/srcWithManifest/variables/public/SolarSystems.ps1 b/tests/srcWithManifestTestRepo/src/variables/public/SolarSystems.ps1 similarity index 100% rename from tests/srcWithManifest/variables/public/SolarSystems.ps1 rename to tests/srcWithManifestTestRepo/src/variables/public/SolarSystems.ps1 From 6015376cc6b11bbd0df05331efa3a802531f01f9 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 24 Feb 2025 12:19:12 +0100 Subject: [PATCH 08/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20tes?= =?UTF-8?q?t=20paths=20in=20Action-Test.yml=20for=20consistency=20and=20cl?= =?UTF-8?q?arity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 9dc22b2..1c8c83d 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -32,7 +32,7 @@ jobs: uses: ./ with: Name: PSModuleTest - Path: tests/src + Path: tests/srcTestRepo ActionTestMinimal: name: Action-Test - [Minimal] @@ -48,7 +48,7 @@ jobs: uses: ./ with: Name: PSModuleTest - Path: tests/srcMinimal + Path: tests/srcMinimalTestRepo ActionTestWithManifest: name: Action-Test - [DefaultWithManifest] @@ -64,4 +64,4 @@ jobs: uses: ./ with: Name: PSModuleTest - Path: tests/srcWithManifest + Path: tests/srcWithManifestTestRepo From b305ae4ec9577abb8d1a0f026afa71b2a59574f8 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 24 Feb 2025 12:35:54 +0100 Subject: [PATCH 09/49] =?UTF-8?q?=F0=9F=A9=B9=20[Add]:=20Implement=20artif?= =?UTF-8?q?act=20upload=20step=20and=20set=20GitHub=20output=20for=20modul?= =?UTF-8?q?e=20name=20in=20action=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 9 +++++++++ scripts/main.ps1 | 1 + 2 files changed, 10 insertions(+) diff --git a/action.yml b/action.yml index adfcf1c..b2797aa 100644 --- a/action.yml +++ b/action.yml @@ -34,6 +34,7 @@ runs: steps: - name: Run Build-PSModule uses: PSModule/GitHub-Script@v1 + id: build env: PSMODULE_BUILD_PSMODULE_INPUT_Name: ${{ inputs.Name }} PSMODULE_BUILD_PSMODULE_INPUT_Path: ${{ inputs.Path }} @@ -45,3 +46,11 @@ runs: Script: | # Build-PSModule ${{ github.action_path }}/scripts/main.ps1 + + - name: Upload module artifact + uses: actions/upload-artifact@v4 + with: + name: module + path: outputs/module/${{ fromJson(steps.build.outputs.result).ModuleName }} + if-no-files-found: error + retention-days: 1 diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 0385f03..6173057 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -22,6 +22,7 @@ LogGroup 'Loading inputs' { $env:PSMODULE_BUILD_PSMODULE_INPUT_Name } Write-Host "Module name: [$moduleName]" + Set-GitHubOutput -Name ModuleName -Value $moduleName $sourceFolderPath = Join-Path -Path $env:PSMODULE_BUILD_PSMODULE_INPUT_Path -ChildPath 'src' if (-not (Test-Path -Path $sourceFolderPath)) { From 992139794a9053857411faa87f3cb52ef58dff83 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 24 Feb 2025 12:39:44 +0100 Subject: [PATCH 10/49] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Update=20artifact?= =?UTF-8?q?=20upload=20path=20to=20use=20input=20parameter=20for=20improve?= =?UTF-8?q?d=20flexibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index b2797aa..e227f24 100644 --- a/action.yml +++ b/action.yml @@ -51,6 +51,6 @@ runs: uses: actions/upload-artifact@v4 with: name: module - path: outputs/module/${{ fromJson(steps.build.outputs.result).ModuleName }} + path: ${{ inputs.Path }}/outputs/module/${{ fromJson(steps.build.outputs.result).ModuleName }} if-no-files-found: error retention-days: 1 From 1c9f792677a3e1aa5c0c21a75c630891d918538a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 24 Feb 2025 12:43:55 +0100 Subject: [PATCH 11/49] =?UTF-8?q?=F0=9F=A9=B9=20[Add]:=20Introduce=20Artif?= =?UTF-8?q?actName=20input=20parameter=20for=20artifact=20upload=20flexibi?= =?UTF-8?q?lity=20in=20workflows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 3 +++ action.yml | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 1c8c83d..f687b89 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -33,6 +33,7 @@ jobs: with: Name: PSModuleTest Path: tests/srcTestRepo + ArtifactName: PSModuleTestDefault ActionTestMinimal: name: Action-Test - [Minimal] @@ -49,6 +50,7 @@ jobs: with: Name: PSModuleTest Path: tests/srcMinimalTestRepo + ArtifactName: PSModuleTestMinimal ActionTestWithManifest: name: Action-Test - [DefaultWithManifest] @@ -65,3 +67,4 @@ jobs: with: Name: PSModuleTest Path: tests/srcWithManifestTestRepo + ArtifactName: PSModuleTestWithManifest diff --git a/action.yml b/action.yml index e227f24..191c9c3 100644 --- a/action.yml +++ b/action.yml @@ -13,6 +13,10 @@ inputs: description: Path to the folder where the modules are located. required: false default: ${{ github.workspace }} + ArtifactName: + description: Name of the artifact to upload. + required: false + default: 'module' Debug: description: Enable debug output. required: false @@ -50,7 +54,7 @@ runs: - name: Upload module artifact uses: actions/upload-artifact@v4 with: - name: module + name: ${{ input.ArtifactName }} path: ${{ inputs.Path }}/outputs/module/${{ fromJson(steps.build.outputs.result).ModuleName }} if-no-files-found: error retention-days: 1 From 804869662974e64f327bf4ed3f394c4126ce6d34 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 24 Feb 2025 12:46:04 +0100 Subject: [PATCH 12/49] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Correct=20input?= =?UTF-8?q?=20reference=20for=20ArtifactName=20in=20action.yml=20for=20pro?= =?UTF-8?q?per=20artifact=20upload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 191c9c3..51b969e 100644 --- a/action.yml +++ b/action.yml @@ -54,7 +54,7 @@ runs: - name: Upload module artifact uses: actions/upload-artifact@v4 with: - name: ${{ input.ArtifactName }} + name: ${{ inputs.ArtifactName }} path: ${{ inputs.Path }}/outputs/module/${{ fromJson(steps.build.outputs.result).ModuleName }} if-no-files-found: error retention-days: 1 From 67afbe5f9c4a3d005e4946a66df1159879896861 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 24 Feb 2025 16:59:49 +0100 Subject: [PATCH 13/49] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Simplify=20artifa?= =?UTF-8?q?ct=20upload=20path=20in=20action.yml=20for=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 51b969e..a0e3cb0 100644 --- a/action.yml +++ b/action.yml @@ -55,6 +55,6 @@ runs: uses: actions/upload-artifact@v4 with: name: ${{ inputs.ArtifactName }} - path: ${{ inputs.Path }}/outputs/module/${{ fromJson(steps.build.outputs.result).ModuleName }} + path: ${{ inputs.Path }}/outputs/module if-no-files-found: error retention-days: 1 From bd01dd088d7a1e6de5b361f5ab44a0c54a6ab33f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 28 Feb 2025 22:05:39 +0100 Subject: [PATCH 14/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20act?= =?UTF-8?q?ion.yml=20to=20add=20WorkingDirectory=20input=20and=20streamlin?= =?UTF-8?q?e=20artifact=20path=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 14 +++++++------- scripts/helpers/Build-PSModule.ps1 | 2 +- scripts/main.ps1 | 13 +++++++------ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/action.yml b/action.yml index a0e3cb0..38f8a77 100644 --- a/action.yml +++ b/action.yml @@ -9,14 +9,10 @@ inputs: Name: description: Name of the module to process. required: false - Path: - description: Path to the folder where the modules are located. - required: false - default: ${{ github.workspace }} ArtifactName: description: Name of the artifact to upload. required: false - default: 'module' + default: module Debug: description: Enable debug output. required: false @@ -32,6 +28,10 @@ inputs: description: Allow prerelease versions if available. required: false default: 'false' + WorkingDirectory: + description: The working directory where the script will run from. + required: false + default: ${{ github.workspace }} runs: using: composite @@ -41,12 +41,12 @@ runs: id: build env: PSMODULE_BUILD_PSMODULE_INPUT_Name: ${{ inputs.Name }} - PSMODULE_BUILD_PSMODULE_INPUT_Path: ${{ inputs.Path }} with: Debug: ${{ inputs.Debug }} Prerelease: ${{ inputs.Prerelease }} Verbose: ${{ inputs.Verbose }} Version: ${{ inputs.Version }} + WorkingDirectory: ${{ inputs.WorkingDirectory }} Script: | # Build-PSModule ${{ github.action_path }}/scripts/main.ps1 @@ -55,6 +55,6 @@ runs: uses: actions/upload-artifact@v4 with: name: ${{ inputs.ArtifactName }} - path: ${{ inputs.Path }}/outputs/module + path: ${{ inputs.WorkingDirectory }}/outputs/module if-no-files-found: error retention-days: 1 diff --git a/scripts/helpers/Build-PSModule.ps1 b/scripts/helpers/Build-PSModule.ps1 index 6f82e0e..b827c6a 100644 --- a/scripts/helpers/Build-PSModule.ps1 +++ b/scripts/helpers/Build-PSModule.ps1 @@ -42,7 +42,7 @@ Build-PSModuleBase -ModuleName $ModuleName -ModuleSourceFolder $moduleSourceFolder -ModuleOutputFolder $moduleOutputFolder Build-PSModuleManifest -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder Build-PSModuleRootModule -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder - Update-PSModuleManifestAliasesToExport -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder # TODO: Use AST to find aliases to export. + Update-PSModuleManifestAliasesToExport -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder LogGroup 'Build manifest file - Final Result' { $outputManifestPath = Join-Path -Path $ModuleOutputFolder -ChildPath "$ModuleName.psd1" diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 6173057..3ca622e 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -24,13 +24,14 @@ LogGroup 'Loading inputs' { Write-Host "Module name: [$moduleName]" Set-GitHubOutput -Name ModuleName -Value $moduleName - $sourceFolderPath = Join-Path -Path $env:PSMODULE_BUILD_PSMODULE_INPUT_Path -ChildPath 'src' - if (-not (Test-Path -Path $sourceFolderPath)) { - throw "Source folder path [$sourceFolderPath] does not exist." - } - - $moduleOutputFolderPath = Join-Path $env:PSMODULE_BUILD_PSMODULE_INPUT_Path -ChildPath 'outputs/module' + $sourceFolderPath = Resolve-Path -Path 'src' | Select-Object -ExpandProperty Path + $moduleOutputFolderPath = Join-Path . -ChildPath 'outputs/module' Write-Host "Modules output path: [$moduleOutputFolderPath]" + [pscustomobject]@{ + moduleName = $moduleName + sourceFolderPath = $sourceFolderPath + moduleOutputFolderPath = $moduleOutputFolderPath + } | Format-List } LogGroup 'Build local scripts' { From 6ce338758408ff381de4e3e7acfbb6ef09facb51 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 28 Feb 2025 22:08:21 +0100 Subject: [PATCH 15/49] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Replace=20Path=20?= =?UTF-8?q?with=20WorkingDirectory=20in=20Action-Test.yml=20for=20consiste?= =?UTF-8?q?ncy=20in=20artifact=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index f687b89..67496d8 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -32,8 +32,8 @@ jobs: uses: ./ with: Name: PSModuleTest - Path: tests/srcTestRepo ArtifactName: PSModuleTestDefault + WorkingDirectory: tests/srcTestRepo ActionTestMinimal: name: Action-Test - [Minimal] @@ -49,8 +49,8 @@ jobs: uses: ./ with: Name: PSModuleTest - Path: tests/srcMinimalTestRepo ArtifactName: PSModuleTestMinimal + WorkingDirectory: tests/srcMinimalTestRepo ActionTestWithManifest: name: Action-Test - [DefaultWithManifest] @@ -66,5 +66,5 @@ jobs: uses: ./ with: Name: PSModuleTest - Path: tests/srcWithManifestTestRepo ArtifactName: PSModuleTestWithManifest + WorkingDirectory: tests/srcWithManifestTestRepo From b74819ce4a8b79f5bc0e7dd7fb641364a1b9b131 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 1 Mar 2025 15:50:54 +0100 Subject: [PATCH 16/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Remove=20Con?= =?UTF-8?q?vertTo-Hashtable=20function=20and=20update=20Import-PSModule=20?= =?UTF-8?q?for=20improved=20clarity=20and=20functionality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 19 ++-- scripts/helpers/Build/Convert-VersionSpec.ps1 | 98 +++++++++++++++++ scripts/helpers/Build/ConvertTo-Hashtable.ps1 | 32 ------ scripts/helpers/Build/Import-PSModule.ps1 | 54 +++++----- .../Build/Resolve-PSModuleDependency.ps1 | 100 ++++++++++++------ 5 files changed, 201 insertions(+), 102 deletions(-) create mode 100644 scripts/helpers/Build/Convert-VersionSpec.ps1 delete mode 100644 scripts/helpers/Build/ConvertTo-Hashtable.ps1 diff --git a/README.md b/README.md index 21e836b..9050f62 100644 --- a/README.md +++ b/README.md @@ -25,15 +25,16 @@ This step lets you add custom build logic to process or modify the module conten ## Usage -| Name | Description | Required | Default | -| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ----------------- | -| `Name` | Name of the module to process. | `false` | | -| `Path` | Path to the folder where the modules are located. | `false` | `src` | -| `ModulesOutputPath` | Path to the folder where the built modules are outputted. | `false` | `outputs/modules` | -| `Debug` | Enable debug output. | `false` | `'false'` | -| `Verbose` | Enable verbose output. | `false` | `'false'` | -| `Version` | Specifies the version of the GitHub module to be installed. The value must be an exact version. | `false` | | -| `Prerelease` | Allow prerelease versions if available. | `false` | `'false'` | +| Name | Description | Required | Default | +| --------------------| ----------------------------------------------------------------------------------------------- | -------- | ------------------------- | +| `Name` | Name of the module to process. | `false` | | +| `Path` | Path to the folder where the modules are located. | `false` | `src` | +| `ModulesOutputPath` | Path to the folder where the built modules are outputted. | `false` | `outputs/modules` | +| `Debug` | Enable debug output. | `false` | `'false'` | +| `Verbose` | Enable verbose output. | `false` | `'false'` | +| `Version` | Specifies the version of the GitHub module to be installed. The value must be an exact version. | `false` | | +| `Prerelease` | Allow prerelease versions if available. | `false` | `'false'` | +| `WorkingDirectory` | The working directory where the script runs. | `false` | `${{ github.workspace }}` | ## Root module diff --git a/scripts/helpers/Build/Convert-VersionSpec.ps1 b/scripts/helpers/Build/Convert-VersionSpec.ps1 new file mode 100644 index 0000000..14357a8 --- /dev/null +++ b/scripts/helpers/Build/Convert-VersionSpec.ps1 @@ -0,0 +1,98 @@ +function Convert-VersionSpec { + <# + .SYNOPSIS + Converts legacy version parameters into a NuGet version range string. + + .DESCRIPTION + This function takes minimum, maximum, or required version parameters + and constructs a NuGet-compatible version range string. + + - If `RequiredVersion` is specified, the output is an exact match range. + - If both `MinimumVersion` and `MaximumVersion` are provided, + an inclusive range is returned. + - If only `MinimumVersion` is provided, it returns a minimum-inclusive range. + - If only `MaximumVersion` is provided, it returns an upper-bound range. + - If no parameters are provided, `$null` is returned. + + .EXAMPLE + Convert-VersionSpec -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + + Output: + ```powershell + [1.0.0,2.0.0] + ``` + + Returns an inclusive version range from 1.0.0 to 2.0.0. + + .EXAMPLE + Convert-VersionSpec -RequiredVersion "1.5.0" + + Output: + ```powershell + [1.5.0] + ``` + + Returns an exact match for version 1.5.0. + + .EXAMPLE + Convert-VersionSpec -MinimumVersion "1.0.0" + + Output: + ```powershell + [1.0.0, ] + ``` + + Returns a minimum-inclusive version range starting at 1.0.0. + + .EXAMPLE + Convert-VersionSpec -MaximumVersion "2.0.0" + + Output: + ```powershell + (, 2.0.0] + ``` + + Returns an upper-bound range up to version 2.0.0. + + .OUTPUTS + string + + .NOTES + The NuGet version range string based on the provided parameters. + The returned string follows NuGet versioning syntax. + + .LINK + https://psmodule.io/Convert/Functions/Convert-VersionSpec + #> + [OutputType([string])] + [CmdletBinding()] + param( + # The minimum version for the range. If specified alone, the range is open-ended upwards. + [Parameter()] + [string] $MinimumVersion, + + # The maximum version for the range. If specified alone, the range is open-ended downwards. + [Parameter()] + [string] $MaximumVersion, + + # Specifies an exact required version. If set, an exact version range is returned. + [Parameter()] + [string] $RequiredVersion + ) + + if ($RequiredVersion) { + # Use exact match in bracket notation. + return "[$RequiredVersion]" + } elseif ($MinimumVersion -and $MaximumVersion) { + # Both bounds provided; both are inclusive. + return "[$MinimumVersion,$MaximumVersion]" + } elseif ($MinimumVersion) { + # Only a minimum is provided. Use a minimum-inclusive range. + return "[$MinimumVersion, ]" + } elseif ($MaximumVersion) { + # Only a maximum is provided; lower bound open. + return "(, $MaximumVersion]" + } else { + return $null + } +} diff --git a/scripts/helpers/Build/ConvertTo-Hashtable.ps1 b/scripts/helpers/Build/ConvertTo-Hashtable.ps1 deleted file mode 100644 index 3356890..0000000 --- a/scripts/helpers/Build/ConvertTo-Hashtable.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -function ConvertTo-Hashtable { - <# - .SYNOPSIS - Converts a string to a hashtable. - - .DESCRIPTION - Converts a string to a hashtable. - - .EXAMPLE - ConvertTo-Hashtable -InputString "@{Key1 = 'Value1'; Key2 = 'Value2'}" - - Key Value - --- ----- - Key1 Value1 - Key2 Value2 - - Converts the string to a hashtable. - #> - [Diagnostics.CodeAnalysis.SuppressMessageAttribute( - 'PSAvoidUsingInvokeExpression', '', Scope = 'Function', - Justification = 'Converting a string based hashtable to a hashtable.' - )] - [CmdletBinding()] - param ( - # The string to convert to a hashtable. - [Parameter(Mandatory = $true)] - [string]$InputString - ) - - Invoke-Expression $InputString - -} diff --git a/scripts/helpers/Build/Import-PSModule.ps1 b/scripts/helpers/Build/Import-PSModule.ps1 index 79fa949..3d384cd 100644 --- a/scripts/helpers/Build/Import-PSModule.ps1 +++ b/scripts/helpers/Build/Import-PSModule.ps1 @@ -1,53 +1,47 @@ function Import-PSModule { <# - .SYNOPSIS - Imports a build PS module. + .SYNOPSIS + Imports a build PS module. - .DESCRIPTION - Imports a build PS module. + .DESCRIPTION + Imports a build PS module. - .EXAMPLE - Import-PSModule -SourceFolderPath $ModuleFolderPath -ModuleName $ModuleName + .EXAMPLE + Import-PSModule -SourceFolderPath $ModuleFolderPath -ModuleName $moduleName - Imports a module located at $ModuleFolderPath with the name $ModuleName. + Imports a module located at $ModuleFolderPath with the name $moduleName. #> [CmdletBinding()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSAvoidUsingWriteHost', '', Scope = 'Function', Justification = 'Want to just write to the console, not the pipeline.' )] - #Requires -Modules @{ ModuleName = 'Utilities'; ModuleVersion = '0.3.0' } param( # Path to the folder where the module source code is located. [Parameter(Mandatory)] - [string] $Path, - - # Name of the module. - [Parameter(Mandatory)] - [string] $ModuleName + [string] $Path ) $moduleName = Split-Path -Path $Path -Leaf - $manifestFileName = "$moduleName.psd1" - $manifestFilePath = Join-Path -Path $Path $manifestFileName - $manifestFile = Get-ModuleManifest -Path $manifestFilePath -As FileInfo -Verbose - - Write-Host "Manifest file path: [$($manifestFile.FullName)]" -Verbose - $existingModule = Get-Module -Name $ModuleName -ListAvailable - $existingModule | Remove-Module -Force -Verbose - $existingModule.RequiredModules | ForEach-Object { $_ | Remove-Module -Force -Verbose -ErrorAction SilentlyContinue } - $existingModule.NestedModules | ForEach-Object { $_ | Remove-Module -Force -Verbose -ErrorAction SilentlyContinue } - # Get-InstalledPSResource | Where-Object Name -EQ $ModuleName | Uninstall-PSResource -SkipDependencyCheck -Verbose:$false - Resolve-PSModuleDependency -ManifestFilePath $manifestFile - Import-Module -Name $ModuleName -RequiredVersion '999.0.0' - - Write-Host 'List loaded modules' + $manifestFilePath = Join-Path -Path $Path "$moduleName.psd1" + + Write-Host " - Manifest file path: [$manifestFilePath]" + Resolve-PSModuleDependency -ManifestFilePath $manifestFilePath + + Write-Host ' - List installed modules' + Get-InstalledPSResource | Format-Table -AutoSize + + Write-Host " - Importing module [$moduleName] v999" + Import-Module $Path + + Write-Host ' - List loaded modules' $availableModules = Get-Module -ListAvailable -Refresh -Verbose:$false $availableModules | Select-Object Name, Version, Path | Sort-Object Name | Format-Table -AutoSize - Write-Host 'List commands' - Write-Host (Get-Command -Module $moduleName | Format-Table -AutoSize | Out-String) + Write-Host ' - List commands' + $commands = Get-Command -Module $moduleName -ListImported + Write-Host (Get-Command -Module $moduleName -ListImported | Format-Table -AutoSize | Out-String) - if ($ModuleName -notin $availableModules.Name) { + if ($moduleName -notin $commands.Source) { throw 'Module not found' } } diff --git a/scripts/helpers/Build/Resolve-PSModuleDependency.ps1 b/scripts/helpers/Build/Resolve-PSModuleDependency.ps1 index accf607..edb3c29 100644 --- a/scripts/helpers/Build/Resolve-PSModuleDependency.ps1 +++ b/scripts/helpers/Build/Resolve-PSModuleDependency.ps1 @@ -1,28 +1,28 @@ function Resolve-PSModuleDependency { <# - .SYNOPSIS - Resolve dependencies for a module based on the manifest file. + .SYNOPSIS + Resolves module dependencies from a manifest file using Install-PSResource. - .DESCRIPTION - Resolve dependencies for a module based on the manifest file, following PSModuleInfo structure - - .EXAMPLE - Resolve-PSModuleDependency -Path 'C:\MyModule\MyModule.psd1' + .DESCRIPTION + Reads a module manifest (PSD1) and for each required module converts the old + Install-Module parameters (MinimumVersion, MaximumVersion, RequiredVersion) + into a single NuGet version range string for Install-PSResource's –Version parameter. + (Note: If RequiredVersion is set, that value takes precedence.) + .EXAMPLE + Resolve-PSModuleDependency -ManifestFilePath 'C:\MyModule\MyModule.psd1' Installs all modules defined in the manifest file, following PSModuleInfo structure. - .NOTES - Should later be adapted to support both pre-reqs, and dependencies. - Should later be adapted to take 4 parameters sets: specific version ("requiredVersion" | "GUID"), latest version ModuleVersion, - and latest version within a range MinimumVersion - MaximumVersion. + .NOTES + Should later be adapted to support both pre-reqs, and dependencies. + Should later be adapted to take 4 parameters sets: specific version ("requiredVersion" | "GUID"), latest version ModuleVersion, + and latest version within a range MinimumVersion - MaximumVersion. #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSAvoidUsingWriteHost', '', Scope = 'Function', Justification = 'Want to just write to the console, not the pipeline.' )] - [Alias('Resolve-PSModuleDependencies')] [CmdletBinding()] - #Requires -Modules @{ ModuleName = 'Retry'; ModuleVersion = '0.1.3' } param( # The path to the manifest file. [Parameter(Mandatory)] @@ -30,38 +30,76 @@ ) Write-Host 'Resolving dependencies' - $manifest = Import-PowerShellDataFile -Path $ManifestFilePath - Write-Host "Reading [$ManifestFilePath]" - Write-Host "Found [$($manifest.RequiredModules.Count)] modules to install" + Write-Host " - Reading [$ManifestFilePath]" + Write-Host " - Found [$($manifest.RequiredModules.Count)] module(s) to install" foreach ($requiredModule in $manifest.RequiredModules) { - $installParams = @{} + # Build parameters for Install-PSResource (new version spec). + $psResourceParams = @{ + TrustRepository = $true + } + # Build parameters for Import-Module (legacy version spec). + $importParams = @{ + Force = $true + Verbose = $false + } if ($requiredModule -is [string]) { - $installParams.Name = $requiredModule + $psResourceParams.Name = $requiredModule + $importParams.Name = $requiredModule } else { - $installParams.Name = $requiredModule.ModuleName - $installParams.MinimumVersion = $requiredModule.ModuleVersion - $installParams.RequiredVersion = $requiredModule.RequiredVersion - $installParams.MaximumVersion = $requiredModule.MaximumVersion + $psResourceParams.Name = $requiredModule.ModuleName + $importParams.Name = $requiredModule.ModuleName + + # Convert legacy version info for Install-PSResource. + $versionSpec = Convert-VersionSpec ` + -MinimumVersion $requiredModule.ModuleVersion ` + -MaximumVersion $requiredModule.MaximumVersion ` + -RequiredVersion $requiredModule.RequiredVersion + + if ($versionSpec) { + $psResourceParams.Version = $versionSpec + } + + # For Import-Module, keep the original version parameters. + if ($requiredModule.ModuleVersion) { + $importParams.MinimumVersion = $requiredModule.ModuleVersion + } + if ($requiredModule.RequiredVersion) { + $importParams.RequiredVersion = $requiredModule.RequiredVersion + } + if ($requiredModule.MaximumVersion) { + $importParams.MaximumVersion = $requiredModule.MaximumVersion + } } - $installParams.Force = $true - $installParams.Verbose = $false - Write-Host "[$($installParams.Name)] - Installing module" + Write-Host " - [$($psResourceParams.Name)] - Installing module with Install-PSResource using version spec: $($psResourceParams.Version)" $VerbosePreferenceOriginal = $VerbosePreference $VerbosePreference = 'SilentlyContinue' - Retry -Count 5 -Delay 10 { - Install-Module @installParams -AllowPrerelease:$false + $retryCount = 5 + $retryDelay = 10 + for ($i = 0; $i -lt $retryCount; $i++) { + try { + Install-PSResource @psResourceParams + break + } catch { + Write-Warning "Installation of $($psResourceParams.Name) failed with error: $_" + if ($i -eq $retryCount - 1) { + throw + } + Write-Warning "Retrying in $retryDelay seconds..." + Start-Sleep -Seconds $retryDelay + } } $VerbosePreference = $VerbosePreferenceOriginal - Write-Host "[$($installParams.Name)] - Importing module" + + Write-Host " - [$($importParams.Name)] - Importing module with legacy version spec" $VerbosePreferenceOriginal = $VerbosePreference $VerbosePreference = 'SilentlyContinue' - Import-Module @installParams + Import-Module @importParams $VerbosePreference = $VerbosePreferenceOriginal - Write-Host "[$($installParams.Name)] - Done" + Write-Host " - [$($importParams.Name)] - Done" } - Write-Host 'Resolving dependencies - Done' + Write-Host ' - Resolving dependencies - Done' } From 19466834b194d5baa964bf4b82387a9c9eef696f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 1 Mar 2025 18:00:12 +0100 Subject: [PATCH 17/49] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Remove=20ModuleNa?= =?UTF-8?q?me=20parameter=20from=20Import-PSModule=20for=20improved=20clar?= =?UTF-8?q?ity=20in=20module=20import=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleRootModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index a388e67..9293cff 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -258,7 +258,7 @@ Export-ModuleMember @exports LogGroup 'Build root module - Validate - Import' { Add-PSModulePath -Path (Split-Path -Path $ModuleOutputFolder -Parent) - Import-PSModule -Path $ModuleOutputFolder -ModuleName $ModuleName + Import-PSModule -Path $ModuleOutputFolder } LogGroup 'Build root module - Validate - File list' { From 16f218a6b098581d2a8f1f174f17f820e27adc1e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 1 Mar 2025 18:04:14 +0100 Subject: [PATCH 18/49] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Update=20PSSemVer?= =?UTF-8?q?=20module=20version=20in=20Get-PSModuleTest.ps1=20for=20compati?= =?UTF-8?q?bility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/functions/public/PSModule/Get-PSModuleTest.ps1 | 2 +- .../src/functions/public/PSModule/Get-PSModuleTest.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/srcTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 b/tests/srcTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 index 86beb12..eae698a 100644 --- a/tests/srcTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 +++ b/tests/srcTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 @@ -1,5 +1,5 @@ #Requires -Modules Store -#Requires -Modules @{ ModuleName = 'PSSemVer'; RequiredVersion = '1.0.0' } +#Requires -Modules @{ ModuleName = 'PSSemVer'; RequiredVersion = '1.1.5' } #Requires -Modules @{ ModuleName = 'DynamicParams'; ModuleVersion = '1.1.8' } function Get-PSModuleTest { diff --git a/tests/srcWithManifestTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 b/tests/srcWithManifestTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 index 86beb12..f544230 100644 --- a/tests/srcWithManifestTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 +++ b/tests/srcWithManifestTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 @@ -1,5 +1,5 @@ #Requires -Modules Store -#Requires -Modules @{ ModuleName = 'PSSemVer'; RequiredVersion = '1.0.0' } +#Requires -Modules @{ ModuleName = 'PSSemVer'; ModuleVersion = '1.0.0' } #Requires -Modules @{ ModuleName = 'DynamicParams'; ModuleVersion = '1.1.8' } function Get-PSModuleTest { From 8562aaa2a3b0dbd157d86a070a077990864fd454 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 2 Mar 2025 11:54:31 +0100 Subject: [PATCH 19/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20out?= =?UTF-8?q?put=20formatting=20in=20main.ps1=20for=20improved=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 3ca622e..b6171bf 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -21,17 +21,15 @@ LogGroup 'Loading inputs' { } else { $env:PSMODULE_BUILD_PSMODULE_INPUT_Name } - Write-Host "Module name: [$moduleName]" Set-GitHubOutput -Name ModuleName -Value $moduleName $sourceFolderPath = Resolve-Path -Path 'src' | Select-Object -ExpandProperty Path $moduleOutputFolderPath = Join-Path . -ChildPath 'outputs/module' - Write-Host "Modules output path: [$moduleOutputFolderPath]" [pscustomobject]@{ moduleName = $moduleName sourceFolderPath = $sourceFolderPath moduleOutputFolderPath = $moduleOutputFolderPath - } | Format-List + } | Format-List | Out-String } LogGroup 'Build local scripts' { From 23ada900c83c4d0c1ae57ed22d61c0bf9c0a2d90 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 2 Mar 2025 11:57:03 +0100 Subject: [PATCH 20/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Enhance=20lo?= =?UTF-8?q?gging=20in=20Build-PSModule.ps1=20to=20display=20module=20sourc?= =?UTF-8?q?e=20and=20output=20folder=20paths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build-PSModule.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/helpers/Build-PSModule.ps1 b/scripts/helpers/Build-PSModule.ps1 index b827c6a..ccccac5 100644 --- a/scripts/helpers/Build-PSModule.ps1 +++ b/scripts/helpers/Build-PSModule.ps1 @@ -34,9 +34,11 @@ LogGroup "Building module [$ModuleName]" { $moduleSourceFolder = Get-Item -Path $ModuleSourceFolderPath - Write-Host "Module source folder: [$moduleSourceFolder]" $moduleOutputFolder = New-Item -Path $ModuleOutputFolderPath -Name $ModuleName -ItemType Directory -Force - Write-Host "Module output folder: [$moduleOutputFolder]" + [pscustomobject]@{ + ModuleSourceFolderPath = $moduleSourceFolder + ModuleOutputFolderPath = $moduleOutputFolder + } | Format-List | Out-String } Build-PSModuleBase -ModuleName $ModuleName -ModuleSourceFolder $moduleSourceFolder -ModuleOutputFolder $moduleOutputFolder From a2c604c0a2e8293db7b19f4f136389538f26191f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 2 Mar 2025 11:59:50 +0100 Subject: [PATCH 21/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20Bui?= =?UTF-8?q?ld-PSModuleBase.ps1=20to=20use=20relative=20paths=20for=20sourc?= =?UTF-8?q?e=20and=20output=20folders=20in=20logging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleBase.ps1 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/helpers/Build/Build-PSModuleBase.ps1 b/scripts/helpers/Build/Build-PSModuleBase.ps1 index ffb664d..56f3e2f 100644 --- a/scripts/helpers/Build/Build-PSModuleBase.ps1 +++ b/scripts/helpers/Build/Build-PSModuleBase.ps1 @@ -35,9 +35,11 @@ ) LogGroup 'Build base' { - Write-Host "Copying files from [$ModuleSourceFolder] to [$ModuleOutputFolder]" - Copy-Item -Path "$ModuleSourceFolder\*" -Destination $ModuleOutputFolder -Recurse -Force -Verbose -Exclude "$ModuleName.psm1" - New-Item -Path $ModuleOutputFolder -Name "$ModuleName.psm1" -ItemType File -Force -Verbose + $relModuleSourceFolder = $ModuleSourceFolder | Resolve-Path -Relative + $relModuleOutputFolder = $ModuleOutputFolder | Resolve-Path -Relative + Write-Host "Copying files from [$relModuleSourceFolder] to [$relModuleOutputFolder]" + Copy-Item -Path "$ModuleSourceFolder\*" -Destination $ModuleOutputFolder -Recurse -Force -Exclude "$ModuleName.psm1" + $null = New-Item -Path $ModuleOutputFolder -Name "$ModuleName.psm1" -ItemType File -Force } LogGroup 'Build base - Result' { From 616fae4c2e3e8e41deefc77731bafc15a990a06d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 2 Mar 2025 12:07:22 +0100 Subject: [PATCH 22/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Modify=20Bui?= =?UTF-8?q?ld-PSModuleBase.ps1=20to=20log=20relative=20paths=20for=20outpu?= =?UTF-8?q?t=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleBase.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/helpers/Build/Build-PSModuleBase.ps1 b/scripts/helpers/Build/Build-PSModuleBase.ps1 index 56f3e2f..e3b56c4 100644 --- a/scripts/helpers/Build/Build-PSModuleBase.ps1 +++ b/scripts/helpers/Build/Build-PSModuleBase.ps1 @@ -43,6 +43,7 @@ } LogGroup 'Build base - Result' { - (Get-ChildItem -Path $ModuleOutputFolder -Recurse -Force).FullName | Sort-Object + # Print relative paths + Get-ChildItem -Path $ModuleOutputFolder -Recurse -Force | Resolve-Path -Relative | Sort-Object } } From d8d67360947a36b832662940be6728d534b45dc2 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 2 Mar 2025 12:10:35 +0100 Subject: [PATCH 23/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Simplify=20S?= =?UTF-8?q?et-ModuleManifest=20call=20and=20enhance=20Test-ModuleManifest?= =?UTF-8?q?=20output=20formatting=20in=20Build-PSModuleManifest.ps1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleManifest.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/helpers/Build/Build-PSModuleManifest.ps1 b/scripts/helpers/Build/Build-PSModuleManifest.ps1 index 2a611f0..3ae127b 100644 --- a/scripts/helpers/Build/Build-PSModuleManifest.ps1 +++ b/scripts/helpers/Build/Build-PSModuleManifest.ps1 @@ -448,7 +448,7 @@ } LogGroup 'Build manifest file - Format' { - Set-ModuleManifest -Path $outputManifestPath -Verbose + Set-ModuleManifest -Path $outputManifestPath } LogGroup 'Build manifest file - Result - After format' { @@ -460,6 +460,6 @@ } LogGroup 'Build manifest file - Validate - Test manifest file' { - Test-ModuleManifest -Path $outputManifestPath + Test-ModuleManifest -Path $outputManifestPath | Format-List | Out-String } } From 7c0aa185fef8e80f66704e91b1c518d8c4269ca7 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 2 Mar 2025 12:15:53 +0100 Subject: [PATCH 24/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Change=20out?= =?UTF-8?q?put=20format=20in=20Build-PSModuleRootModule.ps1=20to=20use=20F?= =?UTF-8?q?ormat-List=20for=20improved=20readability=20of=20exports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleRootModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index 9293cff..7795b43 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -130,7 +130,7 @@ $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = { $exports.Add('Function', (Get-PSModuleFunctionsToExport -SourceFolderPath $ModuleOutputFolder)) $exports.Add('Variable', (Get-PSModuleVariablesToExport -SourceFolderPath $ModuleOutputFolder)) - Write-Host ($exports | Out-String) + [pscustomobject]$exports | Format-List | Out-String #endregion - Analyze source files #region - Module header From 822c4819285dd65262607fbdbd7de32afe4c72d2 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 2 Mar 2025 12:23:55 +0100 Subject: [PATCH 25/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Streamline?= =?UTF-8?q?=20output=20handling=20in=20Build-PSModuleRootModule.ps1=20and?= =?UTF-8?q?=20Import-PSModule.ps1=20for=20improved=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleRootModule.ps1 | 2 +- scripts/helpers/Build/Import-PSModule.ps1 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index 7795b43..19021b5 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -224,7 +224,7 @@ Write-Debug "[`$scriptName] - $relativePath - Done" $exportsString = $exports | Format-Hashtable - Write-Host ($exportsString | Out-String) + $exportsString | Out-String $params = @{ Path = $rootModuleFile diff --git a/scripts/helpers/Build/Import-PSModule.ps1 b/scripts/helpers/Build/Import-PSModule.ps1 index 3d384cd..e41efb5 100644 --- a/scripts/helpers/Build/Import-PSModule.ps1 +++ b/scripts/helpers/Build/Import-PSModule.ps1 @@ -36,10 +36,10 @@ Write-Host ' - List loaded modules' $availableModules = Get-Module -ListAvailable -Refresh -Verbose:$false - $availableModules | Select-Object Name, Version, Path | Sort-Object Name | Format-Table -AutoSize + $availableModules | Select-Object Name, Version, Path | Sort-Object Name | Format-Table -AutoSize | Out-String Write-Host ' - List commands' $commands = Get-Command -Module $moduleName -ListImported - Write-Host (Get-Command -Module $moduleName -ListImported | Format-Table -AutoSize | Out-String) + Get-Command -Module $moduleName -ListImported | Format-Table -AutoSize | Out-String if ($moduleName -notin $commands.Source) { throw 'Module not found' From d5eb28d613ded938172028f7332cf4e5d46609c9 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 2 Mar 2025 12:27:49 +0100 Subject: [PATCH 26/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20out?= =?UTF-8?q?put=20handling=20in=20Import-PSModule.ps1=20to=20convert=20tabl?= =?UTF-8?q?e=20output=20to=20string=20for=20improved=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Import-PSModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Build/Import-PSModule.ps1 b/scripts/helpers/Build/Import-PSModule.ps1 index e41efb5..76224cd 100644 --- a/scripts/helpers/Build/Import-PSModule.ps1 +++ b/scripts/helpers/Build/Import-PSModule.ps1 @@ -29,7 +29,7 @@ Resolve-PSModuleDependency -ManifestFilePath $manifestFilePath Write-Host ' - List installed modules' - Get-InstalledPSResource | Format-Table -AutoSize + Get-InstalledPSResource | Format-Table -AutoSize | Out-String Write-Host " - Importing module [$moduleName] v999" Import-Module $Path From a999ec9393b2598db303f91a46e9012df9939327 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 2 Mar 2025 12:31:28 +0100 Subject: [PATCH 27/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20Bui?= =?UTF-8?q?ld-PSModuleBase.ps1=20and=20Build-PSModuleRootModule.ps1=20to?= =?UTF-8?q?=20log=20relative=20paths=20for=20output=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleBase.ps1 | 1 - scripts/helpers/Build/Build-PSModuleRootModule.ps1 | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/helpers/Build/Build-PSModuleBase.ps1 b/scripts/helpers/Build/Build-PSModuleBase.ps1 index e3b56c4..a0b2c3d 100644 --- a/scripts/helpers/Build/Build-PSModuleBase.ps1 +++ b/scripts/helpers/Build/Build-PSModuleBase.ps1 @@ -43,7 +43,6 @@ } LogGroup 'Build base - Result' { - # Print relative paths Get-ChildItem -Path $ModuleOutputFolder -Recurse -Force | Resolve-Path -Relative | Sort-Object } } diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index 19021b5..68419c3 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -262,6 +262,6 @@ Export-ModuleMember @exports } LogGroup 'Build root module - Validate - File list' { - (Get-ChildItem -Path $ModuleOutputFolder -Recurse -Force).FullName | Sort-Object + Get-ChildItem -Path $ModuleOutputFolder -Recurse -Force | Resolve-Path -Relative | Sort-Object } } From d5865d477daa2d9f74b638299d90532aec656d8c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Mar 2025 18:56:28 +0100 Subject: [PATCH 28/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Integrate=20?= =?UTF-8?q?PSModuleHelpers=20installation=20and=20remove=20unused=20helper?= =?UTF-8?q?=20scripts=20for=20cleaner=20build=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 3 + scripts/helpers/Build/Convert-VersionSpec.ps1 | 98 ---------------- scripts/helpers/Build/Import-PSModule.ps1 | 47 -------- .../Build/Resolve-PSModuleDependency.ps1 | 105 ------------------ 4 files changed, 3 insertions(+), 250 deletions(-) delete mode 100644 scripts/helpers/Build/Convert-VersionSpec.ps1 delete mode 100644 scripts/helpers/Build/Import-PSModule.ps1 delete mode 100644 scripts/helpers/Build/Resolve-PSModuleDependency.ps1 diff --git a/action.yml b/action.yml index 38f8a77..405b001 100644 --- a/action.yml +++ b/action.yml @@ -36,6 +36,9 @@ inputs: runs: using: composite steps: + - name: Install-PSModuleHelpers + uses: PSModule/Install-PSModuleHelpers@v1 + - name: Run Build-PSModule uses: PSModule/GitHub-Script@v1 id: build diff --git a/scripts/helpers/Build/Convert-VersionSpec.ps1 b/scripts/helpers/Build/Convert-VersionSpec.ps1 deleted file mode 100644 index 14357a8..0000000 --- a/scripts/helpers/Build/Convert-VersionSpec.ps1 +++ /dev/null @@ -1,98 +0,0 @@ -function Convert-VersionSpec { - <# - .SYNOPSIS - Converts legacy version parameters into a NuGet version range string. - - .DESCRIPTION - This function takes minimum, maximum, or required version parameters - and constructs a NuGet-compatible version range string. - - - If `RequiredVersion` is specified, the output is an exact match range. - - If both `MinimumVersion` and `MaximumVersion` are provided, - an inclusive range is returned. - - If only `MinimumVersion` is provided, it returns a minimum-inclusive range. - - If only `MaximumVersion` is provided, it returns an upper-bound range. - - If no parameters are provided, `$null` is returned. - - .EXAMPLE - Convert-VersionSpec -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" - - Output: - ```powershell - [1.0.0,2.0.0] - ``` - - Returns an inclusive version range from 1.0.0 to 2.0.0. - - .EXAMPLE - Convert-VersionSpec -RequiredVersion "1.5.0" - - Output: - ```powershell - [1.5.0] - ``` - - Returns an exact match for version 1.5.0. - - .EXAMPLE - Convert-VersionSpec -MinimumVersion "1.0.0" - - Output: - ```powershell - [1.0.0, ] - ``` - - Returns a minimum-inclusive version range starting at 1.0.0. - - .EXAMPLE - Convert-VersionSpec -MaximumVersion "2.0.0" - - Output: - ```powershell - (, 2.0.0] - ``` - - Returns an upper-bound range up to version 2.0.0. - - .OUTPUTS - string - - .NOTES - The NuGet version range string based on the provided parameters. - The returned string follows NuGet versioning syntax. - - .LINK - https://psmodule.io/Convert/Functions/Convert-VersionSpec - #> - [OutputType([string])] - [CmdletBinding()] - param( - # The minimum version for the range. If specified alone, the range is open-ended upwards. - [Parameter()] - [string] $MinimumVersion, - - # The maximum version for the range. If specified alone, the range is open-ended downwards. - [Parameter()] - [string] $MaximumVersion, - - # Specifies an exact required version. If set, an exact version range is returned. - [Parameter()] - [string] $RequiredVersion - ) - - if ($RequiredVersion) { - # Use exact match in bracket notation. - return "[$RequiredVersion]" - } elseif ($MinimumVersion -and $MaximumVersion) { - # Both bounds provided; both are inclusive. - return "[$MinimumVersion,$MaximumVersion]" - } elseif ($MinimumVersion) { - # Only a minimum is provided. Use a minimum-inclusive range. - return "[$MinimumVersion, ]" - } elseif ($MaximumVersion) { - # Only a maximum is provided; lower bound open. - return "(, $MaximumVersion]" - } else { - return $null - } -} diff --git a/scripts/helpers/Build/Import-PSModule.ps1 b/scripts/helpers/Build/Import-PSModule.ps1 deleted file mode 100644 index 76224cd..0000000 --- a/scripts/helpers/Build/Import-PSModule.ps1 +++ /dev/null @@ -1,47 +0,0 @@ -function Import-PSModule { - <# - .SYNOPSIS - Imports a build PS module. - - .DESCRIPTION - Imports a build PS module. - - .EXAMPLE - Import-PSModule -SourceFolderPath $ModuleFolderPath -ModuleName $moduleName - - Imports a module located at $ModuleFolderPath with the name $moduleName. - #> - [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute( - 'PSAvoidUsingWriteHost', '', Scope = 'Function', - Justification = 'Want to just write to the console, not the pipeline.' - )] - param( - # Path to the folder where the module source code is located. - [Parameter(Mandatory)] - [string] $Path - ) - - $moduleName = Split-Path -Path $Path -Leaf - $manifestFilePath = Join-Path -Path $Path "$moduleName.psd1" - - Write-Host " - Manifest file path: [$manifestFilePath]" - Resolve-PSModuleDependency -ManifestFilePath $manifestFilePath - - Write-Host ' - List installed modules' - Get-InstalledPSResource | Format-Table -AutoSize | Out-String - - Write-Host " - Importing module [$moduleName] v999" - Import-Module $Path - - Write-Host ' - List loaded modules' - $availableModules = Get-Module -ListAvailable -Refresh -Verbose:$false - $availableModules | Select-Object Name, Version, Path | Sort-Object Name | Format-Table -AutoSize | Out-String - Write-Host ' - List commands' - $commands = Get-Command -Module $moduleName -ListImported - Get-Command -Module $moduleName -ListImported | Format-Table -AutoSize | Out-String - - if ($moduleName -notin $commands.Source) { - throw 'Module not found' - } -} diff --git a/scripts/helpers/Build/Resolve-PSModuleDependency.ps1 b/scripts/helpers/Build/Resolve-PSModuleDependency.ps1 deleted file mode 100644 index edb3c29..0000000 --- a/scripts/helpers/Build/Resolve-PSModuleDependency.ps1 +++ /dev/null @@ -1,105 +0,0 @@ -function Resolve-PSModuleDependency { - <# - .SYNOPSIS - Resolves module dependencies from a manifest file using Install-PSResource. - - .DESCRIPTION - Reads a module manifest (PSD1) and for each required module converts the old - Install-Module parameters (MinimumVersion, MaximumVersion, RequiredVersion) - into a single NuGet version range string for Install-PSResource's –Version parameter. - (Note: If RequiredVersion is set, that value takes precedence.) - - .EXAMPLE - Resolve-PSModuleDependency -ManifestFilePath 'C:\MyModule\MyModule.psd1' - Installs all modules defined in the manifest file, following PSModuleInfo structure. - - .NOTES - Should later be adapted to support both pre-reqs, and dependencies. - Should later be adapted to take 4 parameters sets: specific version ("requiredVersion" | "GUID"), latest version ModuleVersion, - and latest version within a range MinimumVersion - MaximumVersion. - #> - [Diagnostics.CodeAnalysis.SuppressMessageAttribute( - 'PSAvoidUsingWriteHost', '', Scope = 'Function', - Justification = 'Want to just write to the console, not the pipeline.' - )] - [CmdletBinding()] - param( - # The path to the manifest file. - [Parameter(Mandatory)] - [string] $ManifestFilePath - ) - - Write-Host 'Resolving dependencies' - $manifest = Import-PowerShellDataFile -Path $ManifestFilePath - Write-Host " - Reading [$ManifestFilePath]" - Write-Host " - Found [$($manifest.RequiredModules.Count)] module(s) to install" - - foreach ($requiredModule in $manifest.RequiredModules) { - # Build parameters for Install-PSResource (new version spec). - $psResourceParams = @{ - TrustRepository = $true - } - # Build parameters for Import-Module (legacy version spec). - $importParams = @{ - Force = $true - Verbose = $false - } - - if ($requiredModule -is [string]) { - $psResourceParams.Name = $requiredModule - $importParams.Name = $requiredModule - } else { - $psResourceParams.Name = $requiredModule.ModuleName - $importParams.Name = $requiredModule.ModuleName - - # Convert legacy version info for Install-PSResource. - $versionSpec = Convert-VersionSpec ` - -MinimumVersion $requiredModule.ModuleVersion ` - -MaximumVersion $requiredModule.MaximumVersion ` - -RequiredVersion $requiredModule.RequiredVersion - - if ($versionSpec) { - $psResourceParams.Version = $versionSpec - } - - # For Import-Module, keep the original version parameters. - if ($requiredModule.ModuleVersion) { - $importParams.MinimumVersion = $requiredModule.ModuleVersion - } - if ($requiredModule.RequiredVersion) { - $importParams.RequiredVersion = $requiredModule.RequiredVersion - } - if ($requiredModule.MaximumVersion) { - $importParams.MaximumVersion = $requiredModule.MaximumVersion - } - } - - Write-Host " - [$($psResourceParams.Name)] - Installing module with Install-PSResource using version spec: $($psResourceParams.Version)" - $VerbosePreferenceOriginal = $VerbosePreference - $VerbosePreference = 'SilentlyContinue' - $retryCount = 5 - $retryDelay = 10 - for ($i = 0; $i -lt $retryCount; $i++) { - try { - Install-PSResource @psResourceParams - break - } catch { - Write-Warning "Installation of $($psResourceParams.Name) failed with error: $_" - if ($i -eq $retryCount - 1) { - throw - } - Write-Warning "Retrying in $retryDelay seconds..." - Start-Sleep -Seconds $retryDelay - } - } - $VerbosePreference = $VerbosePreferenceOriginal - - Write-Host " - [$($importParams.Name)] - Importing module with legacy version spec" - $VerbosePreferenceOriginal = $VerbosePreference - $VerbosePreference = 'SilentlyContinue' - Import-Module @importParams - $VerbosePreference = $VerbosePreferenceOriginal - Write-Host " - [$($importParams.Name)] - Done" - } - Write-Host ' - Resolving dependencies - Done' -} From 5f4695860314bbfb182f51be216a3d2e531c0c5d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Mar 2025 19:29:37 +0100 Subject: [PATCH 29/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Replace=20Ad?= =?UTF-8?q?d-PSModulePath=20with=20Install-PSModule=20in=20Build-PSModuleR?= =?UTF-8?q?ootModule.ps1=20for=20improved=20module=20import=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleRootModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index 68419c3..7e2f964 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -257,7 +257,7 @@ Export-ModuleMember @exports } LogGroup 'Build root module - Validate - Import' { - Add-PSModulePath -Path (Split-Path -Path $ModuleOutputFolder -Parent) + Install-PSModule -Path $ModuleOutputFolder Import-PSModule -Path $ModuleOutputFolder } From be6767e247f879f2828576ef0c80c13e0ae6afe8 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Mar 2025 19:47:00 +0100 Subject: [PATCH 30/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Replace=20Im?= =?UTF-8?q?port-PSModule=20with=20Import-Module=20for=20consistency=20in?= =?UTF-8?q?=20module=20loading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleRootModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index 7e2f964..1a69a65 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -258,7 +258,7 @@ Export-ModuleMember @exports LogGroup 'Build root module - Validate - Import' { Install-PSModule -Path $ModuleOutputFolder - Import-PSModule -Path $ModuleOutputFolder + Import-Module -Name $ModuleName } LogGroup 'Build root module - Validate - File list' { From 816091cfda96817099593be0d9c9abe81aefe9bf Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Mar 2025 19:59:39 +0100 Subject: [PATCH 31/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Remove=20Imp?= =?UTF-8?q?ort-Module=20call=20from=20Build-PSModuleRootModule.ps1=20for?= =?UTF-8?q?=20streamlined=20module=20installation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleRootModule.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index 1a69a65..03b7a3a 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -258,7 +258,6 @@ Export-ModuleMember @exports LogGroup 'Build root module - Validate - Import' { Install-PSModule -Path $ModuleOutputFolder - Import-Module -Name $ModuleName } LogGroup 'Build root module - Validate - File list' { From cb7d00175f469f56bbdbd3418422ccd0d1ae4c63 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Mar 2025 22:43:49 +0100 Subject: [PATCH 32/49] =?UTF-8?q?=F0=9F=A9=B9=20[Enhancement]:=20Add=20com?= =?UTF-8?q?patibility=20tags=20for=20Windows,=20Linux,=20and=20MacOS=20in?= =?UTF-8?q?=20module=20manifest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleManifest.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/helpers/Build/Build-PSModuleManifest.ps1 b/scripts/helpers/Build/Build-PSModuleManifest.ps1 index 3ae127b..6226019 100644 --- a/scripts/helpers/Build/Build-PSModuleManifest.ps1 +++ b/scripts/helpers/Build/Build-PSModuleManifest.ps1 @@ -363,6 +363,7 @@ $manifestTags = [System.Collections.Generic.List[string]]::new() $tags = $PSData.Keys -contains 'Tags' ? ($PSData.Tags).Count -gt 0 ? $PSData.Tags : $repoLabels : $repoLabels $tags | ForEach-Object { $manifestTags.Add($_) } + 'Windows', 'Linux', 'MacOS' | ForEach-Object { $manifestTags.Add($_) } # Add tags for compatability mode. https://docs.microsoft.com/en-us/powershell/scripting/developer/module/how-to-write-a-powershell-module-manifest?view=powershell-7.1#compatibility-tags if ($manifest.CompatiblePSEditions -contains 'Desktop') { if ($manifestTags -notcontains 'PSEdition_Desktop') { From 87205b8f53d2c1c071a4ac2351b4d1f7404672a8 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 6 Mar 2025 10:12:33 +0100 Subject: [PATCH 33/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20mod?= =?UTF-8?q?ule=20output=20path=20resolution=20in=20action.yml=20and=20main?= =?UTF-8?q?.ps1=20for=20improved=20artifact=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 2 +- scripts/main.ps1 | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 405b001..d62143e 100644 --- a/action.yml +++ b/action.yml @@ -58,6 +58,6 @@ runs: uses: actions/upload-artifact@v4 with: name: ${{ inputs.ArtifactName }} - path: ${{ inputs.WorkingDirectory }}/outputs/module + path: ${{ fromJson(steps.build.outputs.result).moduleOutputFolderPath }} if-no-files-found: error retention-days: 1 diff --git a/scripts/main.ps1 b/scripts/main.ps1 index b6171bf..c760ab9 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -24,7 +24,7 @@ LogGroup 'Loading inputs' { Set-GitHubOutput -Name ModuleName -Value $moduleName $sourceFolderPath = Resolve-Path -Path 'src' | Select-Object -ExpandProperty Path - $moduleOutputFolderPath = Join-Path . -ChildPath 'outputs/module' + $moduleOutputFolderPath = Join-Path $pwd -ChildPath 'outputs/module' [pscustomobject]@{ moduleName = $moduleName sourceFolderPath = $sourceFolderPath @@ -52,4 +52,6 @@ $params = @{ } Build-PSModule @params +Set-GithubOutput -Name ModuleOutputFolderPath -Value $moduleOutputFolderPath + exit 0 From ce838e8272620273b2ef1e4842d3db45c19eeec5 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 6 Mar 2025 17:20:21 +0100 Subject: [PATCH 34/49] =?UTF-8?q?=F0=9F=A9=B9=20[Documentation]:=20Update?= =?UTF-8?q?=20default=20values=20in=20README.md=20and=20action.yml=20for?= =?UTF-8?q?=20clarity=20and=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 20 ++++++++++---------- action.yml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9050f62..a43ce3f 100644 --- a/README.md +++ b/README.md @@ -25,16 +25,16 @@ This step lets you add custom build logic to process or modify the module conten ## Usage -| Name | Description | Required | Default | -| --------------------| ----------------------------------------------------------------------------------------------- | -------- | ------------------------- | -| `Name` | Name of the module to process. | `false` | | -| `Path` | Path to the folder where the modules are located. | `false` | `src` | -| `ModulesOutputPath` | Path to the folder where the built modules are outputted. | `false` | `outputs/modules` | -| `Debug` | Enable debug output. | `false` | `'false'` | -| `Verbose` | Enable verbose output. | `false` | `'false'` | -| `Version` | Specifies the version of the GitHub module to be installed. The value must be an exact version. | `false` | | -| `Prerelease` | Allow prerelease versions if available. | `false` | `'false'` | -| `WorkingDirectory` | The working directory where the script runs. | `false` | `${{ github.workspace }}` | +| Name | Description | Required | Default | +| --------------------| ----------------------------------------------------------------------------------------------- | -------- | ----------------- | +| `Name` | Name of the module to process. | `false` | | +| `Path` | Path to the folder where the modules are located. | `false` | `src` | +| `ModulesOutputPath` | Path to the folder where the built modules are outputted. | `false` | `outputs/modules` | +| `Debug` | Enable debug output. | `false` | `'false'` | +| `Verbose` | Enable verbose output. | `false` | `'false'` | +| `Version` | Specifies the version of the GitHub module to be installed. The value must be an exact version. | `false` | | +| `Prerelease` | Allow prerelease versions if available. | `false` | `'false'` | +| `WorkingDirectory` | The working directory where the script runs. | `false` | `'.'` | ## Root module diff --git a/action.yml b/action.yml index d62143e..62ee028 100644 --- a/action.yml +++ b/action.yml @@ -31,7 +31,7 @@ inputs: WorkingDirectory: description: The working directory where the script will run from. required: false - default: ${{ github.workspace }} + default: '.' runs: using: composite From 9ca54406d9f300469ae762951140b8be544a8060 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 8 Mar 2025 11:56:44 +0100 Subject: [PATCH 35/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Remove=20GIT?= =?UTF-8?q?HUB=5FTOKEN=20environment=20variable=20from=20Auto-Release=20wo?= =?UTF-8?q?rkflow=20for=20improved=20security?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Auto-Release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/Auto-Release.yml b/.github/workflows/Auto-Release.yml index ec157c9..680da5c 100644 --- a/.github/workflows/Auto-Release.yml +++ b/.github/workflows/Auto-Release.yml @@ -30,7 +30,5 @@ jobs: - name: Auto-Release uses: PSModule/Auto-Release@v1 - env: - GITHUB_TOKEN: ${{ github.token }} # Used for GitHub CLI authentication with: IncrementalPrerelease: false From b5b42c0e7ed33bbd2b3c292c0577fbd12709cea6 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 10 Mar 2025 10:02:02 +0100 Subject: [PATCH 36/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20par?= =?UTF-8?q?ameters=20in=20Build-PSModule=20scripts=20for=20improved=20clar?= =?UTF-8?q?ity=20and=20functionality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build-PSModule.ps1 | 2 +- .../Build/Build-PSModuleRootModule.ps1 | 12 ++-- ...Update-PSModuleManifestAliasesToExport.ps1 | 68 ++++++++++++++++--- 3 files changed, 67 insertions(+), 15 deletions(-) diff --git a/scripts/helpers/Build-PSModule.ps1 b/scripts/helpers/Build-PSModule.ps1 index ccccac5..2a67812 100644 --- a/scripts/helpers/Build-PSModule.ps1 +++ b/scripts/helpers/Build-PSModule.ps1 @@ -44,7 +44,7 @@ Build-PSModuleBase -ModuleName $ModuleName -ModuleSourceFolder $moduleSourceFolder -ModuleOutputFolder $moduleOutputFolder Build-PSModuleManifest -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder Build-PSModuleRootModule -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder - Update-PSModuleManifestAliasesToExport -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder + Update-PSModuleManifestAliasesToExport -ModuleName $ModuleName -ModuleSourceFolder $moduleSourceFolder LogGroup 'Build manifest file - Final Result' { $outputManifestPath = Join-Path -Path $ModuleOutputFolder -ChildPath "$ModuleName.psd1" diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index 03b7a3a..6163fdc 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -256,11 +256,11 @@ Export-ModuleMember @exports Write-Host (Show-FileContent -Path $rootModuleFile) } - LogGroup 'Build root module - Validate - Import' { - Install-PSModule -Path $ModuleOutputFolder - } + # LogGroup 'Build root module - Validate - Import' { + # Install-PSModule -Path $ModuleOutputFolder + # } - LogGroup 'Build root module - Validate - File list' { - Get-ChildItem -Path $ModuleOutputFolder -Recurse -Force | Resolve-Path -Relative | Sort-Object - } + # LogGroup 'Build root module - Validate - File list' { + # Get-ChildItem -Path $ModuleOutputFolder -Recurse -Force | Resolve-Path -Relative | Sort-Object + # } } diff --git a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 index 47d64e4..53ed2e6 100644 --- a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 +++ b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 @@ -25,19 +25,71 @@ # Folder where the module is outputted. [Parameter(Mandatory)] - [System.IO.DirectoryInfo] $ModuleOutputFolder + [System.IO.DirectoryInfo] $ModuleSourceFolder ) LogGroup 'Updating aliases to export in module manifest' { Write-Host "Module name: [$ModuleName]" - Write-Host "Module output folder: [$ModuleOutputFolder]" - $aliases = Get-Command -Module $ModuleName -CommandType Alias - Write-Host "Found aliases: [$($aliases.Count)]" - foreach ($alias in $aliases) { - Write-Host "Alias: [$($alias.Name)]" + Write-Host "Module output folder: [$ModuleSourceFolder]" + + $publicFunctionsPath = Join-Path -Path $ModuleSourceFolder -ChildPath 'public/functions' + Write-Host "Public functions path: [$publicFunctionsPath]" + if (-not (Test-Path -Path $publicFunctionsPath)) { + Write-Host "Public functions path does not exist: [$publicFunctionsPath]" + return + } + + # Get all child items in the module source folder of a powershell file type + $files = Get-ChildItem -Path $publicFunctionsPath -Recurse -File -Include '*.ps1', '*.psm1' | Select-Object -ExpandProperty Path + + # Initialize an array to store all found aliases + $allAliases = @() + + foreach ($file in $files) { + Write-Host "Parsing file: [$file]" + + # Parse the file using AST + $ast = [System.Management.Automation.Language.Parser]::ParseFile( + $file, + [ref]$null, + [ref]$null + ) + + # Get all function definitions + $functionAsts = $ast.FindAll( + { + param($node) + $node -is [System.Management.Automation.Language.FunctionDefinitionAst] + }, $false) + + Write-Host " Found functions: [$($functionAsts.Count)]" + foreach ($functionAst in $functionAsts) { + # Get the function name + $functionName = $functionAst.Name + Write-Host " Processing: [$functionName]" + + $functionAst | ForEach-Object { + $funcName = $_.Name + $funcAttributes = $_.Body.FindAll({ $args[0] -is [System.Management.Automation.Language.AttributeAst] }, $true) | Where-Object { + $_.Parent -is [System.Management.Automation.Language.ParamBlockAst] + } + $aliasAttr = $funcAttributes | Where-Object { $_.TypeName.Name -eq 'Alias' } + + if ($aliasAttr) { + $allAliases = $aliasAttr.PositionalArguments | ForEach-Object { $_.ToString().Trim('"', "'") } + Write-Host " Found alias [$allAliases] for function [$funcName]" + $allAliases += $aliases + } + } + } + } + + Write-Host "Found aliases: [$($allAliases.Count)]" + foreach ($alias in $allAliases) { + Write-Host " - [$($alias.Name)]" } - $outputManifestPath = Join-Path -Path $ModuleOutputFolder -ChildPath "$ModuleName.psd1" + $outputManifestPath = Join-Path -Path $ModuleSourceFolder -ChildPath "$ModuleName.psd1" Write-Host "Output manifest path: [$outputManifestPath]" Write-Host 'Setting module manifest with AliasesToExport' - Set-ModuleManifest -Path $outputManifestPath -AliasesToExport $aliases.Name -Verbose + Set-ModuleManifest -Path $outputManifestPath -AliasesToExport $allAliases.Name -Verbose } } From 02b3fdba91786b04b256776efe31bdf28f8d741f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 10 Mar 2025 10:06:28 +0100 Subject: [PATCH 37/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Correct=20pu?= =?UTF-8?q?blic=20functions=20path=20in=20Update-PSModuleManifestAliasesTo?= =?UTF-8?q?Export.ps1=20for=20improved=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 index 53ed2e6..5ecd136 100644 --- a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 +++ b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 @@ -31,7 +31,7 @@ Write-Host "Module name: [$ModuleName]" Write-Host "Module output folder: [$ModuleSourceFolder]" - $publicFunctionsPath = Join-Path -Path $ModuleSourceFolder -ChildPath 'public/functions' + $publicFunctionsPath = Join-Path -Path $ModuleSourceFolder -ChildPath 'functions/public' Write-Host "Public functions path: [$publicFunctionsPath]" if (-not (Test-Path -Path $publicFunctionsPath)) { Write-Host "Public functions path does not exist: [$publicFunctionsPath]" From fbace4f7d85d50745c6a82d391d162de7c0552de Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 10 Mar 2025 10:09:04 +0100 Subject: [PATCH 38/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20fil?= =?UTF-8?q?e=20path=20retrieval=20in=20Update-PSModuleManifestAliasesToExp?= =?UTF-8?q?ort.ps1=20for=20improved=20accuracy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 index 5ecd136..e705020 100644 --- a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 +++ b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 @@ -39,7 +39,7 @@ } # Get all child items in the module source folder of a powershell file type - $files = Get-ChildItem -Path $publicFunctionsPath -Recurse -File -Include '*.ps1', '*.psm1' | Select-Object -ExpandProperty Path + $files = Get-ChildItem -Path $publicFunctionsPath -Recurse -File -Include '*.ps1', '*.psm1' | Select-Object -ExpandProperty FullName # Initialize an array to store all found aliases $allAliases = @() From 0bf70097976d71fed59443a8128184e86cb392e6 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 10 Mar 2025 10:11:48 +0100 Subject: [PATCH 39/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Rename=20var?= =?UTF-8?q?iable=20for=20alias=20retrieval=20in=20Update-PSModuleManifestA?= =?UTF-8?q?liasesToExport.ps1=20for=20improved=20clarity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 index e705020..474cb46 100644 --- a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 +++ b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 @@ -75,8 +75,8 @@ $aliasAttr = $funcAttributes | Where-Object { $_.TypeName.Name -eq 'Alias' } if ($aliasAttr) { - $allAliases = $aliasAttr.PositionalArguments | ForEach-Object { $_.ToString().Trim('"', "'") } - Write-Host " Found alias [$allAliases] for function [$funcName]" + $aliases = $aliasAttr.PositionalArguments | ForEach-Object { $_.ToString().Trim('"', "'") } + Write-Host " Found alias [$aliases] for function [$funcName]" $allAliases += $aliases } } From 11775bb9bd759b4c86ad5277c0348ccbf755496e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 10 Mar 2025 10:13:13 +0100 Subject: [PATCH 40/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Simplify=20a?= =?UTF-8?q?lias=20output=20in=20Update-PSModuleManifestAliasesToExport.ps1?= =?UTF-8?q?=20for=20improved=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 index 474cb46..49cb6c5 100644 --- a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 +++ b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 @@ -85,11 +85,11 @@ Write-Host "Found aliases: [$($allAliases.Count)]" foreach ($alias in $allAliases) { - Write-Host " - [$($alias.Name)]" + Write-Host " - [$alias]" } $outputManifestPath = Join-Path -Path $ModuleSourceFolder -ChildPath "$ModuleName.psd1" Write-Host "Output manifest path: [$outputManifestPath]" Write-Host 'Setting module manifest with AliasesToExport' - Set-ModuleManifest -Path $outputManifestPath -AliasesToExport $allAliases.Name -Verbose + Set-ModuleManifest -Path $outputManifestPath -AliasesToExport $allAliases -Verbose } } From f29095db15a42d78b812b4231baf0be741ac9ddf Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 10 Mar 2025 10:14:49 +0100 Subject: [PATCH 41/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Add=20Module?= =?UTF-8?q?OutputFolder=20parameter=20to=20Update-PSModuleManifestAliasesT?= =?UTF-8?q?oExport=20for=20improved=20functionality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build-PSModule.ps1 | 2 +- .../Build/Update-PSModuleManifestAliasesToExport.ps1 | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/helpers/Build-PSModule.ps1 b/scripts/helpers/Build-PSModule.ps1 index 2a67812..ea85459 100644 --- a/scripts/helpers/Build-PSModule.ps1 +++ b/scripts/helpers/Build-PSModule.ps1 @@ -44,7 +44,7 @@ Build-PSModuleBase -ModuleName $ModuleName -ModuleSourceFolder $moduleSourceFolder -ModuleOutputFolder $moduleOutputFolder Build-PSModuleManifest -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder Build-PSModuleRootModule -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder - Update-PSModuleManifestAliasesToExport -ModuleName $ModuleName -ModuleSourceFolder $moduleSourceFolder + Update-PSModuleManifestAliasesToExport -ModuleName $ModuleName -ModuleSourceFolder $moduleSourceFolder -ModuleOutputFolder $moduleOutputFolder LogGroup 'Build manifest file - Final Result' { $outputManifestPath = Join-Path -Path $ModuleOutputFolder -ChildPath "$ModuleName.psd1" diff --git a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 index 49cb6c5..887b73c 100644 --- a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 +++ b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 @@ -23,9 +23,13 @@ [Parameter(Mandatory)] [string] $ModuleName, - # Folder where the module is outputted. + # Path to the folder where the module source code is located. [Parameter(Mandatory)] - [System.IO.DirectoryInfo] $ModuleSourceFolder + [System.IO.DirectoryInfo] $ModuleSourceFolder, + + # Path to the folder where the built modules are outputted. + [Parameter(Mandatory)] + [System.IO.DirectoryInfo] $ModuleOutputFolder ) LogGroup 'Updating aliases to export in module manifest' { Write-Host "Module name: [$ModuleName]" @@ -87,7 +91,7 @@ foreach ($alias in $allAliases) { Write-Host " - [$alias]" } - $outputManifestPath = Join-Path -Path $ModuleSourceFolder -ChildPath "$ModuleName.psd1" + $outputManifestPath = Join-Path -Path $ModuleOutputFolder -ChildPath "$ModuleName.psd1" Write-Host "Output manifest path: [$outputManifestPath]" Write-Host 'Setting module manifest with AliasesToExport' Set-ModuleManifest -Path $outputManifestPath -AliasesToExport $allAliases -Verbose From 8e5662fd1abe5e350e4741de8bbfd02513b2a7a2 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 10 Mar 2025 16:44:42 +0100 Subject: [PATCH 42/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Suppress=20o?= =?UTF-8?q?utput=20of=20type=20accelerator=20removal=20in=20Build-PSModule?= =?UTF-8?q?RootModule.ps1=20for=20cleaner=20execution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleRootModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index 6163fdc..721aed2 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -115,7 +115,7 @@ foreach ($Type in $ExportableClasses) { # Remove type accelerators when the module is removed. $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = { foreach ($Type in ($ExportableEnums + $ExportableClasses)) { - $TypeAcceleratorsClass::Remove($Type.FullName) + $null = $TypeAcceleratorsClass::Remove($Type.FullName) } }.GetNewClosure() #endregion Class exporter From db4e395dac99d4492b2c759ae0e4afec2cd4676b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 23 Mar 2025 10:09:17 +0100 Subject: [PATCH 43/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Add=20check?= =?UTF-8?q?=20for=20PSEdition=20to=20determine=20Windows=20environment=20i?= =?UTF-8?q?n=20Build-PSModuleRootModule.ps1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleRootModule.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index 721aed2..7d3893f 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -153,6 +153,9 @@ $script:PSModuleInfo = Test-ModuleManifest -Path "$PSScriptRoot\$baseName.psd1" $script:PSModuleInfo | Format-List | Out-String -Stream | ForEach-Object { Write-Debug $_ } $scriptName = $script:PSModuleInfo.Name Write-Debug "[$scriptName] - Importing module" +if ($PSEdition -eq 'Desktop') { + $IsWindows = $true +} '@ #endregion - Module post-header From dd7608c143263074d554e59092347f592b976757 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 23 Mar 2025 10:09:48 +0100 Subject: [PATCH 44/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Set=20$IsWin?= =?UTF-8?q?dows=20variable=20based=20on=20PSEdition=20in=20Build-PSModuleR?= =?UTF-8?q?ootModule.ps1=20for=20improved=20environment=20detection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleRootModule.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index 7d3893f..851b12e 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -153,9 +153,12 @@ $script:PSModuleInfo = Test-ModuleManifest -Path "$PSScriptRoot\$baseName.psd1" $script:PSModuleInfo | Format-List | Out-String -Stream | ForEach-Object { Write-Debug $_ } $scriptName = $script:PSModuleInfo.Name Write-Debug "[$scriptName] - Importing module" + +# If in Windows PowerShell, set the $IsWindows variable to true. if ($PSEdition -eq 'Desktop') { $IsWindows = $true } + '@ #endregion - Module post-header From 986e9cd1b5d1d049fa2494ec97daa9b205ceb7e4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 23 Mar 2025 19:55:21 +0100 Subject: [PATCH 45/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Suppress=20c?= =?UTF-8?q?ode=20analysis=20warnings=20for=20IsWindows=20variable=20in=20B?= =?UTF-8?q?uild-PSModuleRootModule.ps1=20to=20enhance=20compatibility=20wi?= =?UTF-8?q?th=20PS5.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleRootModule.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index 851b12e..b361bda 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -140,6 +140,14 @@ $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = { $headerFilePath | Remove-Item -Force } else { Add-Content -Path $rootModuleFile -Force -Value @' +[Diagnostics.CodeAnalysis.SuppressMessageAttribute( + 'PSAvoidAssignmentToAutomaticVariable', 'IsWindows', + Justification = 'IsWindows doesnt exist in PS5.1' +)] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute( + 'PSUseDeclaredVarsMoreThanAssignments', 'IsWindows', + Justification = 'IsWindows doesnt exist in PS5.1' +)] [CmdletBinding()] param() '@ From 0a216460ee9113845c9df759b13e5d35f837d6b8 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 23 Mar 2025 19:58:08 +0100 Subject: [PATCH 46/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Remove=20red?= =?UTF-8?q?undant=20check=20for=20Windows=20environment=20in=20Build-PSMod?= =?UTF-8?q?uleRootModule.ps1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleRootModule.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index b361bda..9bbdd3a 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -162,7 +162,6 @@ $script:PSModuleInfo | Format-List | Out-String -Stream | ForEach-Object { Write $scriptName = $script:PSModuleInfo.Name Write-Debug "[$scriptName] - Importing module" -# If in Windows PowerShell, set the $IsWindows variable to true. if ($PSEdition -eq 'Desktop') { $IsWindows = $true } From c46ebaf72aeaff4b478c2e60e8436d5f0de041dc Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 23 Mar 2025 20:06:57 +0100 Subject: [PATCH 47/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Rearrange=20?= =?UTF-8?q?header=20content=20addition=20in=20Build-PSModuleRootModule.ps1?= =?UTF-8?q?=20for=20improved=20clarity=20and=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../helpers/Build/Build-PSModuleRootModule.ps1 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index 9bbdd3a..fa7a32a 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -134,12 +134,7 @@ $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = { #endregion - Analyze source files #region - Module header - $headerFilePath = Join-Path -Path $ModuleOutputFolder -ChildPath 'header.ps1' - if (Test-Path -Path $headerFilePath) { - Get-Content -Path $headerFilePath -Raw | Add-Content -Path $rootModuleFile -Force - $headerFilePath | Remove-Item -Force - } else { - Add-Content -Path $rootModuleFile -Force -Value @' + Add-Content -Path $rootModuleFile -Force -Value @' [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSAvoidAssignmentToAutomaticVariable', 'IsWindows', Justification = 'IsWindows doesnt exist in PS5.1' @@ -148,6 +143,14 @@ $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = { 'PSUseDeclaredVarsMoreThanAssignments', 'IsWindows', Justification = 'IsWindows doesnt exist in PS5.1' )] +'@ + + $headerFilePath = Join-Path -Path $ModuleOutputFolder -ChildPath 'header.ps1' + if (Test-Path -Path $headerFilePath) { + Get-Content -Path $headerFilePath -Raw | Add-Content -Path $rootModuleFile -Force + $headerFilePath | Remove-Item -Force + } else { + Add-Content -Path $rootModuleFile -Force -Value @' [CmdletBinding()] param() '@ From e8182946f1d2c17919e5a67bcda50d0d04a74f8b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 31 Mar 2025 17:33:19 +0200 Subject: [PATCH 48/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20mod?= =?UTF-8?q?ule=20manifest=20loading=20method=20in=20Build-PSModuleRootModu?= =?UTF-8?q?le.ps1=20for=20improved=20reliability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleRootModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index fa7a32a..d767b9a 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -160,7 +160,7 @@ param() #region - Module post-header Add-Content -Path $rootModuleFile -Force -Value @' $baseName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) -$script:PSModuleInfo = Test-ModuleManifest -Path "$PSScriptRoot\$baseName.psd1" +$script:PSModuleInfo = . "$PSScriptRoot\$baseName.psd1" $script:PSModuleInfo | Format-List | Out-String -Stream | ForEach-Object { Write-Debug $_ } $scriptName = $script:PSModuleInfo.Name Write-Debug "[$scriptName] - Importing module" From 1734e534c49e3604bfe4428dbb9631f093eef1c2 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 31 Mar 2025 17:46:52 +0200 Subject: [PATCH 49/49] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Replace=20di?= =?UTF-8?q?rect=20script=20execution=20with=20Import-PowerShellDataFile=20?= =?UTF-8?q?for=20module=20manifest=20loading=20in=20Build-PSModuleRootModu?= =?UTF-8?q?le.ps1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build/Build-PSModuleRootModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index d767b9a..adef93a 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -160,7 +160,7 @@ param() #region - Module post-header Add-Content -Path $rootModuleFile -Force -Value @' $baseName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) -$script:PSModuleInfo = . "$PSScriptRoot\$baseName.psd1" +$script:PSModuleInfo = Import-PowerShellDataFile -Path "$PSScriptRoot\$baseName.psd1" $script:PSModuleInfo | Format-List | Out-String -Stream | ForEach-Object { Write-Debug $_ } $scriptName = $script:PSModuleInfo.Name Write-Debug "[$scriptName] - Importing module"