feature/IO-3066-1-scaffolding: Minor cleanup

This commit is contained in:
Dave Richer
2025-04-16 14:55:11 -04:00
parent 8b7280f66c
commit b683d054ed
10 changed files with 69 additions and 46 deletions

View File

@@ -5,27 +5,35 @@ import eslintPluginReactHooks from "eslint-plugin-react-hooks";
import eslintPluginReactRefresh from "eslint-plugin-react-refresh"; import eslintPluginReactRefresh from "eslint-plugin-react-refresh";
export default tseslint.config( export default tseslint.config(
{ ignores: ["**/node_modules", "**/dist", "**/out"] }, {ignores: ["**/node_modules", "**/dist", "**/out"]},
tseslint.configs.recommended, tseslint.configs.recommended,
eslintPluginReact.configs.flat.recommended, eslintPluginReact.configs.flat.recommended,
eslintPluginReact.configs.flat["jsx-runtime"], eslintPluginReact.configs.flat["jsx-runtime"],
{ {
settings: { settings: {
react: { react: {
version: "detect", version: "detect",
}, },
},
}, },
}, {
{ files: ["**/*.{ts,tsx}"],
files: ["**/*.{ts,tsx}"], plugins: {
plugins: { "react-hooks": eslintPluginReactHooks,
"react-hooks": eslintPluginReactHooks, "react-refresh": eslintPluginReactRefresh,
"react-refresh": eslintPluginReactRefresh, },
rules: {
...eslintPluginReactHooks.configs.recommended.rules,
...eslintPluginReactRefresh.configs.vite.rules,
},
}, },
rules: { {
...eslintPluginReactHooks.configs.recommended.rules, files: ["**/*.{js,mjs,ts,tsx,jsx,tsx}"],
...eslintPluginReactRefresh.configs.vite.rules, rules: {
"prettier/prettier": ["error", {"endOfLine": "off"}]
}
}, },
}, eslintConfigPrettier,
eslintConfigPrettier, )
);

23
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "bodyshop-desktop", "name": "bodyshop-desktop",
"version": "0.0.1-alpha.2", "version": "0.0.1-alpha.5",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "bodyshop-desktop", "name": "bodyshop-desktop",
"version": "0.0.1-alpha.2", "version": "0.0.1-alpha.5",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@apollo/client": "^3.13.6", "@apollo/client": "^3.13.6",
@@ -27,6 +27,7 @@
"@electron-toolkit/tsconfig": "^1.0.1", "@electron-toolkit/tsconfig": "^1.0.1",
"@playwright/test": "^1.51.1", "@playwright/test": "^1.51.1",
"@reduxjs/toolkit": "^2.6.1", "@reduxjs/toolkit": "^2.6.1",
"@types/cors": "^2.8.17",
"@types/express": "^5.0.1", "@types/express": "^5.0.1",
"@types/lodash": "^4.17.16", "@types/lodash": "^4.17.16",
"@types/node": "^22.14.0", "@types/node": "^22.14.0",
@@ -61,7 +62,7 @@
"react-router": "^7.5.0", "react-router": "^7.5.0",
"redux-logger": "^3.0.6", "redux-logger": "^3.0.6",
"typescript": "^5.8.3", "typescript": "^5.8.3",
"vite": "^6.2.5" "vite": "6.2.6"
} }
}, },
"node_modules/@ampproject/remapping": { "node_modules/@ampproject/remapping": {
@@ -4328,6 +4329,16 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/cors": {
"version": "2.8.17",
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz",
"integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/debug": { "node_modules/@types/debug": {
"version": "4.1.12", "version": "4.1.12",
"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz",
@@ -14789,9 +14800,9 @@
} }
}, },
"node_modules/vite": { "node_modules/vite": {
"version": "6.2.5", "version": "6.2.6",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.2.5.tgz", "resolved": "https://registry.npmjs.org/vite/-/vite-6.2.6.tgz",
"integrity": "sha512-j023J/hCAa4pRIUH6J9HemwYfjB5llR2Ps0CWeikOtdR8+pAURAk0DoJC5/mm9kd+UgdnIy7d6HE4EAvlYhPhA==", "integrity": "sha512-9xpjNl3kR4rVDZgPNdTL0/c6ao4km69a/2ihNQbcANz8RuCOK3hQBmLSJf3bRKVQjVMda+YvizNE8AwvogcPbw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {

View File

@@ -42,6 +42,7 @@
"@electron-toolkit/tsconfig": "^1.0.1", "@electron-toolkit/tsconfig": "^1.0.1",
"@playwright/test": "^1.51.1", "@playwright/test": "^1.51.1",
"@reduxjs/toolkit": "^2.6.1", "@reduxjs/toolkit": "^2.6.1",
"@types/cors": "^2.8.17",
"@types/express": "^5.0.1", "@types/express": "^5.0.1",
"@types/lodash": "^4.17.16", "@types/lodash": "^4.17.16",
"@types/node": "^22.14.0", "@types/node": "^22.14.0",
@@ -76,6 +77,6 @@
"react-router": "^7.5.0", "react-router": "^7.5.0",
"redux-logger": "^3.0.6", "redux-logger": "^3.0.6",
"typescript": "^5.8.3", "typescript": "^5.8.3",
"vite": "^6.2.5" "vite": "6.2.6"
} }
} }

