Skip to main content

2023 年生态系统回顾

· 13 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

  • 已切换到 notarytool 进行 macOS 公证:自 2023 年 11 月 1 日起,Apple 将停止支持 macOS 的旧版 altool 公证,此版本将其从 Electron Forge 中完全移除。

    ¥Switched to notarytool for macOS notarization: As of 2023-11-01, Apple sunset the legacy altool for macOS notarization, and this release removes it from Electron Forge entirely.

  • 最低 Node.js 版本提升至 v16.4.0:在此版本中,我们将最低要求的 Node.js 版本设置为 16.4.0。

    ¥Minimum Node.js increased to v16.4.0: With this release, we’ve set the minimum required Node.js version to 16.4.0.

  • 停止对 electron-prebuiltelectron-prebuilt-compile 的支持:electron-prebuilt是 Electron npm 模块的原始名称 一样,但在 v1.3.1 中被 electron 取代。electron-prebuilt-compile 是该二进制文件的替代方案,它带有增强的 DX 功能,但最终被放弃。

    ¥Dropped support for electron-prebuilt and electron-prebuilt-compile: electron-prebuilt was the original name for Electron’s npm module, but was replaced by electron in v1.3.1. electron-prebuilt-compile was an alternative to that binary that came with enhanced DX features, but was eventually abandoned as a project.

亮点

¥Highlights

  • Google Cloud Storage 发布者:为了更好地支持静态自动更新,Electron Forge 现在支持直接发布到 Google Cloud Storage!

    ¥Google Cloud Storage publisher: As part of our push to better support static auto updating, Electron Forge now supports publishing directly to Google Cloud Storage!

  • ESM forge.config.js 支持:Electron Forge 现已支持 ESM forge.config.js 文件。(附:期待 Electron 28 中对 ESM 入口点的支持。)

    ¥ESM forge.config.js support: Electron Forge now supports ESM forge.config.js files. (P.S. Look forward to ESM entrypoint support in Electron 28.)

  • Makers 现在运行于并行:在 Electron Forge 6 中,由于 ✨ 遗留 ✨ 原因,Makers 按顺序运行。从那时起,我们已经测试了 Make 步骤的并行化,没有任何不良副作用,因此在为同一平台构建多个目标时,你应该会看到速度的提升!

    ¥Makers now run in parallel: In Electron Forge 6, Makers ran sequentially for ✨ legacy ✨ reasons. Since then, we’ve tested out parallelization for the Make step with no adverse side effects, so you should see a speed-up when building multiple targets for the same platform!

谢谢!

🙇 非常感谢 mahnunchik 为 Forge 配置中的 GCS Publisher 和 ESM 支持所做的贡献!

¥🙇 Big thanks to mahnunchik for the contributions for both the GCS Publisher and ESM support in Forge configurations!

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

¥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 的更新服务器

    ¥A Squirrel-compatible update server

  • 托管在静态存储提供商(例如 AWS、Google Cloud Platform、Microsoft Azure 等)上的清单 URL

    ¥A manifest URL hosted on a static storage provider (e.g. AWS, Google Cloud Platform, Microsoft Azure, etc.)

更新服务器方法传统上一直是 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 兼容的更新清单。

    ¥Electron Forge’s Zip and Squirrel.Windows makers can now be configured to output autoUpdater-compatible update manifests.

  • update-electron-app 的新主要版本 (v2.0.0) 现在可以读取这些生成的清单,作为 update.electronjs.org 服务器的替代方案。

    ¥A new major version of update-electron-app (v2.0.0) can now read these generated manifests as an alternative to the update.electronjs.org server.

一旦你的 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 自动更新文档

¥📦 Want to learn more? For a detailed guide, see Forge’s auto update documentation.

@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 core will continue to be published under the electron package.

  • Electron Forge 将继续在 @electron-forge/ 命名空间下发布其所有 monorepo 软件包。

    ¥Electron Forge will continue to publish all of its monorepo packages under the @electron-forge/ namespace.

寻星

⭐ 在此过程中,我们还意外地将 electron/packager 仓库私有化,这带来了不幸的副作用,导致我们的 GitHub 星数被抹去(抹去之前超过 9000)。如果你是 Packager 的活跃用户,请给我们一个 ⭐ Star ⭐!

¥⭐ During this process, we also accidentally took the electron/packager repository private, which has the unfortunate side effect of erasing our GitHub star count (over 9000 before the erasure). If you are an active user of Packager, we’d appreciate a ⭐ 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 安装,并可通过编程方式或 CLI 使用。

¥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?

下个月我们将进入一年一度的 12 月静默期。与此同时,我们会思考如何在 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!