Skip to content

Commit

Permalink
Merge branch 'main' into improve-xaml-compile
Browse files Browse the repository at this point in the history
  • Loading branch information
ruxunderscore committed Sep 10, 2024
2 parents e8650e2 + e9a45a0 commit 5109907
Show file tree
Hide file tree
Showing 23 changed files with 543 additions and 366 deletions.
5 changes: 0 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Pull Request

<!--Before you make this PR have you followed the docs here? - https://christitustech.github.io/winutil/contribute/ -->

## Title
<!--[Provide a succinct and descriptive title for the pull request.]-->

## Type of Change
- [ ] New feature
- [ ] Bug fix
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:

- name: Generate Release Notes
id: generate_notes
uses: release-drafter/release-drafter@v5
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -91,7 +91,7 @@ jobs:
name: Pre-Release ${{ env.version }}
body: |
${{ steps.generate_notes.outputs.body }}
![GitHub Downloads (specific asset, specific tag)](https://img.shields.io/github/downloads/ChrisTitusTech/winutil/${{ env.VERSION }}/winutil.ps1)
append_body: false
files: ./winutil.ps1
Expand Down
38 changes: 23 additions & 15 deletions Compile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ param (
[switch]$SkipPreprocessing,
[string]$Arguments
)

if ((Get-Item ".\winutil.ps1" -ErrorAction SilentlyContinue).IsReadOnly) {
Remove-Item ".\winutil.ps1" -Force
}

$OFS = "`r`n"
$scriptname = "winutil.ps1"
$workingdir = $PSScriptRoot

Push-Location
Set-Location $workingdir

# Variable to sync between runspaces
$sync = [Hashtable]::Synchronized(@{})
$sync.PSScriptRoot = $workingdir
Expand Down Expand Up @@ -42,11 +50,11 @@ if (-NOT $SkipPreprocessing) {

# Dot source the 'Invoke-Preprocessing' Function from 'tools/Invoke-Preprocessing.ps1' Script
$preprocessingFilePath = ".\tools\Invoke-Preprocessing.ps1"
. "$(($workingdir -replace ('\\$', '')) + '\' + ($preprocessingFilePath -replace ('\.\\', '')))"
. $preprocessingFilePath

$excludedFiles = @('.\.git\', '.\.gitignore', '.\.gitattributes', '.\.github\CODEOWNERS', '.\LICENSE', "$preprocessingFilePath", '*.png', '*.exe')
$msg = "Pre-req: Code Formatting"
Invoke-Preprocessing -WorkingDir "$workingdir" -ExcludedFiles $excludedFiles -ProgressStatusMessage $msg
Invoke-Preprocessing -WorkingDir "$workingdir" -ExcludedFiles $excludedFiles -ProgressStatusMessage $msg -ThrowExceptionOnEmptyFilesList
}

# Create the script in memory.
Expand All @@ -57,14 +65,14 @@ Update-Progress "Adding: Header" 5
$script_content.Add($header)

Update-Progress "Adding: Version" 10
$script_content.Add($(Get-Content "$workingdir\scripts\start.ps1").replace('#{replaceme}',"$(Get-Date -Format yy.MM.dd)"))
$script_content.Add($(Get-Content "scripts\start.ps1").replace('#{replaceme}',"$(Get-Date -Format yy.MM.dd)"))

Update-Progress "Adding: Functions" 20
Get-ChildItem "$workingdir\functions" -Recurse -File | ForEach-Object {
Get-ChildItem "functions" -Recurse -File | ForEach-Object {
$script_content.Add($(Get-Content $psitem.FullName))
}
Update-Progress "Adding: Config *.json" 40
Get-ChildItem "$workingdir\config" | Where-Object {$psitem.extension -eq ".json"} | ForEach-Object {
Get-ChildItem "config" | Where-Object {$psitem.extension -eq ".json"} | ForEach-Object {
$json = (Get-Content $psitem.FullName).replace("'","''")
$jsonAsObject = $json | convertfrom-json

Expand Down Expand Up @@ -97,28 +105,27 @@ $xaml
'@
"@)

$script_content.Add($(Get-Content "$workingdir\scripts\main.ps1"))
$script_content.Add($(Get-Content "scripts\main.ps1"))

if ($Debug) {
Update-Progress "Writing debug files" 95
$appXamlContent | Out-File -FilePath "$workingdir\xaml\inputApp.xaml" -Encoding ascii
$tweaksXamlContent | Out-File -FilePath "$workingdir\xaml\inputTweaks.xaml" -Encoding ascii
$featuresXamlContent | Out-File -FilePath "$workingdir\xaml\inputFeatures.xaml" -Encoding ascii
$appXamlContent | Out-File -FilePath "xaml\inputApp.xaml" -Encoding ascii
$tweaksXamlContent | Out-File -FilePath "xaml\inputTweaks.xaml" -Encoding ascii
$featuresXamlContent | Out-File -FilePath "xaml\inputFeatures.xaml" -Encoding ascii
} else {
Update-Progress "Removing temporary files" 99
Remove-Item "$workingdir\xaml\inputApp.xaml" -ErrorAction SilentlyContinue
Remove-Item "$workingdir\xaml\inputTweaks.xaml" -ErrorAction SilentlyContinue
Remove-Item "$workingdir\xaml\inputFeatures.xaml" -ErrorAction SilentlyContinue
Remove-Item "xaml\inputApp.xaml" -ErrorAction SilentlyContinue
Remove-Item "xaml\inputTweaks.xaml" -ErrorAction SilentlyContinue
Remove-Item "xaml\inputFeatures.xaml" -ErrorAction SilentlyContinue
}

Set-Content -Path "$workingdir\$scriptname" -Value ($script_content -join "`r`n") -Encoding ascii
Set-Content -Path "$scriptname" -Value ($script_content -join "`r`n") -Encoding ascii
Write-Progress -Activity "Compiling" -Completed

Update-Progress -Activity "Validating" -StatusMessage "Checking winutil.ps1 Syntax" -Percent 0
try {
$null = Get-Command -Syntax .\winutil.ps1
}
catch {
} catch {
Write-Warning "Syntax Validation for 'winutil.ps1' has failed"
Write-Host "$($Error[0])" -ForegroundColor Red
}
Expand All @@ -134,3 +141,4 @@ if ($run) {

break
}
Pop-Location
2 changes: 1 addition & 1 deletion config/applications.json
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@
"content": "Google Drive",
"description": "File syncing across devices all tied to your google account",
"link": "https://www.google.com/drive/",
"winget": "Google.Drive"
"winget": "Google.GoogleDrive"
},
"gpuz": {
"category": "Utilities",
Expand Down
2 changes: 1 addition & 1 deletion config/autounattend.xml
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
<Extensions xmlns="https://schneegans.de/windows/unattend-generator/">
<ExtractScript>
param(
[xml] $Document
[xml]$Document
);

$scriptsDir = 'C:\Windows\Setup\Scripts\';
Expand Down
8 changes: 8 additions & 0 deletions config/feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@
"ButtonWidth": "300",
"link": "https://christitustech.github.io/winutil/dev/features/Legacy-Windows-Panels/sound"
},
"WPFPanelprinter": {
"Content": "Printer Panel",
"category": "Legacy Windows Panels",
"panel": "2",
"Type": "Button",
"ButtonWidth": "300",
"link": "https://christitustech.github.io/winutil/dev/features/Legacy-Windows-Panels/printer"
},
"WPFPanelsystem": {
"Content": "System Properties",
"category": "Legacy Windows Panels",
Expand Down
1 change: 0 additions & 1 deletion config/themes.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"TabRowHeightInPixels": "50",
"IconFontSize": "14",
"IconButtonSize": "35",
"WinUtilIconSize": "Auto",
"SettingsIconFontSize": "18",
"CloseIconFontSize": "18",

Expand Down
65 changes: 65 additions & 0 deletions docs/dev/features/Legacy-Windows-Panels/printer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Printer Settings

Last Updated: 2024-08-31


!!! info
The Development Documentation is auto generated for every compilation of WinUtil, meaning a part of it will always stay up-to-date. **Developers do have the ability to add custom content, which won't be updated automatically.**


<!-- BEGIN CUSTOM CONTENT -->

<!-- END CUSTOM CONTENT -->

<details>
<summary>Preview Code</summary>

```json
{
"Content": "Printer Settings",
"category": "Legacy Windows Panels",
"panel": "2",
"Type": "Button",
"ButtonWidth": "300"
}
```

</details>

## Function: Invoke-WPFControlPanel

```powershell
function Invoke-WPFControlPanel {
<#
.SYNOPSIS
Opens the requested legacy panel
.PARAMETER Panel
The panel to open
#>
param($Panel)
switch ($Panel) {
"WPFPanelcontrol" {cmd /c control}
"WPFPanelnetwork" {cmd /c ncpa.cpl}
"WPFPanelpower" {cmd /c powercfg.cpl}
"WPFPanelregion" {cmd /c intl.cpl}
"WPFPanelsound" {cmd /c mmsys.cpl}
"WPFPanelprinter" {Start-Process "shell:::{A8A91A66-3A7D-4424-8D24-04E180695C7A}"}
"WPFPanelsystem" {cmd /c sysdm.cpl}
"WPFPaneluser" {cmd /c "control userpasswords2"}
}
}
```


<!-- BEGIN SECOND CUSTOM CONTENT -->

<!-- END SECOND CUSTOM CONTENT -->


[View the JSON file](https://github.com/ChrisTitusTech/winutil/tree/main/../config/feature.json)

Loading

0 comments on commit 5109907

Please sign in to comment.