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

Refactor processing logic #38

Closed
AlexSkrypnyk opened this issue May 28, 2024 · 1 comment
Closed

Refactor processing logic #38

AlexSkrypnyk opened this issue May 28, 2024 · 1 comment

Comments

@AlexSkrypnyk
Copy link
Owner

When started integrating this with real projects, it appeared that having a processor per question did not make sense as
a) processing could affect other processing
b) the code was extremely hard to read because different processing took place elsewhere

We can simplify the Customizer to do the following:

  1. Init config
    1.1 Init properties like cwd, io, fs
    1.2 Find and read the config file
    1.3 Validate expected config file methods and callbacks. Make sure that both questions() and process() are added (or the config file does not make sense).
  2. Ask questions and get answers
    2.1 Call default value callback to get the state from the env - NEW (allows to use Customizer for existing projects)
    2.2 Call each question from the map of questions callbacks
    2.3 Add simplest validator utilities - NEW (allows to validate general use cases like php package name) - would be a copy from Str2Name.
  3. Process answers
    3.1 Use a single process() callback passed from config. This will allow to handle everything in a single place.
  4. Cleanup
    3.1 Allow to provide cleanup() callback in the config file. If the callback returns FALSE - the rest of the cleanup is cancelled. Any changes to composer.json would need to be written back to the file within the callback.
    3.2 Run generic cleanup to remove entires from composer.json. The composer.json contents will be re-read before making changes (to pickup modifications possible done in cleanup() callback).
    3.3 Update composer deps (if run as a plugin file).
@AlexSkrypnyk
Copy link
Owner Author

This has been implemented. We need to add more tests - tracked in #40

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

No branches or pull requests

1 participant