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
Scripts: plugin-zip
does not include root-level files
#40528
Comments
I confirm this issue. How to reproduce :
We can see than root files are in a |
ran into this a few minutes ago as well; can confirm the above that it lists all of the files as being added but they are not; great, detailed report @admturner |
Hi 👋, thank you for reporting this issue. I'm able to reproduce the error. I tried in my local and found a solution for the mentioned issue. In our {
"files": [ "*" ]
} I believe the issue with the package I'm sharing a screencast for reference. Screen.Recording.2022-05-14.at.1.13.23.AM.movWe can close this issue. Let me know what do you think? |
Thanks, @amustaque97! I tried adding Unless I'm missing something and this is the expected behavior, then it looks like the issue might be with the implementation of
with:
then when I run
By omitting the second argument from |
if ( '.' !== dirname( file ) ) {
zip.addLocalFile( file, dirname( file ) );
} else {
zip.addLocalFile( file );
} It looks like a simple fix to apply. Is anyone willing to open a PR? |
Hi @admturner , I'm really sorry but I'm not able to reproduce the same issue. Neither I'm able to create a directory whose name is Since your machine is windows I actually tried to reproduce the same issue in Github pipeline with windows environment. No luck so far. Here is the link of the PR I created #41288 Here is the link of the Github pipeline output: https://github.com/WordPress/gutenberg/runs/6580805114?check_suite_focus=true#step:4:200 Here are a few screenshot of the error I get: At last, I would request you to share zip file via some link or screencast so that I can also see and understand what's really going on. cc @seebz @skorasaurus |
I'm happy to provide a screencast; I'll do that as soon as I get a chance. To clarify my environment as well, while I'm on Windows I work in WSL2 using Ubuntu. |
Here is the archive I just build on Xubuntu : gutenpride.zip $ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal
$ node --version
v16.15.0
$ npm --version
8.5.5 |
It looks like the issue is isolated to some specific platform setup. The offending line would be:
When the issue happens then https://github.com/cthackers/adm-zip/blob/bebbabf600a6ae5d64ee31cbc89a1274bd1d8c1f/adm-zip.js#L244 zipPath = zipPath ? fixPath(zipPath) : ""; function fixPath(zipPath) {
const { join, normalize, sep } = pth.posix;
// convert windows file separators and normalize
return join(".", normalize(sep + zipPath.split("\\").join(sep) + sep));
} Now, based on the reports I can see that people have the following files listed:
As far as I can tell from debugging Either one of the proposed fixes from this issue should resolve it or: const zipDirectory = dirname( file );
zip.addLocalFile( file, zipDirectory !== '.' ? zipDirectory : '' ); I can confirm it works the same way on macOs as before. |
Kudos to you for doing in depth investigation. Only reason why I wanted to double check is to understand testing instructions and changes verification. Let’s fix it on our end and make sure nothing breaks. I will submit a PR in sometime. Thanks once again @gziolo 😃😃 |
I have just landed #41439 from @amustaque97. We should have the regular npm publishing happening today (or maybe later this week due to WordCamp EU). I hope this change resolve the issue for everyone 😄 |
Description
When I run the command
wp-scripts plugin-zip
the resulting zip file does not include root-level files, only directories (and their containing files). I expect the resulting zip file to include either the defaults (the entrypoint, Readme, etc.) as described in the documentation, or the files specified in the package.json"files": []
list. Instead the zip file contains only thebuild/
directory files (or other directories specified in package.json) and none of the root-level files.Step-by-step reproduction instructions
src/
directory, an entrypoint, and some other root-level files such as README and CHANGELOG.@wordpress/scripts
package.wp-scripts build
to generate thebuild/
directory.wp-scripts plugin-zip
.Screenshots, screen recording, code snippet
With a test plugin with the directory structure:
Running
wp-scripts plugin-zip
generates a zip file with only:I would expect it to generate:
The terminal output suggests everything worked:
But those root-level files aren't actually included it the zip file.
However, if I edit the
plugin-zip.js
file in mynode_modules
and replace:zip.addLocalFile( file, dirname( file ) );
with:
Then it works as expected. Maybe the problem is that
zip.addLocalFile
is failing silently when it doesn't recognize'.'
as valid.Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: