feat: expose auto-updater method to update from file on disk #45406
+171
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
This is still a bit of a POC, I want to see what the thoughts are from maintainers about the scope of the change and whether they are willing to accept it before polishing the implementation.
The aim of this is to allow alternatives to the builtin auto-updater to leverage the squirrel code to install an updated app, without being forced to jump through as many hoops as today.
This is for electron-userland/electron-builder#2199 and their
electron-updater
npm package.The current flow in the electron-updater package works by it taking its own approach for checking and downloading updates. Once it has an update zip on disk, it invokes the builtin auto-updater by spinning up a simple http server, calling
setFeedUrl
and letting squirrel.mac fetch the update zip file from this http server.The problem is that it requires publishing the application in a zip file format, as that is what squirrel.mac requires. This is annoying as typically it is better to distribute the app in a dmg. So to allow the updater to work, you have to publish both a dmg and a zip.
This new method will allow electron-updater to do whatever it wants to get an app file on disk, it could keep using a zip, or it could download and mount a dmg. Which it can then pass to this new
prepareUpdateFromFile
to let squirrel.mac handle its checks and perform the updates as before.An alternate approach to this problem would be for electron-updater to bring its own node-api addon and build of squirrel so that they can access this method. But that would give them a lot more work to create and maintain that addon (I believe they don't have any c++/obj-c currently) and would likely be code derived from the patched squirrel.mac that electron maintains. I do not know if this would result in it being brittle, or if it would conflict with the builtin squirrel.
I have not explored this route yet, hoping that this PR would be acceptable instead.
This does require a reasonable sized patch to squirrel.mac, that could be improved with some refactoring, as it is largely code copied from elsewhere in the file. Before this PR I had never attempted to even read objective-c, so I do not feel confident in doing that refactoring myself, it took enough trial and error to get this far.
I haven't looked at upstreaming this, as there appears to be no activity on the upstream repository for a few years.
Checklist
npm test
passesRelease Notes
Notes: