Component creation now allows to be created inside a subdirectory #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This enhancement as mentioned in #38 will allow to create components inside a convenient subdirectory and by default will prefix its name after the subdirectory that contains it.
For instance, if we are creating a dashboard component for admin and users, one might like to create like this:
php artisan ng:component admin/dashboard
The component will be created inside components directory like:
components/admin/admin-dashboard/admin-dashboard.component.js
So if the we want to create another and different dashboard component for users e.g.
php artisan ng:component users/dashboard
It will also be created similarly, but its name will be prefixed to avoid duplicated component names on import.
components/users/users-dashboard/users-dashboard.component.js
So, their names will result in different class names:
However, you can always disable that prepending feature with the added
--no-prefix
option to allow only using the component name, if that is what you like.e.g.
php artisan ng:component --no-prefix admin/dashboard
It will be created as
components/admin/dashboard/dashboard.component.js
and its classname will beclass DashboardController{...
So, now
ng:component
withname
that includes subdirectories as mentioned above, is prefixed by default to conveniently avoid duplicated component names... and might also be a hint to help us figure out in which directory is located our component, so we could find it easily. Notice that not using subdirectories, creation of components will behave as usual.