Allow inheriting PowerShell installers
This commit is contained in:
parent
4504ca85d4
commit
d9d1575a19
8 changed files with 64 additions and 97 deletions
|
@ -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";
|
||||||
|
|
||||||
& {
|
|
||||||
$base = "$PSScriptRoot/../../../Common/Software/Oh My Posh/Manage.ps1";
|
|
||||||
|
|
||||||
Start-SoftwareInstaller @args `
|
Start-SoftwareInstaller @args `
|
||||||
|
-Inherit "$PSScriptRoot/../../../Common/Software/Oh My Posh/Manage.ps1" `
|
||||||
-Installer {
|
-Installer {
|
||||||
Install-WingetPackage JanDeDobbeleer.OhMyPosh -ArgumentList "--scope", "machine";
|
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";
|
||||||
|
|
||||||
& {
|
|
||||||
$base = "$PSScriptRoot/../../../Common/Software/aliae/Main.ps1";
|
|
||||||
|
|
||||||
Start-SoftwareInstaller @args `
|
Start-SoftwareInstaller @args `
|
||||||
|
-Inherit "$PSScriptRoot/../../../Common/Software/aliae/Main.ps1" `
|
||||||
-Installer {
|
-Installer {
|
||||||
Install-WingetPackage JanDeDobbeleer.Aliae -ArgumentList "--scope", "machine";
|
Install-WingetPackage JanDeDobbeleer.Aliae -ArgumentList "--scope", "machine";
|
||||||
} `
|
|
||||||
-Configurator {
|
|
||||||
. $base -Action ([InstallerAction]::Configure) @args;
|
|
||||||
} `
|
|
||||||
-UserConfigurator {
|
|
||||||
. $base -Action ([InstallerAction]::ConfigureUser) @args;
|
|
||||||
};
|
};
|
||||||
} @args;
|
|
||||||
|
|
|
@ -3,11 +3,8 @@
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||||
|
|
||||||
& {
|
|
||||||
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
|
||||||
$base = "$PSScriptRoot/../../../Common/Software/git/Manage.ps1";
|
|
||||||
|
|
||||||
Start-SoftwareInstaller @args `
|
Start-SoftwareInstaller @args `
|
||||||
|
-Inherit "$PSScriptRoot/../../../Common/Software/git/Manage.ps1" `
|
||||||
-Installer {
|
-Installer {
|
||||||
$params = "/WindowsTerminalProfile";
|
$params = "/WindowsTerminalProfile";
|
||||||
$defaultBranch = Get-OSConfig "git.defaultBranch";
|
$defaultBranch = Get-OSConfig "git.defaultBranch";
|
||||||
|
@ -17,11 +14,4 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Install-ChocoPackage git -ArgumentList "--params", $params;
|
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 `
|
||||||
|
-Inherit "$PSScriptRoot/../../../Common/Software/vscode/Main.ps1" `
|
||||||
-Installer {
|
-Installer {
|
||||||
Install-ChocoPackage vscode -ArgumentList "--params", "/NoDesktopIcon";
|
Install-ChocoPackage vscode -ArgumentList "--params", "/NoDesktopIcon";
|
||||||
Install-ChocoPackage vscodium -ArgumentList "--params", "/NoDesktopIcon /AssociateWithFiles";
|
Install-ChocoPackage vscodium -ArgumentList "--params", "/NoDesktopIcon /AssociateWithFiles";
|
||||||
refreshenv;
|
refreshenv;
|
||||||
} `
|
|
||||||
-UserConfigurator {
|
|
||||||
& $base ([InstallerAction]::ConfigureUser) @args;
|
|
||||||
};
|
};
|
||||||
} @args;
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
. "$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";
|
||||||
|
@ -13,4 +12,3 @@
|
||||||
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 `
|
||||||
|
-Inherit "$PSScriptRoot/../../../Common/Software/zoxide/Main.ps1" `
|
||||||
-Installer {
|
-Installer {
|
||||||
Install-ChocoPackage zoxide;
|
Install-ChocoPackage zoxide;
|
||||||
Install-WingetPackage junegunn.fzf;
|
Install-WingetPackage junegunn.fzf;
|
||||||
} `
|
|
||||||
-Configurator {
|
|
||||||
& $base ([InstallerAction]::Configure) @args;
|
|
||||||
};
|
};
|
||||||
} @args;
|
|
||||||
|
|
Loading…
Reference in a new issue