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
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
Comment on lines +20 to +22

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These new features significantly enhance the tool's usability and completeness. The Web UI, environment check, and project initialization capabilities are valuable additions.


## 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 |
Comment on lines +77 to +84

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The addition of web, init, and doctor commands to the command table provides a clear overview of the new functionalities. This is a good update to the documentation.

| `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!
```
Comment on lines +250 to +311

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The detailed examples for the new web, init, and doctor commands are very helpful for users to quickly understand and utilize these features. The example output for protobuild doctor is particularly clear.


### 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)
Comment on lines +415 to +418

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The webcmd/ directory is correctly added to the architecture overview, reflecting the new Web UI component.

└── 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 |
Comment on lines +434 to +446

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The new "Roadmap" section is a great addition, providing transparency about future development and giving users an idea of what to expect. This enhances community engagement.


## 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 命令检查开发环境配置
- 🎯 **项目初始化** - 快速项目设置,支持多种模板
Comment on lines +20 to +22

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These new features significantly enhance the tool's usability and completeness. The Web UI, environment check, and project initialization capabilities are valuable additions.


## 安装

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 插件 |
Comment on lines +78 to +85

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The addition of web, init, and doctor commands to the command table provides a clear overview of the new functionalities. This is a good update to the documentation.

| `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')

✅ 环境检查通过!
```
Comment on lines +251 to +312

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The detailed examples for the new web, init, and doctor commands are very helpful for users to quickly understand and utilize these features. The example output for protobuild doctor is particularly clear.


### 强制更新 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 文件 | 计划中 |
Comment on lines +405 to +417

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The new "Roadmap" section is a great addition, providing transparency about future development and giving users an idea of what to expect. This enhances community engagement.


## 项目架构

```
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)
Comment on lines +436 to +439

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The webcmd/ directory is correctly added to the architecture overview, reflecting the new Web UI component.

└── 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
Comment on lines +131 to +134

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Adding a web task to the Taskfile.yml is a convenient way to run the new web server, simplifying the development workflow.

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"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The import of webcmd is correctly added to support the new web UI functionality.

"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(),
Comment on lines +76 to +77

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The newInitCommand() and newDoctorCommand() are correctly integrated into the main command's children, making them accessible via the CLI.

newGenCommand(),
newVendorCommand(&force, &update),
newInstallCommand(&force),
newLintCommand(cliArgs, options),
newFormatCommand(),
newDepsCommand(),
newCleanCommand(&dryRun),
webcmd.New(&protoCfg),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The webcmd.New(&protoCfg) command is correctly added, enabling the new web UI.

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 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Changing globalCfg.changed to globalCfg.Changed ensures consistency with the refactored Config struct in the internal/config package. This is a good maintainability improvement.

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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The introduction of linterCfg := toLinterConfig(globalCfg.Linter) correctly adapts the linter configuration from the new internal package structure, improving modularity.

if err := linters.Linter(cliArgs, linterCfg, includes, protoFiles); err != nil {
return err
}
}
Expand Down
Loading