agent-device
Version:
Open source device layer for AI coding agents: a CLI, MCP server, and typed Node.js API to control mobile, web, TV, and desktop apps on devices and simulators, locally or in the cloud.
1 lines • 927 B
JavaScript
import e from"node:fs";import t from"node:os";import n from"node:path";function r(r,c=n.join(t.homedir(),`Library`,`Developer`,`XCTestDevices`)){let l=`${c}.agent-device-backup`;try{if(o(c)){let e=s(c);i(c),r({phase:`ios_runner_legacy_xctest_device_set_link_removed`,resourcePath:c,data:{linkTarget:e}})}e.existsSync(l)&&!e.existsSync(c)&&(a(l,c),r({phase:`ios_runner_legacy_xctest_device_set_backup_restored`,resourcePath:c,data:{backupPath:l}}))}catch(e){r({phase:`ios_runner_legacy_xctest_device_set_restore_failed`,resourcePath:c,data:{error:e instanceof Error?e.message:String(e)}})}}function i(t){try{e.unlinkSync(t)}catch(e){if(o(t))throw e}}function a(t,n){try{e.renameSync(t,n)}catch(r){if(e.existsSync(t)&&!e.existsSync(n))throw r}}function o(t){return e.lstatSync(t,{throwIfNoEntry:!1})?.isSymbolicLink()??!1}function s(t){try{return e.readlinkSync(t)}catch{return}}export{r as restoreLegacyXctestDeviceSetRedirect};