Documentation
¶
Overview ¶
Package pkgmgr 管理节点包管理器偏好(npm/pnpm/yarn,经 corepack 激活)与多 registry 配置(FR-306)。配置落托管 .npmrc(NPM_CONFIG_USERCONFIG 指向,不污染用户 ~/.npmrc), 供 FR-307 全局包管理 / FR-308 bot-worker 依赖装全局复用。
Index ¶
- type Config
- type GlobalPackage
- type Manager
- func (m *Manager) Get(pm string) Config
- func (m *Manager) GlobalDir() string
- func (m *Manager) InstallGlobal(ctx context.Context, pm, name, version string, onLine func(string)) error
- func (m *Manager) ListGlobal(ctx context.Context, pm string) ([]GlobalPackage, error)
- func (m *Manager) NpmrcPath() string
- func (m *Manager) RemoveGlobal(ctx context.Context, pm, name string) error
- func (m *Manager) Set(ctx context.Context, pm string, regs []Registry) (string, error)
- func (m *Manager) SetRunner(r runner)
- type Registry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
PM string
CorepackAvailable bool
PMVersion string
Registries []Registry
NodeBin string
}
Config 节点 PM 配置读取结果。
type GlobalPackage ¶
type GlobalPackage struct {
Name string
Version string
Latest string // outdated 探测到的最新版(空=已最新/探测失败)
}
GlobalPackage 托管全局目录下的一个已装包(FR-307)。
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 管理托管 .npmrc 与 corepack 激活。runtimesRoot=<数据根>/opt/runtimes(含 nodejs-* 与 .npmrc)。
func NewManager ¶
NewManager 创建包管理器。runtimesRoot 为 <数据根>/opt/runtimes。
func (*Manager) Get ¶
Get 读取当前 PM 配置:探测 corepack 可用性、PM 版本、回读托管 .npmrc registry。 pm 为期望偏好(来自 CP DB,Worker 不持久化偏好,仅落 .npmrc 与激活 shim)。
func (*Manager) InstallGlobal ¶
func (m *Manager) InstallGlobal(ctx context.Context, pm, name, version string, onLine func(string)) error
InstallGlobal 安装/升级一个全局包(version 空=latest);onLine 逐行回调 PM 输出(任务日志)。
func (*Manager) ListGlobal ¶
ListGlobal 列出节点受控项目已装包,并 best-effort 标注可更新版本(FR-307)。
func (*Manager) RemoveGlobal ¶
RemoveGlobal 卸载一个全局包(FR-307)。