-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
WIP: Create WP Plugin #10628
WIP: Create WP Plugin #10628
Conversation
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.
Really cool PR, this has big potential 🔥
Found just a few small typos
* @package {{pluginSlug}} | ||
*/ | ||
|
||
/** |
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.
Delete blank before slash
@Soean thank you will sync some of the changes to |
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.
Can we start by exposing as much as possible from @wordpress/scripts
before we get to templating? It feels like we can limit this PR to adding the code which handles scaffolding. That would be awesome :)
/** | ||
* Check node version | ||
*/ | ||
if ( major < 8 ) { |
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 sure if that would fit here, but we exposed new script which allows to verify the minimum version of node an npm which WordPress enforces for development:
https://github.com/WordPress/gutenberg/tree/master/packages/scripts#check-engines
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.
have been following the scripts would be good to reuse check-engines
here
@@ -0,0 +1,16 @@ | |||
version: "3.1" |
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 would see it inside wp-scripts
with the corresponding scripts which helps to spin up a WordPress instance whit your plugin enabled.
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.
scripts/configs/templates all would go to wp-scripts
"devDependencies": { | ||
"@babel/core": "^7.1.0", | ||
"@wordpress/babel-preset-default": "^2.1.0", | ||
"parcel-bundler": "^1.10.1" |
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.
Let's bring Parcel to wp-scripts
, too :)
See my PR opened a few days ago: #12837.
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.
seems liked missed the PR seems good fit here
@@ -0,0 +1,16 @@ | |||
const { registerBlockType } = wp.blocks; |
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.
How about using this template:
https://github.com/wp-cli/scaffold-command/blob/master/templates/block-index-js.mustache from WP-CLI?
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.
Yes we can use this it contains inline documentations also
@@ -0,0 +1,45 @@ | |||
<?php |
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 also authored this template:
https://github.com/wp-cli/scaffold-command/blob/master/templates/block-php.mustache
There are also 2 CSS templates available.
@@ -0,0 +1,16 @@ | |||
const { registerBlockType } = wp.blocks; |
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.
By the way, WP-CLI adds .mustache
extension to the template files.
# Generate the plugin zip file | ||
status "Creating archive..." | ||
zip -r {{pluginSlug}}.zip \ | ||
{{pluginSlug}}.php \ |
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'm wondering how CSS and other assets are handled by Parcel to ensure they are included in the dist
folder.
will soon resume work on this and get initial scaffolding ready utilizing |
The I like the idea of having a scafolding command, this would be a great addition for onboarding new people to Gutenberg. What do you think @ajitbohra ? |
I think I feel scaffolding is something you do once, and the scripts commands are something you use daily in your package, making it a clear separation of concerns. @nosolosw What are the reasons that makes you prefer a command instead of a separate package? |
@youknowriad those are good thoughts I hadn't considered deeply 👍 |
Yes, those are great reasons to put it in its own package. For reference, this is how it looks with $ npm init react-app ./my-react-ap https://docs.npmjs.com/cli/init#examples By the way, it might be very convenient to have this offering once |
@ajitbohra this PR is now a bit out of date. Do you plan to revisit it and help us land a very first iteration of the scaffolding tool based on the feedback provided? An alternative approach would be to close this PR and let other contributors work on it based on your initial exploration. |
@youknowriad @noisysocks +1 for keeping it as separate package @gziolo resuming work on this PR to address the feedback and suggestions |
It's great to see you back. Feel free to remove |
There is this great work from @youknowriad which uses some related tooling to automate Gutenberg releases in #15699. It would be great to align as much as possible. |
Hey @ajitbohra |
I have this npm package up and running which sort of duplicates the functionality proposed in this PR: https://www.npmjs.com/package/create-wordpress-block I plan to open PR against Gutenberg after some testing with the community. Should we close this PR? |
This has been labeled Stale since April. Thanks for the efforts, but I'll close this for now. |
This PR is the result of casual discussion with @gziolo on
wp-cli
block scaffolding :)Adds initial
MVP
for scaffolding WP plugin with a simple block usingstarter
created by @youknowriadDemo GIF
Immediate Items on list
parcel
,webpack
Rough Roadmap/wishlist posted here #10629