From 0c89b22e9256f292b89f1cfdbd904563726ce694 Mon Sep 17 00:00:00 2001 From: Korbs Date: Wed, 30 Aug 2023 03:11:27 -0400 Subject: [PATCH] Change directory structure and merge all configurations --- .build/devlopment/tsconfig-build.json | 8 +- .build/electron-builder.ts | 26 ++-- {astro => app/astro}/astro.config.ts | 4 +- {astro => app/astro}/src/assets/favicon.svg | 0 .../astro}/src/components/sidebar.astro | 0 {astro => app/astro}/src/env.d.ts | 0 {astro => app/astro}/src/pages/index.astro | 1 + app/astro/src/structure/app.astro | 13 ++ .../electron}/functions/crash-reporter.js | 0 {electron => app/electron}/functions/css.js | 0 .../electron}/functions/global.js | 0 {electron => app/electron}/functions/menu.js | 0 .../electron}/functions/notifications.js | 0 {electron => app/electron}/main/index.ts | 2 +- app/electron/main/window.ts | 43 +++++++ astro/src/structure/app.astro | 9 -- configuration.ts | 117 ++++++++++++++++++ configuration/app.ts | 28 ----- configuration/electron-builder.ts | 26 ---- configuration/sidebar.ts | 30 ----- configuration/theme.ts | 14 --- electron/windows/primary.ts | 24 ---- package.json | 6 +- 23 files changed, 195 insertions(+), 156 deletions(-) rename {astro => app/astro}/astro.config.ts (75%) rename {astro => app/astro}/src/assets/favicon.svg (100%) rename {astro => app/astro}/src/components/sidebar.astro (100%) rename {astro => app/astro}/src/env.d.ts (100%) rename {astro => app/astro}/src/pages/index.astro (78%) create mode 100644 app/astro/src/structure/app.astro rename {electron => app/electron}/functions/crash-reporter.js (100%) rename {electron => app/electron}/functions/css.js (100%) rename {electron => app/electron}/functions/global.js (100%) rename {electron => app/electron}/functions/menu.js (100%) rename {electron => app/electron}/functions/notifications.js (100%) rename {electron => app/electron}/main/index.ts (66%) create mode 100644 app/electron/main/window.ts delete mode 100644 astro/src/structure/app.astro create mode 100644 configuration.ts delete mode 100644 configuration/app.ts delete mode 100644 configuration/electron-builder.ts delete mode 100644 configuration/sidebar.ts delete mode 100644 configuration/theme.ts delete mode 100644 electron/windows/primary.ts diff --git a/.build/devlopment/tsconfig-build.json b/.build/devlopment/tsconfig-build.json index ee3fea6..99caae9 100644 --- a/.build/devlopment/tsconfig-build.json +++ b/.build/devlopment/tsconfig-build.json @@ -1,12 +1,10 @@ { "extends": "./tsconfig.json", "include": [ - "../../electron/main/index.ts", - "../../electron/windows/primary.ts" + "../../app/electron/main/index.ts", + "../../app/electron/main/window.ts" ], "exclude": [ - "../../.build", - "../../astro", - "../../configuration", + "../../app/astro", ] } \ No newline at end of file diff --git a/.build/electron-builder.ts b/.build/electron-builder.ts index 1ee3850..7832ce3 100644 --- a/.build/electron-builder.ts +++ b/.build/electron-builder.ts @@ -1,7 +1,5 @@ import { Configuration } from 'electron-builder' -import {meta} from '../configuration/app' -import {splash} from '../configuration/theme' -import {update, macos, linux, windows} from '../configuration/electron-builder' +import {info, splash, update, macos, linux, windows} from '../configuration' /////////////////////////////////////////////////////////////// // Please configure the "configuration/app.ts" file instead. // @@ -9,8 +7,8 @@ import {update, macos, linux, windows} from '../configuration/electron-builder' const config: Configuration = { directories: {output: ".build/output/distribution/${platform}/${arch}"}, - productName: meta.name, - appId: meta.id, + productName: info.name, + appId: info.id, // Auto Update publish: { @@ -43,16 +41,16 @@ const config: Configuration = { }, appx: { backgroundColor: splash.backgroundColor, - applicationId: meta.id, + applicationId: info.id, identityName: windows.identityName, publisher: windows.publisher, - publisherDisplayName: meta.company + publisherDisplayName: info.company }, nsis: { installerSidebar: ".build/assets/backgrounds/NSIS-Sidebar.bmp", - uninstallDisplayName: meta.name + ' - Uninstall.exe', - artifactName: meta.name + ' - Install.exe', - shortcutName: meta.name, + uninstallDisplayName: info.name + ' - Uninstall.exe', + artifactName: info.name + ' - Install.exe', + shortcutName: info.name, allowElevation: windows.requireAdmin, oneClick: windows.silent, allowToChangeInstallationDirectory: windows.allowToChangeInstallationDirectory, @@ -65,9 +63,9 @@ const config: Configuration = { linux: { icon: ".build/assets/icons/linux/icon.png", category: linux.category, - maintainer: meta.id, - vendor: meta.company, - description: meta.description, + maintainer: info.id, + vendor: info.company, + description: info.description, target: [ { target: 'AppImage', arch: 'x64' }, // Universal - x86_64 { target: 'AppImage', arch: 'arm64' }, // Universal - arm64 @@ -83,7 +81,7 @@ const config: Configuration = { ] }, snap: { - title: meta.name, + title: info.name, allowNativeWayland: true, confinement: "strict" } diff --git a/astro/astro.config.ts b/app/astro/astro.config.ts similarity index 75% rename from astro/astro.config.ts rename to app/astro/astro.config.ts index 9195e5d..65497eb 100644 --- a/astro/astro.config.ts +++ b/app/astro/astro.config.ts @@ -3,8 +3,8 @@ import { defineConfig } from 'astro/config' export default defineConfig({ compressHTML: true, publicDir: "./src/public", - outDir: "../.build/output/astro", - cacheDir: "../build/output/astro-cache/", + outDir: "../../.build/output/astro", + cacheDir: "../../build/output/astro-cache/", server: { host: false, port: 2023 diff --git a/astro/src/assets/favicon.svg b/app/astro/src/assets/favicon.svg similarity index 100% rename from astro/src/assets/favicon.svg rename to app/astro/src/assets/favicon.svg diff --git a/astro/src/components/sidebar.astro b/app/astro/src/components/sidebar.astro similarity index 100% rename from astro/src/components/sidebar.astro rename to app/astro/src/components/sidebar.astro diff --git a/astro/src/env.d.ts b/app/astro/src/env.d.ts similarity index 100% rename from astro/src/env.d.ts rename to app/astro/src/env.d.ts diff --git a/astro/src/pages/index.astro b/app/astro/src/pages/index.astro similarity index 78% rename from astro/src/pages/index.astro rename to app/astro/src/pages/index.astro index 2b3c1e9..369fa86 100644 --- a/astro/src/pages/index.astro +++ b/app/astro/src/pages/index.astro @@ -3,4 +3,5 @@ import App from '../structure/app.astro' --- +

Hello

\ No newline at end of file diff --git a/app/astro/src/structure/app.astro b/app/astro/src/structure/app.astro new file mode 100644 index 0000000..ffce94a --- /dev/null +++ b/app/astro/src/structure/app.astro @@ -0,0 +1,13 @@ +--- +import {info} from '../../../../configuration' +--- + + + + + {info.name} + + + + + \ No newline at end of file diff --git a/electron/functions/crash-reporter.js b/app/electron/functions/crash-reporter.js similarity index 100% rename from electron/functions/crash-reporter.js rename to app/electron/functions/crash-reporter.js diff --git a/electron/functions/css.js b/app/electron/functions/css.js similarity index 100% rename from electron/functions/css.js rename to app/electron/functions/css.js diff --git a/electron/functions/global.js b/app/electron/functions/global.js similarity index 100% rename from electron/functions/global.js rename to app/electron/functions/global.js diff --git a/electron/functions/menu.js b/app/electron/functions/menu.js similarity index 100% rename from electron/functions/menu.js rename to app/electron/functions/menu.js diff --git a/electron/functions/notifications.js b/app/electron/functions/notifications.js similarity index 100% rename from electron/functions/notifications.js rename to app/electron/functions/notifications.js diff --git a/electron/main/index.ts b/app/electron/main/index.ts similarity index 66% rename from electron/main/index.ts rename to app/electron/main/index.ts index 36cca84..b883c88 100644 --- a/electron/main/index.ts +++ b/app/electron/main/index.ts @@ -1,3 +1,3 @@ import {app, BrowserWindow} from "electron" -let mainWindow = require('../windows/primary') +let mainWindow = require('./window') app.whenReady().then(() => {mainWindow.launch()}) \ No newline at end of file diff --git a/app/electron/main/window.ts b/app/electron/main/window.ts new file mode 100644 index 0000000..61a1d24 --- /dev/null +++ b/app/electron/main/window.ts @@ -0,0 +1,43 @@ +import {BrowserWindow} from 'electron' +import {info, window, splash} from '../../../configuration' +if (process.env.NODE_ENV === "development") {var devTools = true} +else if (process.env.NODE_ENV === 'production') {var devTools =false} +let mainWindow : BrowserWindow + +module.exports = { + launch: function() { + mainWindow = new BrowserWindow({ + title: info.name, + width: window.width, + height: window.height, + minWidth: window.minWidth, + minHeight: window.minHeight, + show: false, + autoHideMenuBar: true, + transparent: true, + // frame: false, + // titleBarStyle: 'hiddenInset', + vibrancy: 'sidebar', // Window blur effect on macOS + backgroundMaterial: 'auto', // Window blur effect on Windows. Note: This method is only supported on Windows 11 22H2 and up. + trafficLightPosition: { x: 25, y: 28 }, // Position of Traffic Light buttons on macOS + titleBarOverlay: { // Background and Height of Windows titlebar buttons + color: splash.backgroundColor, // Background + symbolColor: 'white', // Icon + height: 44, + }, + webPreferences: { + webviewTag: true, + nodeIntegration: false, + contextIsolation: true, + devTools: devTools + } + }) + // Load Content + if (process.env.NODE_ENV === "development") {mainWindow.loadURL('http://localhost:2023')} + else if (process.env.NODE_ENV === 'production') {mainWindow.loadFile('.build/output/astro/index.html')} + + // Showing the window gracefuly + // Doc: https://www.electronjs.org/docs/latest/api/browser-window#showing-the-window-gracefully + mainWindow.once('ready-to-show', () => {mainWindow.show()}) + } +} \ No newline at end of file diff --git a/astro/src/structure/app.astro b/astro/src/structure/app.astro deleted file mode 100644 index 07af9d3..0000000 --- a/astro/src/structure/app.astro +++ /dev/null @@ -1,9 +0,0 @@ - - - - DESKTOP_APP_NAME - - - - - diff --git a/configuration.ts b/configuration.ts new file mode 100644 index 0000000..e0d9ea8 --- /dev/null +++ b/configuration.ts @@ -0,0 +1,117 @@ +/////////////////////// +// Metadata // +/////////////////////// +export const info = { + name: 'App ', + company: 'Company Name', + description: '', + id: 'org.company-name.app-name-here', // extension.domain.appname + + // Sources + website: "https://mywebsite.net/", + support: "https://mywebsite.net/help/", + source_code: "https://github.com/user/repo" +} + +//////////////////////////////// +// App Configuration // +//////////////////////////////// +export const config = { + // Notifications + notificationType: "Native", // "Custom" "Native" + + // Pushy Notifications + pushyAppId: "63e9212d7446e48a2a0e8ec0", + + // Crash Reporter + crashReportServer: "https://nexuspolestar.bugsplat.com/post/electron/crash.php" +} + +export const window = { + width: 1200, + height: 800, + minWidth: 400, + minHeight: 400, +} + +//////////////////// +// Theme // +//////////////////// +export const sidebar = { + headerFontSize: "14px", + tabFontSize: "16px", + tabHeight: "24px", + tabPositions: "Normal", // "Normal" "Centered" + size: "Normal", // "Normal" "Compact" + enableToggle: false, + enableSearch: false, +} + +export const splash = { + loadingIndicator: "Spinner", // "Spinner" "ProgressBar" "JumpingBalls" "GlowingBars" + backgroundColor: "#232323", +} + +////////////////////// +// Sidebar // +////////////////////// +export const SIDEBARTOP = [ + { + text: "Dashboard", + icon: "wand-magic-sparkles", + default: true + }, + { + text: "Files", + icon: "folder-tree" + }, + { + text: "Webview Demo", + icon: "globe" + }, + { + text: "Webview Demo 2", + icon: "globe" + }, + { + text: "iFrame Demo", + icon: "eye" + }, +] + +export const SIDEBARBOTTOM = [ + { + text: "Settings", + icon: "sliders" + } +] + +/////////////////////////////// +// Electron Builder // +/////////////////////////////// +export const update = { + channel: "latest", // Branch: "latest" "beta" "alpha" + url: '' // Point to url where build files will be stored on your server. +} + +export const macos = { + category: 'public.app-category.utilities' // https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8 +} + +export const linux = { + category: 'Utilities', // https://specifications.freedesktop.org/menu-spec/menu-spec-1.0.html/category-registry +} + +export const windows = { + // NSIS (.exe setup) + requireAdmin: false, // If you app needs to run admin tasks, which is shouldn't need to, set this to "true" + silent: false, // Ignore NSIS options below if "true" + allowToChangeInstallationDirectory: true, // Allow users to install your app anywhere + displayLanguageSelector: true, + createDesktopShortcut: false, + deleteAppDataOnUninstall: true, + + // Microsoft Store + identityName: '00000Company.AppName', + publisher: 'CN=000A00A0-A00A-0A00-AAA0-0AAA00A000AA' +} \ No newline at end of file diff --git a/configuration/app.ts b/configuration/app.ts deleted file mode 100644 index 2ea7af5..0000000 --- a/configuration/app.ts +++ /dev/null @@ -1,28 +0,0 @@ -/////////////////////// -// Metadata // -/////////////////////// -export const meta = { - name: 'App Name Here', - company: 'Company Name', - description: '', - id: 'org.company-name.app-name-here', // extension.domain.appname - - // Sources - website: "https://mywebsite.net/", - support: "https://mywebsite.net/help/", - source_code: "https://github.com/user/repo" -} - -//////////////////////////////// -// App Configuration // -//////////////////////////////// -export const config = { - // Notifications - notificationType: "Native", // "Custom" "Native" - - // Pushy Notifications - pushyAppId: "63e9212d7446e48a2a0e8ec0", - - // Crash Reporter - crashReportServer: "https://nexuspolestar.bugsplat.com/post/electron/crash.php" -} \ No newline at end of file diff --git a/configuration/electron-builder.ts b/configuration/electron-builder.ts deleted file mode 100644 index b209037..0000000 --- a/configuration/electron-builder.ts +++ /dev/null @@ -1,26 +0,0 @@ -export const update = { - channel: "latest", // Branch: "latest" "beta" "alpha" - url: '' // Point to url where build files will be stored on your server. -} - -export const macos = { - category: 'public.app-category.utilities' // https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8 -} - -export const linux = { - category: 'Utilities', // https://specifications.freedesktop.org/menu-spec/menu-spec-1.0.html/category-registry -} - -export const windows = { - // NSIS (.exe setup) - requireAdmin: false, // If you app needs to run admin tasks, which is shouldn't need to, set this to "true" - silent: false, // Ignore NSIS options below if "true" - allowToChangeInstallationDirectory: true, // Allow users to install your app anywhere - displayLanguageSelector: true, - createDesktopShortcut: false, - deleteAppDataOnUninstall: true, - - // Microsoft Store - identityName: '00000Company.AppName', - publisher: 'CN=000A00A0-A00A-0A00-AAA0-0AAA00A000AA' -} \ No newline at end of file diff --git a/configuration/sidebar.ts b/configuration/sidebar.ts deleted file mode 100644 index f37d047..0000000 --- a/configuration/sidebar.ts +++ /dev/null @@ -1,30 +0,0 @@ -export const SIDEBARTOP = [ - { - text: "Dashboard", - icon: "wand-magic-sparkles", - default: true - }, - { - text: "Files", - icon: "folder-tree" - }, - { - text: "Webview Demo", - icon: "globe" - }, - { - text: "Webview Demo 2", - icon: "globe" - }, - { - text: "iFrame Demo", - icon: "eye" - }, -] - -export const SIDEBARBOTTOM = [ - { - text: "Settings", - icon: "sliders" - } -] \ No newline at end of file diff --git a/configuration/theme.ts b/configuration/theme.ts deleted file mode 100644 index 1cce8c6..0000000 --- a/configuration/theme.ts +++ /dev/null @@ -1,14 +0,0 @@ -export const sidebar = { - headerFontSize: "14px", - tabFontSize: "16px", - tabHeight: "24px", - tabPositions: "normal", // "normal" "centered" - size: "normal", // "normal" "compact" - enableToggle: false, - enableSearch: false, -} - -export const splash = { - loadingIndicator: "Spinner", // "Spinner" "ProgressBar" "JumpingBalls" "GlowingBars" - backgroundColor: "#232323", -} \ No newline at end of file diff --git a/electron/windows/primary.ts b/electron/windows/primary.ts deleted file mode 100644 index 0b8e154..0000000 --- a/electron/windows/primary.ts +++ /dev/null @@ -1,24 +0,0 @@ -import {BrowserWindow} from "electron" -import {meta} from '../../configuration/app' -let mainWindow : BrowserWindow - -module.exports = { - launch: function() { - mainWindow = new BrowserWindow({ - title: meta.name, - width: 500, - height: 500, - webPreferences: { - webviewTag: true, - nodeIntegration: false, - contextIsolation: true - } - }) - // Load Content - if (process.env.NODE_ENV === "development") { - mainWindow.loadURL('http://localhost:2023') - } else if (process.env.NODE_ENV === 'production') { - mainWindow.loadFile('.build/output/astro/index.html') - } - } -} \ No newline at end of file diff --git a/package.json b/package.json index c2c8498..892881d 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,13 @@ "name": "nexus-polestar", "version": "0.0.1", "license": "AGPL-3.0-or-later", - "main": ".build/output/electron/electron/main/index.js", + "main": ".build/output/electron/app/electron/main/index.js", "scripts": { "start": "concurrently \"npm run tsc\" \"npm run astro:start\" \"wait-on http://localhost:2023 && npm run electron:start\"", "build": "npm run tsc && npm run astro:build && npm run electron:build", "tsc": "tsc -p .build/devlopment/tsconfig-build.json", - "astro:start": "astro dev --silent --root ./astro/", - "astro:build": "astro build --silent --root ./astro/", + "astro:start": "astro dev --silent --root ./app/astro/", + "astro:build": "astro build --silent --root ./app/astro/", "electron:start": "NODE_ENV=development electron .", "electron:build": "electron-builder --config ./.build/electron-builder.ts" },