Skip to content

Conversation

solomon-ochepa
Copy link
Contributor

@solomon-ochepa solomon-ochepa commented Mar 9, 2025

Summary
Resolve issues with the app/ path by supporting both default and custom names while ensuring proper namespace conversion.

Description
The app/ path was previously removed due to multiple issues. This task involves reintroducing support for it while ensuring:

  • It correctly supports both default (app/) and custom paths (src/, /).
  • The namespace is properly converted to StudlyCase.
  • No existing features are broken in the process.
  • Tests have been added to verify correctness and stability.

Acceptance Criteria:

  • app/ path works with both default and custom configurations.
  • Namespace is correctly converted to StudlyCase.
  • No feature breakages in this branch.
  • Tests validate the expected behavior.

Tests (PathNamespaceTest)

  • test_generates_app_path()
  • test_generates_custom_app_path()
  • test_generates_root_app_path()
  • test_removes_duplicate_app_path()
  • test_identifies_app_path()
  • test_recognizes_custom_app_path(), etc.

Let me know if you want any modifications! 🚀

@solomon-ochepa solomon-ochepa force-pushed the fix-issues-with-app-path-and-namespace branch 2 times, most recently from 7782291 to 8fe9572 Compare March 12, 2025 01:17
@solomon-ochepa
Copy link
Contributor Author

Hi, @dcblogdev. Your attention is needed here, please.

@dcblogdev
Copy link
Collaborator

this needs to work with the existing app_folder path in the config otherwise it will break for existing apps.

Confirmed app and src folder work as long as the modules composer are updated accordingly such as "Modules\\Blog\\": "app/",

@solomon-ochepa
Copy link
Contributor Author

this needs to work with the existing app_folder path in the config otherwise it will break for existing apps.

That is true. I'll immediately add a backward compatibility replacement for the old app_folder.

Confirmed app and src folder work as long as the modules composer are updated accordingly such as "Modules\\Blog\\": "app/",

Sure, they are all working, and I've written some tests for that. You can go ahead and confirm it.

Tests:

test_generates_app_path() (modules.paths.app: 'app/' or '') - default path.

public function test_generates_app_path()
    {
        $app_path = $this->path_namespace->app_path();

        $this->assertSame('app/Models/User', $this->path_namespace->app_path('Models/User'));
        $this->assertSame($app_path, $this->path_namespace->app_path(null));
    }

test_generates_custom_app_path() (modules.paths.app: 'src/') - any custom path of your choice, including src/

public function test_generates_custom_app_path()
    {
        config(['modules.paths.app' => 'src/']);

        $this->assertSame('src/Models/User', $this->path_namespace->app_path('Models/User'));
    }

test_generates_root_app_path() (modules.paths.app: '/') - can also be used without the app/ path

public function test_generates_root_app_path()
    {
        config(['modules.paths.app' => '/']);

        $this->assertSame('Models/User', $this->path_namespace->app_path('Models/User'));
    }

@solomon-ochepa solomon-ochepa force-pushed the fix-issues-with-app-path-and-namespace branch from 0e924d9 to 33aba43 Compare April 28, 2025 03:17
@solomon-ochepa solomon-ochepa force-pushed the fix-issues-with-app-path-and-namespace branch from 33aba43 to 8097896 Compare April 28, 2025 03:58
@solomon-ochepa
Copy link
Contributor Author

Sorry, your merge affected the workflow. I'll be submitting a new PR shortly.
@dcblogdev

@solomon-ochepa solomon-ochepa reopened this May 7, 2025
@solomon-ochepa
Copy link
Contributor Author

this needs to work with the existing app_folder path in the config otherwise it will break for existing apps.

Confirmed app and src folder work as long as the modules composer are updated accordingly such as "Modules\\Blog\\": "app/",

Hi, @dcblogdev.

The backward compatibility support for both modules.paths.app_folder and composer.json $APP_FOLDER_NAME$ has been added successfully. Please check it out and let me know if more changes are needed.

Thanks, and have a nice day.

@dcblogdev
Copy link
Collaborator

thanks, I'll have a look at this tonight.

@alissn
Copy link
Contributor

alissn commented May 7, 2025

After merging this PR, we’ll likely be saying hi to a lot of new issues. 🤷‍♂️

