Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Electron Fuses to the packaging pipeline #3076

Closed
3 tasks done
erickzhao opened this issue Nov 16, 2022 · 3 comments · Fixed by #3132
Closed
3 tasks done

Add Electron Fuses to the packaging pipeline #3076

erickzhao opened this issue Nov 16, 2022 · 3 comments · Fixed by #3132
Labels
enhancement package Issues related to the `package` command request/plugin

Comments

@erickzhao
Copy link
Member

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem description

In Electron, Fuses are package-time toggle features that can disable certain features on a per-app basis. For example, apps might not want to ship with the ELECTRON_RUN_AS_NODE capability, and can turn it off for their app with a fuse.

See https://www.electronjs.org/docs/latest/tutorial/fuses

Proposed solution

Forge should include a way to easily configure fuses in the packaging process.

Alternatives considered

This can be implemented in various manners in the Forge process, and we don't really have existing guidelines on which one is better:

  • As an opt-in plugin
  • As a built-in part of the Forge config
  • As a written how-to guide in the Forge docs

Additional information

No response

@erickzhao erickzhao added enhancement package Issues related to the `package` command request/plugin labels Nov 16, 2022
@erikian
Copy link
Member

erikian commented Nov 16, 2022

Going for a plugin would potentially help with modularization, though it doesn't look like it's going to take a lot of code (@electron/fuses' docs show a complete example in just a few LOC), so maybe it can be just built into Forge (or packager?) directly. Either way, I'd happy to take on this once an approach is decided.

@pacocoursey
Copy link

@erikian Why close that PR? It looked perfect for adding Fuses support in both places. Has anyone made a plugin to do support using Fuses through Forge/Packager yet?

@erikian erikian mentioned this issue Jan 6, 2023
5 tasks
@SpacingBat3
Copy link
Contributor

@erickzhao As a workaround / current way how to use Fuses with Electron Forge, you can use hooks like this:

const { flipFuses } = require("@electron/fuses");
const { resolve } = require("path");

const electronPath = new Map([
	/* PLATFORM                                BINARY */
	[ "darwin", "Electron.app/Contents/MacOS/Electron" ],
	[ "win32",                          "electron.exe" ],
	[ "linux",                              "electron" ]
]);

module.exports = {
	// (...)
	hooks: {
		packageAfterExtract: (_forgeConfig, path, _electronVersion, platform) =>
			flipFuses(resolve(path, electronPath.get(platform)), {
				// Insert you Fuse config there.
			})
	},
	// (...)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement package Issues related to the `package` command request/plugin
Projects
None yet
4 participants