-
Notifications
You must be signed in to change notification settings - Fork 0
Prepare PSModuleUtils 2.0.0 #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| out/* | ||
| tests/* | ||
| tests/coverage.xml | ||
| tests/testResults.xml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| @{ | ||
| RootModule = 'PSModuleUtils.psm1' | ||
| ModuleVersion = '2.0.0' | ||
| GUID = '3c63c38f-c32c-4837-a6fa-0b456f4099ce' | ||
| Author = '' | ||
| CompanyName = '' | ||
| Copyright = '' | ||
| Description = 'A module with helper functions to build and publish PowerShell modules to the PSGallery.' | ||
| PowerShellVersion = '7.4' | ||
| CompatiblePSEditions = @('Core') | ||
| FunctionsToExport = @() | ||
| CmdletsToExport = @() | ||
| VariablesToExport = @() | ||
| AliasesToExport = @() | ||
| RequiredModules = @( | ||
| @{ ModuleName = 'ModuleBuilder'; ModuleVersion = '3.0.0'; MaximumVersion = '3.*' } | ||
| @{ ModuleName = 'Metadata'; ModuleVersion = '1.5.0'; MaximumVersion = '1.*' } | ||
| @{ ModuleName = 'JBUtils'; ModuleVersion = '1.1.0'; MaximumVersion = '1.*' } | ||
| @{ ModuleName = 'Pester'; ModuleVersion = '5.0'; MaximumVersion = '5.*' } | ||
| @{ ModuleName = 'PSScriptAnalyzer'; ModuleVersion = '1.20.0'; MaximumVersion = '1.*' } | ||
| @{ ModuleName = 'Microsoft.PowerShell.PSResourceGet'; ModuleVersion = '1.0.0' } | ||
| ) | ||
| PrivateData = @{ | ||
| PSData = @{ | ||
| Tags = @('PSEdition_Core', 'Windows', 'Linux', 'macOS') | ||
| ProjectUri = '' | ||
| LicenseUri = 'https://opensource.org/licenses/MIT' | ||
| ReleaseNotes = '' | ||
| Prerelease = '' | ||
| } | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Internal: resolves the bundled analyzer settings across source and built module layouts. | ||
|
|
||
| .DESCRIPTION | ||
| ModuleBuilder merges every source function into a single flat .psm1 while copying the Settings directory | ||
| intact. The settings directory is one level above a source function and a direct sibling of the built | ||
| .psm1. This probes both locations relative to the caller's own $PSScriptRoot. | ||
|
|
||
| .PARAMETER CallerScriptRoot | ||
| The $PSScriptRoot of the calling function. | ||
|
|
||
| .OUTPUTS | ||
| System.String path to the settings file, or nothing if neither candidate exists. | ||
|
|
||
| .EXAMPLE | ||
| Get-PSModuleAnalyzerSettingsPath -CallerScriptRoot $PSScriptRoot | ||
| #> | ||
| function Get-PSModuleAnalyzerSettingsPath { | ||
| [CmdletBinding()] | ||
| [OutputType([String])] | ||
| param ( | ||
| [Parameter(Mandatory)] | ||
| [String]$CallerScriptRoot | ||
| ) | ||
|
|
||
| $candidates = @( | ||
| (Join-Path -Path $CallerScriptRoot -ChildPath 'Settings/PSScriptAnalyzerSettings.psd1') | ||
| (Join-Path -Path $CallerScriptRoot -ChildPath '../Settings/PSScriptAnalyzerSettings.psd1') | ||
| ) | ||
| $candidates | Where-Object -FilterScript { Test-Path -Path $_ } | Select-Object -First 1 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Internal: derives module manifest metadata from a git working tree. | ||
|
|
||
| .DESCRIPTION | ||
| Reads the git remote and history for the given path and returns the manifest metadata that should be | ||
| stamped onto a built module: author list, company name, copyright, project URI, and release notes. | ||
| Returns nothing (with a warning) when the path is not inside a git working tree, so callers can treat | ||
| git-derived metadata as best effort. | ||
|
|
||
| .PARAMETER Path | ||
| A path inside the git working tree to read metadata from. Defaults to the current location. | ||
|
|
||
| .OUTPUTS | ||
| PSCustomObject with Author, CompanyName, Copyright, ProjectUri, and ReleaseNotes properties. | ||
|
|
||
| .EXAMPLE | ||
| $metadata = Get-PSModuleGitMetadata -Path $SourceDirectory | ||
| #> | ||
| function Get-PSModuleGitMetadata { | ||
| [CmdletBinding()] | ||
| [OutputType([PSCustomObject])] | ||
| param ( | ||
| [String]$Path = "$PWD" | ||
| ) | ||
|
|
||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| Push-Location -Path $Path | ||
| try { | ||
| $insideWorkTree = ( & git rev-parse --is-inside-work-tree 2>$null ) | ||
| if ($LASTEXITCODE -ne 0 -or $insideWorkTree -ne 'true') { | ||
| Write-Warning -Message "'$Path' is not inside a git working tree; skipping git-derived metadata." | ||
| return | ||
| } | ||
|
|
||
| $repoUrl = ( & git config --get remote.origin.url ) | ||
| if ($LASTEXITCODE -ne 0 -or [String]::IsNullOrWhiteSpace($repoUrl)) { | ||
| Write-Warning -Message "'$Path' has no origin remote; skipping git-derived metadata." | ||
| return | ||
| } | ||
| try { | ||
| $remoteMetadata = Resolve-PSModuleGitRemote -RepositoryUrl $repoUrl | ||
| } | ||
| catch { | ||
| Write-Warning -Message ( | ||
| 'A company name was not provided and the Git remote URL could not be resolved; ' + | ||
| 'leaving CompanyName and ProjectUri blank.' | ||
| ) | ||
| $remoteMetadata = [PSCustomObject]@{ | ||
| Organization = '' | ||
| ProjectUri = '' | ||
| } | ||
| } | ||
| $companyName = $remoteMetadata.Organization | ||
| $copyright = if ($companyName) { | ||
| "(c) $( Get-Date -Format yyyy ) $companyName. All rights reserved." | ||
| } | ||
| else { | ||
| '' | ||
| } | ||
|
|
||
| [PSCustomObject]@{ | ||
| Author = (( & git log --format='%aN' -- . | Sort-Object -Unique ) -join ', ') | ||
| CompanyName = $companyName | ||
| Copyright = $copyright | ||
| ProjectUri = $remoteMetadata.ProjectUri | ||
| ReleaseNotes = ( & git log -1 --pretty=%B )[0] | ||
| } | ||
| } | ||
| finally { | ||
| Pop-Location | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Internal: retrieves a previously published module's manifest from a repository. | ||
|
|
||
| .DESCRIPTION | ||
| Saves a module from the given repository into a temporary directory and returns its manifest as a | ||
| hashtable, so callers can reuse identity fields (most importantly GUID) when generating or migrating | ||
| a source manifest template for a module that has already been published. Returns nothing (with a | ||
| verbose message, not a warning) when no published version is found, since this is an expected | ||
| outcome for a module that has never been published. | ||
|
|
||
| .PARAMETER Name | ||
| The name of the module to look up. | ||
|
|
||
| .PARAMETER Repository | ||
| The repository to search. Defaults to PSGallery. | ||
|
|
||
| .OUTPUTS | ||
| System.Collections.Hashtable of the published manifest, or nothing if none was found. | ||
|
|
||
| .EXAMPLE | ||
| Get-PSModulePublishedManifest -Name 'MyModule' -Repository 'PSGallery' | ||
| #> | ||
| function Get-PSModulePublishedManifest { | ||
| [CmdletBinding()] | ||
| [OutputType([Hashtable])] | ||
| param ( | ||
| [Parameter(Mandatory)] | ||
| [String]$Name, | ||
|
|
||
| [String]$Repository = 'PSGallery' | ||
| ) | ||
|
|
||
| $lookupPath = Join-Path ` | ||
| -Path ([IO.Path]::GetTempPath()) ` | ||
| -ChildPath "psmodule-manifest-lookup-$( (New-Guid).Guid )" | ||
| try { | ||
| $null = New-Item -ItemType Directory -Path $lookupPath -Force | ||
| Save-PSResource ` | ||
| -Name $Name ` | ||
| -Repository $Repository ` | ||
| -Path $lookupPath ` | ||
| -TrustRepository ` | ||
| -ErrorAction SilentlyContinue | ||
| $publishedManifest = Get-ChildItem -Path $lookupPath -Filter "$Name.psd1" -Recurse | Select-Object -First 1 | ||
| if ($publishedManifest) { | ||
| Import-PowerShellDataFile -Path $publishedManifest.FullName | ||
| } | ||
| else { | ||
| Write-Verbose -Message "No published version of '$Name' was found in repository '$Repository'." | ||
| } | ||
| } | ||
| finally { | ||
| Remove-Item -Path $lookupPath -Recurse -Force -ErrorAction SilentlyContinue | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.