Skip to main content

Electron 十周年 🎉

· 18 min read

🌐 10 Years of Electron 🎉

electron/electron 仓库的第一次提交是在 2013 年 3 月 13 日[^1]。

🌐 The first commit to the electron/electron repository was on March 13, 2013[^1].

Initial commit on electron/electron by @aroben

经过10年和1192名独立贡献者的27,147次提交后,Electron 已成为当今构建桌面应用最受欢迎的框架之一。这个里程碑是一个完美的机会,让我们庆祝并回顾迄今为止的旅程,同时分享我们在此进程中所学到的经验。

如果没有每一位为项目付出时间和努力的人,我们今天不会站在这里。虽然源代码提交总是最显眼的贡献,但我们同样需要感谢那些报告错误、维护用户模块、提供文档和翻译,以及在网络空间参与 Electron 社区的人。每一份贡献对我们这些维护者来说都是无价的。

🌐 We would not be here today without everyone who has dedicated their time and effort to contribute to the project. Although source code commits are always the most visible contributions, we also have to acknowledge the effort of folks who report bugs, maintain userland modules, provide documentation and translations, and participate in the Electron community across cyberspace. Every contribution is invaluable to us as maintainers.

在我们继续阅读博客文章剩下部分之前:谢谢你。❤️

我们是怎么走到这一步的?

🌐 How did we get here?

Atom Shell 是作为 GitHub Atom 编辑器 的基础而构建的,该编辑器于 2014 年 4 月推出了公开测试版。它从零开始开发,作为当时可用的基于网络的桌面框架(node-webkit 和 Chromium 嵌入式框架)的替代方案。它有一个杀手级功能:嵌入 Node.js 和 Chromium,为 web 技术提供强大的桌面运行环境。

在一年内,Atom Shell 在功能和受欢迎程度上都开始迅速增长。大公司、初创企业以及个人开发者都开始用它来构建应用(一些早期采用者包括 SlackGitKrakenWebTorrent),项目也因此被恰当地重命名为 Electron

🌐 Within a year, Atom Shell began seeing immense growth in capabilities and popularity. Large companies, startups, and individual developers alike had started building apps with it (some early adopters include Slack, GitKraken, and WebTorrent), and the project was aptly renamed to Electron.

从那时起,Electron 就一发不可收拾,持续发展。以下是我们每周下载量的变化情况,由 npmtrends.com 提供:

🌐 From then on, Electron hit the ground running and never stopped. Here’s a look at our weekly download count over time, courtesy of npmtrends.com:

Electron weekly downloads graph over time

Electron v1 于 2016 年发布,承诺提供更稳定的 API 以及更好的文档和工具。Electron v2 于 2018 年发布,推出了语义化版本控制,使 Electron 开发者更容易跟踪发布周期。

🌐 Electron v1 was released in 2016, promising increased API stability and better docs and tooling. Electron v2 was released in 2018 and introduced semantic versioning, making it easier for Electron developers to keep track of the release cycle.

到了 Electron v6,我们改为每 12 周发布一次重大版本,以与 Chromium 的发布节奏保持一致。这一决策意味着项目思维方式的转变,将“拥有最新的 Chromium 版本”从可有可无变为了优先事项。这减少了升级之间的技术债务,使我们更容易保持 Electron 的更新和安全。

🌐 By Electron v6, we shifted to a regular 12-week major release cadence to match Chromium’s. This decision was a change in mentality for the project, bringing “having the most up-to-date Chromium version” from a nice-to-have to a priority. This has reduced the amount of tech debt between upgrades, making it easier for us to keep Electron updated and secure.

从那以后,我们就像一台运转良好的机器,每当 Chromium 发布稳定版时,我们也会在同一天发布新的 Electron 版本。到了 2021 年 Chromium 将发布周期加快到 4 周时,我们能够轻轻一耸肩,并相应地将我们的发布频率提高到 8 周。

🌐 Since then, we’ve been a well-oiled machine, releasing a new Electron version on the same day as every Chromium stable. By the time Chromium sped up their release schedule to 4 weeks in 2021, we were able to shrug our shoulders and increase our release cadence to 8 weeks accordingly.

我们现在已经在使用 Electron v23(且仍在更新中),并且仍然致力于打造最好的跨平台桌面应用运行时。即便近年来 JavaScript 开发工具蓬勃发展,Electron 仍然是桌面应用框架字段中稳定、经过实战考验的中坚力量。如今,Electron 应用随处可见:你可以用它编程(如 Visual Studio Code)、设计(如 Figma)、沟通(如 Slack)、做注意(如 Notion)——以及许多其他应用场景。我们为这一成就感到非常自豪,也感谢每一位让这一切成为可能的人。

🌐 We’re now on Electron v23 (and counting), and are still dedicated to building the best runtime for building cross-platform desktop applications. Even with the boom in JavaScript developer tools in recent years, Electron has remained a stable, battle-tested stalwart of the desktop app framework landscape. Electron apps are ubiquitous nowadays: you can program with Visual Studio Code, design with Figma, communicate with Slack, and take notes with Notion (amongst many other use cases). We’re incredibly proud of this achievement and grateful to everyone who has made it possible.

我们在此进程中学到了什么?

🌐 What did we learn along the way?

走向十周年的道路漫长而曲折。以下是一些帮助我们运营可持续大型开源项目的关键因素。

🌐 The road to the decade mark has been long and winding. Here are some key things that have helped us run a sustainable large open source project.

使用治理模型扩展分布式决策

🌐 Scaling distributed decision-making with a governance model

我们必须克服的一个挑战是,在 Electron 首次爆红之后,如何处理项目的长期方向。我们如何应对作为一个由几十名工程师组成、分布在不同公司、国家和时区的团队的情况?

🌐 One challenge we had to overcome was handling the long-term direction of the project once Electron first exploded in popularity. How do we handle being a team of a couple dozen engineers distributed across companies, countries, and time zones?

在早期,Electron 的维护者团队依赖非正式的协调方式,这对于较小的项目来说快速且轻量,但无法扩展到更广泛的协作中。2019 年,我们转向了一种治理模式,不同的工作组拥有正式的职责范围。这对于简化进程和将项目部分所有权分配给特定维护者起到了重要作用。如今,每个工作组(WG)负责的具体内容是什么?

🌐 In the early days, Electron’s maintainer group relied on informal coordination, which is fast and lightweight for smaller projects, but doesn’t scale to wider collaboration. In 2019, we shifted to a governance model where different working groups have formal areas of responsibility. This has been instrumental in streamlining processes and assigning portions of project ownership to specific maintainers. What is each Working Group (WG) responsible for nowadays?

  • 发布 Electron 版本(发布工作组)
  • 升级 Chromium 和 Node.js(升级工作组)
  • 监督公共 API 设计 (API WG)
  • 保障 Electron 安全(安全工作组)
  • 运行网站、文档和工具(生态系统工作组)
  • 社区和企业拓展(拓展工作组)
  • 社区审核(社区与安全工作组)
  • 维护我们的构建基础设施、维护工具和云服务(基础设施工作组)

差不多在我们转向治理模式的同时,我们也将 Electron 的所有权从 GitHub 转移到了 OpenJS 基金会。虽然最初的核心团队今天仍在微软工作,但他们只是构成 Electron 治理的更大协作团队的一部分。[2]

🌐 Around the same time we shifted to the governance model, we also moved Electron's ownership from GitHub to the OpenJS Foundation. Although the original core team still works at Microsoft today, they are only a part of a larger group of collaborators that form Electron governance.[^2]

虽然这个模式并不完美,但它在全球大流行和持续的宏观经济逆风中一直很适合我们。展望未来,我们计划改进治理章程,以引导我们度过 Electron 的第二个十年。

🌐 While this model isn’t perfect, it has suited us well through a global pandemic and ongoing macroeconomic headwinds. Going forward, we plan on revamping the governance charter to guide us through the second decade of Electron.

info

如果你想了解更多,可以查看 electron/governance 仓库!

🌐 If you want to learn more, check out the electron/governance repository!

社区

🌐 Community

开源项目的社区部分很难,尤其是当你的宣传团队只有十几个工程师,却穿着一件写着“社区经理”的风衣时。不过,作为一个大型开源项目,我们拥有大量用户,利用他们的力量为 Electron 构建用户生态系统是维持项目健康的一个关键部分。

🌐 The community part of open source is hard, especially when your Outreach team is a dozen engineers in a trench coat that says “community manager”. That said, being a large open source project means that we have a lot of users, and harnessing their energy for Electron to build a userland ecosystem is a crucial part of sustaining project health.

我们做了哪些工作来提升社区影响力?

🌐 What have we been doing to develop our community presence?

构建虚拟社区

🌐 Building virtual communities

参与高知名度开源项目

🌐 Participating in high-visibility open source programs

让一切自动化!

🌐 Automate all the things!

截至今天,Electron 的治理团队大约有 30 名活跃维护者。不到一半是全职贡献者,这意味着有很多工作需要分担。我们保持一切顺利运转的秘诀是什么?我们的座右铭是计算机便宜,而人类的时间宝贵。以典型工程师的方式,我们开发了一套自动化支持工具来让我们的工作更轻松。

🌐 Today, Electron governance has about 30 active maintainers. Less than half of us are full-time contributors, which means that there’s a lot of work to go around. What’s our trick to keeping everything running smoothly? Our motto is that computers are cheap, and human time is expensive. In typical engineer fashion, we’ve developed a suite of automated support tooling to make our lives easier.

非 Goma

🌐 Not Goma

Electron 核心代码库是一个庞大的 C++ 代码集合,构建时间一直是限制我们快速发布 bug 修复和新功能的因素。2020 年,我们部署了 Not Goma,这是一个为 Electron 定制的 Google Goma 分布式编译服务的后端。Not Goma 会处理授权用户机器的编译请求,并将编译进程分发到后端的数百个核心上。它还会缓存编译结果,因此其他人编译相同的文件时,只需下载预编译结果。

🌐 The core Electron codebase is a behemoth of C++ code, and build times have always been a limiting factor in how fast we can ship bug fixes and new features. In 2020, we deployed Not Goma, a custom Electron-specific backend for Google’s Goma distributed compiler service. Not Goma processes compilation requests from authorized user’s machines and distributes the process across hundreds of cores in the backend. It also caches the compilation result so that someone else compiling the same files will only need to download the pre-compiled result.

自从推出 Not Goma 以来,维护者的编译时间已经从几小时缩短到几分钟。稳定的互联网连接成为贡献者编译 Electron 的最低要求!

🌐 Since launching Not Goma, compilation times for maintainers have decreased from the scale of hours to minutes. A stable internet connection became the minimum requirement for contributors to compile Electron!

info

如果你是开源贡献者,你也可以尝试使用 Not Goma 的只读缓存,它在默认情况下随 Electron Build Tools 提供。

🌐 If you’re an open source contributor, you can also try Not Goma’s read-only cache, which is available by default with Electron Build Tools.

持续因素身份验证

🌐 Continuous Factor Authentication

持续因子认证(CFA) 是围绕 npm 的双因素认证(2FA)系统的一层自动化,我们将其与 semantic-release 结合,以管理我们各个 @electron/ npm 包的安全和自动化发布。

虽然 semantic-release 已经自动化了 npm 包的发布进程,但它需要关闭双因素认证或传入一个绕过此限制的秘密令牌。

🌐 While semantic-release already automates the npm package publishing process, it requires turning off two-factor authentication or passing in a secret token that bypasses this restriction.

我们构建了 CFA,用于为 npm 双因素认证 (2FA) 提供基于时间的一次性密码 (TOTP) 到任意 CI 作业,从而让我们能够利用 semantic-release 的自动化,同时保持双因素认证的额外安全性。

🌐 We built CFA to deliver a time-based one-time password (TOTP) for npm 2FA to arbitrary CI jobs, allowing us to harness the automation of semantic-release while keeping the additional security of two-factor authentication.

我们使用带有 Slack 集成前端的 CFA,使维护者可以从任何安装了 Slack 的设备上验证软件包发布,只要他们手边有 TOTP 生成器。

