()
| 20 | } |
| 21 | |
| 22 | export function registerIPC() { |
| 23 | registerDialogHandlers() |
| 24 | registerSystemHandlers() |
| 25 | registerPrettierHandlers() |
| 26 | registerFsHandlers() |
| 27 | registerThemeHandlers() |
| 28 | registerSpacesHandlers() |
| 29 | registerHttpHandlers() |
| 30 | |
| 31 | ipcMain.on('main-menu:update-context', (_, payload: MainMenuContext) => { |
| 32 | updateMainMenu(payload) |
| 33 | }) |
| 34 | |
| 35 | ipcMain.handle('db:migrate-to-markdown', async (_, sqliteDbPath?: string) => { |
| 36 | const storagePath = store.preferences.get('storage.rootPath') as string |
| 37 | const dbPath |
| 38 | = typeof sqliteDbPath === 'string' && sqliteDbPath.trim() |
| 39 | ? sqliteDbPath |
| 40 | : `${storagePath}/massCode.db` |
| 41 | |
| 42 | if (!isSqliteFile(dbPath)) { |
| 43 | throw new Error( |
| 44 | 'No valid massCode.db found. ' |
| 45 | + 'Select a massCode.db file from a previous version and try again.', |
| 46 | ) |
| 47 | } |
| 48 | |
| 49 | const { closeDB } = lazyRequire('../db') as typeof import('../db') |
| 50 | const { migrateSqliteToMarkdownStorage } = lazyRequire( |
| 51 | '../storage/providers/markdown', |
| 52 | ) as typeof import('../storage/providers/markdown') |
| 53 | |
| 54 | try { |
| 55 | return migrateSqliteToMarkdownStorage(dbPath) |
| 56 | } |
| 57 | finally { |
| 58 | closeDB() |
| 59 | } |
| 60 | }) |
| 61 | } |
no test coverage detected