-
Notifications
You must be signed in to change notification settings - Fork 402
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: reads versions from lock files #900
feat: reads versions from lock files #900
Conversation
I just realized as well the error message still references |
Regardless of #788, keeping the legacy functionality is a fallback for unrecognized lockfiles seems advantageous. As Kamil mentions in #788, This also means that if nobody were to add pnpm lockfiles, then |
actions/info.action.ts
Outdated
@@ -77,7 +86,7 @@ export class InfoAction extends AbstractAction { | |||
); | |||
} | |||
|
|||
async readProjectPackageJsonDependencies(): Promise<PackageJsonDependencies> { | |||
async readProjectLockDependencies(): Promise<PackageJsonDependencies> { |
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.
Insignificant, but I think this would be more clear as readProjectLockfileDependencies
.
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.
Probably, but I was also trying to keep the name from getting too long.
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 agree, perhaps it's worth including this as a comment? Just because, a "project lock" doesn't exactly refer to anything at all.
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 the fact that 3 lines later you see package-lock.json
or yarn.lock
makes the intention clear. Though I guess in a stack trace it could be somewhat problematic, though a comment wouldn't help that either
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.
What if you removed the word project
? It's probably the first assumption once you see "lockfile," although I suppose it doesn't have to be a project.
Thanks @jmcdo29! Can we fallback to |
It would probably be much simpler and less problematic to use Maybe |
That's the current functionality. If there's an error that happens while reading the lockfile, the
I'd have to look into the |
Hmm, not a bad idea actually. We'd need to keep a running list of all Nest package in the CLI repo. Or we could read the dependencies and devDependencies of the |
Just a note, it is theoretically better to use Ugly one liner: |
Reading from the appropriate lock files instead of the package.json means having a better idea of what packages are installed. With the package.json, there's a chance to miss the actual installed version due to using a range like ^7.0.0 whereas with the lock file, the version is printed to what the package manager resolved. To make this more easily achievable, I refactored the info.action.ts file to be more class based so I could reuse the package manager instead of having to re-find it each time. re: nestjs#896
bbf7fb5
to
2868d13
Compare
Now instead of reading `version` from the lock files and needing several lockfile parsers to work, the CLI can read `version` from each package's `package.json` after resolving the file path using `require.resolve`, as suggested by @andreialecu
2868d13
to
3bae6bb
Compare
Unfortunately had to force push due to some rebasing problems, but got the update done which uses |
@kamilmysliwiec Any way we can make this a part of the v8 push? Just to have better package version reporting by the |
LGTM 🙌 Apologies for the delay |
Reading from the appropriate lock files instead of the
package.json means having a better idea of what packages
are installed. With the package.json, there's a chance to
miss the actual installed version due to using a range
like ^7.0.0 whereas with the lock file, the version is
printed to what the package manager resolved.
To make this more easily achievable, I refactored the
info.action.ts file to be more class based so I could
reuse the package manager instead of having to re-find it
each time.
re: #896
PR Checklist
Please check if your PR fulfills the following requirements:
Tests didn't already exist, though I'm happy to try and write some up
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Currently we are reading the nest package versions from the
package.json
.Issue Number: #896
What is the new behavior?
After this PR we will read them from the appropriate lock file.
Does this PR introduce a breaking change?
Kind of depends on your definition of breaking. Though it should be noted that this PR doesn't support PNPM as we need to merge #788 for that. Because of this, PNPM users will lose access to
nest info
until that can be taken up, or we have the old functionality still in place (for pnpm and for not finding a lock file).Other information