picgo 2.0.3 → 3.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.
Files changed (54) hide show
  1. package/AGENTS.md +4 -1
  2. package/CLAUDE.md +1 -0
  3. package/CONTEXT.md +53 -0
  4. package/README.md +57 -2
  5. package/dist/core/Lifecycle.d.ts +4 -2
  6. package/dist/core/PicGo.d.ts +2 -2
  7. package/dist/i18n/ja.d.ts +2 -0
  8. package/dist/i18n/ko.d.ts +2 -0
  9. package/dist/i18n/zh-CN.d.ts +62 -0
  10. package/dist/index.cjs.js +1 -1
  11. package/dist/index.cjs.js.map +1 -1
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.esm.js +1 -1
  14. package/dist/index.esm.js.map +1 -1
  15. package/dist/lib/Cloud/ApiErrorCode.d.ts +11 -0
  16. package/dist/lib/Cloud/Request.d.ts +29 -1
  17. package/dist/lib/Cloud/__mocks__/lifecycleScenarios.d.ts +16 -0
  18. package/dist/lib/Cloud/index.d.ts +17 -4
  19. package/dist/lib/Cloud/services/AlbumService.d.ts +39 -0
  20. package/dist/lib/Cloud/services/BillingService.d.ts +9 -0
  21. package/dist/lib/Cloud/services/FileService.d.ts +20 -0
  22. package/dist/lib/Cloud/services/UserService.d.ts +3 -4
  23. package/dist/lib/Cloud/services/multipart/MultipartStorage.d.ts +37 -0
  24. package/dist/lib/Cloud/services/multipart/MultipartUploadService.d.ts +49 -0
  25. package/dist/lib/Cloud/utils.d.ts +8 -1
  26. package/dist/lib/Logger.d.ts +28 -1
  27. package/dist/lib/Server/index.d.ts +3 -0
  28. package/dist/lib/Server/routes.d.ts +3 -1
  29. package/dist/plugins/commander/cloud/actions/configSync.d.ts +7 -0
  30. package/dist/plugins/commander/cloud/actions/index.d.ts +3 -0
  31. package/dist/plugins/commander/cloud/actions/login.d.ts +2 -0
  32. package/dist/plugins/commander/cloud/actions/logout.d.ts +2 -0
  33. package/dist/plugins/commander/cloud/delete.d.ts +4 -0
  34. package/dist/plugins/commander/cloud/get.d.ts +4 -0
  35. package/dist/plugins/commander/cloud/import.d.ts +13 -0
  36. package/dist/plugins/commander/cloud/index.d.ts +3 -0
  37. package/dist/plugins/commander/cloud/list.d.ts +18 -0
  38. package/dist/plugins/commander/cloud/retry.d.ts +4 -0
  39. package/dist/plugins/commander/cloud/shared.d.ts +16 -0
  40. package/dist/plugins/commander/cloud/status.d.ts +16 -0
  41. package/dist/plugins/commander/cloud/update.d.ts +4 -0
  42. package/dist/plugins/commander/get.d.ts +16 -0
  43. package/dist/plugins/commander/upload.d.ts +1 -1
  44. package/dist/plugins/commander/utils/progressRenderer.d.ts +31 -0
  45. package/dist/plugins/uploader/picgoCloud.d.ts +3 -0
  46. package/dist/types/index.d.ts +351 -5
  47. package/dist/types/internal.d.ts +8 -2
  48. package/dist/utils/enum.d.ts +13 -1
  49. package/dist/utils/interfaces.d.ts +23 -1
  50. package/dist/utils/pluginConfig.d.ts +50 -0
  51. package/dist/utils/progressBar.d.ts +11 -0
  52. package/dist/utils/static.d.ts +18 -0
  53. package/dist/utils/uploadWithProgress.d.ts +39 -0
  54. package/package.json +5 -3
package/AGENTS.md CHANGED
@@ -28,12 +28,15 @@ Always ask questions before create proposal files if unsure about anything in th
28
28
 
29
29
  ## Code Conventions
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
- - Keep TypeScript types explicit; avoid ad-hoc `any` when possible.
31
+ - Keep TypeScript types explicit; avoid ad-hoc `any` when possible. Interface names do not require an `I` prefix.
32
32
  - Don't write `as any` in TypeScript code unless absolutely necessary. Always prefer explicit types.
33
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.
34
34
  - **Commander actions**: prefer `.action(async (...) => { ... })` and avoid wrapping an IIFE like `.action(() => { (async () => { ... })().catch(...) })`.
