61 lines
1.6 KiB
PowerShell
61 lines
1.6 KiB
PowerShell
#Requires -Version 5.1
|
|
<#
|
|
.SYNOPSIS
|
|
Запуск Widgetbook (каталог UI-компонентов).
|
|
|
|
.EXAMPLE
|
|
.\run.ps1
|
|
.\run.ps1 -Device windows
|
|
.\run.ps1 -Device chrome -SkipPubGet
|
|
#>
|
|
param(
|
|
[ValidateSet("chrome", "windows", "edge")]
|
|
[string]$Device = "chrome",
|
|
|
|
[switch]$SkipPubGet
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
Set-Location $ScriptDir
|
|
|
|
function Find-Flutter {
|
|
$cmd = Get-Command flutter -ErrorAction SilentlyContinue
|
|
if ($cmd) { return $cmd.Source }
|
|
|
|
$candidates = @(
|
|
"$env:USERPROFILE\flutter\bin\flutter.bat",
|
|
"$env:LOCALAPPDATA\flutter\bin\flutter.bat",
|
|
"C:\flutter\bin\flutter.bat",
|
|
"C:\src\flutter\bin\flutter.bat"
|
|
)
|
|
foreach ($path in $candidates) {
|
|
if (Test-Path $path) { return $path }
|
|
}
|
|
return $null
|
|
}
|
|
|
|
$flutter = Find-Flutter
|
|
if (-not $flutter) {
|
|
Write-Error @"
|
|
Flutter не найден в PATH и в стандартных путях.
|
|
Установи SDK или добавь в PATH, например:
|
|
`$env:Path = `"$env:USERPROFILE\flutter\bin;`$env:Path`"
|
|
"@
|
|
}
|
|
|
|
Write-Host "Flutter: $flutter" -ForegroundColor DarkGray
|
|
Write-Host "Device: $Device" -ForegroundColor DarkGray
|
|
Write-Host "Dir: $ScriptDir" -ForegroundColor DarkGray
|
|
Write-Host ""
|
|
|
|
if (-not $SkipPubGet) {
|
|
Write-Host ">> flutter pub get" -ForegroundColor Cyan
|
|
& $flutter pub get
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
}
|
|
|
|
Write-Host ">> flutter run -d $Device" -ForegroundColor Cyan
|
|
& $flutter run -d $Device
|
|
exit $LASTEXITCODE
|