Skip to content

halo-dev/create-halo-plugin

Repository files navigation

create-halo-plugin

English | ็ฎ€ไฝ“ไธญๆ–‡

๐Ÿš€ Quickly create Halo plugin development templates

A scaffolding tool for creating Halo plugin projects with modern development setup.

Features

  • ๐ŸŽฏ Interactive CLI - Guided project setup with prompts
  • ๐Ÿ—๏ธ Modern Build Tools - Choose between Vite or Rsbuild for UI development
  • ๐Ÿ“ฆ Complete Project Structure - Pre-configured Gradle build, UI setup, and plugin manifest
  • ๐Ÿ“ TypeScript Support - Full TypeScript configuration for UI development

Quick Start

Create a new Halo plugin project using any of the following commands:

# npm
npm create halo-plugin
npm create halo-plugin my-plugin

# pnpm (recommended)
pnpm create halo-plugin
pnpm create halo-plugin my-plugin

# yarn
yarn create halo-plugin
yarn create halo-plugin my-plugin

# npx
npx create-halo-plugin
npx create-halo-plugin my-plugin

Usage Examples

Create with auto-generated directory name

pnpm create halo-plugin
# Creates a directory named "plugin-{your-plugin-name}"

Create in a specific directory

pnpm create halo-plugin my-awesome-plugin
# Creates the project in "./my-awesome-plugin" directory

Interactive Setup

The CLI will guide you through the setup process:

๐Ÿš€ Welcome to Halo Plugin Creator!

โœ” Plugin name: โ€บ my-awesome-plugin
โœ” Domain (for group and package name): โ€บ com.example
โœ” Author name: โ€บ John Doe
โœ” Include UI project? โ€บ yes
โœ” Choose UI build tool: โ€บ Vite

๐Ÿ“‹ Project Configuration:
   Name: my-awesome-plugin
   Domain: com.example
   Package: com.example.myawesomeplugin
   Author: John Doe
   Include UI: Yes
   UI Tool: vite
   Output Directory: /path/to/my-awesome-plugin

โœ” Create project? โ€บ yes

Creating Backend-Only Plugins

If your plugin doesn't need a user interface, you can skip UI project creation via command line:

pnpm create halo-plugin my-backend-plugin --name=my-backend-plugin --domain=com.example --author="John Doe" --includeUI=false

Or select "no" when prompted to include a UI project during interactive setup.

Project Structure

Full Project with UI

my-plugin/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main/
โ”‚   โ”‚   โ”œโ”€โ”€ java/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ com/example/myplugin/
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ MyPluginPlugin.java
โ”‚   โ”‚   โ””โ”€โ”€ resources/
โ”‚   โ”‚       โ”œโ”€โ”€ plugin.yaml
โ”‚   โ”‚       โ””โ”€โ”€ logo.png
โ”‚   โ””โ”€โ”€ test/
โ”‚       โ””โ”€โ”€ java/
โ”‚           โ””โ”€โ”€ com/example/myplugin/
โ”‚               โ””โ”€โ”€ MyPluginPluginTest.java
โ”œโ”€โ”€ ui/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ index.ts
โ”‚   โ”‚   โ”œโ”€โ”€ views/
โ”‚   โ”‚   โ””โ”€โ”€ assets/
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ”œโ”€โ”€ vite.config.ts (or rsbuild.config.ts)
โ”‚   โ””โ”€โ”€ tsconfig.json
โ”œโ”€โ”€ build.gradle
โ”œโ”€โ”€ settings.gradle
โ”œโ”€โ”€ gradlew
โ””โ”€โ”€ README.md

Backend-Only Project (without UI)

my-plugin/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main/
โ”‚   โ”‚   โ”œโ”€โ”€ java/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ com/example/myplugin/
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ MyPluginPlugin.java
โ”‚   โ”‚   โ””โ”€โ”€ resources/
โ”‚   โ”‚       โ”œโ”€โ”€ plugin.yaml
โ”‚   โ”‚       โ””โ”€โ”€ logo.png
โ”‚   โ””โ”€โ”€ test/
โ”‚       โ””โ”€โ”€ java/
โ”‚           โ””โ”€โ”€ com/example/myplugin/
โ”‚               โ””โ”€โ”€ MyPluginPluginTest.java
โ”œโ”€โ”€ build.gradle
โ”œโ”€โ”€ settings.gradle
โ”œโ”€โ”€ gradlew
โ””โ”€โ”€ README.md

Development

Projects with UI

After creating your project:

# Navigate to your project
cd my-plugin

# Start Halo development server
./gradlew haloServer

# In another terminal, start UI development
cd ui
pnpm dev

Backend-Only Projects

For projects without UI:

# Navigate to your project
cd my-plugin

# Start Halo development server
./gradlew haloServer

Requirements

  • Node.js >= 18.0.0
  • Java >= 21
  • Halo >= 2.21.0

Plugin Name Rules

Plugin names must follow this pattern:

  • Start and end with alphanumeric characters (a-z, 0-9)
  • Can contain hyphens (-) and dots (.) in the middle
  • Only lowercase letters allowed
  • Examples: my-plugin, blog.comment, user-management

UI Build Tools

Choose between two modern build tools:

Vite

  • ๐Ÿ”ง Simple configuration
  • ๐Ÿ“ฆ Optimized builds

Rsbuild

  • ๐Ÿš€ Rspack-based for speed
  • ๐Ÿ› ๏ธ Rich plugin ecosystem
  • ๐Ÿ“Š Better build performance
  • ๐Ÿ“ฆ Code splitting, suitable for larger plugin projects

Command Line Options

# Show help
npx create-halo-plugin --help

# Show version
npx create-halo-plugin --version

# Create project with command line arguments
npx create-halo-plugin my-plugin \
  --name=my-plugin \
  --domain=com.example \
  --author="John Doe" \
  --includeUI \
  --uiTool=rsbuild

# Create backend-only project
npx create-halo-plugin my-backend-plugin \
  --name=my-backend-plugin \
  --domain=com.example \
  --author="John Doe" \
  --includeUI=false

Available options:

  • -n, --name <name> - Plugin name
  • -d, --domain <domain> - Domain for group and package name
  • -a, --author <author> - Author name
  • -i, --includeUI - Include UI project
  • -u, --uiTool <tool> - UI build tool (rsbuild or vite, required when includeUI is true)
  • -h, --help - Show help message
  • -v, --version - Show version number

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

GPL-3.0 ยฉ Halo

Related

About

Quickly create Halo plugin development templates

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •