-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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: npm repo
support repository.directory
field
#163
feat: npm repo
support repository.directory
field
#163
Conversation
I think this change should test the following cases:
But sadly I didn't know how to test these cases. 😢 Line 2 in 86f5bdb
I hope someone would help me about testing... 🙏 |
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.
お願いいたします
Here's an example of how to mock a packument request: https://github.com/npm/cli/blob/release-next/test/tap/aliases.js#L29-L54 You don't need to bother with mocking the tarball. |
t.comment(stderr) | ||
|
||
const res = fs.readFileSync(outFile, 'ascii') | ||
t.equal(res, 'https://github.com/foo/test-repo-with-directory/tree/master/some%2Fdirectory\n') |
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 expected .../some/directory
, not .../some%2Fdirectory
. 🤔
But I find this is a problem of hosted-git-info
package.
So, I will open a new PR on npm/hosted-git-info. 💪
The relevant code is here:
https://github.com/npm/hosted-git-info/blob/067fd7f3559fc051fd56528f6231a70ec4e634d0/git-host.js#L38-L40
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.
This has been fixed! So this test will actually fail now. We'll fix this up when landing this PR! :D
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.
@mikemimik Thanks for your response. I have not touched this PR for a long time, but can I start again?
If you have any advice, I would be glad to accept!
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.
It's not necessary to start again. The @npm/cli-team triaged this pull-request today and we're accepting it into 6.14.0
. We can fix up the test when we pull it into the release, it's no worries :)
You noted that hosted-git-info
does some weird url-encoding, and you had to use "%2f
". Since then hosted-git-info
has had some changes and it's fixed. It now returns properly. The change to the test is just changing %2f
back to /
:D
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 understand it. I'm looking forward to a new release 😊
I added a test case and CI passed! NotesI thought test cases for possible Git hostings were necessary (not only GitHub). |
@zkat I added the tests, so is there something I should do to review this PR? |
See #140 PR-URL: #163 Credit: @ybiquitous Close: #163 Reviewed-by: @mikemimik
This is the standard configuration value for deep-linking into a package's directory within a monorepo. npm RFC: https://github.com/npm/rfcs/blob/latest/implemented/0010-monorepo-subdirectory-declaration.md This will ensure the packages' pages on npmjs.org will link to the correct directory. Also, _eventually_, it will ensure the `npm repo` command opens to the correct location: npm/cli#163 Lastly, this is _required_ for monorepo packages to be successfully published to the GitHub Package Registry (if that is ever considered in the future). https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-npm-for-use-with-github-packages#publishing-multiple-packages-to-the-same-repository
Summary: Configure each package's package.json#repository.directory property to properly reflect the location of the package within the repository. This is the standard configuration value for deep-linking into a package's directory within a monorepo. npm RFC: https://github.com/npm/rfcs/blob/latest/implemented/0010-monorepo-subdirectory-declaration.md This will ensure the packages' pages on npmjs.org will link to the correct directory. Also, _eventually_, it will ensure the npm repo command opens to the correct location: npm/cli#163 Lastly, this is _required_ for monorepo packages to be successfully published to the GitHub Package Registry (if that is ever considered in the future). https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-npm-for-use-with-github-packages#publishing-multiple-packages-to-the-same-repository
Related: #140 PR-URL: #163 Credit: @ybiquitous Close: #163 Reviewd-By: @isaacs
This will be in the v7 beta. Thanks! |
Summary
This PR makes
npm repo
possible to open a given repository's full URL instead of its root URL with the newrepository.directory
field.For example,
npm repo react-dom
opens https://github.com/facebook/react/tree/master/packages/react-dom.Background
npm@6.8.0 shipped the new feature to support
repository.field
inpackage.json
.For example:
See also #140