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

feat: add warning message for the info command #2396

Merged
merged 3 commits into from
Jan 8, 2024

Conversation

GreGosPhaTos
Copy link
Contributor

@GreGosPhaTos GreGosPhaTos commented Nov 22, 2023

More details here: #1929

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

There is no warnin message if deveopers use different version of the nest-js package in a projet

Issue Number: #1929

What is the new behavior?

Developer now gets a warning message folowing the suggestion => #1929

Capture d’écran, le 2023-11-22 à 09 38 28

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

): NestDependencyWarnings {
const unsortedWarnings: NestDependencyWarnings = nestDependencies.reduce<NestDependencyWarnings>(
(acc, { name, fullName, value }) => {
const [major, minor] = value.split('.').map(parseFloat);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assumed that the format of the version (value) is always {number}.{number}.{number}

Copy link
Member

Choose a reason for hiding this comment

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

we might need to add some error handling here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this which filter non-digits chars out of the string.
I also added more test cases.
The main "risk" would be in the sort callback, and I added some guards as well see => https://github.com/nestjs/nest-cli/pull/2396/files#diff-088f2456e09a57e3cc418bccd4ab7a7d3968fb4fe3cd8e24a358f76ba6ad1473R177-R190

Eventually I can throw an error and catch it in the displayWarningMessage method to display a generic error message, but I think I covered all the cases with the last changes. What's you toughts @kamilmysliwiec ?

Copy link
Member

Choose a reason for hiding this comment

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

Eventually I can throw an error and catch it in the displayWarningMessage method to display a generic error message, but I think I covered all the cases with the last changes. What's you toughts @kamilmysliwiec ?

We could add it just in case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done => d29182f

@micalevisk
Copy link
Member

micalevisk commented Nov 22, 2023

note that this rule doesn't apply to all packages under @nestjs/*. For example, the latest version of @nestjs/swagger is v7, not v10.

thus we need a whitelist of those that will be checked against. I think you can start with this:

  • @nestjs/core
  • @nestjs/common
  • @nestjs/schematics
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/websockets

I'm not sure about the others. I guess Kamil should tell us that

@GreGosPhaTos
Copy link
Contributor Author

@@ -21,6 +21,11 @@ interface PackageJsonDependencies {
interface NestDependency {
name: string;
value: string;
fullName: string;
Copy link
Member

Choose a reason for hiding this comment

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

can we rename fullName to packageName?

also, do npm run format

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

  Added few changes after the review
  More details here: nestjs#1929
  Added few changes after the review
  More details here: nestjs#1929
@GreGosPhaTos
Copy link
Contributor Author

Just wondering is this PR needs some changes ? Otherwise should it be merged soon ?

@micalevisk @kamilmysliwiec

@micalevisk
Copy link
Member

Looks fine to me so far

I guess it will be merged after Kamil get some time to review this too, don't worry.

@micalevisk
Copy link
Member

@GreGosPhaTos btw could you please open a PR at https://github.com/nestjs/docs.nestjs.com to document this new behavior of the info command? I guess new subsection under https://docs.nestjs.com/cli/usages#nest-info would be good

@GreGosPhaTos
Copy link
Contributor Author

@GreGosPhaTos btw could you please open a PR at https://github.com/nestjs/docs.nestjs.com to document this new behavior of the info command? I guess new subsection under https://docs.nestjs.com/cli/usages#nest-info would be good

@micalevisk Yes ok => here it is nestjs/docs.nestjs.com#2923

@kamilmysliwiec kamilmysliwiec merged commit 4dd9447 into nestjs:master Jan 8, 2024
1 check passed
@kamilmysliwiec
Copy link
Member

LGTM

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.

None yet

4 participants