Files
aurora-dockside/src/main/ipc/modules.ts
T

52 lines
1.9 KiB
TypeScript
Raw Normal View History

2026-08-14 12:08:21 -05:00
import { dialog, ipcMain } from 'electron'
2026-08-13 14:32:54 -05:00
import { getProjectRoot, listInstalledModules, listModules, scaffoldApplicationModule, setModule } from '../auroraEngine'
import { runCommandStreamed } from '../commandRunner'
2026-08-14 12:08:21 -05:00
import { installModulePackage, uninstallModulePackage } from '../moduleRegistry'
2026-08-13 14:32:54 -05:00
export function registerModulesIpc(): void {
ipcMain.handle('modules:listRegistry', () => listModules())
2026-08-14 12:08:21 -05:00
ipcMain.handle('modules:pickAndInstallPackage', async () => {
const picked = await dialog.showOpenDialog({ properties: ['openDirectory'] })
if (picked.canceled || !picked.filePaths[0]) return null
return installModulePackage(picked.filePaths[0])
})
ipcMain.handle('modules:installPackage', (_event, source: string) => installModulePackage(source))
ipcMain.handle('modules:uninstallPackage', (_event, id: string) => uninstallModulePackage(id))
2026-08-13 14:32:54 -05:00
ipcMain.handle('modules:listInstalled', (_event, name: string) => listInstalledModules(name))
ipcMain.handle(
'modules:install',
async (
event,
operationId: string,
name: string,
moduleId: string,
settings: Record<string, string | number | boolean>
) => {
await setModule(name, moduleId, true, settings)
await scaffoldApplicationModule(name, moduleId)
const root = await getProjectRoot(name)
return runCommandStreamed(
operationId,
'docker',
['compose', '-f', `${root}/.aurora/compose.yaml`, 'up', '-d', '--remove-orphans'],
event.sender,
{ cwd: root }
)
}
)
ipcMain.handle(
'modules:remove',
async (event, operationId: string, name: string, moduleId: string) => {
await setModule(name, moduleId, false)
const root = await getProjectRoot(name)
return runCommandStreamed(
operationId,
'docker',
['compose', '-f', `${root}/.aurora/compose.yaml`, 'up', '-d', '--remove-orphans'],
event.sender,
{ cwd: root }
)
}
)
}