Skip to main content

生态系统 2023 年回顾

· 9 min read

回顾 2023 年 Electron 开发者生态系统的改进和变化。

🌐 Reflecting on the improvements and changes in Electron's developer ecosystem in 2023.


在过去的几个月里,我们一直在 Electron 生态系统中进行一些改进,以全面提升 Electron 应用的开发者体验!这里是来自 Electron 总部的最新更新的快速概览。

🌐 In the past few months, we've been cooking up some changes across the Electron ecosystem to supercharge the developer experience for Electron apps! Here’s a swift rundown of the latest additions straight from Electron HQ.

Electron Forge 7 及更高版本

🌐 Electron Forge 7 and beyond

Electron Forge 7 - 我们用于打包和分发 Electron 应用的一体化工具的最新主要版本 - 现已推出。

🌐 Electron Forge 7 — the newest major version of our all-in-one tool for packaging and distributing Electron applications — is now available.

虽然 Forge 6 是对 v5 的完全重写,v7 的范围较小,但仍然包含一些破坏性更改。今后,我们将继续发布 Forge 的主要版本,以便在需要进行破坏性更改时使用。

🌐 While Forge 6 was a complete rewrite from v5, v7 is smaller in scope but still contains a few breaking changes. Going forward, we will continue to publish major versions of Forge as breaking changes need to be made.

欲了解更多详情,请参见 GitHub 上完整的 Forge v7.0.0 更新日志

🌐 For more details, see the full Forge v7.0.0 changelog on GitHub.

重大变更

🌐 Breaking changes

  • 切换到 macOS 公证的 notarytool 自 2023-11-01 起,Apple 停用了用于 macOS 公证的旧 altool,本次发布已从 Electron Forge 中完全移除它。
  • 最低 Node.js 版本提升至 v16.4.0: 在此版本中,我们将最低要求的 Node.js 版本设为 16.4.0。
  • 已停止支持 electron-prebuiltelectron-prebuilt-compileelectron-prebuilt 曾是 Electron 的 npm 模块的原始名称,但在 v1.3.1 中被 electron 取代。electron-prebuilt-compile 是该二进制文件的一个替代方案,提供了增强的开发者体验功能,但最终被放弃。

亮点

🌐 Highlights

  • Google 云存储发布者 作为我们推动更好支持静态自动更新的一部分,Electron Forge 现在支持直接发布到 Google 云存储!
  • ESM forge.config.js 支持 Electron Forge 现在支持 ESM forge.config.js 文件。(附注:期待在 Electron 28 中支持 ESM 入口点。)
  • 现在 Makers 可以并行运行 在 Electron Forge 6 中,Makers 出于✨传统✨原因是顺序运行的。从那时起,我们已经在 Make 步骤中测试了并行化,没有出现任何负面影响,因此在为同一平台构建多个目标时,你应该会看到速度提升!
谢谢!

🙇 非常感谢 mahnunchik 对 Forge 配置中 GCS 发布器和 ESM 支持的贡献!

更完善的静态存储自动更新

🌐 Better static storage auto updates

Squirrel.Windows 和 Squirrel.Mac 是针对特定平台的更新技术,支持 Electron 内置的 autoUpdater 模块。这两个项目通过两种方式支持自动更新:

🌐 Squirrel.Windows and Squirrel.Mac are platform-specific updater technologies that back Electron’s built-in autoUpdater module. Both projects support auto updates via two methods:

  • 兼容 Squirrel 的更新服务器
  • 托管在静态存储提供商(例如 AWS、Google Cloud Platform、Microsoft Azure 等)上的清单 URL

更新服务器方法传统上一直是 Electron 应用的推荐方法(并且提供了对更新逻辑的额外自定义),但它有一个很大的缺点 - 如果应用是闭源的,它需要维护自己的服务器实例。

🌐 The update server method has traditionally been the recommended approach for Electron apps (and provides additional customization of update logic), but it has a major downside—it requires apps to maintain their own server instance if they are closed-source.

另一方面,静态存储方法一直以来都是可行的,但在 Electron 中没有文档记录,并且在 Electron 工具包中支持不佳。

🌐 On the other hand, the static storage method has always been possible, but was undocumented within Electron and poorly supported across Electron tooling packages.

@MarshallOfSound 的出色工作下,无服务器自动应用更新的更新进程被大大简化了:

🌐 With some great work from @MarshallOfSound, the update story for serverless automatic app updates has been drastically streamlined:

  • Electron Forge 的 Zip 和 Squirrel.Windows 制作工具现在可以配置为输出 autoUpdater 兼容的更新清单。
  • update-electron-app 的新主要版本(v2.0.0)现在可以读取这些生成的清单,作为替代 update.electronjs.org 服务器的选项。

一旦你的 Makers 和 Publishers 配置为将更新清单上传到云文件存储,你只需几行配置即可启用自动更新:

🌐 Once your Makers and Publishers are configured to upload update manifests to cloud file storage, you can enable auto updates with only a few lines of configuration:

const { updateElectronApp, UpdateSourceType } = require('update-electron-app');

updateElectronApp({
updateSource: {
type: UpdateSourceType.StaticStorage,
baseUrl: `https://my-manifest.url/${process.platform}/${process.arch}`,
},
});
进一步阅读

📦 想了解更多吗?有关详细指南,请参阅 Forge 的自动更新文档

@electron/ 扩展宇宙

🌐 The @electron/ extended universe

当 Electron 刚刚起步时,社区发布了许多用于增强开发、打包和分发 Electron 应用体验的包。随着时间的推移,其中许多包被纳入 Electron 的 GitHub 组织,由核心团队承担维护工作。

🌐 When Electron first started, the community published many packages to enhance the experience of developing, packaging, and distributing Electron apps. Over time, many of these packages were incorporated into Electron’s GitHub organization, with the core team taking on the maintenance burden.

在2022年,我们开始将所有这些一方工具统一到 npm 上的 @electron/ 命名空间下。这个变化意味着,以前是 electron-foo 的包现在在 npm 上变为 @electron/foo,而以前命名为 electron/electron-foo 的仓库现在在 GitHub 上变为 electron/foo。这些变化有助于清晰地区分一方项目和用户项目。这包括许多常用的包,例如:

🌐 In 2022, we began unifying all these first-party tools under the @electron/ namespace on npm. This change means that packages that used to be electron-foo are now @electron/foo on npm, and repositories that used to be named electron/electron-foo are now electron/foo on GitHub. These changes help clearly delineate first-party projects from userland projects. This includes many commonly used packages, such as:

  • @electron/asar
  • @electron/fuses
  • @electron/get
  • @electron/notarize
  • @electron/osx-sign
  • @electron/packager
  • @electron/rebuild
  • @electron/remote
  • @electron/symbolicate-mac
  • @electron/universal

今后,我们发布的所有第一方软件包也将位于 @electron/ 命名空间中。对此规则有两个例外:

🌐 Going forward, all first-party packages we release will also be in the @electron/ namespace. There are two exceptions to this rule:

  • Electron 核心将继续在 electron 包下发布。
  • Electron Forge 将继续在 @electron-forge/ 命名空间下发布其所有的 monorepo 包。
寻星

⭐ 在此进程中,我们还不小心将 electron/packager 仓库设为私有,这带来了一个不幸的副作用——清除了我们在 GitHub 上的星标数量(清除前超过 9000 个)。如果你是 Packager 的活跃用户,我们将非常感激你的 ⭐ Star ⭐!

介绍 @electron/windows-sign

🌐 Introducing @electron/windows-sign

从 2023 年 6 月 1 日起,行业标准开始要求 Windows 代码签名证书的密钥存储在符合 FIPS 标准的硬件上。

🌐 Starting on 2023-06-01, industry standards began requiring keys for Windows code signing certificates to be stored on FIPS-compliant hardware.

实际上,这意味着在持续集成 (CI) 环境中构建和签名的应用的代码签名变得更加困难,因为许多 Electron 工具会将证书文件和密码作为配置参数,并尝试使用硬编码逻辑从那里进行签名。

🌐 In practice, this meant that code signing became a lot harder for apps that build and sign in CI environments, since many Electron tools take in a certificate file and password as config parameters and attempt to sign from there using hardcoded logic.

这种情况一直是 Electron 开发者常遇到的痛点,这就是为什么我们一直在努力寻找更好的解决方案,将 Windows 代码签名隔离到一个独立的步骤中,类似于 @electron/osx-sign 在 macOS 上的做法。

🌐 This situation has been a common pain point for Electron developers, which is why we have been working on a better solution that isolates Windows code signing into its own standalone step, similar to what @electron/osx-sign does on macOS.

未来,我们计划将此软件包完全整合到 Electron Forge 工具链中,但目前它是独立存在的。该软件包目前可以在 npm install --save-dev @electron/windows-sign 安装,并且可以通过编程方式或命令行使用。

🌐 In the future, we plan on fully integrating this package into the Electron Forge toolchain, but it currently lives on its own. The package is currently available for installation at npm install --save-dev @electron/windows-sign and can used programmatically or via CLI.

请试用一下,并在仓库的问题跟踪中给我们反馈!

🌐 Please try it out and give us your feedback in the repo’s issue tracker!

下一步是什么?

🌐 What's next?

我们将在下个月进入每年的十二月静默期。在此期间,我们会思考如何在2024年让 Electron 的开发体验变得更好。

🌐 We'll be entering our annual December quiet period next month. While we do, we'll be thinking about how we can make the Electron development experience even better in 2024.

你希望我们接下来做些什么吗?请告诉我们!

🌐 Is there anything you'd like to see us work on next? Let us know!