From 7186589a32f02da0aae22d4fdd343b362b218418 Mon Sep 17 00:00:00 2001 From: Bruce Markham <219281+brucificus@users.noreply.github.com> Date: Tue, 3 Oct 2023 16:41:09 -0400 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=20Makes=20Module=20Exports=20Explicit?= =?UTF-8?q?=20(#32)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 28 +++++++++---------- .github/workflows/review-dependabot.yml | 2 +- .github/workflows/validate.yml | 29 +++++++++++--------- build/funcs/New-ModuleManifestCustomized.ps1 | 6 ++-- build/package-dev.ps1 | 22 +++++++++------ build/package.ps1 | 13 ++++----- packages.PSGallery.config | 2 +- src/poshy-env-proxy.psm1 | 20 ++++++++++++-- 8 files changed, 73 insertions(+), 49 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0ff53bc..26d12cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,15 +15,15 @@ jobs: steps: - run: echo "Beginning release." - name: "Transfer 'version-json' artifact from triggering workflow" - uses: pwshrc/actions-transfer-artifact@v0.3.7 + uses: pwshrc/actions-transfer-artifact@v0.3.9 with: name: 'version-json' - name: "Transfer 'PSGallery-package' artifact from triggering workflow" - uses: pwshrc/actions-transfer-artifact@v0.3.7 + uses: pwshrc/actions-transfer-artifact@v0.3.9 with: name: 'PSGallery-package' - name: "Transfer 'release-notes' artifact from triggering workflow" - uses: pwshrc/actions-transfer-artifact@v0.3.7 + uses: pwshrc/actions-transfer-artifact@v0.3.9 with: name: 'release-notes' @@ -33,10 +33,10 @@ jobs: needs: [begin-release] steps: - name: Check out repository code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Populate GitVersion variables id: gitversion_vars - uses: pwshrc/actions-determine-version@v0.8.5 + uses: pwshrc/actions-determine-version@v0.8.6 with: mode: 'download' - name: "Get artifact: PSGallery-package" @@ -46,12 +46,12 @@ jobs: path: ./out/ - name: Publish Prerelease to PSGallery (WhatIf) if: steps.gitversion_vars.outputs.PreReleaseTag != '' - uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.7 + uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.9 with: run: ./build/publish.ps1 -NUGET_KEY "abc" -Prerelease -WhatIf - name: Publish Release to PSGallery (WhatIf) if: steps.gitversion_vars.outputs.PreReleaseTag == '' - uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.7 + uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.9 with: run: ./build/publish.ps1 -NUGET_KEY "abc" -WhatIf @@ -61,10 +61,10 @@ jobs: needs: [test-publish-psgallery-package] steps: - name: Check out repository code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Populate GitVersion variables id: gitversion_vars - uses: pwshrc/actions-determine-version@v0.8.5 + uses: pwshrc/actions-determine-version@v0.8.6 with: mode: 'download' - name: "Get artifact: PSGallery-package" @@ -74,14 +74,14 @@ jobs: path: ./out/ - name: Publish Prerelease to PSGallery if: steps.gitversion_vars.outputs.PreReleaseTag != '' - uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.7 + uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.9 env: NUGET_KEY: ${{ secrets.NUGET_KEY }} with: run: ./build/publish.ps1 -NUGET_KEY "$env:NUGET_KEY" -Prerelease - name: Publish Release to PSGallery if: steps.gitversion_vars.outputs.PreReleaseTag == '' - uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.7 + uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.9 env: NUGET_KEY: ${{ secrets.NUGET_KEY }} with: @@ -93,15 +93,15 @@ jobs: needs: [publish-psgallery-package] steps: - name: Check out repository code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Get GitVersion id: gitversion_vars - uses: pwshrc/actions-determine-version@v0.8.5 + uses: pwshrc/actions-determine-version@v0.8.6 with: mode: 'download' - name: Get release notes id: get-releasenotes - uses: pwshrc/actions-create-release-notes@v0.8.6 + uses: pwshrc/actions-create-release-notes@v0.8.8 with: mode: 'download' github_token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/review-dependabot.yml b/.github/workflows/review-dependabot.yml index ab61e27..7c576f2 100644 --- a/.github/workflows/review-dependabot.yml +++ b/.github/workflows/review-dependabot.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Review Dependabot PR - uses: pwshrc/actions-review-dependabot@v0.6.0 + uses: pwshrc/actions-review-dependabot@v0.6.2 with: github_token: "${{ secrets.GITHUB_TOKEN }}" required-pr-user-login: 'dependabot[bot]' diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index b27c9ed..b75e521 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -12,9 +12,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Lint with PSScriptAnalyzer - uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.7 + uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.9 with: run: ./build/lint.ps1 -CI -NoFail:([bool]"${{ secrets.MANDATE_LINT_SUCCESS != 'true' }}") @@ -24,7 +24,7 @@ jobs: steps: - name: Populate GitVersion variables id: gitversion_vars - uses: pwshrc/actions-determine-version@v0.8.5 + uses: pwshrc/actions-determine-version@v0.8.6 with: mode: 'upload' @@ -34,7 +34,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Create release notes - uses: pwshrc/actions-create-release-notes@v0.8.6 + uses: pwshrc/actions-create-release-notes@v0.8.8 with: mode: 'upload' github_token: "${{ secrets.GITHUB_TOKEN }}" @@ -45,30 +45,33 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Populate GitVersion id: gitversion_vars - uses: pwshrc/actions-determine-version@v0.8.5 + uses: pwshrc/actions-determine-version@v0.8.6 with: mode: 'download' - name: Populate release notes id: get-releasenotes - uses: pwshrc/actions-create-release-notes@v0.8.6 + uses: pwshrc/actions-create-release-notes@v0.8.8 with: mode: 'download' github_token: "${{ secrets.GITHUB_TOKEN }}" - name: Build PSGallery package - uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.7 + uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.9 env: - PackageVersionNuGet: ${{ steps.gitversion_vars.outputs.NuGetVersionV2 }} - PackageVersionMajorMinorPatchBuild: ${{ steps.gitversion_vars.outputs.AssemblySemVer }} + PackageVersion: ${{ steps.gitversion_vars.outputs.NuGetVersionV2 }} + ModuleVersionMajor: ${{ steps.gitversion_vars.outputs.Major }} + ModuleVersionMinor: ${{ steps.gitversion_vars.outputs.Minor }} + ModuleVersionPatch: ${{ steps.gitversion_vars.outputs.Patch }} PackageVersionPrereleaseTag: ${{ steps.gitversion_vars.outputs.PreReleaseTag }} CommitSha: ${{ steps.gitversion_vars.outputs.Sha }} ReleaseNotesFilepath: ${{ steps.get-releasenotes.outputs.filepath }} with: run: | [string] $releaseNotes = (Get-Content -Raw -Path ./out/release-notes.md -Encoding UTF8).Trim() - ./build/package.ps1 -PackageVersionNuGet $Env:PackageVersionNuGet -PackageVersionMajorMinorPatchBuild $Env:PackageVersionMajorMinorPatchBuild -PackageVersionPrereleaseTag $Env:PackageVersionPrereleaseTag -ReleaseNotes $releaseNotes -CommitSha $Env:CommitSha + [Version] $moduleVersion = [Version]::new($Env:ModuleVersionMajor, $Env:ModuleVersionMinor, $Env:ModuleVersionPatch) + ./build/package.ps1 -PackageVersion $Env:PackageVersion -ModuleVersion $moduleVersion -PackageVersionPrereleaseTag $Env:PackageVersionPrereleaseTag -ReleaseNotes $releaseNotes -CommitSha $Env:CommitSha - name: "Create artifact: PSGallery-package" uses: actions/upload-artifact@v3 with: @@ -102,14 +105,14 @@ jobs: needs: build-release-package steps: - name: Check out repository code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: "Get artifact: PSGallery-package" uses: actions/download-artifact@v3 with: name: PSGallery-package path: ./out/ - name: Test with Pester - uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.7 + uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.9 with: run: ./build/test.ps1 -UsePackageExport -CI -OutputFilesPrefix "${{ matrix.os }}-" -NoFail:([bool]"${{ matrix.experimental }}") - name: "Create artifact: tests-${{ matrix.os }}" diff --git a/build/funcs/New-ModuleManifestCustomized.ps1 b/build/funcs/New-ModuleManifestCustomized.ps1 index 0512e16..f3da088 100644 --- a/build/funcs/New-ModuleManifestCustomized.ps1 +++ b/build/funcs/New-ModuleManifestCustomized.ps1 @@ -62,8 +62,8 @@ function New-ModuleManifestCustomized { [string] $PackageVersion, [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] $PackageVersionMajorMinorPatchBuild, + [ValidateNotNull()] + [Version] $ModuleVersion, [Parameter(Mandatory = $false)] [string] $PackageVersionPrereleaseTag, @@ -159,7 +159,7 @@ function New-ModuleManifestCustomized { -CompanyName $CompanyName ` -Description $packageSynopsis ` -Copyright $PackageCopyright ` - -ModuleVersion $PackageVersion ` + -ModuleVersion $ModuleVersion ` -Guid $PackageGuid ` -Tags $PackageTags ` -LicenseUri "${ProjectUrlAtVersion}/${LicenseFileName}" ` diff --git a/build/package-dev.ps1 b/build/package-dev.ps1 index ac2ecff..da1dd35 100644 --- a/build/package-dev.ps1 +++ b/build/package-dev.ps1 @@ -20,30 +20,36 @@ elseif (Get-Command gitversion -ErrorAction SilentlyContinue) { if ($gitversion_bin) { [PSObject] $versionInfo = & $gitversion_bin | ConvertFrom-Json - [string] $PackageVersionNuGet = $versionInfo | Select-Object -ExpandProperty NuGetVersionV2 + [string] $PackageVersion = $versionInfo | Select-Object -ExpandProperty NuGetVersionV2 [string] $PackageVersionPrereleaseTag = $versionInfo | Select-Object -ExpandProperty PreReleaseTag - [string] $PackageVersionMajorMinorPatchBuild = $versionInfo | Select-Object -ExpandProperty AssemblySemVer + [string] $assemblySemVer = $versionInfo | Select-Object -ExpandProperty AssemblySemVer [string] $CommitSha = $versionInfo | Select-Object -ExpandProperty Sha } else { - [string] $PackageVersionNuGet = "0.0.1" + [string] $PackageVersion = "0.0.1" [string] $PackageVersionPrereleaseTag = $null - [string] $PackageVersionMajorMinorPatchBuild = "0.0.1.0" + [string] $assemblySemVer = "0.0.1" [string] $CommitSha = (git rev-parse HEAD) } [string] $ReleaseNotes = "Fake Release Notes" if (-not $PackageVersionPrereleaseTag) { - $PackageVersionNuGet += "-dev" + $PackageVersion += "-dev" $PackageVersionPrereleaseTag = "dev" } else { - $PackageVersionNuGet = $PackageVersionNuGet.Replace("-" + $PackageVersionPrereleaseTag, "-dev-" + $PackageVersionPrereleaseTag) + $PackageVersion = $PackageVersion.Replace("-" + $PackageVersionPrereleaseTag, "-dev-" + $PackageVersionPrereleaseTag) $PackageVersionPrereleaseTag = "dev-" + $PackageVersionPrereleaseTag } +if (-not $PackageVersionPrereleaseTag) { + [Version] $moduleVersion = [Version] $assemblySemVer +} else { + [Version] $moduleVersion = [Version] ($assemblySemVer -replace "-$PackageVersionPrereleaseTag", "") +} + [string] $ds = [System.IO.Path]::DirectorySeparatorChar & "${PSScriptRoot}${ds}package.ps1" ` - -PackageVersionNuGet $PackageVersionNuGet ` - -PackageVersionMajorMinorPatchBuild $PackageVersionMajorMinorPatchBuild ` + -PackageVersion $PackageVersion ` + -ModuleVersion $moduleVersion ` -PackageVersionPrereleaseTag $PackageVersionPrereleaseTag ` -ReleaseNotes $ReleaseNotes ` -CommitSha $CommitSha diff --git a/build/package.ps1 b/build/package.ps1 index 38cabe5..de3c7c4 100644 --- a/build/package.ps1 +++ b/build/package.ps1 @@ -6,11 +6,11 @@ param( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] - [string] $PackageVersionNuGet, + [string] $PackageVersion, [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] $PackageVersionMajorMinorPatchBuild, + [ValidateNotNull()] + [Version] $ModuleVersion, [Parameter(Mandatory = $false)] [string] $PackageVersionPrereleaseTag, @@ -61,7 +61,6 @@ Set-StrictMode -Version Latest . "${PSScriptRoot}${ds}funcs${ds}Get-PSGalleryModuleNested.ps1" [object[]] $nestedRuntimePSGalleryModules = @(Get-PSGalleryModuleNested -RuntimeDependencies) -[string] $packageVersion = $PackageVersionNuGet . "${PSScriptRoot}${ds}funcs${ds}New-ModuleManifestCustomized.ps1" [System.IO.FileInfo] $moduleManifest = New-ModuleManifestCustomized ` @@ -78,8 +77,8 @@ Set-StrictMode -Version Latest -PackageCopyright $packageCopyright ` -PackageTags $packageTagsForNuSpec ` -ReleaseNotes $ReleaseNotes ` - -PackageVersion $packageVersion ` - -PackageVersionMajorMinorPatchBuild $PackageVersionMajorMinorPatchBuild ` + -PackageVersion $PackageVersion ` + -ModuleVersion $ModuleVersion ` -PackageVersionPrereleaseTag $PackageVersionPrereleaseTag ` -PackageGuid $packageGuid ` -PSEdition_Desktop:$PSEdition_Desktop ` @@ -90,7 +89,7 @@ Set-StrictMode -Version Latest . "${PSScriptRoot}${ds}funcs${ds}New-TemporaryProjectFile.ps1" [System.IO.FileInfo] $projectFile = New-TemporaryProjectFile ` -PackageId $PackageId ` - -PackageVersion $packageVersion ` + -PackageVersion $PackageVersion ` -CompanyName $companyName ` -Authors $authors ` -GitRepositoryUrl $repositoryGitUrl ` diff --git a/packages.PSGallery.config b/packages.PSGallery.config index d8765a0..8da97b9 100644 --- a/packages.PSGallery.config +++ b/packages.PSGallery.config @@ -1,7 +1,7 @@ - + diff --git a/src/poshy-env-proxy.psm1 b/src/poshy-env-proxy.psm1 index db09340..5c51386 100644 --- a/src/poshy-env-proxy.psm1 +++ b/src/poshy-env-proxy.psm1 @@ -39,6 +39,7 @@ function disable-proxy { ssh-disable-proxy } } +Export-ModuleMember -Function disable-proxy <# .SYNOPSIS @@ -97,6 +98,7 @@ function enable-proxy { ssh-enable-proxy } +Export-ModuleMember -Function enable-proxy <# @@ -113,6 +115,8 @@ function show-proxy { git-global-show-proxy ssh-show-proxy } +Export-ModuleMember -Function show-proxy + <# .SYNOPSIS @@ -135,6 +139,7 @@ Run 'glossary proxy' to show the available proxy functions with a short descript pwshrc-show-proxy } +Export-ModuleMember -Function proxy-help <# .SYNOPSIS @@ -150,6 +155,7 @@ function pwshrc-show-proxy { Write-Output "" Get-EnvVar -Process -NameMatch 'PWSHRC.*PROXY' } +Export-ModuleMember -Function pwshrc-show-proxy <# .SYNOPSIS @@ -167,6 +173,7 @@ function npm-show-proxy { Write-Output "npm proxy exceptions: $(npm config get noproxy)" } } +Export-ModuleMember -Function npm-show-proxy <# .SYNOPSIS @@ -182,6 +189,7 @@ function npm-disable-proxy { Write-Output "Disabled npm proxy settings" } } +Export-ModuleMember -Function npm-disable-proxy <# .SYNOPSIS @@ -211,6 +219,7 @@ function npm-enable-proxy { Write-Output "Enabled npm proxy settings" } } +Export-ModuleMember -Function npm-enable-proxy <# .SYNOPSIS @@ -227,6 +236,7 @@ function git-global-show-proxy { Write-Output "Git (Global) HTTPS proxy: $(git config --global --get https.proxy)" } } +Export-ModuleMember -Function git-global-show-proxy <# .SYNOPSIS @@ -241,6 +251,7 @@ function git-global-disable-proxy { Write-Output "Disabled global Git proxy settings" } } +Export-ModuleMember -Function git-global-disable-proxy <# .SYNOPSIS @@ -261,6 +272,7 @@ function git-global-enable-proxy { Write-Output "Enabled global Git proxy settings" } } +Export-ModuleMember -Function git-global-enable-proxy <# .SYNOPSIS @@ -276,6 +288,7 @@ function git-show-proxy { Write-Output "Git HTTPS proxy: $(git config --get https.proxy)" } } +Export-ModuleMember -Function git-show-proxy <# .SYNOPSIS @@ -290,6 +303,7 @@ function git-disable-proxy { Write-Output "Disabled Git project proxy settings" } } +Export-ModuleMember -Function git-disable-proxy <# .SYNOPSIS @@ -310,6 +324,7 @@ function git-enable-proxy { Write-Output "Enabled Git project proxy settings" } } +Export-ModuleMember -Function git-enable-proxy <# .SYNOPSIS @@ -354,6 +369,7 @@ function ssh-show-proxy { } | Format-Table -AutoSize } } +Export-ModuleMember -Function ssh-show-proxy <# .SYNOPSIS @@ -375,6 +391,7 @@ function ssh-disable-proxy { Write-Output "Disabled SSH config proxy settings" } } +Export-ModuleMember -Function ssh-disable-proxy <# .SYNOPSIS @@ -396,5 +413,4 @@ function ssh-enable-proxy { Write-Output "Enabled SSH config proxy settings" } } - -Export-ModuleMember -Function * +Export-ModuleMember -Function ssh-enable-proxy