35
+ - **No `void` fire-and-forget calls**: do not write `void someAsyncCall()` / `void somePromise.then(...)`. If a task is intentionally not awaited, keep the returned promise in a variable and attach explicit handling without using the `void` operator.
36
+ - **Cloud service error handling**: in service-layer code, never branch on `error.message` to decide behavior. Use HTTP status and backend error `code` instead, using specific `ApiErrorCode` values actually needed by PicGo-Core.
35
37
  - **Commander prompts**: avoid `prompt<any>` / `prompt<IStringKeyMap<any>>`; declare a concrete answer type (e.g. `prompt<{ operation: 'list' | 'rename' }>(...)`).
36
38
  - **Commander option descriptions**: for CLI options, use plain strings without i18n keys unless explicitly requested.
39
+ - **Commander alias/shortcut hints**: when a command is an alias or shortcut for another, include the relationship in the `.description()` string. For top-level shortcuts, use `(shortcut for cloud xxx)`; for canonical commands that have a shortcut, use `(alias: picgo xxx)`. Always put the simpler/shorter form first when listing alternatives in i18n strings or descriptions.
37
40
  - **TypeScript enums**: when representing a fixed set of values, prefer `enum` over union string literal types unless explicitly requested otherwise.
38
41
  - **Config persistence**: use `ctx.saveConfig(...)` for changes that must persist to disk; use `ctx.setConfig(...)` only for in-memory/session updates.
39
42
 
package/CLAUDE.md ADDED
@@ -0,0 +1 @@
1
+ @AGENTS.md
package/CONTEXT.md ADDED
@@ -0,0 +1,53 @@
1
+ # PicGo-Core
2
+
3
+ Headless image-upload runtime shared between the PicGo CLI and the PicGo GUI. Owns the plugin loader, config schema, uploader/transformer registry, and lifecycle hooks.
4
+
5
+ ## Language
6
+
7
+ **Plugin Config Schema**:
8
+ The array of field descriptors a plugin returns from `config(ctx)` — the contract that drives both inquirer prompts in CLI and the rendered form in GUI.
9
+ _Avoid_: "form schema" (too generic), "prompts" (CLI-only flavor)
10
+
11
+ **Plugin Config Field**:
12
+ One descriptor in the Plugin Config Schema (`IPluginConfig`), identified by its `name`. Has a `type`, optional `choices`, `default`, and `dependsOn`.
13
+ _Avoid_: "prompt", "form field" (use the canonical term)
14
+
15
+ Known `type` values (the `type` slot stays `string` to remain forward-compatible with unlisted inquirer-supported values, but PicGo guarantees behavior only for these):
16
+
17
+ - `'input'` — single-line text. CLI: inquirer text prompt; GUI: text input.
18
+ - `'password'` — single-line text rendered masked. CLI: inquirer password prompt; GUI: masked input with show/hide toggle.
19
+ - `'list'` — pick one from `choices`. CLI: inquirer list prompt; GUI: single-select dropdown.
20
+ - `'checkbox'` — pick many from `choices`. CLI: inquirer checkbox prompt; GUI: multi-select combobox.
21
+ - `'confirm'` — boolean. CLI: inquirer confirm prompt; GUI: switch.
22
+ - `'editor'` — multi-line text (3.0.0+). Value is `string`, MAY contain `\n`. CLI: inquirer editor prompt — spawns the user's external editor (`VISUAL` / `EDITOR` env vars; falls back to `vi` / `nano` on Unix, `notepad` on Windows); GUI: shadcn `<Textarea>` with `resize-y` handle.
23
+
24
+ **dependsOn**:
25
+ Optional `string[]` on a Plugin Config Field listing the `name`s of other fields whose value changes should cause this field's `choices`/`default` to be re-evaluated. Opt-in; absence means the field is static.
26
+ _Avoid_: "refreshOn", "watch", "deps"
27
+
28
+ **Reactive Field**:
29
+ A Plugin Config Field that declares `dependsOn` — its `choices` and/or `default` are expected to be functions and will be re-evaluated against the latest draft values.
30
+ _Avoid_: "dynamic field", "live field"
31
+
32
+ **Draft Values**:
33
+ A snapshot of all field values currently displayed in the GUI plugin-config form — initialized from stored config plus schema defaults at form open, then layered with the user's unsaved edits. Passed verbatim as the `answers` argument to reactive `choices(answers)`/`default(answers)`. In CLI, the analogous concept is inquirer's accumulated `answers`.
34
+ _Avoid_: "form state", "pending config", "draft only" (the snapshot is not just user edits — it includes stored values for untouched fields)
35
+
36
+ **handleConfigWithFunction**:
37
+ The serialization step (lives in PicGo GUI's main process today) that resolves function-typed `choices`/`default` in a Plugin Config Schema before sending it over IPC to the renderer.
38
+
39
+ ## Relationships
40
+
41
+ - A **Plugin Config Schema** contains one or more **Plugin Config Fields**.
42
+ - A **Plugin Config Field** with **dependsOn** is a **Reactive Field**.
43
+ - **Reactive Fields** are re-evaluated by passing the current **Draft Values** as `answers` to their `choices`/`default` functions.
44
+ - In CLI, inquirer drives Reactive Fields directly via accumulated `answers`; in GUI, **handleConfigWithFunction** is invoked again with Draft Values and produces a fresh Plugin Config Schema for the renderer.
45
+
46
+ ## Example dialogue
47
+
48
+ > **Plugin author:** "I want the second dropdown's options to depend on the first dropdown."
49
+ > **Maintainer:** "Add `dependsOn: ['firstField']` to the second **Plugin Config Field** and make its `choices` a function. CLI works automatically via inquirer; GUI will pass **Draft Values** as `answers` whenever `firstField` changes."
50
+
51
+ ## Flagged ambiguities
52
+
53
+ - "config" was overloaded between the saved persisted config (`ctx.getConfig()`) and the in-progress GUI form values — resolved: the latter is **Draft Values**; the former remains "stored config".
package/README.md CHANGED
@@ -81,11 +81,13 @@ $ picgo -h
81
81
  set <module> [name] [configName] configure config of picgo modules (uploader/transformer/plugin)
82
82
  upload|u [input...] upload, go go go
83
83
  use [module] [name] [configName] use module (uploader/transformer/plugin) of picgo
84
+ get get current picgo module config (uploader/transformer/plugins)
84
85
  i18n [lang] change picgo language
85
86
  uploader manage uploader configurations
86
87
  server [options] run PicGo as a standalone server
87
88
  login [token] login to cloud.picgo.app
88
89
  logout logout from cloud.picgo.app
90
+ cloud manage PicGo Cloud
89
91
  help [command] display help for command
90
92
  ```
91
93
 
@@ -111,7 +113,7 @@ Thanks to [vs-picgo](https://github.com/Spades-S/vs-picgo) && [Spades-S](https:/
111
113
  picgo server -p 36677 -h 127.0.0.1
112
114
  ```
113
115
 
114
- #### Login to PicGo Cloud
116
+ #### Login to [PicGo Cloud](https://cloud.picgo.app)
115
117
 
116
118
  ```bash
117
119
  picgo login
@@ -119,12 +121,65 @@ picgo login
119
121
  picgo login <token>
120
122
  ```
121
123
 
122
- #### Logout from PicGo Cloud
124
+ #### Logout from [PicGo Cloud](https://cloud.picgo.app)
123
125
 
124
126
  ```bash
125
127
  picgo logout
126
128
  ```
127
129
 
130
+ #### Check PicGo Cloud login status
131
+
132
+ Use `picgo cloud auth status` to inspect the current PicGo Cloud login state without triggering an interactive login. The check is non-blocking: when there is no local token it returns immediately without any network request.
133
+
134
+ ```bash
135
+ picgo cloud auth status
136
+
137
+ # machine-readable output
138
+ picgo cloud auth status --format json
139
+ ```
140
+
141
+ The command sets a process exit code so it can be used in scripts:
142
+
143
+ | Status | Meaning | Exit code |
144
+ | ------------- | ------------------------------------------------ | --------- |
145
+ | `logged_in` | Token is valid | `0` |
146
+ | `logged_out` | No local token | `1` |
147
+ | `invalid` | Token exists but is rejected by the server (401) | `2` |
148
+ | `error` | Probe failed (network / server error) | `3` |
149
+
150
+ The `--format json` output is a single line, e.g.:
151
+
152
+ ```json
153
+ {"status":"logged_in","loggedIn":true,"user":"someone","plan":1}
154
+ ```
155
+
156
+ #### Inspect current module config
157
+
158
+ Use `picgo get` to read the currently selected picgo modules. Each subcommand supports `--format pretty|json` (defaults to `pretty`).
159
+
160
+ ```bash
161
+ # current uploader type (resolved as picBed.uploader -> picBed.current -> picgo-cloud)
162
+ picgo get uploader
163
+
164
+ # current transformer (defaults to path)
165
+ picgo get transformer
166
+
167
+ # installed plugins with enabled/disabled state
168
+ picgo get plugins
169
+
170
+ # machine-readable output
171
+ picgo get uploader --format json
172
+ picgo get plugins --format json
173
+ ```
174
+
175
+ In `json` mode each command prints a single parseable line, e.g.:
176
+
177
+ ```json
178
+ {"uploader":"github"}
179
+ {"transformer":"path"}
180
+ {"plugins":[{"name":"picgo-plugin-xxx","enabled":true}]}
181
+ ```
182
+
128
183
  #### Manage uploader configs
129
184
 
130
185
  Since v1.8.0, PicGo-Core supports multiple configurations per uploader. Just like the configuration of the Electron version of PicGo.
@@ -1,14 +1,16 @@
1
1
  import { EventEmitter } from 'events';
2
- import { IPicGo } from '../types';
2
+ import { IPicGo, UploadOptions } from '../types';
3
3
  export declare class Lifecycle extends EventEmitter {
4
4
  private readonly ctx;
5
+ private step;
5
6
  constructor(ctx: IPicGo);
6
- start(input: any[]): Promise<IPicGo>;
7
+ start(input: any[], options?: UploadOptions): Promise<IPicGo>;
7
8
  private beforeTransform;
8
9
  private doTransform;
9
10
  private beforeUpload;
10
11
  private doUpload;
11
12
  private afterUpload;
13
+ private buildSuccessMessage;
12
14
  private handlePlugins;
13
15
  }
14
16
  export default Lifecycle;
@@ -1,7 +1,7 @@
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, IServerManager } from '../types';
4
+ import { IHelper, IImgInfo, IPicGo, IStringKeyMap, IPluginLoader, II18nManager, IPicGoPlugin, IPicGoPluginInterface, IRequest, IUploaderConfigManager, IServerManager, UploadOptions } from '../types';
5
5
  import Request from '../lib/Request';
