Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
10 changes: 6 additions & 4 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ on:

jobs:
cd:
uses: halo-sigs/reusable-workflows/.github/workflows/plugin-cd.yaml@v3
uses: halo-sigs/reusable-workflows/.github/workflows/plugin-cd.yaml@v5
secrets:
halo-pat: ${{ secrets.HALO_PAT }}
permissions:
contents: write
with:
node-version: "20"
pnpm-version: "9"
node-version: "24"
pnpm-version: "12"
java-version: "21"
app-id: app-DlacW
ui-path: "."
ui-path: "packages"
sync-github-readme: true
9 changes: 5 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ on:

jobs:
ci:
uses: halo-sigs/reusable-workflows/.github/workflows/plugin-ci.yaml@v1
uses: halo-sigs/reusable-workflows/.github/workflows/plugin-ci.yaml@v5
with:
node-version: "20"
pnpm-version: "9"
ui-path: "."
node-version: "24"
pnpm-version: "12"
java-version: "21"
ui-path: "packages"
15 changes: 10 additions & 5 deletions .github/workflows/release-npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ on:
jobs:
release:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-node@v4
- uses: actions/setup-node@v7
with:
node-version: lts/*
node-version: "24"
registry-url: https://registry.npmjs.org/
- uses: pnpm/action-setup@v4
- run: pnpm install
- uses: pnpm/action-setup@v6
with:
package_json_file: packages/package.json
- run: pnpm install --frozen-lockfile
- name: Upgrade npm
run: npm i -g npm@latest
- name: Publish to NPM
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ application-local.yml
application-local.yaml
application-local.properties

/packages/*/node_modules/
node_modules
.vitest/
/workplace/
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lint-staged
pnpm -C packages exec lint-staged
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Halo 2.0 的通用搜索组件插件。

## 开发环境

需要 Java 21、Node.js 24(最低 22.12)和 pnpm 12.10.1,插件运行环境为 Halo 2.26 及以上。

```bash
git clone git@github.com:halo-dev/plugin-search-widget.git

Expand All @@ -28,34 +30,35 @@ cd path/to/plugin-search-widget
```

```bash
./gradlew pnpmInstall

./gradlew build
```

修改 Halo 配置文件:

```yaml
halo:
plugin:
runtime-mode: development
classes-directories:
- "build/classes"
- "build/resources"
lib-directories:
- "libs"
fixedPluginPath:
- "/path/to/plugin-search-widget"
`packages` 同时是 Gradle 子项目和 pnpm workspace。Gradle 会自动安装依赖、按包间依赖顺序构建前端,并将 `packages/widget/build/dist` 复制到 `build/resources/main/static`,最后打包到插件 JAR。前端构建不会写入 `src/main/resources`。

启动用于开发的 Halo(需要 Docker):

```bash
./gradlew haloServer
```

单独构建前端或启动搜索组件示例:

```bash
pnpm -C packages install --frozen-lockfile
pnpm -C packages build
pnpm -C packages example:dev
```

代码检查使用 `pnpm -C packages check`,自动修复使用 `pnpm -C packages check:fix`。`./gradlew clean` 会同时清理插件和前端构建产物。

### 运行测试

测试使用 Vitest Browser Mode 和 Playwright Chromium,建议使用 Node.js 24。首次运行前安装依赖和浏览器:

```bash
pnpm install --frozen-lockfile
pnpm -C packages install --frozen-lockfile
pnpm -C packages/search-widget exec playwright install chromium
pnpm test
pnpm -C packages test
```

测试直接加载组件源码,无需启动 Halo 或手动打开测试页面。
Expand Down
51 changes: 32 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,49 +1,62 @@
plugins {
id 'java'
id "io.freefair.lombok" version "8.0.1"
id "com.github.node-gradle.node" version "7.0.2"
id "run.halo.plugin.devtools" version "0.1.1"
id "io.freefair.lombok" version "9.2.0"
id "com.github.node-gradle.node" version "7.1.0" apply false
id "run.halo.plugin.devtools" version "0.8.0"
}

group 'run.halo.search.widget'
sourceCompatibility = JavaVersion.VERSION_17
group = 'run.halo.search.widget'

repositories {
mavenCentral()
}

dependencies {
implementation platform('run.halo.tools.platform:plugin:2.20.11')
implementation platform('run.halo.tools.platform:plugin:2.26.0')
compileOnly 'run.halo.app:api'

testImplementation 'run.halo.app:api'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

test {
useJUnitPlatform()
}

node {
nodeProjectDir = file("${project.projectDir}")
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

tasks.register('buildFrontend', PnpmTask) {
args = ['build']
dependsOn('installDepsForUI')
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.release = 21
}

tasks.register('installDepsForUI', PnpmTask) {
args = ['install']
}
sourceSets.main.resources.exclude 'static/**'

tasks.named('processResources', Copy) {
dependsOn ':packages:pnpmBuild'

from(project(':packages').layout.projectDirectory.dir('widget/build/dist')) {
into 'static'
}

build {
// build frontend before build
tasks.named('compileJava').configure {
dependsOn('buildFrontend')
doFirst {
delete layout.buildDirectory.dir('resources/main/static')
}
}

tasks.named('clean') {
dependsOn ':packages:clean'
}

tasks.named('generatePluginComponentsIdx') {
notCompatibleWithConfigurationCache('This task invokes "Task.project" at execution time, which is not supported with configuration cache.')
}

halo {
version = "2.21"
version = "2.26"
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
40 changes: 22 additions & 18 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading