mirror of
https://github.com/tnb-labs/panel.git
synced 2026-09-19 10:03:36 +08:00
- 依赖注入换到 libtnb/wire v0.3.0,各层包导出 Module 并逐类型 Export, wire.Struct 改用 Struct[T](),cleanup 签名改为 func() error - 测试断言换到 libtnb/assert 的 must/check,20 个 testify suite 拆成标准测试函数 - mock 改用 matryer 模板输出到 internal/mocks,wire 走 go.mod tool 指令, mockery 用 go run 调用,避免它的依赖树污染 go.mod - 引入 .golangci.yml 并修完全部告警,darwin 与 linux 双平台 0 issues - 工作流改用 go-version-file、govulncheck 官方 action, wire 校验移入 test.yml,mockery 由自动提交改为 PR 校验 顺带修复:pkg/db 四处漏查 rows.Err()(DatabaseExists 查询出错会被当成库不存在)、 websitestat 负值转 uint64 污染流量统计、pty 终端尺寸超 uint16 截断、 文件权限位超 32 位静默截断、面板与 ACME challenge 服务器缺 ReadHeaderTimeout、 GetDefault 丢失操作人、三处对结构体值恒成立的假断言、两处带空格而失效的 nolint Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
121 lines
3.2 KiB
Go
121 lines
3.2 KiB
Go
package command
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/leonelquinteros/gotext"
|
|
"github.com/urfave/cli/v3"
|
|
|
|
"github.com/acepanel/panel/v3/internal/service"
|
|
)
|
|
|
|
// UpdateCommand 更新面板
|
|
func UpdateCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
|
|
return &cli.Command{
|
|
Name: "update",
|
|
Usage: t.Get("Update AcePanel to the latest version"),
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.Update(ctx, cmd)
|
|
},
|
|
}
|
|
}
|
|
|
|
// SyncCommand 同步云端缓存数据
|
|
func SyncCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
|
|
return &cli.Command{
|
|
Name: "sync",
|
|
Usage: t.Get("Sync AcePanel cached data with cloud"),
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.Sync(ctx, cmd)
|
|
},
|
|
}
|
|
}
|
|
|
|
// FixCommand 修复升级问题
|
|
func FixCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
|
|
return &cli.Command{
|
|
Name: "fix",
|
|
Usage: t.Get("Fix AcePanel upgrade issues"),
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.Fix(ctx, cmd)
|
|
},
|
|
}
|
|
}
|
|
|
|
// InfoCommand 输出面板基础信息
|
|
func InfoCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
|
|
return &cli.Command{
|
|
Name: "info",
|
|
Usage: t.Get("Output AcePanel basic information"),
|
|
Flags: []cli.Flag{
|
|
&cli.BoolFlag{
|
|
Name: "force",
|
|
Aliases: []string{"f"},
|
|
Usage: t.Get("Force reset password"),
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "username",
|
|
Aliases: []string{"u"},
|
|
Usage: t.Get("Target username (the first user if not filled)"),
|
|
},
|
|
},
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.Info(ctx, cmd)
|
|
},
|
|
}
|
|
}
|
|
|
|
// PortCommand 修改监听端口
|
|
func PortCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
|
|
return &cli.Command{
|
|
Name: "port",
|
|
Usage: t.Get("Change the AcePanel listening port"),
|
|
ArgsUsage: t.Get("<port>"),
|
|
Flags: []cli.Flag{
|
|
&cli.UintFlag{
|
|
Name: "port",
|
|
Aliases: []string{"p"},
|
|
Usage: t.Get("Listening port"),
|
|
},
|
|
},
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.Port(ctx, cmd)
|
|
},
|
|
}
|
|
}
|
|
|
|
// SyncTimeCommand 通过 NTP 同步系统时间
|
|
func SyncTimeCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
|
|
return &cli.Command{
|
|
Name: "sync-time",
|
|
Usage: t.Get("Sync server time with NTP"),
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.SyncTime(ctx, cmd)
|
|
},
|
|
}
|
|
}
|
|
|
|
// ClearTaskCommand 清理卡住的任务队列
|
|
func ClearTaskCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
|
|
return &cli.Command{
|
|
Name: "clear-task",
|
|
Usage: t.Get("Clear all tasks in the task queue if they are stuck (use only under guidance)"),
|
|
Hidden: true,
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.ClearTask(ctx, cmd)
|
|
},
|
|
}
|
|
}
|
|
|
|
// InitCommand 初始化面板
|
|
func InitCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
|
|
return &cli.Command{
|
|
Name: "init",
|
|
Usage: t.Get("Initialize AcePanel (use only under guidance)"),
|
|
Hidden: true,
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.Init(ctx, cmd)
|
|
},
|
|
}
|
|
}
|