| ... | ... | @@ -1,3 +1,19 @@ |
| 1 | import * as Schema from "effect/Schema"; |
| 2 | |
| 3 | export class CatalogDependencyResolutionError extends Schema.TaggedErrorClass<CatalogDependencyResolutionError>()( |
| 4 | "CatalogDependencyResolutionError", |
| 5 | { |
| 6 | workspacePackage: Schema.String, |
| 7 | dependencyName: Schema.String, |
| 8 | catalogSpec: Schema.String, |
| 9 | catalogKey: Schema.String, |
| 10 | }, |
| 11 | ) { |
| 12 | override get message(): string { |
| 13 | return `Unable to resolve '${this.catalogSpec}' for ${this.workspacePackage} dependency '${this.dependencyName}'. Expected key '${this.catalogKey}' in root workspace catalog.`; |
| 14 | } |
| 15 | } |
| 16 | |
| 1 | 17 | /** |
| 2 | 18 | * Resolve `catalog:` dependency specs using the workspace catalog. |
| 3 | 19 | * |
| ... | ... | @@ -7,7 +23,7 @@ |
| 7 | 23 | export function resolveCatalogDependencies( |
| 8 | 24 | dependencies: Record<string, string>, |
| 9 | 25 | catalog: Record<string, string>, |
| 10 | | label: string, |
| 26 | workspacePackage: string, |
| 11 | 27 | ): Record<string, string> { |
| 12 | 28 | return Object.fromEntries( |
| 13 | 29 | Object.entries(dependencies).map(([name, spec]) => { |
| ... | ... | @@ -20,9 +36,12 @@ export function resolveCatalogDependencies( |
| 20 | 36 | const resolved = catalog[lookupKey]; |
| 21 | 37 | |
| 22 | 38 | if (typeof resolved !== "string" || resolved.length === 0) { |
| 23 | | throw new Error( |
| 24 | | `Unable to resolve '${spec}' for ${label} dependency '${name}'. Expected key '${lookupKey}' in root workspace catalog.`, |
| 25 | | ); |
| 39 | throw new CatalogDependencyResolutionError({ |
| 40 | workspacePackage, |
| 41 | dependencyName: name, |
| 42 | catalogSpec: spec, |
| 43 | catalogKey: lookupKey, |
| 44 | }); |
| 26 | 45 | } |
| 27 | 46 | |
| 28 | 47 | return [name, resolved]; |