Skip to main content

Electron 十年 🎉

· 25 min read

¥10 Years of Electron 🎉

electron/electron 代码库的首次提交是在 2013 年 3 月 13 日 1

¥The first commit to the electron/electron repository was on March 13, 20131.

Initial commit on electron/electron by @aroben

10 年后,1192 位独立贡献者提交了 27,147 次提交,Electron 已成为当今最受欢迎的桌面应用构建框架之一。这个里程碑是我们庆祝和反思迄今为止的旅程,并分享我们一路走来所学知识的绝佳机会。

¥10 years and 27,147 more commits from 1192 unique contributors later, Electron has become one of the most popular frameworks for building desktop applications today. This milestone is the perfect opportunity to celebrate and reflect on our journey so far, and to share what we’ve learned along the way.

如果没有每一位为项目贡献时间和精力的朋友们,我们就不会有今天的成就。虽然源代码提交始终是最明显的贡献,但我们也必须感谢那些报告错误、维护用户空间模块、提供文档和翻译以及参与网络空间 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.

**在继续阅读本博文的其余部分之前:谢谢。❤️ **

¥Before we continue with the rest of the blog post: thank you. ❤️

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

¥How did we get here?

Atom Shell 是作为 GitHub Atom 编辑器 的骨干构建的,Atom 编辑器 于 2014 年 4 月发布了公测版。它是从头构建的,作为当时可用的基于 Web 的桌面框架(node-webkit 和 Chromium 嵌入式框架)的替代方案。它有一个杀手级功能:嵌入 Node.js 和 Chromium,为 Web 技术提供强大的桌面运行时。

¥Atom Shell was built as the backbone for GitHub’s Atom editor, which launched in public beta in April 2014. It was built from the ground up as an alternative to the web-based desktop frameworks available at the time (node-webkit and Chromium Embedded Framework). It had a killer feature: embedding Node.js and Chromium to provide a powerful desktop runtime for web technologies.

在一年之内,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 版本(发布工作组)

    ¥Getting Electron releases out the door (Releases WG)

  • 升级 Chromium 和 Node.js(升级工作组)

    ¥Upgrading Chromium and Node.js (Upgrades WG)

  • 监督公共 API 设计 (API WG)

    ¥Overseeing public API design (API WG)

  • 保障 Electron 安全(安全工作组)

    ¥Keeping Electron secure (Security WG)

  • 运行网站、文档和工具(生态系统工作组)

    ¥Running the website, documentation, and tooling (Ecosystem WG)

  • 社区和企业拓展(拓展工作组)

    ¥Community and corporate outreach (Outreach WG)

  • 社区审核(社区与安全工作组)

    ¥Community moderation (Community & Safety WG)

  • 维护我们的构建基础设施、维护工具和云服务(基础设施工作组)

    ¥Maintaining our build infrastructure, maintainer tools, and cloud services (Infrastructure WG)

在我们转向治理模式的同时,我们也将 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.

信息

如果你想了解更多信息,请查看 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

  • 2020 年,我们推出了社区 Discord 服务器。我们之前在 Atom 论坛中有一个版块,但后来决定创建一个更非正式的交流平台,为维护人员和 Electron 开发者提供一个交流的空间,并提供常规的调试帮助。

    ¥In 2020, we launched our community Discord server. We previously had a section in Atom’s forum, but decided to have a more informal messaging platform to have a space for discussions between maintainers and Electron developers and for general debugging help.

  • 2021 年,我们在 @BlackHole1 的帮助下建立了 Electron 中国 用户组。该小组在 Electron 在中国蓬勃发展的科技字段用户中的增长中发挥了重要作用,为他们提供了一个在英语之外进行创意合作和讨论 Electron 的空间。空格。我们还要感谢 cnpm 在其 npm 中文镜像中支持 Electron 的夜间发布。

    ¥In 2021, we established the Electron China user group with the help of @BlackHole1. This group has been instrumental in Electron growth in users from China’s booming tech scene, providing a space for them to collaborate on ideas and discuss Electron outside of our English-language spaces. We’d also like to thank cnpm for their work in supporting Electron’s nightly releases in their Chinese mirror for npm.

