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: add upgrade reminder #3569

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

DevanceJ
Copy link
Contributor

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • The changes are appropriately documented (if applicable).
  • The changes have sufficient test coverage (if applicable).
  • The testsuite passes successfully on my local machine (if applicable).

Summarize your changes:
fixes #3091

uses update-notifier to remind user about new version of Forge.

@DevanceJ DevanceJ requested a review from a team as a code owner April 18, 2024 08:30
@DevanceJ DevanceJ changed the title cli: add upgrade reminder feat: add upgrade reminder Apr 18, 2024
@DevanceJ
Copy link
Contributor Author

Hi @erickzhao
I have used an older version of update-notifier in order to work with CommonJs, I have tried to work with the latest version of the library that supports CommonJs. Looking forward to your feedback.

@DevanceJ
Copy link
Contributor Author

I see that some tests are failing. I'll look into it and let you know.

"chai": "^4.3.3",
"chai-as-promised": "^7.0.0",
"mocha": "^9.0.1"
"mocha": "^9.0.1",
"update-notifier": "5.1.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: I think this should be under dependencies since it ships to users.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, can we not dynamically import the ESM module into CommonJS? Would be nice to have v6. v7 seems out of the question for now because we still support Node 16 in Forge.

await import('update-notifier')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to use the dynamic import() for v6 but kept getting the same ESM errors.


import './util/terminate';
import workingDir from './util/working-dir';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const metadata = require('../package.json');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: This can be converted to an import statement to avoid the ESLint error.

},
updateCheckInterval: 1000 * 60 * 60,
});
if (notifier.update && semver.lt(notifier.update.current, notifier.update.latest)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: In what case is there going to be an update available and current < latest? I thought that updateNotifier would not actually report a notifier.update if there was not an update available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right
Returns an instance with an .update property if there is an available update, otherwise undefined.
I was not thorough enough with the documentation and hence used semver to double check the condition. I'm sorry :)

updateCheckInterval: 1000 * 60 * 60,
});
if (notifier.update && semver.lt(notifier.update.current, notifier.update.latest)) {
console.log(`Update available: ${chalk.dim(`${notifier.update?.current}`)} -> ${chalk.green(`${notifier.update?.latest}`)}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue(blocking): I don't think this is exactly what we want here.

I think a custom log message is necessary for our monorepo design as we want to provide users with a way to update all their packages at a glance, but it seems like the custom message here simply logs the new version number without additional context?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, I'd like to manually generate the little box that updatenotifier uses by default :)

(async () => {
let commandArgs = process.argv;
let appArgs;
const notifier = updateNotifier({
pkg: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we should just pass the package.json directly here?

@DevanceJ
Copy link
Contributor Author

The tests are failing because I used update-notifier as a dependency instead of devdependency. Please guide me on how to fix this.

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.

Add upgrade reminder
2 participants