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