| author | |
| committer | |
| log | 1f2b10c25bc400461e6c114c2c7236e91996225c |
| tree | 23e108e06a941c6e80e0192d215a1784da83d564 |
| parent | a7a2230c33fbec9d6616a5de26f09e1fa8856c05 |
| signature | Signed by PGP key B5690EEEBB952194 |
2 files changed, 29 insertions(+), 4 deletions(-)
scripts/lib/resolve-catalog.test.ts+23| ... | @@ -34,4 +34,27 @@ describe("resolveCatalogDependencies", () => { | ... | @@ -34,4 +34,27 @@ describe("resolveCatalogDependencies", () => { |
| 34 | /Expected key 'missing' in root workspace catalog/, | 34 | /Expected key 'missing' in root workspace catalog/, |
| 35 | ); | 35 | ); |
| 36 | }); | 36 | }); |
| 37 | |||
| 38 | it("resolves version-qualified overrides without changing their selectors", () => { | ||
| 39 | assert.deepStrictEqual( | ||
| 40 | resolveCatalogDependencies( | ||
| 41 | { | ||
| 42 | "undici@^8": "catalog:", | ||
| 43 | "ws@^8": "catalog:", | ||
| 44 | "@clerk/backend@^3": "catalog:", | ||
| 45 | "@scope/parent@^1>undici@^8": "catalog:", | ||
| 46 | "parent@^1>@clerk/backend@^3": "catalog:", | ||
| 47 | }, | ||
| 48 | { ...catalog, undici: "8.11.2", ws: "8.21.0" }, | ||
| 49 | "apps/desktop", | ||
| 50 | ), | ||
| 51 | { | ||
| 52 | "undici@^8": "8.11.2", | ||
| 53 | "ws@^8": "8.21.0", | ||
| 54 | "@clerk/backend@^3": "3.18.1", | ||
| 55 | "@scope/parent@^1>undici@^8": "8.11.2", | ||
| 56 | "parent@^1>@clerk/backend@^3": "3.18.1", | ||
| 57 | }, | ||
| 58 | ); | ||
| 59 | }); | ||
| 37 | }); | 60 | }); |
scripts/lib/resolve-catalog.ts+6-4| ... | @@ -32,10 +32,12 @@ export function resolveCatalogDependencies( | ... | @@ -32,10 +32,12 @@ export function resolveCatalogDependencies( |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | const catalogKey = spec.slice("catalog:".length).trim(); | 34 | const catalogKey = spec.slice("catalog:".length).trim(); |
| 35 | // An override key can be a selector such as `@scope/parent>effect`; like | 35 | // Overrides can include a parent selector and a version range. A bare |
| 36 | // pnpm, a bare `catalog:` there means the catalog entry of the package | 36 | // `catalog:` looks up the final package name, keeping its scope intact. |
| 37 | // the selector ends in. | 37 | const selector = name.split(">").at(-1) ?? name; |
| 38 | const lookupKey = catalogKey.length > 0 ? catalogKey : (name.split(">").at(-1) ?? name); | 38 | const versionIndex = selector.indexOf("@", 1); |
| 39 | const packageName = versionIndex === -1 ? selector : selector.slice(0, versionIndex); | ||
| 40 | const lookupKey = catalogKey.length > 0 ? catalogKey : packageName; | ||
| 39 | const resolved = catalog[lookupKey]; | 41 | const resolved = catalog[lookupKey]; |
| 40 | 42 | ||
| 41 | if (typeof resolved !== "string" || resolved.length === 0) { | 43 | if (typeof resolved !== "string" || resolved.length === 0) { |