Skip to content

Commit 54ab29a

Browse files
committed
chore: auto update in linux electron base tested
1 parent 78325f1 commit 54ab29a

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

src-electron/main.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,45 @@ ipcMain.on('send-health-metric', (event, payload) => {
225225
}
226226
});
227227

228+
/**
229+
* App updater IPC handlers
230+
* These provide low-level APIs for the update-electron.js extension in Phoenix
231+
*/
232+
233+
// Get app version from config
234+
ipcMain.handle('get-app-version', (event) => {
235+
assertTrusted(event);
236+
return version;
237+
});
238+
239+
// Check if app is packaged (production build)
240+
ipcMain.handle('is-packaged', (event) => {
241+
assertTrusted(event);
242+
return app.isPackaged;
243+
});
244+
245+
// Get executable path (path to the AppImage on Linux)
246+
ipcMain.handle('get-executable-path', (event) => {
247+
assertTrusted(event);
248+
return process.execPath;
249+
});
250+
251+
// Run a shell command for update script execution
252+
ipcMain.handle('run-shell-command', async (event, command) => {
253+
assertTrusted(event);
254+
const { exec } = require('child_process');
255+
return new Promise((resolve) => {
256+
exec(command, { shell: '/bin/bash' }, (error, stdout, stderr) => {
257+
if (error) {
258+
console.error('Shell command error:', error);
259+
resolve({ code: error.code || 1, stdout, stderr });
260+
} else {
261+
resolve({ code: 0, stdout, stderr });
262+
}
263+
});
264+
});
265+
});
266+
228267
// Handle quit request from renderer
229268
app.on('quit-requested', (exitCode) => {
230269
gracefulShutdown(exitCode);

src-electron/preload.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,11 @@ contextBridge.exposeInMainWorld('electronAPI', {
160160

161161
// Health metrics for Google Analytics (sends to hidden metrics window)
162162
sendHealthMetric: (payload) => ipcRenderer.send('send-health-metric', payload),
163-
onHealthMetric: (callback) => ipcRenderer.on('health-metric', (_event, payload) => callback(payload))
163+
onHealthMetric: (callback) => ipcRenderer.on('health-metric', (_event, payload) => callback(payload)),
164+
165+
// App updater APIs - just expose primitives, logic is in update-electron.js
166+
getAppVersion: () => ipcRenderer.invoke('get-app-version'),
167+
isPackaged: () => ipcRenderer.invoke('is-packaged'),
168+
getExecutablePath: () => ipcRenderer.invoke('get-executable-path'),
169+
runShellCommand: (command) => ipcRenderer.invoke('run-shell-command', command)
164170
});

0 commit comments

Comments
 (0)