electron / forge

:electron: A complete tool for building and publishing Electron applications
https://electronforge.io
MIT License
6.41k stars 506 forks source link

Add upgrade reminder #3091

Open erickzhao opened 1 year ago

erickzhao commented 1 year ago

Pre-flight checklist

Problem description

Forge users should stay up-to-date with the latest version as much as possible. We currently don't have a way of alerting people to bump their packages up.

Proposed solution

Docusaurus prints out this little message when you run a production build. Something similar for Forge would be nice.


   ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
   │                                                                                                                                                                 │
   │                                                                 Update available 2.0.1 → 2.2.0                                                                  │
   │                                                                                                                                                                 │
   │                                       To upgrade Docusaurus packages with the latest version, run the following command:                                        │
   │    `yarn upgrade @docusaurus/core@latest @docusaurus/plugin-google-analytics@latest @docusaurus/plugin-ideal-image@latest @docusaurus/preset-classic@latest     │
   │                                              @docusaurus/remark-plugin-npm2yarn@latest @docusaurus/types@latest`                                                │
   │                                                                                                                                                                 │
   ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Alternatives considered

Not showing a message.

Additional information

No response

DevanceJ commented 6 months ago

I am working on this. You want a check for latest Electron version right?

Docusaurus uses https://www.npmjs.com/package/update-notifier for comparing latest version and current versions. After going through this package I found out to get the latest version it uses https://www.npmjs.com/package/latest-version. According to me "latest-version" is ideal for us as it is regularly updated, is small in size and we already have current version data.

@erickzhao I would like to know your feed back on this.

I did some changes in start.ts I can make it accurate with the actual latest version data.

Screenshot 2024-03-12 at 12 36 36 AM
erickzhao commented 6 months ago

Hi @DevanceJ, this is specifically looking for the latest Forge version rather than the Electron version.

DevanceJ commented 6 months ago

Hi @erickzhao, Can you help me how to get the latest version to check if the user's version is outdated or not.

TheLazron commented 6 months ago

Hey @erickzhao I have been looking into this issue as well, update-notifier to check for update along with semver to check the difference in version appears to be the solution, like so if (notifier.config && notifier.update && semver.lt(notifier.update.current, notifier.update.latest))

As for the dependencies to be update, I used the exported set of dependencies similarly to the one in docusaurus snippet you provided which results in something like this:

npm i , @electron-forge/cli@latest, @electron-forge/maker-squirrel@latest, @electron-forge/maker-zip@latest, @electron-forge/maker-deb@latest, @electron-forge/maker-rpm@latest, @electron-forge/plugin-auto-unpack-natives@latest, electron-squirrel-startup@latest

But faced an issue when I installed update-notifier. The builds were going fine, but when I added update-notifier, I got flooded with error messages saying for several tsconfig files

packages/publisher/snapcraft/tsconfig.json:4:15 - error TS6046: Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext'.

4     "target": "ES2021",
DevanceJ commented 6 months ago

Hi @TheLazron, I did some more digging and there is actually no need to use any external libraries to implement this, the codebase currently uses exec from child_process to execute npm show for getting the latest versions.

DevanceJ commented 5 months ago

I closed the pr while resolving merge conflicts. I am going to raise a new pr to close the issue soon.

DevanceJ commented 5 months ago

I am trying to do this from the electron-forge-start file in cli but I keep getting this error when i try npm start(electron-forge start) in the linked electron app. Error [ERR_REQUIRE_ESM]: require() of ES Module

import updateNotifier from 'update-notifier';
const notifier = updateNotifier({ pkg: { name: '@electron-forge/cli', version: (await fs.readJson(path.resolve(__dirname, '../package.json'))).version, }, updateCheckInterval: 1000 60 60, }); notifier.notify();

Any advise?

DevanceJ commented 5 months ago

Hi, After doing some research I found a more optimal alternative to update-notifier

tiny-updater

I'll try using this for upgrade reminder.