Documentation
¶
Overview ¶
Package scaffold 实现 appkit new / appkit dev: 生成域仓库与组合仓库骨架(embed 模板 + text/template), 以及本地多仓联调的 go.work 维护。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dev ¶
Dev 维护本地多仓联调工作区(appkit dev):
- 在 dir 下 go work init(已有 go.work 则跳过,幂等);
- 扫描 root 下含 go.mod 的一级子目录,连同 dir 自身逐个 go work use。
go.work 不提交(骨架 .gitignore 已忽略);发版联动走 require + Renovate。
func RenderDomain ¶ added in v0.9.0
RenderDomain renders the entire scaffold without touching o.Dir. Migration DDL still comes from the framework library functions, never duplicated SQL. WorkflowRef must already be an explicit commit SHA: resolving provenance is the caller's responsibility and must not turn this renderer into external I/O.
func RenderSystem ¶ added in v0.9.0
RenderSystem renders the composition scaffold with no filesystem access.
Types ¶
type Options ¶
type Options struct {
// Name 是域名/系统名,须匹配 ^[a-z][a-z0-9]*$(业务包名 = Postgres schema)。
Name string
// Module 是生成仓库的 module path,空则默认 github.com/forgeplex/<name>。
Module string
// Dir 是输出目录,空则默认 ./<name>。目录已存在且非空时报错。
Dir string
// AppkitVersion 是写进 go.mod 的 appkit 版本(取 cli.Version());
// "(devel)" 表示源码构建:go.mod 不 require appkit(对不存在版本的
// require 会让 go 命令去代理拉取而失败),改由 appkit dev 的 go.work 提供。
AppkitVersion string
// WorkflowRef 可显式传 appkit 源码的完整 commit;Domain 入口为空时由
// ruleset 从 AppkitVersion 的来源解析。纯 RenderDomain 必须显式传入,
// 不会执行外部 git/go 命令;RenderSystem 不消费 workflow ref。
WorkflowRef string
// Partitioned 生成「分区域域」形态(仅 domain):一套代码、N 份数据分区,
// 迁移与查询全部无 schema 前缀,落位由组合根注入的分区映射(分区键 → schema)
// 经事务级 search_path 路由确定。分区映射的定义放组合根自己的配置文件。
Partitioned bool
// Tenant 生成「租户域」形态(仅 domain):行级隔离——业务表带 tenant_id
// 列并挂 RLS 策略(pgtx.TenantPolicySQL),每次事务把租户身份落成事务级
// GUC(pgtx.NewTenant)。与 Partitioned 同给即「分区 + 行级」双层:每个
// 分区一套 schema,分区内再按 tenant_id 分行(pgtx.NewRoutedTenant,
// 租户 DDL 用无前缀形态)。
Tenant bool
}
Options 是 appkit new 的输入。