picgo 1.5.0-alpha.8 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +104 -0
- package/dist/core/PicGo.d.ts +8 -4
- package/dist/i18n/zh-TW.d.ts +2 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.esm.js +2 -2
- package/dist/lib/Commander.d.ts +10 -4
- package/dist/lib/LifecyclePlugins.d.ts +1 -0
- package/dist/lib/Request.d.ts +6 -5
- package/dist/types/index.d.ts +74 -7
- package/dist/types/oldRequest.d.ts +19 -0
- package/dist/utils/common.d.ts +3 -2
- package/package.json +7 -7
package/dist/lib/Commander.d.ts
CHANGED
|
@@ -2,15 +2,21 @@ import { Command } from 'commander';
|
|
|
2
2
|
import { Inquirer } from 'inquirer';
|
|
3
3
|
import { IPlugin, ICommander, IPicGo } from '../types';
|
|
4
4
|
export declare class Commander implements ICommander {
|
|
5
|
-
private
|
|
5
|
+
private readonly name;
|
|
6
|
+
static currentPlugin: string | null;
|
|
7
|
+
private readonly list;
|
|
8
|
+
private readonly pluginIdMap;
|
|
9
|
+
private readonly ctx;
|
|
6
10
|
program: Command;
|
|
7
11
|
inquirer: Inquirer;
|
|
8
|
-
private readonly ctx;
|
|
9
12
|
constructor(ctx: IPicGo);
|
|
13
|
+
getName(): string;
|
|
10
14
|
init(): void;
|
|
11
|
-
register(
|
|
15
|
+
register(id: string, plugin: IPlugin): void;
|
|
16
|
+
unregister(pluginName: string): void;
|
|
12
17
|
loadCommands(): void;
|
|
13
|
-
get(
|
|
18
|
+
get(id: string): IPlugin | undefined;
|
|
14
19
|
getList(): IPlugin[];
|
|
20
|
+
getIdList(): string[];
|
|
15
21
|
}
|
|
16
22
|
export default Commander;
|
|
@@ -13,4 +13,5 @@ export declare class LifecyclePlugins implements ILifecyclePlugins {
|
|
|
13
13
|
getIdList(): string[];
|
|
14
14
|
}
|
|
15
15
|
export declare const setCurrentPluginName: (name?: string | null) => void;
|
|
16
|
+
export declare const getCurrentPluginName: () => string | null;
|
|
16
17
|
export default LifecyclePlugins;
|
package/dist/lib/Request.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IPicGo } from '../types';
|
|
3
|
-
export declare class Request {
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { IPicGo, IRequestConfig, IOldReqOptions, IResponse, IRequest } from '../types';
|
|
3
|
+
export declare class Request implements IRequest {
|
|
4
4
|
private readonly ctx;
|
|
5
5
|
private proxy;
|
|
6
|
-
options:
|
|
6
|
+
options: AxiosRequestConfig<any>;
|
|
7
7
|
constructor(ctx: IPicGo);
|
|
8
8
|
private init;
|
|
9
|
-
|
|
9
|
+
private handleProxy;
|
|
10
|
+
request<T, U extends (IRequestConfig<U> extends IOldReqOptions ? IOldReqOptions : IRequestConfig<U> extends AxiosRequestConfig ? AxiosRequestConfig : never)>(options: U): Promise<IResponse<T, U>>;
|
|
10
11
|
}
|
|
11
12
|
export default Request;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
2
|
+
/// <reference types="node" />
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import { Inquirer } from 'inquirer';
|
|
5
|
+
import { IRequestPromiseOptions } from './oldRequest';
|
|
5
6
|
export interface IPicGo extends NodeJS.EventEmitter {
|
|
6
7
|
/**
|
|
7
8
|
* picgo configPath
|
|
@@ -64,7 +65,7 @@ export interface IPicGo extends NodeJS.EventEmitter {
|
|
|
64
65
|
*
|
|
65
66
|
* http request tool
|
|
66
67
|
*/
|
|
67
|
-
request:
|
|
68
|
+
request: IRequest['request'];
|
|
68
69
|
i18n: II18nManager;
|
|
69
70
|
/**
|
|
70
71
|
* get picgo config
|
|
@@ -101,6 +102,7 @@ export interface IPluginConfig {
|
|
|
101
102
|
default?: any;
|
|
102
103
|
alias?: string;
|
|
103
104
|
message?: string;
|
|
105
|
+
prefix?: string;
|
|
104
106
|
[propName: string]: any;
|
|
105
107
|
}
|
|
106
108
|
/**
|
|
@@ -121,12 +123,9 @@ export interface IHelper {
|
|
|
121
123
|
beforeUploadPlugins: ILifecyclePlugins;
|
|
122
124
|
afterUploadPlugins: ILifecyclePlugins;
|
|
123
125
|
}
|
|
124
|
-
export interface ICommander {
|
|
126
|
+
export interface ICommander extends ILifecyclePlugins {
|
|
125
127
|
program: Command;
|
|
126
128
|
inquirer: Inquirer;
|
|
127
|
-
get: (name: string) => IPlugin;
|
|
128
|
-
getList: () => IPlugin[];
|
|
129
|
-
register: (name: string, plugin: IPlugin) => void;
|
|
130
129
|
}
|
|
131
130
|
export interface IPluginLoader {
|
|
132
131
|
/**
|
|
@@ -153,8 +152,71 @@ export interface IPluginLoader {
|
|
|
153
152
|
getFullList: () => string[];
|
|
154
153
|
hasPlugin: (name: string) => boolean;
|
|
155
154
|
}
|
|
155
|
+
export interface IRequestOld {
|
|
156
|
+
request: import('axios').AxiosInstance;
|
|
157
|
+
}
|
|
158
|
+
export declare type IOldReqOptions = Omit<IRequestPromiseOptions & {
|
|
159
|
+
url: string;
|
|
160
|
+
}, 'auth'>;
|
|
161
|
+
export declare type IOldReqOptionsWithFullResponse = IOldReqOptions & {
|
|
162
|
+
resolveWithFullResponse: true;
|
|
163
|
+
};
|
|
164
|
+
export declare type IOldReqOptionsWithJSON = IOldReqOptions & {
|
|
165
|
+
json: true;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* for PicGo new request api, the response will be json format
|
|
169
|
+
*/
|
|
170
|
+
export declare type IReqOptions<T = any> = AxiosRequestConfig<T> & {
|
|
171
|
+
resolveWithFullResponse: true;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* for PicGo new request api, the response will be Buffer
|
|
175
|
+
*/
|
|
176
|
+
export declare type IReqOptionsWithArrayBufferRes<T = any> = IReqOptions<T> & {
|
|
177
|
+
responseType: 'arraybuffer';
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* for PicGo new request api, the response will be just response data. (not statusCode, headers, etc.)
|
|
181
|
+
*/
|
|
182
|
+
export declare type IReqOptionsWithBodyResOnly<T = any> = AxiosRequestConfig<T>;
|
|
183
|
+
export declare type IFullResponse<T = any, U = any> = AxiosResponse<T, U> & {
|
|
184
|
+
statusCode: number;
|
|
185
|
+
body: T;
|
|
186
|
+
};
|
|
187
|
+
declare type AxiosResponse<T = any, U = any> = import('axios').AxiosResponse<T, U>;
|
|
188
|
+
declare type AxiosRequestConfig<T = any> = import('axios').AxiosRequestConfig<T>;
|
|
189
|
+
interface IRequestOptionsWithFullResponse {
|
|
190
|
+
resolveWithFullResponse: true;
|
|
191
|
+
}
|
|
192
|
+
interface IRequestOptionsWithJSON {
|
|
193
|
+
json: true;
|
|
194
|
+
}
|
|
195
|
+
interface IRequestOptionsWithResponseTypeArrayBuffer {
|
|
196
|
+
responseType: 'arraybuffer';
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* T is the response data type
|
|
200
|
+
* U is the config type
|
|
201
|
+
*/
|
|
202
|
+
export declare type IResponse<T, U> = U extends IRequestOptionsWithFullResponse ? IFullResponse<T, U> : U extends IRequestOptionsWithJSON ? T : U extends IRequestOptionsWithResponseTypeArrayBuffer ? Buffer : U extends IOldReqOptionsWithFullResponse ? IFullResponse<T, U> : U extends IOldReqOptionsWithJSON ? T : U extends IOldReqOptions ? string : U extends IReqOptionsWithBodyResOnly ? T : string;
|
|
203
|
+
/**
|
|
204
|
+
* the old request lib will be removed in v1.5.0+
|
|
205
|
+
* the request options have the following properties
|
|
206
|
+
*/
|
|
207
|
+
export interface IRequestLibOnlyOptions {
|
|
208
|
+
proxy?: string;
|
|
209
|
+
body?: any;
|
|
210
|
+
formData?: {
|
|
211
|
+
[key: string]: any;
|
|
212
|
+
} | undefined;
|
|
213
|
+
form?: {
|
|
214
|
+
[key: string]: any;
|
|
215
|
+
} | string | undefined;
|
|
216
|
+
}
|
|
217
|
+
export declare type IRequestConfig<T> = T extends IRequestLibOnlyOptions ? IOldReqOptions : AxiosRequestConfig;
|
|
156
218
|
export interface IRequest {
|
|
157
|
-
request:
|
|
219
|
+
request: <T, U extends (IRequestConfig<U> extends IOldReqOptions ? IOldReqOptions : IRequestConfig<U> extends AxiosRequestConfig ? AxiosRequestConfig : never)>(config: U) => Promise<IResponse<T, U>>;
|
|
158
220
|
}
|
|
159
221
|
export declare type ILogColor = 'blue' | 'green' | 'yellow' | 'red';
|
|
160
222
|
/**
|
|
@@ -438,11 +500,15 @@ export interface ILogger {
|
|
|
438
500
|
info: (...msg: ILogArgvType[]) => void;
|
|
439
501
|
error: (...msg: ILogArgvTypeWithError[]) => void;
|
|
440
502
|
warn: (...msg: ILogArgvType[]) => void;
|
|
503
|
+
debug: (...msg: ILogArgvType[]) => void;
|
|
441
504
|
}
|
|
442
505
|
export interface IConfigChangePayload<T> {
|
|
443
506
|
configName: string;
|
|
444
507
|
value: T;
|
|
445
508
|
}
|
|
509
|
+
export interface ILocale {
|
|
510
|
+
[key: string]: any;
|
|
511
|
+
}
|
|
446
512
|
export interface II18nManager {
|
|
447
513
|
/**
|
|
448
514
|
* translate text
|
|
@@ -468,3 +534,4 @@ export interface II18nManager {
|
|
|
468
534
|
*/
|
|
469
535
|
getLanguageList: () => string[];
|
|
470
536
|
}
|
|
537
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare type IMethod = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
2
|
+
export interface IHeaders {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
export interface IRequestPromiseOptions {
|
|
6
|
+
baseUrl?: string | undefined;
|
|
7
|
+
url?: string;
|
|
8
|
+
method?: IMethod;
|
|
9
|
+
formData?: {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
} | undefined;
|
|
12
|
+
qs?: any;
|
|
13
|
+
json?: boolean;
|
|
14
|
+
body?: any;
|
|
15
|
+
resolveWithFullResponse?: boolean;
|
|
16
|
+
headers?: IHeaders;
|
|
17
|
+
proxy?: any;
|
|
18
|
+
timeout?: number;
|
|
19
|
+
}
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { IImgSize, IPathTransformedImgInfo, IPluginNameType, ILogger, IPicGo } from '../types';
|
|
3
4
|
export declare const isUrl: (url: string) => boolean;
|
|
4
5
|
export declare const isUrlEncode: (url: string) => boolean;
|
|
5
6
|
export declare const handleUrlEncode: (url: string) => string;
|
|
6
7
|
export declare const getImageSize: (file: Buffer) => IImgSize;
|
|
7
8
|
export declare const getFSFile: (filePath: string) => Promise<IPathTransformedImgInfo>;
|
|
8
|
-
export declare const getURLFile: (url: string) => Promise<IPathTransformedImgInfo>;
|
|
9
|
+
export declare const getURLFile: (url: string, ctx: IPicGo) => Promise<IPathTransformedImgInfo>;
|
|
9
10
|
/**
|
|
10
11
|
* detect the input string's type
|
|
11
12
|
* for example
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "picgo",
|
|
3
|
-
"version": "1.5.0
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "A tool for picture uploading",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"@types/md5": "^2.1.32",
|
|
66
66
|
"@types/mime-types": "^2.1.0",
|
|
67
67
|
"@types/minimatch": "^3.0.3",
|
|
68
|
-
"@types/node": "
|
|
69
|
-
"@types/request-promise-native": "^1.0.15",
|
|
68
|
+
"@types/node": "16.11.7",
|
|
70
69
|
"@types/resolve": "^0.0.8",
|
|
71
70
|
"@types/rimraf": "^3.0.0",
|
|
71
|
+
"@types/tunnel": "^0.0.3",
|
|
72
72
|
"@typescript-eslint/eslint-plugin": "3",
|
|
73
73
|
"@typescript-eslint/parser": "^3.2.0",
|
|
74
74
|
"babel-eslint": "^10.1.0",
|
|
@@ -90,11 +90,12 @@
|
|
|
90
90
|
"rollup-plugin-string": "^3.0.0",
|
|
91
91
|
"rollup-plugin-terser": "^7.0.2",
|
|
92
92
|
"rollup-plugin-typescript2": "^0.30.0",
|
|
93
|
-
"typescript": "^4.
|
|
93
|
+
"typescript": "^4.8.2"
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
96
|
"@picgo/i18n": "^1.0.0",
|
|
97
97
|
"@picgo/store": "^2.0.2",
|
|
98
|
+
"axios": "^0.27.2",
|
|
98
99
|
"chalk": "^2.4.1",
|
|
99
100
|
"commander": "^8.1.0",
|
|
100
101
|
"comment-json": "^2.3.1",
|
|
@@ -114,10 +115,9 @@
|
|
|
114
115
|
"minimatch": "^3.0.4",
|
|
115
116
|
"minimist": "^1.2.5",
|
|
116
117
|
"qiniu": "^7.2.1",
|
|
117
|
-
"request": "^2.87.0",
|
|
118
|
-
"request-promise-native": "^1.0.5",
|
|
119
118
|
"resolve": "^1.8.1",
|
|
120
|
-
"rimraf": "^3.0.2"
|
|
119
|
+
"rimraf": "^3.0.2",
|
|
120
|
+
"tunnel": "^0.0.6"
|
|
121
121
|
},
|
|
122
122
|
"repository": {
|
|
123
123
|
"type": "git",
|