From 9d74268da9be5baa4bba3d1ed3d47c15630b69d9 Mon Sep 17 00:00:00 2001 From: Zakaria Tahri <101801384+Zakariathr22@users.noreply.github.com> Date: Tue, 14 Jan 2025 17:46:02 +0100 Subject: [PATCH 1/8] Maintaining the Currency of Recently Added and Updated Samples --- WinUIGallery/DataModel/ControlInfoData.json | 41 ++++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/WinUIGallery/DataModel/ControlInfoData.json b/WinUIGallery/DataModel/ControlInfoData.json index d28fc748d..a010e209f 100644 --- a/WinUIGallery/DataModel/ControlInfoData.json +++ b/WinUIGallery/DataModel/ControlInfoData.json @@ -208,6 +208,7 @@ "Subtitle": "An object which is used to define the look and feel of a given command.", "ImagePath": "ms-appx:///Assets/ControlImages/AppBarSeparator.png", "Description": "An object which is used to define the look and feel of a given command, which can be reused across your app, and which is understood natively by the standard XAML controls.", + "IsUpdated": true, "Docs": [ { "Title": "Guidelines", @@ -499,6 +500,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/MenuFlyout.png", "Description": "A MenuFlyout displays lightweight UI that is light dismissed by clicking or tapping off of it. Use it to let the user choose from a contextual list of simple commands or options.", "Content": "
Look at the MenuFlyoutPage.xaml file in Visual Studio to see the full code.
", + "IsUpdated": true, "SourcePath": "/CommonStyles/MenuFlyout_themeresources.xaml", "Docs": [ { @@ -552,7 +554,7 @@ "Subtitle": "Touch gesture for quick menu actions on items.", "ImagePath": "ms-appx:///Assets/ControlImages/SwipeControl.png", "Description": "Touch gesture for quick menu actions on items.", - "IsUpdated": true, + "IsUpdated": false, "Docs": [ { "Title": "SwipeControl - API", @@ -821,6 +823,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/TreeView.png", "Description": "The TreeView control is a hierarchical list pattern with expanding and collapsing nodes that contain nested items. ", "Content": "PullToRefresh can be used for a collection of items of any type. To populate the view, add items to the Items collection, or set the ItemsSource property to a data source.
Set an ItemTemplate to define the look of individual items.
Look at the ListViewPage.xaml file in Visual Studio to see the full code for this page.
", + "IsUpdated": true, "SourcePath": "/TreeView", "Docs": [ { @@ -1004,7 +1007,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/Button.png", "Description": "The Button control provides a Click event to respond to user input from a touch, mouse, keyboard, stylus, or other input device. You can put different kinds of content in a button, such as text or an image, or you can restyle a button to give it a new look.", "Content": "The main purpose of a Button is to make something happen when a user clicks it. There are two ways you can make something happen:
Buttons often have only simple string content, but you can use any object as content. You can also change the style and template to give them any look you want.
Look at the ButtonPage.xaml file in Visual Studio to see the custom button style and template definitions used on this page.
", - "IsUpdated": true, + "IsUpdated": false, "SourcePath": "/CommonStyles/Button_themeresources.xaml", "Docs": [ { @@ -1183,7 +1186,7 @@ "Subtitle": "A two-part button that displays a flyout when its secondary part is clicked.", "ImagePath": "ms-appx:///Assets/ControlImages/SplitButton.png", "Description": "The splitbutton is a dropdown button, but with an addition execution hit target.", - "IsUpdated": true, + "IsUpdated": false, "SourcePath": "/SplitButton", "Docs": [ { @@ -1259,7 +1262,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/CheckBox.png", "Description": "CheckBox controls let the user select a combination of binary options. In contrast, RadioButton controls allow the user to select from mutually exclusive options. The indeterminate state is used to indicate that an option is set for some, but not all, child options. Don't allow users to set an indeterminate state directly to indicate a third option.", "Content": "Check and uncheck these controls to see how they look in each state. The label for each CheckBox is defined by its Content property.
Use a three-state CheckBox to show that none, some, or all of an items sub-options are checked. You have to add some code to do this. Take a look at the methods in the SelectAllMethods region of CheckBoxPage.xaml.cs to see how we did it.
", - "IsUpdated": true, + "IsUpdated": false, "SourcePath": "/CommonStyles/CheckBox_themeresources.xaml", "Docs": [ { @@ -1428,7 +1431,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/Slider.png", "Description": "Use a Slider when you want your users to be able to set defined, contiguous values (such as volume or brightness) or a range of discrete values (such as screen resolution settings).", "Content": "Look at the SliderPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": true, + "IsUpdated": false, "SourcePath": "/CommonStyles/Slider_themeresources.xaml", "Docs": [ { @@ -1502,6 +1505,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/InfoBadge.png", "Description": "Badging is a non-intrusive and intuitive way to display notifications or bring focus to an area within an app - whether that be for notifications, indicating new content, or showing an alert.", "Content": "Look at the InfoBadgePage.xaml file in Visual Studio to see the full code for this page.
", + "IsNew": true, "SourcePath": "/InfoBadge", "Docs": [ { @@ -1533,7 +1537,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/InfoBar.png", "Description": "Use an InfoBar control when a user should be informed of, acknowledge, or take action on a changed application state. By default the notification will remain in the content area until closed by the user but will not necessarily break user flow.", "Content": "Look at the InfoBarPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": true, + "IsUpdated": false, "SourcePath": "/InfoBar", "Docs": [ { @@ -1668,7 +1672,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/ContentDialog.png", "Description": "Use a ContentDialog to show relavant information or to provide a modal dialog experience that can show any XAML content.", "Content": "Look at the ContentDialog.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": true, + "IsUpdated": false, "SourcePath": "/CommonStyles/ContentDialog_themeresources.xaml", "Docs": [ { @@ -1759,6 +1763,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/TeachingTip.png", "Description": "The XAML TeachingTip Control provides a way for your app to guide and inform users in your application with a non-invasive and content rich notification. TeachingTip can be used for bringing focus to a new or important feature, teaching users how to perform a task, or enhancing the user workflow by providing contextually relevant information to their task at hand.", "Content": "Look at the TeachingTip.xaml file in Visual Studio to see the full code for this page.
", + "IsUpdated": true, "SourcePath": "/TeachingTip", "Docs": [ { @@ -1860,6 +1865,7 @@ "Description": "A ScrollView lets a user scroll, pan, and zoom to see content that's larger than the viewable area. The ItemsView has a ScrollView built into its control template to provide automatic scrolling.", "Content": "Look at the ScrollViewPage.xaml file in Visual Studio to see the full code for this page.
", "IsNew": true, + "IsUpdated": true, "SourcePath": "/ScrollView", "Docs": [ { @@ -1898,7 +1904,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/ScrollViewer.png", "Description": "A ScrollViewer lets a user scroll, pan, and zoom to see content that's larger than the viewable area. Many content controls, like ListView, have ScrollViewers built into their control templates to provide automatic scrolling.", "Content": "Look at the ScrollViewerPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": true, + "IsUpdated": false, "SourcePath": "/CommonStyles/ScrollViewer_themeresources.xaml", "Docs": [ { @@ -2309,6 +2315,7 @@ "Subtitle": "A container control that scales its content to a specified size.", "ImagePath": "ms-appx:///Assets/ControlImages/Viewbox.png", "Description": "Use a Viewbox control scale content up or down to a specified size.", + "IsNew": true, "Content": "Look at the ViewboxPage.xaml file in Visual Studio to see the full code for this page.
", "Docs": [ { @@ -2347,7 +2354,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/BreadcrumbBar.png", "Description": "The BreadcrumbBar control provides a common horizontal layout to display the trail of navigation taken to the current location. Resize to see the nodes crumble, starting at the root.", "Content": "Look at the BreadcrumbBarPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": true, + "IsUpdated": false, "SourcePath": "/Breadcrumb", "Docs": [ { @@ -2474,6 +2481,7 @@ "Subtitle": "A control that displays a collection of tabs that can be used to display several documents.", "ImagePath": "ms-appx:///Assets/ControlImages/TabView.png", "Description": "TabView provides the user with a collection of tabs that can be used to display several documents.", + "IsUpdated": true, "SourcePath": "/TabView", "Docs": [ { @@ -2548,6 +2556,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/CaptureElement.png", "Description": "You can use a MediaPlayerElement control to show a camera preview with a MediaCapture object.", "IsNew": true, + "IsUpdated": true, "Docs": [ { "Title": "MediaCapture - API", @@ -2760,7 +2769,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/AnimatedIcon.png", "Description": "An element that displays and controls an icon that animates when the user interacts with the control.", "Content": "Look at the AnimatedIconPage.xaml and AnimatedIconPage.xaml.cs files in Visual Studio to see the full code for this page.
", - "IsUpdated": true, + "IsUpdated": false, "SourcePath": "/AnimatedIcon", "Docs": [ { @@ -2787,6 +2796,7 @@ "Subtitle": "How to use a Resource Dictionary to enable compact sizing.", "ImagePath": "ms-appx:///Assets/ControlImages/CompactSizing.png", "Description": "Enables the creation of compact, smaller apps by adding a style resource at the app, page or control level.", + "IsUpdated": true, "Docs": [ { "Title": "Spacing", @@ -3002,6 +3012,7 @@ "Description": "Use NumberBox to allow users to enter algebraic equations and numeric input in your app.", "Content": "Look at the NumberBox.xaml file in Visual Studio to see the full code for this page.
", "SourcePath": "/NumberBox", + "IsUpdated": true, "Docs": [ { "Title": "NumberBox - API", @@ -3067,7 +3078,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/RichEditBox.png", "Description": "You can use a RichEditBox control to enter and edit rich text documents that contain formatted text, hyperlinks, and images. By default, the RichEditBox supports spell checking. You can make a RichEditBox read-only by setting its IsReadOnly property to true.", "Content": "On this page, you can type into the RichTextBox control and save it as a RichTextFormat (.rtf) document, or load an existing .rtf document. You can format the text as Bold or Underlined, and change the text color.
Look at the RichEditBoxPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": true, + "IsUpdated": false, "SourcePath": "/CommonStyles/RichEditBox_themeresources.xaml", "Docs": [ { @@ -3100,7 +3111,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/RichTextBlock.png", "Description": "RichTextBlock provides more advanced formatting features than the TextBlock control. You can apply character and paragraph formatting to the text in the RichTextBlock. For example, you can apply Bold, Italic, and Underline to any portion of the text in the control. You can use linked text containers (a RichTextBlock linked to RichTextBlockOverflow elements) to create advanced page layouts.", "Content": "Change the width of the app to see how the RichTextBlock overflows into additional columns as the app gets narrower.
Look at the RichTextBlockPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": true, + "IsUpdated": false, "Docs": [ { "Title": "RichTextBlock - API", @@ -3459,7 +3470,7 @@ "ImagePath": "ms-appx:///Assets/ControlImages/Clipboard.png", "Description": "Copy and paste to and from the system Clipboard.", "Content": "Look at the ClipboardPage.xaml file in Visual Studio to see the full code for this page.
", - "IsNew": true, + "IsNew": false, "Docs": [ { "Title": "Clipboard - API", @@ -3478,7 +3489,8 @@ "ImagePath": "ms-appx:///Assets/ControlImages/FilePicker.png", "Description": "Shows how to access files and folders by letting the user choose them through the file pickers and how to save a file so that the user can specify the name, file type, and location of a file to save.", "Content": "Look at the FilePickerPage.xaml file in Visual Studio to see the full code for this page.
", - "IsNew": true, + "IsUpdated": true, + "IsNew": false, "Docs": [ { "Title": "FilePicker - API", @@ -3497,6 +3509,7 @@ "Description": "Provides an edit box where you can type in some markup and load it to see how it looks and behaves.", "Content": "Look at the ScratchPadPage.xaml file in Visual Studio to see the full code for this page.
", "IsNew": true, + "isUpdated": true, "Docs": [ { "Title": "XamlReader - API", From d68b5e1418033955877082a34974a8b4878e70d4 Mon Sep 17 00:00:00 2001 From: Zakaria Tahri <101801384+Zakariathr22@users.noreply.github.com> Date: Wed, 15 Jan 2025 12:24:04 +0100 Subject: [PATCH 2/8] Update ControlInfoData.json by removing "IsUpdated": false and "IsNew": false --- WinUIGallery/DataModel/ControlInfoData.json | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/WinUIGallery/DataModel/ControlInfoData.json b/WinUIGallery/DataModel/ControlInfoData.json index a010e209f..13455c9ca 100644 --- a/WinUIGallery/DataModel/ControlInfoData.json +++ b/WinUIGallery/DataModel/ControlInfoData.json @@ -554,7 +554,6 @@ "Subtitle": "Touch gesture for quick menu actions on items.", "ImagePath": "ms-appx:///Assets/ControlImages/SwipeControl.png", "Description": "Touch gesture for quick menu actions on items.", - "IsUpdated": false, "Docs": [ { "Title": "SwipeControl - API", @@ -1007,7 +1006,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/Button.png", "Description": "The Button control provides a Click event to respond to user input from a touch, mouse, keyboard, stylus, or other input device. You can put different kinds of content in a button, such as text or an image, or you can restyle a button to give it a new look.", "Content": "The main purpose of a Button is to make something happen when a user clicks it. There are two ways you can make something happen:
Buttons often have only simple string content, but you can use any object as content. You can also change the style and template to give them any look you want.
Look at the ButtonPage.xaml file in Visual Studio to see the custom button style and template definitions used on this page.
", - "IsUpdated": false, "SourcePath": "/CommonStyles/Button_themeresources.xaml", "Docs": [ { @@ -1186,7 +1184,6 @@ "Subtitle": "A two-part button that displays a flyout when its secondary part is clicked.", "ImagePath": "ms-appx:///Assets/ControlImages/SplitButton.png", "Description": "The splitbutton is a dropdown button, but with an addition execution hit target.", - "IsUpdated": false, "SourcePath": "/SplitButton", "Docs": [ { @@ -1262,7 +1259,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/CheckBox.png", "Description": "CheckBox controls let the user select a combination of binary options. In contrast, RadioButton controls allow the user to select from mutually exclusive options. The indeterminate state is used to indicate that an option is set for some, but not all, child options. Don't allow users to set an indeterminate state directly to indicate a third option.", "Content": "Check and uncheck these controls to see how they look in each state. The label for each CheckBox is defined by its Content property.
Use a three-state CheckBox to show that none, some, or all of an items sub-options are checked. You have to add some code to do this. Take a look at the methods in the SelectAllMethods region of CheckBoxPage.xaml.cs to see how we did it.
", - "IsUpdated": false, "SourcePath": "/CommonStyles/CheckBox_themeresources.xaml", "Docs": [ { @@ -1431,7 +1427,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/Slider.png", "Description": "Use a Slider when you want your users to be able to set defined, contiguous values (such as volume or brightness) or a range of discrete values (such as screen resolution settings).", "Content": "Look at the SliderPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": false, "SourcePath": "/CommonStyles/Slider_themeresources.xaml", "Docs": [ { @@ -1537,7 +1532,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/InfoBar.png", "Description": "Use an InfoBar control when a user should be informed of, acknowledge, or take action on a changed application state. By default the notification will remain in the content area until closed by the user but will not necessarily break user flow.", "Content": "Look at the InfoBarPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": false, "SourcePath": "/InfoBar", "Docs": [ { @@ -1672,7 +1666,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/ContentDialog.png", "Description": "Use a ContentDialog to show relavant information or to provide a modal dialog experience that can show any XAML content.", "Content": "Look at the ContentDialog.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": false, "SourcePath": "/CommonStyles/ContentDialog_themeresources.xaml", "Docs": [ { @@ -1904,7 +1897,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/ScrollViewer.png", "Description": "A ScrollViewer lets a user scroll, pan, and zoom to see content that's larger than the viewable area. Many content controls, like ListView, have ScrollViewers built into their control templates to provide automatic scrolling.", "Content": "Look at the ScrollViewerPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": false, "SourcePath": "/CommonStyles/ScrollViewer_themeresources.xaml", "Docs": [ { @@ -2354,7 +2346,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/BreadcrumbBar.png", "Description": "The BreadcrumbBar control provides a common horizontal layout to display the trail of navigation taken to the current location. Resize to see the nodes crumble, starting at the root.", "Content": "Look at the BreadcrumbBarPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": false, "SourcePath": "/Breadcrumb", "Docs": [ { @@ -2769,7 +2760,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/AnimatedIcon.png", "Description": "An element that displays and controls an icon that animates when the user interacts with the control.", "Content": "Look at the AnimatedIconPage.xaml and AnimatedIconPage.xaml.cs files in Visual Studio to see the full code for this page.
", - "IsUpdated": false, "SourcePath": "/AnimatedIcon", "Docs": [ { @@ -3078,7 +3068,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/RichEditBox.png", "Description": "You can use a RichEditBox control to enter and edit rich text documents that contain formatted text, hyperlinks, and images. By default, the RichEditBox supports spell checking. You can make a RichEditBox read-only by setting its IsReadOnly property to true.", "Content": "On this page, you can type into the RichTextBox control and save it as a RichTextFormat (.rtf) document, or load an existing .rtf document. You can format the text as Bold or Underlined, and change the text color.
Look at the RichEditBoxPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": false, "SourcePath": "/CommonStyles/RichEditBox_themeresources.xaml", "Docs": [ { @@ -3111,7 +3100,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/RichTextBlock.png", "Description": "RichTextBlock provides more advanced formatting features than the TextBlock control. You can apply character and paragraph formatting to the text in the RichTextBlock. For example, you can apply Bold, Italic, and Underline to any portion of the text in the control. You can use linked text containers (a RichTextBlock linked to RichTextBlockOverflow elements) to create advanced page layouts.", "Content": "Change the width of the app to see how the RichTextBlock overflows into additional columns as the app gets narrower.
Look at the RichTextBlockPage.xaml file in Visual Studio to see the full code for this page.
", - "IsUpdated": false, "Docs": [ { "Title": "RichTextBlock - API", @@ -3470,7 +3458,6 @@ "ImagePath": "ms-appx:///Assets/ControlImages/Clipboard.png", "Description": "Copy and paste to and from the system Clipboard.", "Content": "Look at the ClipboardPage.xaml file in Visual Studio to see the full code for this page.
", - "IsNew": false, "Docs": [ { "Title": "Clipboard - API", @@ -3490,7 +3477,6 @@ "Description": "Shows how to access files and folders by letting the user choose them through the file pickers and how to save a file so that the user can specify the name, file type, and location of a file to save.", "Content": "Look at the FilePickerPage.xaml file in Visual Studio to see the full code for this page.
", "IsUpdated": true, - "IsNew": false, "Docs": [ { "Title": "FilePicker - API", From f55419439e9e8b586b23547cc5a2cee3f5682dd7 Mon Sep 17 00:00:00 2001 From: Zakaria Tahri <101801384+Zakariathr22@users.noreply.github.com> Date: Thu, 23 Jan 2025 08:31:19 +0100 Subject: [PATCH 3/8] Create Tools folder and add scripts for commit analysis: Get-LatestAddedSamples.ps1 and Get-LatestUpdatedSamples.ps1 - Created a new "Tools" folder to organize utility scripts. - Moved two PowerShell scripts into the "Tools" folder: 1. "Get-LatestAddedSamples.ps1" - Script for listing and sorting files based on their first commit date. 2. "Get-LatestUpdatedSamples.ps1" - Script for listing and sorting modified files based on their last commit date. These scripts help track file changes and updates based on commit history. --- WinUIGallery/Tools/Get-LatestAddedSamples.ps1 | 47 ++++++++++++++++++ .../Tools/Get-LatestUpdatedSamples.ps1 | 49 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 WinUIGallery/Tools/Get-LatestAddedSamples.ps1 create mode 100644 WinUIGallery/Tools/Get-LatestUpdatedSamples.ps1 diff --git a/WinUIGallery/Tools/Get-LatestAddedSamples.ps1 b/WinUIGallery/Tools/Get-LatestAddedSamples.ps1 new file mode 100644 index 000000000..1ab7d0db8 --- /dev/null +++ b/WinUIGallery/Tools/Get-LatestAddedSamples.ps1 @@ -0,0 +1,47 @@ +# Define the folder containing the control pages +$currentFolder = "ControlPages" + +# Retrieve the list of files in the folder with their details +$filesWithDetails = git ls-tree -r HEAD --name-only $currentFolder | ForEach-Object { + $file = $_ # Current file path from the git tree + + # Check if the file is directly under the $currentFolder and not in subdirectories + if ($file -match "^$currentFolder/[^/]+$") { + # Get the date of the first commit where the file was added (diff-filter A means "added") + $firstAddCommit = git log --diff-filter=A --reverse --format="%ai" -- $file | Select-Object -First 1 + + # If the file has an add commit (i.e., it's not a new file) + if ($firstAddCommit) { + # Create a custom object with file name and its first added commit date + [PSCustomObject]@{ + File = $file.Substring($currentFolder.Length + 1) # Remove the folder path to get the file name + FirstAddCommitDate = $firstAddCommit # Date of the first commit where the file was added + } + } + } +} + +# Sort the files by their first add commit date in descending order (most recent first) +$sortedFiles = $filesWithDetails | Sort-Object FirstAddCommitDate -Descending + +# Create a hashtable to cache processed file base names to avoid duplicates +$cachedBaseNames = @{} + +# Initialize the output string for the latest added samples +$LatestAddeddSamples = "Latest Added Samples:`n" + +# Process the sorted files +$sortedFiles | ForEach-Object { + # Remove file extensions and standardize the file name + $fileName = $_.File -replace '\.xaml\.cs$', '' -replace '\.xaml$', '' + $fileName = $fileName -replace 'Page$', '' + + # Add the file to the output if it hasn't been cached yet (to avoid duplicates) + if (-not $cachedBaseNames.Contains($fileName)) { + $cachedBaseNames[$fileName] = $true # Mark the file name as cached + $LatestAddeddSamples += $fileName + "`n" # Append the file name to the output list + } +} + +# Output the list of the latest added samples +Write-Output $LatestAddeddSamples diff --git a/WinUIGallery/Tools/Get-LatestUpdatedSamples.ps1 b/WinUIGallery/Tools/Get-LatestUpdatedSamples.ps1 new file mode 100644 index 000000000..03c24e781 --- /dev/null +++ b/WinUIGallery/Tools/Get-LatestUpdatedSamples.ps1 @@ -0,0 +1,49 @@ +# Define the folder containing the control pages +$currentFolder = "ControlPages" + +# Retrieve the list of files in the folder with their details +$filesWithDetails = git ls-tree -r HEAD --name-only $currentFolder | ForEach-Object { + $file = $_ # Current file path from the git tree + + # Check if the file is directly under the $currentFolder and not in subdirectories + if ($file -match "^$currentFolder/[^/]+$") { + # Get the last commit date for the file + $lastCommitDate = git log -1 --format="%ai" -- $file + + # Get the commit status for the file (checks if it was modified in the last commit) + $commitStatus = git log -1 --name-status -- $file | Select-String -Pattern "^M" | ForEach-Object { $_.Line.Split()[0] } + + # If the file was modified ("M"), create a custom object with file details + if ($commitStatus -eq "M") { + [PSCustomObject]@{ + File = $file.Substring($currentFolder.Length + 1) # Trim the folder path to get the file name + LastCommitDate = $lastCommitDate # Last commit date for the file + } + } + } +} + +# Sort the files by the last commit date in descending order +$sortedFiles = $filesWithDetails | Sort-Object LastCommitDate -Descending + +# Create a hashtable to cache processed file base names to avoid duplicates +$cachedBaseNames = @{} + +# Initialize the output string for the latest updated samples +$LatestUpdatedSamples = "Latest Updated Samples:`n" + +# Process the sorted files +$sortedFiles | ForEach-Object { + # Remove file extensions and standardize the file name + $fileName = $_.File -replace '\.xaml\.cs$', '' -replace '\.xaml$', '' + $fileName = $fileName -replace 'Page$', '' + + # Add the file to the output if it hasn't been cached yet + if (-not $cachedBaseNames.Contains($fileName)) { + $cachedBaseNames[$fileName] = $true # Mark the file name as cached + $LatestUpdatedSamples += $fileName + "`n" # Append the file name to the output + } +} + +# Output the list of latest updated samples +Write-Output $LatestUpdatedSamples From 1b96cff1eb74ca7c3611a16afc8554ce68e3d619 Mon Sep 17 00:00:00 2001 From: Zakaria Tahri <101801384+Zakariathr22@users.noreply.github.com> Date: Mon, 27 Jan 2025 19:43:22 +0100 Subject: [PATCH 4/8] Relocate the tools folder to the root of the repository --- {WinUIGallery/Tools => Tools}/Get-LatestAddedSamples.ps1 | 0 {WinUIGallery/Tools => Tools}/Get-LatestUpdatedSamples.ps1 | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {WinUIGallery/Tools => Tools}/Get-LatestAddedSamples.ps1 (100%) rename {WinUIGallery/Tools => Tools}/Get-LatestUpdatedSamples.ps1 (100%) diff --git a/WinUIGallery/Tools/Get-LatestAddedSamples.ps1 b/Tools/Get-LatestAddedSamples.ps1 similarity index 100% rename from WinUIGallery/Tools/Get-LatestAddedSamples.ps1 rename to Tools/Get-LatestAddedSamples.ps1 diff --git a/WinUIGallery/Tools/Get-LatestUpdatedSamples.ps1 b/Tools/Get-LatestUpdatedSamples.ps1 similarity index 100% rename from WinUIGallery/Tools/Get-LatestUpdatedSamples.ps1 rename to Tools/Get-LatestUpdatedSamples.ps1 From 7b59a3dd8d0483a0db7e2cd92b240dfce1f6eb2a Mon Sep 17 00:00:00 2001 From: Zakaria Tahri <101801384+Zakariathr22@users.noreply.github.com> Date: Mon, 27 Jan 2025 21:40:05 +0100 Subject: [PATCH 5/8] Refactor script to manually change directory to WinUIGallery before accessing ControlPages --- Tools/Get-LatestAddedSamples.ps1 | 11 ++++++++++- Tools/Get-LatestUpdatedSamples.ps1 | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Tools/Get-LatestAddedSamples.ps1 b/Tools/Get-LatestAddedSamples.ps1 index 1ab7d0db8..f98bd9f3a 100644 --- a/Tools/Get-LatestAddedSamples.ps1 +++ b/Tools/Get-LatestAddedSamples.ps1 @@ -1,3 +1,9 @@ +# Define the folder containing the WinUIGallery relative to the script location +$WinUIGalleryFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\WinUIGallery" + +# Change directory to the WinUIGallery folder +Set-Location -Path $WinUIGalleryFolder + # Define the folder containing the control pages $currentFolder = "ControlPages" @@ -25,7 +31,7 @@ $filesWithDetails = git ls-tree -r HEAD --name-only $currentFolder | ForEach-Obj $sortedFiles = $filesWithDetails | Sort-Object FirstAddCommitDate -Descending # Create a hashtable to cache processed file base names to avoid duplicates -$cachedBaseNames = @{} +$cachedBaseNames = @{ } # Initialize the output string for the latest added samples $LatestAddeddSamples = "Latest Added Samples:`n" @@ -45,3 +51,6 @@ $sortedFiles | ForEach-Object { # Output the list of the latest added samples Write-Output $LatestAddeddSamples + +# Wait for the user to press Enter before closing the PowerShell window +Read-Host -Prompt "Press Enter to exit" diff --git a/Tools/Get-LatestUpdatedSamples.ps1 b/Tools/Get-LatestUpdatedSamples.ps1 index 03c24e781..8b8e1851f 100644 --- a/Tools/Get-LatestUpdatedSamples.ps1 +++ b/Tools/Get-LatestUpdatedSamples.ps1 @@ -1,3 +1,9 @@ +# Define the folder containing the WinUIGallery relative to the script location +$WinUIGalleryFolder = Join-Path -Path $PSScriptRoot -ChildPath "..\WinUIGallery" + +# Change directory to the WinUIGallery folder +Set-Location -Path $WinUIGalleryFolder + # Define the folder containing the control pages $currentFolder = "ControlPages" @@ -27,7 +33,7 @@ $filesWithDetails = git ls-tree -r HEAD --name-only $currentFolder | ForEach-Obj $sortedFiles = $filesWithDetails | Sort-Object LastCommitDate -Descending # Create a hashtable to cache processed file base names to avoid duplicates -$cachedBaseNames = @{} +$cachedBaseNames = @{ } # Initialize the output string for the latest updated samples $LatestUpdatedSamples = "Latest Updated Samples:`n" @@ -47,3 +53,6 @@ $sortedFiles | ForEach-Object { # Output the list of latest updated samples Write-Output $LatestUpdatedSamples + +# Wait for the user to press Enter before closing the PowerShell window +Read-Host -Prompt "Press Enter to exit" From 1efb17b433746b11ff2e922a90dab0f83007c487 Mon Sep 17 00:00:00 2001 From: Zakaria Tahri <101801384+Zakariathr22@users.noreply.github.com> Date: Mon, 27 Jan 2025 23:02:17 +0100 Subject: [PATCH 6/8] Add usage instructions and note on PowerShell script execution policy to Tools folder documentation --- Tools/readme.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Tools/readme.md diff --git a/Tools/readme.md b/Tools/readme.md new file mode 100644 index 000000000..72bc63d79 --- /dev/null +++ b/Tools/readme.md @@ -0,0 +1,60 @@ +# Tools Folder + +The Tools folder contains a set of tools and utilities that are repeatedly used by developers to assist in managing and developing the WinUI Gallery. These tools streamline various development tasks, providing functionality to track, manage, and organize files within the repository. + +> **Note**: Before running any PowerShell script, you must set the execution policy to allow locally created scripts to run. Use the following command to set the policy: +> +> ```powershell +> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser +> ``` +> This ensures that PowerShell scripts downloaded from the internet are not run unless they are signed by a trusted publisher, while locally created scripts are allowed to run. + +## 1. Get-LatestAddedSamples tool + +The goal of the `Get-LatestAddedSamples.ps1` script is to assist developers in identifying newly added files in the `ControlPages` directory, along with the date of their first commit. This helps in tracking the progress of new additions to the project and identifying which samples should be included on the home page, ensuring that the most recent content is always showcased. + +### How to Use the Script + +#### 1st Way: From File Explorer +- Step 1: Navigate to the `Tools` folder. +- Step 2: Right-click the `Get-LatestAddedSamples.ps1` script and select **Run with PowerShell**. +  +- Step 3: The script will output a list of newly added files along with their first commit dates. +  + +#### 2nd Way: From Visual Studio +- Step 1: Open `WinUIGallery` project in Visual Studio. +- Step 2: Navigate to the **Tools** menu and select **Open PowerShell Window**. +- Step 3: In the PowerShell window, type the following command: + ```powershell + ..\Tools\Get-LatestAddedSamples.ps1 + ``` +- Step 4: The script will output the list of added files. +  + +## 2. Get-LatestUpdatedSamples tool + +### How to Use the Script + +The goal of the `Get-LatestUpdatedSamples.ps1` script is to help developers quickly identify files in the `ControlPages` directory that have been updated, along with their last commit dates. This information is useful for tracking changes made to the project, ensuring that developers can monitor updates to existing samples, and identifying which updated samples might need to be showcased on the home page. + +#### 1st Way: From File Explorer +- Step 1: Navigate to the `Tools` folder. +- Step 2: Right-click the `Get-LatestUpdatedSamples.ps1` script and select **Run with PowerShell**. +  +- Step 3: The script will output a list of modified files along with their last commit dates. +  + +#### 2nd Way: From Visual Studio +- Step 1: Open `WinUIGallery` project in Visual Studio. +- Step 2: Navigate to the **Tools** menu and select **Open PowerShell Window**. +- Step 3: In the PowerShell window, type the following command: + ```powershell + ..\Tools\Get-LatestUpdatedSamples.ps1 + ``` +- Step 4: The script will output the list of modified files. +  + +# Summary + +The Tools folder provides a collection of tools and utilities to assist developers in managing and developing the WinUI Gallery. These tools help streamline various development tasks, such as tracking file changes, managing updates, and organizing content within the repository. The tools ensure efficient workflows and contribute to the smooth development of the WinUI Gallery project. From f6b979888cdc289dd593bb1ca0876946ae638317 Mon Sep 17 00:00:00 2001 From: Zakaria Tahri <101801384+Zakariathr22@users.noreply.github.com> Date: Tue, 28 Jan 2025 02:26:55 +0100 Subject: [PATCH 7/8] Update readme.md --- Tools/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/readme.md b/Tools/readme.md index 72bc63d79..0843fbd3a 100644 --- a/Tools/readme.md +++ b/Tools/readme.md @@ -34,10 +34,10 @@ The goal of the `Get-LatestAddedSamples.ps1` script is to assist developers in i ## 2. Get-LatestUpdatedSamples tool -### How to Use the Script - The goal of the `Get-LatestUpdatedSamples.ps1` script is to help developers quickly identify files in the `ControlPages` directory that have been updated, along with their last commit dates. This information is useful for tracking changes made to the project, ensuring that developers can monitor updates to existing samples, and identifying which updated samples might need to be showcased on the home page. +### How to Use the Script + #### 1st Way: From File Explorer - Step 1: Navigate to the `Tools` folder. - Step 2: Right-click the `Get-LatestUpdatedSamples.ps1` script and select **Run with PowerShell**. From 43de2640cb1f8ea5e26bb815d5afab9c38a96ffb Mon Sep 17 00:00:00 2001 From: Marcel Wagner