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

feat: remove dependency on rcedit to allow x-platform exe resource modding #1696

Merged
merged 9 commits into from
Mar 27, 2024

Conversation

MarshallOfSound
Copy link
Member

@MarshallOfSound MarshallOfSound commented Mar 25, 2024

This re-implements everythin that rcedit used to do with a native binary using a purely JS implementation of resource editing.

This is required to drop the package-on-platform requirements of the win32 target, it also will make it easier to add asar integrity windows manifest values in the future.

@MarshallOfSound MarshallOfSound marked this pull request as ready for review March 26, 2024 08:49
@MarshallOfSound MarshallOfSound requested a review from a team as a code owner March 26, 2024 08:49
Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 61.97183% with 27 lines in your changes are missing coverage. Please review.

Project coverage is 89.29%. Comparing base (0e162db) to head (97f4ebb).
Report is 3 commits behind head on main.

Files Patch % Lines
src/resedit.ts 55.93% 8 Missing and 18 partials ⚠️
src/win32.ts 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1696      +/-   ##
==========================================
- Coverage   91.80%   89.29%   -2.51%     
==========================================
  Files          16       17       +1     
  Lines         854      897      +43     
  Branches      167      186      +19     
==========================================
+ Hits          784      801      +17     
- Misses         52       60       +8     
- Partials       18       36      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MarshallOfSound MarshallOfSound changed the title fix: remove dependency on rcedit to allow x-platform exe resource modding feat: remove dependency on rcedit to allow x-platform exe resource modding Mar 26, 2024
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 took a gander through the resedit source code (https://github.com/jet2jet/resedit-js/blob/main/package.json) and it seems really well done, so I'm generally supportive.

I found some code that looks a little WIP but I think this is overall net-good.

src/resedit.ts Outdated Show resolved Hide resolved
src/win32.ts Outdated Show resolved Hide resolved
@MarshallOfSound
Copy link
Member Author

I took a gander through the resedit source code (https://github.com/jet2jet/resedit-js/blob/main/package.json) and it seems really well done, so I'm generally supportive.

Yeah for context I started out implementing this myself, then hit an edge case I didn't fully understand. In my search for the answer I found an impl that was very similar to what I was writing from scratch so decided to use that impl instead. It's 0 dependencies, and works quite well.

src/resedit.ts Show resolved Hide resolved
src/win32.ts Show resolved Hide resolved
test/win32.js Show resolved Hide resolved
@erickzhao erickzhao self-requested a review March 27, 2024 17:18
src/resedit.ts Show resolved Hide resolved
src/win32.ts Show resolved Hide resolved
src/win32.ts Outdated Show resolved Hide resolved
throw new Error(`Incorrectly formatted version string: "${str}". Should have at least one and at most four components`);
}
return parts.map((part) => {
const parsed = parseInt(part, 10);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const parsed = parseInt(part, 10);
const parsed = Number(part);

issue: parseInt has some edge cases like allowing mixed alphanumeric string/numbers. Is that something that we explicitly want to allow in this case?

e.g.

parseInt('123alphanumeric', 10)
// 123

Copy link
Member Author

Choose a reason for hiding this comment

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

Number has these quirks too Number('0xc') === 12

@MarshallOfSound MarshallOfSound merged commit d9655d4 into main Mar 27, 2024
3 of 5 checks passed
@MarshallOfSound MarshallOfSound deleted the remove-rcedit branch March 27, 2024 20:40
Copy link

🎉 This PR is included in version 18.2.0 🎉

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