Remove the Need to add 'WPFInstall' for every App Entry Name in 'applications.json' File

This commit is contained in:
Mr.k 2024-06-19 17:39:38 +03:00
parent 08847099b4
commit bea7726587
No known key found for this signature in database
2 changed files with 366 additions and 353 deletions

View File

@ -74,9 +74,22 @@ Get-ChildItem .\config | Where-Object {$psitem.extension -eq ".json"} | ForEach-
$jsonAsObject.$firstLevelName.description = $jsonAsObject.$firstLevelName.description.replace('''',"'") # resolves the Double Apostrophe caused by the first replace function in the main loop $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 Strings
# Most Notably is the scripts in some json files, making it harder for users who want to review these scripts, which're found in the compiled script # Add 'WPFInstall' as a prefix to every entry-name in 'applications.json' file
$json = ($jsonAsObject | convertto-json -Depth 3).replace('\r\n',"`r`n") if ($psitem.Name -eq "applications.json") {
for ($i = 0; $i -lt $firstLevelJsonList.Count; $i += 1) {
$appEntryName = $firstLevelJsonList[$i]
$appEntryContent = $jsonAsObject.$appEntryName
# Remove the entire app entry, so we could add it later with a different name
$jsonAsObject.PSObject.Properties.Remove($appEntryName)
# Add the app entry, but with a different name (WPFInstall + The App Entry Name)
$jsonAsObject | Add-Member -MemberType NoteProperty -Name "WPFInstall$appEntryName" -Value $appEntryContent
}
}
# The replace at the end is required, as without it the output of 'converto-json' will be somewhat weird for Multiline Strings
# Most Notably is the scripts in some json files, making it harder for users who want to review these scripts, which're found in the compiled script
$json = ($jsonAsObject | convertto-json -Depth 3).replace('\r\n',"`r`n")
$sync.configs.$($psitem.BaseName) = $json | convertfrom-json $sync.configs.$($psitem.BaseName) = $json | convertfrom-json
$script_content.Add($(Write-output "`$sync.configs.$($psitem.BaseName) = '$json' `| convertfrom-json" )) $script_content.Add($(Write-output "`$sync.configs.$($psitem.BaseName) = '$json' `| convertfrom-json" ))

File diff suppressed because it is too large Load Diff