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

Add a setting to separate packages from require and require-dev sections for Composer collector #1438

Open
Kaspiman opened this issue Sep 23, 2024 · 4 comments

Comments

@Kaspiman
Copy link

Kaspiman commented Sep 23, 2024

Hello! I have an idea!

https://qossmic.github.io/deptrac/collectors/#composer-collector

According to documentation:

The composer collector allows you to define dependencies on composer require or require-dev packages that follow PSR-0 or PSR-4 autoloading convention. With this collector you can for example enforce: - That your require-dev dependencies are only used in you non-production code (like DB migrations or SA tools)

As I understand it, you need to list the packages manually? What if we add a setting for require and require-dev separation?

Use case: i have Application layer (it could relate only require-section packages) and Test layer (it could relate require and require-dev packages).

For example:

deptrac:
  layers:
    - name: ComposerRequire
      collectors:
        - type: composer
          composerPath: composer.json
          composerLockPath: composer.lock
          require: true
          requireDev: false
     - name: ComposerRequireDev
      collectors:
        - type: composer
          composerPath: composer.json
          composerLockPath: composer.lock
          require: false
          requireDev: true
@patrickkusebauch
Copy link
Collaborator

IMO this is something you can already do relatively easily with the PhP config file:

  • Open the composer file
  • Parse the JSON composer content
  • add all the packages from the section you need

I am wary of adding functionality to the project that can be easily done in userspace. But that is just my opinion. It may be a good topic for a blog post though.

@Kaspiman
Copy link
Author

Often, not all packages are listed in the root composer.json file. For example, I have a SDK for microservices, it has a dozen more dependencies. I want to allow my Infrastructure layer to use all dependencies from the require section. However, the require dev section will only be available in the Test layer. I don't want and can't put all the dependencies into a composer.json file, it will be impossible to support.

@ivoron
Copy link

ivoron commented Oct 2, 2024

good idea! I would like this feature in my projects

@patrickkusebauch
Copy link
Collaborator

Often, not all packages are listed in the root composer.json file. For example, I have a SDK for microservices, it has a dozen more dependencies. I want to allow my Infrastructure layer to use all dependencies from the require section. However, the require dev section will only be available in the Test layer. I don't want and can't put all the dependencies into a composer.json file, it will be impossible to support.

I don't think I follow. What I am suggesting is the same thing as you are suggesting in terms of functionality. The difference is that you propose to have it as part of the tool and I propose to have it in userspace.

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

3 participants