-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
As a new developer using wp-scripts, I expect the zip package generated by plugin-zip to be compatible with plugin updates. #60481
Labels
Comments
nicolasgalvez
added a commit
to nicolasgalvez/gutenberg
that referenced
this issue
May 3, 2024
nicolasgalvez
added a commit
to nicolasgalvez/gutenberg
that referenced
this issue
May 3, 2024
nicolasgalvez
added a commit
to nicolasgalvez/gutenberg
that referenced
this issue
Oct 26, 2024
Require an argument for root-folder. Add option no-root-folder to zip files without a root folder for backwards compatibility. Update documentation, and changelog. (WordPress#60481)
gziolo
added a commit
that referenced
this issue
Oct 29, 2024
#61375) * Scripts: Add a --zip-root-folder argument to the plugin-zip command (#60481) * Scripts: Change the plugin-zip command to add a folder in the plugin zip file by default 1. The plugin-zip command will now create a root folder in the zip file matching the name of the plugin. This aligns with the documentation stating that "By default, it uses Plugin Handbook best practices to discover files." 2. `--zip-root-folder` argument from my previous commit is now named `--root-folder` 3. The --root-folder argument will allow specifying a custom folder, or no folder for backwards compatibility. Example usage: {{{ npm run plugin-zip --root-folder='foo' }}} Follow-up to [61375], [60481]. Props justlevine, gziolo. * Add CHANGELOG entry * Update CHANGELOG.md * Scripts: Modify plugin-zip to add no-root-folder and root-folder options Require an argument for root-folder. Add option no-root-folder to zip files without a root folder for backwards compatibility. Update documentation, and changelog. (#60481) * Scripts: adjust message for plugin-zip command Apply suggestions from code review. props: @gziolo Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl> * Update packages/scripts/README.md Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com> --------- Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl> Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Co-authored-by: nicolasgalvez <nickgalvez@git.wordpress.org> Co-authored-by: gziolo <gziolo@git.wordpress.org> Co-authored-by: justlevine <justlevine@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
karthick-murugan
pushed a commit
to karthick-murugan/gutenberg
that referenced
this issue
Nov 13, 2024
WordPress#61375) * Scripts: Add a --zip-root-folder argument to the plugin-zip command (WordPress#60481) * Scripts: Change the plugin-zip command to add a folder in the plugin zip file by default 1. The plugin-zip command will now create a root folder in the zip file matching the name of the plugin. This aligns with the documentation stating that "By default, it uses Plugin Handbook best practices to discover files." 2. `--zip-root-folder` argument from my previous commit is now named `--root-folder` 3. The --root-folder argument will allow specifying a custom folder, or no folder for backwards compatibility. Example usage: {{{ npm run plugin-zip --root-folder='foo' }}} Follow-up to [61375], [60481]. Props justlevine, gziolo. * Add CHANGELOG entry * Update CHANGELOG.md * Scripts: Modify plugin-zip to add no-root-folder and root-folder options Require an argument for root-folder. Add option no-root-folder to zip files without a root folder for backwards compatibility. Update documentation, and changelog. (WordPress#60481) * Scripts: adjust message for plugin-zip command Apply suggestions from code review. props: @gziolo Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl> * Update packages/scripts/README.md Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com> --------- Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl> Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Co-authored-by: nicolasgalvez <nickgalvez@git.wordpress.org> Co-authored-by: gziolo <gziolo@git.wordpress.org> Co-authored-by: justlevine <justlevine@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
What problem does this address?
I am confused about the differences between the plugin-zip command and the zip requirements for plugin updates.
Issue
As a new developer using wp-scripts, I expect the zip package generated by
plugin-zip
to be compatible with plugin updates.Actual behavior
Details
I expect the zip package to have the tree specified in the best practices for plugin development page.
I made a plugin called
example-plugin
using wp-scripts. I then used theplugin-zip
command to generate a zip file and uploaded it to my site using the admin backend as usual. It worked as expected.However, when I tried to update my plugin after checking in a new version, it failed because the zip file did not have a directory named
example-plugin
.When I examined the zip file, I noticed the tree was like this:
I looked to see if there was an option to pass to
plugin-zip
to alter the behavior but didn't find one in the documentation. I looked at the source code on github but didn't see any way to do this.As a workaround, in my plugin's github action, I unzip the package after running plugin-zip (to take advantage of the file filtering from package.json), create a directory, move the files, and then zip again.
Here's the relevant part of my action for reference:
Now the plugin will update when I update it from the admin/plugin page.
Note that I am using
yahnis-elsts/plugin-update-checker
which I have used before. But I also tried this by writing an update checker manually and am not confident that I did it right because it made a bunch of directories in the plugins directory likeexample-plugin-1
.What is your proposed solution?
Ideally there is already a way to do this that I don't know about. In that case, I would update the documentation to show how to specify a root directory in the zip package.
Otherwise, I would suggest adding a flag to
plugin-zip
to allow this behavior such asplugin-directory=name
. where the name is optional, and the directory name might be pulled from the last portion of the name in the package.json file:"name": "my-namespace/example-plugin",
Or, maybe
yahnis-elsts/plugin-update-checker
is no longer the correct tool to update plugins. Perhaps there could be a link to an example plugin with the update code.I'm happy to take a stab at doing this, since I want to get involved with core development. Thanks everyone!
The text was updated successfully, but these errors were encountered: