extract

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectOrmType

func DetectOrmType(servicePath string) string

DetectOrmType 自动检测源服务使用的 ORM 类型

Types

type Extractor

type Extractor struct {
	// contains filtered or unexported fields
}

Extractor 从源服务提取模块到目标服务

func NewExtractor

func NewExtractor(opts Options) *Extractor

NewExtractor 创建提取器

func (*Extractor) Plan added in v1.0.2

func (e *Extractor) Plan() (*Plan, error)

Plan 只读计算提取计划:枚举将复制、修改、删除的文件,不做任何变更。 供 --dry-run 预览与删除前确认。

func (*Extractor) Run

func (e *Extractor) Run() error

Run 执行提取

type FileCopy added in v1.0.2

type FileCopy struct {
	Src       string
	Dst       string
	Overwrite bool // 目标已存在,执行时将覆盖
}

FileCopy 一对复制动作。

type Options

type Options struct {
	// 项目根路径
	RootPath string
	// 项目模块路径 (go.mod 中的 module)
	ModulePath string
	// 项目名称 (从 module path 提取的最后一段)
	ProjectName string
	// 源服务名
	SourceService string
	// 目标服务名
	TargetService string
	// 要提取的模型名列表 (单数形式, 如 "role", "user")
	Models []string
	// ORM 类型: "ent" | "gorm"
	OrmType string
	// 服务器类型 (用于创建新服务时): ["grpc"], ["grpc","rest"], ...
	Servers []string
	// 数据库客户端类型 (用于创建新服务时): ["ent"], ["gorm"], ...
	DbClients []string
	// 是否保留源文件(默认 false = 删除)
	KeepSource bool
}

Options 提取选项

type Plan added in v1.0.2

type Plan struct {
	SourceService string
	TargetService string
	OrmType       string
	Models        []string
	KeepSource    bool

	// TargetWillBeCreated 目标服务不存在,执行时会先创建服务脚手架。
	TargetWillBeCreated bool

	// CopyFiles 源 -> 目标复制(含 import 改写)。
	CopyFiles []FileCopy

	// ModifiedFiles 目标/源端就地修改的文件(装配登记、server 注册等)。
	ModifiedFiles []string

	// DeletedFiles !KeepSource 时将被删除的源端文件。
	DeletedFiles []string

	// Warnings 计划期发现的问题(如源文件缺失,执行时将失败)。
	Warnings []string
}

Plan 一次提取将发生的文件动作(只读计算,不写盘、不删除)。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL