| 21 | const db = options.db as FumaDB; |
| 22 | |
| 23 | async function selectVersion(defaultValue?: string) { |
| 24 | const schemas = db.schemas; |
| 25 | const selected = await select({ |
| 26 | message: "Select target schema version:", |
| 27 | options: schemas.map((s, i) => { |
| 28 | let hint: string | undefined; |
| 29 | if (s.version === defaultValue) { |
| 30 | hint = "current"; |
| 31 | } else if (i === schemas.length - 1) { |
| 32 | hint = "latest"; |
| 33 | } |
| 34 | |
| 35 | return { |
| 36 | value: s.version, |
| 37 | label: s.version, |
| 38 | hint, |
| 39 | }; |
| 40 | }), |
| 41 | initialValue: defaultValue, |
| 42 | }); |
| 43 | |
| 44 | if (isCancel(selected)) { |
| 45 | cancel("Migration cancelled."); |
| 46 | process.exit(0); |
| 47 | } |
| 48 | |
| 49 | return selected; |
| 50 | } |
| 51 | |
| 52 | async function inputOutputPath(type: "sql" | "orm", suggestion: string) { |
| 53 | const result = await text({ |