Skip to content

Commit 962c978

Browse files
authored
Merge pull request #4 from deadlydog/ImproveSpellCheckingOnLocalDevelopment
Improve spell checking on local development
2 parents 34c8942 + 7f6fb96 commit 962c978

File tree

7 files changed

+67
-6
lines changed

7 files changed

+67
-6
lines changed

.cspell.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"**/_.gitignore",
1111
"**/devcontainer.json",
1212
"**/build-and-test-powershell-module.yml",
13-
"**/build-test-and-deploy-powershell-module.yml"
13+
"**/build-test-and-deploy-powershell-module.yml",
14+
"**/bin/**", // Ignore C# build output files.
15+
"**/obj/**", // Ignore C# build output files.
16+
".gitignore"
1417
],
1518
"words": [
1619
"behaviour",

.devcontainer/devcontainer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "PowerShell",
55
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
"image": "mcr.microsoft.com/powershell:lts-debian-11",
6+
"image": "mcr.microsoft.com/dotnet/sdk:9.0",
77
"features": {
88
"ghcr.io/devcontainers/features/common-utils:2": {
99
"installZsh": "true",
@@ -13,8 +13,9 @@
1313
}
1414
},
1515

16-
// Set VS Code's default shell to PowerShell.
17-
"postCreateCommand": "sudo chsh vscode -s \"$(which pwsh)\"",
16+
// Set pwsh as the default shell for the devcontainer, install required PowerShell modules, and install NPM and CSpell.
17+
// If you do not plan to use CSpell, you can remove everything after and including 'sudo apt update'.
18+
"postCreateCommand": "sudo chsh vscode -s \"$(which pwsh)\"; pwsh -c \"Install-Module Pester -Force\"; pwsh -c \"Install-Module PSScriptAnalyzer -Force\"; sudo apt update; sudo DEBIAN_FRONTEND=noninteractive apt install -y npm; npm install cspell",
1819

1920
// Configure tool-specific properties.
2021
"customizations": {

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Custom additions:
2+
3+
# Ignore NPM files.
4+
package-lock.json
5+
package.json
6+
17
# Created by https://www.toptal.com/developers/gitignore/api/powershell,visualstudiocode,visualstudio
28
# Edit at https://www.toptal.com/developers/gitignore?templates=powershell,visualstudiocode,visualstudio
39

.vscode/tasks.json

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"isDefault": true
1010
},
1111
"dependsOn": [
12-
"Run PSScriptAnalyzer linter"
12+
"Run PSScriptAnalyzer linter",
13+
"Run CSpell spell checker"
1314
]
1415
},
1516
{
@@ -46,6 +47,31 @@
4647
"$func-powershell-watch"
4748
]
4849
},
50+
{
51+
"label": "Run CSpell spell checker",
52+
"type": "shell",
53+
"options": {
54+
"shell": {
55+
"executable": "pwsh",
56+
"args": [
57+
"-NoProfile",
58+
"-Command"
59+
]
60+
}
61+
},
62+
// If npx is not available, warn that Node.js is not installed. If we cannot run cspell, try to install and run it, and warn if we still cannot run it.
63+
"command": "try { & npx -v > $null } catch {}; if (-not $?) { Write-Warning 'Node.js is not installed, so cannot download and run npx cspell.' } else { try { & npx cspell . } catch {}; if (-not $?) { & npm install cspell; & npx cspell . }; if (-not $?) { Write-Warning 'There was a problem installing or running cspell' } }",
64+
"group": "build",
65+
"presentation": {
66+
"reveal": "always",
67+
"panel": "dedicated",
68+
"clear": true,
69+
"group": "build"
70+
},
71+
"problemMatcher": [
72+
"$func-powershell-watch"
73+
]
74+
},
4975
{
5076
"label": "Run all Pester tests",
5177
"type": "shell",

Changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
This page is a list of _notable_ changes made in each version.
44

5+
## v1.2.0 - March 27, 2025
6+
7+
Features:
8+
9+
- Add VS Code task to run CSpell spellcheck when building, as well as a stand-alone VS Code task.
10+
- Update dev container to the latest PowerShell image and have it install PSScriptAnalyzer, Pester, and CSpell.
11+
- Update default Contributing.md to include information around local development and building.
12+
513
## v1.1.0 - April 20, 2024
614

715
Features:

src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/_.cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"language": "en",
88
"ignorePaths": [
99
".devcontainer/devcontainer.json",
10-
".github/workflows/*.yml"
10+
".github/workflows/*.yml",
11+
".gitignore"
1112
],
1213
"words": [
1314
"behaviour",

src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
Feel free to open an issue or pull request.
44

5+
## 💻 Local development
6+
7+
This PowerShell module is developed using Visual Studio Code.
8+
If you encounter any issues developing on your local machine, you can use [Docker Desktop](https://www.docker.com/products/docker-desktop/) and the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) VS Code extension to develop in a Docker container with all of the required dependencies, so that you do not have to install them locally.
9+
You may also develop in your web browser with GitHub Codespaces to avoid needing to put any code or dependencies on your local machine.
10+
11+
### 🛠️ Building and testing
12+
13+
The code is built and tested by CI/CD pipelines on every commit to the `main` branch and every PR opened against the `main` branch.
14+
15+
When developing locally, you can use [the VS Code tasks](/.vscode/tasks.json) to simulate the build and test process and be notified of any problems before pushing your code up to the remote repository.
16+
In VS Code, open the command palette (Ctrl+Shift+P) and select `Tasks: Run Build Task` or `Tasks: Run Test Task`.
17+
18+
When you run the build task, it will run PSScriptAnalyzer and CSpell spellcheck.
19+
If CSpell flags a word as `unknown` that is not misspelled, you can add it to the `.cspell.json` file in the root of the repository to have it ignore the word.
20+
521
## 🚀 Publishing new versions
622

723
A prerelease version of the module is published automatically on every commit to the `main` branch.

0 commit comments

Comments
 (0)