Skip to content

Commit 71d3861

Browse files
authored
✨ Feature: add picgo server and cloud and config sync (#190)
1 parent 1471e7b commit 71d3861

51 files changed

Lines changed: 5095 additions & 32 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PICGO_API_URL=https://xxx.com
2+
PICGO_CLOUD_URL=https://xxx.com

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Setup Node.js
3232
uses: actions/setup-node@v6
3333
with:
34-
node-version: 20
34+
node-version: 22
3535
registry-url: https://registry.npmjs.org
3636
cache: pnpm
3737

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pnpm lint
1+
pnpm lint

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ eslint.config.js
1515
CHANGELOG.md
1616
.github/
1717
test.js
18+
specs/
19+
dist/__tests__/

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ 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+
- **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.
3334
- **Commander actions**: prefer `.action(async (...) => { ... })` and avoid wrapping an IIFE like `.action(() => { (async () => { ... })().catch(...) })`.
3435
- **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.
3538
- **Config persistence**: use `ctx.saveConfig(...)` for changes that must persist to disk; use `ctx.setConfig(...)` only for in-memory/session updates.
3639

3740
## Execution Rules
3841
- If a command fails due to insufficient permissions, rerun with elevated approval.
3942
- 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.
4044

4145
## Serena MCP & Context7 Tools
4246
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.

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ A tool for picture uploading. Both CLI & api supports. It also supports plugin s
2929

3030
## Installation
3131

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/).
3333

3434
### Global install
3535

@@ -81,6 +81,9 @@ $ picgo -h
8181
use [module] [name] [configName] use module (uploader/transformer/plugin) of picgo
8282
i18n [lang] change picgo language
8383
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
8487
help [command] display help for command
8588
```
8689

@@ -100,6 +103,26 @@ picgo upload
100103

101104
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.
102105

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+
103126
#### Manage uploader configs
104127

105128
Since v1.8.0, PicGo-Core supports multiple configurations per uploader. Just like the configuration of the Electron version of PicGo.

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"scripts": {
1515
"start": "node ./bin/picgo",
16-
"lint": "tsc --noEmit && eslint src --ext .ts",
16+
"lint": "pnpm lint:dpdm && tsc --noEmit && eslint src --ext .ts",
1717
"test": "vitest run",
1818
"build": "cross-env NODE_ENV=production rimraf ./dist && rollup -c rollup.config.js",
1919
"dev": "cross-env NODE_ENV=development rollup -c rollup.config.js -w",
@@ -23,7 +23,8 @@
2323
"cz": "git-cz",
2424
"release": "bump-version",
2525
"prepare": "husky",
26-
"commitlint": "commitlint --edit"
26+
"commitlint": "commitlint --edit",
27+
"lint:dpdm": "dpdm -T --tsconfig ./tsconfig.json --no-tree --no-warning --exit-code circular:1 src/index.ts"
2728
},
2829
"keywords": [
2930
"picture",
@@ -74,6 +75,7 @@
7475
"copyfiles": "^2.1.0",
7576
"cross-env": "^7.0.3",
7677
"cz-customizable": "^7.5.1",
78+
"dpdm": "^3.14.0",
7779
"eslint": "^9.39.1",
7880
"eslint-config-prettier": "^10.1.8",
7981
"eslint-plugin-import": "^2.32.0",
@@ -89,6 +91,7 @@
8991
"vitest": "^4.0.16"
9092
},
9193
"dependencies": {
94+
"@hono/node-server": "^1.19.7",
9295
"@picgo/i18n": "^1.0.0",
9396
"@picgo/store": "^2.0.2",
9497
"axios": "^1.13.2",
@@ -97,8 +100,13 @@
97100
"comment-json": "^4.5.1",
98101
"cross-spawn": "^6.0.5",
99102
"dayjs": "^1.7.4",
103+
"dotenv": "^17.2.3",
104+
"ejs": "^3.1.10",
100105
"form-data": "^4.0.5",
101106
"fs-extra": "^6.0.1",
107+
"giget": "^2.0.0",
108+
"globby": "^11.0.4",
109+
"hono": "^4.11.3",
102110
"image-size": "^0.8.3",
103111
"inquirer": "^6.0.0",
104112
"is-wsl": "^2.2.0",
@@ -107,6 +115,7 @@
107115
"md5": "^2.2.1",
108116
"mime-types": "3.0.2",
109117
"minimist": "^1.2.5",
118+
"open": "^11.0.0",
110119
"resolve": "^1.8.1",
111120
"tunnel": "^0.0.6"
112121
},
@@ -119,6 +128,6 @@
119128
},
120129
"plugins": {},
121130
"engines": {
122-
"node": ">= 22.12.0"
131+
"node": ">= 20.19.0"
123132
}
124133
}

0 commit comments

Comments
 (0)