diff --git a/forge.config.ts b/forge.config.ts index 240100dea..02fb4bd13 100644 --- a/forge.config.ts +++ b/forge.config.ts @@ -1,3 +1,6 @@ +import { readdir } from "node:fs/promises" +import path from "node:path" + import { FuseV1Options, FuseVersion } from "@electron/fuses" import { MakerDeb } from "@electron-forge/maker-deb" import { MakerDMG } from "@electron-forge/maker-dmg" @@ -5,23 +8,59 @@ import { MakerRpm } from "@electron-forge/maker-rpm" import { MakerSquirrel } from "@electron-forge/maker-squirrel" import { FusesPlugin } from "@electron-forge/plugin-fuses" import type { ForgeConfig } from "@electron-forge/shared-types" +import { rimraf } from "rimraf" +// remove folders & files not to be included in the app +async function cleanSources( + buildPath, + electronVersion, + platform, + arch, + callback, +) { + // folders & files to be included in the app + const appItems = new Set([ + "dist", + "node_modules", + "package.json", + "resources", + ]) + + // Keep only node_modules to be included in the app + const modules = new Set(["font-list"]) + await Promise.all([ + ...(await readdir(buildPath).then((items) => + items + .filter((item) => !appItems.has(item)) + .map((item) => rimraf(path.join(buildPath, item))), + )), + ...(await readdir(path.join(buildPath, "node_modules")).then((items) => + items + .filter((item) => !modules.has(item)) + .map((item) => rimraf(path.join(buildPath, "node_modules", item))), + )), + ]) + + callback() +} const config: ForgeConfig = { packagerConfig: { appBundleId: "is.follow", icon: "resources/icon", - ignore: [ - /^\/src/, - /(.eslintrc.json)|(.gitignore)|(electron.vite.config.ts)|(forge.config.ts)|(tsconfig.*)/, - ], + + afterCopy: [cleanSources], asar: true, - osxSign: { - optionsForFile: () => ({ - entitlements: "build/entitlements.mac.plist", - }), - keychain: process.env.KEYCHAIN_PATH, - }, - ...(process.env.APPLE_ID && process.env.APPLE_PASSWORD && process.env.APPLE_TEAM_ID && { + ignore: [/^\/node_modules\/(?!font-list)/], + prune: true, + ...(process.env.APPLE_ID && + process.env.APPLE_PASSWORD && + process.env.APPLE_TEAM_ID && { + osxSign: { + optionsForFile: () => ({ + entitlements: "build/entitlements.mac.plist", + }), + keychain: process.env.KEYCHAIN_PATH, + }, osxNotarize: { appleId: process.env.APPLE_ID!, appleIdPassword: process.env.APPLE_PASSWORD!, @@ -50,7 +89,7 @@ const config: ForgeConfig = { }, }, }, - contents: (opts) => ([ + contents: (opts) => [ { x: 180, y: 170, @@ -63,7 +102,7 @@ const config: ForgeConfig = { type: "link", path: "/Applications", }, - ]), + ], }), ], plugins: [ diff --git a/package.json b/package.json index 60ef5708d..9dc3af832 100644 --- a/package.json +++ b/package.json @@ -124,6 +124,7 @@ "@types/node": "^20.14.9", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", + "@types/rimraf": "4.0.5", "@vercel/ncc": "0.38.1", "@vitejs/plugin-react": "^4.3.1", "electron": "^30.1.2", @@ -137,6 +138,7 @@ "postcss-js": "4.0.1", "react": "^18.3.1", "react-dom": "^18.3.1", + "rimraf": "6.0.0", "simple-git-hooks": "2.11.1", "tailwindcss": "3.4.4", "typescript": "^5.5.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8ff2fac98..28e535042 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -314,6 +314,9 @@ importers: '@types/react-dom': specifier: ^18.3.0 version: 18.3.0 + '@types/rimraf': + specifier: 4.0.5 + version: 4.0.5 '@vercel/ncc': specifier: 0.38.1 version: 0.38.1 @@ -353,6 +356,9 @@ importers: react-dom: specifier: ^18.3.1 version: 18.3.1(react@18.3.1) + rimraf: + specifier: 6.0.0 + version: 6.0.0 simple-git-hooks: specifier: 2.11.1 version: 2.11.1 @@ -2114,6 +2120,10 @@ packages: '@types/responselike@1.0.3': resolution: {integrity: sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==} + '@types/rimraf@4.0.5': + resolution: {integrity: sha512-DTCZoIQotB2SUJnYgrEx43cQIUYOlNZz0AZPbKU4PSLYTUdML5Gox0++z4F9kQocxStrCmRNhi4x5x/UlwtKUA==} + deprecated: This is a stub types definition. rimraf provides its own type definitions, so you do not need this installed. + '@types/tar@6.1.13': resolution: {integrity: sha512-IznnlmU5f4WcGTh2ltRu/Ijpmk8wiWXfF0VA4s+HPjHZgvFggk1YaIkbo5krX/zUCzWF8N/l4+W/LNxnvAJ8nw==} @@ -3563,6 +3573,11 @@ packages: engines: {node: '>=16 || 14 >=14.18'} hasBin: true + glob@11.0.0: + resolution: {integrity: sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==} + engines: {node: 20 || >=22} + hasBin: true + glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} deprecated: Glob versions prior to v9 are no longer supported @@ -3951,6 +3966,10 @@ packages: resolution: {integrity: sha512-JVYhQnN59LVPFCEcVa2C3CrEKYacvjRfqIQl+h8oi91aLYQVWRYbxjPcv1bUiUy/kLmQaANrYfNMCO3kuEDHfw==} engines: {node: '>=14'} + jackspeak@4.0.1: + resolution: {integrity: sha512-cub8rahkh0Q/bw1+GxP7aeSe29hHHn2V4m29nnDlvCdlgU+3UGxkZp7Z53jLUdpX3jdTO0nJZUDl3xvbWc2Xog==} + engines: {node: 20 || >=22} + jiti@1.21.6: resolution: {integrity: sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w==} hasBin: true @@ -4192,6 +4211,10 @@ packages: resolution: {integrity: sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==} engines: {node: 14 || >=16.14} + lru-cache@11.0.0: + resolution: {integrity: sha512-Qv32eSV1RSCfhY3fpPE2GNZ8jgM9X7rdAfemLWqTUxwiyIC4jJ6Sy0fZ8H+oLWevO6i4/bizg7c8d8i6bxrzbA==} + engines: {node: 20 || >=22} + lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} @@ -4364,6 +4387,10 @@ packages: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} engines: {node: '>=4'} + minimatch@10.0.1: + resolution: {integrity: sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==} + engines: {node: 20 || >=22} + minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} @@ -4725,6 +4752,10 @@ packages: resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==} engines: {node: '>=16 || 14 >=14.18'} + path-scurry@2.0.0: + resolution: {integrity: sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==} + engines: {node: 20 || >=22} + path-to-regexp@7.0.0: resolution: {integrity: sha512-58Y94bQqF3zBIASFNiufRPH1NfgZth1qwZ35radL87sg8pgbVqr6uikAhqZtFD+w65MGH6SWnY/ly3GbrM4fbg==} engines: {node: '>=16'} @@ -5169,6 +5200,11 @@ packages: deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true + rimraf@6.0.0: + resolution: {integrity: sha512-u+yqhM92LW+89cxUQK0SRyvXYQmyuKHx0jkx4W7KfwLGLqJnQM5031Uv1trE4gB9XEXBM/s6MxKlfW95IidqaA==} + engines: {node: 20 || >=22} + hasBin: true + roarr@2.15.4: resolution: {integrity: sha512-CHhPh+UNHD2GTXNYhPWLnU8ONHdI+5DI+4EYIAOaiD63rHeYlZvyh8P+in5999TTSFgUYuKUAjzRI4mdh/p+2A==} engines: {node: '>=8.0'} @@ -7996,6 +8032,10 @@ snapshots: dependencies: '@types/node': 20.14.9 + '@types/rimraf@4.0.5': + dependencies: + rimraf: 6.0.0 + '@types/tar@6.1.13': dependencies: '@types/node': 20.14.9 @@ -9783,6 +9823,15 @@ snapshots: package-json-from-dist: 1.0.0 path-scurry: 1.11.1 + glob@11.0.0: + dependencies: + foreground-child: 3.2.1 + jackspeak: 4.0.1 + minimatch: 10.0.1 + minipass: 7.1.2 + package-json-from-dist: 1.0.0 + path-scurry: 2.0.0 + glob@7.2.3: dependencies: fs.realpath: 1.0.0 @@ -10262,6 +10311,12 @@ snapshots: optionalDependencies: '@pkgjs/parseargs': 0.11.0 + jackspeak@4.0.1: + dependencies: + '@isaacs/cliui': 8.0.2 + optionalDependencies: + '@pkgjs/parseargs': 0.11.0 + jiti@1.21.6: {} jose@5.6.2: {} @@ -10489,6 +10544,8 @@ snapshots: lru-cache@10.2.2: {} + lru-cache@11.0.0: {} + lru-cache@5.1.1: dependencies: yallist: 3.1.1 @@ -10805,6 +10862,10 @@ snapshots: min-indent@1.0.1: {} + minimatch@10.0.1: + dependencies: + brace-expansion: 2.0.1 + minimatch@3.1.2: dependencies: brace-expansion: 1.1.11 @@ -11175,6 +11236,11 @@ snapshots: lru-cache: 10.2.2 minipass: 7.1.2 + path-scurry@2.0.0: + dependencies: + lru-cache: 11.0.0 + minipass: 7.1.2 + path-to-regexp@7.0.0: {} path-type@2.0.0: @@ -11601,6 +11667,10 @@ snapshots: dependencies: glob: 7.2.3 + rimraf@6.0.0: + dependencies: + glob: 11.0.0 + roarr@2.15.4: dependencies: boolean: 3.2.0