sxzz / stale-dep

Check if your `node_modules` is stale.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for Pnpm Workspaces with one single pnpm-lock.yaml file?

chrisspiegl opened this issue · comments

Clear and concise description of the problem

I started using stale-dep in some of my repositories.

Now one of the projects grew and I am working with a pnpm workspace with one singular pnpm-lock.yaml in the workspace root.

stale-dep does not seem to recognize the pnpm-lock.yaml in the workspace root?

Would this be somethign that's possible to support?

Suggested solution

xy

Alternative

No response

Additional context

No response

Validations

Could you please provide a minimum repo?

For pnpm workspace, you can add the scripts into package.json of the root, and it'll check the pnpm-lock.yaml from the root of the project.

Dear @sxzz , sorry for the long wait time. I had this planned for long but never found the time.

I have now created a reproduction: https://codesandbox.io/p/sandbox/reproduction-stale-dep-pnpm-workspace-dr2lfj

This shows that when I have a pnpm workspace which calls stale-dep from a sub package (app with and without postinstall in this case) it complains that there is no pnpm-lock.yaml file present.

I have also tried to run the stale-dep -u in the sub package app-with-postinstall upon postinstall but that also does not work and shows the same error.

I hope the reproduction helps figure out what may be going on or if there is something I have to fix on my end.

Updated the reproduction to show the case a bit better and run on Node version 18.

https://codesandbox.io/p/sandbox/reproduction-stale-dep-pnpm-workspace-dr2lfj (link above is also updated).

Steps to reproduce:

  1. open sandbox
  2. run pnpm install
  3. result: it will show error because the sub directory app-with-postinstall will try to do the postinstall stale-dep -u but that will fail with error no pnpm-lock.yaml.
  4. run pnpm lint
  5. result: it will print not stale because here the stale-dep -u after install works since pnpm-lock.yaml is present in root of workspace.
  6. cd app-with-postinstall
  7. run pnpm start
  8. error no pnpm-lock.yaml found
  9. cd ../app-no-postinstall
  10. run pnpm start
  11. error no pnpm-lock.yaml found

I hope this helps and is clear to understand.

This project doesn't support pnpm + workspace now. If anyone can contribute this enhancement, I'd like to merge it happily.