mofox-plugin-dev-toolkit 0.4.9__tar.gz → 0.5.0__tar.gz

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.
Files changed (66) hide show
  1. {mofox_plugin_dev_toolkit-0.4.9/mofox_plugin_dev_toolkit.egg-info → mofox_plugin_dev_toolkit-0.5.0}/PKG-INFO +58 -3
  2. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/README.md +56 -1
  3. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0/mofox_plugin_dev_toolkit.egg-info}/PKG-INFO +58 -3
  4. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mofox_plugin_dev_toolkit.egg-info/SOURCES.txt +7 -0
  5. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/__init__.py +1 -1
  6. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/cli.py +241 -4
  7. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/commands/build.py +109 -35
  8. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/commands/generate.py +2 -1
  9. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/commands/init.py +2 -0
  10. mofox_plugin_dev_toolkit-0.5.0/mpdt/commands/market.py +451 -0
  11. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/dev/bridge_plugin/cleanup_handler.py +35 -7
  12. mofox_plugin_dev_toolkit-0.5.0/mpdt/market/__init__.py +1 -0
  13. mofox_plugin_dev_toolkit-0.5.0/mpdt/market/client.py +153 -0
  14. mofox_plugin_dev_toolkit-0.5.0/mpdt/market/config.py +44 -0
  15. mofox_plugin_dev_toolkit-0.5.0/mpdt/market/git.py +109 -0
  16. mofox_plugin_dev_toolkit-0.5.0/mpdt/market/github.py +145 -0
  17. mofox_plugin_dev_toolkit-0.5.0/mpdt/market/manifest.py +102 -0
  18. mofox_plugin_dev_toolkit-0.5.0/mpdt/templates/event_template.py +125 -0
  19. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/utils/config_manager.py +23 -0
  20. mofox_plugin_dev_toolkit-0.5.0/mpdt/utils/plugin_parser.py +33 -0
  21. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/validators/auto_fix_validator.py +1 -0
  22. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/validators/base.py +3 -6
  23. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/validators/component_validator.py +2 -0
  24. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/pyproject.toml +2 -2
  25. mofox_plugin_dev_toolkit-0.4.9/mpdt/templates/event_template.py +0 -101
  26. mofox_plugin_dev_toolkit-0.4.9/mpdt/utils/plugin_parser.py +0 -137
  27. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/LICENSE +0 -0
  28. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/MANIFEST.in +0 -0
  29. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mofox_plugin_dev_toolkit.egg-info/dependency_links.txt +0 -0
  30. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mofox_plugin_dev_toolkit.egg-info/entry_points.txt +0 -0
  31. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mofox_plugin_dev_toolkit.egg-info/requires.txt +0 -0
  32. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mofox_plugin_dev_toolkit.egg-info/top_level.txt +0 -0
  33. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/__main__.py +0 -0
  34. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/commands/__init__.py +0 -0
  35. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/commands/check.py +0 -0
  36. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/commands/dev.py +0 -0
  37. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/dev/bridge_plugin/__init__.py +0 -0
  38. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/dev/bridge_plugin/dev_config.py +0 -0
  39. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/dev/bridge_plugin/file_watcher.py +0 -0
  40. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/dev/bridge_plugin/manifest.json +0 -0
  41. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/dev/bridge_plugin/plugin.py +0 -0
  42. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/templates/__init__.py +0 -0
  43. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/templates/action_template.py +0 -0
  44. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/templates/adapter_template.py +0 -0
  45. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/templates/chatter_template.py +0 -0
  46. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/templates/collection_template.py +0 -0
  47. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/templates/config_template.py +0 -0
  48. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/templates/plus_command_template.py +0 -0
  49. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/templates/prompt_template.py +0 -0
  50. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/templates/router_template.py +0 -0
  51. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/templates/service_template.py +0 -0
  52. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/templates/tool_template.py +0 -0
  53. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/utils/__init__.py +0 -0
  54. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/utils/code_parser.py +0 -0
  55. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/utils/color_printer.py +0 -0
  56. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/utils/config_loader.py +0 -0
  57. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/utils/file_ops.py +0 -0
  58. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/utils/license_generator.py +0 -0
  59. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/utils/template_engine.py +0 -0
  60. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/validators/__init__.py +0 -0
  61. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/validators/config_validator.py +0 -0
  62. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/validators/metadata_validator.py +0 -0
  63. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/validators/structure_validator.py +0 -0
  64. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/validators/style_validator.py +0 -0
  65. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/mpdt/validators/type_validator.py +0 -0
  66. {mofox_plugin_dev_toolkit-0.4.9 → mofox_plugin_dev_toolkit-0.5.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mofox-plugin-dev-toolkit
3
- Version: 0.4.9
3
+ Version: 0.5.0
4
4
  Summary: 开发工具集,用于快速创建、开发和测试 MoFox-Bot 插件
5
5
  Author-email: MoFox-Studio <wwwww95915@qq.com>
6
6
  License: GPL-3.0-or-later
@@ -9,7 +9,7 @@ Project-URL: Documentation, https://docs.mofox.studio/mpdt
9
9
  Project-URL: Repository, https://github.com/MoFox-Studio/mofox-plugin-toolkit
10
10
  Project-URL: Bug Tracker, https://github.com/MoFox-Studio/mofox-plugin-toolkit/issues
11
11
  Keywords: mofox,plugin,toolkit,cli,development
12
- Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Intended Audience :: Developers
14
14
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
15
15
  Classifier: Programming Language :: Python :: 3
@@ -305,7 +305,62 @@ mpdt build --with-docs --bump patch --output release
305
305
 
306
306
  **说明**:`.mfp` 文件是 Neo-MoFox 的标准插件格式(本质为 ZIP 压缩包),可直接被 loader.py 加载。
307
307
 
308
- ### 6. 配置管理
308
+ ### 6. 发布到插件市场
309
+
310
+ MPDT 可以自动完成 GitHub 仓库、tag、Release、资产上传以及中心服务器同步。
311
+
312
+ 准备 GitHub token,至少需要仓库创建和 Release 写入权限:
313
+
314
+ ```bash
315
+ set GITHUB_TOKEN=ghp_xxx
316
+ set PLUGIN_MARKET_BASE_URL=http://127.0.0.1:8787
317
+ set PLUGIN_MARKET_AUTHOR_TOKEN=dev-token
318
+ ```
319
+
320
+ 也可以首次发布时传入 token,并在明确确认后保存到 `~/.mpdt/config.toml`,下次会自动读取:
321
+
322
+ ```bash
323
+ mpdt market publish --github-token ghp_xxx --save-github-token --owner your-github-user-or-org
324
+ ```
325
+
326
+ 如果只传 `--github-token` 且没有指定 `--save-github-token`,MPDT 会询问是否保存;默认不保存。
327
+
328
+ 在插件目录执行一键发布:
329
+
330
+ ```bash
331
+ mpdt market publish --owner your-github-user-or-org
332
+ ```
333
+
334
+ 该命令会依次执行:
335
+
336
+ 1. 读取 `manifest.json`。
337
+ 2. 构建 `.mfp` 包并计算 sha256。
338
+ 3. 如果 GitHub 仓库不存在则自动创建。
339
+ 4. 初始化或复用本地 git 仓库。
340
+ 5. 提交当前插件代码。
341
+ 6. 创建版本 tag,例如 `v1.0.0`。
342
+ 7. 推送分支和 tag 到 GitHub。
343
+ 8. 创建或复用 GitHub Release。
344
+ 9. 上传 `.mfp` Release 资产。
345
+ 10. 注册或更新中心服务器插件元数据。
346
+ 11. 提交新版本;如果版本已存在则同步版本元数据。
347
+
348
+ 常用参数:
349
+
350
+ ```bash
351
+ mpdt market publish \
352
+ --owner MoFox-Studio \
353
+ --repo my_plugin \
354
+ --release-notes "First public release"
355
+ ```
356
+
357
+ 如果仓库和 tag 已经手动推送,可跳过 git push,仅创建/复用 Release 并同步市场:
358
+
359
+ ```bash
360
+ mpdt market publish --owner MoFox-Studio --skip-push
361
+ ```
362
+
363
+ ### 7. 配置管理
309
364
 
310
365
  ```bash
311
366
  # 交互式配置向导
@@ -253,7 +253,62 @@ mpdt build --with-docs --bump patch --output release
253
253
 
254
254
  **说明**:`.mfp` 文件是 Neo-MoFox 的标准插件格式(本质为 ZIP 压缩包),可直接被 loader.py 加载。
255
255
 
256
- ### 6. 配置管理
256
+ ### 6. 发布到插件市场
257
+
258
+ MPDT 可以自动完成 GitHub 仓库、tag、Release、资产上传以及中心服务器同步。
259
+
260
+ 准备 GitHub token,至少需要仓库创建和 Release 写入权限:
261
+
262
+ ```bash
263
+ set GITHUB_TOKEN=ghp_xxx
264
+ set PLUGIN_MARKET_BASE_URL=http://127.0.0.1:8787
265
+ set PLUGIN_MARKET_AUTHOR_TOKEN=dev-token
266
+ ```
267
+
268
+ 也可以首次发布时传入 token,并在明确确认后保存到 `~/.mpdt/config.toml`,下次会自动读取:
269
+
270
+ ```bash
271
+ mpdt market publish --github-token ghp_xxx --save-github-token --owner your-github-user-or-org
272
+ ```
273
+
274
+ 如果只传 `--github-token` 且没有指定 `--save-github-token`,MPDT 会询问是否保存;默认不保存。
275
+
276
+ 在插件目录执行一键发布:
277
+
278
+ ```bash
279
+ mpdt market publish --owner your-github-user-or-org
280
+ ```
281
+
282
+ 该命令会依次执行:
283
+
284
+ 1. 读取 `manifest.json`。
285
+ 2. 构建 `.mfp` 包并计算 sha256。
286
+ 3. 如果 GitHub 仓库不存在则自动创建。
287
+ 4. 初始化或复用本地 git 仓库。
288
+ 5. 提交当前插件代码。
289
+ 6. 创建版本 tag,例如 `v1.0.0`。
290
+ 7. 推送分支和 tag 到 GitHub。
291
+ 8. 创建或复用 GitHub Release。
292
+ 9. 上传 `.mfp` Release 资产。
293
+ 10. 注册或更新中心服务器插件元数据。
294
+ 11. 提交新版本;如果版本已存在则同步版本元数据。
295
+
296
+ 常用参数:
297
+
298
+ ```bash
299
+ mpdt market publish \
300
+ --owner MoFox-Studio \
301
+ --repo my_plugin \
302
+ --release-notes "First public release"
303
+ ```
304
+
305
+ 如果仓库和 tag 已经手动推送,可跳过 git push,仅创建/复用 Release 并同步市场:
306
+
307
+ ```bash
308
+ mpdt market publish --owner MoFox-Studio --skip-push
309
+ ```
310
+
311
+ ### 7. 配置管理
257
312
 
258
313
  ```bash
259
314
  # 交互式配置向导
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mofox-plugin-dev-toolkit
3
- Version: 0.4.9
3
+ Version: 0.5.0
4
4
  Summary: 开发工具集,用于快速创建、开发和测试 MoFox-Bot 插件
5
5
  Author-email: MoFox-Studio <wwwww95915@qq.com>
6
6
  License: GPL-3.0-or-later
@@ -9,7 +9,7 @@ Project-URL: Documentation, https://docs.mofox.studio/mpdt
9
9
  Project-URL: Repository, https://github.com/MoFox-Studio/mofox-plugin-toolkit
10
10
  Project-URL: Bug Tracker, https://github.com/MoFox-Studio/mofox-plugin-toolkit/issues
11
11
  Keywords: mofox,plugin,toolkit,cli,development
12
- Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Intended Audience :: Developers
14
14
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
15
15
  Classifier: Programming Language :: Python :: 3
@@ -305,7 +305,62 @@ mpdt build --with-docs --bump patch --output release
305
305
 
306
306
  **说明**:`.mfp` 文件是 Neo-MoFox 的标准插件格式(本质为 ZIP 压缩包),可直接被 loader.py 加载。
307
307
 
308
- ### 6. 配置管理
308
+ ### 6. 发布到插件市场
309
+
310
+ MPDT 可以自动完成 GitHub 仓库、tag、Release、资产上传以及中心服务器同步。
311
+
312
+ 准备 GitHub token,至少需要仓库创建和 Release 写入权限:
313
+
314
+ ```bash
315
+ set GITHUB_TOKEN=ghp_xxx
316
+ set PLUGIN_MARKET_BASE_URL=http://127.0.0.1:8787
317
+ set PLUGIN_MARKET_AUTHOR_TOKEN=dev-token
318
+ ```
319
+
320
+ 也可以首次发布时传入 token,并在明确确认后保存到 `~/.mpdt/config.toml`,下次会自动读取:
321
+
322
+ ```bash
323
+ mpdt market publish --github-token ghp_xxx --save-github-token --owner your-github-user-or-org
324
+ ```
325
+
326
+ 如果只传 `--github-token` 且没有指定 `--save-github-token`,MPDT 会询问是否保存;默认不保存。
327
+
328
+ 在插件目录执行一键发布:
329
+
330
+ ```bash
331
+ mpdt market publish --owner your-github-user-or-org
332
+ ```
333
+
334
+ 该命令会依次执行:
335
+
336
+ 1. 读取 `manifest.json`。
337
+ 2. 构建 `.mfp` 包并计算 sha256。
338
+ 3. 如果 GitHub 仓库不存在则自动创建。
339
+ 4. 初始化或复用本地 git 仓库。
340
+ 5. 提交当前插件代码。
341
+ 6. 创建版本 tag,例如 `v1.0.0`。
342
+ 7. 推送分支和 tag 到 GitHub。
343
+ 8. 创建或复用 GitHub Release。
344
+ 9. 上传 `.mfp` Release 资产。
345
+ 10. 注册或更新中心服务器插件元数据。
346
+ 11. 提交新版本;如果版本已存在则同步版本元数据。
347
+
348
+ 常用参数:
349
+
350
+ ```bash
351
+ mpdt market publish \
352
+ --owner MoFox-Studio \
353
+ --repo my_plugin \
354
+ --release-notes "First public release"
355
+ ```
356
+
357
+ 如果仓库和 tag 已经手动推送,可跳过 git push,仅创建/复用 Release 并同步市场:
358
+
359
+ ```bash
360
+ mpdt market publish --owner MoFox-Studio --skip-push
361
+ ```
362
+
363
+ ### 7. 配置管理
309
364
 
310
365
  ```bash
311
366
  # 交互式配置向导
@@ -17,12 +17,19 @@ mpdt/commands/check.py
17
17
  mpdt/commands/dev.py
18
18
  mpdt/commands/generate.py
19
19
  mpdt/commands/init.py
20
+ mpdt/commands/market.py
20
21
  mpdt/dev/bridge_plugin/__init__.py
21
22
  mpdt/dev/bridge_plugin/cleanup_handler.py
22
23
  mpdt/dev/bridge_plugin/dev_config.py
23
24
  mpdt/dev/bridge_plugin/file_watcher.py
24
25
  mpdt/dev/bridge_plugin/manifest.json
25
26
  mpdt/dev/bridge_plugin/plugin.py
27
+ mpdt/market/__init__.py
28
+ mpdt/market/client.py
29
+ mpdt/market/config.py
30
+ mpdt/market/git.py
31
+ mpdt/market/github.py
32
+ mpdt/market/manifest.py
26
33
  mpdt/templates/__init__.py
27
34
  mpdt/templates/action_template.py
28
35
  mpdt/templates/adapter_template.py
@@ -4,7 +4,7 @@ MoFox Plugin Dev Toolkit
4
4
  一个用于 MoFox-Bot 插件开发的工具集
5
5
  """
6
6
 
7
- __version__ = "0.4.9"
7
+ __version__ = "0.4.11"
8
8
  __author__ = "MoFox-Studio"
9
9
  __license__ = "GPL-3.0-or-later"
10
10
 
@@ -36,7 +36,7 @@ def cli(ctx: click.Context, verbose: bool, no_color: bool) -> None:
36
36
 
37
37
  @cli.command()
38
38
  @click.argument("plugin_name", required=False)
39
- @click.option("--template", "-t", type=click.Choice(["basic", "action", "tool", "plus_command", "full", "adapter"]),
39
+ @click.option("--template", "-t", type=click.Choice(["basic", "action", "tool", "collection", "router", "plus_command", "event_handler", "full", "adapter", "chatter"]),
40
40
  default="basic", help="插件模板类型")
41
41
  @click.option("--author", "-a", help="作者名称")
42
42
  @click.option("--email", "-e", help="作者电子邮箱")
@@ -69,14 +69,15 @@ def init(ctx: click.Context, plugin_name: str | None, template: str,email: str|
69
69
 
70
70
 
71
71
  @cli.command()
72
- @click.argument("component_type", type=click.Choice(["action", "tool", "event", "adapter", "plus-command", "router", "chatter", "service", "config"]), required=False)
72
+ @click.argument("component_type", type=click.Choice(["action", "tool", "collection", "event", "adapter", "plus-command", "router", "chatter", "service", "config"]), required=False)
73
73
  @click.argument("component_name", required=False)
74
74
  @click.option("--description", "-d", help="组件描述")
75
- @click.option("--output", "-o", type=click.Path(), help="输出目录")
75
+ @click.option("--output", "-o", type=click.Path(), help="插件根目录路径(默认为当前目录)")
76
76
  @click.option("--force", "-f", is_flag=True, help="覆盖已存在的文件")
77
+ @click.option("--root", is_flag=True, help="在插件根目录生成组件文件,而不是 components/ 文件夹")
77
78
  @click.pass_context
78
79
  def generate(ctx: click.Context, component_type: str | None, component_name: str | None, description: str | None,
79
- output: str | None, force: bool) -> None:
80
+ output: str | None, force: bool, root: bool) -> None:
80
81
  """生成插件组件(始终生成异步方法)
81
82
 
82
83
  如果不提供参数,将进入交互式问答模式
@@ -90,6 +91,7 @@ def generate(ctx: click.Context, component_type: str | None, component_name: str
90
91
  description=description,
91
92
  output_dir=output,
92
93
  force=force,
94
+ use_components_folder=not root,
93
95
  verbose=ctx.obj["verbose"],
94
96
  )
95
97
  except Exception as e:
@@ -187,6 +189,241 @@ def dev(ctx: click.Context, neo_mofox_path: str | None, plugin_path: str | None)
187
189
  raise click.Abort()
188
190
 
189
191
 
192
+ @cli.group()
193
+ def market() -> None:
194
+ """插件市场命令"""
195
+ pass
196
+
197
+
198
+ @market.command("doctor")
199
+ @click.option("--market-url", help="中心服务器地址")
200
+ @click.option("--token", help="中心服务器访问令牌")
201
+ def market_doctor_cmd(market_url: str | None, token: str | None) -> None:
202
+ """检查中心服务器连通性"""
203
+ from mpdt.commands.market import market_doctor
204
+
205
+ market_doctor(market_url=market_url, token=token)
206
+
207
+
208
+ @market.command("register")
209
+ @click.argument("plugin_path", type=click.Path(), required=False, default=".")
210
+ @click.option("--market-url", help="中心服务器地址")
211
+ @click.option("--token", help="中心服务器访问令牌")
212
+ @click.option("--repository-url", help="插件 GitHub 仓库地址")
213
+ def market_register_cmd(plugin_path: str, market_url: str | None, token: str | None, repository_url: str | None) -> None:
214
+ """注册插件到中心服务器"""
215
+ from mpdt.commands.market import market_register
216
+
217
+ market_register(plugin_path=plugin_path, market_url=market_url, token=token, repository_url=repository_url)
218
+
219
+
220
+ @market.command("update")
221
+ @click.argument("plugin_path", type=click.Path(), required=False, default=".")
222
+ @click.option("--market-url", help="中心服务器地址")
223
+ @click.option("--token", help="中心服务器访问令牌")
224
+ @click.option("--repository-url", help="插件 GitHub 仓库地址")
225
+ def market_update_cmd(plugin_path: str, market_url: str | None, token: str | None, repository_url: str | None) -> None:
226
+ """更新中心服务器插件元数据"""
227
+ from mpdt.commands.market import market_update
228
+
229
+ market_update(plugin_path=plugin_path, market_url=market_url, token=token, repository_url=repository_url)
230
+
231
+
232
+ @market.command("package")
233
+ @click.argument("plugin_path", type=click.Path(), required=False, default=".")
234
+ @click.option("--output", "output_dir", type=click.Path(), default="dist", help="输出目录")
235
+ @click.option("--with-docs", is_flag=True, help="包含文档")
236
+ def market_package_cmd(plugin_path: str, output_dir: str, with_docs: bool) -> None:
237
+ """生成市场发布产物元数据"""
238
+ from mpdt.commands.market import market_package
239
+
240
+ market_package(plugin_path=plugin_path, output_dir=output_dir, with_docs=with_docs)
241
+
242
+
243
+ @market.command("submit-version")
244
+ @click.argument("plugin_path", type=click.Path(), required=False, default=".")
245
+ @click.option("--market-url", help="中心服务器地址")
246
+ @click.option("--token", help="中心服务器访问令牌")
247
+ @click.option("--asset-url", help="Release 资产下载地址")
248
+ @click.option("--release-url", help="GitHub Release 页面地址")
249
+ @click.option("--output", "output_dir", type=click.Path(), default="dist", help="输出目录")
250
+ @click.option("--with-docs", is_flag=True, help="包含文档")
251
+ def market_submit_version_cmd(
252
+ plugin_path: str,
253
+ market_url: str | None,
254
+ token: str | None,
255
+ asset_url: str | None,
256
+ release_url: str | None,
257
+ output_dir: str,
258
+ with_docs: bool,
259
+ ) -> None:
260
+ """打包并提交插件版本"""
261
+ from mpdt.commands.market import market_submit_version
262
+
263
+ market_submit_version(
264
+ plugin_path=plugin_path,
265
+ market_url=market_url,
266
+ token=token,
267
+ asset_url=asset_url,
268
+ release_url=release_url,
269
+ output_dir=output_dir,
270
+ with_docs=with_docs,
271
+ )
272
+
273
+
274
+ @market.command("sync")
275
+ @click.argument("plugin_path", type=click.Path(), required=False, default=".")
276
+ @click.option("--market-url", help="中心服务器地址")
277
+ @click.option("--token", help="中心服务器访问令牌")
278
+ @click.option("--asset-url", help="Release 资产下载地址")
279
+ @click.option("--release-url", help="GitHub Release 页面地址")
280
+ @click.option("--output", "output_dir", type=click.Path(), default="dist", help="输出目录")
281
+ @click.option("--with-docs", is_flag=True, help="包含文档")
282
+ def market_sync_cmd(
283
+ plugin_path: str,
284
+ market_url: str | None,
285
+ token: str | None,
286
+ asset_url: str | None,
287
+ release_url: str | None,
288
+ output_dir: str,
289
+ with_docs: bool,
290
+ ) -> None:
291
+ """同步插件版本元数据"""
292
+ from mpdt.commands.market import market_sync
293
+
294
+ market_sync(
295
+ plugin_path=plugin_path,
296
+ market_url=market_url,
297
+ token=token,
298
+ asset_url=asset_url,
299
+ release_url=release_url,
300
+ output_dir=output_dir,
301
+ with_docs=with_docs,
302
+ )
303
+
304
+
305
+ @market.command("publish")
306
+ @click.argument("plugin_path", type=click.Path(), required=False, default=".")
307
+ @click.option("--market-url", help="中心服务器地址")
308
+ @click.option("--token", help="中心服务器访问令牌")
309
+ @click.option("--github-token", help="GitHub token;也可使用 GITHUB_TOKEN 或 GH_TOKEN")
310
+ @click.option("--owner", help="GitHub 用户或组织名;默认使用当前 GitHub token 用户")
311
+ @click.option("--repo", help="GitHub 仓库名;默认使用插件 ID")
312
+ @click.option("--private", is_flag=True, help="新建私有仓库")
313
+ @click.option("--output", "output_dir", type=click.Path(), default="dist", help="输出目录")
314
+ @click.option("--with-docs", is_flag=True, help="包含文档")
315
+ @click.option("--release-notes", help="GitHub Release 说明")
316
+ @click.option("--skip-push", is_flag=True, help="跳过 git push,仅创建/复用 Release 并同步市场")
317
+ @click.option("--save-github-token/--no-save-github-token", default=None, help="是否保存本次传入的 GitHub token")
318
+ def market_publish_cmd(
319
+ plugin_path: str,
320
+ market_url: str | None,
321
+ token: str | None,
322
+ github_token: str | None,
323
+ owner: str | None,
324
+ repo: str | None,
325
+ private: bool,
326
+ output_dir: str,
327
+ with_docs: bool,
328
+ release_notes: str | None,
329
+ skip_push: bool,
330
+ save_github_token: bool | None,
331
+ ) -> None:
332
+ """一键发布:建仓库、推送 tag、创建 Release、上传产物并同步市场"""
333
+ from mpdt.commands.market import market_publish
334
+
335
+ market_publish(
336
+ plugin_path=plugin_path,
337
+ market_url=market_url,
338
+ token=token,
339
+ github_token=github_token,
340
+ owner=owner,
341
+ repo=repo,
342
+ private=private,
343
+ output_dir=output_dir,
344
+ with_docs=with_docs,
345
+ release_notes=release_notes,
346
+ skip_push=skip_push,
347
+ save_token=save_github_token,
348
+ )
349
+
350
+
351
+ @market.command("status")
352
+ @click.argument("plugin_path", type=click.Path(), required=False, default=".")
353
+ @click.option("--plugin-id", help="插件 ID,不提供则读取 manifest.json")
354
+ @click.option("--market-url", help="中心服务器地址")
355
+ @click.option("--token", help="中心服务器访问令牌")
356
+ def market_status_cmd(plugin_path: str, plugin_id: str | None, market_url: str | None, token: str | None) -> None:
357
+ """查询插件市场状态"""
358
+ from mpdt.commands.market import market_status
359
+
360
+ market_status(plugin_path=plugin_path, plugin_id=plugin_id, market_url=market_url, token=token)
361
+
362
+
363
+ @market.command("yank")
364
+ @click.argument("plugin_path", type=click.Path(), required=False, default=".")
365
+ @click.option("--version", help="插件版本,不提供则读取 manifest.json")
366
+ @click.option("--market-url", help="中心服务器地址")
367
+ @click.option("--token", help="中心服务器访问令牌")
368
+ @click.option("--reason", help="撤回原因")
369
+ def market_yank_cmd(plugin_path: str, version: str | None, market_url: str | None, token: str | None, reason: str | None) -> None:
370
+ """撤回插件版本"""
371
+ from mpdt.commands.market import market_yank
372
+
373
+ market_yank(plugin_path=plugin_path, version=version, market_url=market_url, token=token, reason=reason)
374
+
375
+
376
+ @market.command("search")
377
+ @click.argument("query", required=False)
378
+ @click.option("--category", help="分类过滤")
379
+ @click.option("--tag", help="标签过滤")
380
+ @click.option("--limit", type=int, default=20, help="返回数量")
381
+ @click.option("--market-url", help="中心服务器地址")
382
+ def market_search_cmd(query: str | None, category: str | None, tag: str | None, limit: int, market_url: str | None) -> None:
383
+ """搜索公开插件"""
384
+ from mpdt.commands.market import market_search
385
+
386
+ market_search(query=query, category=category, tag=tag, limit=limit, market_url=market_url)
387
+
388
+
389
+ @market.command("info")
390
+ @click.argument("plugin_id")
391
+ @click.option("--market-url", help="中心服务器地址")
392
+ def market_info_cmd(plugin_id: str, market_url: str | None) -> None:
393
+ """查看公开插件详情"""
394
+ from mpdt.commands.market import market_info
395
+
396
+ market_info(plugin_id=plugin_id, market_url=market_url)
397
+
398
+
399
+ @market.command("install-info")
400
+ @click.argument("plugin_id")
401
+ @click.option("--market-url", help="中心服务器地址")
402
+ @click.option("--host-version", help="当前 Neo-MoFox 宿主版本")
403
+ @click.option("--plugin-api-version", help="插件 API 版本")
404
+ @click.option("--platform", help="目标平台,例如 windows/linux/macos")
405
+ @click.option("--include-prerelease", is_flag=True, help="允许推荐预发布版本")
406
+ def market_install_info_cmd(
407
+ plugin_id: str,
408
+ market_url: str | None,
409
+ host_version: str | None,
410
+ plugin_api_version: str | None,
411
+ platform: str | None,
412
+ include_prerelease: bool,
413
+ ) -> None:
414
+ """查看推荐安装版本元数据"""
415
+ from mpdt.commands.market import market_install_info
416
+
417
+ market_install_info(
418
+ plugin_id=plugin_id,
419
+ market_url=market_url,
420
+ host_version=host_version,
421
+ plugin_api_version=plugin_api_version,
422
+ platform=platform,
423
+ include_prerelease=include_prerelease,
424
+ )
425
+
426
+
190
427
  @cli.group()
191
428
  def config() -> None:
192
429
  """配置管理"""