-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathtest-cli.ps1
More file actions
119 lines (104 loc) · 4.1 KB
/
test-cli.ps1
File metadata and controls
119 lines (104 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env pwsh
# Test CLI locally without publishing to NuGet
# Usage: ./scripts/test-cli.ps1 [-Version "10.0.0-rc.1"] [-Uninstall]
param(
[string]$Version = "10.0.0-local",
[switch]$Uninstall,
[switch]$SkipBuild
)
$ErrorActionPreference = "Stop"
$ScriptDir = $PSScriptRoot
if (-not $ScriptDir) { $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path }
$RepoRoot = Split-Path -Parent $ScriptDir
$CliProject = Join-Path $RepoRoot "src\Tools\CLI\FSH.CLI.csproj"
$NupkgsDir = Join-Path $RepoRoot "artifacts\nupkgs"
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " FSH CLI Local Test Script" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Repo Root: $RepoRoot" -ForegroundColor Gray
Write-Host "CLI Project: $CliProject" -ForegroundColor Gray
Write-Host ""
# Uninstall existing CLI
Write-Host "[1/4] Uninstalling existing fsh tool..." -ForegroundColor Yellow
dotnet tool uninstall -g FullStackHero.CLI 2>$null
if ($LASTEXITCODE -eq 0) {
Write-Host " Uninstalled successfully" -ForegroundColor Green
} else {
Write-Host " Not installed (skipping)" -ForegroundColor Gray
}
if ($Uninstall) {
Write-Host ""
Write-Host "Uninstall complete." -ForegroundColor Green
exit 0
}
# Build and pack
if (-not $SkipBuild) {
Write-Host ""
Write-Host "[2/4] Building and packing CLI (Version: $Version)..." -ForegroundColor Yellow
# Clean artifacts
if (Test-Path $NupkgsDir) {
Remove-Item -Recurse -Force $NupkgsDir
}
New-Item -ItemType Directory -Force -Path $NupkgsDir | Out-Null
# Build with version
dotnet build $CliProject -c Release -p:Version=$Version
if ($LASTEXITCODE -ne 0) {
Write-Host "Build failed!" -ForegroundColor Red
exit 1
}
# Pack with version
dotnet pack $CliProject -c Release --no-build -o $NupkgsDir -p:PackageVersion=$Version
if ($LASTEXITCODE -ne 0) {
Write-Host "Pack failed!" -ForegroundColor Red
exit 1
}
Write-Host " Package created successfully" -ForegroundColor Green
} else {
Write-Host ""
Write-Host "[2/4] Skipping build (using existing package)..." -ForegroundColor Gray
}
# Install from local package
Write-Host ""
Write-Host "[3/4] Installing CLI from local package..." -ForegroundColor Yellow
$PackagePath = Get-ChildItem -Path $NupkgsDir -Filter "FullStackHero.CLI.*.nupkg" | Select-Object -First 1
if (-not $PackagePath) {
Write-Host "No package found in $NupkgsDir" -ForegroundColor Red
exit 1
}
Write-Host " Package: $($PackagePath.Name)" -ForegroundColor Gray
dotnet tool install -g FullStackHero.CLI --add-source $NupkgsDir --version $Version
if ($LASTEXITCODE -ne 0) {
Write-Host "Install failed!" -ForegroundColor Red
exit 1
}
Write-Host " Installed successfully" -ForegroundColor Green
# Verify installation
Write-Host ""
Write-Host "[4/4] Verifying installation..." -ForegroundColor Yellow
Write-Host ""
$fshPath = Get-Command fsh -ErrorAction SilentlyContinue
if ($fshPath) {
Write-Host " fsh location: $($fshPath.Source)" -ForegroundColor Gray
Write-Host ""
Write-Host "----------------------------------------" -ForegroundColor Cyan
fsh --version
Write-Host "----------------------------------------" -ForegroundColor Cyan
} else {
Write-Host " Warning: 'fsh' command not found in PATH" -ForegroundColor Yellow
Write-Host " You may need to restart your terminal" -ForegroundColor Yellow
}
Write-Host ""
Write-Host "========================================" -ForegroundColor Green
Write-Host " CLI installed successfully!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
Write-Host ""
Write-Host "Test commands:" -ForegroundColor Cyan
Write-Host " fsh --help" -ForegroundColor White
Write-Host " fsh new --help" -ForegroundColor White
Write-Host " fsh new MyApp" -ForegroundColor White
Write-Host ""
Write-Host "To uninstall:" -ForegroundColor Cyan
Write-Host " ./scripts/test-cli.ps1 -Uninstall" -ForegroundColor White
Write-Host ""