Skip to content

Commit 28a6f76

Browse files
committed
Fix Pester Output + Change vsce install
1 parent 36ecce3 commit 28a6f76

5 files changed

Lines changed: 1833 additions & 51 deletions

File tree

.vscode/tasks.json

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,41 @@
22
// for the documentation about the tasks.json format
33
{
44
"version": "2.0.0",
5+
"windows": {
6+
"options": {
7+
"shell": {
8+
"executable": "pwsh.exe",
9+
"args": [
10+
"-NoProfile",
11+
"-ExecutionPolicy",
12+
"Bypass",
13+
"-Command"
14+
]
15+
}
16+
}
17+
},
18+
"linux": {
19+
"options": {
20+
"shell": {
21+
"executable": "/usr/bin/pwsh",
22+
"args": [
23+
"-NoProfile",
24+
"-Command"
25+
]
26+
}
27+
}
28+
},
29+
"osx": {
30+
"options": {
31+
"shell": {
32+
"executable": "/usr/local/bin/pwsh",
33+
"args": [
34+
"-NoProfile",
35+
"-Command"
36+
]
37+
}
38+
}
39+
},
540
"tasks": [
641
{
742
"type": "npm",
@@ -15,6 +50,28 @@
1550
"kind": "build",
1651
"isDefault": true
1752
}
53+
},
54+
{
55+
"label": "Run Tests",
56+
"type": "shell",
57+
"command": "./build.ps1 -Task Test",
58+
"problemMatcher": "$pester",
59+
"group": {
60+
"kind": "test",
61+
"isDefault": true
62+
},
63+
"options": {
64+
"shell": {
65+
"executable": "pwsh",
66+
"args": [
67+
"-NoProfile",
68+
"-NoLogo",
69+
"-ExecutionPolicy",
70+
"Bypass",
71+
"-Command"
72+
]
73+
}
74+
}
1875
}
1976
]
20-
}
77+
}

build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $ErrorActionPreference = 'Stop'
2222

2323
# Bootstrap dependencies
2424
if ($Bootstrap.IsPresent) {
25-
Get-PackageProvider -Name Nuget -ForceBootstrap | Out-Null
25+
PackageManagement\Get-PackageProvider -Name Nuget -ForceBootstrap | Out-Null
2626
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
2727
if ((Test-Path -Path ./requirements.psd1)) {
2828
if (-not (Get-Module -Name PSDepend -ListAvailable)) {

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"type": "string",
7373
"enum": [
7474
"error",
75-
"warn",
75+
"warn",
7676
"info",
7777
"debug"
7878
],
@@ -94,15 +94,16 @@
9494
"package": "pwsh -NoLogo -NoProfile -ExecutionPolicy Bypass -File ./build.ps1 -Task Package"
9595
},
9696
"devDependencies": {
97-
"@types/vscode": "^1.102.0",
9897
"@types/mocha": "^10.0.10",
9998
"@types/node": "22.x",
99+
"@types/vscode": "^1.102.0",
100100
"@typescript-eslint/eslint-plugin": "^8.39.0",
101101
"@typescript-eslint/parser": "^8.39.0",
102-
"eslint": "^9.32.0",
103-
"typescript": "^5.9.2",
104102
"@vscode/test-cli": "^0.0.11",
105-
"@vscode/test-electron": "^2.5.2"
103+
"@vscode/test-electron": "^2.5.2",
104+
"@vscode/vsce": "^3.6.0",
105+
"eslint": "^9.32.0",
106+
"typescript": "^5.9.2"
106107
},
107108
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
108109
"keywords": [
@@ -111,4 +112,4 @@
111112
"inline",
112113
"decorations"
113114
]
114-
}
115+
}

