Assets/postinst.ps1

#Requires -RunAsAdministrator

<#
.SYNOPSIS
Post-installation Script
 
.DESCRIPTION
This script will be executed at the end of installation.
Simply put this script in the `build/${TARGET}` folder where ${TARGET} is Windows/macOS/Linux and it will (should ?) be automatically run as the last step of installation process.
 
#>

[CmdletBinding()]
param (
    [switch]$Configure
)

Start-Transcript -Path $PSScriptRoot\postinst.log
$BASENAME = Split-Path -Path $PSCommandPath -Leaf
$INSTDIR = (Resolve-Path "$PSScriptRoot\..").Path.TrimEnd('/\')
[string]$arg = ""
Foreach ($p in $PSBoundParameters.GetEnumerator()) {
    $arg += "-$($p.key) $($p.value) "
}
Write-Output "$BASENAME $arg"

# . "$PSScriptRoot\windows.inc.ps1"

if ($Configure) {
    if (!(Get-PackageProvider -Name NuGet -Force)) { Install-PackageProvider -Name NuGet -Force -Confirm:$false }
    Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
    $modules = @()
    $modules += "PwSh.Fw.Core"
    # $modules += "<ADD HERE SOME MODULE NAME TO INSTALL>"
    foreach ($m in $modules) {
        Write-Output "Install module $m"
        Install-Module $m -Scope AllUsers -Force
    }
}
Stop-Transcript