39 lines
1.6 KiB
PowerShell
39 lines
1.6 KiB
PowerShell
<#
|
||
一次性环境检查(Windows)。不自动安装任何东西,只报告缺什么。
|
||
用法:右键「使用 PowerShell 运行」,或 powershell -ExecutionPolicy Bypass -File scripts\windows-check.ps1
|
||
#>
|
||
$ErrorActionPreference = 'Continue'
|
||
|
||
function Show($name, $ok, $hint) {
|
||
if ($ok) { Write-Host ("[OK] " + $name) -ForegroundColor Green }
|
||
else { Write-Host ("[缺失] " + $name + " -> " + $hint) -ForegroundColor Yellow }
|
||
}
|
||
|
||
# Node
|
||
$node = (Get-Command node -ErrorAction SilentlyContinue)
|
||
Show "Node.js" ($null -ne $node) "winget install OpenJS.NodeJS.LTS"
|
||
|
||
# Rust
|
||
$rustc = (Get-Command rustc -ErrorAction SilentlyContinue)
|
||
Show "Rust (rustc)" ($null -ne $rustc) "winget install Rustlang.Rustup"
|
||
if ($rustc) {
|
||
$v = (& rustc -V) -join ' '
|
||
Write-Host (" " + $v)
|
||
if ($v -notmatch 'msvc') {
|
||
Write-Host " [!] 当前工具链不是 MSVC,请执行: rustup default stable-msvc" -ForegroundColor Yellow
|
||
}
|
||
}
|
||
|
||
# MSVC 链接器
|
||
$link = Get-ChildItem "C:\Program Files (x86)\Microsoft Visual Studio" -Recurse -Filter link.exe -ErrorAction SilentlyContinue | Select-Object -First 1
|
||
Show "MSVC Build Tools (link.exe)" ($null -ne $link) "安装 VS 2022 Build Tools 并勾选「使用 C++ 的桌面开发」"
|
||
|
||
# WebView2
|
||
$wv = Get-ItemProperty "HKLM:\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" -ErrorAction SilentlyContinue
|
||
Show "WebView2 Runtime" ($null -ne $wv) "winget install Microsoft.EdgeWebView2Runtime(Win11 一般自带)"
|
||
|
||
Write-Host ""
|
||
Write-Host "全部 OK 后执行:" -ForegroundColor Cyan
|
||
Write-Host " npm ci"
|
||
Write-Host " npm run app:build"
|