mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-09 20:44:03 -08:00
feat(pwsh): sync themes un update/install
This commit is contained in:
parent
50ee821688
commit
8c0d33cf13
|
@ -13,14 +13,12 @@ Param
|
|||
|
||||
# set the actual version number
|
||||
(Get-Content '.\oh-my-posh.psd1' -Raw).Replace('0.0.0.1', $ModuleVersion) | Out-File -Encoding 'UTF8' '.\oh-my-posh.psd1'
|
||||
# copy all themes into the module folder
|
||||
Copy-Item -Path "../../../themes" -Destination "./themes" -Recurse
|
||||
# publish the module
|
||||
$exclude = @('README.md','deploy.ps1')
|
||||
if ($RepositoryAPIKey) {
|
||||
Publish-Module -Path . -Repository $Repository -NuGetApiKey $RepositoryAPIKey -Verbose
|
||||
Publish-Module -Path . -Repository $Repository -NuGetApiKey $RepositoryAPIKey -Exclude $exclude -Verbose
|
||||
} else {
|
||||
Publish-Module -Path . -Repository $Repository -Verbose
|
||||
Publish-Module -Path . -Repository $Repository -Exclude $exclude -Verbose
|
||||
}
|
||||
# reset module version (for local testing only as we don't want PR's with changed version numbers all the time)
|
||||
(Get-Content '.\oh-my-posh.psd1' -Raw).Replace($ModuleVersion, '0.0.0.1') | Out-File -Encoding 'UTF8' '.\oh-my-posh.psd1'
|
||||
Remove-Item "./themes" -Recurse -Force
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
# Aliases to export from this module
|
||||
AliasesToExport = '*'
|
||||
# Functions to export from this module
|
||||
FunctionsToExport = @('Get-PoshThemes', 'Set-PoshPrompt', 'Get-PoshInfoForV2Users')
|
||||
FunctionsToExport = @('Set-PoshPrompt')
|
||||
# Private data to pass to the module specified in RootModule. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
|
||||
PrivateData = @{
|
||||
PSData = @{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
$env:POSH_THEMES_PATH = "$PSScriptRoot/themes"
|
||||
$env:PATH = "$((Get-Item $MyInvocation.MyCommand.ScriptBlock.Module.ModuleBase).Parent.FullName);$env:PATH"
|
||||
$artifactPath = "$((Get-Item $MyInvocation.MyCommand.ScriptBlock.Module.ModuleBase).Parent.FullName)"
|
||||
$env:POSH_THEMES_PATH = $artifactPath + "/themes"
|
||||
$env:PATH = "$artifactPath;$env:PATH"
|
||||
|
||||
function Get-PoshDownloadUrl {
|
||||
param(
|
||||
|
@ -71,25 +72,49 @@ function Get-PoshCommand {
|
|||
return "$((Get-Item $MyInvocation.MyCommand.ScriptBlock.Module.ModuleBase).Parent.FullName)/oh-my-posh$extension"
|
||||
}
|
||||
|
||||
function Sync-PoshExecutable {
|
||||
function Sync-PoshThemes {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]
|
||||
$Version
|
||||
)
|
||||
|
||||
Write-Host "Downloading oh-my-posh themes for $Version"
|
||||
$tmp = New-TemporaryFile | Rename-Item -NewName { $_ -replace 'tmp$', 'zip' } –PassThru
|
||||
$themesUrl = "https://github.com/jandedobbeleer/oh-my-posh/releases/download/v$Version/themes.zip"
|
||||
Invoke-WebRequest -OutFile $tmp $themesUrl
|
||||
$destination = $env:POSH_THEMES_PATH
|
||||
$tmp | Expand-Archive -DestinationPath $destination -Force
|
||||
$tmp | Remove-Item
|
||||
}
|
||||
|
||||
function Sync-PoshArtifacts {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]
|
||||
$Version
|
||||
)
|
||||
|
||||
$executable = Get-PoshCommand
|
||||
$moduleVersion = Split-Path -Leaf $MyInvocation.MyCommand.ScriptBlock.Module.ModuleBase
|
||||
if (-not (Test-Path $executable)) {
|
||||
Write-Host "Downloading oh-my-posh executable for $moduleVersion"
|
||||
$url = Get-PoshDownloadUrl -Version $moduleVersion
|
||||
Write-Host "Downloading oh-my-posh executable for $Version"
|
||||
$url = Get-PoshDownloadUrl -Version $Version
|
||||
Get-PoshExecutable -Url $url -Destination $executable
|
||||
Sync-PoshThemes -Version $Version
|
||||
return
|
||||
}
|
||||
$poshVersion = & $executable --version
|
||||
if ($poshVersion -eq $moduleVersion) {
|
||||
if ($poshVersion -eq $Version) {
|
||||
return
|
||||
}
|
||||
Write-Host "Updating oh-my-posh executable to $moduleVersion"
|
||||
$url = Get-PoshDownloadUrl -Version $moduleVersion
|
||||
Write-Host "Updating oh-my-posh executable to $Version"
|
||||
$url = Get-PoshDownloadUrl -Version $Version
|
||||
Get-PoshExecutable -Url $url -Destination $executable
|
||||
Sync-PoshThemes -Version $Version
|
||||
}
|
||||
|
||||
Sync-PoshExecutable
|
||||
$moduleVersion = Split-Path -Leaf $MyInvocation.MyCommand.ScriptBlock.Module.ModuleBase
|
||||
Sync-PoshArtifacts -Version $moduleVersion
|
||||
|
||||
# Legacy functions
|
||||
|
||||
|
|
Loading…
Reference in a new issue