-
-
Notifications
You must be signed in to change notification settings - Fork 78
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: notify users whenever an update available #129
Conversation
✅ Deploy Preview for jest-preview-library ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @huynhducduy. Thank you so much for your interest in Jest Preview and your efforts you put to ship this feature. I left some comments, please let me know your thoughts.
I can't wait to welcome you to contributors.
Hi @nvh95, I updated the PR, please take a look. |
@huynhducduy Hey Duy, I'm going to do some smoke test and review the PR one more time and let you know if it good to be merged. Thank you for your time. <3 |
@huynhducduy /Users/my_name/jest-preview/cli/index.js:19
const chalk = require('chalk');
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/my_name/jest-preview/node_modules/chalk/source/index.js from /Users/my_name/jest-preview/cli/index.js not supported.
Instead change the require of /Users/my_name/jest-preview/node_modules/chalk/source/index.js in /Users/my_name/jest-preview/cli/index.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/Users/my_name/jest-preview/cli/index.js:19:15) {
code: 'ERR_REQUIRE_ESM'
} How to reproduce cd examples/vite-react
npm install
npm run jest-preview The reason that
If you run So I would like to ask you to install
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some tests and it work great. Please help to resolve 2 things and this PR will be ready to be merged:
- Run
npm run prettier:fix
- Use
chalk@4
instead (see above comment).
Thank you very much for your help @huynhducduy
cli/index.js
Outdated
notifier.notify({ | ||
defer: true, // Try not to annoy user by showing the notification after the process has exited | ||
message:[ | ||
`${chalk.blue('{packageName}')} has an update available: ${chalk.gray('{currentVersion}')} → ${chalk.green('{latestVersion}')}`, | ||
`Please run ${chalk.cyan('`{updateCommand}`')} to update.`, | ||
].join('\n') | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you reformat your code by npm run prettier:fix
?
You can leave the changes in other files, just need to update code for cli/index.js
is sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@huynhducduy
Actually, I think your current code is more readable than the one prettier suggests, you can ignore line 30, 31 if you line.
Something like this
<!-- prettier-ignore-start -->
`${chalk.blue('{packageName}')} has an update available: ${chalk.gray('{currentVersion}')} → ${chalk.green('{latestVersion}')}`,
`Please run ${chalk.cyan('`{updateCommand}`')} to update.`,
<!-- prettier-ignore-end -->
It's your call. I am good with either option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nvh95 unfortunately, prettier-ignore-start
only works in markdown 😢 , so it will need 2 piece of // prettier-ignore
for those 2 lines if i wanna keep the code in my way, and it does not seem so good 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I and my team dropped prettier
also because of problems like that, although prettier
is simple, it's too opinionated, and sometimes we don't need to strictly format our code like that. IMO, eslint
's stylistic rules are enough to play with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@all-contributors please add @huynhducduy for code |
I've put up a pull request to add @huynhducduy! 🎉 |
@huynhducduy Thank you very much for your help. Welcome to contributors! |
Features
About @duong-le's considerations in #109 (comment)
update-notifier
already support 3 ways to disable the notification, I don't think that we need more than that.This behavior is intentional
in Notification is only displayed at most once per interval yeoman/update-notifier#209 (comment), the choice is up to us.update-notifier
has a helpful distTag support so we can take advantage of it to notify in multiple distribution types.