26B / php-pre-commit

Pre-commit git hook to help keep code within PHP standards.
MIT License
7 stars 1 forks source link

Setup per use case #15

Open xipasduarte opened 5 months ago

xipasduarte commented 5 months ago

Is your feature request related to a problem? Please describe. Currently the users are required to configure their standard manually, dealing with decisions that make it hard to go from composer require ... to codding with standard.

Describe the solution you'd like Instead of recommending that the user be on her own, we should add commands that install what is required for the standard approach to PHPCS on a given framework, library, etc.. The commands will replace the existing docs and we'd need a unified interface to add support for other frameworks.

Describe alternatives you've considered The current approach was considered, as a lower maintenance, but it pushes the burden to the user. We could be better at it, effectively improving the DX while using ph-pre-commit.

Additional context None.

xipasduarte commented 5 months ago

A Proposal for the actual commands and restructuring.

We should add something that facilitates the CLI maintenance. Ideally something in PHP, to keep with the environment (Laravel Zero).

The CLI should include the following commands:

init

Initializes the library fully with a guided aid (interactive) or accepting flags to speedup. This would do the following:

  1. Hook into git hooks or any existing framework for hooks, like Husky
  2. Add the standards base (using templates: WordPress, Laravel)
  3. Build the local folder structure to keep standards local (.php-pre-commit/)
  4. Add command that runs the pre-commit action

run

Executes PHPCS and compares the diffs with support for what exists today.

hook

Adds the run command to the pre-commit hook. Also checks to see if the hook command is running in certain composer scripts to make sure it's always there.

setup

Downloads and activates all the standards that are specified for a given base (WordPress, Laravel).