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

New: Notify users if the current version of sonar is not up to date #423

Closed

Conversation

qzhou1607-zz
Copy link
Contributor

@qzhou1607-zz qzhou1607-zz commented Aug 14, 2017

Fix #419

Currently the message looks as below:

new-version-notification

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

@alrra alrra Aug 14, 2017

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@alrra alrra Aug 14, 2017

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 and npm 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.

Copy link
Contributor Author

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?

Copy link
Member

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.

@@ -380,28 +380,24 @@
"version": "2.0.0",
Copy link
Contributor

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. :(

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor

@alrra alrra Nov 29, 2017

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! 🎉

Copy link
Member

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 🎉

@qzhou1607-zz
Copy link
Contributor Author

@molant @alrra The message is changed as shown below:

update available

@qzhou1607-zz qzhou1607-zz force-pushed the notify_new_version branch 3 times, most recently from 5b8221a to 7f34d7e Compare August 15, 2017 17:29
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;
Copy link
Contributor

@sarvaje sarvaje Aug 16, 2017

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.

@qzhou1607-zz
Copy link
Contributor Author

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

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?

Copy link
Contributor

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

Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

package.json Outdated
@@ -12,6 +12,7 @@
},
"bin": "./dist/src/bin/sonar.js",
"dependencies": {
"@types/update-notifier": "^1.0.1",
Copy link
Member

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

@alrra alrra Aug 17, 2017

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.

@molant
Copy link
Member

molant commented Aug 18, 2017

@qzhou1607 or @alrra can you please take care of the conflicts?

@qzhou1607-zz
Copy link
Contributor Author

@molant @alrra Done.

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.

4 participants