From e6ee5ae1755d66c68d8672e4a9d7d2c64fdd1594 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 18 Dec 2023 18:42:17 -0800 Subject: [PATCH 1/4] We need to install setuptools earlier, so that our yarn setup has setuptools available for node-gyp --- .github/workflows/build.yml | 6 ++++-- .github/workflows/publish.yml | 6 ++++-- .github/workflows/pull-requests.yml | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ed255f79e..229b09970 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,7 +67,10 @@ jobs: - name: Install udev-dev run: sudo apt update && sudo apt install libudev-dev if: runner.os == 'Linux' - + - name: Workaround a missing python dep + if: matrix.os == 'macos-13' + run: | + sudo -H pip install setuptools - name: Set up yarn network timeout run: yarn config set network-timeout 1000000 -g @@ -86,7 +89,6 @@ jobs: APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} run: | - sudo -H pip install setuptools yarn run make --arch=universal - name: Release (non-macos) shell: bash diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 756d91759..6a31341f5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -59,7 +59,10 @@ jobs: - name: Install udev-dev run: sudo apt update && sudo apt install libudev-dev if: runner.os == 'Linux' - + - name: Workaround a missing python dep + if: matrix.os == 'macos-13' + run: | + sudo -H pip install setuptools - name: Set up yarn network timeout run: yarn config set network-timeout 1000000 -g @@ -76,7 +79,6 @@ jobs: APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} run: | - sudo -H pip install setuptools yarn run publish --arch=universal - name: Release (non-macos) if: matrix.os != 'macos-13' diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index b89b2f54c..43d619f61 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -22,7 +22,10 @@ jobs: - name: Install udev-dev run: sudo apt update && sudo apt install libudev-dev if: runner.os == 'Linux' - + - name: Workaround a missing python dep + if: matrix.os == 'macos-13' + run: | + sudo -H pip install setuptools - name: Set up yarn network timeout run: yarn config set network-timeout 1000000 -g @@ -37,7 +40,6 @@ jobs: UNTRUSTED: 1 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - sudo -H pip install setuptools yarn run publish --arch=universal --dry-run - name: Release (non-macos) if: matrix.os != 'macos-13' From 74e36e2633980bd86578368978c7e3e3dd45b3f6 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 18 Dec 2023 16:24:26 -0800 Subject: [PATCH 2/4] update stylelint-config-standard to fix a deps mismatch --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 049633798..3fd2624ad 100644 --- a/package.json +++ b/package.json @@ -120,7 +120,7 @@ "prettier": "^2.6.1", "style-loader": "^3.0.0", "stylelint": "^15.10.1", - "stylelint-config-standard": "^25.0.0", + "stylelint-config-standard": "^32.0.0", "unraw": "^2.0.0", "webpack": "^5.75.0", "xml2js": "^0.5.0", diff --git a/yarn.lock b/yarn.lock index 4865980ce..2f8ee0148 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9664,17 +9664,17 @@ style-to-object@^0.3.0: dependencies: inline-style-parser "0.1.1" -stylelint-config-recommended@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/stylelint-config-recommended/-/stylelint-config-recommended-7.0.0.tgz#7497372ae83ab7a6fffc18d7d7b424c6480ae15e" - integrity sha512-yGn84Bf/q41J4luis1AZ95gj0EQwRX8lWmGmBwkwBNSkpGSpl66XcPTulxGa/Z91aPoNGuIGBmFkcM1MejMo9Q== +stylelint-config-recommended@^11.0.0: + version "11.0.0" + resolved "https://registry.yarnpkg.com/stylelint-config-recommended/-/stylelint-config-recommended-11.0.0.tgz#b1cb7d71bd92f9b8593f93c2ca6df16ed7d61522" + integrity sha512-SoGIHNI748OCZn6BxFYT83ytWoYETCINVHV3LKScVAWQQauWdvmdDqJC5YXWjpBbxg2E761Tg5aUGKLFOVhEkA== -stylelint-config-standard@^25.0.0: - version "25.0.0" - resolved "https://registry.yarnpkg.com/stylelint-config-standard/-/stylelint-config-standard-25.0.0.tgz#2c916984e6655d40d6e8748b19baa8603b680bff" - integrity sha512-21HnP3VSpaT1wFjFvv9VjvOGDtAviv47uTp3uFmzcN+3Lt+RYRv6oAplLaV51Kf792JSxJ6svCJh/G18E9VnCA== +stylelint-config-standard@^32.0.0: + version "32.0.0" + resolved "https://registry.yarnpkg.com/stylelint-config-standard/-/stylelint-config-standard-32.0.0.tgz#97179035e967f22a7b7e27f14a74f5d5fc0f0bd6" + integrity sha512-UnGJxYDyYFrIE9CjDMZRkrNh2o4lOtO+MVZ9qG5b8yARfsWho0GMx4YvhHfsv8zKKgHeWX2wfeyxmuoqcaYZ4w== dependencies: - stylelint-config-recommended "^7.0.0" + stylelint-config-recommended "^11.0.0" stylelint@^15.10.1: version "15.10.1" From 11f0fe4869d8345a130ad962670c45979b330bda Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 18 Dec 2023 14:33:36 -0800 Subject: [PATCH 3/4] https://www.update.rocks/blog/fixing-the-python3/ If you are using electron-packager or electron-forge, you might encounter the following error : An unhandled rejection has occurred inside Forge: Error: /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/electron-packager/darwin-x64/electron-example-darwin-x64-5AYzr2/Electron.app/Contents/Resources/app/node_modules/macos-alias/build/node_gyp_bins/python3: file "../../../../../../../../../../../../../Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11" links out of the package This error is showing when trying to package an electron application for macOS with Electron Forge. It takes its root in electron-packager and is produced by node-gyp like described in this Github issue. https://github.com/nodejs/node-gyp/issues/2713 --- forge.config.js | 74 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/forge.config.js b/forge.config.js index 4f3e11dfb..631161511 100644 --- a/forge.config.js +++ b/forge.config.js @@ -2,6 +2,7 @@ const { spawnSync } = require("child_process"); const { generateCLDRData } = require("./tools/precompile.js"); const { glob } = require('glob'); const fs = require('fs'); +const path = require('path'); let config = { packagerConfig: { @@ -142,28 +143,63 @@ let config = { } return packageJson; }, - packageAfterPrune: async (forgeConfig, buildPath, electronVersion, platform, arch) => { - const npmInstall = spawnSync("npm", ["install", "--omit=dev"], { - cwd: buildPath, - stdio: "inherit", - shell: true, - }); + packageAfterPrune: async ( + forgeConfig, + buildPath, + electronVersion, + platform, + arch, + ) => { + const npmInstall = spawnSync("npm", ["install", "--omit=dev"], { + cwd: buildPath, + stdio: "inherit", + shell: true, + }); + + // Clear out prebuilds for other architectures + // 1) we don't need them + // 2) windows binary signing tool blows up when it tries to sign them. + + const prebuilds = glob.GlobSync(`${buildPath}/**/prebuilds/*`); + const matchString = new RegExp(`prebuilds/${platform}`); + prebuilds.found.forEach(function (path) { + if (!path.match(matchString)) { + fs.rmSync(path, { recursive: true }); + } + }); + // Workaround from https://www.update.rocks/blog/fixing-the-python3/ + if (platform === "darwin") { + // Directory to inspect + const dirPath = path.join( + buildPath, + "node_modules/macos-alias/build/node_gyp_bins", + ); + // Check if the directory exists + if (fs.existsSync(dirPath)) { + // List files in the directory + console.log("Contents of the directory before removal: "); + const files = fs.readdirSync(path.join(dirPath)); + files.forEach((file) => { + console.log(file); + }); - console.log(buildPath); + // Files to remove + const filesToRemove = ["python", "python2", "python3"]; - // Clear out prebuilds for other architectures - // 1) we don't need them - // 2) windows binary signing tool blows up when it tries to sign them. - - const prebuilds = glob.GlobSync(`${buildPath}/**/prebuilds/*`); - const matchString = new RegExp(`prebuilds/${platform}`); - prebuilds.found.forEach(function(path) { - if (! path.match(matchString)) { - fs.rmdirSync(path, { recursive: true }); - } - }); + // Remove files if they exist + filesToRemove.forEach((file) => { + const filePath = path.join(dirPath, file); + if (fs.existsSync(filePath)) { + console.log(`Removing file: ${file}`); + fs.unlinkSync(filePath); + } + }); + } else { + console.log(`Directory not found: ${dirPath}`); + } + } + }, }, -} }; if (process.env.UNTRUSTED) { delete config['packagerConfig']['osxSign']; From 3116652ad172d30d6e40c32c681743f098b0e895 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 18 Dec 2023 16:59:38 -0800 Subject: [PATCH 4/4] code formatting of forge.config.js --- forge.config.js | 89 ++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/forge.config.js b/forge.config.js index 631161511..cb2bf81bb 100644 --- a/forge.config.js +++ b/forge.config.js @@ -1,13 +1,13 @@ const { spawnSync } = require("child_process"); const { generateCLDRData } = require("./tools/precompile.js"); -const { glob } = require('glob'); -const fs = require('fs'); -const path = require('path'); +const { glob } = require("glob"); +const fs = require("fs"); +const path = require("path"); -let config = { +let config = { packagerConfig: { asar: true, - appBundleId: 'keyboardio.chrysalis', + appBundleId: "keyboardio.chrysalis", darwinDarkModeSupport: "true", icon: "build/icon", name: "Chrysalis", @@ -37,13 +37,13 @@ let config = { }, rebuildConfig: {}, makers: [ - { - name: '@electron-forge/maker-squirrel', + { + name: "@electron-forge/maker-squirrel", config: { - certificateFile: './cert.pfx', + certificateFile: "./cert.pfx", certificatePassword: process.env.WINDOWS_CERTIFICATE_PASSWORD, }, - }, + }, { name: "@electron-forge/maker-dmg", config: {}, @@ -51,40 +51,37 @@ let config = { { name: "@electron-forge/maker-zip", }, -{ - name: "@reforged/maker-appimage", - config: { - options: { - // Package name. - // name: "example-app", - // Executable name. - bin: "Chrysalis", - // Human-friendly name of the application. - // productName: "Example Electron Application", - // `GenericName` in generated `.desktop` file. - // genericName: "Example application", - // Path to application's icon. - icon: "build/icon.png", - // `Categories` in generated `.desktop` file. - categories: [ "Utility" ], - // Actions of generated `.desktop` file. - // actions: { - // new_window: { - // Name: "Launch in new window!", - // Icon: "/path/to/new-window.png", - // Exec: "example-app --new-window" - // } - //}, - // Desktop file to be used instead of the configuration above. - // desktopFile: "/path/to/example-app.desktop", - // Release of `AppImage/AppImageKit`, either number or "continuous". - // AppImageKitRelease: "continuous" - } - } -} - - - + { + name: "@reforged/maker-appimage", + config: { + options: { + // Package name. + // name: "example-app", + // Executable name. + bin: "Chrysalis", + // Human-friendly name of the application. + // productName: "Example Electron Application", + // `GenericName` in generated `.desktop` file. + // genericName: "Example application", + // Path to application's icon. + icon: "build/icon.png", + // `Categories` in generated `.desktop` file. + categories: ["Utility"], + // Actions of generated `.desktop` file. + // actions: { + // new_window: { + // Name: "Launch in new window!", + // Icon: "/path/to/new-window.png", + // Exec: "example-app --new-window" + // } + //}, + // Desktop file to be used instead of the configuration above. + // desktopFile: "/path/to/example-app.desktop", + // Release of `AppImage/AppImageKit`, either number or "continuous". + // AppImageKitRelease: "continuous" + }, + }, + }, ], publishers: [ { @@ -133,7 +130,7 @@ let config = { // only copy deps if there isn't any if (Object.keys(packageJson.dependencies).length === 0) { const originalPackageJson = await fs.readJson( - path.resolve(__dirname, "package.json") + path.resolve(__dirname, "package.json"), ); const webpackConfigJs = require("./webpack.renderer.config.js"); Object.keys(webpackConfigJs.externals).forEach((package) => { @@ -202,8 +199,8 @@ let config = { }, }; if (process.env.UNTRUSTED) { - delete config['packagerConfig']['osxSign']; - delete config['packagerConfig']['osxNotarize']; + delete config["packagerConfig"]["osxSign"]; + delete config["packagerConfig"]["osxNotarize"]; } module.exports = config;