agent-flutter 0.1.18 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-flutter",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Portable Flutter skill/rule pack initializer for multiple AI IDEs.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -135,8 +135,8 @@ normalize_project_name() {
135
135
 
136
136
  append_path_once() {
137
137
  local target="$1"
138
- [[ -n "$target" ]] || return
139
- [[ -d "$target" ]] || return
138
+ [[ -n "$target" ]] || return 0
139
+ [[ -d "$target" ]] || return 0
140
140
  case ":$PATH:" in
141
141
  *":$target:"*) ;;
142
142
  *) export PATH="$PATH:$target" ;;
@@ -174,31 +174,33 @@ EOF
174
174
  }
175
175
 
176
176
  discover_working_fvm() {
177
- local candidates=()
178
177
  local candidate=""
179
178
  local pub_cache_fvm="$HOME/.pub-cache/bin/fvm"
180
179
 
181
180
  if command -v fvm >/dev/null 2>&1; then
182
- candidates+=("$(command -v fvm)")
181
+ candidate="$(command -v fvm)"
182
+ if "$candidate" --version >/dev/null 2>&1; then
183
+ FVM_BIN="$candidate"
184
+ return 0
185
+ fi
183
186
  fi
184
187
 
185
188
  if command -v which >/dev/null 2>&1; then
186
- for candidate in $(which -a fvm 2>/dev/null); do
189
+ while IFS= read -r candidate; do
187
190
  [[ -n "$candidate" ]] || continue
188
- candidates+=("$candidate")
189
- done
191
+ if "$candidate" --version >/dev/null 2>&1; then
192
+ FVM_BIN="$candidate"
193
+ return 0
194
+ fi
195
+ done <<< "$(which -a fvm 2>/dev/null || true)"
190
196
  fi
191
197
 
192
198
  if [[ -x "$pub_cache_fvm" ]]; then
193
- candidates+=("$pub_cache_fvm")
194
- fi
195
-
196
- for candidate in "${candidates[@]}"; do
197
- if "$candidate" --version >/dev/null 2>&1; then
198
- FVM_BIN="$candidate"
199
+ if "$pub_cache_fvm" --version >/dev/null 2>&1; then
200
+ FVM_BIN="$pub_cache_fvm"
199
201
  return 0
200
202
  fi
201
- done
203
+ fi
202
204
 
203
205
  return 1
204
206
  }
@@ -235,6 +237,94 @@ ensure_line_in_file() {
235
237
  fi
236
238
  }
237
239
 
240
+ configure_android_flavors() {
241
+ local android_app_id="$ORG_ID.$APP_PACKAGE_NAME"
242
+ local gradle_kts_file="android/app/build.gradle.kts"
243
+
244
+ if [[ ! -f "$gradle_kts_file" ]]; then
245
+ echo "Warning: Android Gradle Kotlin file not found, skip flavor config: $gradle_kts_file"
246
+ return 0
247
+ fi
248
+
249
+ cat >"$gradle_kts_file" <<EOF
250
+ import java.io.File
251
+
252
+ fun loadEnv(name: String): Map<String, String> {
253
+ val envFile = rootProject.file("../" + name)
254
+ val env = mutableMapOf<String, String>()
255
+
256
+ if (envFile.exists()) {
257
+ envFile.forEachLine { line ->
258
+ if (line.isNotBlank() && !line.startsWith("#") && line.contains("=")) {
259
+ val parts = line.split("=", limit = 2)
260
+ env[parts[0].trim()] = parts[1].trim()
261
+ }
262
+ }
263
+ }
264
+ return env
265
+ }
266
+
267
+ val stagingEnv = loadEnv(".env.staging")
268
+ val prodEnv = loadEnv(".env.prod")
269
+
270
+ plugins {
271
+ id("com.android.application")
272
+ id("kotlin-android")
273
+ // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
274
+ id("dev.flutter.flutter-gradle-plugin")
275
+ }
276
+
277
+ android {
278
+ namespace = "$android_app_id"
279
+ compileSdk = flutter.compileSdkVersion
280
+ ndkVersion = flutter.ndkVersion
281
+
282
+ compileOptions {
283
+ sourceCompatibility = JavaVersion.VERSION_11
284
+ targetCompatibility = JavaVersion.VERSION_11
285
+ }
286
+
287
+ kotlinOptions {
288
+ jvmTarget = JavaVersion.VERSION_11.toString()
289
+ }
290
+
291
+ defaultConfig {
292
+ applicationId = "$android_app_id"
293
+ minSdk = flutter.minSdkVersion
294
+ targetSdk = flutter.targetSdkVersion
295
+ versionCode = flutter.versionCode
296
+ versionName = flutter.versionName
297
+ }
298
+
299
+ buildTypes {
300
+ release {
301
+ signingConfig = signingConfigs.getByName("debug")
302
+ }
303
+ }
304
+
305
+ flavorDimensions += "app"
306
+ productFlavors {
307
+ create("prod") {
308
+ dimension = "app"
309
+ resValue("string", "google_maps_api_key", prodEnv["GOOGLE_MAP_API_KEY"] ?: "")
310
+ }
311
+ create("staging") {
312
+ dimension = "app"
313
+ applicationIdSuffix = ".staging"
314
+ versionNameSuffix = "-staging"
315
+ resValue("string", "google_maps_api_key", stagingEnv["GOOGLE_MAP_API_KEY"] ?: "")
316
+ }
317
+ }
318
+ }
319
+
320
+ flutter {
321
+ source = "../.."
322
+ }
323
+ EOF
324
+
325
+ echo "Configured Android product flavors (prod/staging)."
326
+ }
327
+
238
328
  PROJECT_NAME="$(prompt_required "$PROJECT_NAME" "Project name: ")"
239
329
  if [[ -z "$PROJECT_NAME" ]]; then
240
330
  echo "Error: project name is required." >&2
@@ -288,6 +378,8 @@ if ! "${create_args[@]}"; then
288
378
  exit 1
289
379
  fi
290
380
 
381
+ configure_android_flavors
382
+
291
383
  mkdir -p .vscode
292
384
  cat >.vscode/settings.json <<'JSON'
293
385
  {