picgo 1.8.0 → 2.0.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 (43) hide show
  1. package/.env.example +2 -0
  2. package/AGENTS.md +4 -0
  3. package/README.md +35 -4
  4. package/dist/core/PicGo.d.ts +5 -1
  5. package/dist/i18n/index.d.ts +2 -2
  6. package/dist/i18n/zh-CN.d.ts +36 -0
  7. package/dist/index.cjs.js +1 -1
  8. package/dist/index.cjs.js.map +1 -1
  9. package/dist/index.d.ts +33 -1
  10. package/dist/index.esm.js +1 -1
  11. package/dist/index.esm.js.map +1 -1
  12. package/dist/lib/Cloud/Auth.d.ts +15 -0
  13. package/dist/lib/Cloud/Request.d.ts +12 -0
  14. package/dist/lib/Cloud/index.d.ts +15 -0
  15. package/dist/lib/Cloud/services/ConfigService.d.ts +15 -0
  16. package/dist/lib/Cloud/services/UserService.d.ts +12 -0
  17. package/dist/lib/Cloud/utils.d.ts +15 -0
  18. package/dist/lib/ConfigSyncManager/E2ECryptoService.d.ts +24 -0
  19. package/dist/lib/ConfigSyncManager/Merger.d.ts +4 -0
  20. package/dist/lib/ConfigSyncManager/errors.d.ts +29 -0
  21. package/dist/lib/ConfigSyncManager/index.d.ts +39 -0
  22. package/dist/lib/ConfigSyncManager/types.d.ts +87 -0
  23. package/dist/lib/ConfigSyncManager/utils.d.ts +41 -0
  24. package/dist/lib/Routes/routePath.d.ts +6 -0
  25. package/dist/lib/Server/index.d.ts +39 -0
  26. package/dist/lib/Server/routes.d.ts +4 -0
  27. package/dist/lib/Server/utils.d.ts +10 -0
  28. package/dist/lib/utils.d.ts +2 -0
  29. package/dist/plugins/commander/config.d.ts +2 -2
  30. package/dist/plugins/commander/configPath.d.ts +3 -0
  31. package/dist/plugins/commander/index.d.ts +2 -2
  32. package/dist/plugins/commander/login.d.ts +3 -0
  33. package/dist/plugins/commander/logout.d.ts +3 -0
  34. package/dist/plugins/commander/server.d.ts +3 -0
  35. package/dist/plugins/commander/setting.d.ts +2 -2
  36. package/dist/plugins/commander/utils.d.ts +10 -0
  37. package/dist/types/index.d.ts +86 -2
  38. package/dist/types/internal.d.ts +8 -0
  39. package/dist/utils/common.d.ts +2 -3
  40. package/dist/utils/urlRewrite.d.ts +15 -0
  41. package/package.json +15 -5
  42. package/vitest.config.ts +9 -0
  43. package/dist/__tests__/unit/uploaderConfigManager.spec.d.ts +0 -1
package/.env.example ADDED
@@ -0,0 +1,2 @@
1
+ PICGO_API_URL=https://xxx.com
2
+ PICGO_CLOUD_URL=https://xxx.com
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
@@ -29,7 +29,7 @@ A tool for picture uploading. Both CLI & api supports. It also supports plugin s
29
29
 
30
30
  ## Installation
31
31
 
32
- PicGo should be installed with node.js >= 16 (v1.5.0-alpha.5 and small) & node.js >= 20 (since v1.6.0).
32
+ 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
33
 
34
34
  ### Global install
35
35
 
@@ -81,6 +81,9 @@ $ picgo -h
81
81
  use [module] [name] [configName] use module (uploader/transformer/plugin) of picgo
82
82
  i18n [lang] change picgo language
83
83
  uploader manage uploader configurations
84
+ server [options] run PicGo as a standalone server
85
+ login [token] login to cloud.picgo.app
86
+ logout logout from cloud.picgo.app
84
87
  help [command] display help for command
85
88
  ```
86
89
 
@@ -100,14 +103,42 @@ picgo upload
100
103
 
101
104
  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
105
 
106
+ #### Run as a server
107
+
108
+ ```bash
109
+ picgo server -p 36677 -h 127.0.0.1
110
+ ```
111
+
112
+ #### Login to PicGo Cloud
113
+
114
+ ```bash
115
+ picgo login
116
+ # or
117
+ picgo login <token>
118
+ ```
119
+
120
+ #### Logout from PicGo Cloud
121
+
122
+ ```bash
123
+ picgo logout
124
+ ```
125
+
103
126
  #### Manage uploader configs
104
127
 
105
- Since v1.8.0, PicGo-Core supports multiple configurations per uploader. Just like the configuration of Electron version of PicGo.
128
+ Since v1.8.0, PicGo-Core supports multiple configurations per uploader. Just like the configuration of the Electron version of PicGo.
106
129
 
107
- You can use `picgo set uploader <type> [name] [configName]` to configure different uploader configurations.
130
+ You can use `picgo set uploader <type> [configName]` to configure different uploader configurations.
108
131
 
109
132
  And you can use `picgo use uploader <type> [configName]` to switch between different uploader configurations.
110
133
 
134
+ For example:
135
+
136
+ ```bash
137
+ picgo set uploader github Test
138
+
139
+ picgo use uploader github Test
140
+ ```
141
+
111
142
  For more details, you can use `picgo uploader -h` to check the help of uploader management:
112
143
 
113
144
  ```bash
@@ -163,4 +194,4 @@ picgo.upload()
163
194
 
164
195
  ## Documentation
165
196
 
166
- For more details, you can checkout [documentation](https://picgo.github.io/PicGo-Core-Doc/).
197
+ For more details, you can checkout [documentation](https://docs.picgo.app/core/).
@@ -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
  }
@@ -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 loadOutterI18n;
11
- private getOutterI18nFolder;
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;
@@ -5,6 +5,33 @@ 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;
34
+ URL_REWRITE_EMPTY_RESULT: string;
8
35
  PICBED_SMMS: string;
9
36
  PICBED_SMMS_TOKEN: string;
10
37
  PICBED_SMMS_BACKUP_DOMAIN: string;
@@ -92,6 +119,15 @@ export declare const ZH_CN: {
92
119
  PLUGIN_HANDLER_PLUGIN_UPDATE_FAILED: string;
93
120
  PLUGIN_HANDLER_PLUGIN_UPDATE_FAILED_REASON: string;
94
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;
95
131
  };
96
132
  export type ILocalesKey = keyof typeof ZH_CN;
97
133
  export type ILocales = typeof ZH_CN;