Compare commits

..
3 Commits
Author SHA1 Message Date
Raphire 6012b02ea2 Update CONTRIBUTING.md 2026-08-30 12:24:51 +02:00
Raphire 687ddea148 Update CONTRIBUTING.md 2026-08-30 12:16:28 +02:00
Jeffrey 9b75b1a4e6 Update CONTRIBUTING.md 2026-08-30 02:04:45 +02:00
+74 -22
View File
@@ -48,7 +48,7 @@ You can launch the prerelease version of Win11Debloat by running this command:
2. Enable script execution if necessary:
```powershell
Set-ExecutionPolicy Unrestricted -Scope Process -Force
Set-ExecutionPolicy Bypass -Scope Process -Force
```
3. Navigate to your Win11Debloat directory
@@ -60,38 +60,74 @@ You can launch the prerelease version of Win11Debloat by running this command:
### Running Automated Tests
The automated test cases use Pester 5 and do not modify the registry or other
system state. The optional bootstrap step installs Pester for your user account
when needed. To run the complete suite:
The automated tests use Pester 5 and are found in the `Tests` directory. They cover registry operations, app removal, CLI/GUI logic, and config handling. Some Windows behavior is mocked so the tests can run safely, but they do not replace manual testing on a Windows test environment.
The bootstrap option can be used to automatically install Pester on your machine and run the full suite of tests:
```powershell
.\Scripts\Run-Tests.ps1 -Bootstrap
```
After the initial setup, run the suite with:
After the initial setup, you can simply run the full suite with:
```powershell
.\Scripts\Run-Tests.ps1
```
GitHub Actions runs the same test command with Windows PowerShell 5.1 for pull
requests and pushes to `master`.
For a focused test run during development, you can also call Pester directly:
## Implementation Guidelines
```powershell
Invoke-Pester -Path .\Tests\Invoke-Changes.Tests.ps1 -Output Detailed
```
GitHub Actions runs the same suite with Windows
PowerShell 5.1 for pull requests and pushes to `master`.
## Architecture & Design
Win11Debloat is a PowerShell script with a WPF (Windows Presentation Foundation) based GUI and command-line interface. The CLI provides an alternative to the GUI, allowing most features to be invoked directly through command-line parameters. The project uses a data-driven architecture, separating feature and application definitions from the logic that applies them.
### Entry Points
`Win11Debloat.ps1` is the main entry point and can be launched directly or through one of the provided launchers:
* `Run.bat` launches a locally downloaded copy of `Win11Debloat.ps1`.
* `Get.ps1` downloads Win11Debloat and launches `Win11Debloat.ps1`.
Both `Get.ps1` and `Win11Debloat.ps1` support [command-line parameters](https://github.com/Raphire/Win11Debloat/wiki/Command-Line-Interface), allowing Win11Debloat to be configured and run without using the GUI.
### High-Level Architecture
`Win11Debloat.ps1` loads the configuration and shared functions, then routes execution through either the WPF GUI or CLI. Both interfaces use the same underlying feature and app-removal engine.
```mermaid
flowchart TB
Main[Win11Debloat.ps1] --> GUI[WPF GUI]
Main --> CLI[CLI]
Config["Config Files (JSON)"] --> GUI
Config --> CLI
GUI --> Changes[Apply Selected Changes]
CLI --> Changes
Config --> Changes
Changes --> Regfiles[Regfiles]
Changes --> Tools[Appx / WinGet]
```
### Project Structure
Understanding the project structure is essential for contributing effectively:
```text
Win11Debloat/
├── Win11Debloat.ps1 # Main PowerShell script
├── Run.bat # Batch launcher for the quick launch method
├── Run.bat # Local launcher
├── Scripts/ # Additional PowerShell scripts and functions
│ ├── Get.ps1 # Script used for the quick launch method to automatically download and run Win11debloat
│ ├── Get.ps1 # Download-and-launch script
│ ├── Run-Tests.ps1 # Pester test runner (optionally bootstraps Pester)
│ ├── AppRemoval/ # App package removal logic
│ ├── CLI/ # Command-line interface helpers
│ ├── Features/ # Feature apply/undo logic (e.g. Invoke-Changes.ps1, Replace-StartMenu.ps1)
│ ├── Features/ # Feature apply, undo, backup, and restore logic
│ ├── FileIO/ # File input/output helpers
│ ├── GUI/ # GUI window definitions and logic
│ ├── Helpers/ # Shared helper functions
@@ -104,16 +140,19 @@ Win11Debloat/
├── Regfiles/ # Registry files for all features
│ ├── Undo/ # Registry files for reverting features
│ └── Sysprep/ # Registry files for Sysprep mode
├── Schemas/ # XAML Schemas for GUI elements
├── Schemas/ # XAML views and shared GUI resources
├── Assets/ # Static assets (icons, start menu templates)
├── Tests/ # Pester tests for script and XAML contracts
├── Backups/ # Registry backups (generated during use)
└── Logs/ # Script logs (generated during use)
```
## Implementation Guidelines
### Best Practices
1. **Test Thoroughly**: Always test your changes on a Windows test environment before submitting. This includes undoing tweaks and running script as another user and in Sysprep mode.
2. **Document Changes**: Update the `README.md` and other relevant documentation. Wiki documentation will be generated/updated based on the `Features.json` and `Apps.json` files.
2. **Document Changes**: Update the `README.md`, wiki, and other relevant documentation.
3. **Follow Existing Patterns**: Look at existing implementations for guidance.
4. **Use Clear Naming**: Choose descriptive names for features, IDs, and registry files.
5. **Minimal Changes**: Registry files should only modify what's necessary. Avoid using policies where possible.
@@ -137,7 +176,7 @@ Avoid these common mistakes when contributing:
1. **Forgetting Get.ps1**: When adding a new command-line parameter, contributors often remember to add it to `Win11Debloat.ps1` but forget to add the same parameter to `Scripts/Get.ps1`. Both files **must** have matching parameters.
2. **Missing Registry Files**: Always create an `Undo` registry file for reversibility, aswell as a `Sysprep` registry file for applying changes to other users and Sysprep mode.
2. **Missing Registry Files**: For registry-backed features, create an `Undo` registry file for reversibility and a `Sysprep` registry file for applying changes to other users and Sysprep mode.
3. **Incorrect Registry Hives for Sysprep**: Sysprep registry files are meant to apply changes to a different user. Registry keys in the `HKEY_CURRENT_USER` hive must use `hkey_users\default` instead. Ensure you update **all** registry keys in the file.
@@ -165,12 +204,14 @@ Avoid these common mistakes when contributing:
To add a new app that can be removed via Win11Debloat:
1. **Find the AppId**: To find the correct AppId for an app:
1. **Find the AppId**: For an Appx app, find the package name with:
```powershell
Get-AppxPackage | Select-Object Name, PackageFullName
```
For a WinGet app, use `winget list` and use its `Id` value.
2. **Edit `Config/Apps.json`**: Add a new entry to the `"Apps"` array:
```json
@@ -187,7 +228,9 @@ To add a new app that can be removed via Win11Debloat:
**Field Descriptions**:
- `FriendlyName`: Display name shown in the GUI.
- `AppId`: The `AppPackageIdentifier` from `Get-AppxPackage` or the `Id` from `winget list`, depending on removal method.
- `AppId`: The package name from `Get-AppxPackage` or the `Id` from
`winget list`, depending on removal method. Use an array when one app
requires multiple identifiers.
- `Description`: Brief description of the app shown in the GUI.
- `SelectedByDefault`: Set to `true` only for apps that are largely considered bloatware, otherwise set to `false`.
- `Recommendation`: Indicates how strongly the app is recommended for removal. One of:
@@ -201,7 +244,6 @@ To add a new app that can be removed via Win11Debloat:
3. **Follow the Guidelines**:
- Use clear, user-friendly names for `FriendlyName`
- Set `SelectedByDefault` to `true` only for apps that are largely considered bloatware, otherwise set to `false`
- Provide a concise description explaining what the app does
### Adding a New Feature
@@ -289,6 +331,10 @@ Add a corresponding parameter to both `Win11Debloat.ps1` AND `Scripts/Get.ps1`,
[switch]$YourFeatureId,
```
#### 4. Add or Update Tests
Add or update Pester coverage for the new behavior, then run the full suite.
### Adding a Feature to the Default Preset
> [!IMPORTANT]
@@ -354,8 +400,9 @@ To add a new category for organizing features:
```json
{
"CategoryId": "YourCategoryId",
"Name": "Your Category Name",
"Icon": "&#xE#### ;"
"Icon": "&#xE####;"
}
```
@@ -364,7 +411,9 @@ To add a new category for organizing features:
### Adding UI Groups
UI Groups allow features to be grouped together in the GUI with a combobox (dropdown) selection:
UI Groups allow features to be grouped together in the GUI with a combobox
(dropdown) selection. Add the group to the top-level `"UiGroups"` array in
`Config/Features.json` and use a unique `GroupId`:
```json
{
@@ -386,6 +435,9 @@ UI Groups allow features to be grouped together in the GUI with a combobox (drop
}
```
>[!IMPORTANT]
> Define the referenced features before adding a group. Each `FeatureId` in a group's `Values` list must already be defined in the `"Features"` array in `Features.json`. Features referenced by a group are shown through that group rather than as standalone controls.
## Submitting a Pull Request
1. **Commit your changes** with clear, descriptive commit messages:
@@ -406,7 +458,7 @@ UI Groups allow features to be grouped together in the GUI with a combobox (drop
- Go to the original Win11Debloat repository
- Click "New Pull Request"
- Select your fork and branch
- Provide a clear description of your changes, include references to the registry keys used
- Provide a clear description of your changes. For registry changes, include the registry keys used
- Reference any related issues
4. **Respond to feedback**: Be prepared to make adjustments based on code review feedback.