6
6
  import PluginHandler from '../lib/PluginHandler';
7
7
  import { CloudManager } from '../lib/Cloud';
@@ -49,5 +49,5 @@ export declare class PicGo extends EventEmitter implements IPicGo {
49
49
  unsetConfig(key: string, propName: string): void;
50
50
  get request(): IRequest['request'];
51
51
  openUrl(url: string): Promise<void>;
52
- upload(input?: any[]): Promise<IImgInfo[] | Error>;
52
+ upload(input?: any[], options?: UploadOptions): Promise<IImgInfo[] | Error>;
53
53
  }
@@ -0,0 +1,2 @@
1
+ import { ILocales } from './zh-CN';
2
+ export declare const JA: ILocales;
@@ -0,0 +1,2 @@
1
+ import { ILocales } from './zh-CN';
2
+ export declare const KO: ILocales;
@@ -23,6 +23,68 @@ export declare const ZH_CN: {
23
23
  CLOUD_LOGIN_RESULT_SUCCESS_TITLE: string;
24
24
  CLOUD_LOGIN_RESULT_FAILED_TITLE: string;
25
25
  CLOUD_LOGIN_RESULT_SUCCESS_MESSAGE: string;
26
+ PICGO_CLOUD_UPLOAD_LOGIN_REQUIRED: string;
27
+ PICGO_CLOUD_UPLOAD_RELOGIN_REQUIRED: string;
28
+ PICGO_CLOUD_UPLOAD_INVALID_PRESIGN_RESPONSE: string;
29
+ PICGO_CLOUD_UPLOAD_INVALID_COMPLETE_RESPONSE: string;
30
+ PICGO_CLOUD_UPLOAD_MISSING_FILE_NAME: string;
31
+ PICGO_CLOUD_UPLOAD_MISSING_FILE_DATA: string;
32
+ PICGO_CLOUD_UPLOAD_INVALID_INITIATE_RESPONSE: string;
33
+ PICGO_CLOUD_UPLOAD_MULTIPART_NOT_FOUND: string;
34
+ PICGO_CLOUD_UPLOAD_MULTIPART_PART_FAILED: string;
35
+ PICGO_CLOUD_UPLOAD_MULTIPART_COMPLETE_FAILED: string;
36
+ PICGO_CLOUD_UPLOAD_PROGRESS_BAR: string;
37
+ PICGO_CLOUD_UPLOAD_VERBOSE: string;
38
+ PICGO_CLOUD_UPLOAD_RESUMED_SUFFIX: string;
39
+ CLOUD_ALBUM_PENDING_INVALID_FILE: string;
40
+ CLOUD_ALBUM_IMPORT_AUTO_IMPORT_DISABLED: string;
41
+ CLOUD_ALBUM_IMPORT_PLAN_REQUIRED: string;
42
+ CLOUD_ALBUM_AUTO_IMPORT_PENDING_WARNING: string;
43
+ CLOUD_COMMAND_LOGIN_REQUIRED: string;
44
+ CLOUD_COMMAND_LOGIN_HINT: string;
45
+ CLOUD_AUTH_STATUS_LOGGED_IN: string;
46
+ CLOUD_AUTH_STATUS_LOGGED_OUT: string;
47
+ CLOUD_AUTH_STATUS_INVALID: string;
48
+ CLOUD_AUTH_STATUS_ERROR: string;
49
+ GET_PLUGINS_EMPTY: string;
50
+ CLOUD_ALBUM_IMPORT_PROMPT_ENABLE_AUTO_IMPORT: string;
51
+ CLOUD_ALBUM_IMPORT_ENABLING_AUTO_IMPORT: string;
52
+ CLOUD_ALBUM_IMPORT_AUTO_IMPORT_ENABLED: string;
53
+ CLOUD_ALBUM_IMPORT_DUPLICATE_ID: string;
54
+ CLOUD_ALBUM_IMPORT_PROGRESS_BAR: string;
55
+ CLOUD_ALBUM_IMPORT_VERBOSE_BATCH: string;
56
+ CLOUD_ALBUM_IMPORT_SUMMARY_TITLE: string;
57
+ CLOUD_ALBUM_IMPORT_SUMMARY_TOTAL: string;
58
+ CLOUD_ALBUM_IMPORT_SUMMARY_CREATED: string;
59
+ CLOUD_ALBUM_IMPORT_SUMMARY_SKIPPED: string;
60
+ CLOUD_ALBUM_IMPORT_SUMMARY_INVALID: string;
61
+ CLOUD_ALBUM_IMPORT_SUMMARY_FAILED: string;
62
+ CLOUD_ALBUM_IMPORT_SUMMARY_PENDING: string;
63
+ CLOUD_ALBUM_IMPORT_RETRY_HINT: string;
64
+ CLOUD_ALBUM_IMPORT_NO_PENDING: string;
65
+ CLOUD_ALBUM_LIST_LOADING: string;
66
+ CLOUD_ALBUM_LIST_DONE: string;
67
+ CLOUD_ALBUM_GET_LOADING: string;
68
+ CLOUD_ALBUM_GET_DONE: string;
69
+ CLOUD_ALBUM_UPDATE_LOADING: string;
70
+ CLOUD_ALBUM_UPDATE_DONE: string;
71
+ CLOUD_ALBUM_DELETE_LOADING: string;
72
+ CLOUD_ALBUM_DELETE_DONE: string;
73
+ CLOUD_ALBUM_DELETE_CONFIRM: string;
74
+ CLOUD_ALBUM_IMPORT_SOURCE_REQUIRED: string;
75
+ CLOUD_ALBUM_IMPORT_SOURCE_CONFLICT: string;
76
+ CLOUD_ALBUM_IMPORT_INVALID_JSON: string;
77
+ CLOUD_ALBUM_IMPORT_INVALID_JSON_FILE: string;
78
+ CLOUD_ALBUM_IMPORT_LOADING_SOURCE: string;
79
+ CLOUD_ALBUM_IMPORT_LOADING_SOURCE_DONE: string;
80
+ CLOUD_ALBUM_IMPORT_CHECKING_AUTO_IMPORT: string;
81
+ CLOUD_ALBUM_IMPORT_CHECKING_AUTO_IMPORT_DONE: string;
82
+ CLOUD_ALBUM_IMPORT_UPLOADING: string;
83
+ CLOUD_ALBUM_IMPORT_UPLOADING_DONE: string;
84
+ CLOUD_ALBUM_RETRY_LOADING_PENDING: string;
85
+ CLOUD_ALBUM_RETRY_LOADING_PENDING_DONE: string;
86
+ CLOUD_ALBUM_RETRY_UPLOADING: string;
87
+ CLOUD_ALBUM_RETRY_UPLOADING_DONE: string;
26
88
  SERVER_INVALID_JSON_BODY: string;
27
89
  SERVER_INVALID_REQUEST_BODY_LIST_REQUIRED: string;
28
90
  SERVER_FORMDATA_NO_FILES_IN_FILES_FIELD: string;