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

fix(package-discovery): Check for packages in webroot (Bedrock) #236

Merged
merged 1 commit into from
Jul 8, 2022

Conversation

Log1x
Copy link
Sponsor Member

@Log1x Log1x commented Jul 5, 2022

Potential fix for https://discourse.roots.io/t/bedrock-required-composer-packages-not-registered-with-acorns-packagemanifest/23495

Tested and working on my end – not sure if there's a more sane approach.

@Log1x Log1x requested a review from QWp6t July 5, 2022 01:22
@QWp6t
Copy link
Sponsor Member

QWp6t commented Jul 5, 2022

We have a Filesystem::closest() helper that could be used as well. It crawls up the directory tree until it finds the file you're looking for. It returns null if the file is not found.

(new Filesystem)->closest(WP_CONTENT_DIR, 'composer.json');

Directory traversal could get expensive if done too often, though, so we might want to cache the results of that if we do decide to go that route.

If we're venturing outside of webroot, we should test with open_basedir set to webroot to be sure we're not breaking things for more restrictive environments. I believe it will throw an exception that we would have to catch (not sure tho).

PS-
Sorry for not getting back to you right away on Discord when you were asking about this. 💜

@oxyc
Copy link
Contributor

oxyc commented Jul 5, 2022

Another way to get the data would be

$composer_paths = ...
    ->merge(
        collect(\Composer\InstalledVersions::getAllRawData())
            ->pluck('root')
            ->pluck('install_path'),
    )
    ->...

But if doing that might as well use getAllRawData() to pick up the ['extra']['acorn'] configs as well... making it all more complex really.

I have nothing against assuming a bedrock like structure :)

@QWp6t
Copy link
Sponsor Member

QWp6t commented Jul 6, 2022

One of the issues I've run into with using Composer\InstalledVersions is that sometimes plugins come bundled with Composer, which can result in collisions. But I wouldn't be opposed to that as long as there's a way for developers to recover from those potential collisions.

@Log1x Log1x merged commit c14095a into 2.x Jul 8, 2022
@Log1x Log1x deleted the log1x/bedrock-pkg-discovery branch July 8, 2022 02:50
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.

3 participants