| 13 | const compareStrings = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0 |
| 14 | |
| 15 | const parseAnnotation = (id: string, value: unknown, file: string): MigrationAnnotation => { |
| 16 | if ( |
| 17 | typeof value !== "object" || value === null || |
| 18 | typeof Reflect.get(value, "replacement") !== "string" || |
| 19 | typeof Reflect.get(value, "note") !== "string" || |
| 20 | (Reflect.get(value, "example") !== undefined && typeof Reflect.get(value, "example") !== "string") |
| 21 | ) { |
| 22 | throw new Error(`Invalid annotation for ${id} in ${file}`) |
| 23 | } |
| 24 | return { |
| 25 | replacement: Reflect.get(value, "replacement"), |
| 26 | note: Reflect.get(value, "note"), |
| 27 | ...(Reflect.get(value, "example") === undefined ? {} : { example: Reflect.get(value, "example") }) |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | const loadAnnotationsInternal = Effect.fnUntraced(function*(directory: string) { |
| 32 | const fs = yield* FileSystem.FileSystem |