From f30687f2684e17fb32cd6a262be91fc51caa1618 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 23 Aug 2024 22:38:28 +0200 Subject: [PATCH] Add a script for installing `aliae` --- scripts/Common/Software/aliae/Main.ps1 | 48 +++++++++++++++++++++++++ scripts/Common/Software/aliae/aliae.yml | 24 ++----------- scripts/Windows/Software/aliae/Main.ps1 | 22 ++++++++++++ 3 files changed, 73 insertions(+), 21 deletions(-) create mode 100644 scripts/Common/Software/aliae/Main.ps1 create mode 100644 scripts/Windows/Software/aliae/Main.ps1 diff --git a/scripts/Common/Software/aliae/Main.ps1 b/scripts/Common/Software/aliae/Main.ps1 new file mode 100644 index 00000000..ffd1fe07 --- /dev/null +++ b/scripts/Common/Software/aliae/Main.ps1 @@ -0,0 +1,48 @@ +param( + $Action, + [hashtable] $Arguments +) + +. "$PSScriptRoot/../PowerShell/Profile.ps1"; +. "$PSScriptRoot/../../Scripts/Software.ps1"; + +Start-SoftwareInstaller @PSBoundParameters ` + -Configurator { + $pathExpression = "`"$($IsWindows ? "`$env:ProgramData" : "/etc")/aliae/aliae.yml`""; + $path = & ([scriptblock]::Create($pathExpression)); + $null = New-Item -Force -ItemType Directory (Split-Path -Parent $path); + Copy-Item -Force "$PSScriptRoot/aliae.yml" $path; + + Add-PowerShellProfileStatement ` + -System ` + -Category "aliae" ` + -Script ( + @( + { + #aliae + }, + "`$globalPath = $pathExpression", + { + $userPath = & { + if ($env:ALIAE_CONFIG) { + $env:ALIAE_CONFIG; + } else { + "~/.aliae.yaml"; + } + }; + + if (Test-Path $globalPath) { + & ([scriptblock]::Create((aliae init pwsh --config $globalPath))); + } + + if (Test-Path $userPath) { + & ([scriptblock]::Create((aliae init pwsh))); + } + + & ([scriptblock]::Create((aliae completion powershell))); + } + ) -join [System.Environment]::NewLine) + } ` + -UserConfigurator { + Copy-Item -Force "$PSScriptRoot/aliae.yml" ~/.aliae.yaml; + }; diff --git a/scripts/Common/Software/aliae/aliae.yml b/scripts/Common/Software/aliae/aliae.yml index 1e381147..84d82c4e 100644 --- a/scripts/Common/Software/aliae/aliae.yml +++ b/scripts/Common/Software/aliae/aliae.yml @@ -1,22 +1,4 @@ -alias: - - name: totsch - value: git -env: - - name: POSH_THEME - value: '{{ if eq .OS "windows" }}{{ .Home }}/Nextcloud/.omp{{ else }}/usr/local/share/oh-my-posh/themes{{ end }}/manuel.omp.json' +alias: [] +env: [] path: [] -script: - - value: | - # Profile Files - $profileRoot = Split-Path -Parent $PROFILE; - $profilePaths = @( - "$profileRoot/conf.d/*.ps1", - "{{ if eq .OS "windows" }}$env:ProgramData{{ else }}/etc{{ end }}/powershell/conf.d/*.ps1" - ); - - foreach ($profilePath in $profilePaths) { - if (Test-Path $profilePath) { - Get-Item $profilePath | ForEach-Object { . $_; }; - } - } - if: match .Shell "pwsh" +script: [] diff --git a/scripts/Windows/Software/aliae/Main.ps1 b/scripts/Windows/Software/aliae/Main.ps1 new file mode 100644 index 00000000..c622f798 --- /dev/null +++ b/scripts/Windows/Software/aliae/Main.ps1 @@ -0,0 +1,22 @@ +param ( + $Action, + [hashtable] $Arguments +) + +. "$PSScriptRoot/../../../Common/Scripts/Software.ps1"; +. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1"; + +& { + $base = "$PSScriptRoot/../../../Common/Software/aliae/Manage.ps1"; + + Start-SoftwareInstaller @PSBoundParameters ` + -Installer { + Install-WingetPackage JanDeDobbeleer.Aliae; + } ` + -Configurator { + . $base -Action ([InstallerAction]::Configure); + } ` + -UserConfigurator { + . $base -Action ([InstallerAction]::ConfigureUser); + }; +};