-
Notifications
You must be signed in to change notification settings - Fork 32
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
fix: exclude non-root README.md/LICENSE files #173
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This is for excluding non-root/nested readme and license files NOT top-level readme files, as those will always be included. Sorry if the title was a little misleading, that's my fault. I was just trying to match it up with the original issue's title. |
This comment was marked as resolved.
This comment was marked as resolved.
Does this also work for |
We only tested it with the package.json files array, as it's what we thought the issue was calling for. It likely does not work with .npmignore, as the function is being called inside another function that seems to deal with only package.json (processPackage) |
It looks like what we're doing is marking certain entries in Would it be possible for the new lines to be powered by a distinct set of values like Hope this makes sense. I think you're on the right track. |
that implies that the bug also doesn't exist with npmignore, which would be a good thing :-) |
Hi again, sorry for the late reply, got caught up with something else. Ok, I think I understand what you want us to do, and we'll be looking into it soon, just not sure about what you said here:
|
Line 43 in 21ed893
|
This comment was marked as outdated.
This comment was marked as outdated.
@wraithgar Just saw the comment you left via email but can't find it on GitHub for some reason. Do you want us to bring back the strings to rootOnly or keep it as is? |
@rahulio96 I deleted my suggestion as you'd already implemented it and it wasn't a very strong opinion. |
So far so good. I think it is potentially confusing having this work one way for While not a deal breaker, I think that this at least deserves clarification in the README so folks know that you can't "unignore" readme (etc) files, but you can explicitly include them in the |
Yeah I can get to work on updating the README description soon. |
Thanks! It'd be great to get this into npm 10 before it goes GA. We can make this a breaking change out of an abundance of caution and keep things tidy. |
Thank you both for your time, patience, and feedback, it was much appreciated! |
Could we maybe get this patch backported to the npm-packlist version that npm 9.x is using too? |
No this was considered a breaking change which is why it was held off till npm 10. |
Summary
Currently, package publishers are not able to exclude non-root readme and license/licence files when publishing or packing their packages, as they are always strictly included.
This solution allows users to exclude non-root readme and license/licence files by excluding them in the files array inside package.json.
Added a new function called excludeNonRoot, which removes readme, license, or licence from the strictDefaults array, and adds the inverse of the file to the defaults array. This allows the root files to remain, while non roots are ignored.
Additionally, if users would like to, they can also exclude readme, license, or licence files from specific folders, for example: "!lib/**/README.md"
However, if users do not want to use this behavior, they can simply not include !readme, !license, or !licence and the original behavior will be preserved, meaning that ALL of those files, root or non-root, will be included.
Tap Test
npm test
All results pass
Dummy Project
Installed the npm cli repository, and added our changes to the npm-packlist’s index.js under node_modules.
Installed stylelint repository to have a dummy project for testing.
Make changes to package.json
alias localnpm="node /workspaces/cli/"
localnpm pack --dry
See which files are included/excluded
References
cli issue - 6341