From 82021b8a65f4496f81d8880e7955cfea086b7022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bouget?= Date: Mon, 1 Jul 2024 14:43:28 +0200 Subject: [PATCH] MAC x64 dmg is no longer generated #190 Try to package x64 mac MAC x64 dmg is no longer generated #190 MAC x64 dmg is no longer generated #190 MAC x64 dmg is no longer generated #190 MAC x64 dmg is no longer generated #190 Update notarization tool #191 Double click doesn't work in macOS #183 Use notarytool Add appleApiKeyId for notarize Add appleApiKeyId for notarize Add appleApiKeyId for notarize Add appleApiKeyId for notarize Update notarization tool #191 Update notarization tool #191 Double click doesn't work in macOS #183 Update notarization tool #191 --- app/main.ts | 16 +++++++++--- app/package.json | 2 +- electron-builder.json | 11 +++++++- package.json | 3 ++- scripts/notarize.js | 61 +++++++++++++++++++++++-------------------- yarn.lock | 9 +++++++ 6 files changed, 67 insertions(+), 35 deletions(-) diff --git a/app/main.ts b/app/main.ts index 13ba2aa..d8125d8 100644 --- a/app/main.ts +++ b/app/main.ts @@ -42,11 +42,19 @@ app.on('will-finish-launching', function () { if (fileToLoad) { log.info('fileToLoad'); - setTimeout(function () { - if (win && win.webContents && fileToLoad) { + + if (win) { + setTimeout(() => { win.webContents.send('file-open-system', fileToLoad); - } - }, 2000); + }, 2500); + } else { + // if win is not ready, wait for it + app.once('browser-window-created', () => { + setTimeout(() => { + win.webContents.send('file-open-system', fileToLoad); + }, 2500); + }); + } } }); }); diff --git a/app/package.json b/app/package.json index 954cfe6..6e954db 100644 --- a/app/package.json +++ b/app/package.json @@ -1,7 +1,7 @@ { "name": "khiops-visualization", "title": "khiops Visualization", - "version": "11.0.6", + "version": "11.0.7", "description": "Khiops Visualization", "license": "BSD-3-Clause-Clear", "repository": "https://github.com/KhiopsML/kv-electron", diff --git a/electron-builder.json b/electron-builder.json index f72b6c5..31fc279 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -46,7 +46,16 @@ "entitlementsInherit": "./build/entitlements.mac.plist", "gatekeeperAssess": false, "hardenedRuntime": true, - "target": ["dmg", "zip"], + "target": [ + { + "target": "dmg", + "arch": ["x64", "arm64"] + }, + { + "target": "zip", + "arch": ["x64", "arm64"] + } + ], "fileAssociations": [ { "ext": "khj", diff --git a/package.json b/package.json index 821aee5..ebd95ef 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "khiops-visualization", "title": "khiops Visualization", "main": "app/main.js", - "version": "11.0.6", + "version": "11.0.7", "license": "BSD-3-Clause-Clear", "author": { "name": "Orange", @@ -102,6 +102,7 @@ "@typescript-eslint/eslint-plugin": "6.21.0", "@typescript-eslint/parser": "6.21.0", "conventional-changelog-cli": "4.1.0", + "@electron/notarize": "2.3.2", "electron": "30.0.8", "electron-builder": "24.13.3", "electron-builder-notarize": "1.5.2", diff --git a/scripts/notarize.js b/scripts/notarize.js index ecfbc18..6604f68 100644 --- a/scripts/notarize.js +++ b/scripts/notarize.js @@ -1,38 +1,43 @@ // See: https://medium.com/@TwitterArchiveEraser/notarize-electron-apps-7a5f988406db -const fs = require('fs'); -const path = require('path'); -var electron_notarize = require('electron-notarize'); +const fs = require("fs"); +const path = require("path"); +const electron_notarize = require("electron-notarize"); module.exports = async function (params) { - console.log("----------------------------------", params); - var platform = params.packager.platform.name; - // Only notarize the app on Mac OS only. - if (platform === 'linux' || platform === 'windows') { - return; - } - console.log('afterSign hook triggered', params); + console.log("----------------------------------", params); + const platform = params.packager.platform.name; + // Only notarize the app on Mac OS only. + if (platform === "linux" || platform === "windows") { + return; + } + console.log("afterSign hook triggered", params); - // Same appId in electron-builder. - let appId = 'com.khiops.visualization'; + // Same appId in electron-builder. + let appId = "com.khiops.visualization"; - let appPath = path.join(params.appOutDir, `${params.packager.appInfo.productFilename}.app`); - if (!fs.existsSync(appPath)) { - throw new Error(`Cannot find application at: ${appPath}`); - } + let appPath = path.join( + params.appOutDir, + `${params.packager.appInfo.productFilename}.app` + ); + if (!fs.existsSync(appPath)) { + throw new Error(`Cannot find application at: ${appPath}`); + } - console.log(`Notarizing ${appId} found at ${appPath}`); + console.log(`Notarizing ${appId} found at ${appPath}`); - try { - await electron_notarize.notarize({ - appBundleId: appId, - appPath: appPath, - appleApiKey: process.env.API_KEY_ID, - appleApiIssuer: process.env.API_KEY_ISSUER_ID - }); - } catch (error) { - console.error(error); - } + try { + await electron_notarize.notarize({ + tool: "notarytool", + appBundleId: appId, + appPath: appPath, + appleApiKeyId: process.env.API_KEY_ID, + appleApiKey: "~/private_keys/AuthKey_" + process.env.API_KEY_ID + ".p8", + appleApiIssuer: process.env.API_KEY_ISSUER_ID, + }); + } catch (error) { + console.error("ERROR during Notarization", error); + } - console.log(`Done notarizing ${appId}`); + console.log(`Done notarizing ${appId}`); }; diff --git a/yarn.lock b/yarn.lock index 9a5cd29..877ba3f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1405,6 +1405,15 @@ fs-extra "^9.0.1" promise-retry "^2.0.1" +"@electron/notarize@2.3.2": + version "2.3.2" + resolved "https://registry.yarnpkg.com/@electron/notarize/-/notarize-2.3.2.tgz#20a52a961747be8542a35003380988a0d3fe15e6" + integrity sha512-zfayxCe19euNwRycCty1C7lF7snk9YwfRpB5M8GLr1a4ICH63znxaPNAubrMvj0yDvVozqfgsdYpXVUnpWBDpg== + dependencies: + debug "^4.1.1" + fs-extra "^9.0.1" + promise-retry "^2.0.1" + "@electron/osx-sign@1.0.5": version "1.0.5" resolved "https://registry.yarnpkg.com/@electron/osx-sign/-/osx-sign-1.0.5.tgz#0af7149f2fce44d1a8215660fd25a9fb610454d8"