From 4462cefb548175bd7c1a39ddec9a42d2ea843db8 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Mon, 24 Mar 2025 08:28:11 -0700 Subject: [PATCH] Updates for packaging. --- electron-builder.yml | 5 +++-- src/main/decoder/decoder.ts | 36 +++++++++++++++++------------------- src/main/index.ts | 6 ++++++ 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/electron-builder.yml b/electron-builder.yml index 8e55311..3b22345 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -13,6 +13,7 @@ asarUnpack: - resources/** win: executableName: bodyshop-desktop + nsis: artifactName: ${name}-${version}-setup.${ext} shortcutName: ${productName} @@ -26,7 +27,7 @@ mac: - NSMicrophoneUsageDescription: Application requests access to the device's microphone. - NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder. - NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder. - notarize: false + dmg: artifactName: ${name}-${version}.${ext} linux: @@ -41,7 +42,7 @@ appImage: npmRebuild: false publish: provider: s3 - bucket: bodyshop-desktop-updater + bucket: imex-partner region: ca-central-1 electronDownload: mirror: https://npmmirror.com/mirrors/electron/ diff --git a/src/main/decoder/decoder.ts b/src/main/decoder/decoder.ts index 12f004d..4e273e9 100644 --- a/src/main/decoder/decoder.ts +++ b/src/main/decoder/decoder.ts @@ -135,27 +135,25 @@ async function ImportJob(filepath: string): Promise { delete jobObject.clmt_ph2; delete jobObject.clmt_ea; - // Save jobObject to a timestamped JSON file - const timestamp = new Date() - .toISOString() - .replace(/:/g, "-") - .replace(/\..+/, ""); - const fileName = `job_${timestamp}_${parsedFilePath.name}.json`; - const logsDir = path.join(process.cwd(), "logs"); + if (import.meta.env.DEV) { + // Save jobObject to a timestamped JSON file + const timestamp = new Date() + .toISOString() + .replace(/:/g, "-") + .replace(/\..+/, ""); + const fileName = `job_${timestamp}_${parsedFilePath.name}.json`; + const logsDir = path.join(process.cwd(), "logs"); - // Create logs directory if it doesn't exist - if (!fs.existsSync(logsDir)) { - fs.mkdirSync(logsDir, { recursive: true }); + // Create logs directory if it doesn't exist + if (!fs.existsSync(logsDir)) { + fs.mkdirSync(logsDir, { recursive: true }); + } + + const filePath = path.join(logsDir, fileName); + fs.writeFileSync(filePath, JSON.stringify(jobObject, null, 2), "utf8"); + log.info(`Job data saved to: ${filePath}`); } - const filePath = path.join(logsDir, fileName); - fs.writeFileSync(filePath, JSON.stringify(jobObject, null, 2), "utf8"); - log.info(`Job data saved to: ${filePath}`); - - log.debug("Job Object", { - jobObject, - }); - const newAvailableJob: AvailableJobSchema = { uploaded_by: store.get("user.email"), bodyshopid: store.get("app.bodyshop.id"), @@ -183,7 +181,7 @@ async function ImportJob(filepath: string): Promise { newAvailableJob.est_data.vehicleid = existingVehicleRecord.vehicles[0].id; } - console.log(newAvailableJob); + console.log("Available Job record to upload;", newAvailableJob); const existingJobRecord: QueryJobByClmNoResult = await client.request( QUERY_JOB_BY_CLM_NO_TYPED, diff --git a/src/main/index.ts b/src/main/index.ts index 0730c4c..bfa73f1 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -6,6 +6,7 @@ import icon from "../../resources/icon.png?asset"; import ErrorTypeCheck from "../util/errorTypeCheck"; import client from "./graphql/graphql-client"; import store from "./store/store"; +import { autoUpdater } from "electron-updater"; log.initialize(); const isMac = process.platform === "darwin"; @@ -247,6 +248,11 @@ app.whenReady().then(async () => { }); } + //Check for app updates. + + autoUpdater.logger = log; + autoUpdater.checkForUpdatesAndNotify(); + createWindow(); app.on("activate", function () {