Live video on the AT Protocol
at eli/optional-convergence 176 lines 5.8 kB view raw
1import { MakerDMG } from "@electron-forge/maker-dmg"; 2import { MakerSquirrel } from "@electron-forge/maker-squirrel"; 3import { MakerZIP } from "@electron-forge/maker-zip"; 4import type { 5 ForgeConfig, 6 ForgePackagerOptions, 7} from "@electron-forge/shared-types"; 8// import { MakerDeb } from "@electron-forge/maker-deb"; 9// import { MakerRpm } from "@electron-forge/maker-rpm"; 10import { AutoUnpackNativesPlugin } from "@electron-forge/plugin-auto-unpack-natives"; 11import { FusesPlugin } from "@electron-forge/plugin-fuses"; 12import { WebpackPlugin } from "@electron-forge/plugin-webpack"; 13import { PublisherS3 } from "@electron-forge/publisher-s3"; 14import { FuseV1Options, FuseVersion } from "@electron/fuses"; 15import { MakerAppImage } from "@reforged/maker-appimage"; 16import child_process from "child_process"; 17import fs from "fs"; 18import { mainConfig } from "./webpack.main.config"; 19import { rendererConfig } from "./webpack.renderer.config"; 20 21export default async function () { 22 // go get the version from the actual script 23 let version = child_process 24 .execSync("go run ../../pkg/config/git/git.go -v") 25 .toString() 26 .slice(1); 27 28 let versionCode = child_process 29 .execSync("go run ../../pkg/config/git/git.go --js") 30 .toString(); 31 32 fs.writeFileSync("./src/version.ts", versionCode, "utf8"); 33 34 // https://github.com/Squirrel/Squirrel.Windows/issues/1394#issuecomment-2356692821 35 // This makes the Desktop app have confusing numbers, but actual relases just use X.Y.Z 36 // so it doesn't really matter. Those are just for testing. 37 if (version.includes("-")) { 38 version = version.replace("-", "-z"); 39 } 40 41 const packagerConfig: ForgePackagerOptions = { 42 asar: true, 43 name: "Streamplace", 44 appVersion: version, 45 buildVersion: version, 46 icon: "./assets/images/streamplace-logo", 47 extraResource: ["./assets/images/streamplace-logo.png"], 48 }; 49 50 const config: ForgeConfig = { 51 packagerConfig: packagerConfig, 52 hooks: { 53 prePackage: async (config, plat, arch) => { 54 let platform = plat; 55 let architecture = arch; 56 if (platform === "win32") { 57 platform = "windows"; 58 } 59 if (architecture === "x64") { 60 architecture = "amd64"; 61 } 62 let binary = `../../build-${platform}-${architecture}/streamplace`; 63 if (platform === "windows") { 64 binary += ".exe"; 65 } 66 const exists = fs.existsSync(binary); 67 if (!exists) { 68 throw new Error( 69 `could not find ${binary} while building electron bundle. do you need to run make ${platform}-${architecture}?`, 70 ); 71 } 72 73 if (!config.packagerConfig) { 74 throw new Error("config.packageConfig undefined"); 75 } 76 if (!config.packagerConfig.extraResource) { 77 config.packagerConfig.extraResource = []; 78 } 79 config.packagerConfig.extraResource = [ 80 ...config.packagerConfig.extraResource, 81 binary, 82 ]; 83 }, 84 readPackageJson: async (forgeConfig, packageJson) => { 85 packageJson.version = version; 86 return packageJson; 87 }, 88 }, 89 rebuildConfig: {}, 90 makers: [ 91 new MakerSquirrel({ 92 iconUrl: 93 "https://git.stream.place/-/project/1/uploads/2e5899ffd2b4799ce661cf9b8675e610/streamplace-logo-256.ico", 94 setupIcon: "./assets/images/streamplace-logo.ico", 95 }), 96 new MakerDMG( 97 { 98 icon: "./assets/images/streamplace-logo.icns", 99 appPath: "./Streamplace.app", 100 }, 101 ["darwin"], 102 ), 103 new MakerZIP({}, ["darwin"]), 104 // new MakerRpm({}), 105 new MakerAppImage({ 106 options: { 107 bin: "Streamplace", 108 icon: "./assets/images/streamplace-logo.png", 109 }, 110 }), 111 ], 112 plugins: [ 113 new AutoUnpackNativesPlugin({}), 114 new WebpackPlugin({ 115 mainConfig, 116 packageSourceMaps: true, 117 renderer: { 118 config: rendererConfig, 119 entryPoints: [ 120 { 121 html: "./src/index.html", 122 js: "./src/renderer.ts", 123 name: "main_window", 124 preload: { 125 js: "./src/preload.ts", 126 }, 127 }, 128 ], 129 }, 130 }), 131 // Fuses are used to enable/disable various Electron functionality 132 // at package time, before code signing the application 133 new FusesPlugin({ 134 version: FuseVersion.V1, 135 [FuseV1Options.RunAsNode]: false, 136 [FuseV1Options.EnableCookieEncryption]: true, 137 [FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false, 138 [FuseV1Options.EnableNodeCliInspectArguments]: false, 139 [FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: false, 140 [FuseV1Options.OnlyLoadAppFromAsar]: true, 141 }), 142 ], 143 publishers: [ 144 new PublisherS3({ 145 endpoint: "http://192.168.8.136:9000", 146 accessKeyId: "minioadmin", 147 secretAccessKey: "minioadmin", 148 public: true, 149 bucket: "streamplace", 150 region: "unused", 151 }), 152 ], 153 }; 154 if ( 155 process.env.NOTARIZATION_TEAM_ID && 156 process.env.NOTARIZATION_EMAIL && 157 process.env.NOTARIZATION_PASSWORD 158 ) { 159 packagerConfig.osxNotarize = { 160 teamId: process.env.NOTARIZATION_TEAM_ID, 161 appleId: process.env.NOTARIZATION_EMAIL, 162 appleIdPassword: process.env.NOTARIZATION_PASSWORD, 163 }; 164 packagerConfig.osxSign = { 165 optionsForFile: (filePath) => { 166 // Here, we keep it simple and return a single entitlements.plist file. 167 // You can use this callback to map different sets of entitlements 168 // to specific files in your packaged app. 169 return { 170 entitlements: "./entitlements.plist", 171 }; 172 }, 173 }; 174 } 175 return config; 176}