diff --git a/Gruntfile.js b/Gruntfile.js index af43c656..6f90bc7b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -457,6 +457,14 @@ module.exports = function (grunt) { } } }, + 'electron-patch': { + 'win32-x64': 'tmp/desktop/KeeWeb-win32-x64/KeeWeb.exe', + 'win32-ia32': 'tmp/desktop/KeeWeb-win32-ia32/KeeWeb.exe', + 'win32-arm64': 'tmp/desktop/KeeWeb-win32-arm64/KeeWeb.exe', + 'darwin-x64': 'tmp/desktop/KeeWeb-darwin-x64/KeeWeb.app', + 'darwin-arm64': 'tmp/desktop/KeeWeb-darwin-arm64/KeeWeb.app', + 'linux': 'tmp/desktop/KeeWeb-linux-x64/keeweb' + }, osacompile: { options: { language: 'JavaScript' diff --git a/build/tasks/grunt-electron-patch.js b/build/tasks/grunt-electron-patch.js new file mode 100644 index 00000000..06301fba --- /dev/null +++ b/build/tasks/grunt-electron-patch.js @@ -0,0 +1,12 @@ +module.exports = function (grunt) { + grunt.registerMultiTask('electron-patch', 'Patches Electron executable', async function () { + const patch = require('electron-evil-feature-patcher'); + + for (const { src } of this.files) { + for (const path of src) { + grunt.log.writeln(`Patching ${path}...`); + patch({ path }); + } + } + }); +}; diff --git a/grunt.entrypoints.js b/grunt.entrypoints.js index 91b141d7..6bbe3fe3 100644 --- a/grunt.entrypoints.js +++ b/grunt.entrypoints.js @@ -51,6 +51,7 @@ module.exports = function(grunt) { 'default', 'build-desktop-app-content', 'electron:darwin-x64', + 'electron-patch:darwin-x64', 'build-darwin-installer', 'copy:desktop-darwin-helper-x64', 'copy:desktop-darwin-installer-helper-x64', diff --git a/grunt.tasks.js b/grunt.tasks.js index c41fd8b8..fc46d5c8 100644 --- a/grunt.tasks.js +++ b/grunt.tasks.js @@ -26,6 +26,7 @@ module.exports = function (grunt) { grunt.registerTask('build-desktop-executables-linux', [ 'electron:linux', + 'electron-patch:linux', 'chmod:linux-desktop-x64', 'copy:native-modules-linux-x64' ]); @@ -33,6 +34,8 @@ module.exports = function (grunt) { grunt.registerTask('build-desktop-executables-darwin', [ 'electron:darwin-x64', 'electron:darwin-arm64', + 'electron-patch:darwin-x64', + 'electron-patch:darwin-arm64', 'build-darwin-installer', 'copy:desktop-darwin-helper-x64', 'copy:desktop-darwin-helper-arm64', @@ -56,6 +59,9 @@ module.exports = function (grunt) { 'electron:win32-x64', 'electron:win32-ia32', 'electron:win32-arm64', + 'electron-patch:win32-x64', + 'electron-patch:win32-ia32', + 'electron-patch:win32-arm64', sign ? 'sign-exe:win32-build-x64' : 'noop', sign ? 'sign-exe:win32-build-ia32' : 'noop', sign ? 'sign-exe:win32-build-arm64' : 'noop', diff --git a/package-lock.json b/package-lock.json index 84a3059a..8109678c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "dompurify": "^2.2.6", "electron": "^12.0.0-beta.22", "electron-builder": "^22.9.1", + "electron-evil-feature-patcher": "^1.2.0", "electron-notarize": "^1.0.0", "electron-osx-sign": "^0.5.0", "eslint": "^7.19.0", @@ -5529,6 +5530,14 @@ "node": ">=8" } }, + "node_modules/electron-evil-feature-patcher": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/electron-evil-feature-patcher/-/electron-evil-feature-patcher-1.2.0.tgz", + "integrity": "sha512-R6TZ2JWUFuCsgMl7W1sRaWgNbipS56d4waFHKq0/CnI1C6yrjJHdxB94QUmfDTlhvEXPy7e1bio0AZ7AQH9p2A==", + "bin": { + "electron-evil-feature-patcher": "cli.js" + } + }, "node_modules/electron-notarize": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/electron-notarize/-/electron-notarize-1.0.0.tgz", @@ -25540,6 +25549,11 @@ } } }, + "electron-evil-feature-patcher": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/electron-evil-feature-patcher/-/electron-evil-feature-patcher-1.2.0.tgz", + "integrity": "sha512-R6TZ2JWUFuCsgMl7W1sRaWgNbipS56d4waFHKq0/CnI1C6yrjJHdxB94QUmfDTlhvEXPy7e1bio0AZ7AQH9p2A==" + }, "electron-notarize": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/electron-notarize/-/electron-notarize-1.0.0.tgz", diff --git a/package.json b/package.json index da5c8084..41c4e7c4 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "dompurify": "^2.2.6", "electron": "^12.0.0-beta.22", "electron-builder": "^22.9.1", + "electron-evil-feature-patcher": "^1.2.0", "electron-notarize": "^1.0.0", "electron-osx-sign": "^0.5.0", "eslint": "^7.19.0",