From e4fa099097611ebe5e02a798eb95dfc999706dcd Mon Sep 17 00:00:00 2001 From: Alex Tu <6798052+AlexTu2@users.noreply.github.com> Date: Mon, 12 Feb 2024 18:13:58 -0500 Subject: [PATCH 01/10] Update Dev Toys URL (#1606) --- config/applications.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/applications.json b/config/applications.json index 29f505c3..b3496185 100755 --- a/config/applications.json +++ b/config/applications.json @@ -324,7 +324,7 @@ "choco": "devToys", "content": "Devtoys", "description": "Devtoys is a collection of development-related utilities and tools for Windows. It includes tools for file management, code formatting, and productivity enhancements for developers.", - "link": "https://dev.to/devtoys", + "link": "https://devtoys.app/", "winget": "devtoys" }, "WPFInstalldigikam": { From 70ec48130505b61dbdb196c09938720c21bce402 Mon Sep 17 00:00:00 2001 From: ChrisTitusTech Date: Mon, 12 Feb 2024 23:14:20 +0000 Subject: [PATCH 02/10] Compile Winutil --- winutil.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/winutil.ps1 b/winutil.ps1 index 0ecc36f8..0a93b6a2 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.08 + Version : 24.02.12 #> 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.08" +$sync.version = "24.02.12" $sync.configs = @{} $sync.ProcessRunning = $false @@ -5726,7 +5726,7 @@ $sync.configs.applications = '{ "choco": "devToys", "content": "Devtoys", "description": "Devtoys is a collection of development-related utilities and tools for Windows. It includes tools for file management, code formatting, and productivity enhancements for developers.", - "link": "https://dev.to/devtoys", + "link": "https://devtoys.app/", "winget": "devtoys" }, "WPFInstalldigikam": { From cfd2f54827112546af5c360e6aa7a7bde7143a48 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Wed, 21 Feb 2024 11:12:49 -0600 Subject: [PATCH 03/10] 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 04/10] 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 05/10] 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 += "