Make software name available in scripts
This commit is contained in:
parent
50b4a30256
commit
5ae07886c8
15 changed files with 116 additions and 50 deletions
|
@ -317,21 +317,25 @@ $null = New-Module {
|
|||
}
|
||||
|
||||
Start-Operation {
|
||||
if ($null -ne $Name) {
|
||||
$Name = "``$Name``";
|
||||
} else {
|
||||
$Name = "unknown software";
|
||||
}
|
||||
|
||||
$installHandler = {
|
||||
param(
|
||||
[string] $Name,
|
||||
[InstallerAction] $Action,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
[string] $DisplayName = $null;
|
||||
|
||||
if ($null -ne $Name) {
|
||||
$DisplayName = "``$Name``";
|
||||
} else {
|
||||
$DisplayName = "unknown software";
|
||||
}
|
||||
|
||||
$Arguments ??= @{ };
|
||||
|
||||
$argumentList = @{
|
||||
name = $Name;
|
||||
installer = $installHandler;
|
||||
arguments = $Arguments;
|
||||
};
|
||||
|
@ -339,13 +343,13 @@ $null = New-Module {
|
|||
switch ($Action) {
|
||||
([InstallerAction]::Backup) {
|
||||
if ($Backup) {
|
||||
Write-Host "Backing up $Name…";
|
||||
Write-Host "Backing up $DisplayName…";
|
||||
& $Backup @argumentList;
|
||||
}
|
||||
}
|
||||
([InstallerAction]::Install) {
|
||||
if ($Installer) {
|
||||
Write-Host "Installing $Name…";
|
||||
Write-Host "Installing $DisplayName…";
|
||||
& $Installer @argumentList;
|
||||
}
|
||||
|
||||
|
@ -357,7 +361,7 @@ $null = New-Module {
|
|||
}
|
||||
([InstallerAction]::Configure) {
|
||||
if ($Configurator) {
|
||||
Write-Host "Configuring $Name…";
|
||||
Write-Host "Configuring $DisplayName…";
|
||||
& $Configurator @argumentList;
|
||||
}
|
||||
}
|
||||
|
@ -372,13 +376,13 @@ $null = New-Module {
|
|||
switch ($_) {
|
||||
([InstallerAction]::BackupUser) {
|
||||
if ($UserBackup) {
|
||||
Write-Host "Backing up $Name for user ``$user``…";
|
||||
Write-Host "Backing up $DisplayName for user ``$user``…";
|
||||
& $UserBackup @argumentList;
|
||||
}
|
||||
}
|
||||
([InstallerAction]::ConfigureUser) {
|
||||
if ($UserConfigurator) {
|
||||
Write-Host "Configuring $Name for user ``$user``…";
|
||||
Write-Host "Configuring $DisplayName for user ``$user``…";
|
||||
& $UserConfigurator @argumentList;
|
||||
}
|
||||
}
|
||||
|
@ -387,7 +391,7 @@ $null = New-Module {
|
|||
}
|
||||
};
|
||||
|
||||
& $installHandler -Action $Action -Arguments $Arguments;
|
||||
& $installHandler -Name $Name -Action $Action -Arguments $Arguments;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,11 @@ param (
|
|||
|
||||
Start-SoftwareInstaller @PSBoundParameters `
|
||||
-Configurator {
|
||||
param([string] $Name)
|
||||
|
||||
Add-PowerShellProfileStatement `
|
||||
-System `
|
||||
-Category "oh-my-posh" `
|
||||
-Category "$Name" `
|
||||
-Script (
|
||||
@(
|
||||
"# Oh My Posh!",
|
||||
|
|
|
@ -9,6 +9,7 @@ param(
|
|||
|
||||
Start-SoftwareInstaller @PSBoundParameters `
|
||||
-Configurator {
|
||||
param([string] $Name)
|
||||
. "$PSScriptRoot/Constants.ps1";
|
||||
$pathExpression = Get-GlobalConfigExpression;
|
||||
$path = Get-GlobalConfigPath;
|
||||
|
@ -17,7 +18,7 @@ Start-SoftwareInstaller @PSBoundParameters `
|
|||
|
||||
Add-PowerShellProfileStatement `
|
||||
-System `
|
||||
-Category "aliae" `
|
||||
-Category $Name `
|
||||
-Script (
|
||||
@(
|
||||
{
|
||||
|
|
|
@ -8,12 +8,14 @@ param(
|
|||
|
||||
Start-SoftwareInstaller @PSBoundParameters `
|
||||
-Configurator {
|
||||
param([string] $Name)
|
||||
|
||||
Add-PowerShellProfileStatement `
|
||||
-System `
|
||||
-Category "zoxide" `
|
||||
-Category "$Name" `
|
||||
-Script (
|
||||
@(
|
||||
"# zoxide",
|
||||
"# $Name",
|
||||
(Get-ScriptInitializer "zoxide init powershell | Out-String")
|
||||
) -join [System.Environment]::NewLine);
|
||||
};
|
||||
|
|
|
@ -63,21 +63,23 @@ param(
|
|||
} `
|
||||
-UserBackup {
|
||||
param(
|
||||
[string] $Name,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
Edit-LGHubConfig {
|
||||
Add-BackupArtifacts -User $Arguments.Name -Source $configPath -Path "LGHub" `
|
||||
Add-BackupArtifacts -User $Arguments.Name -Source $configPath -Path "$Name" `
|
||||
-Include @("settings.db", "icon_cache")
|
||||
};
|
||||
} `
|
||||
-UserConfigurator {
|
||||
param(
|
||||
[string] $Name,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
Edit-LGHubConfig {
|
||||
Expand-BackupArtifacts -User $Arguments.Name -Path "LGHub" -Target $configPath;
|
||||
Expand-BackupArtifacts -User $Arguments.Name -Path "$Name" -Target $configPath;
|
||||
};
|
||||
};
|
||||
} $PSBoundParameters;
|
||||
|
|
|
@ -17,10 +17,11 @@ param(
|
|||
} `
|
||||
-UserBackup {
|
||||
param(
|
||||
[string] $Name,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
Add-BackupArtifacts -User $Arguments.Name -Source $path -Path "ManiaPlanet" `
|
||||
Add-BackupArtifacts -User $Arguments.Name -Source $path -Path "$Name" `
|
||||
-Include @(
|
||||
"Actions",
|
||||
"Blocks",
|
||||
|
@ -36,9 +37,10 @@ param(
|
|||
} `
|
||||
-UserConfigurator {
|
||||
param(
|
||||
[string] $Name,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
Expand-BackupArtifacts -User $Arguments.Name -Path "ManiaPlanet" -Target $path;
|
||||
Expand-BackupArtifacts -User $Arguments.Name -Path "$Name" -Target $path;
|
||||
};
|
||||
} $PSBoundParameters;
|
||||
|
|
|
@ -14,18 +14,26 @@ Start-SoftwareInstaller @PSBoundParameters `
|
|||
Install-ChocoPackage putty;
|
||||
} `
|
||||
-UserBackup {
|
||||
param([hashtable] $Arguments)
|
||||
param(
|
||||
[string] $Name,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
$dir = New-TemporaryDirectory;
|
||||
$fileName = Join-Path "$dir" PuTTY.reg;
|
||||
& reg export "HKCU\Software\SimonTatham\PuTTY" $fileName /y;
|
||||
Add-BackupArtifacts -User $Arguments.Name -Source $fileName -Path "PuTTY/PuTTY.reg";
|
||||
Add-BackupArtifacts -User $Arguments.Name -Source $fileName -Path "$Name/$Name.reg";
|
||||
Remove-Item -Recurse -Force $dir;
|
||||
} `
|
||||
-UserConfigurator {
|
||||
param([hashtable] $Arguments)
|
||||
param(
|
||||
[string] $Name,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
$dir = New-TemporaryDirectory;
|
||||
$fileName = Join-Path "$dir" PuTTY.reg;
|
||||
Expand-BackupArtifacts -User $Arguments.Name -Path "PuTTY/PuTTY.reg" -Target $fileName;
|
||||
Expand-BackupArtifacts -User $Arguments.Name -Path "$Name/$Name.reg" -Target $fileName;
|
||||
& reg import $fileName;
|
||||
Remove-Item -Recurse -Force $dir;
|
||||
};
|
||||
|
|
|
@ -12,7 +12,9 @@ param(
|
|||
|
||||
Start-SoftwareInstaller @Parameters `
|
||||
-Backup {
|
||||
Add-BackupArtifacts -Path "RetroArch" -Source $path `
|
||||
param([string] $Name)
|
||||
|
||||
Add-BackupArtifacts -Path "$Name" -Source $path `
|
||||
-Include @(
|
||||
"config",
|
||||
"cores",
|
||||
|
@ -29,7 +31,8 @@ param(
|
|||
Install-ChocoPackage retroarch;
|
||||
} `
|
||||
-Configurator {
|
||||
param([string] $Name)
|
||||
Add-StartMenuIcon "RetroArch" "C:\tools\RetroArch-Win64\retroarch.exe";
|
||||
Expand-BackupArtifacts -Path "RetroArch" -Target $path;
|
||||
Expand-BackupArtifacts -Path "$Name" -Target $path;
|
||||
};
|
||||
} $PSBoundParameters;
|
||||
|
|
|
@ -23,10 +23,14 @@ param(
|
|||
Remove-DesktopIcon "*TmNationsForever*";
|
||||
} `
|
||||
-UserBackup {
|
||||
param([hashtable] $Arguments)
|
||||
param(
|
||||
[string] $Name,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
$name = $Arguments.Name;
|
||||
|
||||
Add-BackupArtifacts -User $name -Source $path -Path "TmNationsForever" `
|
||||
Add-BackupArtifacts -User $name -Source $path -Path "$Name" `
|
||||
-Include @(
|
||||
"ChallengeMusics",
|
||||
"MediaTracker",
|
||||
|
@ -38,8 +42,12 @@ param(
|
|||
);
|
||||
} `
|
||||
-UserConfigurator {
|
||||
param([hashtable] $Arguments)
|
||||
$name = $Arguments.Name;
|
||||
Expand-BackupArtifacts -User $name -Path "TmNationsForever" -Target $path;
|
||||
param(
|
||||
[string] $Name,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
$user = $Arguments.Name;
|
||||
Expand-BackupArtifacts -User $user -Path "$Name" -Target $path;
|
||||
};
|
||||
} $PSBoundParameters;
|
||||
|
|
|
@ -35,8 +35,12 @@ param(
|
|||
Remove-Item -Recurse $dir;
|
||||
} `
|
||||
-UserBackup {
|
||||
param([hashtable] $Arguments)
|
||||
Add-BackupArtifacts -User $Arguments.Name -Source $path -Path "TmUnitedForever" `
|
||||
param(
|
||||
[string] $Name,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
Add-BackupArtifacts -User $Arguments.Name -Source $path -Path "$Name" `
|
||||
-Include @(
|
||||
"ChallengeMusics",
|
||||
"MediaTracker",
|
||||
|
@ -47,7 +51,11 @@ param(
|
|||
);
|
||||
} `
|
||||
-UserConfigurator {
|
||||
param([hashtable] $Arguments)
|
||||
Expand-BackupArtifacts -User $Arguments.Name -Path "TmUnitedForever" -Target $path;
|
||||
param(
|
||||
[string] $Name,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
Expand-BackupArtifacts -User $Arguments.Name -Path "$Name" -Target $path;
|
||||
};
|
||||
} $PSBoundParameters;
|
||||
|
|
|
@ -36,14 +36,17 @@ param(
|
|||
#>
|
||||
function Get-ConfigPath {
|
||||
param(
|
||||
[string] $Name,
|
||||
[string] $PackageName
|
||||
)
|
||||
|
||||
return Join-Path "Visual Studio" "$PackageName.vsconfig";
|
||||
return Join-Path "$Name" "$PackageName.vsconfig";
|
||||
}
|
||||
|
||||
Start-SoftwareInstaller @parameters `
|
||||
-Backup {
|
||||
param([string] $Name)
|
||||
|
||||
foreach ($version in $versions) {
|
||||
if (Test-ChocoPackage $version[0]) {
|
||||
Write-Host "Backing up ``$($version[0])…";
|
||||
|
@ -58,17 +61,19 @@ param(
|
|||
"--quiet"
|
||||
);
|
||||
|
||||
Add-BackupArtifacts -Source $configFile -Path (Get-ConfigPath $version[0]);
|
||||
Add-BackupArtifacts -Source $configFile -Path (Get-ConfigPath $Name $version[0]);
|
||||
Remove-Item $configFile;
|
||||
}
|
||||
}
|
||||
} `
|
||||
-Installer {
|
||||
param([string] $Name)
|
||||
|
||||
foreach ($version in $versions) {
|
||||
$packageName = $version[0];
|
||||
$file = New-TemporaryFile;
|
||||
Remove-Item $file;
|
||||
Expand-BackupArtifacts -Path (Get-ConfigPath $packageName) -Target $file;
|
||||
Expand-BackupArtifacts -Path (Get-ConfigPath $Name $packageName) -Target $file;
|
||||
|
||||
if (Test-Path $file) {
|
||||
Write-Host "Restoring ``$packageName``…";
|
||||
|
|
|
@ -10,6 +10,7 @@ param(
|
|||
|
||||
Start-SoftwareInstaller @PSBoundParameters `
|
||||
-Configurator {
|
||||
param([string] $Name)
|
||||
[string] $backup = $null;
|
||||
$nativeProfile = powershell -c '$PROFILE';
|
||||
|
||||
|
@ -23,7 +24,7 @@ Start-SoftwareInstaller @PSBoundParameters `
|
|||
|
||||
Add-PowerShellProfileStatement `
|
||||
-DefaultUser `
|
||||
-Category "chocolatey" `
|
||||
-Category "$Name" `
|
||||
-Script (Get-Content $nativeProfile | Out-String) `
|
||||
-Append;
|
||||
|
||||
|
|
|
@ -20,7 +20,9 @@ param(
|
|||
Remove-DesktopIcon "*osu*";
|
||||
} `
|
||||
-Backup {
|
||||
Add-BackupArtifacts -Source (& $getInstallPath) -Path "osu!" `
|
||||
param([string] $Name)
|
||||
|
||||
Add-BackupArtifacts -Source (& $getInstallPath) -Path "$Name" `
|
||||
-Include @(
|
||||
"Screenshots",
|
||||
"Skins",
|
||||
|
@ -30,16 +32,22 @@ param(
|
|||
);
|
||||
} `
|
||||
-Configurator {
|
||||
Expand-BackupArtifacts -Path "osu!" -Target (& $getInstallPath);
|
||||
param([string] $Name)
|
||||
|
||||
Expand-BackupArtifacts -Path "$Name" -Target (& $getInstallPath);
|
||||
} `
|
||||
-UserBackup {
|
||||
param([hashtable] $Arguments)
|
||||
$name = $Arguments.Name;
|
||||
Add-BackupArtifacts -Source "$(& $getInstallPath)/osu!.$name.cfg" -User $name -Path "osu!/osu!.cfg";
|
||||
param(
|
||||
[string] $Name,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
$user = $Arguments.Name;
|
||||
Add-BackupArtifacts -Source "$(& $getInstallPath)/osu!.$user.cfg" -User $user -Path "$Name/osu!.cfg";
|
||||
} `
|
||||
-UserConfigurator {
|
||||
param([hashtable] $Arguments)
|
||||
$name = $Arguments.Name;
|
||||
Expand-BackupArtifacts -User $name -Path "osu!/osu!.cfg" -Target "$(& $getInstallPath)/osu!.$name.cfg";
|
||||
Expand-BackupArtifacts -User $name -Path "$Name/osu!.cfg" -Target "$(& $getInstallPath)/osu!.$name.cfg";
|
||||
};
|
||||
} $PSBoundParameters;
|
||||
|
|
|
@ -12,8 +12,12 @@ param(
|
|||
|
||||
Start-SoftwareInstaller @Parameters `
|
||||
-UserBackup {
|
||||
param([hashtable] $Arguments)
|
||||
Add-BackupArtifacts -User $Arguments.Name -Source $path -Path "osu!lazer" `
|
||||
param(
|
||||
[string] $Name,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
Add-BackupArtifacts -User $Arguments.Name -Source $path -Path "$Name" `
|
||||
-Include @(
|
||||
"files",
|
||||
"rulesets",
|
||||
|
@ -24,6 +28,11 @@ param(
|
|||
);
|
||||
} `
|
||||
-UserConfigurator {
|
||||
param(
|
||||
[string] $Name,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
$file = "osu!lazer.exe";
|
||||
$processName = "osu!";
|
||||
$dir = New-TemporaryDirectory;
|
||||
|
@ -42,6 +51,6 @@ param(
|
|||
Remove-Item -Recurse $dir;
|
||||
|
||||
Remove-DesktopIcon "*osu*";
|
||||
Expand-BackupArtifacts -User $Arguments.Name -Path "osu!lazer" -Target $path;
|
||||
Expand-BackupArtifacts -User $Arguments.Name -Path "$Name" -Target $path;
|
||||
};
|
||||
} $PSBoundParameters;
|
||||
|
|
|
@ -14,7 +14,9 @@ param(
|
|||
|
||||
Start-SoftwareInstaller @Parameters `
|
||||
-Backup {
|
||||
Add-BackupArtifacts -Path "reWASD" -Source $path `
|
||||
param([string] $Name)
|
||||
|
||||
Add-BackupArtifacts -Path "$Name" -Source $path `
|
||||
-Exclude @(
|
||||
"Logs",
|
||||
"Presets",
|
||||
|
@ -40,6 +42,7 @@ param(
|
|||
Remove-DesktopIcon "*reWASD*";
|
||||
} `
|
||||
-Configurator {
|
||||
Expand-BackupArtifacts -Path "reWASD" -Target $path;
|
||||
param([string] $Name)
|
||||
Expand-BackupArtifacts -Path "$Name" -Target $path;
|
||||
};
|
||||
} $PSBoundParameters;
|
||||
|
|
Loading…
Reference in a new issue