-
Notifications
You must be signed in to change notification settings - Fork 716
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
New: Notify users if the current version of sonar is not up to date #423
Conversation
4b5d93b
to
4066949
Compare
src/lib/cli.ts
Outdated
const changelogUrl: string = `https://sonarwhal.com/about/changelog.html`; | ||
// No indentation due to the use of `\` to avoid new line. | ||
// https://stackoverflow.com/a/35428171 | ||
const message: string = `Update available ${chalk.dim(update.current)}${chalk.reset(' → ')}${chalk.green(update.latest)}\nRun ${chalk.cyan(`npm i -g ${update.name}`)} to update\nSee ${chalk.red(changelogUrl)} for update details`; |
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.
sonar
may be installed as a (dev)dependence and run via a npm
script, so suggesting npm i -g
is not accurate in those cases.
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.
@alrra If we have a label in the code that indicates whether or not sonar is installed as a dependency, I can generate different messages based on different scenarios. Does such "label" exist? Otherwise I can include both npm i -g
and npm i -D
options in the message and ask the user to pick according to their own use.
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.
Otherwise I can include both npm i -g and npm i -D o
-P | --save-prod
is also possible.
Otherwise I can include both
npm i -g
andnpm i -D
options in the message and ask the user to pick according to their own use.
Not all users will know the differences, so if we do that we will need to also explain the differences between the options, and IMHO that is not the way to go.
My opinion is that the less we asked from the user the better.
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.
@alrra How about using detect-installed to see if sonar was installed globally first. If yes, then add the -g
flag in there?
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 would just say "please update" or similar. Don't think it is worth pulling another dependency just for that.
4066949
to
471d6b3
Compare
@@ -380,28 +380,24 @@ | |||
"version": "2.0.0", |
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.
These package-lock.json
changes fluctuate so much. :(
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.
@alrra Is there a good way to avoid fluctuation?
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.
@qzhou1607 I was just making a remark, nothing to do with this PR.
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.
These package-lock.json changes fluctuate so much. :(
From http://blog.npmjs.org/post/167963735925/v560-2017-11-27
bc263c3fd #19054 Fully cross-platform package-lock.json. Installing a failing optional dependency on one platform no longer removes it from the dependency tree, meaning that package-lock.json should now be generated consistently across platforms! 🎉
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.
Update your npm install now 🎉
471d6b3
to
2387c89
Compare
5b8221a
to
7f34d7e
Compare
tests/lib/cli.ts
Outdated
test.serial(`User shouldn't be notified if the current version is up to date`, async (t) => { | ||
let undefinedUpdate; | ||
|
||
t.context.notifier.update = undefinedUpdate; |
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 think you should do directly t.context.notifier.update = void 0
or t.context.notifier.update = null
instead of use a variable.
7f34d7e
to
f28740b
Compare
@sarvaje Done. |
src/lib/cli.ts
Outdated
@@ -61,6 +69,23 @@ const setUpUserFeedback = (sonarInstance: Sonar, spinner: IORA) => { | |||
}); | |||
}; | |||
|
|||
type Update = { // eslint-disable-line no-unused-vars |
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.
It's a bit weird to have this type here. Isn't there a type package for update-notifier
?
If not I think the type should be declared elsewhere. @sarvaje thoughts?
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.
It looks like there is a package @types/update-notifier
.
Anyway, I think that all types should go to the folder /types
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.
Then we should use that package instead of doing this. @qzhou1607 can you please add it as a dev dependency?
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.
f28740b
to
806a6cf
Compare
package.json
Outdated
@@ -12,6 +12,7 @@ | |||
}, | |||
"bin": "./dist/src/bin/sonar.js", | |||
"dependencies": { | |||
"@types/update-notifier": "^1.0.1", |
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 should be with the other types under dev dependencies.
src/lib/cli.ts
Outdated
// No indentation due to the use of `\` to avoid new line. | ||
// https://stackoverflow.com/a/35428171 | ||
const message: string = `Update available ${chalk.red(update.current)}${chalk.reset(' → ')}${chalk.green(update.latest)}\ | ||
\nPlease update to the newest version ${chalk.green(update.latest)}\nSee ${chalk.cyan(changelogUrl)} for details`; |
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.
Do we need both Update available...
and Please update to the newest version...
? To me they basically specify the same thing.
806a6cf
to
5aae5c4
Compare
@qzhou1607 or @alrra can you please take care of the conflicts? |
5aae5c4
to
4820c29
Compare
Fix #419
Currently the message looks as below: