-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathinstall.ps1
More file actions
288 lines (240 loc) · 9.97 KB
/
install.ps1
File metadata and controls
288 lines (240 loc) · 9.97 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# Flutter Skill One-Click Installation Script (Windows PowerShell)
$ErrorActionPreference = "Stop"
Write-Host "Flutter Skill One-Click Installation" -ForegroundColor Blue
Write-Host ""
# ========== Helper Functions ==========
function Install-ToolPriorityRules {
$promptsDir = "$env:USERPROFILE\.claude\prompts"
$targetFile = "$promptsDir\flutter-tool-priority.md"
if (Test-Path $targetFile) {
Write-Host " [OK] Tool priority rules already installed" -ForegroundColor Green
return
}
# Create directory
if (-not (Test-Path $promptsDir)) {
New-Item -ItemType Directory -Path $promptsDir -Force | Out-Null
}
# Download from GitHub
$url = "https://raw.githubusercontent.com/ai-dashboad/flutter-skill/main/docs/prompts/tool-priority.md"
try {
Invoke-WebRequest -Uri $url -OutFile $targetFile -UseBasicParsing
Write-Host " [OK] Tool priority rules installed" -ForegroundColor Green
return
} catch {
# Fallback: try using the CLI
try {
& flutter-skill setup --silent 2>$null
Write-Host " [OK] Tool priority rules installed" -ForegroundColor Green
return
} catch {}
try {
& flutter-skill setup --silent 2>$null
Write-Host " [OK] Tool priority rules installed" -ForegroundColor Green
return
} catch {}
}
Write-Host " [!] Could not install tool priority rules automatically" -ForegroundColor Yellow
Write-Host " Run manually: flutter-skill setup"
}
function Add-McpToJson {
param([string]$FilePath, [string]$CmdName)
$entry = @{ command = $CmdName; args = @("server") }
if (Test-Path $FilePath) {
try {
$data = Get-Content $FilePath -Raw | ConvertFrom-Json
} catch {
$data = [PSCustomObject]@{}
}
} else {
$parentDir = Split-Path $FilePath -Parent
if (-not (Test-Path $parentDir)) {
New-Item -ItemType Directory -Path $parentDir -Force | Out-Null
}
$data = [PSCustomObject]@{}
}
if (-not $data.mcpServers) {
$data | Add-Member -NotePropertyName "mcpServers" -NotePropertyValue ([PSCustomObject]@{}) -Force
}
$data.mcpServers | Add-Member -NotePropertyName "flutter-skill" -NotePropertyValue ([PSCustomObject]$entry) -Force
$data | ConvertTo-Json -Depth 10 | Set-Content $FilePath -Encoding UTF8
}
function Show-IdeConfig {
param([string]$CmdName)
Write-Host ""
Write-Host "Configuring IDE integration..." -ForegroundColor Blue
# Claude Code
$claudeDir = "$env:USERPROFILE\.claude"
$claudeSettings = "$claudeDir\settings.json"
if (Test-Path $claudeDir) {
if ((Test-Path $claudeSettings) -and ((Get-Content $claudeSettings -Raw) -match "flutter-skill|flutter_skill")) {
Write-Host " [OK] Claude Code: already configured" -ForegroundColor Green
} else {
try {
Add-McpToJson -FilePath $claudeSettings -CmdName $CmdName
Write-Host " [OK] Claude Code: configured" -ForegroundColor Green
} catch {
Write-Host " [!] Claude Code: auto-config failed, manual config needed" -ForegroundColor Yellow
Write-Host " Add to $claudeSettings`:"
Write-Host " { `"mcpServers`": { `"flutter-skill`": { `"command`": `"$CmdName`", `"args`": [`"server`"] } } }" -ForegroundColor Cyan
}
}
}
# Cursor
$cursorDir = "$env:USERPROFILE\.cursor"
$cursorConfig = "$cursorDir\mcp.json"
if (Test-Path $cursorDir) {
if ((Test-Path $cursorConfig) -and ((Get-Content $cursorConfig -Raw) -match "flutter-skill|flutter_skill")) {
Write-Host " [OK] Cursor: already configured" -ForegroundColor Green
} else {
try {
Add-McpToJson -FilePath $cursorConfig -CmdName $CmdName
Write-Host " [OK] Cursor: configured" -ForegroundColor Green
} catch {
Write-Host " [!] Cursor: auto-config failed, manual config needed" -ForegroundColor Yellow
Write-Host " Add to $cursorConfig`:"
Write-Host " { `"mcpServers`": { `"flutter-skill`": { `"command`": `"$CmdName`", `"args`": [`"server`"] } } }" -ForegroundColor Cyan
}
}
}
}
function Test-Installation {
param([string]$CmdName)
Write-Host ""
Write-Host "Verifying installation..." -ForegroundColor Blue
try {
$versionOutput = & $CmdName --version 2>&1
Write-Host " [OK] $CmdName $versionOutput" -ForegroundColor Green
return $true
} catch {
Write-Host " [!] $CmdName not found in PATH" -ForegroundColor Yellow
Write-Host " You may need to restart your terminal"
return $false
}
}
function Show-Summary {
param([string]$CmdName)
Write-Host ""
Write-Host "============================================" -ForegroundColor Green
Write-Host " Installation complete!" -ForegroundColor Green
Write-Host "============================================" -ForegroundColor Green
Write-Host ""
Write-Host " Quick Start:"
Write-Host " 1. Launch your Flutter app:"
Write-Host " $CmdName launch /path/to/flutter/app" -ForegroundColor Cyan
Write-Host ""
Write-Host " 2. Or configure as MCP server in your IDE:"
Write-Host " { `"command`": `"$CmdName`", `"args`": [`"server`"] }" -ForegroundColor Cyan
Write-Host ""
Write-Host " 3. Check environment health:"
Write-Host " $CmdName doctor" -ForegroundColor Cyan
Write-Host ""
Write-Host " Docs: https://pub.dev/packages/flutter_skill"
Write-Host ""
}
# ========== Installation Methods ==========
Write-Host "Detecting best installation method..." -ForegroundColor Yellow
Write-Host ""
# Method 1: npm (Recommended)
if (Get-Command npm -ErrorAction SilentlyContinue) {
Write-Host "[OK] npm detected, installing via npm (recommended)" -ForegroundColor Green
Write-Host ""
Write-Host "Running: npm install -g flutter-skill"
npm install -g flutter-skill
$cmd = "flutter-skill"
if (Get-Command flutter-skill -ErrorAction SilentlyContinue) {
$cmd = "flutter-skill"
}
Test-Installation -CmdName $cmd
Write-Host ""
Write-Host "Setting up tool priority rules..." -ForegroundColor Blue
Install-ToolPriorityRules
Show-IdeConfig -CmdName $cmd
Show-Summary -CmdName $cmd
exit 0
}
# Method 2: Scoop
if (Get-Command scoop -ErrorAction SilentlyContinue) {
Write-Host "[OK] Scoop detected, installing via scoop" -ForegroundColor Green
Write-Host ""
Write-Host "Running: scoop bucket add flutter-skill"
scoop bucket add flutter-skill https://github.com/ai-dashboad/scoop-flutter-skill
Write-Host "Running: scoop install flutter-skill"
scoop install flutter-skill
Test-Installation -CmdName "flutter-skill"
Write-Host ""
Write-Host "Setting up tool priority rules..." -ForegroundColor Blue
Install-ToolPriorityRules
Show-IdeConfig -CmdName "flutter-skill"
Show-Summary -CmdName "flutter-skill"
exit 0
}
# Method 3: Install from source (requires Dart/Flutter)
if ((Get-Command dart -ErrorAction SilentlyContinue) -or (Get-Command flutter -ErrorAction SilentlyContinue)) {
Write-Host "[!] npm or Scoop not detected" -ForegroundColor Yellow
Write-Host "Installing from source using Dart (requires Flutter SDK)" -ForegroundColor Yellow
Write-Host ""
# Check Flutter
if (-not (Get-Command flutter -ErrorAction SilentlyContinue)) {
Write-Host "[X] Error: Flutter SDK not found" -ForegroundColor Red
Write-Host ""
Write-Host "Please install Flutter first: https://flutter.dev/docs/get-started/install"
Write-Host ""
Write-Host "Or use one of the following methods:"
Write-Host " npm install -g flutter-skill (recommended)"
Write-Host " scoop install flutter-skill"
exit 1
}
# Download source
$InstallDir = "$env:USERPROFILE\.flutter-skill-src"
if (-not (Test-Path $InstallDir)) {
Write-Host "Cloning repository to $InstallDir ..."
git clone https://github.com/ai-dashboad/flutter-skill.git $InstallDir
} else {
Write-Host "Updating source code..."
Set-Location $InstallDir
git pull origin main
}
Set-Location $InstallDir
# Install dependencies
Write-Host "Installing dependencies..."
flutter pub get
# Create batch file wrapper
Write-Host "Creating executable..."
$BinDir = "$env:USERPROFILE\bin"
if (-not (Test-Path $BinDir)) {
New-Item -ItemType Directory -Path $BinDir | Out-Null
}
$WrapperContent = @"
@echo off
cd /d "$InstallDir"
dart run bin/flutter_skill.dart %*
"@
$WrapperContent | Out-File -FilePath "$BinDir\flutter-skill.bat" -Encoding ASCII
# Add to PATH
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($UserPath -notlike "*$BinDir*") {
[Environment]::SetEnvironmentVariable("Path", "$UserPath;$BinDir", "User")
Write-Host ""
Write-Host " [OK] Added to PATH: $BinDir" -ForegroundColor Green
Write-Host " [!] Please restart your terminal to use flutter-skill command" -ForegroundColor Yellow
}
# Verify
Write-Host ""
Write-Host " [OK] flutter-skill installed to $BinDir\flutter-skill.bat" -ForegroundColor Green
Write-Host ""
Write-Host "Setting up tool priority rules..." -ForegroundColor Blue
Install-ToolPriorityRules
Show-IdeConfig -CmdName "flutter-skill"
Show-Summary -CmdName "flutter-skill"
exit 0
}
# No installation method found
Write-Host "[X] Error: No available installation method found" -ForegroundColor Red
Write-Host ""
Write-Host "Please install one of the following tools:"
Write-Host " 1. npm (recommended) - https://nodejs.org/"
Write-Host " 2. Scoop - https://scoop.sh/"
Write-Host " 3. Flutter SDK - https://flutter.dev/"
Write-Host ""
Write-Host "Then run this script again"
exit 1