View File

@@ -12,7 +12,7 @@ import { handlePartsPriceChangeRequest } from "../ppc/ppc-handler";
import { handleQuickBookRequest } from "../quickbooks-desktop/quickbooks-desktop"; import { handleQuickBookRequest } from "../quickbooks-desktop/quickbooks-desktop";
export default class LocalServer { export default class LocalServer {
private app: express.Application; private readonly app: express.Application;
private server: http.Server | null; private server: http.Server | null;
private PORT = 1337; private PORT = 1337;
@@ -149,7 +149,7 @@ export default class LocalServer {
); );
this.app.post( this.app.post(
"/refresh", "/refresh",
async (req: express.Request, res: express.Response) => { async (_req: express.Request, res: express.Response) => {
log.debug("[HTTP Server] Refresh request received"); log.debug("[HTTP Server] Refresh request received");
try { try {
await handleShopMetaDataFetch(true); await handleShopMetaDataFetch(true);

View File

@@ -67,6 +67,7 @@ function createWindow(): void {
const template: Electron.MenuItemConstructorOptions[] = [ const template: Electron.MenuItemConstructorOptions[] = [
// { role: 'appMenu' } // { role: 'appMenu' }
// @ts-ignore
...(isMac ...(isMac
? [ ? [
{ {
@@ -89,7 +90,9 @@ function createWindow(): void {
{ {
label: "File", label: "File",
submenu: [ submenu: [
// @ts-ignore
...(!isMac ? [{ role: "about" }] : []), ...(!isMac ? [{ role: "about" }] : []),
// @ts-ignore
isMac ? { role: "close" } : { role: "quit" }, isMac ? { role: "close" } : { role: "quit" },
], ],
}, },
@@ -103,6 +106,7 @@ function createWindow(): void {
{ role: "cut" }, { role: "cut" },
{ role: "copy" }, { role: "copy" },
{ role: "paste" }, { role: "paste" },
// @ts-ignore
...(isMac ...(isMac
? [ ? [
{ role: "pasteAndMatchStyle" }, { role: "pasteAndMatchStyle" },
@@ -120,6 +124,7 @@ function createWindow(): void {
// { role: 'viewMenu' } // { role: 'viewMenu' }
{ {
label: "View", label: "View",
// @ts-ignore
submenu: [ submenu: [
{ role: "reload" }, { role: "reload" },
{ role: "forceReload" }, { role: "forceReload" },
@@ -134,6 +139,7 @@ function createWindow(): void {
}, },
{ {
label: "Application", label: "Application",
// @ts-ignore
submenu: [ submenu: [
{ {
label: "Open on Startup", label: "Open on Startup",
@@ -235,6 +241,7 @@ function createWindow(): void {
submenu: [ submenu: [
{ role: "minimize" }, { role: "minimize" },
{ role: "zoom" }, { role: "zoom" },
// @ts-ignore
...(isMac ...(isMac
? [ ? [
{ type: "separator" }, { type: "separator" },
@@ -257,6 +264,7 @@ function createWindow(): void {
// Update the menu to make the hidden item visible // Update the menu to make the hidden item visible
// Find the menu item dynamically by its id // Find the menu item dynamically by its id
const fileMenu = template.find((item) => item.label === "Application"); const fileMenu = template.find((item) => item.label === "Application");
// @ts-ignore
const hiddenItem = fileMenu?.submenu?.find( const hiddenItem = fileMenu?.submenu?.find(
(item) => item.id === "development", (item) => item.id === "development",
); );
@@ -375,7 +383,7 @@ app.whenReady().then(async () => {
// module.someFunction() // module.someFunction()
log.debug("Successfully loaded ipcMainConfig", module); log.debug("Successfully loaded ipcMainConfig", module);
} catch (error) { } catch (error) {
log.error("Failed to load ipcMainconfig", { log.error("Failed to load ipcMainConfig", {
...ErrorTypeCheck(error), ...ErrorTypeCheck(error),
}); });
} }
@@ -409,7 +417,7 @@ app.whenReady().then(async () => {
// if (import.meta.env.DEV) { // if (import.meta.env.DEV) {
// // Useful for some dev/debugging tasks, but download can // // Useful for some dev/debugging tasks, but download can
// // not be validated becuase dev app is not signed // // not be validated because dev app is not signed
// autoUpdater.channel = "alpha"; // autoUpdater.channel = "alpha";
// autoUpdater.updateConfigPath = path.join( // autoUpdater.updateConfigPath = path.join(
// __dirname, // __dirname,

View File

@@ -38,8 +38,7 @@ const SettingsWatchedFilePathsRemove = async (
}; };
const SettingsWatchedFilePathsGet = async (): Promise<string[]> => { const SettingsWatchedFilePathsGet = async (): Promise<string[]> => {
const filepaths: string[] = Store.get("settings.filepaths") || []; return Store.get("settings.filepaths") || [];
return filepaths;
}; };
const SettingsWatcherPollingGet = async (): Promise<{ const SettingsWatcherPollingGet = async (): Promise<{
@@ -66,7 +65,7 @@ const SettingsWatcherPollingSet = async (
//Restart the watcher with these new settings. //Restart the watcher with these new settings.
await StopWatcher(); await StopWatcher();
StartWatcher(); await StartWatcher();
return { enabled, interval }; return { enabled, interval };
}; };

View File

@@ -36,7 +36,7 @@ const ipcMainHandleAuthStateChanged = async (
} }
} catch (error) { } catch (error) {
log.error( log.error(
"Error while querying active bodyshop or masterdata", "Error while querying active bodyshop or master data",
errorTypeCheck(error), errorTypeCheck(error),
); );
sendIpcToRenderer( sendIpcToRenderer(
@@ -48,7 +48,7 @@ const ipcMainHandleAuthStateChanged = async (
}; };
const handleShopMetaDataFetch = async ( const handleShopMetaDataFetch = async (
reloadWindow: boolean, reloadWindow?: boolean,
): Promise<void> => { ): Promise<void> => {
try { try {
log.debug("Requery shop information & master data."); log.debug("Requery shop information & master data.");

View File

@@ -3,9 +3,9 @@ import fs from "fs";
import path from "path"; import path from "path";
import errorTypeCheck from "../../util/errorTypeCheck"; import errorTypeCheck from "../../util/errorTypeCheck";
const createdDirectoryIfNotExist = async (dirpath: string) => { const createdDirectoryIfNotExist = async (dirPath: string) => {
try { try {
const directoryPath = path.dirname(dirpath); const directoryPath = path.dirname(dirPath);
if (!fs.existsSync(directoryPath)) { if (!fs.existsSync(directoryPath)) {
log.info(`Directory does not exist. Creating: ${directoryPath}`); log.info(`Directory does not exist. Creating: ${directoryPath}`);
fs.mkdirSync(directoryPath, { recursive: true }); fs.mkdirSync(directoryPath, { recursive: true });

View File

@@ -1,9 +1,8 @@
import { BrowserWindow } from "electron"; import {BrowserWindow} from "electron";
import log from "electron-log/main"; import log from "electron-log/main";
const getMainWindow = (): Electron.BrowserWindow => { const getMainWindow = (): Electron.BrowserWindow => {
const mainWindow = BrowserWindow.getAllWindows()[0]; return BrowserWindow.getAllWindows()[0];
return mainWindow;
}; };
const sendIpcToRenderer = (ipcMessage: string, ...args: any[]): void => { const sendIpcToRenderer = (ipcMessage: string, ...args: any[]): void => {

View File

@@ -13,12 +13,9 @@ function uppercaseObjectKeys<T extends Record<string, any>>(
return Object.entries(obj).reduce( return Object.entries(obj).reduce(
(result, [key, value]) => { (result, [key, value]) => {
const uppercaseKey = key.toUpperCase(); const uppercaseKey = key.toUpperCase();
const newValue = result[uppercaseKey] = typeof value === "object" && value !== null
typeof value === "object" && value !== null
? uppercaseObjectKeys(value) ? uppercaseObjectKeys(value)
: value; : value;
result[uppercaseKey] = newValue;
return result; return result;
}, },
{} as Record<string, any>, {} as Record<string, any>,