mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 12:43:09 -05:00
:electron: server.js ➡️ server.ts (#2995)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import fs from 'fs';
|
||||
import NodeModule from 'module';
|
||||
import Module from 'module';
|
||||
import path from 'path';
|
||||
|
||||
import {
|
||||
@@ -14,6 +14,8 @@ import {
|
||||
UtilityProcess,
|
||||
} from 'electron';
|
||||
import isDev from 'electron-is-dev';
|
||||
// @ts-strict-ignore
|
||||
import fetch from 'node-fetch';
|
||||
import promiseRetry from 'promise-retry';
|
||||
|
||||
import { getMenu } from './menu';
|
||||
@@ -26,10 +28,6 @@ import './setRequireHook';
|
||||
|
||||
import './security';
|
||||
|
||||
const Module: typeof NodeModule & { globalPaths: string[] } =
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
NodeModule as unknown as any;
|
||||
|
||||
Module.globalPaths.push(__dirname + '/..');
|
||||
|
||||
// This allows relative URLs to be resolved to app:// which makes
|
||||
@@ -38,7 +36,7 @@ protocol.registerSchemesAsPrivileged([
|
||||
{ scheme: 'app', privileges: { standard: true } },
|
||||
]);
|
||||
|
||||
global.fetch = require('node-fetch');
|
||||
global.fetch = fetch;
|
||||
|
||||
if (!isDev || !process.env.ACTUAL_DOCUMENT_DIR) {
|
||||
process.env.ACTUAL_DOCUMENT_DIR = app.getPath('documents');
|
||||
|
||||
8
packages/desktop-electron/modules.d.ts
vendored
Normal file
8
packages/desktop-electron/modules.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
declare module 'module' {
|
||||
const globalPaths: string[];
|
||||
}
|
||||
|
||||
// bundles not available until we build them
|
||||
declare module 'loot-core/lib-dist/bundle.desktop.js' {
|
||||
const initApp: (isDev: boolean) => void;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="server.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
require('./setRequireHook');
|
||||
require('module').globalPaths.push(__dirname + '/..');
|
||||
|
||||
global.fetch = require('node-fetch');
|
||||
|
||||
// Lazy load backend code
|
||||
function getBackend() {
|
||||
// eslint-disable-next-line import/extensions
|
||||
return require('loot-core/lib-dist/bundle.desktop.js');
|
||||
}
|
||||
|
||||
const isDev = false;
|
||||
|
||||
// Start the app
|
||||
getBackend().initApp(isDev);
|
||||
20
packages/desktop-electron/server.ts
Normal file
20
packages/desktop-electron/server.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import Module from 'module';
|
||||
|
||||
// @ts-strict-ignore
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
import './setRequireHook';
|
||||
|
||||
Module.globalPaths.push(__dirname + '/..');
|
||||
global.fetch = fetch;
|
||||
|
||||
const lazyLoadBackend = async (isDev: boolean) => {
|
||||
// eslint-disable-next-line import/extensions
|
||||
const bundle = await import('loot-core/lib-dist/bundle.desktop.js');
|
||||
bundle.initApp(isDev);
|
||||
};
|
||||
|
||||
const isDev = false;
|
||||
|
||||
// Start the app
|
||||
lazyLoadBackend(isDev);
|
||||
6
upcoming-release-notes/2995.md
Normal file
6
upcoming-release-notes/2995.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Maintenance
|
||||
authors: [MikesGlitch]
|
||||
---
|
||||
|
||||
Update Electron server file to use typescript
|
||||
Reference in New Issue
Block a user