koishi-plugin-market-bundle-workbench 0.2.0-alpha.1 → 0.2.0-alpha.2
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 +225 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,25 +1,234 @@
|
|
|
1
1
|
# koishi-plugin-market-bundle-workbench
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Koishi 插件包制作与发布工作台。它面向插件作者,用一个固定向导完成 `koishi-plugin-pa-*` 插件包的创建、成员选择、预设配置审查、npm 校验、文件生成、压缩包下载和发布命令生成。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
这个插件只负责“制作与发布准备”。插件包的识别、安装、成员配置分组和卸载管理由 [koishi-plugin-market-next](https://github.com/qinfeng365/koishi-plugin-market-next) 负责。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## 为什么需要它
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Market NEXT 的插件包允许开发者把一组 Koishi 插件作为一个独立 npm 插件发布到市场中。典型场景包括:
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
- Pick installed plugins as members or enter package names manually.
|
|
15
|
-
- Edit required/optional members and preset config JSON.
|
|
16
|
-
- Generate dry-run and publish commands without storing npm tokens.
|
|
11
|
+
- 整理一套实用插件,用户安装插件包后即可一次性安装全部成员。
|
|
12
|
+
- 发布小型插件生态,例如核心插件加多个外围插件。
|
|
13
|
+
- 为新用户提供预设组合,同时让高级用户在安装前选择成员和审查配置。
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
手写插件包容易出错:npm 包名必须小写、成员版本不能缺省、`market:package` keyword 容易忘、预设配置存在安全风险、版本是否已发布需要反复查。工作台把这些步骤收进一条可检查的发布流。
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
2. Turn on `enableWorkbench`.
|
|
22
|
-
3. Open **插件包工作台** in the Console.
|
|
23
|
-
4. Build the member list, validate, generate files, then run the suggested npm commands in your project.
|
|
17
|
+
## 特性
|
|
24
18
|
|
|
25
|
-
|
|
19
|
+
- 分步发布向导:项目、成员、配置审计、校验、生成与发布。
|
|
20
|
+
- 支持 `koishi-plugin-pa-*` 和 `@scope/koishi-plugin-pa-*` 插件包命名。
|
|
21
|
+
- 可从已安装插件选择成员,也可手动输入 npm 包名。
|
|
22
|
+
- 每个成员可设置包名、插件键、版本范围、必选/可选和预设配置。
|
|
23
|
+
- 预设配置支持 JSON 预览,并提示敏感字段。
|
|
24
|
+
- 校验 npm 包存在性、版本占用、成员版本范围、自引用、重复成员、直接循环和缺少 `market:package`。
|
|
25
|
+
- 生成 `package.json`、`koishi.bundle`、`README.md` 和 `lib/index.js`。
|
|
26
|
+
- 支持下载 npm-ready `.tgz`,由 `npm pack` 真实生成。
|
|
27
|
+
- 支持下载源码 `.zip`,便于开发者本地审查和二次编辑。
|
|
28
|
+
- 支持写入本地项目目录、预览覆盖差异和运行 `npm pack --dry-run`。
|
|
29
|
+
- 不保存 npm token,不代替用户执行 `npm publish`。
|
|
30
|
+
|
|
31
|
+
## 安装
|
|
32
|
+
|
|
33
|
+
在 Koishi 中安装:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install koishi-plugin-market-bundle-workbench@alpha
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
如果你希望在 Koishi 控制台的插件市场里安装,推荐同时安装 Market NEXT:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install koishi-plugin-market-next@alpha
|
|
43
|
+
npm install koishi-plugin-market-bundle-workbench@alpha
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
启用插件后,在配置页打开:
|
|
47
|
+
|
|
48
|
+
```yaml
|
|
49
|
+
enableWorkbench: true
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
默认不开启工作台页面,避免普通用户的控制台出现开发者工具入口。
|
|
53
|
+
|
|
54
|
+
## 使用流程
|
|
55
|
+
|
|
56
|
+
1. 打开 Koishi 控制台中的“插件包工作台”。
|
|
57
|
+
2. 在“项目”步骤填写插件包名、版本、显示名、描述、keywords、dist-tag 和可选项目目录。
|
|
58
|
+
3. 在“成员”步骤选择已安装插件,或手动输入成员 npm 包名。
|
|
59
|
+
4. 在“配置审计”步骤检查每个成员的预设配置。含 `command`、`script`、`exec`、`path`、`token`、`sql`、`url` 等字段时应特别审查。
|
|
60
|
+
5. 在“校验”步骤运行 npm 与清单校验,确认没有 error。
|
|
61
|
+
6. 在“生成与发布”步骤生成文件,并选择一种发布方式。
|
|
62
|
+
|
|
63
|
+
## 推荐发布方式
|
|
64
|
+
|
|
65
|
+
### 下载 npm 发布包
|
|
66
|
+
|
|
67
|
+
这是推荐方式。工作台会创建临时目录,写入生成文件,执行真实的:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npm pack --json
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
然后把生成的 `.tgz` 返回给浏览器下载。开发者在本机执行:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npm publish ./koishi-plugin-pa-example-0.1.0.tgz --tag alpha
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
scoped 包需要公开发布:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npm publish ./scope-koishi-plugin-pa-example-0.1.0.tgz --tag alpha --access public
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
这种方式最接近真实 npm 产物,适合确认后直接发布。
|
|
86
|
+
|
|
87
|
+
### 下载源码 zip
|
|
88
|
+
|
|
89
|
+
源码 zip 包含同样的生成文件:
|
|
90
|
+
|
|
91
|
+
- `package.json`
|
|
92
|
+
- `README.md`
|
|
93
|
+
- `lib/index.js`
|
|
94
|
+
|
|
95
|
+
下载后可以解压、审查、修改,再在本机运行:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npm pack --dry-run
|
|
99
|
+
npm publish --tag alpha
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 写入本地项目
|
|
103
|
+
|
|
104
|
+
如果你已经准备了一个本地插件包项目,可以填写项目目录并使用“写入项目”。工作台默认不会覆盖已有文件,除非显式勾选允许覆盖。写入后可直接在该目录运行:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npm pack --dry-run
|
|
108
|
+
npm publish --tag alpha
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## 插件包格式
|
|
112
|
+
|
|
113
|
+
真实 npm 包名必须使用小写:
|
|
114
|
+
|
|
115
|
+
- `koishi-plugin-pa-xxx`
|
|
116
|
+
- `@scope/koishi-plugin-pa-xxx`
|
|
117
|
+
|
|
118
|
+
`koishi-plugin-PA-xxx` 只能作为概念写法,不是合法 npm 包名。
|
|
119
|
+
|
|
120
|
+
推荐添加 keyword:
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"keywords": ["koishi", "plugin", "market:package"]
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
核心清单位于 `package.json` 的 `koishi.bundle`:
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"koishi": {
|
|
133
|
+
"bundle": {
|
|
134
|
+
"label": "Dialogue 插件包",
|
|
135
|
+
"description": "一组对话系统相关插件。",
|
|
136
|
+
"members": [
|
|
137
|
+
{
|
|
138
|
+
"package": "koishi-plugin-dialogue",
|
|
139
|
+
"plugin": "dialogue",
|
|
140
|
+
"version": "^1.0.0",
|
|
141
|
+
"required": true,
|
|
142
|
+
"config": {}
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
`members[].version` 必填。工作台不会默认使用 `latest`,因为这会让用户安装到插件包作者没有确认过的破坏性版本。
|
|
151
|
+
|
|
152
|
+
## 生成的包会做什么
|
|
153
|
+
|
|
154
|
+
插件包自身是一个很薄的 Koishi 插件入口:
|
|
155
|
+
|
|
156
|
+
```js
|
|
157
|
+
'use strict'
|
|
158
|
+
|
|
159
|
+
exports.name = 'pa-example'
|
|
160
|
+
|
|
161
|
+
exports.apply = function apply() {
|
|
162
|
+
// This package is a Market NEXT plugin bundle manifest.
|
|
163
|
+
// Runtime behavior is provided by the bundle members.
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
也就是说,插件包本身不应该承载业务逻辑。它的职责是把成员清单和版本约束发布到 npm,并交给 Market NEXT 展开安装和管理。
|
|
168
|
+
|
|
169
|
+
## 安全边界
|
|
170
|
+
|
|
171
|
+
工作台刻意不做这些事:
|
|
172
|
+
|
|
173
|
+
- 不保存 npm token。
|
|
174
|
+
- 不在服务器端执行 `npm publish`。
|
|
175
|
+
- 不绕过 npm 登录态和二次确认。
|
|
176
|
+
- 不默认启用成员插件。
|
|
177
|
+
- 不把预设配置静默注入用户环境。
|
|
178
|
+
|
|
179
|
+
原因很简单:插件包可能包含多个成员和预设配置,发布动作也会影响公开 npm 包。最终发布应该发生在开发者自己的本机 npm 环境中。
|
|
180
|
+
|
|
181
|
+
## 配置项
|
|
182
|
+
|
|
183
|
+
| 配置项 | 默认值 | 说明 |
|
|
184
|
+
| --- | --- | --- |
|
|
185
|
+
| `enableWorkbench` | `false` | 是否启用控制台“插件包工作台”页面。 |
|
|
186
|
+
| `npmRegistry` | `https://registry.npmjs.org` | 用于校验 npm 包信息的 registry。 |
|
|
187
|
+
| `defaultDistTag` | `alpha` | 生成发布命令时使用的默认 dist-tag。 |
|
|
188
|
+
| `allowPublishCommand` | `false` | 是否显示 `npm publish` 命令。插件仍不会代为执行发布。 |
|
|
189
|
+
|
|
190
|
+
## Console 事件
|
|
191
|
+
|
|
192
|
+
工作台注册以下只面向控制台的事件:
|
|
193
|
+
|
|
194
|
+
| 事件 | 作用 |
|
|
195
|
+
| --- | --- |
|
|
196
|
+
| `bundle-workbench/npm-info(name)` | 查询 npm 包是否存在、版本、作者、维护者和 keywords。 |
|
|
197
|
+
| `bundle-workbench/validate(draft)` | 校验插件包草稿,返回 error / warning / info。 |
|
|
198
|
+
| `bundle-workbench/generate(draft)` | 生成 `package.json`、`koishi.bundle`、`lib/index.js`、README 和发布命令。 |
|
|
199
|
+
| `bundle-workbench/download-archive(draft, type)` | 生成并下载 `npm-tgz` 或 `source-zip`。 |
|
|
200
|
+
| `bundle-workbench/write-files(projectPath, draft, options)` | 写入本地项目目录,支持 dry-run 和覆盖控制。 |
|
|
201
|
+
| `bundle-workbench/pack-dry-run(projectPath)` | 在项目目录运行 `npm pack --dry-run`。 |
|
|
202
|
+
|
|
203
|
+
## 本地开发
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
npm install
|
|
207
|
+
npm run build
|
|
208
|
+
npm run check:package
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
脚本说明:
|
|
212
|
+
|
|
213
|
+
- `npm run build`:构建 TypeScript、后端入口和控制台前端产物。
|
|
214
|
+
- `npm run check:package`:运行 `npm pack --dry-run`,确认发布包内容。
|
|
215
|
+
|
|
216
|
+
## CI 与发布
|
|
217
|
+
|
|
218
|
+
仓库包含两个 GitHub Actions workflow:
|
|
219
|
+
|
|
220
|
+
- `CI`:在 push / pull request 时运行安装、构建和打包检查。
|
|
221
|
+
- `Publish`:在 `v*` tag 或手动触发时发布 npm,发布前检查 tag/input 版本必须等于 `package.json`。
|
|
222
|
+
|
|
223
|
+
发布 alpha 版本时建议:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
npm version 0.2.0-alpha.2 --no-git-tag-version
|
|
227
|
+
npm run build
|
|
228
|
+
npm run check:package
|
|
229
|
+
npm publish --tag alpha
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
AGPL-3.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-market-bundle-workbench",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.2",
|
|
4
4
|
"description": "Plugin bundle authoring workbench for Koishi Market NEXT.",
|
|
5
5
|
"homepage": "https://github.com/qinfeng365/koishi-plugin-market-bundle-workbench#readme",
|
|
6
6
|
"repository": {
|