参与高知名度开源项目

¥Participating in high-visibility open source programs

  • 自 2019 年以来,我们每年都会庆祝 Hacktoberfest。Hacktoberfest 是由 DigitalOcean 组织的年度开源庆祝活动,每年都会有数十位热情的贡献者参与其中,希望在开源软件字段留下自己的印记。

    ¥We have been celebrating Hacktoberfest every year since 2019. Hacktoberfest is yearly celebration of open source organized by DigitalOcean, and we get dozens of enthusiastic contributors every year looking to make their mark on open source software.

  • 2020 年,我们参与了 Google Season of Docs 的初始迭代,并与 @bandantonio 合作重新设计了 Electron 的新用户教程流程。

    ¥In 2020, we participated in the initial iteration of Google Season of Docs, where we worked with @bandantonio to rework Electron’s new user tutorial flow.

  • 2022 年,我们首次指导了一位 Google Summer of Code 的学生。@aryanshridhar 做了一些出色的工作,重构了 Electron Fiddle 的核心版本加载逻辑,并将其打包器迁移到 webpack

    ¥In 2022, we mentored a Google Summer of Code student for the first time. @aryanshridhar did some awesome work to refactor Electron Fiddle's core version loading logic and migrate its bundler to webpack.

让一切自动化!

¥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++ 代码组成的,构建时间一直是我们发布错误修复和新功能速度的限制因素。在 2020 年,我们部署了 非 Goma,这是一个为 Google Goma 分布式编译器服务定制的 Electron 专用后端。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!

信息

如果你是开源贡献者,你还可以尝试 Not Goma 的只读缓存,该功能在 Electron 构建工具 中默认启用。

¥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 软件包的安全自动发布。

¥Continuous Factor Authentication (CFA) is a layer of automation around npm’s two-factor authentication (2FA) system that we combine with semantic-release to manage secure and automated releases of our various @electron/ npm packages.

虽然 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 向任意 CI 作业提供基于时间的一次性密码 (TOTP),这使我们能够利用语义发布的自动化功能,同时保留双因素身份验证的额外安全性。

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

我们使用 CFA 和 Slack 集成前端,允许维护人员在任何装有 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.

信息

如果你想在自己的项目中尝试 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 is an open source tool we wrote to automate the management of permissions across GitHub, Slack, and 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。

    ¥Sudowoodo automates the Electron release process from start to finish, from kicking off builds to uploading the release assets to GitHub and npm.

  • Trop 通过尝试根据 GitHub PR 标签挑选补丁到之前的版本分支,自动化了 Electron 的反向移植过程。

    ¥Trop automates the backporting process for Electron by attempting to cherry-pick patches to previous release branches based on GitHub PR labels.

  • Roller 自动滚动升级 Electron 的 Chromium 和 Node.js 依赖。

    ¥Roller automates rolling upgrades of Electron’s Chromium and Node.js dependencies.

  • Cation 是我们用于 electron/electron PR 状态检查的机器人。

    ¥Cation is our status check bot for electron/electron PRs.

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

¥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)!

Footnotes

  1. 这实际上是 electron-archive/brightray 项目 的第一次提交,electron-archive/brightray 项目 于 2017 年被并入 Electron,并将其 git 历史记录合并。但谁在乎呢?今天是我们的生日,所以我们来制定规则吧!

    ¥This is actually the first commit from the electron-archive/brightray project, which got absorbed into Electron in 2017 and had its git history merged. But who’s counting? It’s our birthday, so we get to make the rules! 2

  2. 与普遍看法相反,Electron 不再归 GitHub 或 Microsoft 所有,而是现在属于 OpenJS 基金会 的一部分。

    ¥Contrary to popular belief, Electron is no longer owned by GitHub or Microsoft, and is part of the OpenJS Foundation nowadays. 2