From fc505872d2c8da9f1dfb869ad8d6e311ee3470a2 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Mon, 19 Feb 2024 18:32:13 -0600 Subject: [PATCH 01/20] Update close-old-issues.yaml --- .github/workflows/close-old-issues.yaml | 56 ++++++++++++------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/.github/workflows/close-old-issues.yaml b/.github/workflows/close-old-issues.yaml index 5b472bc0..7fca4ccc 100644 --- a/.github/workflows/close-old-issues.yaml +++ b/.github/workflows/close-old-issues.yaml @@ -14,43 +14,39 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const octokit = github.getOctokit(); + const octokit = context.octokit; // Get the repository owner and name - const { owner, repo } = github.context.repo; + const { owner, repo } = context.repo; // Define the inactivity period (14 days) const inactivityPeriod = new Date(); inactivityPeriod.setDate(inactivityPeriod.getDate() - 14); - async function run() { - // Get all open issues - const issues = await octokit.issues.listForRepo({ - owner, - repo, - state: 'open', - }); + // Get all open issues + const { data: issues } = await octokit.rest.issues.listForRepo({ + owner, + repo, + state: 'open', + }); - // Close issues inactive for more than the inactivity period - for (const issue of issues.data) { - const lastCommentDate = issue.updated_at; - if (new Date(lastCommentDate) < inactivityPeriod) { - // Close the issue and add a comment - await octokit.issues.update({ - owner, - repo, - issue_number: issue.number, - state: 'closed', - }); + // Close issues inactive for more than the inactivity period + for (const issue of issues) { + const lastCommentDate = issue.updated_at; + if (new Date(lastCommentDate) < inactivityPeriod) { + // Close the issue and add a comment + await octokit.rest.issues.update({ + owner, + repo, + issue_number: issue.number, + state: 'closed', + }); - await octokit.issues.createComment({ - owner, - repo, - issue_number: issue.number, - body: 'Closed due to inactivity', - }); - } + await octokit.rest.issues.createComment({ + owner, + repo, + issue_number: issue.number, + body: 'Closed due to inactivity', + }); } - } - - run().catch(error => console.error(error)); + } \ No newline at end of file From 8e00077e50073cfd4b5d5f15fdee08d4d098d28f Mon Sep 17 00:00:00 2001 From: ChrisTitusTech Date: Tue, 20 Feb 2024 00:32:36 +0000 Subject: [PATCH 02/20] Compile Winutil --- winutil.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/winutil.ps1 b/winutil.ps1 index 3e750be9..2ec7e27d 100644 --- a/winutil.ps1 +++ b/winutil.ps1 @@ -10,7 +10,7 @@ Author : Chris Titus @christitustech Runspace Author: @DeveloperDurp GitHub : https://github.com/ChrisTitusTech - Version : 24.02.07 + Version : 24.02.20 #> param ( [switch]$Debug, @@ -47,7 +47,7 @@ Add-Type -AssemblyName System.Windows.Forms # Variable to sync between runspaces $sync = [Hashtable]::Synchronized(@{}) $sync.PSScriptRoot = $PSScriptRoot -$sync.version = "24.02.07" +$sync.version = "24.02.20" $sync.configs = @{} $sync.ProcessRunning = $false @@ -7660,7 +7660,7 @@ $sync.configs.applications = '{ "WPFInstallintelpresentmon": { "category": "Utilities", "choco": "na", - "content": "Intel? PresentMon", + "content": "Intel?? PresentMon", "description": "A new gaming performance overlay and telemetry application to monitor and measure your gaming experience.", "link": "https://game.intel.com/us/stories/intel-presentmon/", "winget": "Intel.PresentMon.Beta" From 07eeed310b155048e036f0752f3ea10fa3c393f7 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Mon, 19 Feb 2024 18:39:24 -0600 Subject: [PATCH 03/20] Update close-old-issues.yaml --- .github/workflows/close-old-issues.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/close-old-issues.yaml b/.github/workflows/close-old-issues.yaml index 7fca4ccc..72a3ca8e 100644 --- a/.github/workflows/close-old-issues.yaml +++ b/.github/workflows/close-old-issues.yaml @@ -14,7 +14,7 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const octokit = context.octokit; + const octokit = github; // Get the repository owner and name const { owner, repo } = context.repo; From e745d798b112514162b7785fe4e90337892b97d4 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Mon, 19 Feb 2024 18:43:44 -0600 Subject: [PATCH 04/20] Update close-old-issues.yaml --- .github/workflows/close-old-issues.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/close-old-issues.yaml b/.github/workflows/close-old-issues.yaml index 72a3ca8e..e4910adc 100644 --- a/.github/workflows/close-old-issues.yaml +++ b/.github/workflows/close-old-issues.yaml @@ -3,7 +3,7 @@ name: Close Inactive Issues on: schedule: - cron: '0 0 * * *' # Run daily - + workflow_dispatch: # This line enables manual triggering jobs: close-issues: runs-on: ubuntu-latest From 31c6622926996854555e140acea128684a9fe9d5 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Mon, 19 Feb 2024 21:43:49 -0600 Subject: [PATCH 05/20] Update close-old-issues.yaml --- .github/workflows/close-old-issues.yaml | 61 +++++++++++++++---------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/.github/workflows/close-old-issues.yaml b/.github/workflows/close-old-issues.yaml index e4910adc..1b129a0a 100644 --- a/.github/workflows/close-old-issues.yaml +++ b/.github/workflows/close-old-issues.yaml @@ -7,6 +7,8 @@ on: jobs: close-issues: runs-on: ubuntu-latest + permissions: + issues: write # Ensure necessary permissions for issues steps: - name: Close inactive issues @@ -23,30 +25,41 @@ jobs: const inactivityPeriod = new Date(); inactivityPeriod.setDate(inactivityPeriod.getDate() - 14); - // Get all open issues - const { data: issues } = await octokit.rest.issues.listForRepo({ - owner, - repo, - state: 'open', - }); + try { + // Get all open issues with pagination + for await (const response of octokit.paginate.iterator(octokit.rest.issues.listForRepo, { + owner, + repo, + state: 'open', + })) { + const issues = response.data; - // Close issues inactive for more than the inactivity period - for (const issue of issues) { - const lastCommentDate = issue.updated_at; - if (new Date(lastCommentDate) < inactivityPeriod) { - // Close the issue and add a comment - await octokit.rest.issues.update({ - owner, - repo, - issue_number: issue.number, - state: 'closed', - }); + // Close issues inactive for more than the inactivity period + for (const issue of issues) { + const lastCommentDate = issue.updated_at; + if (new Date(lastCommentDate) < inactivityPeriod) { + try { + // Close the issue + await octokit.rest.issues.update({ + owner, + repo, + issue_number: issue.number, + state: 'closed', + }); - await octokit.rest.issues.createComment({ - owner, - repo, - issue_number: issue.number, - body: 'Closed due to inactivity', - }); + // Add a comment + await octokit.rest.issues.createComment({ + owner, + repo, + issue_number: issue.number, + body: 'Closed due to inactivity', + }); + } catch (error) { + console.error(`Error updating or commenting on issue #${issue.number}: ${error}`); + } + } + } } - } \ No newline at end of file + } catch (error) { + console.error(`Error fetching issues: ${error}`); + } From cfd2f54827112546af5c360e6aa7a7bde7143a48 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Wed, 21 Feb 2024 11:12:49 -0600 Subject: [PATCH 06/20] Bring workflow to test (#1638) * Update close-old-issues.yaml * Compile Winutil * Update close-old-issues.yaml * Update close-old-issues.yaml * Update close-old-issues.yaml --------- Co-authored-by: ChrisTitusTech --- .github/workflows/close-old-issues.yaml | 61 ++++++++++++++----------- winutil.ps1 | 4 +- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/.github/workflows/close-old-issues.yaml b/.github/workflows/close-old-issues.yaml index 5b472bc0..1b129a0a 100644 --- a/.github/workflows/close-old-issues.yaml +++ b/.github/workflows/close-old-issues.yaml @@ -3,10 +3,12 @@ name: Close Inactive Issues on: schedule: - cron: '0 0 * * *' # Run daily - + workflow_dispatch: # This line enables manual triggering jobs: close-issues: runs-on: ubuntu-latest + permissions: + issues: write # Ensure necessary permissions for issues steps: - name: Close inactive issues @@ -14,43 +16,50 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const octokit = github.getOctokit(); + const octokit = github; // Get the repository owner and name - const { owner, repo } = github.context.repo; + const { owner, repo } = context.repo; // Define the inactivity period (14 days) const inactivityPeriod = new Date(); inactivityPeriod.setDate(inactivityPeriod.getDate() - 14); - async function run() { - // Get all open issues - const issues = await octokit.issues.listForRepo({ + try { + // Get all open issues with pagination + for await (const response of octokit.paginate.iterator(octokit.rest.issues.listForRepo, { owner, repo, state: 'open', - }); + })) { + const issues = response.data; - // Close issues inactive for more than the inactivity period - for (const issue of issues.data) { - const lastCommentDate = issue.updated_at; - if (new Date(lastCommentDate) < inactivityPeriod) { - // Close the issue and add a comment - await octokit.issues.update({ - owner, - repo, - issue_number: issue.number, - state: 'closed', - }); + // Close issues inactive for more than the inactivity period + for (const issue of issues) { + const lastCommentDate = issue.updated_at; + if (new Date(lastCommentDate) < inactivityPeriod) { + try { + // Close the issue + await octokit.rest.issues.update({ + owner, + repo, + issue_number: issue.number, + state: 'closed', + }); - await octokit.issues.createComment({ - owner, - repo, - issue_number: issue.number, - body: 'Closed due to inactivity', - }); + // Add a comment + await octokit.rest.issues.createComment({ + owner, + repo, + issue_number: issue.number, + body: 'Closed due to inactivity', + }); + } catch (error) { + console.error(`Error updating or commenting on issue #${issue.number}: ${error}`); + } + } } } + } catch (error) { + console.error(`Error fetching issues: ${error}`); } - - run().catch(error => console.error(error)); diff --git a/winutil.ps1 b/winutil.ps1 index 0a93b6a2..1fba3f53 100644 --- a/winutil.ps1 +++ b/winutil.ps1 @@ -10,7 +10,7 @@ Author : Chris Titus @christitustech Runspace Author: @DeveloperDurp GitHub : https://github.com/ChrisTitusTech - Version : 24.02.12 + Version : 24.02.20 #> param ( [switch]$Debug, @@ -47,7 +47,7 @@ Add-Type -AssemblyName System.Windows.Forms # Variable to sync between runspaces $sync = [Hashtable]::Synchronized(@{}) $sync.PSScriptRoot = $PSScriptRoot -$sync.version = "24.02.12" +$sync.version = "24.02.20" $sync.configs = @{} $sync.ProcessRunning = $false From f6e9028fdb3ec0439ad038571312f46c448e0ebb Mon Sep 17 00:00:00 2001 From: ChrisTitusTech Date: Wed, 21 Feb 2024 17:13:14 +0000 Subject: [PATCH 07/20] Compile Winutil --- winutil.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winutil.ps1 b/winutil.ps1 index 1fba3f53..9e279b50 100644 --- a/winutil.ps1 +++ b/winutil.ps1 @@ -10,7 +10,7 @@ Author : Chris Titus @christitustech Runspace Author: @DeveloperDurp GitHub : https://github.com/ChrisTitusTech - Version : 24.02.20 + Version : 24.02.21 #> param ( [switch]$Debug, @@ -47,7 +47,7 @@ Add-Type -AssemblyName System.Windows.Forms # Variable to sync between runspaces $sync = [Hashtable]::Synchronized(@{}) $sync.PSScriptRoot = $PSScriptRoot -$sync.version = "24.02.20" +$sync.version = "24.02.21" $sync.configs = @{} $sync.ProcessRunning = $false From f83d7126bcd3f9626113d47910a997552c70c77d Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Wed, 21 Feb 2024 16:06:27 -0600 Subject: [PATCH 08/20] Change Dynamic xaml to static --- Compile.ps1 | 22 +- functions/private/Get-TabXaml.ps1 | 125 +++++ scripts/main.ps1 | 115 +--- winutil.ps1 | 244 ++++---- xaml/inputApp.xaml | 894 ++++++++++++++++++++++++++++++ 5 files changed, 1173 insertions(+), 227 deletions(-) create mode 100644 functions/private/Get-TabXaml.ps1 create mode 100644 xaml/inputApp.xaml diff --git a/Compile.ps1 b/Compile.ps1 index 1bb5b03f..c04c600b 100644 --- a/Compile.ps1 +++ b/Compile.ps1 @@ -1,6 +1,9 @@ $OFS = "`r`n" $scriptname = "winutil.ps1" - +# Variable to sync between runspaces +$sync = [Hashtable]::Synchronized(@{}) +$sync.PSScriptRoot = $PSScriptRoot +$sync.configs = @{} if (Test-Path -Path "$($scriptname)") { @@ -21,15 +24,20 @@ Get-ChildItem .\functions -Recurse -File | ForEach-Object { Get-Content $psitem.FullName | Out-File ./$scriptname -Append -Encoding ascii } -Get-ChildItem .\xaml | ForEach-Object { - $xaml = (Get-Content $psitem.FullName).replace("'","''") - Write-output "`$$($psitem.BaseName) = '$xaml'" | Out-File ./$scriptname -Append -Encoding ascii -} +$xaml = (Get-Content .\xaml\inputXML.xaml).replace("'","''") +Write-output "`$inputXML = '$xaml'" | Out-File ./$scriptname -Append -Encoding ascii Get-ChildItem .\config | Where-Object {$psitem.extension -eq ".json"} | ForEach-Object { $json = (Get-Content $psitem.FullName).replace("'","''") - + $sync.configs.$($psitem.BaseName) = $json | convertfrom-json Write-output "`$sync.configs.$($psitem.BaseName) = '$json' `| convertfrom-json" | Out-File ./$scriptname -Append -Encoding ascii } -Get-Content .\scripts\main.ps1 | Out-File ./$scriptname -Append -Encoding ascii +# 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 + +Get-Content .\scripts\main.ps1 | Out-File ./$scriptname -Append -Encoding ascii \ No newline at end of file diff --git a/functions/private/Get-TabXaml.ps1 b/functions/private/Get-TabXaml.ps1 new file mode 100644 index 00000000..a420e344 --- /dev/null +++ b/functions/private/Get-TabXaml.ps1 @@ -0,0 +1,125 @@ +function Get-TabXaml { + <# + .SYNOPSIS + Generates XAML for a tab in the WinUtil GUI + This function is used to generate the XAML for the applications tab in the WinUtil GUI + It takes the tabname and the number of columns to display the applications in as input and returns the XAML for the tab as output + .PARAMETER tabname + The name of the tab to generate XAML for + .PARAMETER columncount + The number of columns to display the applications in + .OUTPUTS + The XAML for the tab + .EXAMPLE + Get-TabXaml "applications" 3 + #> + + + param( [Parameter(Mandatory=$true)] + $tabname, + $columncount = 0 + ) + $organizedData = @{} + # Iterate through JSON data and organize by panel and category + foreach ($appName in $sync.configs.$tabname.PSObject.Properties.Name) { + $appInfo = $sync.configs.$tabname.$appName + + # Create an object for the application + $appObject = [PSCustomObject]@{ + Name = $appName + Category = $appInfo.Category + Content = $appInfo.Content + Choco = $appInfo.choco + Winget = $appInfo.winget + Panel = if ($columncount -gt 0 ) { "0" } else {$appInfo.panel} + Link = $appInfo.link + Description = $appInfo.description + # Type is (Checkbox,Toggle,Button,Combobox ) (Default is Checkbox) + Type = $appInfo.type + ComboItems = $appInfo.ComboItems + # Checked is the property to set startup checked status of checkbox (Default is false) + Checked = $appInfo.Checked + } + + if (-not $organizedData.ContainsKey($appObject.panel)) { + $organizedData[$appObject.panel] = @{} + } + + if (-not $organizedData[$appObject.panel].ContainsKey($appObject.Category)) { + $organizedData[$appObject.panel][$appObject.Category] = @{} + } + + # Store application data in a sub-array under the category + # Add Order property to keep the original order of tweaks and features + $organizedData[$appObject.panel][$appInfo.Category]["$($appInfo.order)$appName"] = $appObject + } + $panelcount=0 + $paneltotal = $organizedData.Keys.Count + if ($columncount -gt 0) { + $appcount = $sync.configs.$tabname.PSObject.Properties.Name.count + $organizedData["0"].Keys.count + $maxcount = [Math]::Round( $appcount / $columncount + 0.5) + $paneltotal = $columncount + } + # add ColumnDefinitions to evenly draw colums + $blockXml="`n"+("`n"*($paneltotal))+"`n" + # Iterate through organizedData by panel, category, and application + $count = 0 + foreach ($panel in ($organizedData.Keys | Sort-Object)) { + $blockXml += "`n`n" + $panelcount++ + foreach ($category in ($organizedData[$panel].Keys | Sort-Object)) { + $count++ + if ($columncount -gt 0) { + $panelcount2 = [Int](($count)/$maxcount-0.5) + if ($panelcount -eq $panelcount2 ) { + $blockXml +="`n`n`n" + $blockXml += "`n`n" + $panelcount++ + } + } + $blockXml += "`n`n" + $blockXml += "`n`n" + $panelcount++ + } + } + $appInfo = $organizedData[$panel][$category][$appName] + if ("Toggle" -eq $appInfo.Type) { + $blockXml += "`n`n" + } elseif ("Combobox" -eq $appInfo.Type) { + $blockXml += "`n" + # If it is a digit, type is button and button length is digits + } elseif ($appInfo.Type -match "^[\d\.]+$") { + $blockXml += " - - - - - - Choose Windows SKU - - Choose Windows features you want to remove from the ISO - - - - - - - - - - - + + + + + + Choose Windows SKU + + Choose Windows features you want to remove from the ISO + + + + + + + + + + +