refactor: 重构 zip 管理逻辑

pull/29/head
954270063@qq.com 2021-06-04 09:57:36 +08:00
parent 04d0642806
commit cd64e87f52
12 changed files with 1331 additions and 18 deletions

View File

@ -3,6 +3,4 @@
# pkgName=$(cat ../package.json .name | sed 's/\"//g') # pkgName=$(cat ../package.json .name | sed 's/\"//g')
yarn build:zip
git add dist.zip
yarn lint-staged yarn lint-staged

View File

@ -11,7 +11,7 @@ import {
} from '../../src/helpers/is'; } from '../../src/helpers/is';
describe('对 src/helpers/is.ts 进行测试', () => { describe('对 src/helpers/is.ts 进行测试', () => {
it('测试 isArray() 执行结果是否符合预期', () => { it('测试 isArray() 执行结果是否符合预期', () => {
expect(isArray([0])).toBe(true); expect(isArray([0])).toBe(true);
expect(isArray([])).toBe(true); expect(isArray([])).toBe(true);
expect(isArray({})).toBe(false); expect(isArray({})).toBe(false);
@ -21,7 +21,7 @@ describe('对 src/helpers/is.ts 进行测试', () => {
expect(isArray(null)).toBe(false); expect(isArray(null)).toBe(false);
}); });
it('测试 isDate() 执行结果是否符合预期', () => { it('测试 isDate() 执行结果是否符合预期', () => {
expect(isDate(new Date())).toBe(true); expect(isDate(new Date())).toBe(true);
expect(isDate({})).toBe(false); expect(isDate({})).toBe(false);
expect(isDate([])).toBe(false); expect(isDate([])).toBe(false);
@ -31,7 +31,7 @@ describe('对 src/helpers/is.ts 进行测试', () => {
expect(isDate(null)).toBe(false); expect(isDate(null)).toBe(false);
}); });
it('测试 isEmptyArray() 执行结果是否符合预期', () => { it('测试 isEmptyArray() 执行结果是否符合预期', () => {
expect(isEmptyArray([])).toBe(true); expect(isEmptyArray([])).toBe(true);
expect(isEmptyArray([0])).toBe(false); expect(isEmptyArray([0])).toBe(false);
expect(isEmptyArray({})).toBe(false); expect(isEmptyArray({})).toBe(false);
@ -41,7 +41,7 @@ describe('对 src/helpers/is.ts 进行测试', () => {
expect(isEmptyArray(null)).toBe(false); expect(isEmptyArray(null)).toBe(false);
}); });
it('测试 isEmptyObject() 执行结果是否符合预期', () => { it('测试 isEmptyObject() 执行结果是否符合预期', () => {
expect(isEmptyObject({})).toBe(true); expect(isEmptyObject({})).toBe(true);
expect(isEmptyObject({ a: 0 })).toBe(false); expect(isEmptyObject({ a: 0 })).toBe(false);
expect(isEmptyObject([0])).toBe(false); expect(isEmptyObject([0])).toBe(false);
@ -52,7 +52,7 @@ describe('对 src/helpers/is.ts 进行测试', () => {
expect(isEmptyObject(null)).toBe(false); expect(isEmptyObject(null)).toBe(false);
}); });
it('测试 isFunction 执行结果是否符合预期', () => { it('测试 isFunction() 执行结果是否符合预期', () => {
expect( expect(
isFunction(() => { isFunction(() => {
return; return;
@ -71,7 +71,7 @@ describe('对 src/helpers/is.ts 进行测试', () => {
expect(isFunction(null)).toBe(false); expect(isFunction(null)).toBe(false);
}); });
it('测试 isNull() 执行结果是否符合预期', () => { it('测试 isNull() 执行结果是否符合预期', () => {
expect(isNull(null)).toBe(true); expect(isNull(null)).toBe(true);
expect(isNull({ a: 0 })).toBe(false); expect(isNull({ a: 0 })).toBe(false);
expect(isNull([0])).toBe(false); expect(isNull([0])).toBe(false);
@ -81,7 +81,7 @@ describe('对 src/helpers/is.ts 进行测试', () => {
expect(isNull(undefined)).toBe(false); expect(isNull(undefined)).toBe(false);
}); });
it('测试 isPlainObject() 执行结果是否符合预期', () => { it('测试 isPlainObject() 执行结果是否符合预期', () => {
expect(isPlainObject({})).toBe(true); expect(isPlainObject({})).toBe(true);
expect(isPlainObject({ a: 0 })).toBe(true); expect(isPlainObject({ a: 0 })).toBe(true);
expect(isPlainObject([0])).toBe(false); expect(isPlainObject([0])).toBe(false);
@ -92,7 +92,7 @@ describe('对 src/helpers/is.ts 进行测试', () => {
expect(isPlainObject(null)).toBe(false); expect(isPlainObject(null)).toBe(false);
}); });
it('测试 isString() 执行结果是否符合预期', () => { it('测试 isString() 执行结果是否符合预期', () => {
expect(isString('')).toBe(true); expect(isString('')).toBe(true);
expect(isString({})).toBe(false); expect(isString({})).toBe(false);
expect(isString({ a: 0 })).toBe(false); expect(isString({ a: 0 })).toBe(false);
@ -103,7 +103,7 @@ describe('对 src/helpers/is.ts 进行测试', () => {
expect(isString(null)).toBe(false); expect(isString(null)).toBe(false);
}); });
it('测试 isUndefined() 执行结果是否符合预期', () => { it('测试 isUndefined() 执行结果是否符合预期', () => {
expect(isUndefined(undefined)).toBe(true); expect(isUndefined(undefined)).toBe(true);
expect(isUndefined('')).toBe(false); expect(isUndefined('')).toBe(false);
expect(isUndefined({})).toBe(false); expect(isUndefined({})).toBe(false);

View File

@ -27,7 +27,7 @@ describe('对 src/helpers/url.ts 进行测试', () => {
); );
}); });
it('测试 combineURL() 执行结果是否正确', () => { it('测试 combineURL() 执行结果是否符合预期', () => {
expect(combineURL('https://www.server.com', 'api')).toBe( expect(combineURL('https://www.server.com', 'api')).toBe(
'https://www.server.com/api', 'https://www.server.com/api',
); );
@ -39,7 +39,7 @@ describe('对 src/helpers/url.ts 进行测试', () => {
); );
}); });
it('测试 dynamicInterpolation() 执行结果是否正确', () => { it('测试 dynamicInterpolation() 执行结果是否符合预期', () => {
expect( expect(
dynamicInterpolation('https://www.server.com/api/user/:id', { dynamicInterpolation('https://www.server.com/api/user/:id', {
id: 1, id: 1,

BIN
dist.zip

Binary file not shown.

BIN
download/v2.0.0-rc-1.zip Normal file

Binary file not shown.

View File

@ -37,7 +37,7 @@ const banner = `/**
* @description ${pkg.description} * @description ${pkg.description}
* @date ${dayjs().format('YYYY-MM-DD')} * @date ${dayjs().format('YYYY-MM-DD')}
* @author ${pkg.author} * @author ${pkg.author}
* @github ${pkg.repository.url} * @github ${pkg.repository.url.replace('git+', '')}
* @issues ${pkg.bugs.url} * @issues ${pkg.bugs.url}
*/`; */`;

View File

@ -8,7 +8,7 @@ const pkg = require('../package.json');
const zip = archiver('zip'); const zip = archiver('zip');
const distPath = path.resolve(__dirname, '..', 'dist'); const distPath = path.resolve(__dirname, '..', 'dist');
const distZipName = 'dist.zip'; const distZipName = `download/${pkg.version}.zip`;
const distZipPath = path.resolve(__dirname, '..', distZipName); const distZipPath = path.resolve(__dirname, '..', distZipName);
console.log(); console.log();

View File

@ -67,6 +67,7 @@ export interface AxiosAdapterUpload {
export interface AxiosAdapterDownload { export interface AxiosAdapterDownload {
(config: AxiosAdapterDownloadOptions): AxiosAdapterTask | void; (config: AxiosAdapterDownloadOptions): AxiosAdapterTask | void;
} }
export interface AxiosPlatform { export interface AxiosPlatform {
request: AxiosAdapterRequest; request: AxiosAdapterRequest;
upload: AxiosAdapterUpload; upload: AxiosAdapterUpload;

View File

@ -1,15 +1,15 @@
import axios from './axios'; import axios from './axios';
export { export type {
AxiosRequestConfig, AxiosRequestConfig,
AxiosRequestFormData, AxiosRequestFormData,
AxiosResponse, AxiosResponse,
AxiosResponseError, AxiosResponseError,
} from './core/Axios'; } from './core/Axios';
export { export type {
AxiosAdapterRequestConfig, AxiosAdapterRequestConfig,
AxiosAdapter, AxiosAdapter,
AxiosPlatform, AxiosPlatform,
} from './core/adapter'; } from './core/adapter';
export { AxiosInstance, AxiosStatic } from './axios'; export type { AxiosInstance, AxiosStatic } from './axios';
export default axios; export default axios;

1
website/docs/index.md Normal file
View File

@ -0,0 +1 @@
# Hello VitePress

14
website/package.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "website",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:serve": "vitepress serve docs"
},
"devDependencies": {
"vitepress": "^0.14.0"
}
}

1299
website/yarn.lock Normal file

File diff suppressed because it is too large Load Diff