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
17 changes: 17 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: CD

on:
release:
types:
- published

jobs:
cd:
uses: halo-sigs/reusable-workflows/.github/workflows/plugin-cd.yaml@v3
permissions:
contents: write
with:
pnpm-version: 9
node-version: 22
java-version: 21
skip-appstore-release: true
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +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@v3
with:
ui-path: "ui"
pnpm-version: 9
node-version: 22
java-version: 21
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# plugin-starter

Halo 2.0 插件开发快速开始模板。
Halo 2.x 插件开发快速开始模板。

## 开发环境

插件开发的详细文档请查阅:<https://docs.halo.run/developer-guide/plugin/introduction>

所需环境:

1. Java 17
1. JDK 21
2. Node 20
3. pnpm 9
4. Docker (可选)
Expand Down
42 changes: 17 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,56 +1,48 @@
plugins {
id 'java'
id "com.github.node-gradle.node" version "7.0.2"
id "io.freefair.lombok" version "8.0.1"
id "run.halo.plugin.devtools" version "0.2.0"
id "io.freefair.lombok" version "8.13"
id "run.halo.plugin.devtools" version "0.6.0"
}

group 'run.halo.starter'
sourceCompatibility = JavaVersion.VERSION_17

repositories {
mavenCentral()
maven { url 'https://s01.oss.sonatype.org/content/repositories/releases' }
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://repo.spring.io/milestone' }
}

dependencies {
implementation platform('run.halo.tools.platform:plugin:2.20.0-SNAPSHOT')
implementation platform('run.halo.tools.platform:plugin:2.21.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()
}

tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
}

node {
nodeProjectDir = file("${project.projectDir}/ui")
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']
tasks.register('processUiResources', Copy) {
from project(':ui').tasks.named('buildFrontend')
into layout.buildDirectory.dir('resources/main/console')
}

build {
// build frontend before build
tasks.named('compileJava').configure {
dependsOn('buildFrontend')
}
tasks.named('processResources', ProcessResources) {
dependsOn tasks.named('processUiResources')
}

halo {
version = '2.20'
version = '2.21'
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ pluginManagement {
}
}
rootProject.name = 'plugin-starter'

include 'ui'
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
name: starter
spec:
enabled: true
requires: ">=2.20.0"
requires: ">=2.21.0"
author:
name: Halo
website: https://github.com/halo-dev
Expand Down
24 changes: 24 additions & 0 deletions src/test/java/run/halo/starter/StarterPluginTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package run.halo.starter;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import run.halo.app.plugin.PluginContext;

@ExtendWith(MockitoExtension.class)
class StarterPluginTest {

@Mock
PluginContext context;

@InjectMocks
StarterPlugin plugin;

@Test
void contextLoads() {
plugin.start();
plugin.stop();
}
}
6 changes: 6 additions & 0 deletions ui/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"singleQuote": true,
"printWidth": 100
}
30 changes: 30 additions & 0 deletions ui/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
plugins {
id 'base'
id "com.github.node-gradle.node" version "7.1.0"
}

group 'run.halo.starter.ui'

tasks.register('buildFrontend', PnpmTask) {
args = ['build']
dependsOn tasks.named('pnpmInstall')
inputs.dir(layout.projectDirectory.dir('src'))
inputs.files(fileTree(
dir: layout.projectDirectory,
includes: ['*.cjs', '*.ts', '*.js', '*.json', '*.yaml']))
outputs.dir(layout.buildDirectory.dir('dist'))
shouldRunAfter(tasks.named('check'))
}

tasks.register('checkFrontend', PnpmTask) {
args = ['test:unit']
dependsOn tasks.named('pnpmInstall')
}

tasks.named('check') {
dependsOn tasks.named('checkFrontend')
}

tasks.named('build') {
dependsOn tasks.named('buildFrontend')
}
20 changes: 11 additions & 9 deletions ui/package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
{
"type": "module",
"scripts": {
"dev": "vite build --watch --mode=development",
"build": "run-p type-check \"build-only {@}\" --",
"build-only": "vite build",
"test:unit": "vitest",
"type-check": "vue-tsc --build --force",
"dev": "vite build --watch --mode=development",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"prettier": "prettier --write src/"
"prettier": "prettier --write src/",
"test:unit": "vitest --passWithNoTests",
"type-check": "vue-tsc --build --force"
},
"dependencies": {
"@halo-dev/api-client": "^2.17.0",
"@halo-dev/components": "^2.17.0",
"@halo-dev/console-shared": "^2.17.0",
"@halo-dev/api-client": "^2.21.0",
"@halo-dev/components": "^2.21.0",
"@halo-dev/console-shared": "^2.21.0",
"axios": "^1.7.2",
"canvas-confetti": "^1.9.3",
"vue": "^3.4.31"
},
"devDependencies": {
"@halo-dev/ui-plugin-bundler-kit": "^2.17.0",
"@halo-dev/ui-plugin-bundler-kit": "^2.21.1",
"@iconify/json": "^2.2.224",
"@rushstack/eslint-patch": "^1.10.3",
"@tsconfig/node20": "^20.1.4",
Expand All @@ -40,5 +41,6 @@
"vite": "^5.3.2",
"vitest": "^1.6.0",
"vue-tsc": "^2.0.24"
}
},
"packageManager": "[email protected]+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c"
}
Loading