picgo 1.5.10 → 1.6.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.
Files changed (60) hide show
  1. package/.github/workflows/release.yml +60 -0
  2. package/.node-version +1 -1
  3. package/CHANGELOG.md +20 -0
  4. package/README.md +1 -1
  5. package/dist/core/Lifecycle.d.ts +14 -15
  6. package/dist/core/PicGo.d.ts +48 -49
  7. package/dist/i18n/en.d.ts +2 -2
  8. package/dist/i18n/index.d.ts +18 -18
  9. package/dist/i18n/zh-CN.d.ts +97 -97
  10. package/dist/i18n/zh-TW.d.ts +2 -2
  11. package/dist/index.cjs.js +2 -2
  12. package/dist/index.cjs.js.map +1 -0
  13. package/dist/index.d.ts +10 -10
  14. package/dist/index.esm.js +2 -2
  15. package/dist/index.esm.js.map +1 -0
  16. package/dist/lib/Commander.d.ts +22 -22
  17. package/dist/lib/LifecyclePlugins.d.ts +17 -17
  18. package/dist/lib/Logger.d.ts +19 -19
  19. package/dist/lib/PluginHandler.d.ts +10 -10
  20. package/dist/lib/PluginLoader.d.ts +27 -27
  21. package/dist/lib/Request.d.ts +12 -12
  22. package/dist/plugins/commander/config.d.ts +3 -3
  23. package/dist/plugins/commander/i18n.d.ts +3 -3
  24. package/dist/plugins/commander/index.d.ts +3 -3
  25. package/dist/plugins/commander/init.d.ts +3 -3
  26. package/dist/plugins/commander/pluginHandler.d.ts +3 -3
  27. package/dist/plugins/commander/proxy.d.ts +3 -3
  28. package/dist/plugins/commander/setting.d.ts +5 -5
  29. package/dist/plugins/commander/upload.d.ts +3 -3
  30. package/dist/plugins/commander/use.d.ts +3 -3
  31. package/dist/plugins/transformer/base64.d.ts +5 -5
  32. package/dist/plugins/transformer/index.d.ts +3 -3
  33. package/dist/plugins/transformer/path.d.ts +5 -5
  34. package/dist/plugins/uploader/aliyun.d.ts +2 -2
  35. package/dist/plugins/uploader/github.d.ts +2 -2
  36. package/dist/plugins/uploader/imgur.d.ts +2 -2
  37. package/dist/plugins/uploader/index.d.ts +3 -3
  38. package/dist/plugins/uploader/qiniu.d.ts +2 -2
  39. package/dist/plugins/uploader/smms.d.ts +2 -2
  40. package/dist/plugins/uploader/tcyun.d.ts +8 -8
  41. package/dist/plugins/uploader/upyun.d.ts +2 -2
  42. package/dist/types/index.d.ts +540 -542
  43. package/dist/types/oldRequest.d.ts +19 -19
  44. package/dist/utils/common.d.ts +118 -106
  45. package/dist/utils/createContext.d.ts +6 -6
  46. package/dist/utils/db.d.ts +15 -15
  47. package/dist/utils/enum.d.ts +27 -27
  48. package/dist/utils/eventBus.d.ts +3 -4
  49. package/dist/utils/getClipboardImage.d.ts +4 -4
  50. package/dist/utils/initUtils.d.ts +26 -26
  51. package/dist/utils/interfaces.d.ts +202 -203
  52. package/dist/utils/static.d.ts +1 -1
  53. package/eslint.config.js +134 -0
  54. package/package.json +39 -37
  55. package/rollup.config.js +59 -66
  56. package/.eslintignore +0 -2
  57. package/.eslintrc.js +0 -25
  58. package/.github/workflows/alpha.yml +0 -22
  59. package/.github/workflows/main.yml +0 -22
  60. package/.github/workflows/manually.yml +0 -19
