Skip to content

Commit

Permalink
Merge branch 'main' into generate-resource-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gijsreyn authored Nov 12, 2024
2 parents f271a97 + d44307c commit 7b7f855
Show file tree
Hide file tree
Showing 11 changed files with 299 additions and 21 deletions.
102 changes: 102 additions & 0 deletions .configurations/configuration.dsc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2

properties:
resources:
########################################################################
# Section: Install Git
########################################################################
- resource: Microsoft.WinGet.DSC/WinGetPackage
id: install-git
directives:
description: Install Git # Although the user probably already has git installed, it's possible that they don't
allowPrerelease: true
settings:
id: Git.Git
source: winget
Ensure: Present
- resource: Microsoft.WinGet.DSC/WinGetPackage
dependsOn:
- install-git
id: install-github-cli
directives:
description: Install GitHub CLI
allowPrerelease: true
securityContext: elevated
settings:
id: GitHub.cli
source: winget
Ensure: Present
########################################################################
# Section: Configure Git Remotes
########################################################################
- resource: GitDSC/GitRemote
id: add-microsoft-upstream
directives:
description: Add microsoft/winget-dsc as the upstream remote
allowPrerelease: true
settings:
ProjectDirectory: '${WinGetConfigRoot}\..'
RemoteName: upstream
RemoteUrl: https://github.com/microsoft/winget-pkgs.git
########################################################################
# Section: Install VS-Code
########################################################################
- resource: Microsoft.WinGet.DSC/WinGetPackage
id: install-vs-code
directives:
description: Install Microsoft Visual Studio Code
allowPrerelease: true
settings:
id: Microsoft.VisualStudioCode
source: winget
Ensure: Present
- resource: Microsoft.VSCode.Dsc/VSCodeExtension
id: install_vscode-yaml
dependsOn:
- install-vs-code
directives:
description: Install YAML extension for VSCode
allowPrerelease: true
settings:
Name: redhat.vscode-yaml
Exist: true
- resource: Microsoft.VSCode.Dsc/VSCodeExtension
id: install_editorconfig.editorconfig
dependsOn:
- install-vs-code
directives:
description: Install EditorConfig extension for VSCode
allowPrerelease: true
settings:
Name: EditorConfig.EditorConfig
Exist: true
- resource: Microsoft.VSCode.Dsc/VSCodeExtension
id: install_ms-vscode.powershell
dependsOn:
- install-vs-code
directives:
description: Install PowerShell extension for VSCode
allowPrerelease: true
settings:
Name: ms-vscode.powershell
Exist: true
########################################################################
# Section: Install PowerShell Modules
########################################################################
- resource: PowerShellModule/PSModuleResource
id: install-pester
directives:
description: Install Pester module
allowPrerelease: true
settings:
Module_Name: Pester
Ensure: Present
- resource: PowerShellModule/PSModuleResource
id: install-psscriptanalyzer
directives:
description: Install PSScriptAnalyzer module
allowPrerelease: true
settings:
Module_Name: PSScriptAnalyzer
Ensure: Present
configurationVersion: 0.2.0
7 changes: 1 addition & 6 deletions .github/actions/spelling/candidate.patterns
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,7 @@ customObjectInstantitationMethod

# version suffix <word>v#
(?:(?<=[A-Z]{2})V|(?<=[a-z]{2}|[A-Z]{2})v)\d+(?:\b|(?=[a-zA-Z_]))
# Compiler flags (Scala)
(?:^|[\t ,>"'`=(])-J-[DPWXY](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,})
# Compiler flags
(?:^|[\t ,"'`=(])-[DPWXYLlf](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,})
# Compiler flags (linker)
,-B

# curl arguments
\b(?:\\n|)curl(?:\s+-[a-zA-Z]{1,2}\b)*(?:\s+-[a-zA-Z]{3,})(?:\s+-[a-zA-Z]+)*
# set arguments
Expand Down
1 change: 1 addition & 0 deletions .github/actions/spelling/expect/generic_terms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ worktree
sortby
msft
automerge
Workaround
3 changes: 3 additions & 0 deletions .github/actions/spelling/patterns.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ name\:\s+.+$

# Commit Hashes
[0-9a-f]{40}

# Github User Content
/[-a-z0-9]+\.githubusercontent\.com/[-a-zA-Z0-9?&=_\/.]*
4 changes: 2 additions & 2 deletions .github/workflows/spellCheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ jobs:
use_magic_file: 1
extra_dictionary_limit: 10
extra_dictionaries:
https://github.com/streetsidesoftware/cspell-dicts/raw/098e323325a389a5d1cebcd7770807b9d11d0a17/dictionaries/software-terms/src/software-terms.txt
https://raw.githubusercontent.com/streetsidesoftware/cspell-dicts/098e323325a389a5d1cebcd7770807b9d11d0a17/dictionaries/software-terms/src/software-terms.txt
https://raw.githubusercontent.com/streetsidesoftware/cspell-dicts/098e323325a389a5d1cebcd7770807b9d11d0a17/dictionaries/filetypes/src/filetypes.txt
https://raw.githubusercontent.com/streetsidesoftware/cspell-dicts/098e323325a389a5d1cebcd7770807b9d11d0a17/dictionaries/powershell/src/powershell.txt
https://raw.githubusercontent.com/streetsidesoftware/cspell-dicts/098e323325a389a5d1cebcd7770807b9d11d0a17/dictionaries/win32/src/generator/win32.txt
https://github.com/streetsidesoftware/cspell-dicts/raw/098e323325a389a5d1cebcd7770807b9d11d0a17/dictionaries/python/src/common_packages.txt
https://raw.githubusercontent.com/streetsidesoftware/cspell-dicts/098e323325a389a5d1cebcd7770807b9d11d0a17/dictionaries/python/src/common_packages.txt
check_extra_dictionaries: ''

comment-push:
Expand Down
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"recommendations": [
"redhat.vscode-yaml",
"EditorConfig.EditorConfig"
"EditorConfig.EditorConfig",
"ms-vscode.powershell"
]
}
31 changes: 24 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,30 @@ Once the team have approved an issue/spec, development can proceed. If no develo

### Fork, Clone, Branch and Create your PR

Once you've discussed your proposed feature/fix/etc. with a team member, and you've agreed an approach or a spec has been written and approved, it's time to start development:
Once you've discussed your proposed feature/fix/etc. with a team member, and you've agreed an approach or a spec has been written and approved, it's time to start development. There are two flows you can follow depending on the proposed feature or fix.

If you're feature (or module) has not yet been created, follow these steps:

1. Fork the repository if you haven't already.
2. Clone your fork locally.
3. Open a PowerShell terminal session and execute: `.\utilities\tools\New-DscResourceModule.ps1 -DscResourceModule '<moduleName>' -Description 'DSC Resource for <description>'`
4. Work on your changes and write tests.
5. Build and test to see if it works.
6. Create & push a feature branch.
7. Create a [Draft Pull Request (PR)](https://github.blog/2019-02-14-introducing-draft-pull-requests/).
8. If you are finished with your changes and you want a review, change the state.

> [!TIP]
> Don't forget to add the `DscResourcesToExport` and `Tags`.
When you are working on a fix or you want to add additional features to an existing module, you can follow the below steps:

1. Fork the repository if you haven't already.
1. Clone your fork locally.
1. Create & push a feature branch.
1. Create a [Draft Pull Request (PR)](https://github.blog/2019-02-14-introducing-draft-pull-requests/).
1. Work on your changes.
1. Build and see if it works.
2. Clone your fork locally.
3. Work on your fix or feature, and _optionally_ write tests
4. Build and test to see if it works.
5. Create & push a feature branch.
6. Create a [Pull Request (PR)](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) when you are finished with your changes

### Testing

Expand All @@ -126,7 +142,8 @@ Testing is a key component in the development workflow.

When you'd like the team to take a look, (even if the work is not yet fully-complete), mark the Draft PR as 'Ready For Review' so that the team can review your work and provide comments, suggestions, and request changes. It may take several cycles, but the end result will be solid, testable, conformant code that is safe for us to merge.

> ⚠ Remember: **changes you make may affect both the Windows Package Manager and the schema support implemented in our validation pipelines!** Because of this, we will treat community PR's with the same level of scrutiny and rigor as commits submitted to the official Windows source by team members and partners.
> [!CAUTION]
> Remember: **changes you make may affect both the Windows Package Manager and the schema support implemented in our validation pipelines!** Because of this, we will treat community PR's with the same level of scrutiny and rigor as commits submitted to the official Windows source by team members and partners.
### Merge

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
'TextCursor',
'StickyKeys',
'ToggleKeys',
'FilterKeys'
'FilterKeys',
'EyeControl'
)
PrivateData = @{
PSData = @{
Expand All @@ -32,7 +33,8 @@
'PSDscResource_TextCursor',
'PSDscResource_StickyKeys',
'PSDscResource_ToggleKeys',
'PSDscResource_FilterKeys'
'PSDscResource_FilterKeys',
'PSDscResource_EyeControl'
)

# Prerelease string of this module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest

enum Ensure {
Absent
Present
}

enum TextSize {
KeepCurrentValue
Small
Expand Down Expand Up @@ -78,8 +83,9 @@ if ([string]::IsNullOrEmpty($env:TestRegistryPath)) {
$global:StickyKeysRegistryPath = 'HKCU:\Control Panel\Accessibility\StickyKeys'
$global:ToggleKeysRegistryPath = 'HKCU:\Control Panel\Accessibility\ToggleKeys'
$global:FilterKeysRegistryPath = 'HKCU:\Control Panel\Accessibility\Keyboard Response'
$global:EyeControlRegistryPath = 'HKCU:\Software\Microsoft\input\EC\'
} else {
$global:AccessibilityRegistryPath = $global:MagnifierRegistryPath = $global:PointerRegistryPath = $global:ControlPanelAccessibilityRegistryPath = $global:AudioRegistryPath = $global:PersonalizationRegistryPath = $global:NTAccessibilityRegistryPath = $global:CursorIndicatorAccessibilityRegistryPath = $global:ControlPanelDesktopRegistryPath = $global:StickyKeysRegistryPath = $global:ToggleKeysRegistryPath = $global:FilterKeysRegistryPath = $env:TestRegistryPath
$global:AccessibilityRegistryPath = $global:MagnifierRegistryPath = $global:PointerRegistryPath = $global:ControlPanelAccessibilityRegistryPath = $global:AudioRegistryPath = $global:PersonalizationRegistryPath = $global:NTAccessibilityRegistryPath = $global:CursorIndicatorAccessibilityRegistryPath = $global:ControlPanelDesktopRegistryPath = $global:StickyKeysRegistryPath = $global:ToggleKeysRegistryPath = $global:FilterKeysRegistryPath = $global:EyeControlRegistryPath = $env:TestRegistryPath
}

[DSCResource()]
Expand Down Expand Up @@ -891,6 +897,37 @@ class FilterKeys {
}
}

[DscResource()]
class EyeControl {
[DscProperty(Key)] [Ensure] $Ensure
hidden [string] $SettingsProperty = 'Enabled'

[EyeControl] Get() {
$currentState = [EyeControl]::new()

if (-not(DoesRegistryKeyPropertyExist -Path $global:EyeControlRegistryPath -Name $this.SettingsProperty)) {
$currentState.Ensure = [Ensure]::Absent
} else {
$currentState.Ensure = [int]((Get-ItemPropertyValue -Path $global:EyeControlRegistryPath -Name $this.SettingsProperty) -eq 1)
}

return $currentState
}

[bool] Test() {
return $this.Get().Ensure -eq $this.Ensure
}

[void] Set() {
# Only make changes if changes are needed
if ($this.Test()) { return }
if (-not (DoesRegistryKeyPropertyExist -Path $global:EyeControlRegistryPath -Name $this.SettingsProperty)) {
New-ItemProperty -Path $global:EyeControlRegistryPath -Name $this.SettingsProperty -PropertyType DWord
}
Set-ItemProperty -Path $global:EyeControlRegistryPath -Name $this.SettingsProperty -Value $([int]$this.Ensure)
}
}

#region Functions
function DoesRegistryKeyPropertyExist {
param (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ BeforeAll {

Describe 'List available DSC resources' {
It 'Shows DSC Resources' {
$expectedDSCResources = 'Text', 'Magnifier', 'MousePointer', 'VisualEffect', 'Audio', 'TextCursor', 'StickyKeys', 'ToggleKeys', 'FilterKeys'
$expectedDSCResources = 'Text', 'Magnifier', 'MousePointer', 'VisualEffect', 'Audio', 'TextCursor', 'StickyKeys', 'ToggleKeys', 'FilterKeys', 'EyeControl'
$availableDSCResources = (Get-DscResource -Module Microsoft.Windows.Setting.Accessibility).Name
$availableDSCResources.length | Should -Be 9
$availableDSCResources.length | Should -Be 10
$availableDSCResources | Where-Object { $expectedDSCResources -notcontains $_ } | Should -BeNullOrEmpty -ErrorAction Stop
}
}
Expand Down Expand Up @@ -401,6 +401,28 @@ Describe 'FilterKeys' {
}
}

Describe 'EyeControl' {
It 'Enable EyeControl.' {
Invoke-DscResource -Name EyeControl -ModuleName Microsoft.Windows.Setting.Accessibility -Method Set -Property @{ Ensure = 'Absent' }

$initialState = Invoke-DscResource -Name EyeControl -ModuleName Microsoft.Windows.Setting.Accessibility -Method Get -Property @{}
$initialState.Ensure | Should -Be 'Absent'

# Test enabled
$parameters = @{ Ensure = 'Present' }
$testResult = Invoke-DscResource -Name EyeControl -ModuleName Microsoft.Windows.Setting.Accessibility -Method Test -Property $parameters
$testResult.InDesiredState | Should -Be $false

# Set enabled
Invoke-DscResource -Name EyeControl -ModuleName Microsoft.Windows.Setting.Accessibility -Method Set -Property $parameters
$finalState = Invoke-DscResource -Name EyeControl -ModuleName Microsoft.Windows.Setting.Accessibility -Method Get -Property @{}
$finalState.Ensure | Should -Be 'Present'

$testResult2 = Invoke-DscResource -Name EyeControl -ModuleName Microsoft.Windows.Setting.Accessibility -Method Test -Property $parameters
$testResult2.InDesiredState | Should -Be $true
}
}

AfterAll {
$env:TestRegistryPath = ''
}
Loading

0 comments on commit 7b7f855

Please sign in to comment.