diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 14db30e..0000000 Binary files a/.DS_Store and /dev/null differ 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 6958d33..0000000 Binary files a/src/.DS_Store and /dev/null differ diff --git a/src/core/adapter.ts b/src/adapter.ts similarity index 98% rename from src/core/adapter.ts rename to src/adapter.ts index 63f89d6..2943e9d 100644 --- a/src/core/adapter.ts +++ b/src/adapter.ts @@ -4,8 +4,8 @@ import { isPlainObject, isString, isUndefined, -} from '../helpers/is'; -import { assert, throwError } from '../helpers/utils'; +} from './helpers/is'; +import { assert, throwError } from './helpers/utils'; import { AxiosProgressCallback, AxiosRequestConfig, @@ -14,7 +14,7 @@ import { AxiosRequestHeaders, AxiosResponse, AxiosResponseError, -} from './Axios'; +} from './core/Axios'; export type AxiosAdapterRequestType = 'request' | 'download' | 'upload'; diff --git a/src/axios.ts b/src/axios.ts index b712553..f4b1aea 100644 --- a/src/axios.ts +++ b/src/axios.ts @@ -1,4 +1,4 @@ -import { AxiosAdapter, createAdapter, AxiosPlatform } from './core/adapter'; +import { AxiosAdapter, createAdapter, AxiosPlatform } from './adapter'; import Axios, { AxiosConstructor, AxiosRequestConfig, diff --git a/src/core/Axios.ts b/src/core/Axios.ts index 2f90bc0..9ababd2 100644 --- a/src/core/Axios.ts +++ b/src/core/Axios.ts @@ -4,7 +4,7 @@ import { AxiosAdapterRequestMethod, AxiosAdapter, AxiosAdapterTask, -} from './adapter'; +} from '../adapter'; import { CancelToken } from './cancel'; import dispatchRequest from './dispatchRequest'; import InterceptorManager from './InterceptorManager'; diff --git a/src/core/createError.ts b/src/core/createError.ts index aa23711..bd2394f 100644 --- a/src/core/createError.ts +++ b/src/core/createError.ts @@ -1,4 +1,4 @@ -import { AxiosAdapterTask } from './adapter'; +import { AxiosAdapterTask } from '../adapter'; import { AxiosRequestConfig, AxiosResponse, AxiosResponseError } from './Axios'; export type AxiosErrorResponse = AxiosResponse | AxiosResponseError; diff --git a/src/core/generateType.ts b/src/core/generateType.ts index cee06ee..632a286 100644 --- a/src/core/generateType.ts +++ b/src/core/generateType.ts @@ -1,5 +1,5 @@ import { toLowerCase } from '../helpers/utils'; -import { AxiosAdapterRequestType } from './adapter'; +import { AxiosAdapterRequestType } from '../adapter'; import { AxiosRequestConfig, AxiosRequestMethodAlias } from './Axios'; export function generateType( diff --git a/src/core/request.ts b/src/core/request.ts index 146619f..2a43818 100644 --- a/src/core/request.ts +++ b/src/core/request.ts @@ -4,7 +4,7 @@ import { AxiosAdapterRequestConfig, AxiosAdapterRequestMethod, AxiosAdapterTask, -} from './adapter'; +} from '../adapter'; import { AxiosProgressCallback, AxiosRequestConfig, diff --git a/src/defaults.ts b/src/defaults.ts index e2224fc..67e8510 100644 --- a/src/defaults.ts +++ b/src/defaults.ts @@ -1,4 +1,4 @@ -import { getAdapterDefault } from './core/adapter'; +import { getAdapterDefault } from './adapter'; import { AxiosRequestConfig } from './core/Axios'; const defaults: AxiosRequestConfig = { diff --git a/src/helpers/is.ts b/src/helpers/is.ts index 299ebce..6f20db0 100644 --- a/src/helpers/is.ts +++ b/src/helpers/is.ts @@ -16,7 +16,8 @@ export function isEmptyObject(value: any): value is object { return isPlainObject(value) && Object.keys(value).length === 0; } -export function isFunction 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;