Preview package files and validate against package.json
Closed this issue · 6 comments
Hello,
my most frequent problem in publishing, being an npm noob, is the absence of a file in dist/
when the project is being packaged. (often due to the subtle differences between npm
and yarn
...)
As a result all the checks are green, but once the published package is npm-installed a file is missing and everything explodes.
Have someone ever experienced the same?
Could this tool solve that issue, maybe by checking package.json files
fields and .npmignore
, and making sure all needed files exists?
Could it be a feature you're interested in?
Hi @caesarsol
Your issue looks interesting and familiar, but I haven't completely understood your pain point.
If your problem is that some of the files builded in /dist
are missing from your whitelist files
, you could simply add the whole folder to the whitelist as follows:
"files": [
"dist"
]
Would this fix that precise problem or not?
Yeah, that is the solution, but I realize it only after publishing a non-working version... 😄
Plus, there are small differences in .npmignore
and .yarnignore
that could give more problems.
Yeah, we are completely ignoring .yarnignore
in our validation and that is definitely a defect we should solve!
The problem with the rest is that I'm afraid it's impossible for a script to be 100% sure that every file you need is inside files
(or outside of .npmignore
) as first it would have to know which are the files you do need :)
We can consider adding an optional step to make a dry-run of npm publish
so to let the user review the soon-to-be-published package content before continuing.
What I was thinking is to run npm pack
and then list all the tar-packed files, for visual validation by the user.
Do you think it could be useful?
Yes, that sounds very useful, we should try with that approach first! 💯
👍 I'll take a look at the code in the next days!