|
1 | | -# Online Dev Tools (pnpm monorepo) |
| 1 | +# CodeExpander Plugins |
| 2 | + |
| 3 | +[English](./README.md) | [简体中文](./README.zh-CN.md) |
2 | 4 |
|
3 | 5 | Monorepo of **CodeExpander plugins**, managed with pnpm workspaces. |
4 | 6 |
|
5 | 7 | ## Structure |
6 | 8 |
|
7 | 9 | - **packages/ui** — Shared Tailwind + shadcn-style UI components used by plugins. |
8 | 10 | - **packages/i18n** — Minimal i18n helpers (`getLocale`, `t`) for plugin locales. |
9 | | -- **packages/plugin-text** … **packages/plugin-ai** — CodeExpander plugin packages (one per category). Each builds to a `dist/` folder with `plugin.json` + `index.html` + assets. |
| 11 | +- **packages/plugin-text** … **packages/plugin-ai** — CodeExpander plugin packages (one per category). Each builds to a `dist/` folder with `plugin.json`, `index.html`, and assets. |
10 | 12 |
|
11 | 13 | ## Commands |
12 | 14 |
|
13 | | -- `pnpm install` — Install all workspace dependencies. |
14 | | -- `pnpm run dev` — Start the plugin-text dev server. **`make dev`** — CLI 选择要开发的插件后启动对应 dev server;或 `make dev PLUGIN=plugin-html` 直接指定。 |
15 | | -- `pnpm run build` — Build all plugin packages. |
16 | | -- Build a single plugin: `pnpm --filter @codeexpander/plugin-text run build`. |
17 | | -- Build all plugins only: `pnpm run build:plugins`(或 `pnpm --filter './packages/plugin-*' run build`)。 |
18 | | -- **一键发布所有插件到 npm**:`pnpm run publish:plugins`(先构建再按序发布 11 个包,包名为 `@codeexpander/plugin-xxx`)。 |
19 | | - |
20 | | ---- |
| 15 | +| Command | Description | |
| 16 | +|--------|-------------| |
| 17 | +| `pnpm install` | Install all workspace dependencies. | |
| 18 | +| `pnpm run dev` | Start the default plugin dev server. Use **`make dev`** to pick a plugin interactively, or `make dev PLUGIN=plugin-html` to specify one. | |
| 19 | +| `pnpm run build` | Build all packages. | |
| 20 | +| `pnpm --filter @codeexpander/plugin-text run build` | Build a single plugin. | |
| 21 | +| `pnpm run build:plugins` | Build all plugin packages only (`pnpm --filter './packages/plugin-*' run build`). | |
| 22 | +| `pnpm run publish:plugins` | Build and publish all plugins to npm in sequence (package names: `@codeexpander/plugin-*`). | |
21 | 23 |
|
22 | | -## 一键发布插件 / One-click plugin publish |
| 24 | +## One-Click Plugin Publish |
23 | 25 |
|
24 | | -插件包名已统一为 **`@codeexpander/plugin-*`**(如 `@codeexpander/plugin-text`),发布到 npm 后可通过 CodeExpander 的 npm 安装方式使用。 |
| 26 | +Plugin packages use the **`@codeexpander/plugin-*`** scope (e.g. `@codeexpander/plugin-text`). After publishing to npm, they can be installed via CodeExpander’s npm install flow. |
25 | 27 |
|
26 | | -**发布前准备** |
| 28 | +**Before publishing** |
27 | 29 |
|
28 | | -1. 登录 npm:`npm login`(需有 `@codeexpander` 组织权限或使用个人 scope)。 |
29 | | -2. 可选:统一改版本号(如 `0.1.0` → `0.2.0`): |
| 30 | +1. Log in to npm: `npm login` (requires `@codeexpander` org access or your own scope). |
| 31 | +2. Optional — bump versions (e.g. `0.1.0` → `0.2.0`): |
30 | 32 | ```bash |
31 | 33 | pnpm --filter './packages/plugin-*' exec -- npm version patch --no-git-tag-version |
32 | 34 | ``` |
33 | 35 |
|
34 | | -**执行发布** |
| 36 | +**Publish** |
35 | 37 |
|
36 | 38 | ```bash |
37 | 39 | pnpm run publish:plugins |
38 | 40 | ``` |
39 | 41 |
|
40 | | -该命令会依次:构建所有插件(`build:plugins`)→ 对每个插件执行 `pnpm publish -r`(`--no-git-checks` 跳过 git 检查)。发布内容为各包的 `dist/` 目录(含 `plugin.json`、`index.html`、assets)。 |
| 42 | +This will: build all plugins (`build:plugins`), then run `pnpm publish` for each plugin (with `--no-git-checks`). Published content is each package’s `dist/` (including `plugin.json`, `index.html`, and assets). |
41 | 43 |
|
42 | | -若只发布单个插件,可先构建再进入该包目录执行 `pnpm publish`: |
| 44 | +To publish a single plugin: |
43 | 45 |
|
44 | 46 | ```bash |
45 | 47 | pnpm --filter @codeexpander/plugin-text run build |
46 | 48 | cd packages/plugin-text && pnpm publish --no-git-checks |
47 | 49 | ``` |
48 | 50 |
|
49 | | ---- |
50 | | - |
51 | | -## 如何验证开发插件 / How to verify plugin development |
| 51 | +## Verifying Plugin Development |
52 | 52 |
|
53 | | -### 方式一:本地开发(不依赖 CodeExpander) |
| 53 | +### Option 1: Local dev (no CodeExpander) |
54 | 54 |
|
55 | | -在浏览器里直接跑插件的 UI,改代码会热更新,适合改界面、加功能。复制/Toast 在无 host 时会走 fallback(如 `navigator.clipboard`)。 |
| 55 | +Run the plugin UI in the browser with hot reload. Copy/Toast use fallbacks (e.g. `navigator.clipboard`) when not running inside CodeExpander. |
56 | 56 |
|
57 | 57 | ```bash |
58 | | -# 进入某个插件目录并启动 Vite 开发服务器 |
59 | 58 | cd packages/plugin-text && pnpm run dev |
60 | | -# 或从仓库根目录指定插件 |
| 59 | +# or from repo root: |
61 | 60 | pnpm --filter @codeexpander/plugin-text run dev |
62 | 61 | ``` |
63 | 62 |
|
64 | | -浏览器打开终端里提示的地址(如 `http://localhost:5173`),即可看到该插件的**多 Tab 工具界面**(无「Back to Tools」等外壳,仅插件内容)。 |
| 63 | +Open the URL shown in the terminal (e.g. `http://localhost:5173`) to see the plugin’s multi-tab tools UI (no “Back to Tools” shell, just the plugin). |
65 | 64 |
|
66 | | -### 方式二:构建后在 CodeExpander 里验证(推荐) |
| 65 | +### Option 2: Build and test in CodeExpander (recommended) |
67 | 66 |
|
68 | | -在真实宿主里确认插件是否按规范工作(含 `writeClipboard`、`showToast`、多语言等)。 |
| 67 | +Verify behavior in the real host (e.g. `writeClipboard`, `showToast`, i18n). |
69 | 68 |
|
70 | | -1. **构建插件** |
| 69 | +1. **Build** |
71 | 70 | ```bash |
72 | | - # 构建单个插件 |
73 | 71 | pnpm --filter @codeexpander/plugin-text run build |
74 | | - |
75 | | - # 或构建所有插件 |
| 72 | + # or all plugins: |
76 | 73 | pnpm run build:plugins |
77 | 74 | ``` |
78 | 75 |
|
79 | | -2. **导入 CodeExpander** |
80 | | - - 打开 CodeExpander → **设置** 或 **插件中心** |
81 | | - - 选择 **从目录导入**(Import from directory) |
82 | | - - 选中该插件的 **dist** 目录,例如: |
| 76 | +2. **Import in CodeExpander** |
| 77 | + - Open CodeExpander → **Settings** or **Plugin Hub** |
| 78 | + - Choose **Import from directory** |
| 79 | + - Select the plugin’s **dist** folder, e.g.: |
83 | 80 | - `packages/plugin-text/dist` |
84 | 81 | - `packages/plugin-html/dist` |
85 | | - - 等等 |
86 | | - |
87 | | -3. **验证** |
88 | | - - 在 CodeExpander 里搜索或打开对应插件(如 "Text Tools") |
89 | | - - 应只看到插件内容:Tab 切换各工具(如 Word Counter、Text Diff…),无「Back to Tools」 |
90 | | - - 测试复制、Toast、中英文切换(若传了 `initialPayload.locale`) |
91 | 82 |
|
92 | | ---- |
| 83 | +3. **Verify** |
| 84 | + - Search or open the plugin (e.g. “Text Tools”) in CodeExpander. |
| 85 | + - You should see only the plugin content: tabs for each tool (Word Counter, Text Diff, etc.), no “Back to Tools”. |
| 86 | + - Test copy, Toast, and locale (if `initialPayload.locale` is passed). |
93 | 87 |
|
94 | | -## Using plugins in CodeExpander |
| 88 | +## Using Plugins in CodeExpander |
95 | 89 |
|
96 | 90 | 1. Build the plugin: `pnpm --filter @codeexpander/plugin-text run build`. |
97 | 91 | 2. In CodeExpander: **Settings** or **Plugin Hub** → **Import from directory**. |
98 | | -3. Select the plugin’s `dist` folder (e.g. `packages/plugin-text/dist`). The folder must contain `plugin.json` and the entry file (`index.html`). |
| 92 | +3. Select the plugin’s `dist` folder (e.g. `packages/plugin-text/dist`). It must contain `plugin.json` and the entry file (`index.html`). |
99 | 93 |
|
100 | | -Each plugin supports multiple languages (en, zh) via `initialPayload.locale` or browser locale. |
| 94 | +Plugins support multiple languages (en, zh) via `initialPayload.locale` or browser locale. |
0 commit comments