2023-03-07 12:28:00 -08:00
$OFS = " `r`n "
$scriptname = "winutil.ps1"
2024-02-21 16:06:27 -06:00
# Variable to sync between runspaces
$sync = [ Hashtable ]:: Synchronized ( @ {})
$sync . PSScriptRoot = $PSScriptRoot
$sync . configs = @ {}
2023-03-07 12:28:00 -08:00
2023-07-13 15:46:00 -05:00
if ( Test-Path -Path " $( $scriptname ) " )
{
Remove-Item -Force " $( $scriptname ) "
}
2023-03-07 12:28:00 -08:00
Write-output '
################################################################################################################
### ###
### WARNING: This file is automatically generated DO NOT modify this file directly as it will be overwritten ###
### ###
################################################################################################################
' | Out-File ./ $scriptname -Append -Encoding ascii
2024-01-15 11:32:19 -06:00
( Get-Content .\ scripts \ start . ps1 ). replace ( '#{replaceme}' , " $( Get-Date -Format yy . MM . dd ) " ) | Out-File ./ $scriptname -Append -Encoding ascii
2023-03-07 12:28:00 -08:00
Get-ChildItem .\ functions -Recurse -File | ForEach-Object {
Get-Content $psitem . FullName | Out-File ./ $scriptname -Append -Encoding ascii
}
Get-ChildItem .\ config | Where-Object { $psitem . extension -eq ".json" } | ForEach-Object {
$json = ( Get-Content $psitem . FullName ). replace ( "'" , "''" )
2024-04-20 16:38:43 -05:00
# Replace every XML Special Character so it'll render correctly in final build
# Only do so if json files has content to be displayed (for example the applications, tweaks, features json files)
# Some Type Convertion using Casting and Cleaning Up of the convertion result using 'Replace' Method
$jsonAsObject = $json | convertfrom-json
$firstLevelJsonList = ([ System.String ] $jsonAsObject ). split ( '=;' ) | ForEach-Object {
$_ . Replace ( '=}' , '' ). Replace ( '@{' , '' ). Replace ( ' ' , '' )
}
for ( $i = 0 ; $i -lt $firstLevelJsonList . Count ; $i += 1 ) {
$firstLevelName = $firstLevelJsonList [ $i ]
# Note: Avoid using HTML Entity Codes (for example '”' (stands for "Right Double Quotation Mark")), and use HTML decimal/hex codes instead.
# as using HTML Entity Codes will result in XML parse Error when running the compiled script.
if ( $jsonAsObject . $firstLevelName . content -ne $null ) {
$jsonAsObject . $firstLevelName . content = $jsonAsObject . $firstLevelName . content . replace ( '&' , '&' ). replace ( '“' , '“' ). replace ( '”' , '”' ). replace ( "'" , ''' ). replace ( '<' , '<' ). replace ( '>' , '>' )
$jsonAsObject . $firstLevelName . content = $jsonAsObject . $firstLevelName . content . replace ( '''' , "'" ) # resolves the Double Apostrophe caused by the first replace function in the main loop
}
if ( $jsonAsObject . $firstLevelName . description -ne $null ) {
$jsonAsObject . $firstLevelName . description = $jsonAsObject . $firstLevelName . description . replace ( '&' , '&' ). replace ( '“' , '“' ). replace ( '”' , '”' ). replace ( "'" , ''' ). replace ( '<' , '<' ). replace ( '>' , '>' )
$jsonAsObject . $firstLevelName . description = $jsonAsObject . $firstLevelName . description . replace ( '''' , "'" ) # resolves the Double Apostrophe caused by the first replace function in the main loop
}
}
# The replace at the end is required, as without it the output of converto-json will be somewhat weird for Multiline String
# Most Notably is the scripts in json files, make=ing it harder for users who want to review these scripts that are found in the final compiled script
$json = ( $jsonAsObject | convertto-json -Depth 3 ). replace ( '\r\n' , " `r`n " )
2024-02-21 16:06:27 -06:00
$sync . configs . $ ( $psitem . BaseName ) = $json | convertfrom-json
2023-03-07 12:28:00 -08:00
Write-output " `$ sync.configs. $( $psitem . BaseName ) = ' $json ' `| convertfrom-json" | Out-File ./ $scriptname -Append -Encoding ascii
}
2024-06-04 20:27:27 -07:00
Get-ChildItem .\ config | Where-Object { $PSItem . Extension -eq ".cfg" } | ForEach-Object {
Write-output " `$ sync.configs. $( $psitem . BaseName ) = ' $( Get-Content $PSItem . FullName ) '" | Out-File ./ $scriptname -Append -Encoding ascii
}
2023-03-07 12:28:00 -08:00
2024-03-21 16:58:40 -07:00
$xaml = ( Get-Content .\ xaml \ inputXML . xaml ). replace ( "'" , "''" )
2024-02-21 16:06:27 -06:00
# Dot-source the Get-TabXaml function
. .\ functions \ private \ Get-TabXaml . ps1
## Xaml Manipulation
$tabColumns = Get-TabXaml "applications" 5
$tabColumns | Out-File -FilePath ".\xaml\inputApp.xaml" -Encoding ascii
2024-02-21 16:26:03 -06:00
$tabColumns = Get-TabXaml "tweaks"
$tabColumns | Out-File -FilePath ".\xaml\inputTweaks.xaml" -Encoding ascii
$tabColumns = Get-TabXaml "feature"
$tabColumns | Out-File -FilePath ".\xaml\inputFeatures.xaml" -Encoding ascii
2024-02-21 16:06:27 -06:00
2024-03-21 16:58:40 -07:00
# Assuming inputApp.xaml is in the same directory as main.ps1
$appXamlPath = Join-Path -Path $PSScriptRoot -ChildPath "xaml/inputApp.xaml"
$tweaksXamlPath = Join-Path -Path $PSScriptRoot -ChildPath "xaml/inputTweaks.xaml"
$featuresXamlPath = Join-Path -Path $PSScriptRoot -ChildPath "xaml/inputFeatures.xaml"
# Load the XAML content from inputApp.xaml
$appXamlContent = Get-Content -Path $appXamlPath -Raw
$tweaksXamlContent = Get-Content -Path $tweaksXamlPath -Raw
$featuresXamlContent = Get-Content -Path $featuresXamlPath -Raw
# Replace the placeholder in $inputXML with the content of inputApp.xaml
$xaml = $xaml -replace "{{InstallPanel_applications}}" , $appXamlContent
$xaml = $xaml -replace "{{InstallPanel_tweaks}}" , $tweaksXamlContent
$xaml = $xaml -replace "{{InstallPanel_features}}" , $featuresXamlContent
Write-output " `$ inputXML = ' $xaml '" | Out-File ./ $scriptname -Append -Encoding ascii
2024-04-20 16:38:43 -05:00
Get-Content .\ scripts \ main . ps1 | Out-File ./ $scriptname -Append -Encoding ascii