Documentation
¶
Index ¶
- Constants
- Variables
- func AddExtensionToConfig(path string, extension config.ExtensionConfig) error
- func CloneRepository(repoURL *RepoURL) (string, error)
- func InstallFromURL(urlStr, configPath, extensionDirectory string) error
- func IsURL(str string) bool
- func LoadExtensionsForHook(cfg *config.Config, hookType HookType) ([]*extensions.ExtensionManifest, error)
- func RunPostBumpHooks(ctx context.Context, cfg *config.Config, ...) error
- func RunPreBumpHooks(ctx context.Context, cfg *config.Config, ...) error
- func ValidateExtensionHook(hookType string) error
- func ValidateGitAvailable() error
- type Executor
- type ExtensionHookRunner
- type HookInput
- type HookOutput
- type HookType
- type ModuleInfo
- type OSFileCopier
- type RepoURL
- type ScriptExecutor
Constants ¶
const DefaultTimeout = core.TimeoutDefault
DefaultTimeout is the default execution timeout for extension scripts. Uses core.TimeoutDefault for consistency across the codebase.
const MaxOutputSize = 1024 * 1024 // 1MB
MaxOutputSize limits the amount of data read from script stdout/stderr
Variables ¶
var (
AddExtensionToConfigFn = AddExtensionToConfig
)
var (
RegisterLocalExtensionFn = registerLocalExtension
)
Functions ¶
func AddExtensionToConfig ¶
func AddExtensionToConfig(path string, extension config.ExtensionConfig) error
AddExtensionToConfig appends an extension entry to the YAML config at the given path. It avoids duplicates and preserves existing fields.
func CloneRepository ¶
CloneRepository clones a repository to a temporary directory
func InstallFromURL ¶
InstallFromURL clones a repository and installs the extension
func LoadExtensionsForHook ¶
func LoadExtensionsForHook(cfg *config.Config, hookType HookType) ([]*extensions.ExtensionManifest, error)
LoadExtensionsForHook returns all enabled extensions that support the specified hook
func RunPostBumpHooks ¶
func RunPostBumpHooks(ctx context.Context, cfg *config.Config, version, previousVersion, bumpType string, prerelease, metadata *string, moduleInfo *ModuleInfo) error
RunPostBumpHooks is a convenience function to run post-bump hooks
func RunPreBumpHooks ¶
func RunPreBumpHooks(ctx context.Context, cfg *config.Config, version, previousVersion, bumpType string, moduleInfo *ModuleInfo) error
RunPreBumpHooks is a convenience function to run pre-bump hooks
func ValidateExtensionHook ¶
ValidateExtensionHook validates that a hook type is valid
func ValidateGitAvailable ¶
func ValidateGitAvailable() error
ValidateGitAvailable checks if git is available in the system
Types ¶
type Executor ¶
type Executor interface {
Execute(ctx context.Context, scriptPath string, input *HookInput) (*HookOutput, error)
}
Executor defines the interface for executing extension scripts
type ExtensionHookRunner ¶
ExtensionHookRunner manages the execution of extension hooks
func NewExtensionHookRunner ¶
func NewExtensionHookRunner(cfg *config.Config) *ExtensionHookRunner
NewExtensionHookRunner creates a new ExtensionHookRunner
type HookInput ¶
type HookInput struct {
Hook string `json:"hook"`
Version string `json:"version"`
PreviousVersion string `json:"previous_version,omitempty"`
BumpType string `json:"bump_type,omitempty"`
Prerelease *string `json:"prerelease,omitempty"`
Metadata *string `json:"metadata,omitempty"`
ProjectRoot string `json:"project_root"`
ModuleDir string `json:"module_dir,omitempty"` // Directory containing the .version file (for monorepo support)
ModuleName string `json:"module_name,omitempty"` // Module identifier (for monorepo support)
}
HookInput represents the JSON input passed to an extension script
type HookOutput ¶
type HookOutput struct {
Success bool `json:"success"`
Message string `json:"message,omitempty"`
Data map[string]any `json:"data,omitempty"`
}
HookOutput represents the JSON output expected from an extension script
func ExecuteExtensionHook ¶
func ExecuteExtensionHook(ctx context.Context, extensionPath, entry string, input *HookInput) (*HookOutput, error)
ExecuteExtensionHook is a convenience function to execute an extension hook It resolves the full script path relative to the extension directory and validates that the script remains within the extension directory to prevent path traversal attacks
type HookType ¶
type HookType string
HookType represents the different hook points available in the extension system
const ( // PreBumpHook is called before any version bump operation PreBumpHook HookType = "pre-bump" // PostBumpHook is called after a version bump completes successfully PostBumpHook HookType = "post-bump" // PreReleaseHook is called before pre-release changes are applied PreReleaseHook HookType = "pre-release" // ValidateHook is called to validate version changes ValidateHook HookType = "validate" )
type ModuleInfo ¶
type ModuleInfo struct {
Dir string // Directory containing the .version file
Name string // Module identifier
}
ModuleInfo contains optional module context for monorepo support.
type OSFileCopier ¶
type OSFileCopier struct {
// contains filtered or unexported fields
}
OSFileCopier implements core.FileCopier using OS file operations.
func NewOSFileCopier ¶
func NewOSFileCopier() *OSFileCopier
NewOSFileCopier creates an OSFileCopier with default OS implementations.
func (*OSFileCopier) CopyDir ¶
func (c *OSFileCopier) CopyDir(src, dst string) error
CopyDir recursively copies all files and subdirectories from src to dst.
type RepoURL ¶
type RepoURL struct {
Host string // github.com, gitlab.com, etc.
Owner string // user or organization
Repo string // repository name
Raw string // original URL
}
RepoURL represents a parsed repository URL
func ParseRepoURL ¶
ParseRepoURL parses various repository URL formats into a RepoURL struct
func (*RepoURL) IsGitHubURL ¶
IsGitHubURL checks if the URL is a GitHub repository
func (*RepoURL) IsGitLabURL ¶
IsGitLabURL checks if the URL is a GitLab repository
type ScriptExecutor ¶
ScriptExecutor implements the Executor interface for running shell scripts
func NewScriptExecutor ¶
func NewScriptExecutor() *ScriptExecutor
NewScriptExecutor creates a new ScriptExecutor with the default timeout
func NewScriptExecutorWithTimeout ¶
func NewScriptExecutorWithTimeout(timeout time.Duration) *ScriptExecutor
NewScriptExecutorWithTimeout creates a new ScriptExecutor with a custom timeout
func (*ScriptExecutor) Execute ¶
func (e *ScriptExecutor) Execute(ctx context.Context, scriptPath string, input *HookInput) (*HookOutput, error)
Execute runs an extension script with the provided input and returns the output