Files
voidea/flutter/init_project.ps1
T

84 lines
2.9 KiB
PowerShell

# Инициализация Flutter-проекта VoIdea
# Создаёт platform-папки (android/ios/web) не трогая наши lib/ файлы
param (
[string]$ProjectDir = $PSScriptRoot
)
Write-Host "=== VoIdea Flutter Project Init ===" -ForegroundColor Cyan
# 1. Удаляем пустые папки android/ios/web которые мы создали вручную
Write-Host "`n[1/5] Cleaning stub folders..." -ForegroundColor Yellow
$stubs = @("android", "ios", "web")
foreach ($dir in $stubs) {
$path = Join-Path $ProjectDir $dir
if (Test-Path $path) {
Remove-Item -Recurse -Force $path
Write-Host " Removed $dir"
}
}
# 2. Создаём временный проект
Write-Host "`n[2/5] Creating temp Flutter project..." -ForegroundColor Yellow
$tempDir = Join-Path $env:TEMP "voidea_flutter_temp_$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
flutter create --android-language kotlin --project-name voidea_app --org com.voidea --platforms android,ios,web $tempDir 2>&1 | Out-Null
if (-not (Test-Path (Join-Path $tempDir "android"))) {
Write-Host "ERROR: flutter create failed. Check Flutter SDK installation." -ForegroundColor Red
exit 1
}
Write-Host " Temp project created at $tempDir"
# 3. Копируем platform-папки в наш проект
Write-Host "`n[3/5] Copying platform folders..." -ForegroundColor Yellow
$folders = @("android", "ios", "web")
foreach ($folder in $folders) {
$src = Join-Path $tempDir $folder
$dst = Join-Path $ProjectDir $folder
if (Test-Path $src) {
Copy-Item -Recurse -Force $src $dst
Write-Host " Copied $folder"
}
}
# Копируем .metadata (нужен Flutter tools)
Copy-Item (Join-Path $tempDir ".metadata") (Join-Path $ProjectDir ".metadata") -Force
Write-Host " Copied .metadata"
# 4. Удаляем временный проект
Write-Host "`n[4/5] Cleaning up..." -ForegroundColor Yellow
Remove-Item -Recurse -Force $tempDir
Write-Host " Temp project removed"
# 5. Проверяем что наши lib/ файлы на месте
Write-Host "`n[5/5] Verifying..." -ForegroundColor Yellow
$ourFiles = @(
"lib/main.dart",
"lib/app.dart",
"lib/core/theme/app_theme.dart",
"lib/core/router/app_router.dart",
"lib/core/api/client.dart",
"lib/providers/auth_provider.dart"
)
$allOk = $true
foreach ($file in $ourFiles) {
$path = Join-Path $ProjectDir $file
if (Test-Path $path) {
Write-Host " OK $file"
} else {
Write-Host " MISSING $file" -ForegroundColor Red
$allOk = $false
}
}
Write-Host "`n================================" -ForegroundColor Cyan
if ($allOk) {
Write-Host "SUCCESS! Run these commands:" -ForegroundColor Green
Write-Host " cd flutter"
Write-Host " flutter clean"
Write-Host " flutter pub get"
Write-Host " flutter run"
} else {
Write-Host "Some files are missing. Check git status." -ForegroundColor Red
}