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(ts): refactor db module to use TS and ESM #938

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

jescalada
Copy link
Contributor

@jescalada jescalada commented Mar 14, 2025

Fixes #964.

This PR refactors the db module to use TS and ESM. It builds on top of #929 (the latest commits haven't been merged in yet).

Original PR comment:

My biggest concern is the implications of CommonJS and ESM interoperation. Is it desirable to use ESM, or should we stick to CommonJS? I thought using ESM would make the project more future-proof and allow more modern syntax, but getting things to work has been a massive headache.

Specifically, it's a pain to get tests to work while mixing JS/TS and CommonJS/ESM.

Right now, I'm stuck with a problem with the plugin tests, which depend on an ESM-only module (load-plugin). I'm not sure if this is a compatibility bug or if there's an easy way to fix it on the git-proxy side, but I've tried a few workarounds without any luck.

If ESM is problematic, I can roll back the export changes while keeping the TS stuff in.

Edit: I've managed to get the tests to pass by using mocha on the plugin tests and ts-mocha on everything else. The only problem is that some recent tests are flaky on local (they seem to pass reliably in the CI):

Edit 2: Fixed flaky tests in #945.

image

Thank you!

Copy link

netlify bot commented Mar 14, 2025

Deploy Preview for endearing-brigadeiros-63f9d0 canceled.

Name Link
🔨 Latest commit 478703b
🔍 Latest deploy log https://app.netlify.com/sites/endearing-brigadeiros-63f9d0/deploys/67e6053832e8790008abddaa

@JamieSlome JamieSlome requested a review from 06kellyjac March 15, 2025 11:09
Copy link

codecov bot commented Mar 21, 2025

Codecov Report

Attention: Patch coverage is 59.16667% with 49 lines in your changes missing coverage. Please review.

Project coverage is 51.70%. Comparing base (83e814b) to head (478703b).

Files with missing lines Patch % Lines
src/db/file/pushes.ts 48.48% 17 Missing ⚠️
src/db/index.ts 42.85% 11 Missing and 5 partials ⚠️
src/db/file/repo.ts 60.52% 15 Missing ⚠️
src/db/file/users.ts 92.85% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #938       +/-   ##
===========================================
- Coverage   61.88%   51.70%   -10.18%     
===========================================
  Files          49       48        -1     
  Lines        1805     1671      -134     
  Branches        0       53       +53     
===========================================
- Hits         1117      864      -253     
- Misses        688      790      +102     
- Partials        0       17       +17     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Successfully merging this pull request may close these issues.

Refactor auxiliary backend modules into TS (config, db)
3 participants