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

fix(template-base): install correct version of plugin-fuses #3823

Merged
merged 6 commits into from
Jan 29, 2025

Conversation

erickzhao
Copy link
Member

@erickzhao erickzhao commented Jan 29, 2025

Context

In #3480, we added the @electron/fuses plugin to our templates.

This was done by adding the dependencies directly into the tmpl/package.json file for each template like so:

"devDependencies": {
"@electron/fuses": "^1.7.0",
"@electron-forge/plugin-fuses": "^7.2.0"
},

This approach eventually caused two problems:

  1. The import command didn't install the correct Fuses dependency (ref Error: Cannot find module '@electron-forge/plugin-fuses' when npm run make after importing manually created project #3509)
  2. The init script was hard-coding the version to ^7.2.0 instead of matching the current Electron Forge version.

The first bug was fixed by #3535, which added both @electron/fuses and @electron-forge/plugin-fuses to the base dependencies we install via the initNPM utility function:

export const devDeps = [
'@electron/fuses',
siblingDep('cli'),
siblingDep('maker-squirrel'),
siblingDep('maker-zip'),
siblingDep('maker-deb'),
siblingDep('maker-rpm'),
siblingDep('plugin-auto-unpack-natives'),
siblingDep('plugin-fuses'),
];

Solution

#3535 actually made adding the deps via tmpl/package.json redundant because they're treated as "common" dependencies (i.e. non-template-specific) and installed anyways. The solution to fixing the second problem is just to remove the deps from tmpl/package.json altogether.

BaseTemplate changes

While crafting this PR, I found that we actually support adding dependencies via templates in another way: adding them to the TemplateClass.dependencies or TemplateClass.devDependencies arrays.

The BaseTemplate has a getter for devDependencies that does the magic replacement for the ELECTRON_FORGE/VERSION syntax, but no equivalent for dependencies. This PR changes that.

It also extends a specific custom initializer fixture to grab dependencies and devDependencies from the base package.json via these getters so that custom deps are added to what we expect from the base template.

@erickzhao erickzhao requested a review from yangannyx January 29, 2025 03:53
@erickzhao erickzhao marked this pull request as ready for review January 29, 2025 18:27
@erickzhao erickzhao requested a review from a team as a code owner January 29, 2025 18:27
@erickzhao erickzhao added this pull request to the merge queue Jan 29, 2025
Merged via the queue into main with commit 062ec75 Jan 29, 2025
13 checks passed
@erickzhao erickzhao deleted the ELECTRON_FORGE/VERSION-1-more branch January 29, 2025 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants