Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upPlease give an error when files don't exist #6582
Comments
othiym23
added
feature-request
next-minor
labels
Oct 31, 2014
This comment has been minimized.
This comment has been minimized.
At the very least it should warn, but yeah, it would be best if it printed an error and stopped when a member of |
iarna
added
starter
patch-welcome
labels
Oct 31, 2014
This comment has been minimized.
This comment has been minimized.
I forgot if I saw any warning but it definitely published a broken version |
This comment has been minimized.
This comment has been minimized.
Silently ignores missing files. Added test set in PR #6618 , with repro steps. Tracked this through several modules, appears to be a problem in fstream-npm or node-tar.. possibly node-tar is not throwing/reporting an error when an expected file is missing. Looks like fstream-npm in readRules creates an inclusion rule as a sort of reverse ignore rule: ignore everything ('*') except for not-the-things-in-files. Apparently this fails for files that are missing. Will check in fstream-ignore. |
This comment has been minimized.
This comment has been minimized.
Those aren't files, those are patterns as far as I remember. If you specify |
This comment has been minimized.
This comment has been minimized.
Confirmed that the problem occurs when fstream-npm (and underlyingly fstream-ignore) receive an ignore list which specifies that e.g., See npm/fstream-ignore#9 for a test that shows this. (This PR is for illustration only) |
This comment has been minimized.
This comment has been minimized.
@rlidwka When they are patterns, this logic cannot be applied. But when they contain no wildcard characters and no file matches an entry in |
This comment has been minimized.
This comment has been minimized.
Thinking about this a bit more; @rlidwka 's point is that the files[] array is defined to be a list of patterns. There is no general-case way to decide whether an entry in However, it is possible to build the tarball before publishing by running |
This comment has been minimized.
This comment has been minimized.
@smikes sure |
This comment has been minimized.
This comment has been minimized.
I think it would be useful to warn or error if any of the individual entries in |
This comment has been minimized.
This comment has been minimized.
@othiym23 Sounds plausible. For now, I will write the external code that inspects a pack file and its package.json and checks for entries of Then if that turns out to be a good thing to include in npm, I can deed the snippet or package over to the npm organization. At present I am a bit overwhelmed by the number of places it would be possible to insert that check in npm-pack and its related/dependent modules. |
This comment has been minimized.
This comment has been minimized.
The problem is not in fstream-ignore, and since (as @rlidwka points out) the entries in |
This comment has been minimized.
This comment has been minimized.
Agreed. What I was trying to demonstrate (to my own satisfaction) was that the file list is arising much deeper than the call to
Impossible in the general case. Very possible in the way that @petkaantonov is (ab)using the This issue is actually a feature request: A. detect whether critical files are missing from the pack (and if so, B. don't let me shoot myself in the foot by publishing) . I propose to write an external utility to answer question A. Then I will test it against a sample of published modules to estimate the risk in turning this into a on-by-default feature. If nothing else I'll learn something about tar files. |
This comment has been minimized.
This comment has been minimized.
It's possible to know if no files matched a pattern, and I am not using any pattern anyway but directory and direct file references. |
This comment has been minimized.
This comment has been minimized.
I expected The difference is that when I execute |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Nice. This will read the "files" property from
I tested with missing |
This comment has been minimized.
This comment has been minimized.
By the way, I'm not saying I'm necessarily opposed to adding the "warn on unmatched globs in What if you have This would basically mean that we need to add another step in the package, or at least, keep track of what the needed files matches are, so that we can warn if any of them are not matched. |
es128
referenced this issue
Jan 21, 2015
Closed
`files` directory resolution inconsistent on prereleases #7184
othiym23
removed
next-minor
starter
labels
Jul 28, 2015
This comment has been minimized.
This comment has been minimized.
This has been moved to the npm roadmap, which we're using instead of the confusing |
othiym23
added
footgun
breaking
labels
Sep 22, 2016
othiym23
added
the
already-looked-at
label
Sep 22, 2016
This comment has been minimized.
This comment has been minimized.
Hey @petkaantonov! I had originally poked at a version of this change with #12191 (which was connected to #8791) during a Files and Ignores push we had earlier this year, but it got waylaid because it required some bigger changes to That said! The team talked it over today, and we agreed that this might be a good thing to have (done a bit differently than the original one -- most notably making it an error, as you requested here). This would make it a breaking change, but we don’t have a schedule for when we’re going to implement it right now. Most likely, what we’ll end up doing is add something at the end of So yeah! We’re gonna leave this open, since we do intend to get to it ourselves |
npm-robot
added
the
bot-closed
label
Jun 19, 2017
This comment has been minimized.
This comment has been minimized.
npm-robot
commented
Jun 19, 2017
We're closing this issue as it has gone thirty days without activity. In our experience if an issue has gone thirty days without any activity then it's unlikely to be addressed. In the case of bug reports, often the underlying issue will be addressed but finding related issues is quite difficult and often incomplete. If this was a bug report and it is still relevant then we encourage you to open it again as a new issue. If this was a feature request then you should feel free to open it again, or even better open a PR. For more information about our new issue aging policies and why we've instituted them please see our blog post. |
petkaantonov commentedOct 28, 2014
I have defined a
files
field in mypackage.json
and I don't think npm should publish a broken version when any of those files are missing.