mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 06:42:03 +00:00
feat: Implement worktree initialization script functionality
This commit introduces a new feature for managing worktree initialization scripts, allowing users to configure and execute scripts upon worktree creation. Key changes include: 1. **New API Endpoints**: Added endpoints for getting, setting, and deleting init scripts. 2. **Worktree Routes**: Updated worktree routes to include init script handling. 3. **Init Script Service**: Created a service to execute the init scripts asynchronously, with support for cross-platform compatibility. 4. **UI Components**: Added UI components for displaying and editing init scripts, including a dedicated section in the settings view. 5. **Event Handling**: Implemented event handling for init script execution status, providing real-time feedback in the UI. This enhancement improves the user experience by allowing automated setup processes for new worktrees, streamlining project workflows.
This commit is contained in:
@@ -1608,6 +1608,35 @@ export class HttpApiClient implements ElectronAPI {
|
||||
listDevServers: () => this.post('/api/worktree/list-dev-servers', {}),
|
||||
getPRInfo: (worktreePath: string, branchName: string) =>
|
||||
this.post('/api/worktree/pr-info', { worktreePath, branchName }),
|
||||
// Init script methods
|
||||
getInitScript: (projectPath: string) =>
|
||||
this.post('/api/worktree/init-script', { projectPath }),
|
||||
setInitScript: (projectPath: string, content: string) =>
|
||||
this.put('/api/worktree/init-script', { projectPath, content }),
|
||||
deleteInitScript: (projectPath: string) =>
|
||||
this.delete('/api/worktree/init-script', { projectPath }),
|
||||
onInitScriptEvent: (
|
||||
callback: (event: {
|
||||
type: 'worktree:init-started' | 'worktree:init-output' | 'worktree:init-completed';
|
||||
payload: unknown;
|
||||
}) => void
|
||||
) => {
|
||||
// Note: subscribeToEvent callback receives (payload) not (_, payload)
|
||||
const unsub1 = this.subscribeToEvent('worktree:init-started', (payload) =>
|
||||
callback({ type: 'worktree:init-started', payload })
|
||||
);
|
||||
const unsub2 = this.subscribeToEvent('worktree:init-output', (payload) =>
|
||||
callback({ type: 'worktree:init-output', payload })
|
||||
);
|
||||
const unsub3 = this.subscribeToEvent('worktree:init-completed', (payload) =>
|
||||
callback({ type: 'worktree:init-completed', payload })
|
||||
);
|
||||
return () => {
|
||||
unsub1();
|
||||
unsub2();
|
||||
unsub3();
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
// Git API
|
||||
|
||||
Reference in New Issue
Block a user