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

Add upgrade reminder #3091

Open
3 tasks done
erickzhao opened this issue Nov 24, 2022 · 8 comments · May be fixed by #3569
Open
3 tasks done

Add upgrade reminder #3091

erickzhao opened this issue Nov 24, 2022 · 8 comments · May be fixed by #3569

Comments

@erickzhao
Copy link
Member

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

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
Copy link
Contributor

DevanceJ commented Mar 11, 2024

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
Copy link
Member Author

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

@DevanceJ
Copy link
Contributor

DevanceJ commented Mar 11, 2024

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

@TheLazron
Copy link

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
Copy link
Contributor

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
Copy link
Contributor

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

@DevanceJ
Copy link
Contributor

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
Copy link
Contributor

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

tiny-updater

I'll try using this for upgrade reminder.

@DevanceJ DevanceJ linked a pull request Apr 18, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants