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
6 changes: 5 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Lint

on: [push]
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
lint:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASER_TOKEN }}
11 changes: 0 additions & 11 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ builds:
- -X 'github.com/pubgo/funk/version.project=protobuild'
- -X 'github.com/pubgo/funk/version.buildTime={{ .CommitDate }}'
- -X 'github.com/pubgo/funk/version.commitID={{ .ShortCommit }}'
- main: ./cmd/protoc-gen-retag/main.go
id: protoc-gen-retag
binary: protoc-gen-retag
skip: false
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
archives:
- name_template: "{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
format: binary
Expand Down
2 changes: 1 addition & 1 deletion .version/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.0.29
v0.1.1
92 changes: 91 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
- ⚙️ **Configuration-driven** - YAML-based project configuration
- 📊 **Progress Display** - Visual progress bars and detailed error messages
- 🗑️ **Cache Management** - Clean and manage dependency cache
- 🌐 **Web UI** - Visual configuration editor with proto file browser
- 🏥 **Environment Check** - Doctor command to diagnose development environment
- 🎯 **Project Initialization** - Quick project setup with templates

## Installation

Expand Down Expand Up @@ -71,8 +74,14 @@ protobuild gen
| `format -w` | Format and write changes to files |
| `format --diff` | Show diff of formatting changes |
| `format --builtin` | Use builtin formatter instead of buf |
| `web` | Start web-based configuration UI |
| `web --port 9090` | Start web UI on custom port |
| `clean` | Clean dependency cache |
| `clean --dry-run` | Show what would be cleaned without deleting |
| `init` | Initialize a new protobuild project |
| `init --template grpc` | Initialize with specific template (basic, grpc, minimal) |
| `doctor` | Check development environment and dependencies |
| `doctor --fix` | Auto-install missing Go plugins |
| `version` | Show version information |

## Configuration
Expand Down Expand Up @@ -238,6 +247,69 @@ protobuild format --builtin
protobuild format -w proto/ api/
```

### Web Configuration UI

```bash
# Start web UI on default port (8080)
protobuild web

# Start web UI on custom port
protobuild web --port 9090
```

The web interface provides:
- 📝 Visual configuration editor
- 📦 Dependency management
- 🔌 Plugin configuration
- 🚀 One-click build, lint, format operations
- 📄 Real-time YAML preview
- 📊 Project statistics dashboard
- 🔍 Proto file browser with syntax highlighting
- 📚 Configuration examples reference

### Initialize New Project

```bash
# Interactive initialization
protobuild init

# Use specific template
protobuild init --template basic # Basic Go + gRPC project
protobuild init --template grpc # Full gRPC-Gateway project
protobuild init --template minimal # Minimal configuration

# Specify output directory
protobuild init -o ./my-project
```

### Check Development Environment

```bash
# Diagnose environment issues
protobuild doctor

# Auto-install missing Go plugins
protobuild doctor --fix
```

Example output:
```
🏥 Protobuild Doctor

Checking development environment...

✅ protoc installed (v25.1)
✅ protoc-gen-go installed
✅ protoc-gen-go-grpc installed
✅ buf installed (v1.28.1)
✅ api-linter installed
✅ go installed (go1.21.5)
✅ Configuration protobuf.yaml found
⚠️ Vendor directory not found (run 'protobuild vendor')

✅ Environment check passed!
```

### Force Vendor Update

```bash
Expand Down Expand Up @@ -339,7 +411,11 @@ protobuild
│ │ └── yaml_types.go # YAML type definitions
│ ├── format/ # Proto file formatting (builtin)
│ ├── formatcmd/ # Format command (buf integration)
│ └── linters/ # AIP linting rules
│ ├── linters/ # AIP linting rules
│ └── webcmd/ # Web configuration UI
│ ├── cmd.go # Web command entry
│ ├── server.go # HTTP server and API
│ └── templates/ # HTML templates (Alpine.js + Tailwind)
└── internal/
├── depresolver/ # Multi-source dependency resolver
├── modutil/ # Go module utilities
Expand All @@ -355,6 +431,20 @@ protobuild
- [Multi-Source Dependencies](./docs/MULTI_SOURCE_DEPS.md) - Design document for multi-source dependency resolution
- [Design Document](./docs/DESIGN.md) - Architecture and design documentation

