From 0228482c8b454d1511cc3f40c696b936c0db68ff Mon Sep 17 00:00:00 2001 From: zjx0905 <954270063@qq.com> Date: Fri, 24 Mar 2023 20:15:51 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20adapter=20=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E5=88=B0=20src=20=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 0 bytes .github/workflows/ci.yml | 3 +++ .gitignore | 2 ++ scripts/build-zip.ts | 6 +++++- src/.DS_Store | Bin 6148 -> 0 bytes src/{core => }/adapter.ts | 6 +++--- src/axios.ts | 2 +- src/core/Axios.ts | 2 +- src/core/createError.ts | 2 +- src/core/generateType.ts | 2 +- src/core/request.ts | 2 +- src/defaults.ts | 2 +- src/helpers/is.ts | 3 ++- src/helpers/utils.ts | 6 +++--- src/index.ts | 2 +- 15 files changed, 25 insertions(+), 15 deletions(-) delete mode 100644 .DS_Store delete mode 100644 src/.DS_Store rename src/{core => }/adapter.ts (98%) diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 14db30ea74cc55e5de8eec9c8fafd74c077f16ff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKPjAyO6n|a=b(ugp0NT+K*GY7vLZBT8r4!;x5F7xNrYT#rG>(##9;!;YaDk7q zFR%}=3pY+6ab_oO+>v#$^O~zkKfBrvK<2e>rTQg02cr_HbUnTcE1s_ zQ>)3E(Of}fv_>$^(;$`s&W~!|R$&>i46GUhw09i{A%Yx=>i!MVILeE5`x9GhI2SH9 zd6Td6m;Sz-`o*A_docAPPt5^5R*PgmT)I zlO)Vltgj8c#an%MV>auwJDZ|&XM4UWW_P#SIKFjzK5y}BH*W4c?jOYCM84AmGCXgT zTsC+L?{VvTa2}8)^y)Azz$EgXLS8Ze2>zOl*pG*#}-}`!ef6*TP z(Vp&C*A|qbiQEn$Lyl7@mb1HG>K@e^UVnV_;rofIVQHPQJgek#J9qt;jN98TiKx(D@*+5qbto zjq2#YPCWq-9aJm9F})=yMi}%AmKxE5!gMI24rS(v!E`w4h4J$YmKt?9F!T6eCNncH z6sEG{`a-#by@50jwzmu{Gtkfqm+t>v+{5R*|Cht;+%jMp_>UN1PS5Xk@q^6WTKhD* vYX!Df*ht8))TlzRGuN>i&{e#FO$pir4G=wprAE}C*dGB!gY7H>f0cosIIgG^ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88955f8..e68eab2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,5 +35,8 @@ jobs: - name: Build run: pnpm build -a + - name: Build zip + run: pnpm build:zip + - name: Test run: pnpm test diff --git a/.gitignore b/.gitignore index 6b699e1..2f28064 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ node_modules dist .eslintcache +.DS_Store +.idea diff --git a/scripts/build-zip.ts b/scripts/build-zip.ts index 0bfe792..5f23b1a 100644 --- a/scripts/build-zip.ts +++ b/scripts/build-zip.ts @@ -25,7 +25,11 @@ function generateZip(inputPath: string, outputPath: string) { const start = Date.now(); JSZip() - .file(inputName, fs.createReadStream(inputPath)) + .file(inputName, fs.createReadStream(inputPath), { + compressionOptions: { + level: 9, + }, + }) .generateNodeStream({ type: 'nodebuffer', streamFiles: true }) .pipe(fs.createWriteStream(outputPath)) .on('finish', (result) => { diff --git a/src/.DS_Store b/src/.DS_Store deleted file mode 100644 index 6958d332a5cefa213e1f0448a9a5a28ec40c375e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKJ5Iwu5S(hH{U9Z(t(l1i1jp2U6HtD~R5g;0*MfAvG7Ep`haqh&MZ< z;KhUzA()Y7-g-Xk^>gIO5RseSt_q?F5#>c93a~ z-^u{LyNs3;XiMw#{auawu_jd2q7DoA^5X4&_xiHCNaL$-3PoiJSN6~F<=b*7Y5L?S@IJ>v&MiiU<~XT z;O~QnGM0*+VElBz#1R0P!5sx_o+Y@(E0&6#AR-Var9dflI$}5}hu>>nsn`ihIXN9Z zoZi{#gyQ1evA>V$ void>(value: any): value is T { +// eslint-disable-next-line @typescript-eslint/ban-types +export function isFunction(value: any): value is T { return typeof value === 'function'; } diff --git a/src/helpers/utils.ts b/src/helpers/utils.ts index 47dec98..02a01cf 100644 --- a/src/helpers/utils.ts +++ b/src/helpers/utils.ts @@ -1,6 +1,6 @@ import { isPlainObject, isString } from './is'; -export function deepMerge(...objs: T[]): T { +export function deepMerge(...objs: T[]): T { const result: AnyObject = {}; objs.forEach((obj: AnyObject) => @@ -53,7 +53,7 @@ export function throwError(msg: string): void { throw new Error(`[axios-miniprogram]: ${msg}`); } -export function toLowerCase(value: unknown, defaultValue: T): T { +export function toLowerCase(value: any, defaultValue: T): T { if (!isString(value)) { value = defaultValue; } @@ -61,7 +61,7 @@ export function toLowerCase(value: unknown, defaultValue: T): return value.toLowerCase() as T; } -export function toUpperCase(value: unknown, defaultValue: T): T { +export function toUpperCase(value: any, defaultValue: T): T { if (!isString(value)) { value = defaultValue; } diff --git a/src/index.ts b/src/index.ts index 59dc48f..a500da1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,6 +10,6 @@ export type { AxiosAdapterRequestConfig, AxiosAdapter, AxiosPlatform, -} from './core/adapter'; +} from './adapter'; export type { AxiosInstance, AxiosStatic } from './axios'; export default axios;