🌐 We use CFA with a Slack integration front-end, allowing maintainers to validate package publishing from any device they have Slack on, as long as they have their TOTP generator handy.

info

如果你想在自己的项目中尝试 CFA,可以查看 GitHub 仓库文档! 如果你使用 CircleCI 作为 CI 提供商,我们还有 一个方便的 orb 可以快速使用 CFA 搭建项目。

🌐 If you want to try CFA out in your own projects, check out the GitHub repository or the docs! If you use CircleCI as your CI provider, we also have a handy orb to quickly scaffold a project with CFA.

Sheriff

Sheriff 是我们编写的一个开源工具,用于自动管理 GitHub、Slack 和 Google Workspace 的权限。

Sheriff 的核心价值主张是权限管理应该是一个透明的进程。它使用一个单一的 YAML 配置文件来指定上述所有服务的权限。使用 Sheriff,获得仓库的协作者身份或创建一个新的邮件列表就像批准并合并一个 PR 一样简单。

🌐 Sheriff’s key value proposition is that permission management should be a transparent process. It uses a single YAML config file that designates permissions across all the above listed services. With Sheriff, getting collaborator status on a repo or creating a new mailing list is as easy as getting a PR approved and merged.

Sheriff 还有一个审计日志,会发布到 Slack,当 Electron 组织中的任何地方发生可疑活动时,会警告管理员。

🌐 Sheriff also has an audit log that posts to Slack, warning admins when suspicious activity occurs anywhere in the Electron organization.

……以及我们所有的 GitHub 机器人

🌐 …and all our GitHub bots

GitHub 是一个具有丰富 API 可扩展性的平台,并且拥有一个名为 Probot 的第一方机器人应用框架。为了帮助我们专注于工作中更具创造性的部分,我们开发了一系列小型机器人,帮助我们处理繁琐的工作。以下是几个示例:

🌐 GitHub is a platform with rich API extensibility and a first-party bot application framework called Probot. To help us focus on the more creative parts of our job, we built out a suite of smaller bots that help do the dirty work for us. Here are a few examples:

  • Sudowoodo 自动化了 Electron 的整个发布进程,从启动构建到将发布资源上传到 GitHub 和 npm,一应俱全。
  • Trop 通过尝试根据 GitHub PR 标签将补丁挑选到以前的发布分支,自动化 Electron 的回移植进程。
  • Roller 自动化 Electron 的 Chromium 和 Node.js 依赖的滚动升级。
  • Cation 是我们用于 electron/electron PR 的状态检查机器人。

总而言之,我们的机器人小家族极大地提高了开发者的生产力!

🌐 Altogether, our little family of bots has given us a huge boost in developer productivity!

下一步是什么?

🌐 What’s next?

随着我们作为一个项目进入第二个十年,你可能会问:Electron 的下一步是什么?

🌐 As we enter our second decade as a project, you might be asking: what’s next for Electron?

我们将与 Chromium 的发布节奏保持同步,每 8 周发布一次 Electron 的新主版本,使框架保持最新的 Web 平台和 Node.js 特性,同时确保企业级应用的稳定性和安全性。

🌐 We’re going to stay in sync with Chromium's release cadence, releasing new major versions of Electron every 8 weeks, keeping the framework updated with the latest and greatest from the web platform and Node.js while maintaining stability and security for enterprise-grade applications.

我们通常会在即将开展的计划变得具体时发布相关新闻。如果你想了解未来的版本、功能和一般项目更新,可以阅读我们的博客并关注我们的社交媒体账户(TwitterMastodon)!

🌐 We generally announce news on upcoming initiatives when they become concrete. If you want to keep up with future releases, features, and general project updates, you can read our blog and follow our social media profiles (Twitter and Mastodon)!

[^1]: 这实际上是来自 electron-archive/brightray 项目 的第一个提交,该项目在 2017 年被并入 Electron 并合并了其 git 历史记录。但谁在乎呢? 今天是我们的生日,所以我们可以自己定规则!

[^2]:与大众认知相反,Electron 目前不再由 GitHub 或微软拥有,而是如今属于 OpenJS 基金会 的一部分。