-
Notifications
You must be signed in to change notification settings - Fork 35
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
[BUG] workspace root .gitignore
supersed every .npmignore
and .gitignore
#106
Comments
After checking 12c23ad a bit more in-depth, here are a few thoughts: 1. ignorefile combination orderCombining the Let's say I want to ignore all the This is what 2. Respect the
|
if an a nested to tweak your example to work as you'd expect:
this will cause the |
alternatively if you want the another option, and arguably the better one, would be to edit |
this is definitely a bug, you're right that the contents of edit: #108 fixes this |
Concerning the empty So yeah, in short, I did expect no ignore rules to be applied in my case.
Yes, I misread when taking only the root and the leaf. However, I reckon https://github.com/npm/npm-packlist/blob/main/lib/index.js#L40 So if you have let's say
Instead of
|
Left a comment on #108, I think you need to carry "the type of ignorefile to use" in the recursion as soon as you found it, otherwise, you'll end up mixing npmignore and gitignore (potentially). |
this would cause us to build a set of ignore rules that lists the root at the bottom, which is the reverse of what we want. as written, based on your example directory structure, we iterate
ignore rules are applied sequentially, starting with the root, this is how an ignore file in a subdirectory can re-include something that an ignore file at the root ignored, so we need the final rule list to include the contents of each file starting at the root and working deeper into the tree structure up to and including the parent of the workspace |
I reread the code, yes, my bad 😅 I misread how the path was constructed when reading the file |
no worries! it happens to all of us, and often! i really appreciate your attention to this and making sure we get it right, it's a huge help i'll follow up with another pull request that ensures we ignore a thanks again! |
Thanks a lot @nlf If I may bug you a bit more, I'm curious about #108 (comment). In short err, "why?" I personally think that if we have a What do you think? |
i can see why you would want it that way, and the answer as for why it is the way it is is the trickiest one to work around. it's the way it is because that's the way its always been, and changing it is definitely a breaking change and one that would take some care from our users to fix. the ignore behavior was initially built using only the if the concern were ignoring too many files, we would likely take the risk. the worst case there is an incomplete package gets published. the author can correct the problem, publish a new version, and deprecate the broken one and all is well. the concern with stopping the behavior of respecting a root because of this i think we're probably stuck where we are. if you feel passionate about it though, please feel free to open an RRFC issue at https://github.com/npm/rfcs and we can discuss it in our weekly openrfc call |
Wow, thanks for this comprehensive answer @nlf 😄 I'm not especially passionate about this issue, and, with this history, I do understand and would do take the same decision. Thanks a lot for taking the time to explain things are going this way, it was really enlightening. |
https://coveord.atlassian.net/browse/CDX-1010 <!-- For Coveo Employees only. Fill this section. CDX-1010 --> ## Proposed changes I discussed with a developer from the npm team here npm/npm-packlist#106 and got a good understanding of their philosophy moving forward with the concept of workspaces and their multi-level ignore files. In short, npm will try to acquire an ignorefile at each directory level and concatenate them. The peculiarity (at least IMO), is that if it acquire a npmignore first, this will have no incidence for the acquisition of the other ignorefile. So, we can end up with a mix of `gitignore` and `npmignore`. I discussed this behavior with the npm team, and they are kinda stuck, so its their least worst option here, so we just have to adapt and make it work. This is what this PR is about. ## Testing - Ran `npm publish --dry-run` on every package and checked them out. ## Prerequisites - [x] npm/npm-packlist#108 - [ ] `npm-cli` released with ☝️
Is there an existing issue for this?
Current Behavior
Given that I have a gitignore at the root level of my workspaces, it will supersed the
.gitignore
and the.npmignore
at the workspace level.This means that when I run
npm publish
at the level of a single package, it ends up using the root.gitignore
to filter out files.Expected Behavior
I would expect the 'ignore file resolution' order to be a such:
.npmignore
.gitignore
.npmignore
.gitignore
Steps To Reproduce
npm 8.11.0
npm publish --dry-run
while cwd ispackages/a
dist/test.js
is not included.Environment
The text was updated successfully, but these errors were encountered: