feat: 更新模块路径为 v2,修正文档和代码中的相关引用

This commit is contained in:
Rogee
2025-09-10 14:54:16 +08:00
parent 8bcc2cbdad
commit 0d05d70fb1
18 changed files with 328 additions and 308 deletions

View File

@@ -3,7 +3,7 @@
## Install
```
go install go.ipao.vip/atomctl@latest
go install go.ipao.vip/atomctl/v2@latest
```
## 命令列表
@@ -11,6 +11,7 @@ go install go.ipao.vip/atomctl@latest
### 生成命令
#### gen model (别名m)
- 描述:生成 jet 模型
- 功能:
- 从 PostgreSQL 数据库生成模型
@@ -21,6 +22,7 @@ go install go.ipao.vip/atomctl@latest
- 自动生成数据库 schema 文件
#### gen provider (别名p)
- 描述:生成 provider
- 参数:
- path可选指定生成路径默认当前目录
@@ -32,6 +34,7 @@ go install go.ipao.vip/atomctl@latest
- 支持分组生成
#### gen route
- 描述:生成路由
- 参数:
- path可选指定生成路径默认当前目录
@@ -44,6 +47,7 @@ go install go.ipao.vip/atomctl@latest
### 数据库命令
#### migrate (别名m)
- 描述:数据库迁移
- 参数:
- action必选迁移操作up|up-by-one|up-to|create|down|down-to|fix|redo|reset|status|version
@@ -59,6 +63,7 @@ go install go.ipao.vip/atomctl@latest
### 新建命令
#### new project (别名p)
- 描述:创建新项目
- 参数:
- moduleName必选项目模块名需符合 Go 包名规范)
@@ -71,6 +76,7 @@ go install go.ipao.vip/atomctl@latest
- 生成完成后提示后续步骤
#### new provider
- 描述:创建新的 provider
- 参数:
- providerName必选provider 名称

View File

@@ -10,8 +10,8 @@ import (
_ "github.com/lib/pq"
"github.com/spf13/cobra"
"go.ipao.vip/atomctl/pkg/utils"
"go.ipao.vip/atomctl/pkg/utils/generator"
"go.ipao.vip/atomctl/v2/pkg/utils"
"go.ipao.vip/atomctl/v2/pkg/utils/generator"
)
func CommandGenEnum(root *cobra.Command) {

View File

@@ -6,7 +6,7 @@ import (
"regexp"
"strings"
astModel "go.ipao.vip/atomctl/pkg/ast/model"
astModel "go.ipao.vip/atomctl/v2/pkg/ast/model"
"github.com/go-jet/jet/v2/generator/metadata"
"github.com/go-jet/jet/v2/generator/postgres"
@@ -19,9 +19,9 @@ import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.ipao.vip/atomctl/pkg/ast/model"
pgDatabase "go.ipao.vip/atomctl/pkg/postgres"
"go.ipao.vip/atomctl/pkg/utils/gomod"
"go.ipao.vip/atomctl/v2/pkg/ast/model"
pgDatabase "go.ipao.vip/atomctl/v2/pkg/postgres"
"go.ipao.vip/atomctl/v2/pkg/utils/gomod"
)
func CommandGenModel(root *cobra.Command) {

View File

@@ -6,11 +6,11 @@ import (
"path/filepath"
"strings"
"go.ipao.vip/atomctl/pkg/ast/provider"
"go.ipao.vip/atomctl/pkg/utils/gomod"
"github.com/samber/lo"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"go.ipao.vip/atomctl/v2/pkg/ast/provider"
"go.ipao.vip/atomctl/v2/pkg/utils/gomod"
)
func CommandGenProvider(root *cobra.Command) {

View File

@@ -10,8 +10,8 @@ import (
"github.com/samber/lo"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"go.ipao.vip/atomctl/pkg/ast/route"
"go.ipao.vip/atomctl/pkg/utils/gomod"
"go.ipao.vip/atomctl/v2/pkg/ast/route"
"go.ipao.vip/atomctl/v2/pkg/utils/gomod"
)
func CommandGenRoute(root *cobra.Command) {
@@ -27,7 +27,7 @@ func CommandGenRoute(root *cobra.Command) {
root.AddCommand(cmd)
}
// https://go.ipao.vip/atomctl/pkg/swag?tab=readme-ov-file#api-operation
// https://go.ipao.vip/atomctl/v2/pkg/swag?tab=readme-ov-file#api-operation
func commandGenRouteE(cmd *cobra.Command, args []string) error {
var err error
var path string

View File

@@ -3,12 +3,12 @@ package cmd
import (
"context"
"go.ipao.vip/atomctl/pkg/postgres"
"github.com/pkg/errors"
"github.com/pressly/goose/v3"
"github.com/samber/lo"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"go.ipao.vip/atomctl/v2/pkg/postgres"
)
// migrate

View File

@@ -8,10 +8,10 @@ import (
"strings"
"text/template"
"go.ipao.vip/atomctl/pkg/utils/gomod"
"go.ipao.vip/atomctl/templates"
"github.com/samber/lo"
"github.com/spf13/cobra"
"go.ipao.vip/atomctl/v2/pkg/utils/gomod"
"go.ipao.vip/atomctl/v2/templates"
)
// CommandNewProvider 注册 new_provider 命令
@@ -79,12 +79,18 @@ func commandNewEventE(cmd *cobra.Command, args []string) error {
var destPath string
if relPath == "publisher.go.tpl" {
if only == "subscriber" { return nil }
if only == "subscriber" {
return nil
}
destPath = filepath.Join(publisherPath, snakeName+".go")
} else if relPath == "subscriber.go.tpl" {
if only == "publisher" { return nil }
if only == "publisher" {
return nil
}
destPath = filepath.Join(subscriberPath, snakeName+".go")
} else { return nil }
} else {
return nil
}
tmpl, err := template.ParseFS(templates.Events, path)
if err != nil {
@@ -117,17 +123,25 @@ func commandNewEventE(cmd *cobra.Command, args []string) error {
} else {
// ensure file exists with basic header
if _, statErr := os.Stat(topicsPath); os.IsNotExist(statErr) {
if err := os.MkdirAll(filepath.Dir(topicsPath), os.ModePerm); err != nil { return err }
if err := os.MkdirAll(filepath.Dir(topicsPath), os.ModePerm); err != nil {
return err
}
header := "package events\n\n// topics generated by atomctl\n\n"
if err := os.WriteFile(topicsPath, []byte(header), 0o644); err != nil { return err }
if err := os.WriteFile(topicsPath, []byte(header), 0o644); err != nil {
return err
}
}
// check duplicate
content, _ := os.ReadFile(topicsPath)
if !strings.Contains(string(content), "Topic"+camelName+" ") && !strings.Contains(string(content), topicLine) {
f, err := os.OpenFile(topicsPath, os.O_APPEND|os.O_WRONLY, 0o644)
if err != nil { return err }
if err != nil {
return err
}
defer f.Close()
if _, err := f.WriteString(topicLine); err != nil { return err }
if _, err := f.WriteString(topicLine); err != nil {
return err
}
}
}

View File

@@ -7,10 +7,10 @@ import (
"path/filepath"
"text/template"
"go.ipao.vip/atomctl/pkg/utils/gomod"
"go.ipao.vip/atomctl/templates"
"github.com/samber/lo"
"github.com/spf13/cobra"
"go.ipao.vip/atomctl/v2/pkg/utils/gomod"
"go.ipao.vip/atomctl/v2/templates"
)
// CommandNewProvider 注册 new_provider 命令

View File

@@ -9,11 +9,11 @@ import (
"strings"
"text/template"
"go.ipao.vip/atomctl/pkg/utils/gomod"
"go.ipao.vip/atomctl/templates"
"github.com/samber/lo"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"go.ipao.vip/atomctl/v2/pkg/utils/gomod"
"go.ipao.vip/atomctl/v2/templates"
)
func CommandNewModule(root *cobra.Command) {

View File

@@ -13,8 +13,8 @@ import (
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"go.ipao.vip/atomctl/pkg/utils/gomod"
"go.ipao.vip/atomctl/templates"
"go.ipao.vip/atomctl/v2/pkg/utils/gomod"
"go.ipao.vip/atomctl/v2/templates"
)
// 验证包名是否合法:支持域名、路径分隔符和常见字符

View File

@@ -9,9 +9,9 @@ import (
"strings"
"text/template"
"go.ipao.vip/atomctl/templates"
"github.com/iancoleman/strcase"
"github.com/spf13/cobra"
"go.ipao.vip/atomctl/v2/templates"
)
// CommandNewProvider 注册 new_provider 命令

2
go.mod
View File

@@ -1,4 +1,4 @@
module go.ipao.vip/atomctl
module go.ipao.vip/atomctl/v2
go 1.23.2

View File

@@ -1,9 +1,9 @@
package main
import (
"go.ipao.vip/atomctl/cmd"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"go.ipao.vip/atomctl/v2/cmd"
)
func main() {

View File

@@ -10,7 +10,7 @@ import (
"github.com/samber/lo"
log "github.com/sirupsen/logrus"
"go.ipao.vip/atomctl/pkg/utils/gomod"
"go.ipao.vip/atomctl/v2/pkg/utils/gomod"
)
//go:embed table.go.tpl

View File

@@ -11,7 +11,7 @@ import (
"github.com/samber/lo"
log "github.com/sirupsen/logrus"
"go.ipao.vip/atomctl/pkg/utils/gomod"
"go.ipao.vip/atomctl/v2/pkg/utils/gomod"
)
func getTypePkgName(typ string) string {

View File

@@ -6,8 +6,8 @@ import (
"os"
"strings"
"go.ipao.vip/atomctl/pkg/utils/gomod"
"github.com/samber/lo"
"go.ipao.vip/atomctl/v2/pkg/utils/gomod"
"golang.org/x/tools/imports"
)

View File

@@ -8,10 +8,10 @@ import (
"path/filepath"
"text/template"
"go.ipao.vip/atomctl/pkg/utils/gomod"
"github.com/Masterminds/sprig/v3"
"github.com/iancoleman/strcase"
"github.com/samber/lo"
"go.ipao.vip/atomctl/v2/pkg/utils/gomod"
)
//go:embed router.go.tpl

View File

@@ -7,10 +7,10 @@ import (
"go/token"
"strings"
"go.ipao.vip/atomctl/pkg/utils/gomod"
"github.com/pkg/errors"
"github.com/samber/lo"
log "github.com/sirupsen/logrus"
"go.ipao.vip/atomctl/v2/pkg/utils/gomod"
)
type RouteDefinition struct {