From a9daaa9d2b5f1fc56a3096967c4b1a407fd3dd1f Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 24 Aug 2024 01:16:56 +0200 Subject: [PATCH] Install `vscode` extensions by default --- scripts/Common/Software/vscode/Main.ps1 | 26 ++++++++++++++++++++++ scripts/Common/Software/vscode/main.fish | 14 ++---------- scripts/Windows/OS/Install.ps1 | 4 +--- scripts/Windows/Software/vscode/Main.ps1 | 28 ++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 15 deletions(-) create mode 100644 scripts/Common/Software/vscode/Main.ps1 create mode 100644 scripts/Windows/Software/vscode/Main.ps1 diff --git a/scripts/Common/Software/vscode/Main.ps1 b/scripts/Common/Software/vscode/Main.ps1 new file mode 100644 index 00000000..91199e69 --- /dev/null +++ b/scripts/Common/Software/vscode/Main.ps1 @@ -0,0 +1,26 @@ +param( + $Action, + [hashtable] $Arguments +) + +. "$PSScriptRoot/../../../Common/Scripts/Software.ps1"; +. "$PSScriptRoot/../../../Common/Scripts/SoftwareManagement.ps1"; + +Start-SoftwareInstaller @PSBoundParameters ` + -UserConfigurator { + param( + $Arguments + ) + + $bins = @("codium", "codium-insiders", "code", "code-insiders"); + $extensions = @("zokugun.sync-settings", "zokugun.vsix-manager"); + $user = $Arguments.Name; + + foreach ($bin in $bins) { + if (Test-Command "$bin") { + foreach ($extension in $extensions) { + sudo -u "$user" "$bin" --install-extension "$extension"; + } + } + } + }; diff --git a/scripts/Common/Software/vscode/main.fish b/scripts/Common/Software/vscode/main.fish index 90b0221e..6cf00c40 100755 --- a/scripts/Common/Software/vscode/main.fish +++ b/scripts/Common/Software/vscode/main.fish @@ -2,19 +2,9 @@ begin set -l dir (status dirname) source "$dir/../../Scripts/software.fish" - source "$dir/../../../Common/Software/aliae/main.fish" - function userConfig -a name - set -l bins codium codium-insiders code code-insiders - set -l extensions zokugun.{sync-settings,vsix-manager} - - for bin in $bins - if type -q "$bin" - for extension in $extensions - sudo -u "$name" "$bin" --install-extension "$extension" - end - end - end + function userConfig -V dir -a name + pwsh "$dir/Main.ps1" ConfigureUser; end runInstaller $argv diff --git a/scripts/Windows/OS/Install.ps1 b/scripts/Windows/OS/Install.ps1 index cb961ab5..3968e821 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -458,9 +458,6 @@ $null = New-Module { if (Test-Collection "coding") { if ($install) { - Install-ChocoPackage vscode -ArgumentList "--params","/NoDesktopIcon"; - Install-ChocoPackage vscodium -ArgumentList "--params","/NoDesktopIcon /AssociateWithFiles"; - Install-ChocoPackage ` gh ` github-desktop ` @@ -476,6 +473,7 @@ $null = New-Module { Remove-DesktopIcon "Docker*"; } + & "$softwarePath/vscode/Main.ps1" @arguments; & "$softwarePath/VisualStudio/Manage.ps1" @arguments; # Node.js diff --git a/scripts/Windows/Software/vscode/Main.ps1 b/scripts/Windows/Software/vscode/Main.ps1 new file mode 100644 index 00000000..96141b58 --- /dev/null +++ b/scripts/Windows/Software/vscode/Main.ps1 @@ -0,0 +1,28 @@ +param( + $Action, + [hashtable] $Arguments +) + +& { + param ( + [hashtable] $Parameters + ) + + . "$PSScriptRoot/../../../Common/Scripts/Software.ps1"; + . "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1"; + $base = "$PSScriptRoot/../../../Common/Software/vscode/Main.ps1"; + + Start-SoftwareInstaller @Parameters ` + -Installer { + Install-ChocoPackage vscode -ArgumentList "--params","/NoDesktopIcon"; + Install-ChocoPackage vscodium -ArgumentList "--params","/NoDesktopIcon /AssociateWithFiles"; + refreshenv; + } ` + -UserConfigurator { + param( + $Arguments + ) + + & $base ([InstallerAction]::ConfigureUser) @PSBoundParameters; + }; +} $PSBoundParameters;