From 3908307f7b23d965ab20e7d4268a9fa866b66aa5 Mon Sep 17 00:00:00 2001 From: deadlydog Date: Thu, 27 Mar 2025 00:57:10 -0600 Subject: [PATCH 1/6] chore: Update to the latest devcontainer image chore: Install CSpell if needed feat: Add VS Code tasks to run CSpell locally --- .cspell.json | 4 ++- .devcontainer/devcontainer.json | 7 +++-- .gitignore | 6 ++++ .vscode/tasks.json | 28 ++++++++++++++++++- .../TemplateRepoFiles/_.cspell.json | 3 +- 5 files changed, 42 insertions(+), 6 deletions(-) diff --git a/.cspell.json b/.cspell.json index a933584..6d53ef9 100644 --- a/.cspell.json +++ b/.cspell.json @@ -10,7 +10,9 @@ "**/_.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. ], "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/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", From 90edaa27eae58b4fe6999ac5d388368d3160b4b1 Mon Sep 17 00:00:00 2001 From: deadlydog Date: Thu, 27 Mar 2025 00:58:07 -0600 Subject: [PATCH 2/6] feat: Update Contributing docs with more info on local development --- .../TemplateRepoFiles/docs/Contributing.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md b/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md index 32903b0..34a8ca3 100644 --- a/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md +++ b/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md @@ -2,6 +2,19 @@ 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`. + ## 🚀 Publishing new versions A prerelease version of the module is published automatically on every commit to the `main` branch. From a77371ab5a4a3aa03ad971a3681b1011cc106a14 Mon Sep 17 00:00:00 2001 From: deadlydog Date: Thu, 27 Mar 2025 01:00:23 -0600 Subject: [PATCH 3/6] style: Add emoji to headers --- .../TemplateRepoFiles/docs/Contributing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md b/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md index 34a8ca3..33fcf83 100644 --- a/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md +++ b/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md @@ -2,13 +2,13 @@ Feel free to open an issue or pull request. -## Local development +## 💻 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 +### 🛠️ 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. From d8bf25d7cad183fa0a561186b01f423752d31871 Mon Sep 17 00:00:00 2001 From: deadlydog Date: Thu, 27 Mar 2025 01:07:31 -0600 Subject: [PATCH 4/6] Update Contributing docs with CSpell info --- .../TemplateRepoFiles/docs/Contributing.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md b/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md index 33fcf83..d8ff807 100644 --- a/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md +++ b/src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/docs/Contributing.md @@ -15,6 +15,9 @@ The code is built and tested by CI/CD pipelines on every commit to the `main` br 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. From d1b150f901e217289c6eefac5fd614c050335468 Mon Sep 17 00:00:00 2001 From: deadlydog Date: Thu, 27 Mar 2025 01:10:56 -0600 Subject: [PATCH 5/6] docs: Update Changelog --- Changelog.md | 8 ++++++++ 1 file changed, 8 insertions(+) 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: From 7f6fb96153a3fcefe4fabf8617e6904540552782 Mon Sep 17 00:00:00 2001 From: deadlydog Date: Thu, 27 Mar 2025 01:12:54 -0600 Subject: [PATCH 6/6] chore: Do not spellcheck the gitignore file --- .cspell.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.cspell.json b/.cspell.json index 6d53ef9..2895231 100644 --- a/.cspell.json +++ b/.cspell.json @@ -12,7 +12,8 @@ "**/build-and-test-powershell-module.yml", "**/build-test-and-deploy-powershell-module.yml", "**/bin/**", // Ignore C# build output files. - "**/obj/**" // Ignore C# build output files. + "**/obj/**", // Ignore C# build output files. + ".gitignore" ], "words": [ "behaviour",