@@ -13,6 +13,13 @@ NapGram 原生插件模板仓库(可作为 GitHub **Template repository** 使
1313
1414## 快速开始
1515
16+ ### 0) 使用模板创建仓库
17+
18+ 1 . 打开本仓库,点击 ** Use this template** 创建新仓库
19+ 2 . 克隆新仓库到本地
20+ 3 . 修改 ` napgram-plugin.json ` (id/name/description/permissions)
21+ 4 . 修改 ` package.json ` (name/version/description)
22+
1623### 1) 安装依赖
1724
1825``` bash
@@ -24,9 +31,9 @@ pnpm install
2431编辑 ` src/index.ts ` ,实现你的插件逻辑:
2532
2633``` typescript
27- import type { NapGramPlugin } from ' @naplink/ napgram-plugin-types ' ;
34+ import { definePlugin } from ' @napgram/sdk ' ;
2835
29- const plugin: NapGramPlugin = {
36+ const plugin = definePlugin ( {
3037 id: ' my-plugin' ,
3138 name: ' My Plugin' ,
3239 version: ' 1.0.0' ,
@@ -36,12 +43,12 @@ const plugin: NapGramPlugin = {
3643 if (event .message .text === ' ping' ) await event .reply (' pong' );
3744 });
3845 }
39- };
46+ }) ;
4047
4148export default plugin ;
4249```
4350
44- > 注:模板内包含 ` src/types/@naplink/ napgram-plugin-types/ index.d.ts ` 的最小类型声明,便于直接开发与通过 CI;构建产物不会包含该依赖 。
51+ > 注:模板内包含 ` src/types/@napgram/sdk/ index.d.ts ` 的最小类型声明,便于离线开发与通过 CI;构建产物不会包含该声明。模板默认依赖 ` @napgram/sdk ` ,如已安装可按需移除此兜底类型 。
4552
4653### 3) 构建
4754
@@ -177,13 +184,17 @@ napgram-plugin-template/
177184
178185### 自动化发布(推荐)
179186
180- 打 tag 后 Release workflow 会自动:
187+ 推送 tag 后 Release workflow 会自动:
1811881 . 打包产物并生成 ` marketplace-index-snippet.json `
182- 2 . 若配置了 ` MARKETPLACE_PR_TOKEN ` ,自动向 marketplace 提交 PR(你负责合并 )
189+ 2 . 若配置了 ` MARKETPLACE_PR_TOKEN ` ,自动向 ** NapGram/ marketplace** 提交 PR(请关注 ` https://github.com/NapGram/marketplace/pulls ` )
183190
184191需要在** 实际插件仓库** 配置以下 Secrets:
185192- ` NPM_TOKEN ` :npm automation token(用于 publish)
186- - ` MARKETPLACE_PR_TOKEN ` :GitHub PAT(公开仓库用 ` public_repo ` 即可)
193+ - ` MARKETPLACE_PR_TOKEN ` :GitHub PAT(需要 ** repo** + ** workflow** 权限)
194+
195+ ` MARKETPLACE_PR_TOKEN ` 权限建议(fine-grained):
196+ - Repository access:选择你的插件仓库
197+ - Permissions:Contents(read/write)、Pull requests(read/write)、Workflows(read/write)
187198
188199可选配置:
189200- ` MARKETPLACE_DIST_HOST ` :自定义资源下载域名,未设置时默认使用 GitHub Release 下载链接
0 commit comments