-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Scripts: Add plugin-zip command to create a zip file for a WordPress plugin
#37687
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
Conversation
|
Size Change: 0 B Total Size: 1.13 MB ℹ️ View Unchanged
|
a50a8b4 to
ffc6478
Compare
ffc6478 to
3d45a3b
Compare
ryanwelcher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really great @gziolo! I just left a comment on how the files entry is managed. It's not a blocker to merging but may be a nice addition.
| const zip = new AdmZip(); | ||
|
|
||
| let files = []; | ||
| if ( hasPackageProp( 'files' ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an idea here, but could we have the files entry merge with the existing defaults? This would make it much easier to add a new directory/file without needing to also provide all of the defaults.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to check our existing configs but I remember one of the tools exposing … shortcut that brings all the default settings if you want to extend them. This should do the trick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that exists already? That would be great to add to the docs in the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not here, but it would be simple to replicate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an idea here, but could we have the files entry merge with the existing defaults? This would make it much easier to add a new directory/file without needing to also provide all of the defaults.
Let's keep it as is for now. It's a bit tricky to handle with files because it is used also when publishing to npm. The good news is that when you set files then you don't need to list files like readme, changelog, or license because they are always included. I figured out that we can't add any custom items in files because it would break npm publish if someone is using it.
Description
Fixes #19237.
This PR adds a new
plugin-zipcommand to create a zip file for a WordPress plugin in@wordpress/scripts. By default, the command uses best practices for file organization documented in Plugin Handbook.Usage:
Recommended changes in
package.json:{ "scripts": { "plugin-zip": "wp-scripts plugin-zip" } }Executing from CLI:
Advanced information
In the case where the plugin author wants to customize the files included in the zip file, they can provide the
filesfield in thepackage.jsonfile as documented in https://www.npmjs.com/package/npm-packlist, example:{ "files": [ "dir" ] }It reuses the same logic as
npm packcommand to create an npm package tarball.How has this been tested?
I executed
./bin/test-create-block.shto ensure that the new command runs correctly and lists all necessary files:The same command is executed on CI.
I also executed some of the steps manually to test uploading the created zip file with WordPress:
npx wp-create-block esnext-test --no-wp-scripts cd esnext-test ../node_modules/.bin/wp-scripts build ../node_modules/.bin/wp-scripts plugin-zipSteps necessary to activate the plugin from the zip file:
Add New.Upload Plugin.esnext-test.zipfile and clicked theInstall Nowbutton.Activate Pluginbutton.Screenshots
Screen.Recording.2022-01-03.at.13.55.01.mov
Types of changes
New feature (non-breaking change which adds functionality).
Checklist:
*.native.jsfiles for terms that need renaming or removal).