-
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
Expand create block options and add readme.txt template #20694
Expand create block options and add readme.txt template #20694
Conversation
packages/create-block/lib/prompts.js
Outdated
type: 'input', | ||
name: 'author', | ||
message: | ||
"The author name — this should be a list of wordpress.org userid's:", |
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.
"The author name — this should be a list of wordpress.org userid's:", | |
"The author name — this should be a list of wordpress.org user ids:", |
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 don't see it updated.
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.
Nice work @pereirinha, thank you for opening this PR. I left a few minor comments to check.
Testing is a bit tricky for this package because it is usually executed from npm. However, there is a way to run this script from Gutenberg:
npx wp-create-block
for ESNext
npx wp-create-block --template es5
for ES5
I think we should add some tests but the issue is that at least for ESNext the process depends on npm so you can't execute it while being offline and when online it takes 1-2 minutes. I need to think about it, maybe we could test only scaffolding bits with unit tests.
Hi @gziolo, Thanks for the quick turn around on this PR. About tests for this package, which bits would you like to see covered? Do you have any example that you can point me out? I'll be happy to open a new PR for that. |
I was thinking about the method that scaffolds block: When I look at this file, it makes me wonder whether it could be generalized in a way where you could pass the full template config as param rather than a string. This way we could disable the part that inits |
Awesome work, I scanned all changes and ti looks great. I will test it myself later. I have one more idea for improvement, I will leave a comment inline. |
That one also left me undecided. I agree that the prompt should be asking for the short description for the block. The PR is ready for you to circle back. |
packages/create-block/lib/prompts.js
Outdated
type: 'input', | ||
name: 'author', | ||
message: | ||
"The author name — this should be a list of wordpress.org user id's:", |
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 see it differs a bit between npm and WordPress.org:
https://docs.npmjs.com/files/package.json#people-fields-author-contributors
In Gutenberg I can see the following list:
Contributors: matveb, joen, karmatosed
We can handle it as a follow-up.
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.
Awesome work @pereirinha. I applied a few small changes to the user-facing messaging to better align with other prompts.
I also fixed the copy/paste issue in the version prompt where the author was used :)
I opened #20756 with some further cleanup to make the generated code better aligned with the CLI prompts – it's mostly targeting optional values. |
* Add Author, License and Version prompt options * Add readme.txt template * Fix typo * Add License URI option * Do not filter, just assume the default value * Update default values * Use version option in documentation * Update the default description field to add details on limits * Update readme description * Remove extra spaces * Update packages/create-block/lib/prompts.js * Apply suggestions from code review Co-authored-by: Grzegorz (Greg) Ziółkowski <grzegorz@gziolo.pl>
Description
This PR closes #20263
How has this been tested?
@gziolo I could use your guidance to test this, as I wasn't able to do it yet.
Types of changes
The PR introduces
Author
,Version
andLicense
and prompt options when creating a new block.The PR also adds
readme.txt
to both templates.Checklist: