feat: first cut at publishing tool
This commit is contained in:
@@ -18,6 +18,7 @@ import { APP_MENU_ACTION_EVENT_MAP, APP_MENU_WEB_CONTENTS_ACTIONS, type AppMenuA
|
||||
import { generateBlogmarkBookmarkletSource } from '../shared/blogmark';
|
||||
import { registerMetadataDiffHandlers } from './metadataDiffHandlers';
|
||||
import { registerBlogHandlers } from './blogHandlers';
|
||||
import { registerPublishHandlers } from './publishHandlers';
|
||||
|
||||
/**
|
||||
* Wrap an IPC handler so that "Database is closing" errors during shutdown
|
||||
@@ -1433,6 +1434,7 @@ export function registerIpcHandlers(): void {
|
||||
|
||||
registerMetadataDiffHandlers(safeHandle);
|
||||
registerBlogHandlers(safeHandle);
|
||||
registerPublishHandlers(safeHandle);
|
||||
|
||||
// ============ Event Forwarding ============
|
||||
|
||||
|
||||
30
src/main/ipc/publishHandlers.ts
Normal file
30
src/main/ipc/publishHandlers.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { getProjectEngine } from '../engine/ProjectEngine';
|
||||
import { getPublishEngine, type PublishCredentials } from '../engine/PublishEngine';
|
||||
import { taskManager } from '../engine/TaskManager';
|
||||
|
||||
type SafeHandle = (channel: string, handler: (...args: any[]) => Promise<any>) => void;
|
||||
|
||||
export function registerPublishHandlers(safeHandle: SafeHandle): void {
|
||||
safeHandle('publish:uploadSite', async (_event: unknown, credentials: PublishCredentials) => {
|
||||
const projectEngine = getProjectEngine();
|
||||
const project = await projectEngine.getActiveProject();
|
||||
if (!project) {
|
||||
throw new Error('No active project');
|
||||
}
|
||||
|
||||
const publishEngine = getPublishEngine();
|
||||
publishEngine.setProjectContext(project.id, project.dataPath!);
|
||||
|
||||
return taskManager.runTask({
|
||||
id: `publish-upload-${Date.now()}`,
|
||||
name: 'Upload Site',
|
||||
groupId: 'publish',
|
||||
groupName: 'Site Publishing',
|
||||
execute: async (onProgress) => {
|
||||
return publishEngine.uploadSite(credentials, (progress, message) => {
|
||||
onProgress(progress, message);
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user