picgo 1.8.1 → 2.0.1
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/.env.example +2 -0
- package/AGENTS.md +4 -0
- package/README.md +30 -5
- package/dist/core/PicGo.d.ts +5 -1
- package/dist/i18n/index.d.ts +2 -2
- package/dist/i18n/zh-CN.d.ts +35 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/Cloud/Auth.d.ts +15 -0
- package/dist/lib/Cloud/Request.d.ts +12 -0
- package/dist/lib/Cloud/index.d.ts +15 -0
- package/dist/lib/Cloud/services/ConfigService.d.ts +15 -0
- package/dist/lib/Cloud/services/UserService.d.ts +12 -0
- package/dist/lib/Cloud/utils.d.ts +15 -0
- package/dist/lib/ConfigSyncManager/E2ECryptoService.d.ts +24 -0
- package/dist/lib/ConfigSyncManager/Merger.d.ts +4 -0
- package/dist/lib/ConfigSyncManager/errors.d.ts +29 -0
- package/dist/lib/ConfigSyncManager/index.d.ts +39 -0
- package/dist/lib/ConfigSyncManager/types.d.ts +87 -0
- package/dist/lib/ConfigSyncManager/utils.d.ts +41 -0
- package/dist/lib/Routes/routePath.d.ts +6 -0
- package/dist/lib/Server/index.d.ts +39 -0
- package/dist/lib/Server/routes.d.ts +4 -0
- package/dist/lib/Server/utils.d.ts +10 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/plugins/commander/config.d.ts +2 -2
- package/dist/plugins/commander/configPath.d.ts +3 -0
- package/dist/plugins/commander/index.d.ts +2 -2
- package/dist/plugins/commander/login.d.ts +3 -0
- package/dist/plugins/commander/logout.d.ts +3 -0
- package/dist/plugins/commander/server.d.ts +3 -0
- package/dist/plugins/commander/setting.d.ts +2 -2
- package/dist/plugins/commander/utils.d.ts +10 -0
- package/dist/types/index.d.ts +78 -2
- package/dist/types/internal.d.ts +8 -0
- package/package.json +29 -18
- package/vitest.config.ts +9 -0
- package/dist/__tests__/unit/uploaderConfigManager.spec.d.ts +0 -1
- package/dist/__tests__/unit/urlRewrite.spec.d.ts +0 -1
package/.env.example
ADDED
package/AGENTS.md
CHANGED
|
@@ -30,13 +30,17 @@ Always ask questions before create proposal files if unsure about anything in th
|
|
|
30
30
|
- **Exports**: do not use `export default` for new/modified modules. Prefer named exports (e.g. `export { ServerManager }`) and named imports (e.g. `import { ServerManager } from '...'`).
|
|
31
31
|
- Keep TypeScript types explicit; avoid ad-hoc `any` when possible.
|
|
32
32
|
- Don't write `as any` in TypeScript code unless absolutely necessary. Always prefer explicit types.
|
|
33
|
+
- **i18n / user-facing text**: do not hard-code user-facing strings (logs, errors, HTML result pages). Add i18n keys under `src/i18n/zh-CN.ts` and provide corresponding entries in `src/i18n/en.ts` and `src/i18n/zh-TW.ts`, then use `ctx.i18n.translate<ILocalesKey>(...)` (supports `${var}` placeholders via args). CLI option descriptions are exempt unless explicitly requested.
|
|
33
34
|
- **Commander actions**: prefer `.action(async (...) => { ... })` and avoid wrapping an IIFE like `.action(() => { (async () => { ... })().catch(...) })`.
|
|
34
35
|
- **Commander prompts**: avoid `prompt<any>` / `prompt<IStringKeyMap<any>>`; declare a concrete answer type (e.g. `prompt<{ operation: 'list' | 'rename' }>(...)`).
|
|
36
|
+
- **Commander option descriptions**: for CLI options, use plain strings without i18n keys unless explicitly requested.
|
|
37
|
+
- **TypeScript enums**: when representing a fixed set of values, prefer `enum` over union string literal types unless explicitly requested otherwise.
|
|
35
38
|
- **Config persistence**: use `ctx.saveConfig(...)` for changes that must persist to disk; use `ctx.setConfig(...)` only for in-memory/session updates.
|
|
36
39
|
|
|
37
40
|
## Execution Rules
|
|
38
41
|
- If a command fails due to insufficient permissions, rerun with elevated approval.
|
|
39
42
|
- For `pnpm` commands that hit network issues, retry first.
|
|
43
|
+
- After completing a task, run `pnpm lint` and `pnpm test` and ensure they pass before handing work back.
|
|
40
44
|
|
|
41
45
|
## Serena MCP & Context7 Tools
|
|
42
46
|
When starting work or if you hit issues, try checking MCP for Serena or Context7 tooling. If available, use those tools to navigate, edit, or fetch docs efficiently.
|
package/README.md
CHANGED
|
@@ -23,13 +23,15 @@
|
|
|
23
23
|
|
|
24
24
|

