kubb-labs / kubb

The ultimate toolkit for working with APIs.
https://kubb.dev
MIT License
670 stars 54 forks source link

Fix react-query dependency lookup #1054

Closed dgarciamuria closed 3 months ago

dgarciamuria commented 3 months ago

Issue

If you have multiple @tanstack packages in your package.json file, the logic that checks if your are using v5 will fail because internally is calling isValidSync(/@tanstack/, '>=5')

Solution

Call isValidSync explicitly passing @tanstack/react-query

changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: 2125766ac89def1c81cf8a905b9f1dacb67eaf9a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages | Name | Type | | ---------------------------- | ----- | | @kubb/swagger-tanstack-query | Patch | | @kubb/cli | Patch | | @kubb/config-biome | Patch | | @kubb/config-ts | Patch | | @kubb/config-tsup | Patch | | @kubb/core | Patch | | @kubb/fs | Patch | | @kubb/oas | Patch | | @kubb/parser-ts | Patch | | @kubb/plugin-oas | Patch | | @kubb/plugin-redoc | Patch | | @kubb/react | Patch | | @kubb/swagger-client | Patch | | @kubb/swagger-faker | Patch | | @kubb/swagger-msw | Patch | | @kubb/swagger-swr | Patch | | @kubb/swagger-ts | Patch | | @kubb/swagger-zod | Patch | | @kubb/swagger-zodios | Patch | | @kubb/swagger | Patch | | @kubb/types | Patch | | kubb | Patch | | unplugin-kubb | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

stijnvanhulle commented 3 months ago

Thanks but this will not work for vue-query, solid-query and such. Can you adapt the regex so that react is not hardcoded?

stijnvanhulle commented 3 months ago

@all-contributors add @dgarciamuria for code

allcontributors[bot] commented 3 months ago

@stijnvanhulle

I've put up a pull request to add @dgarciamuria! :tada:

dgarciamuria commented 3 months ago

Thanks but this will not work for vue-query, solid-query and such. Can you adapt the regex so that react is not hardcoded?

Good catch! I decided to be explicit instead of trying some form of fuzzy matching, the downside is that if react-query adds support for a new framework then the regex will need to be updated...but is better than risking capturing other packages that are not related. Also moved the regex as an export to make it easier to refactor in the future