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(core,common): improve adapter resolution strategy #213

Merged
merged 15 commits into from
Dec 6, 2023

Conversation

yaron-shamul
Copy link
Collaborator

@yaron-shamul yaron-shamul commented Dec 3, 2023

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

As of today, the Automock iterates through the supported adapters, attempting to import each one until it successfully imports one. It is imperative to enhance this process for improved efficiency and reliability.

Issue Number: #193

What is the new behavior?

Added new functionality to read package.json extracting both dependencies and dev-dependencies and resolving the first supported adapter. This refined capability allows the system to intelligently resolve the first supported adapter with unparalleled precision and efficiency.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Copy link

codecov bot commented Dec 3, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (62bec01) 91.86% compared to head (243b6a8) 93.15%.

Files Patch % Lines
packages/core/src/adapter-error-handler.static.ts 87.50% 1 Missing ⚠️
packages/core/src/services/package-reader.ts 96.87% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next     #213      +/-   ##
==========================================
+ Coverage   91.86%   93.15%   +1.28%     
==========================================
  Files          13       15       +2     
  Lines         246      292      +46     
  Branches       43       50       +7     
==========================================
+ Hits          226      272      +46     
+ Misses         13       12       -1     
- Partials        7        8       +1     
Flag Coverage Δ
adapters.nestjs 93.15% <96.36%> (+1.28%) ⬆️
core 93.15% <96.36%> (+1.28%) ⬆️
jest 93.15% <96.36%> (+1.28%) ⬆️
sinon 93.15% <96.36%> (+1.28%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@omermorad omermorad self-requested a review December 4, 2023 21:15
@omermorad omermorad changed the title feat(core): improve adapter resolving strategy feat(core,common): improve adapter resolution strategy Dec 5, 2023
@omermorad
Copy link
Collaborator

@yaron-shamul Nice work buddy!! 🚀 🚀

@omermorad omermorad merged commit 1e2524b into next Dec 6, 2023
14 checks passed
@omermorad omermorad deleted the feat/issue-193/add-package-reader branch December 6, 2023 05:58
omermorad added a commit that referenced this pull request Dec 7, 2023
Incorporated additional functionality to read the `package.json` file, extracting both dependencies and devDependencies, and resolving the adapter from that list. This mechanism is implemented prior to the base mechanism of attempting to globally resolve the adapters package (module) using node require.resolve.

Co-authored-by: Omer Morad <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants