syncpack icon indicating copy to clipboard operation
syncpack copied to clipboard

Wildcards being replaced (useful for monorepos)

Open zomars opened this issue 3 years ago • 4 comments

Description

Monorepo packages that uses wildcard versions "example": "*" are being replaced by "example": "0.0.0"

Suggested Solution

Leave as it is?

Help Needed

Is there a way to prevent this? Couldn't find anything in the README about this.

zomars avatar Aug 12 '22 22:08 zomars

It sounds like defining a semver group might be what you need, this would let you define which packages should only use *

https://github.com/JamieMason/syncpack#semvergroups

JamieMason avatar Aug 12 '22 22:08 JamieMason

Tried adding this config but no luck still:

"semverGroups": [
      {
        "range": "*",
        "dependencies": ["@alpha/**"],
        "packages": ["**"]
      }
    ]

Still "@alpha/example": "*" is being transformed to "@alpha/example": "0.0.0"

zomars avatar Aug 12 '22 23:08 zomars

Adding a custom filter works for now:

    "filter": "^(?!@alpha).*",

zomars avatar Aug 12 '22 23:08 zomars

If you can share a reproduction I can take a look for you

JamieMason avatar Aug 13 '22 06:08 JamieMason

Closing as blocked but please reopen with a repro if you find the time.

JamieMason avatar Oct 28 '22 13:10 JamieMason

Actually, have a check with 8.3.9 – I found that support for setting versions to '*' wasn't available in any circumstances. All other ranges were supported.

JamieMason avatar Oct 28 '22 17:10 JamieMason

Hi, it seems that support for * is still broken with 8.3.9, i have created a simple repro, just run yarn syncpack and versions will be set to 0.0.0.

https://github.com/macieklad/syncpack-repro

macieklad avatar Nov 11 '22 15:11 macieklad

I don't know what commands you guys are running (whether they're the version-related commands or the semver range commands) but looking at https://github.com/macieklad/syncpack-repro @macieklad I think the problem is that workspace is enabled by default, so it is using the versions of your own packages as the source of truth for what should be the correct version for them when they are used as a dependency.

If you set workspace: false in your /syncpack.config.js it should hopefully work as you're expecting. Give that a try @macieklad @zomars and I can try and help you from there if it does not get you what you need.

Thanks.

JamieMason avatar Nov 24 '22 21:11 JamieMason

That is a great clarification, I have missed that option entirely, thank you! The repo is working as intended now :> I think your answer will clarify it for others if they will stumble upon that again.

macieklad avatar Nov 25 '22 14:11 macieklad

There is a new Getting Started guide now to help with some of these things.

JamieMason avatar Nov 08 '23 12:11 JamieMason