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

WIP: Create WP Plugin #10628

Closed
wants to merge 6 commits into from
Closed

WIP: Create WP Plugin #10628

wants to merge 6 commits into from

Conversation

ajitbohra
Copy link
Member

@ajitbohra ajitbohra commented Oct 15, 2018

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 using starter created by @youknowriad

Demo GIF
create-wp-plugin

Immediate Items on list

  • Validation and error handling
  • Improve CLI experience for the user
  • Mustachejs for templates
  • Option to chose bundler parcel, webpack

Rough Roadmap/wishlist posted here #10629

Copy link
Member

@Soean Soean left a 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

packages/create-plugin/cli/commands.js Outdated Show resolved Hide resolved
packages/create-plugin/package.json Outdated Show resolved Hide resolved
packages/create-plugin/README.md Outdated Show resolved Hide resolved
packages/create-plugin/cli/commands.js Outdated Show resolved Hide resolved
packages/create-plugin/cli/main.js Outdated Show resolved Hide resolved
packages/create-plugin/templates/plugin/README.md Outdated Show resolved Hide resolved
packages/create-plugin/templates/plugin/README.md Outdated Show resolved Hide resolved
packages/create-plugin/templates/plugin/README.md Outdated Show resolved Hide resolved
packages/create-plugin/templates/plugin/README.md Outdated Show resolved Hide resolved
* @package {{pluginSlug}}
*/

/**
Copy link
Member

Choose a reason for hiding this comment

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

Delete blank before slash

@ajitbohra
Copy link
Member Author

@Soean thank you will sync some of the changes to wp-js-plugin-starter https://github.com/youknowriad/wp-js-plugin-starter

@ajitbohra ajitbohra changed the title Draft: Create WP Plugin WIP: Create WP Plugin Oct 19, 2018
@ajitbohra ajitbohra added the [Status] In Progress Tracking issues with work in progress label Oct 19, 2018
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.

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 ) {
Copy link
Member

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

Copy link
Member Author

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"
Copy link
Member

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.

Copy link
Member Author

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"
Copy link
Member

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.

Copy link
Member Author

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;
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

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
Copy link
Member

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;
Copy link
Member

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 \
Copy link
Member

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.

@gziolo gziolo added [Tool] WP Scripts /packages/scripts [Type] Build Tooling Issues or PRs related to build tooling labels Dec 20, 2018
@gziolo gziolo added this to the Future: 5.x milestone Dec 20, 2018
@ajitbohra
Copy link
Member Author

@gziolo

will soon resume work on this and get initial scaffolding ready utilizing wp-scripts

@gziolo gziolo added the [Type] Technical Prototype Offers a technical exploration into an idea as an example of what's possible label Jan 25, 2019
@gziolo gziolo removed this from the WordPress 5.x milestone Jan 25, 2019
@oandregal oandregal self-requested a review February 12, 2019 10:33
@oandregal
Copy link
Member

The @wordpress/scripts package has received some love lately (including support for ESNext/JSX transpilation). We also have better docs such (JavaScript tutorial FTW!). Considering that, I wonder whether this could be rethought as scripts scaffold command instead of a separate package.

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 ?

@youknowriad
Copy link
Contributor

youknowriad commented Mar 15, 2019

I think npm might have a special packages that start with create-*. I like the separation of concerns between @wordpress/scripts and a create package. A create package might need dependencies not really needed aside for generating the initial app.

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?

@oandregal
Copy link
Member

@youknowriad those are good thoughts I hadn't considered deeply 👍

@gziolo
Copy link
Member

gziolo commented Mar 15, 2019

I think npm might have a special packages that start with create-*. I like the separation of concerns between @wordpress/scripts and a create package. A create package might need dependencies not really needed aside for generating the initial app.

Yes, those are great reasons to put it in its own package. For reference, this is how it looks with create-react-app:

$ 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 block.json format is shipped (#13693).

@gziolo gziolo added [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. and removed [Status] In Progress Tracking issues with work in progress labels Apr 24, 2019
@gziolo
Copy link
Member

gziolo commented Apr 24, 2019

@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.

@ajitbohra
Copy link
Member Author

@youknowriad @noisysocks +1 for keeping it as separate package

@gziolo resuming work on this PR to address the feedback and suggestions

@gziolo
Copy link
Member

gziolo commented May 14, 2019

resuming work on this PR to address the feedback and suggestions

It's great to see you back. Feel free to remove Stale label when it gets updated :)

@gziolo
Copy link
Member

gziolo commented May 24, 2019

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.

@paaljoachim
Copy link
Contributor

Hey @ajitbohra
Can we get a status update on this PR? What is needed to move the PR onward?

@gziolo
Copy link
Member

gziolo commented Dec 17, 2019

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
https://github.com/gziolo/create-wordpress-block

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

Should we close this PR?

@mcsf
Copy link
Contributor

mcsf commented Dec 17, 2019

This has been labeled Stale since April. Thanks for the efforts, but I'll close this for now.

@mcsf mcsf closed this Dec 17, 2019
@youknowriad youknowriad deleted the try/create-wp-plugin branch May 27, 2020 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. [Tool] WP Scripts /packages/scripts [Type] Build Tooling Issues or PRs related to build tooling [Type] Technical Prototype Offers a technical exploration into an idea as an example of what's possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants