refactor: adapter 移动到 src 目录
parent
acb110bd41
commit
0228482c8b
|
@ -35,5 +35,8 @@ jobs:
|
||||||
- name: Build
|
- name: Build
|
||||||
run: pnpm build -a
|
run: pnpm build -a
|
||||||
|
|
||||||
|
- name: Build zip
|
||||||
|
run: pnpm build:zip
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: pnpm test
|
run: pnpm test
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
.eslintcache
|
.eslintcache
|
||||||
|
.DS_Store
|
||||||
|
.idea
|
||||||
|
|
|
@ -25,7 +25,11 @@ function generateZip(inputPath: string, outputPath: string) {
|
||||||
|
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
JSZip()
|
JSZip()
|
||||||
.file(inputName, fs.createReadStream(inputPath))
|
.file(inputName, fs.createReadStream(inputPath), {
|
||||||
|
compressionOptions: {
|
||||||
|
level: 9,
|
||||||
|
},
|
||||||
|
})
|
||||||
.generateNodeStream({ type: 'nodebuffer', streamFiles: true })
|
.generateNodeStream({ type: 'nodebuffer', streamFiles: true })
|
||||||
.pipe(fs.createWriteStream(outputPath))
|
.pipe(fs.createWriteStream(outputPath))
|
||||||
.on('finish', (result) => {
|
.on('finish', (result) => {
|
||||||
|
|
Binary file not shown.
|
@ -4,8 +4,8 @@ import {
|
||||||
isPlainObject,
|
isPlainObject,
|
||||||
isString,
|
isString,
|
||||||
isUndefined,
|
isUndefined,
|
||||||
} from '../helpers/is';
|
} from './helpers/is';
|
||||||
import { assert, throwError } from '../helpers/utils';
|
import { assert, throwError } from './helpers/utils';
|
||||||
import {
|
import {
|
||||||
AxiosProgressCallback,
|
AxiosProgressCallback,
|
||||||
AxiosRequestConfig,
|
AxiosRequestConfig,
|
||||||
|
@ -14,7 +14,7 @@ import {
|
||||||
AxiosRequestHeaders,
|
AxiosRequestHeaders,
|
||||||
AxiosResponse,
|
AxiosResponse,
|
||||||
AxiosResponseError,
|
AxiosResponseError,
|
||||||
} from './Axios';
|
} from './core/Axios';
|
||||||
|
|
||||||
export type AxiosAdapterRequestType = 'request' | 'download' | 'upload';
|
export type AxiosAdapterRequestType = 'request' | 'download' | 'upload';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { AxiosAdapter, createAdapter, AxiosPlatform } from './core/adapter';
|
import { AxiosAdapter, createAdapter, AxiosPlatform } from './adapter';
|
||||||
import Axios, {
|
import Axios, {
|
||||||
AxiosConstructor,
|
AxiosConstructor,
|
||||||
AxiosRequestConfig,
|
AxiosRequestConfig,
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
AxiosAdapterRequestMethod,
|
AxiosAdapterRequestMethod,
|
||||||
AxiosAdapter,
|
AxiosAdapter,
|
||||||
AxiosAdapterTask,
|
AxiosAdapterTask,
|
||||||
} from './adapter';
|
} from '../adapter';
|
||||||
import { CancelToken } from './cancel';
|
import { CancelToken } from './cancel';
|
||||||
import dispatchRequest from './dispatchRequest';
|
import dispatchRequest from './dispatchRequest';
|
||||||
import InterceptorManager from './InterceptorManager';
|
import InterceptorManager from './InterceptorManager';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { AxiosAdapterTask } from './adapter';
|
import { AxiosAdapterTask } from '../adapter';
|
||||||
import { AxiosRequestConfig, AxiosResponse, AxiosResponseError } from './Axios';
|
import { AxiosRequestConfig, AxiosResponse, AxiosResponseError } from './Axios';
|
||||||
|
|
||||||
export type AxiosErrorResponse = AxiosResponse | AxiosResponseError;
|
export type AxiosErrorResponse = AxiosResponse | AxiosResponseError;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { toLowerCase } from '../helpers/utils';
|
import { toLowerCase } from '../helpers/utils';
|
||||||
import { AxiosAdapterRequestType } from './adapter';
|
import { AxiosAdapterRequestType } from '../adapter';
|
||||||
import { AxiosRequestConfig, AxiosRequestMethodAlias } from './Axios';
|
import { AxiosRequestConfig, AxiosRequestMethodAlias } from './Axios';
|
||||||
|
|
||||||
export function generateType(
|
export function generateType(
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
AxiosAdapterRequestConfig,
|
AxiosAdapterRequestConfig,
|
||||||
AxiosAdapterRequestMethod,
|
AxiosAdapterRequestMethod,
|
||||||
AxiosAdapterTask,
|
AxiosAdapterTask,
|
||||||
} from './adapter';
|
} from '../adapter';
|
||||||
import {
|
import {
|
||||||
AxiosProgressCallback,
|
AxiosProgressCallback,
|
||||||
AxiosRequestConfig,
|
AxiosRequestConfig,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getAdapterDefault } from './core/adapter';
|
import { getAdapterDefault } from './adapter';
|
||||||
import { AxiosRequestConfig } from './core/Axios';
|
import { AxiosRequestConfig } from './core/Axios';
|
||||||
|
|
||||||
const defaults: AxiosRequestConfig = {
|
const defaults: AxiosRequestConfig = {
|
||||||
|
|
|
@ -16,7 +16,8 @@ export function isEmptyObject(value: any): value is object {
|
||||||
return isPlainObject(value) && Object.keys(value).length === 0;
|
return isPlainObject(value) && Object.keys(value).length === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isFunction<T extends () => void>(value: any): value is T {
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
|
export function isFunction<T extends Function>(value: any): value is T {
|
||||||
return typeof value === 'function';
|
return typeof value === 'function';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { isPlainObject, isString } from './is';
|
import { isPlainObject, isString } from './is';
|
||||||
|
|
||||||
export function deepMerge<T = unknown>(...objs: T[]): T {
|
export function deepMerge<T extends AnyObject>(...objs: T[]): T {
|
||||||
const result: AnyObject = {};
|
const result: AnyObject = {};
|
||||||
|
|
||||||
objs.forEach((obj: AnyObject) =>
|
objs.forEach((obj: AnyObject) =>
|
||||||
|
@ -53,7 +53,7 @@ export function throwError(msg: string): void {
|
||||||
throw new Error(`[axios-miniprogram]: ${msg}`);
|
throw new Error(`[axios-miniprogram]: ${msg}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toLowerCase<T extends string>(value: unknown, defaultValue: T): T {
|
export function toLowerCase<T extends string>(value: any, defaultValue: T): T {
|
||||||
if (!isString(value)) {
|
if (!isString(value)) {
|
||||||
value = defaultValue;
|
value = defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ export function toLowerCase<T extends string>(value: unknown, defaultValue: T):
|
||||||
return value.toLowerCase() as T;
|
return value.toLowerCase() as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toUpperCase<T extends string>(value: unknown, defaultValue: T): T {
|
export function toUpperCase<T extends string>(value: any, defaultValue: T): T {
|
||||||
if (!isString(value)) {
|
if (!isString(value)) {
|
||||||
value = defaultValue;
|
value = defaultValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,6 @@ export type {
|
||||||
AxiosAdapterRequestConfig,
|
AxiosAdapterRequestConfig,
|
||||||
AxiosAdapter,
|
AxiosAdapter,
|
||||||
AxiosPlatform,
|
AxiosPlatform,
|
||||||
} from './core/adapter';
|
} from './adapter';
|
||||||
export type { AxiosInstance, AxiosStatic } from './axios';
|
export type { AxiosInstance, AxiosStatic } from './axios';
|
||||||
export default axios;
|
export default axios;
|
||||||
|
|
Loading…
Reference in New Issue