Skip to content

Commit b43f7aa

Browse files
authored
✨ Feature(config): add multi-config support (#188)
1 parent c86b5ca commit b43f7aa

File tree

16 files changed

+2084
-173
lines changed

16 files changed

+2084
-173
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ test.jpg
1010
test.js
1111
specs/
1212
.env
13-
openspec/
13+
openspec/
14+
test*.json
15+
test.md

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Always ask questions before create proposal files if unsure about anything in th
3030
- **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 '...'`).
3131
- Keep TypeScript types explicit; avoid ad-hoc `any` when possible.
3232
- Don't write `as any` in TypeScript code unless absolutely necessary. Always prefer explicit types.
33+
- **Commander actions**: prefer `.action(async (...) => { ... })` and avoid wrapping an IIFE like `.action(() => { (async () => { ... })().catch(...) })`.
34+
- **Commander prompts**: avoid `prompt<any>` / `prompt<IStringKeyMap<any>>`; declare a concrete answer type (e.g. `prompt<{ operation: 'list' | 'rename' }>(...)`).
3335
- **Config persistence**: use `ctx.saveConfig(...)` for changes that must persist to disk; use `ctx.setConfig(...)` only for in-memory/session updates.
3436

3537
## Execution Rules

README.md

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,23 @@ $ picgo -h
6565
Usage: picgo [options] [command]
6666

6767
Options:
68-
69-
-v, --version output the version number
70-
-d, --debug debug mode
71-
-s, --silent silent mode
72-
-c, --config <path> set config path
73-
-h, --help output usage information
68+
-v, --version output the version number
69+
-d, --debug debug mode
70+
-s, --silent silent mode
71+
-c, --config <path> set config path
72+
-p, --proxy <url> set proxy for uploading
73+
-h, --help display help for command
7474

7575
Commands:
76-
77-
install|add <plugins...> install picgo plugin
78-
uninstall|rm <plugins...> uninstall picgo plugin
79-
update <plugins...> update picgo plugin
80-
set <module> [name] configure config of picgo modules
81-
upload|u [input...] upload, go go go
82-
use [module] use modules of picgo
83-
```
84-
85-
Note: the plugin's template initializer has moved to the standalone [picgo-init](https://github.com/PicGo/PicGo-Init) package.
86-
87-
You can use the following command to init a picgo plugin template:
88-
89-
```bash
90-
npx picgo-init plugin <your-plugin-folder>
76+
install|add [options] <plugins...> install picgo plugin
77+
uninstall|rm <plugins...> uninstall picgo plugin
78+
update [options] <plugins...> update picgo plugin
79+
set <module> [name] [configName] configure config of picgo modules (uploader/transformer/plugin)
80+
upload|u [input...] upload, go go go
81+
use [module] [name] [configName] use module (uploader/transformer/plugin) of picgo
82+
i18n [lang] change picgo language
83+
uploader manage uploader configurations
84+
help [command] display help for command
9185
```
9286

9387
#### Upload a picture from path
@@ -106,6 +100,41 @@ picgo upload
106100

107101
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.
108102

103+
#### Manage uploader configs
104+
105+
Since v1.8.0, PicGo-Core supports multiple configurations per uploader. Just like the configuration of Electron version of PicGo.
106+
107+
You can use `picgo set uploader <type> [name] [configName]` to configure different uploader configurations.
108+
109+
And you can use `picgo use uploader <type> [configName]` to switch between different uploader configurations.
110+
111+
For more details, you can use `picgo uploader -h` to check the help of uploader management:
112+
113+
```bash
114+
Usage: picgo uploader [options] [command]
115+
116+
117+
Options:
118+
-h, --help display help for command
119+
120+
Commands:
121+
list [type] list uploader configurations
122+
rename <type> <oldName> <newName> rename a config
123+
copy <type> <configName> <newConfigName> copy a config (does not switch current uploader)
124+
rm <type> <configName> remove a config
125+
```
126+
127+
128+
#### Init a picgo plugin template
129+
130+
Note: the plugin's template initializer has moved to the standalone [picgo-init](https://github.com/PicGo/PicGo-Init) package.
131+
132+
You can use the following command to init a picgo plugin template:
133+
134+
```bash
135+
npx picgo-init plugin <your-plugin-folder>
136+
```
137+
109138
### Use in node project
110139

111140
#### Common JS

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"scripts": {
1515
"start": "node ./bin/picgo",
1616
"lint": "eslint src --ext .ts && tsc --noEmit",
17+
"test:unit": "vitest run",
1718
"build": "cross-env NODE_ENV=production rimraf ./dist && rollup -c rollup.config.js",
1819
"dev": "cross-env NODE_ENV=development rollup -c rollup.config.js -w",
1920
"patch": "npm version patch && git push origin master && git push origin --tags",
@@ -79,11 +80,12 @@
7980
"execa": "^5.1.1",
8081
"globals": "^16.5.0",
8182
"husky": "^9.1.7",
83+
"rimraf": "^6.1.2",
8284
"rollup": "^4.53.3",
8385
"rollup-plugin-copy": "^3.5.0",
8486
"rollup-plugin-string": "^3.0.0",
85-
"rimraf": "^6.1.2",
86-
"typescript": "^5.9.3"
87+
"typescript": "^5.9.3",
88+
"vitest": "^4.0.16"
8789
},
8890
"dependencies": {
8991
"@picgo/i18n": "^1.0.0",

0 commit comments

Comments
 (0)