Skip to content
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 command does not exclude files not included in files field #61171

Open
t-hamano opened this issue Apr 27, 2024 · 1 comment
Labels
[Package] Scripts /packages/scripts [Type] Bug An existing feature does not function as intended

Comments

@t-hamano
Copy link
Contributor

Description

Originally reported in this comment.

The plugin-zip command refers to the files field in package.json and allows you to include directories and files other than the default in the zip file:

@wordpress/scripts – Block Editor Handbook > plugin-zip

However, if this field is defined, it seems that both package.json and readme.txt are always included in the zip. This means that if you want to include non-default assets in the plugin-zip command, these two files will always be included. Especially when it comes to package.json, you often don't want to include it when you want to publish your plugin.

I tried defining package.json as below, but the result did not change.

{
	"name": "test-block",
	"scripts": {
		"plugin-zip": "wp-scripts plugin-zip"
	},
	"devDependencies": {
		"@wordpress/scripts": "^27.7.0"
	},
	"files": []
}
{
	"name": "test-block",
	"scripts": {
		"plugin-zip": "wp-scripts plugin-zip"
	},
	"devDependencies": {
		"@wordpress/scripts": "^27.7.0"
	},
	"files": [ "!package.json" ]
}
{
	"name": "test-block",
	"scripts": {
		"plugin-zip": "wp-scripts plugin-zip"
	},
	"devDependencies": {
		"@wordpress/scripts": "^27.7.0"
	},
	"files": [ "!readme.txt" ]
}

Log output:

npm run plugin-zip

> plugin-zip
> wp-scripts plugin-zip

Creating archive for `test-block` plugin... 🎁

Using the `files` field from `package.json` to detect files:

  Adding `package.json`.
  Adding `readme.txt`.

Done. `test-block.zip` is ready! 🎉

Step-by-step reproduction instructions

  • Run npx @wordpress/create-block test-block
  • cd test-block
  • Update the files field in package.json
  • Run npm run plugin-zip

Screenshots, screen recording, code snippet

No response

Environment info

No response

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

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Package] Scripts /packages/scripts labels Apr 27, 2024
@danielpost
Copy link

I just ran into the same issue, would be good to be able to ignore files in the root directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Scripts /packages/scripts [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants