-
Notifications
You must be signed in to change notification settings - Fork 46
fix(#390): notify user of new cht-conf versions #730
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
Conversation
|
I see you have committed some changes to the Typically, if you are not making any changes to the If you did need any changes |
9f8f797 to
be74b09
Compare
|
"Thanks for the feedback! I've reverted the |
be74b09 to
0fd8520
Compare
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.
This is great @SinghCod3r! It works as expected! Forgive me, but I am going to make a couple more feature requests here (seems like as long as we are going to bring this feature back, we should make it as good as possible).
In the check-for-updates library code the nonFatal option is not really being used effectively (the outcome is almost identical either way). Essentially the nonFatal option just indicates if the check is being made by the run-by-default logic (in which case nonFatal = true) or if the user explicitly specified the check-for-updates action (in which case nonFatal = undefined). My goal is that when the user requests the check-for-updates action, it guarantees that the user is running the latest version or the command should fail.
The changes I think we should make here are:
- In the
catchblock, we can simplify the logic to always print a warning with the error message. Then, if the user actually requested thecheck-for-updatesaction (!options.nonFatal), we should throw the error. This will ensure that the cht command ends with a non-zero status code in this case. - Then we can split the current
thenblock. We should unpack the response data before thecatch. Then, after thecatchwe have anotherthenblock that can print the results to the console and throw an error if the user is not running the latest version AND the user requested thecheck-for-updatesaction.
Putting it all together, I think it would be something like this (have not tested this code 😅):
return request
.get('https://registry.npmjs.org/cht-conf')
.then(res => {
const json = JSON.parse(res);
return json['dist-tags'].latest;
})
.catch(err => {
warn(`Could not check NPM for updates: ${err.message}`);
if (!options.nonFatal) {
throw err;
}
})
.then(latest => {
if (latest !== current) {
warn(`New version available!
${current} -> ${latest}
To install:
npm install -g cht-conf
`);
if (!options.nonFatal) {
throw new Error('You are not running the latest version of cht-conf!');
}
} else if (!options.nonFatal) {
info('You are already on the latest version :¬)');
}
});And finally, the last thing would be to add unit tests, both for the check-for-updates lib code and the logic in the main block so that hopefully we can avoid regressing on this again in the future! 😬
9d8b741 to
92f358c
Compare
|
@jkuester Thanks for the feedback! I've updated the logic and added the help text as you requested. Please let me know what you think. |
|
@jkuester , I've added the unit tests as you requested. They are passing locally. Thanks! |
jkuester
left a comment
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.
The implementation code is looking good here! 👍 Added some comments around the unit tests.
src/cli/usage.js
Outdated
| Skips checking the version running is set to the same version in the package.json | ||
| --skip-version-check | ||
| Skip the automatic check for new cht-conf versions. |
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.
| Skip the automatic check for new cht-conf versions. | |
| Skips the automatic check for new cht-conf versions |
test/lib/check-for-updates.js
Outdated
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.
The name of this file should be check-for-updates.spec.js. (With the current name, this file is not getting run as part of the npm run test command.)
test/lib/check-for-updates.js
Outdated
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.
While it is fine to use AI when producing code for a contribution, this code needs to adhere to the same standards/conventions as the rest of the codebase.
For this file, please:
- Clean-up/remove comments (most of these seem completely unnecessary)
- Make sure we are following similar testing conventions as the other files. (e.g. the convert-forms.spec.js).
- Make sure the tests actually pass! 😅 These tests are not passing for me. (And CI will not run them because of the invalid file name.)
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.
@jkuester I've addressed all the feedback: the logic is updated, the help text is added, and the new unit tests are now passing locally. Please let me know if there's anything else!
Note - @jkuester, i have checked the test locally and it is perfect for my section of code. i request you to review the code as you got the time.
i also changed the code of check-for-updates.js file.
cc1d3ae to
3171d46
Compare
jkuester
left a comment
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.
Very nice! The only thing left is to fix a couple minor linting problems and add one more test. Then we can get this merged!
|
Thanks for checking in! Great job on getting E2E tests passing \o/ I'll see if @jkuester is free to review your changes, but in the meanwhile, can you ensure CI is passing? I see there's some lint failures that need fixing. |
e7161cf to
6fd7427
Compare
6fd7427 to
8a2bf89
Compare
|
@mrjones-plip Thanks for the heads up! I've run the linter and pushed the fixes. i want you to review this please and make it merged . just wanna be a contributor. |
jkuester
left a comment
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! Thanks @SinghCod3r for sticking with this!
|
🎉 This PR is included in version 5.2.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
2nd @jkuester's comment - thanks a bunch @SinghCod3r, great to see contributions like this get merged \o/ |
|
@jkuester , @medic-ci , @mrjones-plip , Thankyou all for guiding me to complete this. Thankyou all once again. |
Hi! This PR adds a feature to notify users when a new version of cht-conf is available.
This resolves issue #390.