Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

heytom-labs/heytom-cli

Repository files navigation

heytom-cli

Go Version License Build Status

heytom-cli 是一个命令行工具集,用于简化 heytom 框架体系的开发工作流程。

功能特性

  • 🚀 Proto 管理: 初始化、生成、检查和导入 Protocol Buffer 文件
  • 📦 项目脚手架: 快速创建 Go 和 C# 微服务项目
  • 🔄 数据库迁移: 管理数据库 schema 的版本变更
  • 代码规范检查: 使用 Buf 进行 Proto 文件的 lint 和 breaking change 检测
  • 🛠️ 依赖检查: 自动检测和提示必需的工具依赖

安装

从源码构建

git clone https://github.com/heytom/heytom-cli.git
cd heytom-cli
go build -o heytom-cli ./cmd/heytom-cli

安装到系统

go install github.com/heytom/heytom-cli/cmd/heytom-cli@latest

依赖要求

  • Go 1.21+
  • Buf CLI (用于 Proto 文件管理)

检查依赖:

heytom-cli check-deps

快速开始

1. 创建新服务

创建 Go 服务:

heytom-cli new service my-service --lang go
cd my-service

创建 C# 服务:

heytom-cli new service my-service --lang csharp
cd my-service

2. Proto 文件管理

初始化 Proto 项目:

heytom-cli proto init my-service --lang go

创建新的 Proto 文件:

heytom-cli new proto user --version v1

生成代码:

heytom-cli proto gen

检查代码规范:

heytom-cli proto lint

检查破坏性变更:

heytom-cli proto breaking --against main

3. 数据库迁移

创建迁移文件:

heytom-cli new migration create_users_table

应用迁移:

heytom-cli migrate up --dsn "postgres://user:pass@localhost/db"

回滚迁移:

heytom-cli migrate down --dsn "postgres://user:pass@localhost/db"

命令参考

Proto 命令

  • heytom-cli proto init [service-name] - 初始化 Proto 项目结构
  • heytom-cli proto gen - 从 Proto 文件生成代码
  • heytom-cli proto lint - 检查 Proto 文件规范
  • heytom-cli proto breaking - 检测破坏性变更
  • heytom-cli proto import [source-path] - 导入其他服务的 Proto 文件

创建命令

  • heytom-cli new service [name] - 创建新的微服务项目
  • heytom-cli new proto [service-name] - 创建新的 Proto 文件
  • heytom-cli new migration [name] - 创建数据库迁移文件

迁移命令

  • heytom-cli migrate up - 应用待执行的迁移
  • heytom-cli migrate down - 回滚迁移

其他命令

  • heytom-cli version - 显示版本信息
  • heytom-cli check-deps - 检查依赖工具
  • heytom-cli help - 显示帮助信息

项目结构

使用 heytom-cli 创建的服务遵循以下结构:

Go 服务

my-service/
├── api/ # Proto 文件
│ └── my-service/
│ └── v1/
│ └── my-service.proto
├── cmd/
│ └── my-service/
│ └── main.go # 服务入口
├── internal/
│ ├── service/ # 业务逻辑
│ └── handler/ # gRPC 处理器
├── gen/ # 生成的代码
├── migrations/ # 数据库迁移
├── buf.yaml # Buf 配置
├── buf.gen.yaml # 代码生成配置
└── go.mod

C# 服务

my-service/
├── api/ # Proto 文件
├── src/
│ ├── Program.cs # 服务入口
│ └── my-service.csproj
├── gen/ # 生成的代码
├── migrations/ # 数据库迁移
├── buf.yaml
└── buf.gen.yaml

开发

构建

go build -o heytom-cli ./cmd/heytom-cli

运行测试

go test ./...

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

About

heytom-cli 是一个命令行工具集,用于简化 heytom 框架体系的开发工作流程。

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /