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

Expand create block options and add readme.txt template #20694

Merged
merged 12 commits into from
Mar 10, 2020

Conversation

pereirinha
Copy link
Member

@pereirinha pereirinha commented Mar 6, 2020

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 and License and prompt options when creating a new block.
The PR also adds readme.txt to both templates.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

type: 'input',
name: 'author',
message:
"The author name — this should be a list of wordpress.org userid's:",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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:",

Copy link
Member

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.

@gziolo gziolo added [Package] Create Block /packages/create-block [Type] Enhancement A suggestion for improvement. First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository labels Mar 9, 2020
Copy link
Member

@gziolo gziolo left a 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.

@gziolo gziolo requested a review from ntwb March 9, 2020 08:42
@pereirinha
Copy link
Member Author

Hi @gziolo,

Thanks for the quick turn around on this PR.
I took care of all the comments. Also, I was able to test the functionality with the npx. Thanks for the tip.

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.

@gziolo
Copy link
Member

gziolo commented Mar 9, 2020

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:
https://github.com/WordPress/gutenberg/blob/master/packages/create-block/lib/scaffold.js

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 @wordpress/scripts and runs all code formatting and building. I need to think about it a bit more. Feel free to explore and share your ideas. In general, there is a lot of code that could be isolated and covered with unit tests.

@gziolo
Copy link
Member

gziolo commented Mar 9, 2020

Thanks for the quick turn around on this PR.
I took care of all the comments. Also, I was able to test the functionality with the npx. Thanks for the tip.

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.

@pereirinha
Copy link
Member Author

@gziolo

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.

type: 'input',
name: 'author',
message:
"The author name — this should be a list of wordpress.org user id's:",
Copy link
Member

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.

Copy link
Member

@gziolo gziolo left a 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 :)

@gziolo gziolo merged commit f2028fa into WordPress:master Mar 10, 2020
@github-actions github-actions bot added this to the Gutenberg 7.8 milestone Mar 10, 2020
@gziolo
Copy link
Member

gziolo commented Mar 10, 2020

I opened #20756 with some further cleanup to make the generated code better aligned with the CLI prompts – it's mostly targeting optional values.

gziolo added a commit that referenced this pull request Mar 13, 2020
* 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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Create Block /packages/create-block [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create block: Add more options to control the plugin created
3 participants