From 9eedac1d414716e00042094ee07798a0e059bae8 Mon Sep 17 00:00:00 2001 From: Lilian Saget-Lethias Date: Wed, 12 Oct 2022 17:17:16 +0200 Subject: [PATCH] fix(windows): drop pst not working --- .github/workflows/release.yml | 2 ++ scripts/replaceForChannel.js | 10 ++++++++++ src/common/config.ts | 14 ++++++++++++-- tests/integration/mock/electron.ts | 3 +++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 54586326..28863c77 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,6 +56,8 @@ jobs: - name: Setup Node uses: ./.github/actions/setup-node - name: Yarn install + env: + npm_config_build_from_source: true run: yarn --frozen-lockfile --perfer-offline - name: Import GPG key uses: crazy-max/ghaction-import-gpg@v5 diff --git a/scripts/replaceForChannel.js b/scripts/replaceForChannel.js index 179ba781..c63fa2e3 100644 --- a/scripts/replaceForChannel.js +++ b/scripts/replaceForChannel.js @@ -43,6 +43,16 @@ replace({ silent: true, }); +const appIdReplacement = `"appId": "fr.gouv.social.fabrique.archifiltre.$1-${channel}"`; +console.log("[ReplaceForChannel] Replacing app id with", appIdReplacement); +replace({ + paths: [packageJsonPath], + recursive: false, + regex: /"appId": "fr\.gouv\.social\.fabrique\.archifiltre\.(.+)"/g, + replacement: appIdReplacement, + silent: true, +}); + const iconIcnsReplacement = `"icon": "./electron/build/icon_${channel}.icns"`; console.log( "[ReplaceForChannel] Replacing ICNS icon with", diff --git a/src/common/config.ts b/src/common/config.ts index 6e6d8cd1..f05c91b1 100644 --- a/src/common/config.ts +++ b/src/common/config.ts @@ -22,6 +22,7 @@ export interface WorkerConfig { IS_MAIN: boolean; IS_PACKAGED: boolean; IS_TEST: boolean; + IS_WIN: boolean; PRODUCT_CHANNEL: "beta" | "next" | "stable"; STATIC_PATH: string; } @@ -47,6 +48,7 @@ export const IS_DEV = (process.env.NODE_ENV !== "production" && !IS_TEST); export const IS_E2E = localWorkerConfig.IS_E2E ?? !!process.env.E2E; export const IS_MAC = localWorkerConfig.IS_MAC ?? process.platform === "darwin"; +export const IS_WIN = localWorkerConfig.IS_WIN ?? process.platform === "win32"; const IS_PACKAGE_EVENT = "config.IS_PACKAGED"; const APP_CACHE_EVENT = "config.APP_CACHE"; if (IS_MAIN && !IS_WORKER) { @@ -61,7 +63,12 @@ if (IS_MAIN && !IS_WORKER) { if (IS_DEV && IS_MAIN && !IS_WORKER) { app.setName(`${name}-dev`); app.setPath("appData", path.resolve(__dirname, "../../electron/.appData/")); - app.setPath("cache", path.resolve(__dirname, "../../electron/.appCache/")); + if (!IS_WIN) { + app.setPath( + "cache", + path.resolve(__dirname, "../../electron/.appCache/") + ); + } } export const IS_PACKAGED = (): boolean => { @@ -74,7 +81,9 @@ export const IS_PACKAGED = (): boolean => { export const APP_CACHE = (): string => { if (IS_WORKER) return localWorkerConfig.APP_CACHE!; if (IS_MAIN) { - return path.resolve(app.getPath("cache"), name); + return IS_WIN + ? path.resolve(app.getPath("userData"), "Cache") + : path.resolve(app.getPath("cache"), app.getName()); } else return ipcRenderer.sendSync(APP_CACHE_EVENT) as string; }; @@ -98,6 +107,7 @@ export const workerConfig: WorkerConfig = { IS_MAIN, IS_PACKAGED: IS_PACKAGED(), IS_TEST, + IS_WIN, PRODUCT_CHANNEL, STATIC_PATH, }; diff --git a/tests/integration/mock/electron.ts b/tests/integration/mock/electron.ts index 96c1366c..0cac4324 100644 --- a/tests/integration/mock/electron.ts +++ b/tests/integration/mock/electron.ts @@ -1,5 +1,7 @@ import path from "path"; +process.env.NODE_ENV = "test-jest"; + jest.mock( "electron", () => { @@ -9,6 +11,7 @@ jest.mock( return { app: { getLocale: () => "fr-FR", + getName: () => `archifiltre-mails-test`, getPath: (p: string) => path.resolve(__dirname, `../__app_getPath__/${p}`), },