yeoman / update-notifier

Update notifications for your CLI app
BSD 2-Clause "Simplified" License
1.76k stars 132 forks source link

Notify Option to show Changelog in default message. #213

Open karanshah-browserstack opened 3 years ago

karanshah-browserstack commented 3 years ago

Add a option to add ChangeLog message in default message. Example :

  ╭──────────────────────────────────╮
   │                                                                                                                                  │
   │                          Update available 0.9.2 → 1.2.0                                                     │
   │    Changelog: https://github.com/sindresorhus/public-ip/releases/tag/v1.2.0  │
   │                         Run npm i -g public-ip to update                                                  │
   │                                                                                                                                  │
   ╰──────────────────────────────────╯
macCesar commented 2 years ago

I also want to know how to add a link to the change log.

Like npm does it:

╭───────────────────────────────────────────────────────────────╮
   │                                                               │
   │      New major version of npm available! 6.14.15 → 8.3.0      │
   │   Changelog: https://github.com/npm/cli/releases/tag/v8.3.0   │
   │               Run npm install -g npm to update!               │
   │                                                               │
   ╰───────────────────────────────────────────────────────────────╯
equiman commented 2 years ago

It will be good to have it as a property, but actually you can do it using the custom message option:

https://github.com/yeoman/update-notifier#options-and-custom-message

astorije commented 2 years ago

If that's any useful, I am now using the following custom message based on this thread and https://github.com/yeoman/update-notifier/blob/main/update-notifier.js#L152-L156:

if (notifier.update) {
  notifier.notify({
    message: `New ${notifier.update.type} version available: ${chalk.dim(
      '{currentVersion}',
    )}${chalk.reset(' → ')}${
      notifier.update.type === 'major' ? chalk.red('{latestVersion}')
        : notifier.update.type === 'minor' ? chalk.yellow('{latestVersion}')
        : chalk.green('{latestVersion}')
    }\n` +
    `Run ${chalk.cyan('{updateCommand}')} to update\n` +
    '${chalk.dim.underline(`${packageJson.homepage ?? ''}/releases`)}`,
  });
}

Result:

Screen Shot 2022-08-25 at 6 45 43 PM

I would love for this to be the default! Or at the very least be able to append to the default template without having to re-specify it entirely!

LitoMore commented 2 years ago

@equiman Use https://github.com/sindresorhus/terminal-link