diff --git a/automatic/fondue/fondue.nuspec b/automatic/fondue/fondue.nuspec new file mode 100644 index 0000000..9cef98c --- /dev/null +++ b/automatic/fondue/fondue.nuspec @@ -0,0 +1,29 @@ + + + + + fondue + 1.0.2 + steviecoaster + fondue (Install) + Chocolatey Software + https://github.com/chocolatey-solutions/Fondue + https://img.chocolatey.org/nupkg/chocolateyicon.png + Chocolatey Software + https://github.com/chocolatey-solutions/Fondue/blob/main/LICENSE + https://github.com/chocolatey-solutions/Fondue + https://chocolatey-solutions.github.io/Fondue/ + https://ch0.co/community + https://github.com/chocolatey-solutions/Fondue/issues + fondue maintainer package development author + A PowerShell module that melts away the complexity of creating and managing Chocolatey packages. + Fondue provides a rich set of cmdlets that streamline every step of the Chocolatey package lifecycle — from scaffolding new packages and metapackages, to managing dependencies, updating metadata, syncing installed software, and validating your work before publishing. + + + + + + + + + diff --git a/automatic/fondue/tools/Fondue.zip b/automatic/fondue/tools/Fondue.zip new file mode 100644 index 0000000..d0335e2 Binary files /dev/null and b/automatic/fondue/tools/Fondue.zip differ diff --git a/automatic/fondue/tools/chocolateyBeforeModify.ps1 b/automatic/fondue/tools/chocolateyBeforeModify.ps1 new file mode 100644 index 0000000..fb8c362 --- /dev/null +++ b/automatic/fondue/tools/chocolateyBeforeModify.ps1 @@ -0,0 +1,2 @@ +$ErrorActionPreference = 'Stop' +Remove-Module -Name $env:ChocolateyPackageName -Force -ErrorAction SilentlyContinue \ No newline at end of file diff --git a/automatic/fondue/tools/chocolateyInstall.ps1 b/automatic/fondue/tools/chocolateyInstall.ps1 new file mode 100644 index 0000000..fa59538 --- /dev/null +++ b/automatic/fondue/tools/chocolateyInstall.ps1 @@ -0,0 +1,75 @@ +$ErrorActionPreference = 'Stop' + +$toolsDir = Split-Path -Parent $MyInvocation.MyCommand.Definition +$ModuleName = $env:ChocolateyPackageName # this may be different from the package name and different case +$ModuleVersion = $env:ChocolateyPackageVersion # this may change so keep this here +$SavedParamsPath = Join-Path $toolsDir -ChildPath 'parameters.saved' + +if ($PSVersionTable.PSVersion.Major -lt 5) { + Write-Warning "$ModuleName has not been tested on this version of PowerShell" +} + +# Module may already be installed outside of Chocolatey +Remove-Module -Name $ModuleName -Force -ErrorAction SilentlyContinue + +# remove the saved parameters file if it exists +if (Test-Path -Path $savedParamsPath) { + Remove-Item -Path $savedParamsPath -Force +} + +$sourcePath = Join-Path $toolsDir -ChildPath "$($ModuleName).zip" +$destinationPath = @() + +$PathSegment = @{ + Windows = "WindowsPowerShell\Modules\" + Core = "PowerShell\Modules\" + + AllUsers = $env:ProgramFiles + CurrentUser = try { + $PROFILE | Split-Path | Split-Path + } catch { + Write-Warning "Profile is set to '$($PROFILE)'. Current user '$($env:USERNAME)' may not be able to install at user level." + } +} + +$Parameters = Get-PackageParameters + +if (-not $Parameters.ContainsKey('Windows') -and -not $Parameters.ContainsKey('Core')) { + $Parameters += @{ + Windows = $PSVersionTable.PSVersion.Major -le 5 + Core = $PSVersionTable.PSVersion.Major -gt 5 + } +} + +if (-not $Parameters.ContainsKey('AllUsers') -and -not $Parameters.ContainsKey('CurrentUser')) { + $Parameters += @{ + AllUsers = Test-ProcessAdminRights + CurrentUser = -not (Test-ProcessAdminRights) + } +} + +foreach ($Scope in $Parameters.Keys.Where{$Parameters[$_] -and $_ -in @("AllUsers", "CurrentUser")}) { + if ($Parameters.Windows) { + $destinationPath += Join-Path -Path $PathSegment.$Scope -ChildPath $PathSegment.Windows + } + + if ($Parameters.Core) { + $destinationPath += Join-Path -Path $PathSegment.$Scope -ChildPath $PathSegment.Core + } +} + +foreach ($destPath in $destinationPath) { + Write-Verbose "Installing '$($modulename)' to '$($destPath)'." + + # Check if the destination path exists and create if not + if (Test-Path -Path $destPath) { + $null = New-Item -Path $destPath -ItemType Directory -Force + } + Get-ChocolateyUnzip -FileFullPath $sourcePath -Destination $destPath -PackageName $moduleName + + # save the locations where the module was installed so we can uninstall it + Add-Content -Path $savedParamsPath -Value $destPath +} + +# cleanup the module from the Chocolatey $toolsDir folder +Remove-Item -Path $sourcePath -Force -Recurse \ No newline at end of file diff --git a/automatic/fondue/tools/chocolateyUninstall.ps1 b/automatic/fondue/tools/chocolateyUninstall.ps1 new file mode 100644 index 0000000..1a5a84a --- /dev/null +++ b/automatic/fondue/tools/chocolateyUninstall.ps1 @@ -0,0 +1,27 @@ +$ErrorActionPreference = 'Stop' + +$toolsDir = Split-Path -Parent $MyInvocation.MyCommand.Definition +$moduleName = $env:ChocolateyPackageName # this may be different from the package name and different case +$savedParamsPath = Join-Path $toolsDir -ChildPath 'parameters.saved' + +if (Test-Path -Path $savedParamsPath) { + $removePath = Get-Content -Path $savedParamsPath +} else { + $removePath = Join-Path -Path $env:ProgramFiles -ChildPath "WindowsPowerShell\Modules\$moduleName" +} + +ForEach ($path in $removePath) { + Write-Verbose "Removing all version of '$moduleName' from '$path'." + Remove-Item -Path $path -Recurse -Force -ErrorAction SilentlyContinue +} + +# remove path of module from $env:PSModulePath +if ($PSVersionTable.PSVersion.Major -lt 4) { + $modulePaths = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine') -split ';' + + Write-Verbose "Removing '$sourcePath' from PSModulePath." + $newModulePath = $modulePaths | Where-Object { $_ -ne $sourcePath } + + [Environment]::SetEnvironmentVariable('PSModulePath', $newModulePath, 'Machine') + $env:PSModulePath = $newModulePath +} \ No newline at end of file diff --git a/automatic/fondue/update.ps1 b/automatic/fondue/update.ps1 new file mode 100644 index 0000000..0dcc22f --- /dev/null +++ b/automatic/fondue/update.ps1 @@ -0,0 +1,24 @@ +Import-Module Chocolatey-AU + +#Create a temp dir +$tempDir = New-Item -Path $env:TEMP -Name (New-Guid).Guid -ItemType Directory +$fondue = Join-Path $tempDir -ChildPath 'Fondue' +$zipFile = Join-Path $tempDir -ChildPath 'Fondue.zip' + +Save-Module -Name Fondue -Path $tempDir -Repository PSGallery +Compress-Archive -Path $fondue -DestinationPath $zipFile + +$toolsDir = Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Definition) -ChildPath 'tools' + +Copy-Item $zipFile -Destination $toolsDir -Force + +Remove-Item $tempDir -Recurse -Force +function global:au_GetLatest { + $LatestRelease = Find-Module Fondue -Repository PSGallery + + @{ + Version = $LatestRelease.Version + } +} + +update -ChecksumFor none -NoCheckChocoVersion \ No newline at end of file