Skip to content

Conversation

@ChilloManiac
Copy link

For pnpm monorepos its usually like so

.
├── .git
├── pnpm-lock.yaml
├── package.json
└── packages/
    ├── lib1/
    │   └── package.json
    └── lib2/
        └── package.json

In the current case this would default back to npm if inside lib1

@github-actions github-actions bot requested a review from stevearc March 27, 2025 07:56
Copy link
Owner

@stevearc stevearc left a comment

Choose a reason for hiding this comment

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

Instead of doing a separate vim.fs.find up to the git root (which is not guaranteed to exist), I'd prefer a solution that makes use of the fact that we're already doing get_candidate_package_files to find all possible package.json files. It would require a little refactoring, but we could inspect the directory of each of them for the lockfiles instead of just the one that we determine is the relevant package file.

@ChilloManiac
Copy link
Author

Instead of doing a separate vim.fs.find up to the git root (which is not guaranteed to exist), I'd prefer a solution that makes use of the fact that we're already doing get_candidate_package_files to find all possible package.json files. It would require a little refactoring, but we could inspect the directory of each of them for the lockfiles instead of just the one that we determine is the relevant package file.

Yeah looking at that function, it would make more sense to have the logic there or a similar function.

Would it make sense to search for the closest lock-file, as well as the package.json?
The package.json is responsible for declaring the scripts, but the lock-file seems like the definitive package-manager declaration?

@ChilloManiac
Copy link
Author

Maybe something like refactoring the pick_package_manager(package_file) function to find the closest lockfile from that package_file?

@stevearc
Copy link
Owner

What I am thinking is: we are already finding every possible package.json file in the hierarchy. We then take that list and find the closest one that has scripts defined. What if we also operated on that same list and searched for a lockfile in the same directory as that package.json file? Would require some refactoring because currently that list of package.json files is consumed immediately to find the right package file, so instead we would probably want to call it and then pass that list into two helpers, one to get the correct package file and one to find the lockfile.

@ChilloManiac
Copy link
Author

Sounds good - I'll get on around to it

@github-actions github-actions bot requested a review from stevearc April 23, 2025 12:36
@ChilloManiac
Copy link
Author

I've updated the PR

@ChilloManiac
Copy link
Author

Not meaning to be disrespectful, but bumping this as it seems to have been forgotten @stevearc

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.

2 participants