comp-hub 0.47.1 → 1.0.3

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/README.md CHANGED
@@ -7,7 +7,7 @@ CLI for comp-hub — a component sharing platform supporting Vue and React. Star
7
7
 
8
8
  > **Languages**: Full docs are also available in [简体中文 · 繁體中文](https://docs.comphub.cn) on our documentation site.
9
9
  >
10
- > **Website:** <https://www.comphub.cn> &nbsp;·&nbsp; **Docs:** <https://docs.comphub.cn>
10
+ > **Website:** <https://www.comphub.cn> &nbsp;·&nbsp; **Studio:** <https://studio.comphub.cn> &nbsp;·&nbsp; **Docs:** <https://docs.comphub.cn>
11
11
 
12
12
  ## Requirements
13
13
 
@@ -74,6 +74,8 @@ comphub -d ./src # Custom component directory
74
74
  | `comphub status` | List all running projects |
75
75
  | `comphub stop <hash>` | Stop a specific project |
76
76
  | `comphub stop --all` | Stop all projects |
77
+ | `comphub login` | Sign in via browser authorization |
78
+ | `comphub logout` | Sign out and remove stored credentials |
77
79
  | `comphub kill` | Shut down all services |
78
80
 
79
81
  Examples:
@@ -124,10 +126,43 @@ module.exports = {
124
126
  |--------|------|---------|-------------|
125
127
  | `dir` | string | `"./"` | Component root directory |
126
128
  | `allowDebug` | boolean | false | Enable debug mode |
127
- | `proxy` | object | — | Custom proxy rules |
129
+ | `proxy` | object | — | Proxy rules for the preview server — see [Proxy rules](#proxy-rules) |
128
130
 
129
131
  **Priority**: CLI flags > config file > defaults
130
132
 
133
+ ### Proxy rules
134
+
135
+ Component demos run inside an iframe and can only talk to the local dev server. `proxy` forwards
136
+ requests matching a path to another server — the same idea as `server.proxy` in Vite or
137
+ `devServer.proxy` in webpack. Use it when a demo needs an API the browser cannot reach directly:
138
+ an internal backend, a third-party API without CORS headers, or another local service.
139
+
140
+ ```json
141
+ {
142
+ "dir": "./src",
143
+ "proxy": {
144
+ "/api": {
145
+ "target": "http://10.0.0.5:8080",
146
+ "changeOrigin": true,
147
+ "pathRewrite": { "^/api": "" }
148
+ }
149
+ }
150
+ }
151
+ ```
152
+
153
+ With the config above, `fetch("/__proxy__/api/users")` inside a component demo is forwarded to
154
+ `http://10.0.0.5:8080/users`.
155
+
156
+ - Request the **absolute** path `/__proxy__/...` from the preview page — the page itself is served
157
+ under `/{hash}/main/`, and the master routes the request back to your project.
158
+ - The key (`/api` above) is matched against the path that follows `/__proxy__` — prefix match, or a
159
+ regular expression.
160
+ - The value is passed straight to [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware);
161
+ `target` is required, everything else is optional.
162
+ - `pathRewrite` is applied after the `/__proxy__` prefix is stripped.
163
+ - Requests matching no rule get `404 {"message":"Proxy not found"}`.
164
+ - Rules are per project: only the project whose `.comphub.json` declares them gets them.
165
+
131
166
  ## Component Specs
132
167
 
133
168
  - Upload components as **folders** — folder name is the component name
@@ -139,6 +174,7 @@ module.exports = {
139
174
  ## Links
140
175
 
141
176
  - Website: <https://www.comphub.cn>
177
+ - Studio (browser-based component workspace): <https://studio.comphub.cn>
142
178
  - Docs (English · 简体中文 · 繁體中文): <https://docs.comphub.cn>
143
179
 
144
180
  ## License