Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
FriedrichWeinmann committed Dec 31, 2024
1 parent 8883dda commit 610a74f
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 10 deletions.
72 changes: 62 additions & 10 deletions PSFramework.NuGet/functions/Get/Publish-PSFModule.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
function Publish-PSFModule
{
function Publish-PSFModule {
[CmdletBinding(DefaultParameterSetName = 'ToRepository')]
Param (
[Parameter(Mandatory = $true)]
Expand All @@ -25,13 +24,14 @@
[string]
$ApiKey,

[Parameter(ParameterSetName = 'ToRepository')]
[switch]
$SkipDependenciesCheck,

[Parameter(Mandatory = $true, ParameterSetName = 'ToPath')]
[PsfDirectory]
$DestinationPath,

[switch]
$SkipDependenciesCheck,

[string[]]
$Tags,

Expand All @@ -45,12 +45,64 @@
$ProjectUri
)

begin
{
begin {
#region Setup
$killIt = $ErrorActionPreference = 'Stop'
if ($Repository) {
# Resolve Repositories
Search-PSFPowerShellGet
$repositories = Resolve-Repository -Name $Repository -Type $Type -Cmdlet $PSCmdlet | Group-Object Name | ForEach-Object {
@($_.Group | Sort-Object Type -Descending)[0]
}
}
# Create Temp Directories
$workingDirectory = New-PSFTempDirectory -ModuleName PSFramework.NuGet -Name Publish.Work
$stagingDirectory = New-PSFTempDirectory -ModuleName PSFramework.NuGet -Name Publish.Staging

$commonPublish = @{
StagingDirectory = $stagingDirectory
Cmdlet = $PSCmdlet
Continue = $true
ContinueLabel = 'repo'
}
if ($ApiKey) { $commonPublish.ApiKey = $ApiKey }
if ($Credential) { $commonPublish.Credential = $Credential }
if ($SkipDependenciesCheck) { $commonPublish.SkipDependenciesCheck = $SkipDependenciesCheck }
#endregion Setup
}
process
{
#TODO: Implement
process {
try {
foreach ($sourceModule in $Path) {
# Update Metadata per Parameter
$moduleData = Copy-Module -Path $sourceModule -Destination $workingDirectory -Cmdlet $PSCmdlet -Continue
Update-ModuleInformation -Module $moduleData -Tags $Tags -LicenseUri $LicenseUri -IconUri $IconUri -ProjectUri $ProjectUri -Cmdlet $PSCmdlet -Continue

# Case 1: Publish to Destination Path
if ($DestinationPath) {
Publish-ModuleToPath -Module $moduleData -Path $DestinationPath -Cmdlet $PSCmdlet
continue
}

# Case 2: Publish to Repository
:repo foreach ($repositoryObject in $repositories) {
switch ($repositoryObject.Type) {
V2 {
Publish-ModuleV2 @commonPublish -Module $moduleData -Repository $repositoryObject.Name
}
V3 {
Publish-ModuleV3 @commonPublish -Module $moduleData -Repository $repositoryObject.Name
}
default {
Stop-PSFFunction -String 'Publish-PSFModule.Error.UnexpectedRepositoryType' -StringValues $repositoryObject.Name, $repositoryObject.Type -Continue -Cmdlet $PSCmdlet -EnableException $killIt
}
}
}
}
}
finally {
# Cleanup Temp Directory
Remove-PSFTempItem -ModuleName PSFramework.NuGet -Name Publish.*
}
}
}
<#
Expand Down
22 changes: 22 additions & 0 deletions PSFramework.NuGet/internal/functions/Get/Publish/Copy-Module.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function Copy-Module {
[CmdletBinding()]
param (
[string]
$Path,

[string]
$Destination,

$Cmdlet,

[switch]
$Continue,

[string]
$ContinueLabel
)
process {
#TODO: Implement
throw "Not Implemented Yet"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function Publish-ModuleToPath {
[CmdletBinding()]
param (

)
process {
#TODO: Implement
throw "Not Implemented Yet"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function Publish-ModuleV2 {
[CmdletBinding()]
param (

)
process {
#TODO: Implement
throw "Not Implemented Yet"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function Publish-ModuleV3 {
[CmdletBinding()]
param (

)
process {
#TODO: Implement
throw "Not Implemented Yet"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function Update-ModuleInformation {
[CmdletBinding()]
param (

)
process {
#TODO: Implement
throw "Not Implemented Yet"
}
}

0 comments on commit 610a74f

Please sign in to comment.