()
| 429 | } |
| 430 | |
| 431 | async function applyPluginUpdates() { |
| 432 | if (pluginUpdates.size === 0) return; |
| 433 | |
| 434 | for (const dir of pluginUpdates) { |
| 435 | const pluginPath = path.join(PLUGINS, dir); |
| 436 | const pluginXml = path.join(pluginPath, "plugin.xml"); |
| 437 | |
| 438 | if (!fs.existsSync(pluginXml)) { |
| 439 | log("warn", `No plugin.xml in ${dir} — skipping`); |
| 440 | continue; |
| 441 | } |
| 442 | |
| 443 | const xml = fs.readFileSync(pluginXml, "utf8"); |
| 444 | const idMatch = /<plugin[^>]*?\sid=["']([^"']+)["']/.exec(xml); |
| 445 | const pluginId = idMatch?.[1]; |
| 446 | if (!pluginId) { |
| 447 | log("warn", `Could not find plugin id in ${dir}/plugin.xml`); |
| 448 | continue; |
| 449 | } |
| 450 | |
| 451 | log("info", `Updating plugin: ${pluginId}`); |
| 452 | |
| 453 | try { |
| 454 | await spawnAsync("cordova", ["plugin", "remove", pluginId], { |
| 455 | cwd: ROOT, |
| 456 | }); |
| 457 | } catch (_e) { |
| 458 | // Plugin might not be installed yet — that's OK |
| 459 | } |
| 460 | |
| 461 | try { |
| 462 | await spawnAsync("cordova", ["plugin", "add", `./src/plugins/${dir}`], { |
| 463 | cwd: ROOT, |
| 464 | }); |
| 465 | log("ok", `Plugin ${pluginId} reinstalled`); |
| 466 | } catch (err) { |
| 467 | log("warn", `Failed to reinstall plugin ${pluginId}: ${err.message}`); |
| 468 | continue; |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | pluginUpdates.clear(); |
| 473 | |
| 474 | // Restart the app after plugin changes (native changes need full restart) |
| 475 | try { |
| 476 | const configXml = fs.readFileSync(path.join(ROOT, "config.xml"), "utf8"); |
| 477 | const pkgMatch = /id="([^"]+)"/.exec(configXml); |
| 478 | const pkg = pkgMatch?.[1]; |
| 479 | if (pkg) { |
| 480 | log("info", "Restarting app after plugin update..."); |
| 481 | // Need to rebuild APK since native plugin code changed |
| 482 | await spawnAsync("cordova", ["build", pluginPlatform], { |
| 483 | cwd: ROOT, |
| 484 | }); |
| 485 | if (pluginPlatform === "android") { |
| 486 | await spawnAsync("adb", ["uninstall", pkg], { stdio: "ignore" }); |
| 487 | } |
| 488 | await spawnAsync("cordova", ["run", pluginPlatform], { |
nothing calls this directly
no test coverage detected