Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] :electron: hosting the sync-server with the desktop app (POC) #3631

Draft
wants to merge 71 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
20e2ef2
start to this epic idea
MikesGlitch Oct 10, 2024
361200e
bits
MikesGlitch Oct 10, 2024
c718b2c
add a note
MikesGlitch Oct 10, 2024
e32fb8b
server starting button erroring on imports due to env differences
MikesGlitch Oct 11, 2024
1802818
working now
MikesGlitch Oct 11, 2024
194f50d
using node_modules and allowing electron-builder to bundle it
MikesGlitch Oct 12, 2024
7782f2d
ensuring deps are built before running server
MikesGlitch Oct 12, 2024
55e9113
unneeded mode
MikesGlitch Oct 12, 2024
3266319
exposing sync server via ngrok
MikesGlitch Oct 13, 2024
b3e6d28
log msg for dev
MikesGlitch Oct 13, 2024
ce5225e
using official ngrok package for smaller size
MikesGlitch Oct 14, 2024
07e7730
comment
MikesGlitch Oct 14, 2024
b9c14dc
ngrok bits
MikesGlitch Oct 14, 2024
c6d2f59
correcting ngrok conditional logic
MikesGlitch Oct 14, 2024
8eb145f
ngrok settings optional
MikesGlitch Oct 14, 2024
23fdf04
bits
MikesGlitch Oct 14, 2024
58aa350
moving server folders
MikesGlitch Oct 15, 2024
2dc34de
package process
MikesGlitch Oct 15, 2024
4873c9c
merge
MikesGlitch Oct 15, 2024
5d01674
what an ordeal
MikesGlitch Oct 15, 2024
8eca643
fixes
MikesGlitch Oct 17, 2024
b83a3c6
reenable sync server now tests have passed
MikesGlitch Oct 17, 2024
39d060b
splitting up server management to allow config of desktop app server …
MikesGlitch Oct 18, 2024
45d9fae
fix the port thing
MikesGlitch Oct 20, 2024
0a333ed
tunnel erorrs cleanup
MikesGlitch Oct 20, 2024
a78ad88
trickle in
MikesGlitch Oct 20, 2024
804425f
resetting state if not available to avoid hard crashes
MikesGlitch Oct 21, 2024
a1de454
small updates until I figure out what the issue is
MikesGlitch Oct 21, 2024
e1c5a68
merge
MikesGlitch Oct 22, 2024
1178bec
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch Oct 23, 2024
17f520f
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch Oct 24, 2024
6d0363f
settings
MikesGlitch Oct 27, 2024
7d5af1f
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch Oct 27, 2024
f3c2743
remove it
MikesGlitch Oct 27, 2024
76b2918
thoughts
MikesGlitch Oct 27, 2024
9ff112c
waiting on sync server before starting
MikesGlitch Oct 28, 2024
312e85e
fix timeout message
MikesGlitch Oct 30, 2024
4f667d0
note
MikesGlitch Oct 30, 2024
a5f2f8b
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch Nov 3, 2024
79f648f
use env variable instead of https agent for default fetch
MikesGlitch Nov 4, 2024
2265164
updating root ca impl to use node env variable for more support
MikesGlitch Nov 4, 2024
4400ff1
release notes
MikesGlitch Nov 4, 2024
98174bb
removing node-fetch
MikesGlitch Nov 4, 2024
26adfec
clean up
MikesGlitch Nov 4, 2024
8cfd39f
error message
MikesGlitch Nov 4, 2024
4dd1fe0
merg
MikesGlitch Nov 4, 2024
78fbebe
adding the sync server into the workspace as an experiment
MikesGlitch Nov 4, 2024
5886678
merge
MikesGlitch Nov 4, 2024
6513207
update server
MikesGlitch Nov 4, 2024
99b6cb2
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch Nov 7, 2024
4036b57
responsive
MikesGlitch Nov 7, 2024
c718e67
test
MikesGlitch Nov 7, 2024
2a1bb2c
put it back
MikesGlitch Nov 7, 2024
8847f64
fix rootpath
MikesGlitch Nov 9, 2024
0ce8c57
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch Nov 11, 2024
8037e03
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch Nov 12, 2024
6671e2c
merge
MikesGlitch Nov 12, 2024
207d63e
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch Nov 14, 2024
b539e7b
merge
MikesGlitch Nov 19, 2024
99a97c6
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch Nov 19, 2024
2656d65
bits
MikesGlitch Nov 20, 2024
3f70a9f
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch Nov 21, 2024
64b007f
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch Nov 22, 2024
3ada82a
update server
MikesGlitch Nov 23, 2024
53f1054
yarn lock
MikesGlitch Nov 23, 2024
2d27e1d
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch Nov 24, 2024
f14a118
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch Nov 30, 2024
3e3d1cf
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch Dec 2, 2024
862c765
Merge branch 'master' of https://github.com/MikesGlitch/actual into e…
MikesGlitch Dec 6, 2024
c2aad50
updated server
MikesGlitch Dec 6, 2024
606fe7e
update the lock
MikesGlitch Dec 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
start to this epic idea
  • Loading branch information
MikesGlitch committed Oct 10, 2024
commit 20e2ef27b2e72858ca673131de2ca0197d862040
1 change: 1 addition & 0 deletions packages/desktop-client/src/browser-preload.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ global.Actual = {
openURLInBrowser: url => {
window.open(url, '_blank');
},
downloadActualServer: () => {},
onEventFromMain: () => {},
applyAppUpdate: () => {},
updateAppMenu: () => {},
Expand Down
28 changes: 28 additions & 0 deletions packages/desktop-electron/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
} from './window-state';

import './security';
import AdmZip from 'adm-zip';

const isDev = !app.isPackaged; // dev mode if not packaged

Expand Down Expand Up @@ -373,6 +374,33 @@ ipcMain.handle('open-external-url', (event, url) => {
shell.openExternal(url);
});

ipcMain.handle(
'download-actual-server',
async (_event, payload: { releaseVersion: string }) => {
console.info({ payload });
const downloadUrl = `https://github.com/MikesGlitch/actual-server/releases/download/${payload.releaseVersion}/${payload.releaseVersion}-server-sync-dist.zip`;

try {
const res = await fetch(downloadUrl);
const arrBuffer = await res.arrayBuffer();
const zipped = new AdmZip(Buffer.from(arrBuffer));
console.info(
'actual-server will be installed here:',
process.env.ACTUAL_DATA_DIR,
);
zipped.extractAllTo(
process.env.ACTUAL_DATA_DIR + '/actual-server-releases',
true,
false,
);
return { error: undefined };
} catch (error) {
console.error('Error retrieving actual-server:', error);
return { error };
}
},
);

ipcMain.on('message', (_event, msg) => {
if (!serverProcess) {
return;
Expand Down
1 change: 1 addition & 0 deletions packages/desktop-electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"npmRebuild": false
},
"dependencies": {
"adm-zip": "^0.5.10",
"better-sqlite3": "^9.6.0",
"fs-extra": "^11.2.0",
"node-fetch": "^2.7.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/desktop-electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ contextBridge.exposeInMainWorld('Actual', {
ipcRenderer.invoke('open-external-url', url);
},

downloadActualServer: async (releaseVersion: string) => {
await ipcRenderer.invoke('download-actual-server', {
releaseVersion,
});
},

onEventFromMain: (type: string, handler: (...args: unknown[]) => void) => {
ipcRenderer.on(type, handler);
},
Expand Down
1 change: 1 addition & 0 deletions packages/loot-core/typings/window.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ declare global {
IS_FAKE_WEB: boolean;
ACTUAL_VERSION: string;
openURLInBrowser: (url: string) => void;
downloadActualServer: (releaseVersion: string) => Promise<void>;
saveFile: (
contents: string | Buffer,
filename: string,
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8432,6 +8432,7 @@ __metadata:
"@electron/rebuild": "npm:3.6.0"
"@types/copyfiles": "npm:^2"
"@types/fs-extra": "npm:^11"
adm-zip: "npm:^0.5.10"
better-sqlite3: "npm:^9.6.0"
copyfiles: "npm:^2.4.1"
cross-env: "npm:^7.0.3"
Expand Down