feat: offer to move into Applications folder on macOS
Fixes https://github.com/microsoft/vscode/issues/213909
Detect when application on macOS is installed outside the Applications folder and offer choice to move. The detection will bail early under the following cases,
- Application is launched from the cli (CI or perf environments). Additionally the relauncher on the runtime side cannot forward cli args so we should skip this case
- Application is installed in portable mode
There are 3 cases this path should cover,
- There are no versions of the app already present under the Applications folder
In this case, once user confirms the choice to move app.moveToApplicationsFolder will quit the current instance (which follows app.quit path in the runtime so all shutdown veto paths will be respected), copy the app to destination, trash the source app, wait for the application to exit and relaunch from the destination
- There is an existing version of the app in the Applications folder but is not running
conflictType === exists
In this case, once user confirms the choice to move app.moveToApplicationsFolder delete the version under Applications folder and follow the same order of steps as 1)
- There is an existing version of the app in the Applications folder and is currently running
conflictType === existsAndRunning
In this case, due to our singleton logic any new instance sharing the same user-data-dir will merge to the running instance and hence no action is needed. When using different user-data-dir the launch would happen from cli in which case the detection will bail early as mentioned before.
Question:
- Do we need a setting for explicit opt-out in case there are cases we haven't covered ?
Do we need a setting for explicit opt-out in case there are cases we haven't covered ?
I lean towards NO. And then we can add a setting if users complain.