|
|
25
25
|
|
|
26
|
-
A tool for
|
|
26
|
+
A tool for image uploading. Both CLI & api supports. It also supports plugin system, please check [Awesome-PicGo](https://github.com/PicGo/Awesome-PicGo) to find powerful plugins.
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
More details please see the [Homepage](https://picgo.app/) of PicGo.
|
|
29
|
+
|
|
30
|
+
**Typora supports PicGo-Core natively**.
|
|
29
31
|
|
|
30
32
|
## Installation
|
|
31
33
|
|
|
32
|
-
PicGo
|
|
34
|
+
PicGo requires Node.js >= 20.19.0 or >= 22.12.0. For older PicGo versions (<= v1.5.x), Node.js >= 16 is sufficient. Cause we need the [stability of ES Module support](https://joyeecheung.github.io/blog/2025/12/30/require-esm-in-node-js-from-experiment-to-stability/).
|
|
33
35
|
|
|
34
36
|
### Global install
|
|
35
37
|
|
|
@@ -55,7 +57,7 @@ yarn add picgo -D
|
|
|
55
57
|
|
|
56
58
|
### Use in CLI
|
|
57
59
|
|
|
58
|
-
> PicGo uses `SM.MS` as the default upload
|
|
60
|
+
> PicGo uses `SM.MS(S.EE)` as the default upload image host.
|
|
59
61
|
|
|
60
62
|
Show help:
|
|
61
63
|
|
|
@@ -81,6 +83,9 @@ $ picgo -h
|
|
|
81
83
|
use [module] [name] [configName] use module (uploader/transformer/plugin) of picgo
|
|
82
84
|
i18n [lang] change picgo language
|
|
83
85
|
uploader manage uploader configurations
|
|
86
|
+
server [options] run PicGo as a standalone server
|
|
87
|
+
login [token] login to cloud.picgo.app
|
|
88
|
+
logout logout from cloud.picgo.app
|
|
84
89
|
help [command] display help for command
|
|
85
90
|
```
|
|
86
91
|
|
|
@@ -100,6 +105,26 @@ picgo upload
|
|
|
100
105
|
|
|
101
106
|
Thanks to [vs-picgo](https://github.com/Spades-S/vs-picgo) && [Spades-S](https://github.com/Spades-S) for providing the method to upload picture from clipboard.
|
|
102
107
|
|
|
108
|
+
#### Run as a server
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
picgo server -p 36677 -h 127.0.0.1
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### Login to PicGo Cloud
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
picgo login
|
|
118
|
+
# or
|
|
119
|
+
picgo login <token>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### Logout from PicGo Cloud
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
picgo logout
|
|
126
|
+
```
|
|
127
|
+
|
|
103
128
|
#### Manage uploader configs
|
|
104
129
|
|
|
105
130
|
Since v1.8.0, PicGo-Core supports multiple configurations per uploader. Just like the configuration of the Electron version of PicGo.
|
|
@@ -171,4 +196,4 @@ picgo.upload()
|
|
|
171
196
|
|
|
172
197
|
## Documentation
|
|
173
198
|
|
|
174
|
-
For more details, you can checkout [documentation](https://picgo.
|
|
199
|
+
For more details, you can checkout [documentation](https://docs.picgo.app/core/).
|
package/dist/core/PicGo.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import Commander from '../lib/Commander';
|
|
3
3
|
import { Logger } from '../lib/Logger';
|
|
4
|
-
import { IHelper, IImgInfo, IPicGo, IStringKeyMap, IPluginLoader, II18nManager, IPicGoPlugin, IPicGoPluginInterface, IRequest, IUploaderConfigManager } from '../types';
|
|
4
|
+
import { IHelper, IImgInfo, IPicGo, IStringKeyMap, IPluginLoader, II18nManager, IPicGoPlugin, IPicGoPluginInterface, IRequest, IUploaderConfigManager, IServerManager } from '../types';
|
|
5
5
|
import Request from '../lib/Request';
|
|
6
6
|
import PluginHandler from '../lib/PluginHandler';
|
|
7
|
+
import { CloudManager } from '../lib/Cloud';
|
|
7
8
|
export declare class PicGo extends EventEmitter implements IPicGo {
|
|
8
9
|
private _config;
|
|
9
10
|
private lifecycle;
|
|
@@ -17,6 +18,8 @@ export declare class PicGo extends EventEmitter implements IPicGo {
|
|
|
17
18
|
output: IImgInfo[];
|
|
18
19
|
input: any[];
|
|
19
20
|
pluginHandler: PluginHandler;
|
|
21
|
+
server: IServerManager;
|
|
22
|
+
cloud: CloudManager;
|
|
20
23
|
uploaderConfig: IUploaderConfigManager;
|
|
21
24
|
/**
|
|
22
25
|
* @deprecated will be removed in v1.5.0+
|
|
@@ -45,5 +48,6 @@ export declare class PicGo extends EventEmitter implements IPicGo {
|
|
|
45
48
|
setConfig(config: IStringKeyMap<any>): void;
|
|
46
49
|
unsetConfig(key: string, propName: string): void;
|
|
47
50
|
get request(): IRequest['request'];
|
|
51
|
+
openUrl(url: string): Promise<void>;
|
|
48
52
|
upload(input?: any[]): Promise<IImgInfo[] | Error>;
|
|
49
53
|
}
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ declare class I18nManager implements II18nManager {
|
|
|
7
7
|
private readonly objectAdapter;
|
|
8
8
|
private readonly ctx;
|
|
9
9
|
constructor(ctx: IPicGo);
|
|
10
|
-
private
|
|
11
|
-
private
|
|
10
|
+
private loadOutsideI18n;
|
|
11
|
+
private getOutsideI18nFolder;
|
|
12
12
|
translate<T extends string>(key: ILocalesKey | T, args?: IStringKeyMap<string>): string;
|
|
13
13
|
setLanguage(language: string): void;
|
|
14
14
|
addLocale(language: string, locales: ILocale): boolean;
|
package/dist/i18n/zh-CN.d.ts
CHANGED
|
@@ -5,6 +5,32 @@ export declare const ZH_CN: {
|
|
|
5
5
|
UPLOAD_FAILED_REASON: string;
|
|
6
6
|
SERVER_ERROR: string;
|
|
7
7
|
AUTH_FAILED: string;
|
|
8
|
+
CLOUD_LOGIN_CANCELLED: string;
|
|
9
|
+
CLOUD_LOGIN_IN_PROGRESS: string;
|
|
10
|
+
CLOUD_LOGIN_INVALID_TOKEN: string;
|
|
11
|
+
CLOUD_LOGIN_SUCCESS: string;
|
|
12
|
+
CLOUD_LOGOUT_SUCCESS: string;
|
|
13
|
+
CLOUD_LOGIN_SERVER_START_FAILED: string;
|
|
14
|
+
CLOUD_LOGIN_OPEN_BROWSER_FAILED: string;
|
|
15
|
+
CLOUD_LOGIN_OPEN_BROWSER_TIP: string;
|
|
16
|
+
CLOUD_LOGIN_STATE_MISMATCH_WARN: string;
|
|
17
|
+
CLOUD_LOGIN_STATE_INVALID: string;
|
|
18
|
+
CLOUD_LOGIN_TOKEN_MISSING: string;
|
|
19
|
+
CLOUD_LOGIN_CODE_MISSING: string;
|
|
20
|
+
CLOUD_LOGIN_EXCHANGE_FAILED: string;
|
|
21
|
+
CLOUD_LOGIN_NOT_IN_PROGRESS: string;
|
|
22
|
+
CLOUD_LOGIN_PAGE_TITLE: string;
|
|
23
|
+
CLOUD_LOGIN_RESULT_SUCCESS_TITLE: string;
|
|
24
|
+
CLOUD_LOGIN_RESULT_FAILED_TITLE: string;
|
|
25
|
+
CLOUD_LOGIN_RESULT_SUCCESS_MESSAGE: string;
|
|
26
|
+
SERVER_INVALID_JSON_BODY: string;
|
|
27
|
+
SERVER_INVALID_REQUEST_BODY_LIST_REQUIRED: string;
|
|
28
|
+
SERVER_FORMDATA_NO_FILES_IN_FILES_FIELD: string;
|
|
29
|
+
SERVER_FORMDATA_FILES_MUST_BE_FILES: string;
|
|
30
|
+
SERVER_AUTH_ENABLED: string;
|
|
31
|
+
SERVER_AUTH_DISABLED_WARNING: string;
|
|
32
|
+
SERVER_AUTH_UNAUTHORIZED_REQUEST: string;
|
|
33
|
+
SERVER_AUTH_QUERY_SECRET_WARNING: string;
|
|
8
34
|
URL_REWRITE_EMPTY_RESULT: string;
|
|
9
35
|
PICBED_SMMS: string;
|
|
10
36
|
PICBED_SMMS_TOKEN: string;
|
|
@@ -93,6 +119,15 @@ export declare const ZH_CN: {
|
|
|
93
119
|
PLUGIN_HANDLER_PLUGIN_UPDATE_FAILED: string;
|
|
94
120
|
PLUGIN_HANDLER_PLUGIN_UPDATE_FAILED_REASON: string;
|
|
95
121
|
PLUGIN_HANDLER_PLUGIN_UPDATE_FAILED_VALID: string;
|
|
122
|
+
CONFIG_SYNC_INVALID_ENCRYPTION_METHOD: string;
|
|
123
|
+
CONFIG_SYNC_ENCRYPTION_METHOD_E2EE: string;
|
|
124
|
+
CONFIG_SYNC_ENCRYPTION_METHOD_SSE: string;
|
|
125
|
+
CONFIG_SYNC_ENCRYPTION_SWITCH_TITLE: string;
|
|
126
|
+
CONFIG_SYNC_ENCRYPTION_SWITCH_BODY: string;
|
|
127
|
+
CONFIG_SYNC_ENCRYPTION_SWITCH_CONFIRM: string;
|
|
128
|
+
CONFIG_SYNC_ENCRYPTION_SWITCH_CANCEL: string;
|
|
129
|
+
CONFIG_SYNC_ENCRYPTION_SWITCH_CANCELLED: string;
|
|
130
|
+
CONFIG_SYNC_ENCRYPTION_SWITCH_MISSING_HANDLER: string;
|
|
96
131
|
};
|
|
97
132
|
export type ILocalesKey = keyof typeof ZH_CN;
|
|
98
133
|
export type ILocales = typeof ZH_CN;
|