psake.ps1

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# psake build script for PowerShellLocalization
22
# See https://psake.dev/ for syntax and usage
33
#requires -Version 7
4+
# spell-checker:ignore Markdig
45
Properties {
56
$script:extensionName = 'PowerShellLocalization'
67
$script:vsixPattern = '*.vsix'
@@ -9,14 +10,21 @@ Properties {
910

1011
$script:PesterConfiguration = New-PesterConfiguration
1112
$script:PesterConfiguration.Output.CIFormat = 'Auto'
13+
$script:PesterConfiguration.Output.Verbosity = 'Detailed'
1214
$script:PesterConfiguration.Run.Path = ".\tests\"
1315
$script:PesterConfiguration.Run.PassThru = $true
1416
}
1517

18+
FormatTaskName {
19+
param($taskName)
20+
Write-Host 'Task: ' -ForegroundColor Cyan -NoNewline
21+
Write-Host $taskName.ToUpper() -ForegroundColor Blue
22+
}
23+
1624
Task Default -Depends Test
1725
Task Test -Depends Lint, VscodeTest, Pester
1826

19-
Task Clean {
27+
Task Clean -Description "Clean the output directory" {
2028
Write-Host '🧹 Cleaning previous builds...'
2129
if (Test-Path $script:outDir) {
2230
Remove-Item -Recurse -Force $script:outDir
@@ -29,32 +37,19 @@ Task Clean {
2937
}
3038
}
3139

32-
33-
Task InstallVsce {
34-
Write-Host '🔍 Checking for vsce (Visual Studio Code Extension manager)...'
35-
try {
36-
$null = vsce --version 2>$null
37-
Write-Host '✅ vsce is already installed'
38-
} catch {
39-
Write-Host '⚠️ vsce not found. Installing vsce globally...'
40-
npm install -g @vscode/vsce
41-
Write-Host '✅ vsce installed successfully'
42-
}
43-
}
44-
45-
Task InstallDependencies -Depends InstallVsce {
40+
Task InstallDependencies -Description "Install project dependencies" {
4641
Write-Host '📥 Installing dependencies...'
4742
yarn install
4843
Write-Host '✅ Dependencies installed successfully'
4944
}
5045

51-
Task Compile -Depends InstallDependencies {
46+
Task Compile -Depends InstallDependencies -Description "Compile TypeScript files" {
5247
Write-Host '🔨 Compiling TypeScript...'
5348
yarn run compile
5449
Write-Host '✅ TypeScript compiled successfully'
5550
}
5651

57-
Task Lint {
52+
Task Lint -Description "Lint the source code" {
5853
Write-Host '🔍 Running linter...'
5954
try {
6055
yarn run lint
@@ -64,7 +59,7 @@ Task Lint {
6459
}
6560
}
6661

67-
Task VscodeTest -Depends InstallDependencies {
62+
Task VscodeTest -Depends InstallDependencies -Description "Run VS Code tests" {
6863
Write-Host '🔍 Running VS Code tests...'
6964
try {
7065
yarn run vscode:test
@@ -75,10 +70,9 @@ Task VscodeTest -Depends InstallDependencies {
7570
}
7671
}
7772

78-
Task Pester {
73+
Task Pester -Description "Run Pester tests" {
7974
Write-Host '🧪 Running Pester tests...'
8075
try {
81-
Import-Module Pester
8276
$results = Invoke-Pester -Configuration $script:PesterConfiguration
8377
if ($results.FailedCount -gt 0) {
8478
Write-Error '❌ Pester tests failed. Please fix the issues before packaging.'
@@ -87,13 +81,14 @@ Task Pester {
8781
Write-Host '✅ Pester tests passed'
8882
} catch {
8983
Write-Error '❌ Pester tests failed. Please fix the issues before packaging.'
84+
$PSCmdlet.ThrowTerminatingError($_)
9085
exit 1
9186
}
9287
}
9388

94-
Task Package -Depends Clean, Compile, Test {
89+
Task Package -Depends Clean, Compile, Test -Description "Package the extension" {
9590
Write-Host '📦 Packaging extension...'
96-
$packageResult = Write-Output 'y' | vsce package --allow-missing-repository --out $script:outDir
91+
Write-Output 'y' | vsce package --allow-missing-repository --out $script:outDir
9792
$vsixFiles = Get-ChildItem -Path $script:outDir -Filter $script:vsixPattern | Sort-Object LastWriteTime -Descending
9893
if (-not $vsixFiles) {
9994
throw '❌ No .vsix file was generated'
@@ -102,16 +97,15 @@ Task Package -Depends Clean, Compile, Test {
10297
Write-Host "✅ Extension packaged successfully: $($vsixFiles[0].Name)"
10398
}
10499

105-
Task Install -Depends Package {
100+
Task Install -Depends Package -Description "Install the extension in VS Code" {
106101
Write-Host '🚀 Installing extension in VS Code...'
107102
$command = @('code', '--install-extension', $script:vsixFile, '--force')
108103
& $command
109104
Write-Host '✅ Extension installed successfully!'
110105
Write-Host '🔄 Please reload VS Code to activate the extension.'
111106
}
112107

113-
# CI task for GitHub Actions
114-
Task CI -Depends Package {
108+
Task CI -Depends Package -Description "Run CI task for GitHub Actions" {
115109
Write-Host '🏗️ Running CI task for GitHub Actions...'
116110
if ($env:GITHUB_OUTPUT) {
117111
Write-Host 'GITHUB_OUTPUT environment variable is set. Writing output...'

0 commit comments

Comments
 (0)