## Roadmap

Upcoming features planned for future releases:

| Feature | Description | Status |
|---------|-------------|--------|
| 🔗 **Dependency Graph** | Visualize proto file import dependencies | Planned |
| ⚠️ **Breaking Change Detection** | Detect incompatible changes between versions | Planned |
| 📚 **API Documentation Generator** | Auto-generate Markdown/HTML docs from proto comments | Planned |
| 🎭 **Mock Server** | Auto-start mock gRPC/HTTP server for testing | Planned |
| 📝 **Proto Templates** | Quick generation of common proto patterns (CRUD, pagination) | Planned |
| 📊 **Field Statistics** | Analyze field naming conventions and type distribution | Planned |
| ✏️ **Online Editor** | Edit proto files directly in Web UI | Planned |

## License

[MIT License](LICENSE)
Expand Down
92 changes: 91 additions & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
- ⚙️ **配置驱动** - 基于 YAML 的项目配置
- 📊 **进度显示** - 可视化进度条和详细错误信息
- 🗑️ **缓存管理** - 清理和管理依赖缓存
- 🌐 **Web 界面** - 可视化配置编辑器,支持 Proto 文件浏览
- 🏥 **环境诊断** - Doctor 命令检查开发环境配置
- 🎯 **项目初始化** - 快速项目设置,支持多种模板

## 安装

Expand Down Expand Up @@ -72,8 +75,14 @@ protobuild gen
| `format --diff` | 显示格式化差异 |
| `format --exit-code` | 需要格式化时返回错误码(CI 适用)|
| `format --builtin` | 使用内置格式化器 |
| `web` | 启动 Web 配置管理界面 |
| `web --port 9090` | 指定端口启动 Web 界面 |
| `clean` | 清理依赖缓存 |
| `clean --dry-run` | 预览将被清理的内容 |
| `init` | 初始化新的 protobuild 项目 |
| `init --template grpc` | 使用指定模板初始化(basic、grpc、minimal)|
| `doctor` | 检查开发环境和依赖配置 |
| `doctor --fix` | 自动安装缺失的 Go 插件 |
| `version` | 显示版本信息 |

## 配置说明
Expand Down Expand Up @@ -239,6 +248,69 @@ protobuild format --builtin
protobuild format -w proto/ api/
```

### Web 配置管理界面

```bash
# 在默认端口 (8080) 启动 Web 界面
protobuild web

# 在指定端口启动 Web 界面
protobuild web --port 9090
```

Web 界面提供:
- 📝 可视化配置编辑器
- 📦 依赖管理
- 🔌 插件配置
- 🚀 一键执行构建、检查、格式化等操作
- 📄 实时 YAML 配置预览
- 📊 项目统计仪表盘
- 🔍 Proto 文件浏览器(支持语法高亮)
- 📚 配置示例参考

### 初始化新项目

```bash
# 交互式初始化
protobuild init

# 使用指定模板
protobuild init --template basic # 基础 Go + gRPC 项目
protobuild init --template grpc # 完整 gRPC-Gateway 项目
protobuild init --template minimal # 最小化配置

# 指定输出目录
protobuild init -o ./my-project
```

### 检查开发环境

```bash
# 诊断环境问题
protobuild doctor

# 自动安装缺失的 Go 插件
protobuild doctor --fix
```

输出示例:
```
🏥 Protobuild Doctor

正在检查开发环境...

✅ protoc 已安装 (v25.1)
✅ protoc-gen-go 已安装
✅ protoc-gen-go-grpc 已安装
✅ buf 已安装 (v1.28.1)
✅ api-linter 已安装
✅ go 已安装 (go1.21.5)
✅ 配置文件 已找到 protobuf.yaml
⚠️ Vendor 目录 未找到(请运行 'protobuild vendor')

✅ 环境检查通过!
```

### 强制更新 Vendor

```bash
Expand Down Expand Up @@ -330,6 +402,20 @@ plugins:
- [多源依赖设计](./docs/MULTI_SOURCE_DEPS.md) - 多源依赖解析设计文档
- [设计文档](./docs/DESIGN_CN.md) - 架构和设计文档

## 路线图

以下是计划在未来版本中实现的功能:

| 功能 | 描述 | 状态 |
|------|------|------|
| 🔗 **依赖关系图** | 可视化 proto 文件的 import 依赖关系 | 计划中 |
| ⚠️ **Breaking Change 检测** | 检测版本间的不兼容变更 | 计划中 |
| 📚 **API 文档生成** | 从 proto 注释自动生成 Markdown/HTML 文档 | 计划中 |
| 🎭 **Mock 服务器** | 自动启动用于测试的 mock gRPC/HTTP 服务器 | 计划中 |
| 📝 **Proto 模板** | 快速生成常用 proto 模式(CRUD、分页等)| 计划中 |
| 📊 **字段统计分析** | 分析字段命名规范和类型分布 | 计划中 |
| ✏️ **在线编辑器** | 在 Web 界面直接编辑 proto 文件 | 计划中 |

## 项目架构

```
Expand All @@ -346,7 +432,11 @@ protobuild
│ │ └── yaml_types.go # YAML 类型定义
│ ├── format/ # Proto 文件格式化(内置)
│ ├── formatcmd/ # 格式化命令(buf 集成)
│ └── linters/ # AIP 检查规则
│ ├── linters/ # AIP 检查规则
│ └── webcmd/ # Web 配置管理界面
│ ├── cmd.go # Web 命令入口
│ ├── server.go # HTTP 服务器和 API
│ └── templates/ # HTML 模板 (Alpine.js + Tailwind)
└── internal/
├── depresolver/ # 多源依赖解析器
├── modutil/ # Go 模块工具
Expand Down
4 changes: 4 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@ tasks:
- task: lint
- task: test
- task: build
web:
desc: Run web server
cmds:
- go run -v *.go web
9 changes: 7 additions & 2 deletions cmd/protobuild/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/pubgo/funk/running"
"github.com/pubgo/protobuild/cmd/formatcmd"
"github.com/pubgo/protobuild/cmd/linters"
"github.com/pubgo/protobuild/cmd/webcmd"
"github.com/pubgo/protobuild/internal/shutil"
"github.com/pubgo/protobuild/internal/typex"
"github.com/pubgo/redant"
Expand Down Expand Up @@ -72,13 +73,16 @@ func Main(ver string) *redant.Command {
},
Handler: handleStdinPlugin,
Children: typex.Commands{
newInitCommand(),
newDoctorCommand(),
newGenCommand(),
newVendorCommand(&force, &update),
newInstallCommand(&force),
newLintCommand(cliArgs, options),
newFormatCommand(),
newDepsCommand(),
newCleanCommand(&dryRun),
webcmd.New(&protoCfg),
newVersionCommand(),
},
}
Expand Down Expand Up @@ -201,7 +205,7 @@ func installPlugin(plg string, force bool) {
slog.Error("command not found", slog.Any("name", plgName))
}

if err == nil && !globalCfg.changed && !force {
if err == nil && !globalCfg.Changed && !force {
slog.Info("no changes", slog.Any("path", path))
return
}
Expand Down Expand Up @@ -256,7 +260,8 @@ func newLintCommand(cliArgs *linters.CliArgs, options typex.Options) *redant.Com
}

includes := lo.Uniq(append(globalCfg.Includes, globalCfg.Vendor))
if err := linters.Linter(cliArgs, globalCfg.Linter, includes, protoFiles); err != nil {
linterCfg := toLinterConfig(globalCfg.Linter)
if err := linters.Linter(cliArgs, linterCfg, includes, protoFiles); err != nil {
return err
}
}
Expand Down
Loading