Skip to content

Commit 7b7f855

Browse files
authored
Merge branch 'main' into generate-resource-docs
2 parents f271a97 + d44307c commit 7b7f855

File tree

11 files changed

+299
-21
lines changed

11 files changed

+299
-21
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
2+
3+
properties:
4+
resources:
5+
########################################################################
6+
# Section: Install Git
7+
########################################################################
8+
- resource: Microsoft.WinGet.DSC/WinGetPackage
9+
id: install-git
10+
directives:
11+
description: Install Git # Although the user probably already has git installed, it's possible that they don't
12+
allowPrerelease: true
13+
settings:
14+
id: Git.Git
15+
source: winget
16+
Ensure: Present
17+
- resource: Microsoft.WinGet.DSC/WinGetPackage
18+
dependsOn:
19+
- install-git
20+
id: install-github-cli
21+
directives:
22+
description: Install GitHub CLI
23+
allowPrerelease: true
24+
securityContext: elevated
25+
settings:
26+
id: GitHub.cli
27+
source: winget
28+
Ensure: Present
29+
########################################################################
30+
# Section: Configure Git Remotes
31+
########################################################################
32+
- resource: GitDSC/GitRemote
33+
id: add-microsoft-upstream
34+
directives:
35+
description: Add microsoft/winget-dsc as the upstream remote
36+
allowPrerelease: true
37+
settings:
38+
ProjectDirectory: '${WinGetConfigRoot}\..'
39+
RemoteName: upstream
40+
RemoteUrl: https://github.com/microsoft/winget-pkgs.git
41+
########################################################################
42+
# Section: Install VS-Code
43+
########################################################################
44+
- resource: Microsoft.WinGet.DSC/WinGetPackage
45+
id: install-vs-code
46+
directives:
47+
description: Install Microsoft Visual Studio Code
48+
allowPrerelease: true
49+
settings:
50+
id: Microsoft.VisualStudioCode
51+
source: winget
52+
Ensure: Present
53+
- resource: Microsoft.VSCode.Dsc/VSCodeExtension
54+
id: install_vscode-yaml
55+
dependsOn:
56+
- install-vs-code
57+
directives:
58+
description: Install YAML extension for VSCode
59+
allowPrerelease: true
60+
settings:
61+
Name: redhat.vscode-yaml
62+
Exist: true
63+
- resource: Microsoft.VSCode.Dsc/VSCodeExtension
64+
id: install_editorconfig.editorconfig
65+
dependsOn:
66+
- install-vs-code
67+
directives:
68+
description: Install EditorConfig extension for VSCode
69+
allowPrerelease: true
70+
settings:
71+
Name: EditorConfig.EditorConfig
72+
Exist: true
73+
- resource: Microsoft.VSCode.Dsc/VSCodeExtension
74+
id: install_ms-vscode.powershell
75+
dependsOn:
76+
- install-vs-code
77+
directives:
78+
description: Install PowerShell extension for VSCode
79+
allowPrerelease: true
80+
settings:
81+
Name: ms-vscode.powershell
82+
Exist: true
83+
########################################################################
84+
# Section: Install PowerShell Modules
85+
########################################################################
86+
- resource: PowerShellModule/PSModuleResource
87+
id: install-pester
88+
directives:
89+
description: Install Pester module
90+
allowPrerelease: true
91+
settings:
92+
Module_Name: Pester
93+
Ensure: Present
94+
- resource: PowerShellModule/PSModuleResource
95+
id: install-psscriptanalyzer
96+
directives:
97+
description: Install PSScriptAnalyzer module
98+
allowPrerelease: true
99+
settings:
100+
Module_Name: PSScriptAnalyzer
101+
Ensure: Present
102+
configurationVersion: 0.2.0

.github/actions/spelling/candidate.patterns

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -509,12 +509,7 @@ customObjectInstantitationMethod
509509

510510
# version suffix <word>v#
511511
(?:(?<=[A-Z]{2})V|(?<=[a-z]{2}|[A-Z]{2})v)\d+(?:\b|(?=[a-zA-Z_]))
512-
# Compiler flags (Scala)
513-
(?:^|[\t ,>"'`=(])-J-[DPWXY](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,})
514-
# Compiler flags
515-
(?:^|[\t ,"'`=(])-[DPWXYLlf](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,})
516-
# Compiler flags (linker)
517-
,-B
512+
518513
# curl arguments
519514
\b(?:\\n|)curl(?:\s+-[a-zA-Z]{1,2}\b)*(?:\s+-[a-zA-Z]{3,})(?:\s+-[a-zA-Z]+)*
520515
# set arguments

.github/actions/spelling/expect/generic_terms.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ worktree
1212
sortby
1313
msft
1414
automerge
15+
Workaround

.github/actions/spelling/patterns.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,6 @@ name\:\s+.+$
6868

6969
# Commit Hashes
7070
[0-9a-f]{40}
71+
72+
# Github User Content
73+
/[-a-z0-9]+\.githubusercontent\.com/[-a-zA-Z0-9?&=_\/.]*

.github/workflows/spellCheck.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ jobs:
7777
use_magic_file: 1
7878
extra_dictionary_limit: 10
7979
extra_dictionaries:
80-
https://github.com/streetsidesoftware/cspell-dicts/raw/098e323325a389a5d1cebcd7770807b9d11d0a17/dictionaries/software-terms/src/software-terms.txt
80+
https://raw.githubusercontent.com/streetsidesoftware/cspell-dicts/098e323325a389a5d1cebcd7770807b9d11d0a17/dictionaries/software-terms/src/software-terms.txt
8181
https://raw.githubusercontent.com/streetsidesoftware/cspell-dicts/098e323325a389a5d1cebcd7770807b9d11d0a17/dictionaries/filetypes/src/filetypes.txt
8282
https://raw.githubusercontent.com/streetsidesoftware/cspell-dicts/098e323325a389a5d1cebcd7770807b9d11d0a17/dictionaries/powershell/src/powershell.txt
8383
https://raw.githubusercontent.com/streetsidesoftware/cspell-dicts/098e323325a389a5d1cebcd7770807b9d11d0a17/dictionaries/win32/src/generator/win32.txt
84-
https://github.com/streetsidesoftware/cspell-dicts/raw/098e323325a389a5d1cebcd7770807b9d11d0a17/dictionaries/python/src/common_packages.txt
84+
https://raw.githubusercontent.com/streetsidesoftware/cspell-dicts/098e323325a389a5d1cebcd7770807b9d11d0a17/dictionaries/python/src/common_packages.txt
8585
check_extra_dictionaries: ''
8686

8787
comment-push:

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"recommendations": [
33
"redhat.vscode-yaml",
4-
"EditorConfig.EditorConfig"
4+
"EditorConfig.EditorConfig",
5+
"ms-vscode.powershell"
56
]
67
}

CONTRIBUTING.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,30 @@ Once the team have approved an issue/spec, development can proceed. If no develo
109109

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

112-
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:
112+
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.
113+
114+
If you're feature (or module) has not yet been created, follow these steps:
115+
116+
1. Fork the repository if you haven't already.
117+
2. Clone your fork locally.
118+
3. Open a PowerShell terminal session and execute: `.\utilities\tools\New-DscResourceModule.ps1 -DscResourceModule '<moduleName>' -Description 'DSC Resource for <description>'`
119+
4. Work on your changes and write tests.
120+
5. Build and test to see if it works.
121+
6. Create & push a feature branch.
122+
7. Create a [Draft Pull Request (PR)](https://github.blog/2019-02-14-introducing-draft-pull-requests/).
123+
8. If you are finished with your changes and you want a review, change the state.
124+
125+
> [!TIP]
126+
> Don't forget to add the `DscResourcesToExport` and `Tags`.
127+
128+
When you are working on a fix or you want to add additional features to an existing module, you can follow the below steps:
113129

114130
1. Fork the repository if you haven't already.
115-
1. Clone your fork locally.
116-
1. Create & push a feature branch.
117-
1. Create a [Draft Pull Request (PR)](https://github.blog/2019-02-14-introducing-draft-pull-requests/).
118-
1. Work on your changes.
119-
1. Build and see if it works.
131+
2. Clone your fork locally.
132+
3. Work on your fix or feature, and _optionally_ write tests
133+
4. Build and test to see if it works.
134+
5. Create & push a feature branch.
135+
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
120136

121137
### Testing
122138

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

127143
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.
128144

129-
> ⚠ 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.
145+
> [!CAUTION]
146+
> 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.
130147
131148
### Merge
132149

resources/Microsoft.Windows.Setting.Accessibility/Microsoft.Windows.Setting.Accessibility.psd1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
'TextCursor',
1919
'StickyKeys',
2020
'ToggleKeys',
21-
'FilterKeys'
21+
'FilterKeys',
22+
'EyeControl'
2223
)
2324
PrivateData = @{
2425
PSData = @{
@@ -32,7 +33,8 @@
3233
'PSDscResource_TextCursor',
3334
'PSDscResource_StickyKeys',
3435
'PSDscResource_ToggleKeys',
35-
'PSDscResource_FilterKeys'
36+
'PSDscResource_FilterKeys',
37+
'PSDscResource_EyeControl'
3638
)
3739

3840
# Prerelease string of this module

resources/Microsoft.Windows.Setting.Accessibility/Microsoft.Windows.Setting.Accessibility.psm1

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
$ErrorActionPreference = 'Stop'
55
Set-StrictMode -Version Latest
66

7+
enum Ensure {
8+
Absent
9+
Present
10+
}
11+
712
enum TextSize {
813
KeepCurrentValue
914
Small
@@ -78,8 +83,9 @@ if ([string]::IsNullOrEmpty($env:TestRegistryPath)) {
7883
$global:StickyKeysRegistryPath = 'HKCU:\Control Panel\Accessibility\StickyKeys'
7984
$global:ToggleKeysRegistryPath = 'HKCU:\Control Panel\Accessibility\ToggleKeys'
8085
$global:FilterKeysRegistryPath = 'HKCU:\Control Panel\Accessibility\Keyboard Response'
86+
$global:EyeControlRegistryPath = 'HKCU:\Software\Microsoft\input\EC\'
8187
} else {
82-
$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
88+
$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
8389
}
8490

8591
[DSCResource()]
@@ -891,6 +897,37 @@ class FilterKeys {
891897
}
892898
}
893899

900+
[DscResource()]
901+
class EyeControl {
902+
[DscProperty(Key)] [Ensure] $Ensure
903+
hidden [string] $SettingsProperty = 'Enabled'
904+
905+
[EyeControl] Get() {
906+
$currentState = [EyeControl]::new()
907+
908+
if (-not(DoesRegistryKeyPropertyExist -Path $global:EyeControlRegistryPath -Name $this.SettingsProperty)) {
909+
$currentState.Ensure = [Ensure]::Absent
910+
} else {
911+
$currentState.Ensure = [int]((Get-ItemPropertyValue -Path $global:EyeControlRegistryPath -Name $this.SettingsProperty) -eq 1)
912+
}
913+
914+
return $currentState
915+
}
916+
917+
[bool] Test() {
918+
return $this.Get().Ensure -eq $this.Ensure
919+
}
920+
921+
[void] Set() {
922+
# Only make changes if changes are needed
923+
if ($this.Test()) { return }
924+
if (-not (DoesRegistryKeyPropertyExist -Path $global:EyeControlRegistryPath -Name $this.SettingsProperty)) {
925+
New-ItemProperty -Path $global:EyeControlRegistryPath -Name $this.SettingsProperty -PropertyType DWord
926+
}
927+
Set-ItemProperty -Path $global:EyeControlRegistryPath -Name $this.SettingsProperty -Value $([int]$this.Ensure)
928+
}
929+
}
930+
894931
#region Functions
895932
function DoesRegistryKeyPropertyExist {
896933
param (

tests/Microsoft.Windows.Setting.Accessibility/Microsoft.Windows.Setting.Accessibility.Tests.ps1

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ BeforeAll {
2626

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

404+
Describe 'EyeControl' {
405+
It 'Enable EyeControl.' {
406+
Invoke-DscResource -Name EyeControl -ModuleName Microsoft.Windows.Setting.Accessibility -Method Set -Property @{ Ensure = 'Absent' }
407+
408+
$initialState = Invoke-DscResource -Name EyeControl -ModuleName Microsoft.Windows.Setting.Accessibility -Method Get -Property @{}
409+
$initialState.Ensure | Should -Be 'Absent'
410+
411+
# Test enabled
412+
$parameters = @{ Ensure = 'Present' }
413+
$testResult = Invoke-DscResource -Name EyeControl -ModuleName Microsoft.Windows.Setting.Accessibility -Method Test -Property $parameters
414+
$testResult.InDesiredState | Should -Be $false
415+
416+
# Set enabled
417+
Invoke-DscResource -Name EyeControl -ModuleName Microsoft.Windows.Setting.Accessibility -Method Set -Property $parameters
418+
$finalState = Invoke-DscResource -Name EyeControl -ModuleName Microsoft.Windows.Setting.Accessibility -Method Get -Property @{}
419+
$finalState.Ensure | Should -Be 'Present'
420+
421+
$testResult2 = Invoke-DscResource -Name EyeControl -ModuleName Microsoft.Windows.Setting.Accessibility -Method Test -Property $parameters
422+
$testResult2.InDesiredState | Should -Be $true
423+
}
424+
}
425+
404426
AfterAll {
405427
$env:TestRegistryPath = ''
406428
}

0 commit comments

Comments
 (0)