This Pull Request aims to organize the code structure in everything related to creating a new PowerGrid component, while also resolving the issue mentioned below.
Main Interface Changes
Laravel Prompt Windows Fallback
There is no support for Laravel Prompt in Windows (read more here). I have tried to adapt the prompts to be usable when it goes into "asking question" mode. We might have to put more work to ensure a good user experience in the future. I propose to monitor issues on this topic.
Check for Component Existence
Until now, this check was happening at the end of the wizard, after the user has answered all asked questions. With this PR, this check happens right after the user informed a component name, and it defaults to "no".
Dependencies Notification
I have moved the notification check into a separated command powergrid:check-dependencies.
I rewrote the notification messages to bring more clarity.
In addition, I have also added a "confirmation" step to make sure the user doesn't miss this message. While this might be inconvenient, specially in a prompt fallback situation, we can easily remove this step in src/Commands/CheckDependenciesCommand.php.
Installation Wizard
I have provided some new texts and removed tables such as passwords, tokens, migrations from the table listing.
In addition, I improved the parsing of different ways to receive component names for a nested folder structure, such like "tables.admins.users.ListTable" or "\Tables\Admins\Users\ListTable".
In this PR, I have also modified the order questions were asked. I think it makes sense to for the table name in the same step we ask for models (when it applies).
To follow the new nomenclature, the wizard asks to import "fields" and not columns anymore.
To finalize, instead of throwing exceptions, some prompts run on a loop.
When asked for models, if the given model doesn't exist the setup will return to the same question, avoiding having the user starting the wizard all over again.
Same for tables:
Before suggesting importing database table columns as fields, the wizard is now checking if there is a database connection, if the database has tables. If both fail, the setup will assume the given table and continue creating the component. When there are tables, it will suggest tables and validate that the given table exists.
While I think this scenario is less common, this PR allows the users to create components before running migrations.
Main Structural changes
Improved variable names in stubs.
Legacy variable names are handled to avoid breaking changes.
Stubs now have the type (e.g., .fillable) at the end of the filename, so we can decide when to load each type.
Stubs are processed by the PowerGridStub class (src/Support/PowerGridStub.php).
Data source types are now controlled by an enum src/Enums/Datasource.php. It may be a bit inflated with methods, but I think it is just simple to go this way.
The component building process is centered on the PowerGridComponentMaker class (src/Support/PowerGridComponentMaker.php)
Questions asked during the wizard are now moved into Actions.
TO DO
❗ The Laravel Prompt tests are failing, I assume, due to a fallback to Symphony Question Helper. I need to dig deeper into testing prompts.
❗ As mentioned above, we have to keep a look at Windows user's experience when creating a component.
⚡ PowerGrid - Pull Request
Motivation
Description
This Pull Request aims to organize the code structure in everything related to creating a new PowerGrid component, while also resolving the issue mentioned below.
Main Interface Changes
Laravel Prompt Windows Fallback
There is no support for Laravel Prompt in Windows (read more here). I have tried to adapt the prompts to be usable when it goes into "asking question" mode. We might have to put more work to ensure a good user experience in the future. I propose to monitor issues on this topic.
Check for Component Existence
Until now, this check was happening at the end of the wizard, after the user has answered all asked questions. With this PR, this check happens right after the user informed a component name, and it defaults to "no".
Dependencies Notification
I have moved the notification check into a separated command
powergrid:check-dependencies
.I rewrote the notification messages to bring more clarity.
In addition, I have also added a "confirmation" step to make sure the user doesn't miss this message. While this might be inconvenient, specially in a prompt fallback situation, we can easily remove this step in
src/Commands/CheckDependenciesCommand.php
.Installation Wizard
I have provided some new texts and removed tables such as passwords, tokens, migrations from the table listing.
In addition, I improved the parsing of different ways to receive component names for a nested folder structure, such like "tables.admins.users.ListTable" or "\Tables\Admins\Users\ListTable".
In this PR, I have also modified the order questions were asked. I think it makes sense to for the table name in the same step we ask for models (when it applies).
To follow the new nomenclature, the wizard asks to import "fields" and not columns anymore.
To finalize, instead of throwing exceptions, some prompts run on a loop.
When asked for models, if the given model doesn't exist the setup will return to the same question, avoiding having the user starting the wizard all over again.
Same for tables:
Before suggesting importing database table columns as fields, the wizard is now checking if there is a database connection, if the database has tables. If both fail, the setup will assume the given table and continue creating the component. When there are tables, it will suggest tables and validate that the given table exists.
While I think this scenario is less common, this PR allows the users to create components before running migrations.
Main Structural changes
.fillable
) at the end of the filename, so we can decide when to load each type.src/Support/PowerGridStub.php
).src/Enums/Datasource.php
. It may be a bit inflated with methods, but I think it is just simple to go this way.src/Support/PowerGridComponentMaker.php
)TO DO
❗
The Laravel Prompt tests are failing, I assume, due to a fallback to Symphony Question Helper. I need to dig deeper into testing prompts.❗
As mentioned above, we have to keep a look at Windows user's experience when creating a component.Related Issue(s):
https://github.com/Power-Components/livewire-powergrid/issues/1394
Documentation
This PR requires Documentation update?