mirror of
https://github.com/halo-dev/plugin-starter.git
synced 2025-10-15 07:32:12 +00:00
Refactor build scripts and workflows (#52)
* Refactor build scripts and workflows * Add a unit test sample * chore: bump @halo-dev/ui-plugin-bundler-kit version Signed-off-by: Ryan Wang <i@ryanc.cc> --------- Signed-off-by: Ryan Wang <i@ryanc.cc> Co-authored-by: Ryan Wang <i@ryanc.cc>
This commit is contained in:
17
.github/workflows/cd.yaml
vendored
Normal file
17
.github/workflows/cd.yaml
vendored
Normal file
@@ -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
.github/workflows/ci.yaml
vendored
5
.github/workflows/ci.yaml
vendored
@@ -10,6 +10,9 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
uses: halo-sigs/reusable-workflows/.github/workflows/plugin-ci.yaml@v1
|
uses: halo-sigs/reusable-workflows/.github/workflows/plugin-ci.yaml@v3
|
||||||
with:
|
with:
|
||||||
ui-path: "ui"
|
ui-path: "ui"
|
||||||
|
pnpm-version: 9
|
||||||
|
node-version: 22
|
||||||
|
java-version: 21
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# plugin-starter
|
# plugin-starter
|
||||||
|
|
||||||
Halo 2.0 插件开发快速开始模板。
|
Halo 2.x 插件开发快速开始模板。
|
||||||
|
|
||||||
## 开发环境
|
## 开发环境
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ Halo 2.0 插件开发快速开始模板。
|
|||||||
|
|
||||||
所需环境:
|
所需环境:
|
||||||
|
|
||||||
1. Java 17
|
1. JDK 21
|
||||||
2. Node 20
|
2. Node 20
|
||||||
3. pnpm 9
|
3. pnpm 9
|
||||||
4. Docker (可选)
|
4. Docker (可选)
|
||||||
|
42
build.gradle
42
build.gradle
@@ -1,56 +1,48 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id "com.github.node-gradle.node" version "7.0.2"
|
id "io.freefair.lombok" version "8.13"
|
||||||
id "io.freefair.lombok" version "8.0.1"
|
id "run.halo.plugin.devtools" version "0.6.0"
|
||||||
id "run.halo.plugin.devtools" version "0.2.0"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'run.halo.starter'
|
group 'run.halo.starter'
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
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 {
|
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'
|
compileOnly 'run.halo.app:api'
|
||||||
|
|
||||||
testImplementation 'run.halo.app:api'
|
testImplementation 'run.halo.app:api'
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
|
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion = JavaLanguageVersion.of(21)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
|
options.release = 21
|
||||||
}
|
}
|
||||||
|
|
||||||
node {
|
tasks.register('processUiResources', Copy) {
|
||||||
nodeProjectDir = file("${project.projectDir}/ui")
|
from project(':ui').tasks.named('buildFrontend')
|
||||||
|
into layout.buildDirectory.dir('resources/main/console')
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register('buildFrontend', PnpmTask) {
|
tasks.named('processResources', ProcessResources) {
|
||||||
args = ['build']
|
dependsOn tasks.named('processUiResources')
|
||||||
dependsOn('installDepsForUI')
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register('installDepsForUI', PnpmTask) {
|
|
||||||
args = ['install']
|
|
||||||
}
|
|
||||||
|
|
||||||
build {
|
|
||||||
// build frontend before build
|
|
||||||
tasks.named('compileJava').configure {
|
|
||||||
dependsOn('buildFrontend')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
halo {
|
halo {
|
||||||
version = '2.20'
|
version = '2.21'
|
||||||
}
|
}
|
||||||
|
@@ -4,4 +4,4 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
rootProject.name = 'plugin-starter'
|
rootProject.name = 'plugin-starter'
|
||||||
|
include 'ui'
|
||||||
|
@@ -7,7 +7,7 @@ metadata:
|
|||||||
name: starter
|
name: starter
|
||||||
spec:
|
spec:
|
||||||
enabled: true
|
enabled: true
|
||||||
requires: ">=2.20.0"
|
requires: ">=2.21.0"
|
||||||
author:
|
author:
|
||||||
name: Halo
|
name: Halo
|
||||||
website: https://github.com/halo-dev
|
website: https://github.com/halo-dev
|
||||||
|
24
src/test/java/run/halo/starter/StarterPluginTest.java
Normal file
24
src/test/java/run/halo/starter/StarterPluginTest.java
Normal file
@@ -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
ui/.prettierrc.json
Normal file
6
ui/.prettierrc.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/prettierrc",
|
||||||
|
"semi": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"printWidth": 100
|
||||||
|
}
|
30
ui/build.gradle
Normal file
30
ui/build.gradle
Normal file
@@ -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')
|
||||||
|
}
|
@@ -1,23 +1,24 @@
|
|||||||
{
|
{
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite build --watch --mode=development",
|
|
||||||
"build": "run-p type-check \"build-only {@}\" --",
|
"build": "run-p type-check \"build-only {@}\" --",
|
||||||
"build-only": "vite build",
|
"build-only": "vite build",
|
||||||
"test:unit": "vitest",
|
"dev": "vite build --watch --mode=development",
|
||||||
"type-check": "vue-tsc --build --force",
|
|
||||||
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
"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": {
|
"dependencies": {
|
||||||
"@halo-dev/api-client": "^2.17.0",
|
"@halo-dev/api-client": "^2.21.0",
|
||||||
"@halo-dev/components": "^2.17.0",
|
"@halo-dev/components": "^2.21.0",
|
||||||
"@halo-dev/console-shared": "^2.17.0",
|
"@halo-dev/console-shared": "^2.21.0",
|
||||||
"axios": "^1.7.2",
|
"axios": "^1.7.2",
|
||||||
"canvas-confetti": "^1.9.3",
|
"canvas-confetti": "^1.9.3",
|
||||||
"vue": "^3.4.31"
|
"vue": "^3.4.31"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@halo-dev/ui-plugin-bundler-kit": "^2.17.0",
|
"@halo-dev/ui-plugin-bundler-kit": "^2.21.1",
|
||||||
"@iconify/json": "^2.2.224",
|
"@iconify/json": "^2.2.224",
|
||||||
"@rushstack/eslint-patch": "^1.10.3",
|
"@rushstack/eslint-patch": "^1.10.3",
|
||||||
"@tsconfig/node20": "^20.1.4",
|
"@tsconfig/node20": "^20.1.4",
|
||||||
@@ -40,5 +41,6 @@
|
|||||||
"vite": "^5.3.2",
|
"vite": "^5.3.2",
|
||||||
"vitest": "^1.6.0",
|
"vitest": "^1.6.0",
|
||||||
"vue-tsc": "^2.0.24"
|
"vue-tsc": "^2.0.24"
|
||||||
}
|
},
|
||||||
|
"packageManager": "pnpm@9.15.0+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c"
|
||||||
}
|
}
|
||||||
|
1027
ui/pnpm-lock.yaml
generated
1027
ui/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,17 @@
|
|||||||
import { fileURLToPath, URL } from "url";
|
import { fileURLToPath, URL } from "url";
|
||||||
|
|
||||||
import { HaloUIPluginBundlerKit } from "@halo-dev/ui-plugin-bundler-kit";
|
import { viteConfig } from "@halo-dev/ui-plugin-bundler-kit";
|
||||||
import Vue from "@vitejs/plugin-vue";
|
|
||||||
import Icons from "unplugin-icons/vite";
|
import Icons from "unplugin-icons/vite";
|
||||||
import { defineConfig } from "vite";
|
|
||||||
|
|
||||||
export default defineConfig({
|
// For more info,
|
||||||
plugins: [Vue(), Icons({ compiler: "vue3" }), HaloUIPluginBundlerKit()],
|
// please see https://github.com/halo-dev/halo/tree/main/ui/packages/ui-plugin-bundler-kit
|
||||||
|
export default viteConfig({
|
||||||
|
vite: {
|
||||||
|
plugins: [Icons({ compiler: "vue3" })],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user