Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question(config): how to pin versions to a range? #257

Closed
1 task done
sissi144 opened this issue Jan 20, 2025 · 6 comments
Closed
1 task done

question(config): how to pin versions to a range? #257

sissi144 opened this issue Jan 20, 2025 · 6 comments

Comments

@sissi144
Copy link

Description

now we can add rules like
{ dependencies: [ 'react',], pinVersion: '^16.1.1', },
which means react should wirte as 'react': '^16.1.1''in every packages.json

but we now need it to satisfy a scenario that we can also write react 16.1.9 or 16.6.6 in packages.json, which satisfy the semver rules that ^16.1.1 means version between16.1.1-16.X.X (not 17)

Suggested Solution

like top

Optional comments

No response

Code of Conduct

@JamieMason
Copy link
Owner

For this you could use the following as ">=16.1.1 <17" is a valid version specifier in npm.

{
  "versionGroups": [
    {
      "dependencies": ["react"],
      "pinVersion": ">=16.1.1 <17",
    }
  ]
}

Image
https://semver.npmjs.com/

@JamieMason JamieMason changed the title feat: Support multiple versions use semver rules question: how to pin versions to a range Jan 20, 2025
@sissi144
Copy link
Author

Thank you for your prompt reply.

{ dependencies: ['react'], pinVersion: '>=17.0.2 <19', },

Image

But it seems not work . I am using syncpack 13.0.0.

@JamieMason
Copy link
Owner

You would next need to run fix mismatches to set each of your react versions to use the new range specifier we added as the pinVersion in your config.

@sissi144
Copy link
Author

Sorry, its may not be what i want。

i want synpack to check the react version should between 17-19 in my monorepo, which can help us manage our dependencies in a safe range. if i just use the range specifier in packages.json, how can I update any of them?

For example:

A packages.json
"react": "17.0.2"

B packages.json
"react": "18.0.2" -> "react": "18.0.3" ☑️

i can update B to 18.0.3 which still satisify the rule version should between the safe area 17-19 .

But if I use range

A packages.json
"react": ">=17.0.2 <19"

B packages.json
"react": ">=17.0.2 <19"

How can I update version ? ❌

@JamieMason
Copy link
Owner

JamieMason commented Jan 22, 2025

Sorry @sissi144 I'm not completely sure what it is you need.

If you need to constrain your dependency to a specific range, >=17.0.2 <19 will do that and your package manager will handle it all for you. The package manager will most likely put them all on the highest v18 unless certain packages have other dependencies which cause some deviation.

As far as updating packages goes, again your package manager would handle this and you would see the changes reflected in your lockfile when you run its update command.

The closest thing syncpack has today is a same range group, but that ensures the versions all satisfy eachother, it doesn't apply a constraint to what that range should be. I think doing that is a step too far for syncpack and starts to encroach on the job package managers do already, but I'm open to being persuaded on this if I have a blind spot.

@JamieMason JamieMason changed the title question: how to pin versions to a range question(config): how to pin versions to a range? Feb 9, 2025
@JamieMason
Copy link
Owner

I will close this as a duplicate of #244, I think they could be the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants