Allow inheriting PowerShell installers
This commit is contained in:
parent
4504ca85d4
commit
d9d1575a19
|
@ -9,11 +9,13 @@ $null = New-Module {
|
||||||
function Start-SoftwareInstaller {
|
function Start-SoftwareInstaller {
|
||||||
param(
|
param(
|
||||||
[string] $Name,
|
[string] $Name,
|
||||||
|
[scriptblock] $Base = $null,
|
||||||
[scriptblock] $Backup = $null,
|
[scriptblock] $Backup = $null,
|
||||||
[scriptblock] $Installer = $null,
|
[scriptblock] $Installer = $null,
|
||||||
[scriptblock] $Configurator = $null,
|
[scriptblock] $Configurator = $null,
|
||||||
[scriptblock] $UserBackup = $null,
|
[scriptblock] $UserBackup = $null,
|
||||||
[scriptblock] $UserConfigurator = $null,
|
[scriptblock] $UserConfigurator = $null,
|
||||||
|
[string] $Inherit,
|
||||||
[Parameter(Position = 0)]
|
[Parameter(Position = 0)]
|
||||||
[Nullable[InstallerAction]] $Action,
|
[Nullable[InstallerAction]] $Action,
|
||||||
[Parameter(Position = 1)]
|
[Parameter(Position = 1)]
|
||||||
|
@ -35,6 +37,14 @@ $null = New-Module {
|
||||||
$Name = Split-Path -Leaf (Split-Path -Parent ((Get-PSCallStack)[1].ScriptName));
|
$Name = Split-Path -Leaf (Split-Path -Parent ((Get-PSCallStack)[1].ScriptName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($Inherit) {
|
||||||
|
foreach ($script in @("Backup", "Installer", "Configurator", "UserBackup", "UserConfigurator")) {
|
||||||
|
if (-not (Get-Variable $script).Value) {
|
||||||
|
Set-Variable $script { & $Inherit -Action $Action @args };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Start-Operation {
|
Start-Operation {
|
||||||
$installHandler = {
|
$installHandler = {
|
||||||
param(
|
param(
|
||||||
|
@ -61,6 +71,7 @@ $null = New-Module {
|
||||||
installer = $installHandler;
|
installer = $installHandler;
|
||||||
arguments = $Arguments;
|
arguments = $Arguments;
|
||||||
context = $Context;
|
context = $Context;
|
||||||
|
base = { & "$Inherit" -Action $Action $args };
|
||||||
};
|
};
|
||||||
|
|
||||||
switch ($Action) {
|
switch ($Action) {
|
||||||
|
|
|
@ -2,17 +2,8 @@
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||||
|
|
||||||
& {
|
Start-SoftwareInstaller @args `
|
||||||
$base = "$PSScriptRoot/../../../Common/Software/Oh My Posh/Manage.ps1";
|
-Inherit "$PSScriptRoot/../../../Common/Software/Oh My Posh/Manage.ps1" `
|
||||||
|
-Installer {
|
||||||
Start-SoftwareInstaller @args `
|
Install-WingetPackage JanDeDobbeleer.OhMyPosh -ArgumentList "--scope", "machine";
|
||||||
-Installer {
|
};
|
||||||
Install-WingetPackage JanDeDobbeleer.OhMyPosh -ArgumentList "--scope", "machine";
|
|
||||||
} `
|
|
||||||
-Configurator {
|
|
||||||
. $base -Action ([InstallerAction]::Configure) @args;
|
|
||||||
} `
|
|
||||||
-UserConfigurator {
|
|
||||||
. $base -Action ([InstallerAction]::ConfigureUser) @args;
|
|
||||||
};
|
|
||||||
} @args;
|
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||||
|
|
||||||
Start-SoftwareInstaller @args `
|
Start-SoftwareInstaller @args -Inherit "$PSScriptRoot/../../../Common/Software/PowerShell/Manage.ps1";
|
||||||
-Configurator {
|
|
||||||
. "$PSScriptRoot/../../../Common/Software/PowerShell/Manage.ps1" `
|
|
||||||
-Action ([InstallerAction]::Configure);
|
|
||||||
};
|
|
||||||
|
|
|
@ -2,17 +2,8 @@
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||||
|
|
||||||
& {
|
Start-SoftwareInstaller @args `
|
||||||
$base = "$PSScriptRoot/../../../Common/Software/aliae/Main.ps1";
|
-Inherit "$PSScriptRoot/../../../Common/Software/aliae/Main.ps1" `
|
||||||
|
-Installer {
|
||||||
Start-SoftwareInstaller @args `
|
Install-WingetPackage JanDeDobbeleer.Aliae -ArgumentList "--scope", "machine";
|
||||||
-Installer {
|
};
|
||||||
Install-WingetPackage JanDeDobbeleer.Aliae -ArgumentList "--scope", "machine";
|
|
||||||
} `
|
|
||||||
-Configurator {
|
|
||||||
. $base -Action ([InstallerAction]::Configure) @args;
|
|
||||||
} `
|
|
||||||
-UserConfigurator {
|
|
||||||
. $base -Action ([InstallerAction]::ConfigureUser) @args;
|
|
||||||
};
|
|
||||||
} @args;
|
|
||||||
|
|
|
@ -3,25 +3,15 @@
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||||
|
|
||||||
& {
|
Start-SoftwareInstaller @args `
|
||||||
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
-Inherit "$PSScriptRoot/../../../Common/Software/git/Manage.ps1" `
|
||||||
$base = "$PSScriptRoot/../../../Common/Software/git/Manage.ps1";
|
-Installer {
|
||||||
|
$params = "/WindowsTerminalProfile";
|
||||||
|
$defaultBranch = Get-OSConfig "git.defaultBranch";
|
||||||
|
|
||||||
Start-SoftwareInstaller @args `
|
if ($defaultBranch) {
|
||||||
-Installer {
|
$params += " /DefaultBranchName:`"$defaultBranch`"";
|
||||||
$params = "/WindowsTerminalProfile";
|
}
|
||||||
$defaultBranch = Get-OSConfig "git.defaultBranch";
|
|
||||||
|
|
||||||
if ($defaultBranch) {
|
Install-ChocoPackage git -ArgumentList "--params", $params;
|
||||||
$params += " /DefaultBranchName:`"$defaultBranch`"";
|
};
|
||||||
}
|
|
||||||
|
|
||||||
Install-ChocoPackage git -ArgumentList "--params", $params;
|
|
||||||
} `
|
|
||||||
-Configurator {
|
|
||||||
& $base ([InstallerAction]::Configure) @args;
|
|
||||||
} `
|
|
||||||
-UserConfigurator {
|
|
||||||
& $base ([InstallerAction]::ConfigureUser) @args;
|
|
||||||
};
|
|
||||||
} @args;
|
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
& {
|
. "$PSScriptRoot/../../Scripts/SoftwareManagement.ps1";
|
||||||
. "$PSScriptRoot/../../Scripts/SoftwareManagement.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
|
||||||
$base = "$PSScriptRoot/../../../Common/Software/vscode/Main.ps1";
|
|
||||||
|
|
||||||
Start-SoftwareInstaller @args `
|
Start-SoftwareInstaller @args `
|
||||||
-Installer {
|
-Inherit "$PSScriptRoot/../../../Common/Software/vscode/Main.ps1" `
|
||||||
Install-ChocoPackage vscode -ArgumentList "--params", "/NoDesktopIcon";
|
-Installer {
|
||||||
Install-ChocoPackage vscodium -ArgumentList "--params", "/NoDesktopIcon /AssociateWithFiles";
|
Install-ChocoPackage vscode -ArgumentList "--params", "/NoDesktopIcon";
|
||||||
refreshenv;
|
Install-ChocoPackage vscodium -ArgumentList "--params", "/NoDesktopIcon /AssociateWithFiles";
|
||||||
} `
|
refreshenv;
|
||||||
-UserConfigurator {
|
};
|
||||||
& $base ([InstallerAction]::ConfigureUser) @args;
|
|
||||||
};
|
|
||||||
} @args;
|
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
|
||||||
& {
|
Start-SoftwareInstaller @args `
|
||||||
Start-SoftwareInstaller @args `
|
-Installer {
|
||||||
-Installer {
|
$xamlDownloadLink = "https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx";
|
||||||
$xamlDownloadLink = "https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx";
|
$downloadLink = "https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle";
|
||||||
$downloadLink = "https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle";
|
$file = New-TemporaryFile;
|
||||||
$file = New-TemporaryFile;
|
$file = Rename-Item $file "$file.msixbundle" -PassThru;
|
||||||
$file = Rename-Item $file "$file.msixbundle" -PassThru;
|
Invoke-WebRequest "$xamlDownloadLink" -OutFile "$file";
|
||||||
Invoke-WebRequest "$xamlDownloadLink" -OutFile "$file";
|
Add-AppxPackage "$file" -ErrorAction Continue;
|
||||||
Add-AppxPackage "$file" -ErrorAction Continue;
|
Invoke-WebRequest "$downloadLink" -OutFile "$file";
|
||||||
Invoke-WebRequest "$downloadLink" -OutFile "$file";
|
Add-AppxPackage "$file" -ErrorAction Continue;
|
||||||
Add-AppxPackage "$file" -ErrorAction Continue;
|
Remove-Item $file;
|
||||||
Remove-Item $file;
|
};
|
||||||
};
|
|
||||||
} @args;
|
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
& {
|
. "$PSScriptRoot/../../Scripts/SoftwareManagement.ps1";
|
||||||
. "$PSScriptRoot/../../Scripts/SoftwareManagement.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Software/PowerShell/Profile.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Software/PowerShell/Profile.ps1";
|
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
|
||||||
$base = "$PSScriptRoot/../../../Common/Software/zoxide/Main.ps1";
|
|
||||||
|
|
||||||
Start-SoftwareInstaller @args `
|
Start-SoftwareInstaller @args `
|
||||||
-Installer {
|
-Inherit "$PSScriptRoot/../../../Common/Software/zoxide/Main.ps1" `
|
||||||
Install-ChocoPackage zoxide;
|
-Installer {
|
||||||
Install-WingetPackage junegunn.fzf;
|
Install-ChocoPackage zoxide;
|
||||||
} `
|
Install-WingetPackage junegunn.fzf;
|
||||||
-Configurator {
|
};
|
||||||
& $base ([InstallerAction]::Configure) @args;
|
|
||||||
};
|
|
||||||
} @args;
|
|
Loading…
Reference in a new issue