Skip to content

Commit

Permalink
feat: bump deps and add httpLib in tsdk.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
suhaotian committed Feb 20, 2024
1 parent f91c383 commit 81736c1
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 16 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

This is the log of notable changes to the `tsdk` that are developer-facing.


### 0.1.6 2024/2/21

- Feat: add **httpLib** config in `tsdk.config.js`, More detail https://tsdk.dev/docs/guide/tsdk.config
- Chore: bump webpack version
- Chore: add `XiorRequestConfig` in generate code

### 0.1.5 2024/2/20

- Feat: add fetch support (use xior, similar axios API: https://www.npmjs.com/package/xior)
Expand Down
2 changes: 1 addition & 1 deletion packages/tsdk-server-adapters/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tsdk-server-adapters",
"version": "0.1.5",
"version": "0.1.6",
"main": "lib/index.js",
"repository": "tsdk-monorepo/tsdk",
"bugs": "https://github.com/tsdk-monorepo/tsdk/issues",
Expand Down
2 changes: 2 additions & 0 deletions packages/tsdk/fe-sdk-template/config/tsdk.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ module.exports = {
shareExt: 'shared',
sharedDirs: ['./src/shared'],
removeFields: [],
/** 'xior' | 'axios'. More: https://tsdk.dev/docs/guide/tsdk.config#httplib */
// httpLib: 'xior',
};
4 changes: 2 additions & 2 deletions packages/tsdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tsdk",
"version": "0.1.5",
"version": "0.1.6",
"description": "Type-safe API development and code share tool for TypeScript projects.",
"repository": "tsdk-monorepo/tsdk",
"bugs": "https://github.com/tsdk-monorepo/tsdk/issues",
Expand Down Expand Up @@ -57,7 +57,7 @@
"@configs/ts-config": "workspace:*",
"@types/fs-extra": "^11.0.4",
"@types/webpack-node-externals": "^3.0.0",
"webpack": "^5.90.1",
"webpack": "^5.90.3",
"webpack-node-externals": "^3.0.0"
},
"eslintConfig": {
Expand Down
2 changes: 2 additions & 0 deletions packages/tsdk/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface TSDKConfig {
shareExt?: string;
sharedDirs: string[];
monorepoRoot?: string;
/** default: axios */
httpLib?: 'xior' | 'axios';
dataHookLib?: 'SWR' | 'ReactQuery';
/** custom dependencies */
dependencies?: { [key: string]: string };
Expand Down
12 changes: 10 additions & 2 deletions packages/tsdk/src/sync-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ export async function syncAPI() {
? ''
: `import useSWR, { SWRConfiguration } from "swr";
import useSWRMutation, { SWRMutationConfiguration } from "swr/mutation";
import { AxiosRequestConfig } from "axios";
${
config.httpLib !== 'xior'
? `import type { AxiosRequestConfig } from "axios";`
: `import type { XiorRequestConfig as AxiosRequestConfig } from "xior";`
}
`
}
${
Expand All @@ -48,7 +52,11 @@ export async function syncAPI() {
UndefinedInitialDataOptions,
UseMutationOptions,
} from "@tanstack/react-query";
import { AxiosRequestConfig } from "axios";
${
config.httpLib !== 'xior'
? `import type { AxiosRequestConfig } from "axios";`
: `import type { XiorRequestConfig as AxiosRequestConfig } from "xior";`
}
`
}
`;
Expand Down
74 changes: 69 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"nextra-theme-docs": "2.13.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"next-videos": "^1.4.1",
"react-wrap-balancer": "^1.1.0",
"next-videos": "1.4.1",
"react-wrap-balancer": "1.1.0",
"next-sitemap": "4.2.3"
},
"devDependencies": {
Expand Down
15 changes: 11 additions & 4 deletions website/pages/docs/guide/tsdk.config.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
entityLibName: 'typeorm',
entityExt: 'entity',
apiconfExt: 'apiconf',
httpLib: 'axios',
shareExt: 'shared',
sharedDirs: ['./src/shared'],
removeFields: [],
Expand All @@ -25,9 +26,10 @@ module.exports = {
- `entityLibName` - ORM library, current support `TypeORM`, `kysely``DrizzleORM`
- `entityExt` - ORM model extension name, default is `*.entity.ts`
- `apiconfExt` - API config extension name, default is `*.apiconf.ts`
- `shareExt` - shared file extension name, default is `*.shared.ts`
- `sharedDirs` - shared dir, default is `["./src/shared"]`
- `shareExt` - shared file extension name, default is `*.shared.ts`
- `sharedDirs` - shared dir, default is `["./src/shared"]`
- `monorepoRoot` - monorepo root folder, default is `./`
- `httpLib` - `xior` | `axios`, default is `axios`; `xior` use fetch, and have similiar API with axios
- `dataHookLib` - `SWR` | `ReactQuery`,Generate `SWR` or `React Query` hooks;dependencies version: `swr@^2.2.5`; `@tanstack/react-query@^5.10.0`
- `dependencies` - custom dependencies,will combine to `fe-sdk/package.json ` dependencies. This can custom dependencies and override fe-sdk's default version
- `devDependencies` - custom devDependencies.
Expand Down Expand Up @@ -64,6 +66,12 @@ module.exports = {

`monorepoRoot` - monorepo root folder, default is `./`

### httpLib

Generate API SDK which request library to use.

`xior` | `axios`, default is `axios`; And `xior` use fetch, and similiar API with axios

### dataHookLib

`dataHookLib` - `SWR` | `ReactQuery`; Generate `SWR` or `React Query` hooks;dependencies version: `swr@^2.2.5`; `@tanstack/react-query@^5.10.0`
Expand All @@ -74,7 +82,6 @@ Custom dependencies,will combine to `fe-sdk/package.json` dependencies. This c

For example, update `tsdk.config.js` to change axios to latest version:


```js filename="tsdk.config.js" {4-6}
/** @type {import('tsdk').TSDKConfig} */
module.exports = {
Expand All @@ -87,4 +94,4 @@ module.exports = {

### `devDependencies`

Like `dependencies`, but for `devDependencies`.
Like `dependencies`, but for `devDependencies`.
9 changes: 9 additions & 0 deletions website/pages/docs/guide/tsdk.config.zh-CN.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
entityExt: 'entity',
apiconfExt: 'apiconf',
shareExt: 'shared',
httpLib: 'axios',
sharedDirs: ['./src/shared'],
removeFields: [],
monorepoRoot: './',
Expand All @@ -28,6 +29,7 @@ module.exports = {
- `shareExt` - 共享文件名扩展,默认 `*.shared.ts`
- `sharedDirs` - 共享文件夹,默认 `["./src/shared"]`
- `monorepoRoot` - monorepo 根路径,默认当前路径 `./`
- `httpLib` - 可选值有 `xior` | `axios`,默认 `axios`; `xior``axios` 什么区别?`xior` 使用 fetch,API 和 `axios` 类似
- `dataHookLib` - 可选值有 `SWR` | `ReactQuery`,生成 `SWR` 或者 `React Query` 钩子;get 方法的接口将生成获取钩子,非 get 的将生成更新钩子。默认不生成。依赖版本:swr@^2.2.4;@tanstack/react-query@^5.10.0
- `dependencies` - 自定义依赖,将会和 **fe-sdk/package.json** dependencies 进行合并。作用:添加自定义依赖,以及覆盖默认的依赖版本号
- `devDependencies` - 自定义依赖,将会和 **fe-sdk/package.json** devDependencies 进行合并。
Expand Down Expand Up @@ -64,6 +66,13 @@ module.exports = {

`monorepoRoot` - monorepo 根路径,默认当前路径 `./`


### `httpLib`

可选值有 `xior` | `axios`,默认 `axios`

`xior``axios` 什么区别?`xior` 使用 fetch,API 和 `axios` 类似

### dataHookLib

`dataHookLib` - 可选值有 `SWR` | `ReactQuery`,生成 `SWR` 或者 `React Query` 钩子;get 方法的接口将生成获取钩子,非 get 的将生成更新钩子。默认不生成。依赖版本:swr@^2.2.4;@tanstack/react-query@^5.10.0
Expand Down

0 comments on commit 81736c1

Please sign in to comment.