Having 230 changed files is not normal. It would be better if the author could split this into smaller, more focused PRs so the community can review the changes more effectively.

@solomon-ochepa
Copy link
Contributor Author

After merging this PR, we’ll likely be saying hi to a lot of new issues. 🤷‍♂️

Having 230 changed files is not normal. It would be better if the author could split this into smaller, more focused PRs so the community can review the changes more effectively.

Do you discover any bug you'd like the author to correct?

The CI/CD tests was created to detect early bugs. If passed, the code is believed to be okay!

Thanks and have a great day

@solomon-ochepa
Copy link
Contributor Author

After merging this PR, we’ll likely be saying hi to a lot of new issues. 🤷‍♂️

Having 230 changed files is not normal. It would be better if the author could split this into smaller, more focused PRs so the community can review the changes more effectively.

image

More than 156 files are tests and snapshots.

@alissn
Copy link
Contributor

alissn commented May 8, 2025

I don't want this to happen again.

Reference: https://x.com/taylorotwell/status/1552452998546300929
image

@solomon-ochepa
Copy link
Contributor Author

I don't want this to happen again.

Reference: https://x.com/taylorotwell/status/1552452998546300929
image

Do you realize at all that this same PR is to correct a problem you yourself introduced to this package?

Don't be too sentimental. Go through the PR and recommend changes if any.

Have you tested the PR and it's not working or do you find any bugs you'll like the author to fix?

Do you know the level of damages your changes cost us?

Let's join hands together and create solutions, not fighting each other all the time.

No one is paying us to contribute code here! Let's not feel so entitled or sentimental or judgemental please 🙏

@dcblogdev
Copy link
Collaborator

we're not looking to argue, its a massive PR, going to find some time to look over this and try out with a few apps I have.

The tests are all passing which is great 👍 with there being so many changes just want to check there's no unexpected issues that the tests don't check for.

@solomon-ochepa solomon-ochepa force-pushed the fix-issues-with-app-path-and-namespace branch 5 times, most recently from bf0dd09 to 0435c4e Compare May 9, 2025 06:02
@solomon-ochepa
Copy link
Contributor Author

After merging this PR, we’ll likely be saying hi to a lot of new issues. 🤷‍♂️

Having 230 changed files is not normal. It would be better if the author could split this into smaller, more focused PRs so the community can review the changes more effectively.

Hi, I figured out a way to extract fractions of the PR into a separate micro PR. I've created a draft PR and will mark it ready once this is reviewed and merged.

While waiting for @dcblogdev and the rest of the QA team to complete the review, I'll review the codebase again to see if there is still room for more micro PRs.

Thanks for your observation and recommendation.

@solomon-ochepa solomon-ochepa force-pushed the fix-issues-with-app-path-and-namespace branch 6 times, most recently from df4eb1b to 1206ed2 Compare May 9, 2025 08:29
… methods

- [test] Enhance PathNamespaceTest with additional path and namespace conversion tests
- [feat] add module_path and module_app_path methods for improved module path handling
- [refactor] fix trimming logic in clean() method for improved path handling
- [fix] trim leading and trailing slashes in app path for consistency
- [refactor] enhance path handling methods for improved clarity and consistency
…nerator for improved namespace handling and code clarity
refactor: update `default_namespace()` method to accept a default path for improved flexibility

refactor: update `default_namespace()` method to use an empty string as default value for improved clarity
…e new `path` method for improved module retrieval
…r generated files

- Updated namespaces in generated module files from 'Modules\Blog\Http\Controllers' to 'Modules\Blog\App\Http\Controllers'.
- Changed service provider namespaces from 'Modules\Blog\Providers' to 'Modules\Blog\App\Providers'.
- Adjusted repository, request, resource, and rule namespaces to follow the new structure.
- Modified test snapshots to reflect the updated namespaces.
- Cleaned up unnecessary module path variables in tests for better readability and maintainability.
@solomon-ochepa solomon-ochepa force-pushed the fix-issues-with-app-path-and-namespace branch from e418940 to b6e231b Compare July 4, 2025 08:00
@solomon-ochepa solomon-ochepa force-pushed the fix-issues-with-app-path-and-namespace branch from 85aef68 to 2ed853f Compare July 7, 2025 11:56
Copy link

@piotrczech piotrczech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! I was going through this PR and I had a few questions.

The PR seems a bit large (like said before) and I noticed there are some changes that feel slightly unrelated to the main scope - for example, changing the stub here, and also renaming things from Transformers to Resources.

Could you share the reasoning behind bundling these changes together in the same PR?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stub changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review.

I contributed the initial format some time ago and while working on these changes I discovered they could be optimized.

I added them here so they can be reviewed together since they are just basic modifications.

Please let me know if they are done wrong, and I'll update them.

Thank you very much for your time.

@solomon-ochepa
Copy link
Contributor Author

Hi, @dcblogdev , @nWidart and @DeRaja . I've submitted a complimentary PR for the Laravel modules livewire package.

Thank you.

@piotrczech
Copy link

@solomon-ochepa I totally see why you'd want to keep related changes together, especially if they were discovered while refactoring. But I still think splitting this into multiple, smaller PRs would really help the review process and make sure nothing critical slips through unnoticed.

As @alissn mentioned, having 210+ changed files is very hard to properly review, and merging such a big PR often leads to new issues afterwards. Smaller, more focused PRs would make it easier for everyone to understand the intention behind each change (like the stub adjustments or renaming transformers to resource).

This isn't about the changes being wrong, it’s just about keeping the PR easier to track, test, and discuss.

@solomon-ochepa
Copy link
Contributor Author

@solomon-ochepa I totally see why you'd want to keep related changes together, especially if they were discovered while refactoring. But I still think splitting this into multiple, smaller PRs would really help the review process and make sure nothing critical slips through unnoticed.

As @alissn mentioned, having 210+ changed files is very hard to properly review, and merging such a big PR often leads to new issues afterwards. Smaller, more focused PRs would make it easier for everyone to understand the intention behind each change (like the stub adjustments or renaming transformers to resource).

This isn't about the changes being wrong, it’s just about keeping the PR easier to track, test, and discuss.

Yes, I understand that reviewing such large changes may lead to oversights.

However, we should also understand that splitting a highly coupled change could lead to inefficiency and untestable PRs.

Nevertheless, I'll check if there's anything not directly related to the main issue that can be removed.

Thank you.

@piotrczech
Copy link

However, we should also understand that splitting a highly coupled change could lead to inefficiency and untestable PRs.

I totally understand your point about wanting to avoid untestable or inefficient PRs. But the thing is, some of the changes here (like renaming Transformers to Resources and changing the stubs) don’t really seem tightly coupled to the main problem this PR is solving.

Nevertheless, I'll check if there's anything not directly related to the main issue that can be removed.

Actually, it even looks like you also recognized they could be separate, since you created another PR (#2091) with similar stub changes earlier, so they could clearly live in their own scope. Including them again here just because the other PR wasn’t merged feels a bit like pushing more changes into this one big PR.

I really think smaller, focused PRs are easier to review, test and understand, especially for the community. Right now, it really does feel less like we’re discussing the solution to the specific problem in the title, and more like trying to get as many unrelated changes merged as possible in one go.

@solomon-ochepa
Copy link
Contributor Author

However, we should also understand that splitting a highly coupled change could lead to inefficiency and untestable PRs.

I totally understand your point about wanting to avoid untestable or inefficient PRs. But the thing is, some of the changes here (like renaming Transformers to Resources and changing the stubs) don’t really seem tightly coupled to the main problem this PR is solving.

Nevertheless, I'll check if there's anything not directly related to the main issue that can be removed.

Actually, it even looks like you also recognized they could be separate, since you created another PR (#2091) with similar stub changes earlier, so they could clearly live in their own scope. Including them again here just because the other PR wasn’t merged feels a bit like pushing more changes into this one big PR.

I really think smaller, focused PRs are easier to review, test and understand, especially for the community. Right now, it really does feel less like we’re discussing the solution to the specific problem in the title, and more like trying to get as many unrelated changes merged as possible in one go.

I get your point, and I totally agree with you.

I did more regarding the stubs, and many more other features such as the copy module command, move module, etc.

I'll move theses changes to the other PR or better stil create a new PR. But one thing for sure is that they will not reduce the count as other things are also modified in these files.

Give me a minute to remove these two off topic changes. Please, as you go continue reviewing the PR, you can always recommend any changes that can be move to a new PR.

Thanks for your time.

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

Successfully merging this pull request may close these issues.

5 participants