mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -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
|
# 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'
|
(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
|
# publish the module
|
||||||
|
$exclude = @('README.md','deploy.ps1')
|
||||||
if ($RepositoryAPIKey) {
|
if ($RepositoryAPIKey) {
|
||||||
Publish-Module -Path . -Repository $Repository -NuGetApiKey $RepositoryAPIKey -Verbose
|
Publish-Module -Path . -Repository $Repository -NuGetApiKey $RepositoryAPIKey -Exclude $exclude -Verbose
|
||||||
} else {
|
} 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)
|
# 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'
|
(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
|
# Aliases to export from this module
|
||||||
AliasesToExport = '*'
|
AliasesToExport = '*'
|
||||||
# Functions to export from this module
|
# 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.
|
# 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 = @{
|
PrivateData = @{
|
||||||
PSData = @{
|
PSData = @{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
$env:POSH_THEMES_PATH = "$PSScriptRoot/themes"
|
$artifactPath = "$((Get-Item $MyInvocation.MyCommand.ScriptBlock.Module.ModuleBase).Parent.FullName)"
|
||||||
$env:PATH = "$((Get-Item $MyInvocation.MyCommand.ScriptBlock.Module.ModuleBase).Parent.FullName);$env:PATH"
|
$env:POSH_THEMES_PATH = $artifactPath + "/themes"
|
||||||
|
$env:PATH = "$artifactPath;$env:PATH"
|
||||||
|
|
||||||
function Get-PoshDownloadUrl {
|
function Get-PoshDownloadUrl {
|
||||||
param(
|
param(
|
||||||
|
@ -71,25 +72,49 @@ function Get-PoshCommand {
|
||||||
return "$((Get-Item $MyInvocation.MyCommand.ScriptBlock.Module.ModuleBase).Parent.FullName)/oh-my-posh$extension"
|
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
|
$executable = Get-PoshCommand
|
||||||
$moduleVersion = Split-Path -Leaf $MyInvocation.MyCommand.ScriptBlock.Module.ModuleBase
|
|
||||||
if (-not (Test-Path $executable)) {
|
if (-not (Test-Path $executable)) {
|
||||||
Write-Host "Downloading oh-my-posh executable for $moduleVersion"
|
Write-Host "Downloading oh-my-posh executable for $Version"
|
||||||
$url = Get-PoshDownloadUrl -Version $moduleVersion
|
$url = Get-PoshDownloadUrl -Version $Version
|
||||||
Get-PoshExecutable -Url $url -Destination $executable
|
Get-PoshExecutable -Url $url -Destination $executable
|
||||||
|
Sync-PoshThemes -Version $Version
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
$poshVersion = & $executable --version
|
$poshVersion = & $executable --version
|
||||||
if ($poshVersion -eq $moduleVersion) {
|
if ($poshVersion -eq $Version) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Write-Host "Updating oh-my-posh executable to $moduleVersion"
|
Write-Host "Updating oh-my-posh executable to $Version"
|
||||||
$url = Get-PoshDownloadUrl -Version $moduleVersion
|
$url = Get-PoshDownloadUrl -Version $Version
|
||||||
Get-PoshExecutable -Url $url -Destination $executable
|
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
|
# Legacy functions
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue