diff --git a/.cspell.json b/.cspell.json index a933584..2895231 100644 --- a/.cspell.json +++ b/.cspell.json @@ -10,7 +10,10 @@ "**/_.gitignore", "**/devcontainer.json", "**/build-and-test-powershell-module.yml", - "**/build-test-and-deploy-powershell-module.yml" + "**/build-test-and-deploy-powershell-module.yml", + "**/bin/**", // Ignore C# build output files. + "**/obj/**", // Ignore C# build output files. + ".gitignore" ], "words": [ "behaviour", diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 65f375d..3fe48dd 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,7 +3,7 @@ { "name": "PowerShell", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/powershell:lts-debian-11", + "image": "mcr.microsoft.com/dotnet/sdk:9.0", "features": { "ghcr.io/devcontainers/features/common-utils:2": { "installZsh": "true", @@ -13,8 +13,9 @@ } }, - // Set VS Code's default shell to PowerShell. - "postCreateCommand": "sudo chsh vscode -s \"$(which pwsh)\"", + // Set pwsh as the default shell for the devcontainer, install required PowerShell modules, and install NPM and CSpell. + // If you do not plan to use CSpell, you can remove everything after and including 'sudo apt update'. + "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", // Configure tool-specific properties. "customizations": { diff --git a/.gitignore b/.gitignore index 0beb3dc..9bba3b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ +# Custom additions: + +# Ignore NPM files. +package-lock.json +package.json + # Created by https://www.toptal.com/developers/gitignore/api/powershell,visualstudiocode,visualstudio # Edit at https://www.toptal.com/developers/gitignore?templates=powershell,visualstudiocode,visualstudio diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 6de0722..feab2e8 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -9,7 +9,8 @@ "isDefault": true }, "dependsOn": [ - "Run PSScriptAnalyzer linter" + "Run PSScriptAnalyzer linter", + "Run CSpell spell checker" ] }, { @@ -46,6 +47,31 @@ "$func-powershell-watch" ] }, + { + "label": "Run CSpell spell checker", + "type": "shell", + "options": { + "shell": { + "executable": "pwsh", + "args": [ + "-NoProfile", + "-Command" + ] + } + }, + // 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. + "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' } }", + "group": "build", + "presentation": { + "reveal": "always", + "panel": "dedicated", + "clear": true, + "group": "build" + }, + "problemMatcher": [ + "$func-powershell-watch" + ] + }, { "label": "Run all Pester tests", "type": "shell", diff --git a/Changelog.md b/Changelog.md index bcab158..3766c41 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,14 @@ This page is a list of _notable_ changes made in each version. +## v1.2.0 - March 27, 2025 + +Features: + +- Add VS Code task to run CSpell spellcheck when building, as well as a stand-alone VS Code task. +- Update dev container to the latest PowerShell image and have it install PSScriptAnalyzer, Pester, and CSpell. +- Update default Contributing.md to include information around local development and building. + ## v1.1.0 - April 20, 2024 Features: diff --git a/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/_.cspell.json b/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/_.cspell.json index b4a3bcf..0085d1e 100644 --- a/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/_.cspell.json +++ b/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/_.cspell.json @@ -7,7 +7,8 @@ "language": "en", "ignorePaths": [ ".devcontainer/devcontainer.json", - ".github/workflows/*.yml" + ".github/workflows/*.yml", + ".gitignore" ], "words": [ "behaviour", diff --git a/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md b/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md index 32903b0..d8ff807 100644 --- a/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md +++ b/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md @@ -2,6 +2,22 @@ Feel free to open an issue or pull request. +## 💻 Local development + +This PowerShell module is developed using Visual Studio Code. +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. +You may also develop in your web browser with GitHub Codespaces to avoid needing to put any code or dependencies on your local machine. + +### 🛠️ Building and testing + +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. + +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. +In VS Code, open the command palette (Ctrl+Shift+P) and select `Tasks: Run Build Task` or `Tasks: Run Test Task`. + +When you run the build task, it will run PSScriptAnalyzer and CSpell spellcheck. +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. + ## 🚀 Publishing new versions A prerelease version of the module is published automatically on every commit to the `main` branch.