Add scripts for installing PS modules
This commit is contained in:
parent
dd902e4859
commit
5e2e43735e
54
scripts/Common/Software/PowerShell/Module.ps1
Normal file
54
scripts/Common/Software/PowerShell/Module.ps1
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
|
||||||
|
|
||||||
|
$null = New-Module {
|
||||||
|
. "$PSScriptRoot/../../Software/PowerShell/Profile.ps1";
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Generates the components for creating a module installer.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The name of the module to install.
|
||||||
|
#>
|
||||||
|
function Get-ModuleInstallerComponents {
|
||||||
|
param(
|
||||||
|
[string] $Name
|
||||||
|
)
|
||||||
|
|
||||||
|
@{
|
||||||
|
arguments = @{
|
||||||
|
name = $Name;
|
||||||
|
};
|
||||||
|
installer = {
|
||||||
|
param(
|
||||||
|
[scriptblock] $Installer,
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
$env:PENDING_MODULE_NAME = $Arguments.Name;
|
||||||
|
$installAction = { Install-Module -Scope AllUsers -Force $env:PENDING_MODULE_NAME @args };
|
||||||
|
& $installAction -AcceptLicense;
|
||||||
|
|
||||||
|
if (Test-Command powershell) {
|
||||||
|
powershell -c ($installAction.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
Remove-Item Env:\PENDING_MODULE_NAME;
|
||||||
|
& $Installer -Action ([InstallerAction]::Configure) @PSBoundParameters;
|
||||||
|
};
|
||||||
|
|
||||||
|
configurator = {
|
||||||
|
param(
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
$name = $Arguments.Name;
|
||||||
|
|
||||||
|
Add-PowerShellProfileStatement `
|
||||||
|
-DefaultUser `
|
||||||
|
-Category $name `
|
||||||
|
-Script "Import-Module `"$name`";";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
15
scripts/Common/Software/Terminal-Icons/Manage.ps1
Normal file
15
scripts/Common/Software/Terminal-Icons/Manage.ps1
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
param (
|
||||||
|
$Action,
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/../PowerShell/Module.ps1";
|
||||||
|
. "$PSScriptRoot/../../Scripts/Software.ps1";
|
||||||
|
|
||||||
|
$parameters = Get-ModuleInstallerComponents "Terminal-Icons";
|
||||||
|
|
||||||
|
foreach ($key in $PSBoundParameters.Keys) {
|
||||||
|
$parameters.Add($key, $PSBoundParameters.TryGetValue($key));
|
||||||
|
}
|
||||||
|
|
||||||
|
Start-SoftwareInstaller @parameters;
|
15
scripts/Common/Software/posh-git/Manage.ps1
Normal file
15
scripts/Common/Software/posh-git/Manage.ps1
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
param (
|
||||||
|
$Action,
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/../PowerShell/Module.ps1";
|
||||||
|
. "$PSScriptRoot/../../Scripts/Software.ps1";
|
||||||
|
|
||||||
|
$parameters = Get-ModuleInstallerComponents "posh-git";
|
||||||
|
|
||||||
|
foreach ($key in $PSBoundParameters.Keys) {
|
||||||
|
$parameters.Add($key, $PSBoundParameters.TryGetValue($key));
|
||||||
|
}
|
||||||
|
|
||||||
|
Start-SoftwareInstaller @parameters;
|
|
@ -178,6 +178,7 @@ $null = New-Module {
|
||||||
$null = New-Module {
|
$null = New-Module {
|
||||||
# Windows Config
|
# Windows Config
|
||||||
$softwarePath = "$PSScriptRoot/../Software";
|
$softwarePath = "$PSScriptRoot/../Software";
|
||||||
|
$commonSoftware = "$PSScriptRoot/../../Common/Software";
|
||||||
. "$softwarePath/Windows/Manage.ps1" @arguments;
|
. "$softwarePath/Windows/Manage.ps1" @arguments;
|
||||||
|
|
||||||
if (Test-Collection "essential") {
|
if (Test-Collection "essential") {
|
||||||
|
@ -185,6 +186,8 @@ $null = New-Module {
|
||||||
. "$softwarePath/OpenSSH/Manage.ps1" @arguments;
|
. "$softwarePath/OpenSSH/Manage.ps1" @arguments;
|
||||||
. "$softwarePath/PowerShell/Manage.ps1" @arguments;
|
. "$softwarePath/PowerShell/Manage.ps1" @arguments;
|
||||||
. "$softwarePath/chocolatey/Manage.ps1" @arguments;
|
. "$softwarePath/chocolatey/Manage.ps1" @arguments;
|
||||||
|
. "$commonSoftware/posh-git/Manage.ps1" @arguments;
|
||||||
|
. "$commonSoftware/Terminal-Icons/Manage.ps1" @arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Test-Collection "common") {
|
if (Test-Collection "common") {
|
||||||
|
|
Loading…
Reference in a new issue