Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose auto-updater method to update from file on disk #45406

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Julusian
Copy link

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

Release Notes

Notes:

Copy link

welcome bot commented Jan 31, 2025

💖 Thanks for opening this pull request! 💖

Semantic PR titles

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Commit signing

This repo enforces commit signatures for all incoming PRs.
To sign your commits, see GitHub's documentation on Telling Git about your signing key.

PR tips

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jan 31, 2025
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant