
&"$PSScriptRoot\vars.ps1"
&"$PSScriptRoot\vars-config.ps1"

&"$ROOT\Scripts\check-dep.ps1"
# Prompt the user to identify the installation type
# Loop until the user enters a valid response: Y/y/N/n
# Ask user if this is a customer installation
do {
    $userResponse = Read-Host "Is this installation for the customer? (Y/N)"
} while ($userResponse -notmatch '^[YyNn]$') # Regex to allow only Y, y, N, or n

$skipComposerInstall = $userResponse -match '^[Yy]$'

# Run Composer install only if this is NOT a customer installation
if (-not $skipComposerInstall) {
    &"$PHPexe" "$ROOT/Var/composer.phar" install --working-dir="$ROOT/Var/" --no-ansi --no-dev --no-interaction --no-plugins --no-progress --no-scripts --optimize-autoloader --prefer-dist
} else {
    Write-Host "Skipping Composer install for customer deployment."
}

@(
'vendor\ezyang\htmlpurifier\library\HTMLPurifier\DefinitionCache'
) | ForEach-Object {
    Write-Host $_
    $path = "$ROOT/$_"
    $acl = Get-Acl $path
    ForEach ($usr in $CEDAR_INSTALL_USERS)
    {
        $a = New-Object System.Security.AccessControl.FileSystemAccessRule($usr, "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
        $acl.AddAccessRule($a)
    }
    $acl.SetAccessRuleProtection($false,$true)
    Set-Acl $path $acl
}
