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

refactor: TypeScript rewrite #1593

Merged
merged 39 commits into from
Dec 5, 2023
Merged

refactor: TypeScript rewrite #1593

merged 39 commits into from
Dec 5, 2023

Conversation

erikian
Copy link
Member

@erikian erikian commented Nov 3, 2023

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • The changes are appropriately documented (if applicable).
  • The changes have sufficient test coverage (if applicable).
  • The testsuite passes successfully on my local machine (if applicable).

Summarize your changes:

@request-info request-info bot added the needs info Issue reporter needs to provide more information for maintainers to take action label Nov 3, 2023
@erikian erikian removed the needs info Issue reporter needs to provide more information for maintainers to take action label Nov 3, 2023
@erikian erikian force-pushed the refactor/typescript-rewrite branch from 07443bd to 456e681 Compare November 5, 2023 19:44
@electron electron deleted a comment from request-info bot Nov 5, 2023
@erikian erikian force-pushed the refactor/typescript-rewrite branch 2 times, most recently from d47c5bb to cd844b5 Compare November 5, 2023 20:40
@erikian erikian marked this pull request as ready for review November 5, 2023 20:41
@erikian erikian requested a review from a team as a code owner November 5, 2023 20:41
@erikian erikian force-pushed the refactor/typescript-rewrite branch from 74e88c6 to c3dd70d Compare November 5, 2023 20:46
@erikian erikian marked this pull request as draft November 5, 2023 20:54
@erikian erikian force-pushed the refactor/typescript-rewrite branch 3 times, most recently from c4864a2 to 2649717 Compare November 6, 2023 01:31
Copy link

codecov bot commented Nov 6, 2023

Codecov Report

Merging #1593 (5ccd8d1) into main (4e3ab8a) will decrease coverage by 11.24%.
The diff coverage is 84.42%.

@@             Coverage Diff             @@
##             main    #1593       +/-   ##
===========================================
- Coverage   95.65%   84.42%   -11.24%     
===========================================
  Files          15       16        +1     
  Lines         783      828       +45     
  Branches        0      163      +163     
===========================================
- Hits          749      699       -50     
- Misses         34       94       +60     
- Partials        0       35       +35     
Files Coverage Δ
src/hooks.ts 100.00% <100.00%> (ø)
src/index.ts 100.00% <100.00%> (ø)
src/linux.ts 100.00% <100.00%> (ø)
src/prune.ts 100.00% <100.00%> (ø)
src/unzip.ts 100.00% <100.00%> (ø)
src/common.ts 98.43% <98.43%> (ø)
src/download.ts 94.73% <94.73%> (ø)
src/infer.ts 98.68% <98.68%> (ø)
src/cli.ts 95.34% <95.34%> (ø)
src/win32.ts 95.55% <95.55%> (ø)
... and 6 more

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@erikian erikian force-pushed the refactor/typescript-rewrite branch 3 times, most recently from 9924874 to ffb30cc Compare November 6, 2023 04:19
@erikian erikian marked this pull request as ready for review November 6, 2023 04:27
@erikian erikian force-pushed the refactor/typescript-rewrite branch from 5b35113 to 1644eb0 Compare November 6, 2023 12:42
@@ -1,5 +1,5 @@
import { normalizePath, warning } from './common';
import galactus from 'galactus';
import { DestroyerOfModules, DepType, Module, ModuleMap } from 'galactus';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The names will always be funny to me

Copy link
Member

@felixrieseberg felixrieseberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave this whole PR one solid read - and even though it's massive and I think I should have found one place to provide constructive feedback, this seems mostly pretty good to me.

The one thing we should make double-and-triple sure before merging is that nobody can actually rely on electron-packager/hooks - and if they could, that we maybe just keep it and cut it in a later PR.

"main": "src/index.js",
"types": "src/index.d.ts",
"main": "dist/index.js",
"types": "dist/types.d.ts",
"bin": {
"electron-packager": "bin/electron-packager.js"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: I'm pretty sure you'll need to update this file. (Although I don't know if I'd necessarily convert it to TypeScript, since it's basically a Node.js-version-checking shim for src/cli.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're still shipping the bin directory to npm, so the path here is fine — I did forgot to update a require in that file from src to dist though 😅

That being said, do we really need this file? Like, if the user has e.g. Node 10 and we require Node 16, the package manager should prevent packager from being installed (unless they're using --ignore-engines, but then the user should be aware that things can break)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd be surprised how many issues were filed back in the day about why there were SyntaxErrors even though the minimum engine has been specified for a very long time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I happened to find a relatively new instance of this with Electron Forge in the Discord server: the user was using Node.js 12 when Forge requires Node.js 16, and Forge definitely has engine constraints in its various package.json files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, now I see why the validation is there, we shouldn't trust engines at all. Adding a proper validation to the ~40 packages in the Forge monorepo is gonna be fun 😟

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just add it to the two CLI-facing packages: create-electron-app and @electron-forge/cli.

@erikian erikian force-pushed the refactor/typescript-rewrite branch from 83bf2ce to 5ccd8d1 Compare November 7, 2023 20:39
@dsanders11
Copy link
Member

Something to watch out for, there's at least one usage in Forge that directly reaches into src/: https://github.com/electron/forge/blob/fd00d9abf1dfc6b34deadfea62ea72d4589105c8/packages/api/core/src/util/parse-archs.ts#L5

@erikian erikian force-pushed the refactor/typescript-rewrite branch from 5ccd8d1 to 47e4006 Compare November 19, 2023 22:00
@erikian erikian force-pushed the refactor/typescript-rewrite branch from d9ada2e to 437471a Compare November 19, 2023 23:19
@erikian
Copy link
Member Author

erikian commented Nov 19, 2023

Something to watch out for, there's at least one usage in Forge that directly reaches into src/: https://github.com/electron/forge/blob/fd00d9abf1dfc6b34deadfea62ea72d4589105c8/packages/api/core/src/util/parse-archs.ts#L5

early draft so I don't forget it: electron/forge@c9da714

@erikian
Copy link
Member Author

erikian commented Nov 20, 2023

My n=1 experiment says removing this hack, originally introduced in #381, doesn't result in a catastrophic failure. The PR only mentions some truncated text when displaying the usage info, so we should be good 🤞🏼

@dsanders11
Copy link
Member

@erikian, couple of conflicts due to other PRs landing.

@erikian erikian force-pushed the refactor/typescript-rewrite branch from 7795430 to 48a47a3 Compare December 5, 2023 01:35
@erikian erikian merged commit 3588ea1 into main Dec 5, 2023
@erikian erikian deleted the refactor/typescript-rewrite branch December 5, 2023 03:04
Copy link

🎉 This PR is included in version 18.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants