JamieMason / syncpack

Consistent dependency versions in large JavaScript Monorepos.
https://jamiemason.github.io/syncpack/
MIT License
1.34k stars 44 forks source link

feat(groups): allow many dependencies to be interpreted as one #204

Open moltar opened 3 months ago

moltar commented 3 months ago

For example, it is possible to force all @aws-sdk/* packages to use the same version?

I know there is this example: https://jamiemason.github.io/syncpack/examples/fix-aws-sdk-version-mismatch/

But it enforces a specific version via pinVersion.

I don't want to enforce a specific version, but rather ensure that all of them are using the same one.

Thanks!

moltar commented 3 months ago

In addition to that, is there a way to enforce the same version, but for alpha packages?

E.g. in the cdk-land, there's this convention for alpha packages:

2.114.1-alpha.0

Where 2.114.1 is the version of the aws-cdk-lib package.

They are always released together, so versions always go together, just appending -alpha.0 to the end.

I'd like to lint (and possibly fix) this to be always the same.

Thanks!

JamieMason commented 3 months ago

Hey @moltar, I think for this there needs to be some kind of merging/aliasing config along these lines.

{
  "versionGroups": [
    {
      "label": "Ensure AWS SDK dependencies always use the same version",
      "packages": ["**"],
      "dependencies": [{ "@aws-sdk/core": ["@aws-sdk/**"] }]
    }
  ]
}

Where the key is the dependency whose version should be the source of truth, and the array contains the patterns for which dependencies should be 1) included in this group and 2) treated as actually being @aws-sdk/core instead.

So in summary, dependencies would be extended to not only contain an array of pattern strings, but a combination of those and/or these objects as well.

We could use the same approach for packages.

moltar commented 3 months ago

Why can't it be some policy or some such that basically says:

"packages in this group shall all have the same version"


EDIT:

{
  "versionGroups": [
    {
      "dependencies": ["@aws-sdk/**"],
      "policy": "sameVersion",
      "label": "AWS SDK dependencies should all have the same version"
    }
  ]
}
JamieMason commented 3 months ago

Ahh, I see what you mean. Yeah that could work really well, let me think it through but yeah that does sound better.

moimael commented 5 days ago

This feature would be incredibly useful to not have to update the config file for pinned version on dep update.