create-halo-plugin-template 1.0.0 → 1.0.1
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/.editorconfig +520 -0
- package/.github/workflows/cd.yaml +20 -0
- package/.github/workflows/ci.yaml +32 -0
- package/.github/workflows/publish-npm.yaml +46 -0
- package/.gitignore +84 -0
- package/LICENSE +674 -0
- package/README.md +191 -0
- package/build.gradle +103 -0
- package/docs/first-npm-release-checklist.md +58 -0
- package/docs/publish-template.md +148 -0
- package/docs/rsbuild-switch.md +90 -0
- package/docs/template-pruning.md +43 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/gradle.properties +1 -0
- package/gradlew +248 -0
- package/gradlew.bat +93 -0
- package/package.json +67 -7
- package/scripts/create-project.mjs +399 -0
- package/scripts/init-template.mjs +281 -0
- package/scripts/publish-check.mjs +97 -0
- package/scripts/release.mjs +278 -0
- package/scripts/verify-template.mjs +407 -0
- package/settings.gradle +7 -0
- package/src/main/java/run/halo/plugintemplate/PluginTemplatePlugin.java +43 -0
- package/src/main/java/run/halo/plugintemplate/config/PluginTemplateConfig.java +14 -0
- package/src/main/java/run/halo/plugintemplate/dto/PluginTemplateChecklistItem.java +30 -0
- package/src/main/java/run/halo/plugintemplate/dto/PluginTemplateFeatureItem.java +30 -0
- package/src/main/java/run/halo/plugintemplate/dto/PluginTemplateOverview.java +73 -0
- package/src/main/java/run/halo/plugintemplate/dto/PluginTemplateStatItem.java +30 -0
- package/src/main/java/run/halo/plugintemplate/endpoint/PluginTemplateConsoleEndpoint.java +33 -0
- package/src/main/java/run/halo/plugintemplate/endpoint/PluginTemplatePublicEndpoint.java +26 -0
- package/src/main/java/run/halo/plugintemplate/endpoint/PluginTemplateUcEndpoint.java +33 -0
- package/src/main/java/run/halo/plugintemplate/endpoint/routes/PluginTemplateOverviewRoutes.java +60 -0
- package/src/main/java/run/halo/plugintemplate/model/PluginTemplateAudience.java +23 -0
- package/src/main/java/run/halo/plugintemplate/query/PluginTemplateOverviewQuery.java +26 -0
- package/src/main/java/run/halo/plugintemplate/reconcile/PluginTemplateSettingsReconciler.java +17 -0
- package/src/main/java/run/halo/plugintemplate/scheme/PluginTemplateRecord.java +43 -0
- package/src/main/java/run/halo/plugintemplate/service/PluginTemplateOverviewService.java +10 -0
- package/src/main/java/run/halo/plugintemplate/service/impl/PluginTemplateOverviewServiceImpl.java +74 -0
- package/src/main/java/run/halo/plugintemplate/setting/PluginTemplateGeneralSetting.java +25 -0
- package/src/main/java/run/halo/plugintemplate/setting/PluginTemplateSettingKeys.java +24 -0
- package/src/main/java/run/halo/plugintemplate/setting/PluginTemplateUiSetting.java +13 -0
- package/src/main/java/run/halo/plugintemplate/utils/PluginTemplateSeeds.java +197 -0
- package/src/main/resources/extensions/roleTemplate-console.yaml +39 -0
- package/src/main/resources/extensions/roleTemplate-uc.yaml +19 -0
- package/src/main/resources/extensions/settings.yaml +47 -0
- package/src/main/resources/logo.png +0 -0
- package/src/main/resources/plugin.yaml +24 -0
- package/src/test/java/run/halo/plugintemplate/PluginTemplatePluginTest.java +34 -0
- package/src/test/java/run/halo/plugintemplate/service/impl/PluginTemplateOverviewServiceImplTest.java +97 -0
- package/ui/build.gradle +41 -0
- package/ui/env.d.ts +2 -0
- package/ui/eslint.config.ts +30 -0
- package/ui/package.json +57 -0
- package/ui/pnpm-lock.yaml +5250 -0
- package/ui/src/api/__tests__/normalizers.spec.ts +65 -0
- package/ui/src/api/generated/.openapi-generator/FILES +23 -0
- package/ui/src/api/generated/.openapi-generator/VERSION +1 -0
- package/ui/src/api/generated/.openapi-generator-ignore +23 -0
- package/ui/src/api/generated/api/plugin-template-console-api.ts +128 -0
- package/ui/src/api/generated/api/plugin-template-uc-api.ts +128 -0
- package/ui/src/api/generated/api.ts +19 -0
- package/ui/src/api/generated/base.ts +86 -0
- package/ui/src/api/generated/common.ts +150 -0
- package/ui/src/api/generated/configuration.ts +110 -0
- package/ui/src/api/generated/git_push.sh +57 -0
- package/ui/src/api/generated/index.ts +18 -0
- package/ui/src/api/generated/models/add-operation.ts +49 -0
- package/ui/src/api/generated/models/copy-operation.ts +49 -0
- package/ui/src/api/generated/models/index.ts +11 -0
- package/ui/src/api/generated/models/json-patch-inner.ts +41 -0
- package/ui/src/api/generated/models/move-operation.ts +49 -0
- package/ui/src/api/generated/models/plugin-template-checklist-item.ts +54 -0
- package/ui/src/api/generated/models/plugin-template-feature-item.ts +54 -0
- package/ui/src/api/generated/models/plugin-template-overview.ts +147 -0
- package/ui/src/api/generated/models/plugin-template-stat-item.ts +54 -0
- package/ui/src/api/generated/models/remove-operation.ts +43 -0
- package/ui/src/api/generated/models/replace-operation.ts +49 -0
- package/ui/src/api/generated/models/test-operation.ts +49 -0
- package/ui/src/api/index.ts +42 -0
- package/ui/src/api/normalizers.ts +65 -0
- package/ui/src/assets/element.scss +24 -0
- package/ui/src/assets/index.css +361 -0
- package/ui/src/assets/logo.svg +1 -0
- package/ui/src/components/PluginTemplateAttachmentTab.vue +69 -0
- package/ui/src/components/PluginTemplateCommonTable.vue +69 -0
- package/ui/src/components/PluginTemplateDashboardWidget.vue +62 -0
- package/ui/src/components/PluginTemplateOverviewPage.vue +254 -0
- package/ui/src/components/ui/PluginUiProvider.vue +40 -0
- package/ui/src/components/ui/UiMetricCard.vue +21 -0
- package/ui/src/components/ui/UiSectionCard.vue +25 -0
- package/ui/src/components/ui/UiStatusPill.vue +18 -0
- package/ui/src/composables/useTemplateOverview.ts +38 -0
- package/ui/src/index.ts +88 -0
- package/ui/src/lib/__tests__/plugin-ui.spec.ts +19 -0
- package/ui/src/lib/plugin-ui.ts +19 -0
- package/ui/src/lib/template.spec.ts +24 -0
- package/ui/src/lib/template.ts +52 -0
- package/ui/src/lib/theme.ts +31 -0
- package/ui/src/types/index.ts +59 -0
- package/ui/src/views/console/ConsoleDashboardView.vue +7 -0
- package/ui/src/views/uc/UcDashboardView.vue +7 -0
- package/ui/tsconfig.app.json +12 -0
- package/ui/tsconfig.json +14 -0
- package/ui/tsconfig.node.json +15 -0
- package/ui/tsconfig.vitest.json +11 -0
- package/ui/vite.config.ts +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# Halo Plugin Template
|
|
2
|
+
|
|
3
|
+
通用的 Halo 插件开发模板,基于官方 `pnpm create halo-plugin` 的 Vite 预设收敛而成。
|
|
4
|
+
|
|
5
|
+
这个模板默认提供:
|
|
6
|
+
|
|
7
|
+
- Java 21 + Halo Plugin DevTools 基线
|
|
8
|
+
- `@halo-dev/ui-shared` + `@halo-dev/components` + Element Plus 的 UI 组合
|
|
9
|
+
- Console / UC 路由骨架
|
|
10
|
+
- 仪表盘小部件、快速操作项、附件选择器扩展点示例
|
|
11
|
+
- `settings.yaml`、Console/UC 角色模板、OpenAPI 客户端生成配置
|
|
12
|
+
- 已接线的 `ui/src/api/generated` + `ui/src/api/index.ts` API 包装层
|
|
13
|
+
- 一次性初始化脚本,用于批量改插件名、包名、权限前缀和仓库信息
|
|
14
|
+
|
|
15
|
+
## 环境要求
|
|
16
|
+
|
|
17
|
+
- Java 21+
|
|
18
|
+
- Node.js 22+
|
|
19
|
+
- pnpm 10+
|
|
20
|
+
- Docker(推荐,用于 `haloServer`)
|
|
21
|
+
|
|
22
|
+
## 快速开始
|
|
23
|
+
|
|
24
|
+
推荐直接用一键脚本从当前模板创建新项目目录:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
node scripts/create-project.mjs \
|
|
28
|
+
--plugin-name hello-world \
|
|
29
|
+
--base-package com.example.helloworld \
|
|
30
|
+
--display-name "Hello World" \
|
|
31
|
+
--author-name "Your Name" \
|
|
32
|
+
--target-dir ../hello-world \
|
|
33
|
+
--install \
|
|
34
|
+
--build
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
这个脚本会自动完成:
|
|
38
|
+
|
|
39
|
+
- 复制模板到目标目录
|
|
40
|
+
- 执行 `init-template.mjs`
|
|
41
|
+
- 执行 `verify-template.mjs`
|
|
42
|
+
- 可选安装前端依赖
|
|
43
|
+
- 可选执行 `./gradlew build`
|
|
44
|
+
|
|
45
|
+
如果你已经手工复制好了目录,再使用下面的初始化方式也可以。
|
|
46
|
+
|
|
47
|
+
如果你后续把这个模板发布成 npm 的 `create-*` 包,还可以直接远程一键创建:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm create halo-plugin-template@latest -- \
|
|
51
|
+
--plugin-name hello-world \
|
|
52
|
+
--base-package com.example.helloworld \
|
|
53
|
+
--display-name "Hello World" \
|
|
54
|
+
--author-name "Your Name"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
发布说明见 [docs/publish-template.md](./docs/publish-template.md)。
|
|
58
|
+
首发操作清单见 [docs/first-npm-release-checklist.md](./docs/first-npm-release-checklist.md)。
|
|
59
|
+
|
|
60
|
+
当前 GitHub 仓库名和 unscoped npm 包名统一为 `create-halo-plugin-template`,便于后续维护和分发。
|
|
61
|
+
|
|
62
|
+
如果你要在发布前做一次完整自检,直接执行:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm run publish:check
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
如果你要准备一个新版本发布,可以直接执行:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm run release:prepare -- --bump patch
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
如果你已经在 npm 侧配置好了 Trusted Publishing,并且希望本地完成检查、提交、打 tag、推送一条龙:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm run release:prepare -- --bump patch --push
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
这条命令会自动:
|
|
81
|
+
|
|
82
|
+
- 校验当前分支必须是 `main`
|
|
83
|
+
- 校验工作区必须是干净状态
|
|
84
|
+
- 更新根目录 `package.json` 的版本号
|
|
85
|
+
- 执行 `npm run publish:check`
|
|
86
|
+
- 创建 `chore: release vX.Y.Z` 提交
|
|
87
|
+
- 创建 `vX.Y.Z` tag
|
|
88
|
+
- 可选推送 `main` 和 tag
|
|
89
|
+
|
|
90
|
+
仓库当前使用 `push tag -> publish-npm.yaml` 的方式触发 npm 发布。
|
|
91
|
+
|
|
92
|
+
先运行初始化脚本,把模板占位符替换成你的插件信息:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
node scripts/init-template.mjs \
|
|
96
|
+
--plugin-name hello-world \
|
|
97
|
+
--base-package com.example.helloworld \
|
|
98
|
+
--display-name "Hello World" \
|
|
99
|
+
--author-name "Your Name" \
|
|
100
|
+
--author-website "https://github.com/your-name" \
|
|
101
|
+
--repo-owner your-name \
|
|
102
|
+
--description "Hello World - Halo 插件"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
这个脚本是一次性的。执行后会连同自身模板常量一起改写,确保生成出来的项目里不再残留模板占位符。
|
|
106
|
+
|
|
107
|
+
初始化完成后,马上执行一次模板一致性检查:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
node scripts/verify-template.mjs \
|
|
111
|
+
--plugin-name hello-world \
|
|
112
|
+
--base-package com.example.helloworld \
|
|
113
|
+
--display-name "Hello World" \
|
|
114
|
+
--author-name "Your Name"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
然后安装前端依赖并启动开发环境:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
pnpm install --dir ui
|
|
121
|
+
./gradlew haloServer
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
如果只调试前端构建:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
cd ui
|
|
128
|
+
pnpm dev
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 常用命令
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# 构建插件
|
|
135
|
+
./gradlew build
|
|
136
|
+
|
|
137
|
+
# 后端单测
|
|
138
|
+
./gradlew test
|
|
139
|
+
|
|
140
|
+
# 一致性检查
|
|
141
|
+
node scripts/verify-template.mjs
|
|
142
|
+
|
|
143
|
+
# 前端检查
|
|
144
|
+
cd ui
|
|
145
|
+
pnpm verify
|
|
146
|
+
|
|
147
|
+
# 生成 OpenAPI 文档和 TS 客户端
|
|
148
|
+
cd ..
|
|
149
|
+
./gradlew generateApiClient
|
|
150
|
+
|
|
151
|
+
# 基于 OpenAPI 生成角色模板草稿
|
|
152
|
+
./gradlew generateRoleTemplates
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## 目录说明
|
|
156
|
+
|
|
157
|
+
- `src/main/java/`:后端骨架,按 `config / endpoint / query / service / scheme / reconcile / setting / utils` 分层
|
|
158
|
+
- `src/main/resources/extensions/`:插件设置和角色模板
|
|
159
|
+
- `ui/src/index.ts`:插件 UI 唯一注册入口
|
|
160
|
+
- `ui/src/components/ui/`:低层通用 UI 包装
|
|
161
|
+
- `ui/src/components/`:业务级共享组件
|
|
162
|
+
- `ui/src/api/index.ts`:前端唯一 API 包装出口
|
|
163
|
+
- `ui/src/api/generated/`:由 `generateApiClient` 生成并已接入的客户端代码
|
|
164
|
+
- `docs/rsbuild-switch.md`:从当前模板切换到 Rsbuild 的最小差异说明
|
|
165
|
+
- `docs/template-pruning.md`:初始化后如何裁剪模板能力的操作建议
|
|
166
|
+
|
|
167
|
+
## OpenAPI 与角色模板
|
|
168
|
+
|
|
169
|
+
模板已经预置了 `haloPlugin.openApi` 配置,默认会:
|
|
170
|
+
|
|
171
|
+
- 输出 OpenAPI 文档到 `api-docs/openapi/v3_0`
|
|
172
|
+
- 把生成的前端客户端输出到 `ui/src/api/generated`
|
|
173
|
+
- 为 `generateRoleTemplates` 提供基础输入
|
|
174
|
+
|
|
175
|
+
视图层不要直接写裸请求 URL,也不要直接 import 生成客户端,统一从 `ui/src/api/index.ts` 包装后再消费。
|
|
176
|
+
|
|
177
|
+
## 初始化后裁剪
|
|
178
|
+
|
|
179
|
+
主模板故意把 Console、UC、仪表盘、快捷操作、附件扩展和 PublicEndpoint 占位都带上了,方便你按需删减。
|
|
180
|
+
|
|
181
|
+
- 若只做 Console 插件,可删除 UC 路由、UC 角色模板和相关设置。
|
|
182
|
+
- 若不需要附件扩展或工作台小部件,可删除对应扩展点和配套组件。
|
|
183
|
+
- 具体裁剪顺序见 [docs/template-pruning.md](./docs/template-pruning.md)。
|
|
184
|
+
|
|
185
|
+
## Rsbuild
|
|
186
|
+
|
|
187
|
+
主模板只维护 Vite 版本。若需要切换到 Rsbuild,请参考 [docs/rsbuild-switch.md](./docs/rsbuild-switch.md)。
|
|
188
|
+
|
|
189
|
+
## 许可证
|
|
190
|
+
|
|
191
|
+
[GPL-3.0](./LICENSE)
|
package/build.gradle
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
plugins {
|
|
2
|
+
id 'java'
|
|
3
|
+
id "io.freefair.lombok" version "9.2.0"
|
|
4
|
+
id "run.halo.plugin.devtools" version "0.6.2"
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
group 'run.halo.plugintemplate'
|
|
8
|
+
|
|
9
|
+
ext {
|
|
10
|
+
haloPlatformVersion = '2.23.0'
|
|
11
|
+
javaReleaseVersion = 21
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
repositories {
|
|
15
|
+
mavenCentral()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
dependencies {
|
|
19
|
+
implementation platform("run.halo.tools.platform:plugin:$haloPlatformVersion")
|
|
20
|
+
compileOnly 'run.halo.app:api'
|
|
21
|
+
|
|
22
|
+
testImplementation 'run.halo.app:api'
|
|
23
|
+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
|
24
|
+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
test {
|
|
28
|
+
useJUnitPlatform()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
java {
|
|
32
|
+
toolchain {
|
|
33
|
+
languageVersion = JavaLanguageVersion.of(javaReleaseVersion)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
tasks.withType(JavaCompile).configureEach {
|
|
38
|
+
options.encoding = "UTF-8"
|
|
39
|
+
options.release = javaReleaseVersion
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
tasks.register('processUiResources', Copy) {
|
|
43
|
+
from project(':ui').layout.buildDirectory.dir('dist')
|
|
44
|
+
into layout.buildDirectory.dir('resources/main/console')
|
|
45
|
+
dependsOn project(':ui').tasks.named('assemble')
|
|
46
|
+
shouldRunAfter tasks.named('processResources')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
tasks.named('classes') {
|
|
50
|
+
dependsOn tasks.named('processUiResources')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
tasks.matching { it.name == 'haloServer' || it.name == 'createHaloContainer' }.configureEach {
|
|
54
|
+
dependsOn tasks.named('processUiResources')
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
tasks.named('generatePluginComponentsIdx') {
|
|
58
|
+
notCompatibleWithConfigurationCache('This task invokes "Task.project" at execution time, which is not supported with configuration cache.')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
tasks.register('verifyTemplateConsistency', Exec) {
|
|
62
|
+
group = 'verification'
|
|
63
|
+
description = 'Verify the starter repository or initialized plugin stays internally consistent'
|
|
64
|
+
commandLine 'node', 'scripts/verify-template.mjs'
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
tasks.named('check') {
|
|
68
|
+
dependsOn tasks.named('verifyTemplateConsistency')
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
halo {
|
|
72
|
+
version = '2.23'
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
haloPlugin {
|
|
76
|
+
openApi {
|
|
77
|
+
outputDir = file("$rootDir/api-docs/openapi/v3_0")
|
|
78
|
+
groupingRules {
|
|
79
|
+
templateApis {
|
|
80
|
+
displayName = 'Extension API for halo-plugin-template'
|
|
81
|
+
pathsToMatch = [
|
|
82
|
+
'/apis/console.halo-plugin-template.halo.run/v1alpha1/**',
|
|
83
|
+
'/apis/uc.halo-plugin-template.halo.run/v1alpha1/**'
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
groupedApiMappings = [
|
|
88
|
+
'/v3/api-docs/templateApis': 'templateApis.json'
|
|
89
|
+
]
|
|
90
|
+
generator {
|
|
91
|
+
outputDir = file("${projectDir}/ui/src/api/generated")
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
watchDomains {
|
|
96
|
+
uiSource {
|
|
97
|
+
files files('ui/src/', 'ui/vite.config.ts', 'ui/package.json')
|
|
98
|
+
}
|
|
99
|
+
pluginSource {
|
|
100
|
+
files files('src/main/java/', 'src/main/resources/')
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# First npm Release Checklist
|
|
2
|
+
|
|
3
|
+
适用于仓库:`liuyiwuqing/create-halo-plugin-template`
|
|
4
|
+
|
|
5
|
+
## 5 步完成首发
|
|
6
|
+
|
|
7
|
+
1. 登录 npm 并确认账号有发布权限:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm login
|
|
11
|
+
npm whoami
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
2. 在 npm 后台创建包 `create-halo-plugin-template` 的 Trusted Publisher,绑定:
|
|
15
|
+
|
|
16
|
+
- GitHub repository: `liuyiwuqing/create-halo-plugin-template`
|
|
17
|
+
- Workflow file: `.github/workflows/publish-npm.yaml`
|
|
18
|
+
- Environment: `npm`
|
|
19
|
+
|
|
20
|
+
3. 在本地主分支确认工作区干净:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
git checkout main
|
|
24
|
+
git pull --ff-only
|
|
25
|
+
git status --short
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
4. 准备并推送首个发布版本:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm run release:prepare -- --version 0.1.0 --push
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
如果首发版本号已经改过,按实际版本替换 `0.1.0`。
|
|
35
|
+
|
|
36
|
+
5. 到 GitHub Actions 查看 `Publish npm CLI` 工作流是否成功,并到 npm 验证包是否已发布:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm view create-halo-plugin-template version
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 失败时先检查什么
|
|
43
|
+
|
|
44
|
+
- npm Trusted Publisher 是否绑到了正确仓库和工作流文件
|
|
45
|
+
- GitHub Actions environment 是否叫 `npm`
|
|
46
|
+
- 本地是否在 `main` 分支
|
|
47
|
+
- 工作区是否有未提交改动
|
|
48
|
+
- 本地 tag 是否已经存在
|
|
49
|
+
|
|
50
|
+
## 首发后创建项目
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm create halo-plugin-template@latest -- \
|
|
54
|
+
--plugin-name hello-world \
|
|
55
|
+
--base-package com.example.helloworld \
|
|
56
|
+
--display-name "Hello World" \
|
|
57
|
+
--author-name "Your Name"
|
|
58
|
+
```
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Publish The Template CLI
|
|
2
|
+
|
|
3
|
+
这个模板仓库现在可以同时承担两种角色:
|
|
4
|
+
|
|
5
|
+
1. Halo 插件模板源码仓库
|
|
6
|
+
2. npm 上的 `create-*` 脚手架包
|
|
7
|
+
|
|
8
|
+
如果你现在就是要做首发,直接看 [first-npm-release-checklist.md](./first-npm-release-checklist.md)。
|
|
9
|
+
|
|
10
|
+
## 推荐发布方式
|
|
11
|
+
|
|
12
|
+
### 方案一:npm `create-*` 包
|
|
13
|
+
|
|
14
|
+
适合对外分发和一键创建:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm create halo-plugin-template@latest -- \
|
|
18
|
+
--plugin-name hello-world \
|
|
19
|
+
--base-package com.example.helloworld \
|
|
20
|
+
--display-name "Hello World" \
|
|
21
|
+
--author-name "Your Name"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
注意:
|
|
25
|
+
|
|
26
|
+
- 当前模板已经把 GitHub 仓库名和 npm 包名统一为 `create-halo-plugin-template`。
|
|
27
|
+
- 如果后续你还想再区分“源码仓库名”和“npm 包名”,优先考虑 scoped 包,而不是再拆回两套不一致命名。
|
|
28
|
+
- 如果你坚持让包名进一步品牌化,建议改成 scoped 包,例如 `@liuyiwuqing/create-halo-plugin-template`。
|
|
29
|
+
|
|
30
|
+
如果你改成 scoped 包名,例如 `@your-scope/create-halo-plugin-template`,对应命令建议写成:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm init @your-scope/halo-plugin-template@latest -- \
|
|
34
|
+
--plugin-name hello-world \
|
|
35
|
+
--base-package com.example.helloworld \
|
|
36
|
+
--display-name "Hello World" \
|
|
37
|
+
--author-name "Your Name"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 方案二:GitHub Template Repository
|
|
41
|
+
|
|
42
|
+
适合团队内部维护“源码基线”,但不适合交互式参数初始化。通常建议保留,用来承载源码和 PR 审核;npm 包只负责分发最新模板。
|
|
43
|
+
|
|
44
|
+
## 第一次发布前
|
|
45
|
+
|
|
46
|
+
1. 检查根目录 `package.json` 的 `name`、`version`、`description`、`homepage`、`repository`、`bugs` 是否仍然指向当前仓库。
|
|
47
|
+
当前模板已经按 `liuyiwuqing/create-halo-plugin-template` 预填。
|
|
48
|
+
2. 执行:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm run publish:check
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
3. 确认打包内容只包含模板和 CLI 所需文件。
|
|
55
|
+
4. 登录 npm:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm login
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
5. 在 npm 后台为包 `create-halo-plugin-template` 配置 Trusted Publisher,绑定:
|
|
62
|
+
|
|
63
|
+
- GitHub repository: `liuyiwuqing/create-halo-plugin-template`
|
|
64
|
+
- Workflow file: `.github/workflows/publish-npm.yaml`
|
|
65
|
+
- Environment: `npm`
|
|
66
|
+
|
|
67
|
+
## 发布命令
|
|
68
|
+
|
|
69
|
+
### 一键准备下个版本
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm run release:prepare -- --bump patch
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
这会自动完成版本号更新、发布前检查、提交和打 tag。
|
|
76
|
+
|
|
77
|
+
### 一键准备并推送发布
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npm run release:prepare -- --bump patch --push
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
这会在本地完成检查后直接推送 `main` 和 `vX.Y.Z` tag。
|
|
84
|
+
当前仓库使用 tag push 触发 [publish-npm.yaml](../.github/workflows/publish-npm.yaml),所以只要 npm Trusted Publishing 已经配置好,推送 tag 后就会自动发布。
|
|
85
|
+
|
|
86
|
+
### 手工发布
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npm publish
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### scoped 公共包手工发布
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npm publish --access public
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 指定版本号准备发布
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm run release:prepare -- --version 1.0.0
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
或者直接推送:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npm run release:prepare -- --version 1.0.0 --push
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## 持续发布建议
|
|
111
|
+
|
|
112
|
+
- GitHub 仓库继续作为模板源码主仓库。
|
|
113
|
+
- npm 包只跟模板版本,不跟具体业务插件版本混用。
|
|
114
|
+
- 每次模板有破坏性修改时,提升主版本号。
|
|
115
|
+
- 发布前至少执行:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
node scripts/verify-template.mjs
|
|
119
|
+
cd ui && pnpm verify
|
|
120
|
+
cd .. && ./gradlew build
|
|
121
|
+
npm pack --dry-run
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## CI 发布
|
|
125
|
+
|
|
126
|
+
如果你要做自动发布,优先用 npm Trusted Publishing,而不是长期有效的 npm token。
|
|
127
|
+
|
|
128
|
+
- 源码仓库推送 `v*` tag
|
|
129
|
+
- GitHub Actions 触发 [publish-npm.yaml](../.github/workflows/publish-npm.yaml) 工作流
|
|
130
|
+
- npm 侧配置 Trusted Publisher
|
|
131
|
+
|
|
132
|
+
Trusted Publisher 里要填写的工作流文件名必须和仓库里的一致,也就是 `publish-npm.yaml`。
|
|
133
|
+
|
|
134
|
+
另外,npm 官方目前要求 Trusted Publishing 使用 npm CLI `11.5.1+` 和 Node `22.14.0+`;工作流里已经显式升级到了这个版本线。
|
|
135
|
+
|
|
136
|
+
## 平台建议
|
|
137
|
+
|
|
138
|
+
- 对外开源分发:npm + GitHub Template Repository
|
|
139
|
+
- 团队内私有分发:GitHub Template Repository + GitHub Release tarball
|
|
140
|
+
- 需要固定版本初始化:npm 最方便,因为天然支持 `@latest` 或指定版本
|
|
141
|
+
|
|
142
|
+
## 当前仓库绑定
|
|
143
|
+
|
|
144
|
+
- GitHub owner: `liuyiwuqing`
|
|
145
|
+
- GitHub repository: `create-halo-plugin-template`
|
|
146
|
+
- npm package: `create-halo-plugin-template`
|
|
147
|
+
- Homepage: `https://github.com/liuyiwuqing/create-halo-plugin-template#readme`
|
|
148
|
+
- Issues: `https://github.com/liuyiwuqing/create-halo-plugin-template/issues`
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# 从 Vite 切换到 Rsbuild
|
|
2
|
+
|
|
3
|
+
这个模板只维护一套 Vite 主线。如果你的插件前端体量变大,或者希望切到 Rspack 生态,可以按下面的最小差异切换到 Rsbuild。
|
|
4
|
+
|
|
5
|
+
## 需要保留不动的部分
|
|
6
|
+
|
|
7
|
+
这些文件不用改:
|
|
8
|
+
|
|
9
|
+
- `build.gradle`
|
|
10
|
+
- `settings.gradle`
|
|
11
|
+
- `src/main/resources/plugin.yaml`
|
|
12
|
+
- `src/main/resources/extensions/*`
|
|
13
|
+
- `ui/src/index.ts`
|
|
14
|
+
- `ui/src/api/*`
|
|
15
|
+
|
|
16
|
+
模板里真正和 bundler 绑定的部分,只有 `ui/package.json` 与构建配置文件。
|
|
17
|
+
|
|
18
|
+
## 变更步骤
|
|
19
|
+
|
|
20
|
+
1. 替换 `ui/package.json` 的脚本与依赖
|
|
21
|
+
|
|
22
|
+
把:
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
"build-only": "vite build",
|
|
26
|
+
"dev": "vite build --watch --mode=development"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
替换成:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
"build-only": "rsbuild build",
|
|
33
|
+
"dev": "rsbuild build --watch --env-mode=development"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
把 `vite` 从 `devDependencies` 移除,新增:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
"@rsbuild/core": "^1.7.3",
|
|
40
|
+
"@rsbuild/plugin-sass": "^1.5.0"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
2. 新建 `ui/rsbuild.config.ts`
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { rsbuildConfig } from '@halo-dev/ui-plugin-bundler-kit'
|
|
47
|
+
import type { RsbuildConfig } from '@rsbuild/core'
|
|
48
|
+
import { pluginSass } from '@rsbuild/plugin-sass'
|
|
49
|
+
import Icons from 'unplugin-icons/rspack'
|
|
50
|
+
|
|
51
|
+
export default rsbuildConfig({
|
|
52
|
+
rsbuild: {
|
|
53
|
+
resolve: {
|
|
54
|
+
alias: {
|
|
55
|
+
'@': './src',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
plugins: [pluginSass()],
|
|
59
|
+
tools: {
|
|
60
|
+
rspack: {
|
|
61
|
+
plugins: [Icons({ compiler: 'vue3' })],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
}) as RsbuildConfig
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
3. 删除 `ui/vite.config.ts`
|
|
69
|
+
|
|
70
|
+
Rsbuild 启用后不再需要 Vite 配置文件。
|
|
71
|
+
|
|
72
|
+
## 验证
|
|
73
|
+
|
|
74
|
+
完成后执行:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pnpm install --dir ui
|
|
78
|
+
cd ui
|
|
79
|
+
pnpm build
|
|
80
|
+
pnpm dev
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
然后回到项目根目录执行:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
./gradlew build
|
|
87
|
+
./gradlew haloServer
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
如果你只是为了试验构建性能,不要复制第二套 `ui-*` 目录;保持一套模板源代码,只切 bundler。
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Template Pruning Guide
|
|
2
|
+
|
|
3
|
+
这个 starter 预置的是“可删减的上限”,不是要求每个插件都把所有模块保留下来。
|
|
4
|
+
|
|
5
|
+
## 建议保留
|
|
6
|
+
|
|
7
|
+
- `src/main/resources/plugin.yaml`、`settings.yaml`、角色模板:这是 Halo 插件最稳定的元数据骨架。
|
|
8
|
+
- `ui/src/index.ts`:继续作为唯一 UI 注册出口,避免路由、扩展点和权限定义分散。
|
|
9
|
+
- `ui/src/api/index.ts`:所有前端请求统一经过这一层,不要在页面里直连生成客户端或裸 URL。
|
|
10
|
+
- `scripts/init-template.mjs` 和 `scripts/verify-template.mjs`:一个负责初始化,一个负责验收,后续孵化多个插件时都能复用。
|
|
11
|
+
|
|
12
|
+
## 按需删除
|
|
13
|
+
|
|
14
|
+
- 不需要 User Center 时:
|
|
15
|
+
删除 `PluginTemplateUcEndpoint`、`roleTemplate-uc.yaml`、`ucRoutes` 和相关 `enableUcDashboard` 设置。
|
|
16
|
+
- 不需要附件扩展标签页时:
|
|
17
|
+
删除 `PluginTemplateAttachmentTab.vue`、`attachment:selector:create` 扩展点和 `enableAttachmentProvider` 设置。
|
|
18
|
+
- 不需要工作台小部件或快速操作时:
|
|
19
|
+
删除 `PluginTemplateDashboardWidget.vue`、`console:dashboard:*` 扩展点,以及对应权限项。
|
|
20
|
+
- 不需要公共 API 时:
|
|
21
|
+
保留 `PluginTemplatePublicEndpoint.java` 作为占位即可,真正需要公开接口时再加 `@Component` 和路由。
|
|
22
|
+
|
|
23
|
+
## 增量开发顺序
|
|
24
|
+
|
|
25
|
+
1. 先补后端接口和 Springdoc 注解。
|
|
26
|
+
2. 执行 `./gradlew generateApiClient` 更新 `ui/src/api/generated/`。
|
|
27
|
+
3. 只在 `ui/src/api/index.ts` 暴露业务可用的 API 包装。
|
|
28
|
+
4. 页面和组件只依赖本地包装层,不直接引用生成客户端。
|
|
29
|
+
|
|
30
|
+
## 初始化后的最小验收
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
node scripts/verify-template.mjs \
|
|
34
|
+
--plugin-name hello-world \
|
|
35
|
+
--base-package com.example.helloworld \
|
|
36
|
+
--display-name "Hello World" \
|
|
37
|
+
--author-name "Your Name"
|
|
38
|
+
|
|
39
|
+
./gradlew build
|
|
40
|
+
cd ui && pnpm test:unit
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
如果模板已经剪裁过,只要 `verify-template.mjs` 和构建通过,就说明插件的基础边界仍然一致。
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
version=1.0.0-SNAPSHOT
|