electron / update-electron-app

🌲 A drop-in module that adds autoUpdating capabilities to Electron apps
MIT License
736 stars 131 forks source link

Update files in src #55

Closed alexthemonk closed 3 years ago

alexthemonk commented 4 years ago

Hi, I've built an app with Electron and applied update-electron-app (which is awesome). My app is structured that the electron front end is responsible for just the user interface and a lot of the functionalities are back end binaries pre-compiled. Basically the electron app will invoke those binaries as needed. I just want to double check whether this auto-updater would also update those binaries in the src directory if I ever upload a new version of them. Thank you for your time.

alexthemonk commented 4 years ago

The main reason I'm asking is, I saw how it works with MacOS (submitting a zip file of the new app) which would include all the src files, including the pre-compiled binaries, but for Windows in README it says upload new .exe file, which I think doesn't include any of the src files (please correct me if I'm wrong). So I'm not sure whether this update is an update for the entire app or just the electron binaries. Thanks

frodal commented 3 years ago

If you package your binaries within your electron app, these binaries will also be updated. That is if your pre-compiled binaries are located within your electron app project folder and you update them before building your new version of the electron app. F.ex. if your project looks something like this:

Electron app
β”œβ”€β”€ package.json
β”œβ”€β”€ index.html
β”œβ”€β”€ […other files, like the app's LICENSE…]
└── BinariesFolder
     └── [pre-compiled binaries]
alexthemonk commented 3 years ago

@frodal Thank you very much!! A quick clarification question. I understand that the pre-compiled binary are required to be inside the electron app project folder. And this is straightforward to be done for Mac OS. What I'm not sure about is for Windows. After building electron app with electron forge I found that the .exe file is along side in the same folder as the binaries folder.

Parent Folder
β”œβ”€β”€ app.exe
└── BinariesFolder
     └── [pre-compiled binaries]

Since in the README of update-electron-app only says to upload the .exe file to github release, I'm wondering how are the binaries get updated to the clients on Windows. Thanks!!

frodal commented 3 years ago

Unfortunately, I don't have any experience with Electron forge, but what I understand from their Github page is that it uses Electron packager under the hood to build and package the app. I've built projects including pre-compiled binaries using Electron packager and Electron installer windows or Electron (w)installer. In this case, Electron packager will package the app with the pre-compiled binaries in a resources folder under the apps parent folder, e.g.,

Packaged app
β”œβ”€β”€ app.exe
β”œβ”€β”€ […other files, like the electron LICENSE, some .dll files, some folders…]
└── resources
     └── [either app.asar or a folder "app" containing your apps source code]

The app.asar/app folder contains the source code of your app as outlined in my previous post with the pre-compiled binaries inside. To run the app one needs the entire packaged app and not only the .exe file in the above file structure, this is the case for apps without pre-compiled binaries as well. To create the .exe installer that is needed by electron-update-app on Windows I've used Electron installer to create an installer based on the packaged app. Electron installer will create, e.g., a RELEASE file, a .exe installer, a .nupkg file, and an MSI installer. The RELEASE and the .nupkg files are what electron-update-app uses to update the app, while the .exe installer is what a user will typically use when they install your app on their computer. The .exe installer is also important for update.electronjs.org which is used by electron-update-app. Thus, you will need to upload the RELEASE file, the .exe installer and the .nupkg file to your Github releases or distribution server. Remember to use electron-squirrel-startup to handle install and update events. Hope this helps.

alexthemonk commented 3 years ago

@frodal Thank you so much. This has been super helpful.