@@ -1,203 +1,202 @@
1
- /** This file is deprecated */
2
- /// <reference types="node" />
3
- import { PicGo } from '../core/PicGo';
4
- import LifecyclePlugins from '../lib/LifecyclePlugins';
5
- /**
6
- * for plugin config
7
- */
8
- export interface IPluginConfig {
9
- name: string;
10
- type: string;
11
- required: boolean;
12
- default?: any;
13
- [propName: string]: any;
14
- }
15
- /**
16
- * for lifecycle plugins
17
- */
18
- export interface IHelper {
19
- transformer: LifecyclePlugins;
20
- uploader: LifecyclePlugins;
21
- beforeTransformPlugins: LifecyclePlugins;
22
- beforeUploadPlugins: LifecyclePlugins;
23
- afterUploadPlugins: LifecyclePlugins;
24
- }
25
- /**
26
- * for uploading image info
27
- */
28
- export interface IImgInfo {
29
- buffer?: Buffer;
30
- base64Image?: string;
31
- fileName?: string;
32
- width?: number;
33
- height?: number;
34
- extname?: string;
35
- [propName: string]: any;
36
- }
37
- export interface IPathTransformedImgInfo extends IImgInfo {
38
- success: boolean;
39
- }
40
- /** SM.MS 图床配置项 */
41
- export interface ISmmsConfig {
42
- token: string;
43
- }
44
- /** 七牛云图床配置项 */
45
- export interface IQiniuConfig {
46
- accessKey: string;
47
- secretKey: string;
48
- /** 存储空间名 */
49
- bucket: string;
50
- /** 自定义域名 */
51
- url: string;
52
- /** 存储区域编号 */
53
- area: 'z0' | 'z1' | 'z2' | 'na0' | 'as0';
54
- /** 网址后缀,比如使用 `?imageslim` 可进行[图片瘦身](https://developer.qiniu.com/dora/api/1271/image-thin-body-imageslim) */
55
- options: string;
56
- /** 自定义存储路径,比如 `img/` */
57
- path: string;
58
- }
59
- /** 又拍云图床配置项 */
60
- export interface IUpyunConfig {
61
- /** 存储空间名,及你的服务名 */
62
- bucket: string;
63
- /** 操作员 */
64
- operator: string;
65
- /** 密码 */
66
- password: string;
67
- /** 针对图片的一些后缀处理参数 */
68
- options: string;
69
- /** 自定义存储路径,比如 `img/` */
70
- path: string;
71
- /** 加速域名,注意要加 `http://` 或者 `https://` */
72
- url: string;
73
- }
74
- /** 腾讯云图床配置项 */
75
- export interface ITcyunConfig {
76
- secretId: string;
77
- secretKey: string;
78
- /** 存储桶名,v4 和 v5 版本不一样 */
79
- bucket: string;
80
- appId: string;
81
- /** 存储区域,例如 ap-beijing-1 */
82
- area: string;
83
- /** 自定义存储路径,比如 img/ */
84
- path: string;
85
- /** 自定义域名,注意要加 `http://` 或者 `https://` */
86
- customUrl: string;
87
- /** COS 版本,v4 或者 v5 */
88
- version: 'v5' | 'v4';
89
- }
90
- /** GitHub 图床配置项 */
91
- export interface IGithubConfig {
92
- /** 仓库名,格式是 `username/reponame` */
93
- repo: string;
94
- /** github token */
95
- token: string;
96
- /** 自定义存储路径,比如 `img/` */
97
- path: string;
98
- /** 自定义域名,注意要加 `http://` 或者 `https://` */
99
- customUrl: string;
100
- /** 分支名,默认是 `master` */
101
- branch: string;
102
- }
103
- /** 阿里云图床配置项 */
104
- export interface IAliyunConfig {
105
- accessKeyId: string;
106
- accessKeySecret: string;
107
- /** 存储空间名 */
108
- bucket: string;
109
- /** 存储区域代号 */
110
- area: string;
111
- /** 自定义存储路径 */
112
- path: string;
113
- /** 自定义域名,注意要加 `http://` 或者 `https://` */
114
- customUrl: string;
115
- /** 针对图片的一些后缀处理参数 PicGo 2.2.0+ PicGo-Core 1.4.0+ */
116
- options: string;
117
- }
118
- /** Imgur 图床配置项 */
119
- export interface IImgurConfig {
120
- /** imgur 的 `clientId` */
121
- clientId: string;
122
- /** 代理地址,仅支持 http 代理 */
123
- proxy: string;
124
- }
125
- /** PicGo 配置文件类型定义 */
126
- export interface IConfig {
127
- picBed: {
128
- uploader: string;
129
- current?: string;
130
- smms?: ISmmsConfig;
131
- qiniu?: IQiniuConfig;
132
- upyun?: IUpyunConfig;
133
- tcyun?: ITcyunConfig;
134
- github?: IGithubConfig;
135
- aliyun?: IAliyunConfig;
136
- imgur?: IImgurConfig;
137
- transformer?: string;
138
- proxy: string;
139
- };
140
- picgoPlugins: {
141
- [propName: string]: boolean;
142
- };
143
- debug?: boolean;
144
- silent?: boolean;
145
- settings?: {
146
- logLevel: string;
147
- logPath: string;
148
- };
149
- /** 下载插件时 npm 命令自定义的 registry */
150
- registry: string;
151
- }
152
- /**
153
- * for plugin
154
- */
155
- export interface IPlugin {
156
- handle: ((ctx: PicGo) => Promise<any>) | ((ctx: PicGo) => void);
157
- [propName: string]: any;
158
- }
159
- /**
160
- * for spawn output
161
- */
162
- export interface IResult {
163
- code: number;
164
- data: string;
165
- }
166
- /**
167
- * for transformer - path
168
- */
169
- export interface IImgSize {
170
- width: number;
171
- height: number;
172
- real?: boolean;
173
- }
174
- /**
175
- * for initUtils
176
- */
177
- export interface IOptions {
178
- template: string;
179
- dest: string;
180
- hasSlash: boolean;
181
- inPlace: boolean;
182
- clone: boolean;
183
- offline: boolean;
184
- tmp: string;
185
- project: string;
186
- }
187
- /**
188
- * for clipboard image
189
- */
190
- export interface IClipboardImage {
191
- imgPath: string;
192
- isExistFile: boolean;
193
- }
194
- /**
195
- * for install command environment variable
196
- */
197
- export interface IProcessEnv {
198
- [propName: string]: Undefinable<string>;
199
- }
200
- export declare type ILogArgvType = string | number;
201
- export declare type ILogArgvTypeWithError = ILogArgvType | Error;
202
- export declare type Nullable<T> = T | null;
203
- export declare type Undefinable<T> = T | undefined;
1
+ /** This file is deprecated */
2
+ import { PicGo } from '../core/PicGo';
3
+ import LifecyclePlugins from '../lib/LifecyclePlugins';
4
+ /**
5
+ * for plugin config
6
+ */
7
+ export interface IPluginConfig {
8
+ name: string;
9
+ type: string;
10
+ required: boolean;
11
+ default?: any;
12
+ [propName: string]: any;
13
+ }
14
+ /**
15
+ * for lifecycle plugins
16
+ */
17
+ export interface IHelper {
18
+ transformer: LifecyclePlugins;
19
+ uploader: LifecyclePlugins;
20
+ beforeTransformPlugins: LifecyclePlugins;
21
+ beforeUploadPlugins: LifecyclePlugins;
22
+ afterUploadPlugins: LifecyclePlugins;
23
+ }
24
+ /**
25
+ * for uploading image info
26
+ */
27
+ export interface IImgInfo {
28
+ buffer?: Buffer;
29
+ base64Image?: string;
30
+ fileName?: string;
31
+ width?: number;
32
+ height?: number;
33
+ extname?: string;
34
+ [propName: string]: any;
35
+ }
36
+ export interface IPathTransformedImgInfo extends IImgInfo {
37
+ success: boolean;
38
+ }
39
+ /** SM.MS 图床配置项 */
40
+ export interface ISmmsConfig {
41
+ token: string;
42
+ }
43
+ /** 七牛云图床配置项 */
44
+ export interface IQiniuConfig {
45
+ accessKey: string;
46
+ secretKey: string;
47
+ /** 存储空间名 */
48
+ bucket: string;
49
+ /** 自定义域名 */
50
+ url: string;
51
+ /** 存储区域编号 */
52
+ area: 'z0' | 'z1' | 'z2' | 'na0' | 'as0';
53
+ /** 网址后缀,比如使用 `?imageslim` 可进行[图片瘦身](https://developer.qiniu.com/dora/api/1271/image-thin-body-imageslim) */
54
+ options: string;
55
+ /** 自定义存储路径,比如 `img/` */
56
+ path: string;
57
+ }
58
+ /** 又拍云图床配置项 */
59
+ export interface IUpyunConfig {
60
+ /** 存储空间名,及你的服务名 */
61
+ bucket: string;
62
+ /** 操作员 */
63
+ operator: string;
64
+ /** 密码 */
65
+ password: string;
66
+ /** 针对图片的一些后缀处理参数 */
67
+ options: string;
68
+ /** 自定义存储路径,比如 `img/` */
69
+ path: string;
70
+ /** 加速域名,注意要加 `http://` 或者 `https://` */
71
+ url: string;
72
+ }
73
+ /** 腾讯云图床配置项 */
74
+ export interface ITcyunConfig {
75
+ secretId: string;
76
+ secretKey: string;
77
+ /** 存储桶名,v4 和 v5 版本不一样 */
78
+ bucket: string;
79
+ appId: string;
80
+ /** 存储区域,例如 ap-beijing-1 */
81
+ area: string;
82
+ /** 自定义存储路径,比如 img/ */
83
+ path: string;
84
+ /** 自定义域名,注意要加 `http://` 或者 `https://` */
85
+ customUrl: string;
86
+ /** COS 版本,v4 或者 v5 */
87
+ version: 'v5' | 'v4';
88
+ }
89
+ /** GitHub 图床配置项 */
90
+ export interface IGithubConfig {
91
+ /** 仓库名,格式是 `username/reponame` */
92
+ repo: string;
93
+ /** github token */
94
+ token: string;
95
+ /** 自定义存储路径,比如 `img/` */
96
+ path: string;
97
+ /** 自定义域名,注意要加 `http://` 或者 `https://` */
98
+ customUrl: string;
99
+ /** 分支名,默认是 `master` */
100
+ branch: string;
101
+ }
102
+ /** 阿里云图床配置项 */
103
+ export interface IAliyunConfig {
104
+ accessKeyId: string;
105
+ accessKeySecret: string;
106
+ /** 存储空间名 */
107
+ bucket: string;
108
+ /** 存储区域代号 */
109
+ area: string;
110
+ /** 自定义存储路径 */
111
+ path: string;
112
+ /** 自定义域名,注意要加 `http://` 或者 `https://` */
113
+ customUrl: string;
114
+ /** 针对图片的一些后缀处理参数 PicGo 2.2.0+ PicGo-Core 1.4.0+ */
115
+ options: string;
116
+ }
117
+ /** Imgur 图床配置项 */
118
+ export interface IImgurConfig {
119
+ /** imgur 的 `clientId` */
120
+ clientId: string;
121
+ /** 代理地址,仅支持 http 代理 */
122
+ proxy: string;
123
+ }
124
+ /** PicGo 配置文件类型定义 */
125
+ export interface IConfig {
126
+ picBed: {
127
+ uploader: string;
128
+ current?: string;
129
+ smms?: ISmmsConfig;
130
+ qiniu?: IQiniuConfig;
131
+ upyun?: IUpyunConfig;
132
+ tcyun?: ITcyunConfig;
133
+ github?: IGithubConfig;
134
+ aliyun?: IAliyunConfig;
135
+ imgur?: IImgurConfig;
136
+ transformer?: string;
137
+ proxy: string;
138
+ };
139
+ picgoPlugins: {
140
+ [propName: string]: boolean;
141
+ };
142
+ debug?: boolean;
143
+ silent?: boolean;
144
+ settings?: {
145
+ logLevel: string;
146
+ logPath: string;
147
+ };
148
+ /** 下载插件时 npm 命令自定义的 registry */
149
+ registry: string;
150
+ }
151
+ /**
152
+ * for plugin
153
+ */
154
+ export interface IPlugin {
155
+ handle: ((ctx: PicGo) => Promise<any>) | ((ctx: PicGo) => void);
156
+ [propName: string]: any;
157
+ }
158
+ /**
159
+ * for spawn output
160
+ */
161
+ export interface IResult {
162
+ code: number;
163
+ data: string;
164
+ }
165
+ /**
166
+ * for transformer - path
167
+ */
168
+ export interface IImgSize {
169
+ width: number;
170
+ height: number;
171
+ real?: boolean;
172
+ }
173
+ /**
174
+ * for initUtils
175
+ */
176
+ export interface IOptions {
177
+ template: string;
178
+ dest: string;
179
+ hasSlash: boolean;
180
+ inPlace: boolean;
181
+ clone: boolean;
182
+ offline: boolean;
183
+ tmp: string;
184
+ project: string;
185
+ }
186
+ /**
187
+ * for clipboard image
188
+ */
189
+ export interface IClipboardImage {
190
+ imgPath: string;
191
+ isExistFile: boolean;
192
+ }
193
+ /**
194
+ * for install command environment variable
195
+ */
196
+ export interface IProcessEnv {
197
+ [propName: string]: Undefinable<string>;
198
+ }
199
+ export type ILogArgvType = string | number;
200
+ export type ILogArgvTypeWithError = ILogArgvType | Error;
201
+ export type Nullable<T> = T | null;
202
+ export type Undefinable<T> = T | undefined;
@@ -1 +1 @@
1
- export declare const CLIPBOARD_IMAGE_FOLDER = "picgo-clipboard-images";
1
+ export declare const CLIPBOARD_IMAGE_FOLDER = "picgo-clipboard-images";
@@ -0,0 +1,134 @@
1
+ const globals = require('globals')
2
+ const js = require('@eslint/js')
3
+ const tsPlugin = require('@typescript-eslint/eslint-plugin')
4
+ const tsParser = require('@typescript-eslint/parser')
5
+ const importPlugin = require('eslint-plugin-import')
6
+ const promisePlugin = require('eslint-plugin-promise')
7
+ const eslintConfigPrettier = require('eslint-config-prettier')
8
+
9
+ const tsEslintRecommendedAdjustments =
10
+ tsPlugin.configs['eslint-recommended'].overrides?.[0]?.rules ?? {}
11
+
12
+ module.exports = [
13
+ {
14
+ ignores: [
15
+ '**/dist/**',
16
+ '**/node_modules/**',
17
+ '**/*.d.ts',
18
+ '.eslintrc.js',
19
+ 'bin',
20
+ 'scripts/**/*.js'
21
+ ],
22
+ linterOptions: {
23
+ reportUnusedDisableDirectives: 'off'
24
+ }
25
+ },
26
+ {
27
+ ...js.configs.recommended,
28
+ files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
29
+ ignores: ['**/dist/**', '**/node_modules/**'],
30
+ languageOptions: {
31
+ sourceType: 'commonjs',
32
+ globals: {
33
+ ...globals.node,
34
+ ...globals.es2022
35
+ }
36
+ },
37
+ rules: {
38
+ 'no-undef': 'off',
39
+ semi: ['error', 'never']
40
+ }
41
+ },
42
+ {
43
+ files: ['**/*.d.ts'],
44
+ ignores: ['**/dist/**', '**/node_modules/**'],
45
+ languageOptions: {
46
+ parser: tsParser,
47
+ parserOptions: {
48
+ project: './tsconfig.json',
49
+ tsconfigRootDir: __dirname,
50
+ sourceType: 'module'
51
+ },
52
+ globals: {
53
+ ...globals.node,
54
+ ...globals.es2022
55
+ }
56
+ },
57
+ plugins: {
58
+ '@typescript-eslint': tsPlugin
59
+ },
60
+ rules: {
61
+ 'no-var': 'off',
62
+ '@typescript-eslint/naming-convention': 'off'
63
+ }
64
+ },
65
+ {
66
+ files: ['src/**/*.ts', 'scripts/**/*.ts', 'types/**/*.ts'],
67
+ ignores: ['**/*.d.ts'],
68
+ languageOptions: {
69
+ parser: tsParser,
70
+ parserOptions: {
71
+ project: './tsconfig.json',
72
+ tsconfigRootDir: __dirname,
73
+ sourceType: 'module'
74
+ },
75
+ globals: {
76
+ ...globals.node,
77
+ ...globals.es2022
78
+ }
79
+ },
80
+ plugins: {
81
+ '@typescript-eslint': tsPlugin,
82
+ import: importPlugin,
83
+ promise: promisePlugin
84
+ },
85
+ rules: {
86
+ ...tsEslintRecommendedAdjustments,
87
+ ...tsPlugin.configs.recommended.rules,
88
+ ...tsPlugin.configs['recommended-requiring-type-checking'].rules,
89
+ ...promisePlugin.configs.recommended.rules,
90
+ ...eslintConfigPrettier.rules,
91
+ '@typescript-eslint/strict-boolean-expressions': 'off',
92
+ '@typescript-eslint/prefer-nullish-coalescing': 'off',
93
+ '@typescript-eslint/return-await': 'off',
94
+ '@typescript-eslint/no-floating-promises': 'off',
95
+ '@typescript-eslint/no-non-null-assertion': 'off',
96
+ '@typescript-eslint/no-explicit-any': 'off',
97
+ '@typescript-eslint/no-unsafe-member-access': 'off',
98
+ '@typescript-eslint/no-unsafe-assignment': 'off',
99
+ '@typescript-eslint/no-unsafe-argument': 'off',
100
+ '@typescript-eslint/no-unsafe-call': 'off',
101
+ '@typescript-eslint/no-unsafe-return': 'off',
102
+ '@typescript-eslint/no-unsafe-function-type': 'off',
103
+ '@typescript-eslint/no-redundant-type-constituents': 'off',
104
+ '@typescript-eslint/ban-ts-comment': 'off',
105
+ '@typescript-eslint/require-await': 'off',
106
+ '@typescript-eslint/no-require-imports': 'off',
107
+ '@typescript-eslint/no-unused-vars': 'off',
108
+ '@typescript-eslint/prefer-promise-reject-errors': 'off',
109
+ '@typescript-eslint/naming-convention': [
110
+ 'error',
111
+ {
112
+ selector: 'interface',
113
+ format: ['PascalCase'],
114
+ custom: { regex: '^I[A-Z]', match: true }
115
+ }
116
+ ],
117
+ 'import/no-unresolved': 'off',
118
+ 'import/namespace': 'off',
119
+ 'import/no-duplicates': 'off',
120
+ 'import/default': 'off',
121
+ 'import/no-named-as-default': 'off',
122
+ 'import/no-named-as-default-member': 'off',
123
+ 'promise/always-return': 'off',
124
+ 'promise/no-promise-in-callback': 'off',
125
+ semi: ['error', 'never']
126
+ },
127
+ settings: {
128
+ 'import/resolver': {
129
+ typescript: true,
130
+ node: true
131
+ }
132
+ }
133
+ }
134
+ ]