Skip to content

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).
Report is 81 commits behind head on main.

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.

@jescalada jescalada linked an issue Apr 2, 2025 that may be closed by this pull request
2 tasks
@coopernetes coopernetes self-assigned this Apr 7, 2025
Copy link
Contributor

@coopernetes coopernetes left a comment

Choose a reason for hiding this comment

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

Hi @jescalada not sure which PR caused all the conflicts but can you tidy your branch up and then re-request a review from me? Thanks!

@coopernetes
Copy link
Contributor

The db and config modules were modified as part of #960 so closing for now. If further conversion or refactoring is needed, we can either re-open or start a new PR.

@JamieSlome
Copy link
Member

@coopernetes - can you confirm the suggested version bump for the merge of #960?

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) [Migration] Convert Utility Functions to TS
4 participants