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

Add --github flag to scaffold plugin from a repository #158

Open
rheinardkorf opened this issue Jul 4, 2018 · 5 comments
Open

Add --github flag to scaffold plugin from a repository #158

rheinardkorf opened this issue Jul 4, 2018 · 5 comments

Comments

@rheinardkorf
Copy link

Issue

Currently when using wp scaffold plugin you are limited to the provided plugin architecture. This is not ideal where you might have your own architecture you would like to use. In most cases this can be solved with other scripts, but it takes you outside of the convenience of wp-cli.

Proposal

Add a new --github flag which will allow wp scaffold plugin to checkout a source that will be used for scaffolding.

Example usage:

# Checkout default branch and use for scaffolding.
wp scaffold plugin --github=myorg/mypluginbase

# Checkout alternate branch to use for scaffolding.
wp scaffold plugin --github=myorg/mypluginbase:alternate-branch

Considerations

  1. exec() vs PHP git library
  2. Replacement patterns for source files (and the methods to do the replacing)
  3. Alternate method to determine successful checkout and replacement than log_whether_files_written
@schlessera
Copy link
Member

I would love to have something like that available!

I think that the use cases for scaffolding have by now outgrown the way this is technically handled, and it needs an overhaul to open it up to more flexible usage.

Refactoring the scaffolding system (in a backward compatible fashion, of course) would be a good overarching target for v2.1. I'll open a new umbrella issue in that regard.

@rheinardkorf
Copy link
Author

@schlessera do you already have an architecture in mind for a refactored scaffolding system?

@schlessera
Copy link
Member

Not yet, I haven't spent much time on it, given I'm focusing on the package restructuring for v2.

However, here are some basic goals I'd like to achieve:

  • OOP-based main architecture.
  • Decouple template source & processing and provide extensible interfaces for both.
  • Provide set of default template sources as available objects (Git repo, folder, ZIP file, ...)
  • Provide set of default processing mechanisms as available objects (placeholder replacement with Mustache or similar, code generation through PHP-Parser, ...)
  • Allow for custom integrations to be added through WP-CLI config files, so that a project can simply add its folder of templates, for example.

@schlessera
Copy link
Member

I'd like this to be closer to the project-based generation tools like Laravel's artisan, where you can define custom templates for types of objects for your project once and then have an easy method to add new implementations with one command.

@constantinosgeorgiou
Copy link

I am willing to contribute the feature which will scaffold a plugin based on a custom template.

I suggest that the flag, which specifies the custom template, should be named either --template= or --from=, instead of --github=, because it should recognize git repositories from various vendors as well as directories.

I will create a PR once the issue is assigned to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants