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: added a fix for npmjs now returns readme in version instead of global… #654

Closed
wants to merge 8 commits into from

Conversation

aremishevsky
Copy link

… metadata readme key

Type:

The following has been addressed in the PR:

  • There is a related issue?
  • Unit or Functional tests are included in the PR

Description:

Copy link
Member

@juanpicado juanpicado left a 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.

@juanpicado
Copy link
Member

I just checked the code. I'll test it later with real data.

@juanpicado juanpicado added this to In progress in Roadmap Apr 12, 2018
@aremishevsky
Copy link
Author

Hi @juanpicado

As an example of dist-tags i've took a dist-tasg list from verdaccio package.
I've just added "next","dev" and "canary" tags in this list.
Please note it will take the readme of the first found tag's version readme.

@juanpicado
Copy link
Member

It seems to be fix https://github.com/npm/registry/issues/305

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 = [
Copy link
Member

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

  1. pkg.readme exist, return.
  2. latestVersion.readme exist return
  3. Iterate and return
  4. 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.

@@ -71,11 +71,34 @@ function cleanUpReadme(version: Version): Version {
return version;
}

function getLatestReadme(pkg: Package): string {
Copy link
Member

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

@aremishevsky
Copy link
Author

Hi @juanpicado .
I've added some minor changes according to your review.
Could you please take a look?

@juanpicado
Copy link
Member

juanpicado commented May 8, 2018

@aremishevsky I'll do it after work :) Thanks for your changes. Please read this #677 (comment)
Your stuff should be feat: xxx

@aremishevsky aremishevsky changed the title added a fix for npmjs now returns readme in version instead of global… feat: added a fix for npmjs now returns readme in version instead of global… May 8, 2018
@aremishevsky
Copy link
Author

@juanpicado
I've changed the last commit.
However I can't change previous commits using rebase command. Not sure that I will not revert some of your changes.
If it's critical to have all commits with "feat: xxx" in messages - i can re-commit my changes in a new forked repo. If not - you can just merge it.
Just let me know

@juanpicado
Copy link
Member

screen shot 2018-05-08 at 11 31 08 pm

@juanpicado
Copy link
Member

I just noticed. Just above your code, there is a function called cleanUpReadme https://github.com/verdaccio/verdaccio/blob/master/src/lib/storage-utils.js#L66 which remove all readme from versions.

So, the result is gonna be always undefined.

screen shot 2018-05-08 at 11 31 08 pm

So, I think

// In case of empty readme - trying to get ANY readme in the following order: 'next','beta','alpha','test','dev','canary'
  const readmeDistTagsPriority = [
    'next',
    'beta',
    'alpha',
    'test',
    'dev',
    'canary'];
  readmeDistTagsPriority.map(function(tag) {
    if(readme) {
      return readme;
    }
    const data = distTags[tag] ? versions[distTags[tag]] || {} : {};
    readme = _.trim(data.readme || readme);
  });

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.

@juanpicado
Copy link
Member

Some lint is failing

/home/ubuntu/verdaccio/src/lib/storage-utils.js
  80:3  error  Expected space(s) after "if"  keyword-spacing
  92:5  error  Expected space(s) after "if"  keyword-spacing

@aremishevsky
Copy link
Author

aremishevsky commented May 10, 2018

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.

feat__added_a_fix_for_npmjs_now_returns_readme_in_version_instead_of_global by_aremishevsky pull_request__654 _verdaccio_verdaccio

As for lint errors - i've fixed them in new PR. Thanks for an advise.
Please review this PR: #687 after that please close this PR.

Thanks!

@aremishevsky
Copy link
Author

Hi @juanpicado .
Did you have a chance to take a look on #687 PR?

Thanks

@juanpicado
Copy link
Member

@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.

@juanpicado
Copy link
Member

Thanks, done :) thanks for your patient I'll merge #687 and close this one.

@juanpicado juanpicado closed this May 14, 2018
Roadmap automation moved this from In progress to Done May 14, 2018
@aremishevsky
Copy link
Author

@juanpicado Thanks for review.
Could you please let me know once it would be published with a some next release version on npmjs?

@juanpicado
Copy link
Member

Just after my dinner 🍽 😉

@juanpicado
Copy link
Member

@aremishevsky
Copy link
Author

@juanpicado do you have any plans to get rid of "beta" versions?
Maybe we should use some v3.0.0 version as well.

@juanpicado
Copy link
Member

juanpicado commented May 15, 2018

@aremishevsky beta is just a ⚠️ to encourage people to be careful, but, to be honest, is 100% stable and nothing big will change.

We have more than 370 test running+ 83% coverage + puppeteer. On 2.x not even half of it. Nothing will change in the next beta anyway. I want to finish first Google Cloud #473 and S3 #472 plugins to ensure the new Store API is 100% stable.

I hope we finish all stuff before ends this month. In short, you can use it, it's safe.

@lock
Copy link

lock bot commented Nov 11, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Roadmap
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants