-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add optional snapTo property in versionGroups #87
Comments
Hey Hector, could you go into some more detail on what the overall task you're doing here is? It helps if I understand the wider system, right now I would be considering exposing a new piece of config to users but not be able to explain to them why it exists, when to use it, and what it's for etc. Thanks. |
Hey, sure thing. In my specific case, some package.json files are modified by code generators within a monorepo, always generating dependencies with "*". I have other package.json files that have specific versions, so I would like to ignore "*" as the highest valid version and instead use the specific semver found in the other files. This goes a bit in hand with #88 since it would be also useful to specify a file from which some or all package.json files must adhere to if "*" is found. |
OK I think I get it, I'll think about it for a while but right now I'm thinking maybe, a bit like |
I think we can track it under (this) one |
@JamieMason Sorry to hi-jack this to ask: is there a way to ignore certain dependencies from being matched during |
In the case of |
This should be possible with versionGroups, if you create a versionGroup containing only these versions you want treating differently, they'll be isolated from other groups. If it's a group containing only one package, there'll be no other packages it could mismatch with.
was this related to your previous comment or this issue? I'm a bit lost. |
What I mean was having somthing like this: {
"versionGroups": [
{
"dependencies": ["@myDeps/**"],
"snapTo": ["native-app", "web-app"],
"packages": ["**"]
}
]
} This will sync all That is what I meant earlier by the "driver" file, the root * EDIT * Im assuming passing {
"versionGroups": [
{
"dependencies": ["@myDeps/**"],
"snapTo": ["native-app", "", "_ROOT_"],
"packages": ["**"]
}
]
} |
Although I've never been in a situation that has needed it, I could understand a single file being used as a source of truth of some sort and some kind of snapTo property might be able to support that if we decide to go ahead. But:
I'm generally just looking to understand how all of this fits together. Right now this seems like it could be a niche problem specific to your stack, but let me know. |
Sure,
I should note that none of this would be necessary IF watchman (used by React Native) supported symlink, which is what
Here any version found in the native app has priority as the "correct" version. If not specified there, the "web-app" version is the "correct" version. For example, imagine both apps share |
Great explanation, thanks. Leave it with me a while, I've a much better idea of what's going on now. |
Thank you so much for your consideration and interest! Looking forward to what you can come up with 😀 |
Released in 9.7.4 Docs: https://jamiemason.github.io/syncpack/config/version-groups#snapto-string /cc @javascripter @chbdetta (👍🏻'd this issue) |
EPIC! Thank you so much for your work. |
You're welcome, let me know if it works as you'd expect. |
@JamieMason If I understand correctly, the {
// Snapped
"label": "snap everything to root package.json",
"dependencies": ["**"],
"packages": ["**"],
"snapTo": ["root-package-name"]
}, However, this does not seem to work with the latest version of syncpack either and I run into —
errors. Is the root workspace made available to |
I'm not sure this is it but try adding |
So upon adding logs, I figured the error is thrown for local dependencies that don't have a version in root package.json — which is expected. Shouldn't I also tried adding a
|
Thanks a lot @pastelsky that's useful, could you create a new issue to track this please? and I'll take a look |
@pastelsky that issue where a version is missing should be handled now in 12.0.0-alpha.0 |
@JamieMason I'm testing the newest version 12.0.0-alpha.0 and I'm still facing the issue @pastelsky referred above (if I understood it correctly). If you prefer I can create a separate issue for this, but since this is related to this thread of comments and related to the testing of an alpha version, I thought that discussing it here would suffice. DescriptionI need all local packages to use whatever version some specific local packages (a.k.a. "apps") are using of the local packages. And for the other local packages (that are not used by any "app"), I need them to use workspace protocol ( {
label: "Ensure all packages use whatever version the apps are using",
packages: ["**"],
dependencies: ["$LOCAL"],
dependencyTypes: ["**"],
snapTo: ["appA", "appB", "appC"],
},
{
label: "Ensure all packages use the workspace protocol for the local packages",
packages: ["**"],
dependencies: ["$LOCAL"],
dependencyTypes: ["!local"],
pinVersion: "workspace:*",
}, OutputBut this causes an error when a local package is not used by an app, something like this:
Expected outputI was expecting for ContextI can't share any repo, but I will try to describe my context in the best and simplest way possible to check if I'm approaching my necessity incorrectly. In my shared monorepo I have almost 30 packages and 3 "apps", and I use the workspace protocol for every package, with some exceptions in the apps. These apps have some particularities:
|
Description
Perhaps this is doable with the current configuration options but seems like it is not:
I have an autogenerated
package.json
that automatically sets some versions to"*"
. I want to runfix-mismatches
such that the version set on all files matches the highest none"*"
version.Suggested Solution
Have a new option on
fix-mismatches
that replaces all deps with"*"
with the latest semver range found. At the moment I am getting my wanted behavior by commenting out theif (raw === '*' || rawHighest === '*')
check in thegetHighestVersion
function.The text was updated successfully, but these errors were encountered: