Merge pull request #2167 from RoboSats/desktop-app-fix

Desktop app fix 2
This commit is contained in:
KoalaSat
2025-08-12 12:50:41 +00:00
committed by GitHub
4 changed files with 99 additions and 29 deletions

View File

@ -42,6 +42,7 @@ jobs:
npm install
- name: 'Build'
run: |
export NODE_OPTIONS="--max-old-space-size=4096"
cd frontend
npm run build
- name: 'Archive Django Static Build Results'
@ -65,7 +66,7 @@ jobs:
path: |
desktopApp/static
desktopApp/*.html
- name: 'Archive Django Static Build Results'
- name: 'Archive Web Static Build Results'
uses: actions/upload-artifact@v4
with:
name: web-main-static

View File

@ -25,6 +25,7 @@
"country-flag-icons": "^1.5.19",
"date-fns": "^4.1.0",
"file-replace-loader": "^1.4.2",
"fs-extra": "^11.3.1",
"i18next": "^25.2.1",
"i18next-browser-languagedetector": "^8.2.0",
"i18next-http-backend": "^3.0.2",
@ -65,6 +66,7 @@
"@eslint/compat": "^1.3.1",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.30.1",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.14",
"@types/latlon-geohash": "^2.0.4",
"@types/leaflet": "^1.9.18",
@ -4419,6 +4421,17 @@
"integrity": "sha512-xFU8ZXTw4gd358lb2jw25nxY9QAgqn2+bKKjKOYfNCzN4DKCFetK7sPtrlpg66Ywe3vWY9FNxprZawAh9wfJ3g==",
"license": "MIT"
},
"node_modules/@types/fs-extra": {
"version": "11.0.4",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.4.tgz",
"integrity": "sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/jsonfile": "*",
"@types/node": "*"
}
},
"node_modules/@types/geojson": {
"version": "7946.0.16",
"resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz",
@ -4494,6 +4507,16 @@
"dev": true,
"license": "MIT"
},
"node_modules/@types/jsonfile": {
"version": "6.1.4",
"resolved": "https://registry.npmjs.org/@types/jsonfile/-/jsonfile-6.1.4.tgz",
"integrity": "sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/latlon-geohash": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/latlon-geohash/-/latlon-geohash-2.0.4.tgz",
@ -8626,6 +8649,20 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/fs-extra": {
"version": "11.3.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.1.tgz",
"integrity": "sha512-eXvGGwZ5CL17ZSwHWd3bbgk7UUpF6IFHtP57NYYakPvHOs8GDgDe5KJI36jIJzDkJ6eJjuzRA8eBQb6SkKue0g==",
"license": "MIT",
"dependencies": {
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
"universalify": "^2.0.0"
},
"engines": {
"node": ">=14.14"
}
},
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@ -8889,7 +8926,6 @@
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
"dev": true,
"license": "ISC"
},
"node_modules/graphemer": {
@ -10562,6 +10598,18 @@
"node": ">=6"
}
},
"node_modules/jsonfile": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
"license": "MIT",
"dependencies": {
"universalify": "^2.0.0"
},
"optionalDependencies": {
"graceful-fs": "^4.1.6"
}
},
"node_modules/jsx-ast-utils": {
"version": "3.3.5",
"resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz",
@ -16304,6 +16352,15 @@
"node": ">=4"
}
},
"node_modules/universalify": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
"integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
"license": "MIT",
"engines": {
"node": ">= 10.0.0"
}
},
"node_modules/unrs-resolver": {
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/unrs-resolver/-/unrs-resolver-1.7.3.tgz",

View File

@ -24,6 +24,7 @@
"@eslint/compat": "^1.3.1",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.30.1",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.14",
"@types/latlon-geohash": "^2.0.4",
"@types/leaflet": "^1.9.18",
@ -73,6 +74,7 @@
"country-flag-icons": "^1.5.19",
"date-fns": "^4.1.0",
"file-replace-loader": "^1.4.2",
"fs-extra": "^11.3.1",
"i18next": "^25.2.1",
"i18next-browser-languagedetector": "^8.2.0",
"i18next-http-backend": "^3.0.2",

View File

@ -1,13 +1,21 @@
import path from 'path';
import { Configuration } from 'webpack';
import { Compiler, Configuration } from 'webpack';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import { version } from './package.json';
import { Buffer } from 'buffer';
import fs from 'fs-extra';
// Declare __dirname for TypeScript
declare const __dirname: string;
const sourceBuild = 'static/frontend';
const outputPaths: string[] = [
path.resolve(__dirname, '../nodeapp/static'),
path.resolve(__dirname, '../desktopApp/static'),
path.resolve(__dirname, '../web/static'),
];
const config: Configuration = {
entry: './src/index.js',
module: {
@ -38,11 +46,11 @@ const configNode = (env: any, argv: { mode: string }): Configuration => {
return {
...config,
output: {
path: path.resolve(__dirname, 'static/frontend'),
path: path.resolve(__dirname, sourceBuild),
filename:
argv.mode === 'production' ? `main.v${version}.[contenthash].js` : `main.v${version}.js`,
clean: true,
publicPath: '/static/frontend/',
publicPath: '/' + sourceBuild,
},
plugins: [
// Django
@ -91,14 +99,7 @@ const configNode = (env: any, argv: { mode: string }): Configuration => {
robosatsSettings: 'selfhosted-pro',
basePath: '/',
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, 'static'),
to: path.resolve(__dirname, '../nodeapp/static'),
},
],
}),
// Desktop App
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
@ -111,14 +112,7 @@ const configNode = (env: any, argv: { mode: string }): Configuration => {
robosatsSettings: 'desktop-basic',
basePath: '/',
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, 'static'),
to: path.resolve(__dirname, '../desktopApp/static'),
},
],
}),
// Web App
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
@ -142,14 +136,30 @@ const configNode = (env: any, argv: { mode: string }): Configuration => {
robosatsSettings: 'web-pro',
basePath: '/',
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, 'static'),
to: path.resolve(__dirname, '../web/static'),
},
],
}),
{
apply: (compiler: Compiler) => {
compiler.hooks.afterEmit.tapAsync('CopyFilesPlugin', (_compilation, callback) => {
Promise.all(
outputPaths.map((outputPath) => {
const sourceDir = path.resolve(__dirname, sourceBuild);
return fs
.copy(sourceDir, outputPath)
.then(() => {
console.log(`Files copied to ${outputPath}`);
})
.catch((err) => {
console.error(`Error copying files to ${outputPath}:`, err);
});
}),
)
.then(() => {
callback();
})
.catch(callback);
});
},
},
],
};
};