nicojs / node-link-parent-bin

A tool to link the bins of the your npm dependencies to child packages in a node multi-package repository
43 stars 11 forks source link

Get list of child packages from lerna.json #19

Open billba opened 4 years ago

billba commented 4 years ago

Our project uses Lerna in what appears to be a nonstandard but accepted way. Instead of putting all the child packages under a root/packages folder, they are all directly under root, e.g. root/client, root/server. Lerna handles this by listing them in lerna.json in a packages array, e.g.:

{
  ...
  "packages": [
    "./client",
    "./server"
  ]
  ...
}

It appears that, in a more traditional Lerna setup, the child packages are listed there as follows:

{
  ...
  "packages": ["packages/*"]
  ...
}

I propose that, instead of reading the command-line option --child-directory-root (with default packages), the list of packages instead be read from the lerna.json.

For backwards compatibility you could still allow the option as an override, however I would recommend instead bumping up the major version number to keep the code simple, since this approach seems to be more in line with how Lerna is intended to be used, and therefore should obviate the need for anyone to use --child-directory-root.

If you approve I'd be happy to submit a PR.

macksal commented 2 years ago

It would be great to see this - after seeing lerna mentioned in the README, it was a bit of a gotcha for it to not just work out of the box.

I'd recommend that support is kept for non-lerna Yarn workspaces, too. Perhaps the order of precedence should be:

With the existing command line option as an override?

nicojs commented 2 years ago

Sounds good. I'd be happy to accept a PR for this.

I personally use packages/* always for my projects, which is why I didn't see this as a problem.

Let's use the fallback mechanism @macksal mentioned. Resources: