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: added a fix for npmjs now returns readme in version instead of global… #654
Conversation
… metadata readme key
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.
The readmeDistTagsPriority
seems to optimistic asumming all packages follow such approach. That's the point I was thinking last time. Just see the react dist-tags
{ latest: '16.3.1',
next: '16.3.1',
dev: '15.5.0-rc.2',
canary: '16.4.0-alpha.0911da3' },
So, I'm not sure about it.
Also, we would need unit test for this.
I just checked the code. I'll test it later with real data. |
Hi @juanpicado As an example of dist-tags i've took a dist-tasg list from verdaccio package. |
It seems to be fix https://github.com/npm/registry/issues/305 |
src/lib/storage-utils.js
Outdated
const latestVersion = distTags['latest'] ? versions[distTags['latest']] || {} : {}; | ||
let readme = latestVersion.readme || pkg.readme || ''; | ||
// In case of empty readme - trying to get ANY readme in the following order: 'next','beta','alpha','test','dev','canary' | ||
const readmeDistTagsPriority = [ |
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.
If you catch here readme
you do not need to iterate.
let readme = latestVersion.readme || pkg.readme || '';
Logic should be like this
pkg.readme
exist, return.latestVersion.readme
exist return- Iterate and return
- No result, return emtpy string.
Please return readme whether is different than an empty string. I'd add || ''
only as las resource.
Try to avoid iterations if are not need it.
src/lib/storage-utils.js
Outdated
@@ -71,11 +71,34 @@ function cleanUpReadme(version: Version): Version { | |||
return version; | |||
} | |||
|
|||
function getLatestReadme(pkg: Package): string { |
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.
getLatestReadme
function requires a unit test in a new file. I suggest test/unit/latest.readme.spec.js
Hi @juanpicado . |
@aremishevsky I'll do it after work :) Thanks for your changes. Please read this #677 (comment) |
@juanpicado |
I just noticed. Just above your code, there is a function called So, the result is gonna be always So, I think
is a bit unecessary with the current approach, with local-storage we cannot afford save readme for each version otherwhise metadata will grow exponenxially, that's the main reason why is being removed. About your commit would be something like this `"feat: return latest dis-tag readme whether readme is emtpy" But you must remove the iteration, sorry I did not noticed that earlier. |
Some lint is failing
|
Hi @juanpicado I've re-created a PR with a new single commit with a normal message: #687 As for iteration and cleanUpReadme calling - If you take a look closer - I've moved readme set before calling cleanup function - so it should be fine and it is needed. As for lint errors - i've fixed them in new PR. Thanks for an advise. Thanks! |
Hi @juanpicado . Thanks |
@aremishevsky give me some days, I'm un a hurry to finish Google Cloud plugin (before expiring my trial) and next week is the We Are Developers at Vienna 😓 ... I'll try to do it as soon as possible. |
Thanks, done :) thanks for your patient I'll merge #687 and close this one. |
@juanpicado Thanks for review. |
Just after my dinner 🍽 😉 |
@juanpicado do you have any plans to get rid of "beta" versions? |
@aremishevsky beta is just a We have more than 370 test running+ 83% coverage + puppeteer. On I hope we finish all stuff before ends this month. In short, you can use it, it's safe. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
… metadata readme key
Type:
The following has been addressed in the PR:
Description: