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

Tooling: scaffolding WordPress plugins and blocks #10629

Closed
ajitbohra opened this issue Oct 15, 2018 · 10 comments · Fixed by #19773
Closed

Tooling: scaffolding WordPress plugins and blocks #10629

ajitbohra opened this issue Oct 15, 2018 · 10 comments · Fixed by #19773
Assignees
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Status] In Progress Tracking issues with work in progress

Comments

@ajitbohra
Copy link
Member

Introduction:

A javascript based tool to fit into developer workflow which enables them to kickstart blocks & plugins. Runs independently without any PHP/WordPress.

Scaffolding Wishlist:

  • Generate plugin with block (single/multiple)
  • Generate blocks based on predefined templates
  • Generate plugin to extend Gutenberg using extensibility API
  • Generate plugin to setup custom plugin page using Gutenberg components & react abstraction

Commands Idea List:

Generate plugin with a single block setup using esnext
$create-wp-plugin block --single --esnext

Generate plugin with a multi-block setup
$create-wp-plugin block --multi

Generate blocks without any plugin (for themes & existing plugins)
$create-wp-plugin block --no-plugin

Generate block using predefined templates
$create-wp-plugin block --template=serverside | richtext | blockcontrols | inspectorcontrols

Generate plugin to extend gutenberg
$create-wp-plugin extensibility --template=sidebar | block

Generate plugin page utilizing gutenberg components & react abstraction
$create-wp-plugin page --title=<page_title>

Commands / Flags:

block

--name=
--slug=
--icon=<Dashicon / SVG>
--category=< category name >
--keywords=<Max 3>
--esnext
--single
--multi
--no-plugin
--template=[
basic,
serverside
richtext,
blockcontrols,
inspectorcontrols,
kitchensink
]

extend

-- sidebar --icon=<Dashicon / SVG> --name=
-- block --with-insepctor-controls --with-block-controls --with-save --with-edit
-- publish
-- pre-publish

page

--name=
--menu=<menu_title>
--slug=
--parent=<menu_parent>
--icon=<Dashicon / SVG>
--kitchensink(Add demo controls)
--tabs=<tabs1,tab2,tab3>

#10628 is MVP exploring above

@designsimply designsimply added the [Feature] Extensibility The ability to extend blocks or the editing experience label Oct 16, 2018
@swissspidy
Copy link
Member

I don't think this should be part of Gutenberg, tbh.

There are already popular tools like https://github.com/ahmadawais/create-guten-block and even support for that in the official WordPress command line utility, WP-CLI: https://github.com/wp-cli/scaffold-command. Both can work without WordPress.

IMO we should concentrate our focus on the existing solutions to make them better if needed.

@youknowriad
Copy link
Contributor

We actually already have a wp-scripts package. It supports: linting, testing, and I think "bundling" is also in the work cc @gziolo

It's probably too soon at the moment but It seems like a natural evolution for me to have a scaffolding tool based on wp-scripts.

@gziolo
Copy link
Member

gziolo commented Dec 12, 2018

There are already popular tools like https://github.com/ahmadawais/create-guten-block and even support for that in the official WordPress command line utility, WP-CLI: https://github.com/wp-cli/scaffold-command. Both can work without WordPress.

Just wanted to clarify create-guten-block doesn't use any of the published code from Gutenberg - Babel config, Eslint config, not mentioning exposed scripts. I hope they fix it someday to avoid promoting solutions which fundamentally differ from the core.

The downside of the current implementation of wp scaffold block in WP-CLi is that it generates ES5 code and depends on both PHP and WordPress instance. In effect, it's very limited in capabilities and hard to use for developers without WordPress expertise.

@gziolo
Copy link
Member

gziolo commented Dec 12, 2018

We actually already have a wp-scripts package. It supports: linting, testing, and I think "bundling" is also in the work

Yes, once we add support for handling builds, we will have all that is required to manage plugins.

@ajitbohra
Copy link
Member Author

@youknowriad @gziolo already covered most of the points

WP-CLI past discussion around having modern tooling for scaffolding wp-cli/scaffold-command#106

The plan is to use wp-scripts and also provide several options for creating plugins apart from the block.

@gziolo
Copy link
Member

gziolo commented Dec 20, 2018

Sharing this handbook tutorial from @mkaz for reference as it is a nice starter for extensibility template.

@schlessera
Copy link
Member

schlessera commented Jan 8, 2019

There's no reason why wp-scripts couldn't be used by the WP-CLI scaffolding tool.

Note: my main focus for v2.2.0 of WP-CLI will be to rethink the scaffolding tool to make it the de-facto code generator for WordPress. This would probably be a better place to include block generation than the Gutenberg plugin itself.

@youknowriad
Copy link
Contributor

@schlessera Great to hear, If I could have one suggestion about this rethinking is to consider splitting the scaffolding from the rest of the tooling. Installing and running the scaffolding tool shouldn't require an active WordPress installation.

@gziolo
Copy link
Member

gziolo commented Mar 12, 2019

I'm sharing for reference the link to create-cloud-block which helps to scaffold blocks to use with Cloud Blocks plugin. Those blocks work with both WordPress and Drupal. The repository is maintained by @eliocro.

@gziolo
Copy link
Member

gziolo commented Dec 17, 2019

I have this npm package up and running which implements parts of the functionality proposed in this issue:

https://www.npmjs.com/package/create-wordpress-block
https://github.com/gziolo/create-wordpress-block

I plan to open PR against Gutenberg after some testing with the community.

This is how it works:

@gziolo gziolo self-assigned this Dec 17, 2019
@gziolo gziolo added the [Status] In Progress Tracking issues with work in progress label Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants