extensionmgr

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = core.TimeoutDefault

DefaultTimeout is the default execution timeout for extension scripts. Uses core.TimeoutDefault for consistency across the codebase.

View Source
const MaxOutputSize = 1024 * 1024 // 1MB

MaxOutputSize limits the amount of data read from script stdout/stderr

Variables

View Source
var (
	AddExtensionToConfigFn = AddExtensionToConfig
)
View Source
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

func CloneRepository(repoURL *RepoURL) (string, error)

CloneRepository clones a repository to a temporary directory

func InstallFromURL

func InstallFromURL(urlStr, configPath, extensionDirectory string) error

InstallFromURL clones a repository and installs the extension

func IsURL

func IsURL(str string) bool

IsURL checks if a string looks like a URL (has a host and path)

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

func ValidateExtensionHook(hookType string) error

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

type ExtensionHookRunner struct {
	Config   *config.Config
	Executor Executor
}

ExtensionHookRunner manages the execution of extension hooks

func NewExtensionHookRunner

func NewExtensionHookRunner(cfg *config.Config) *ExtensionHookRunner

NewExtensionHookRunner creates a new ExtensionHookRunner

func (*ExtensionHookRunner) RunHooks

func (r *ExtensionHookRunner) RunHooks(ctx context.Context, hookType HookType, input *HookInput) error

RunHooks executes all enabled extensions for the specified hook point

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.

func (*OSFileCopier) CopyFile

func (c *OSFileCopier) CopyFile(src, dst string, perm core.FileMode) error

CopyFile copies a single file from src to dst with given permissions.

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

func ParseRepoURL(urlStr string) (*RepoURL, error)

ParseRepoURL parses various repository URL formats into a RepoURL struct

func (*RepoURL) CloneURL

func (r *RepoURL) CloneURL() string

CloneURL returns the HTTPS clone URL for the repository

func (*RepoURL) IsGitHubURL

func (r *RepoURL) IsGitHubURL() bool

IsGitHubURL checks if the URL is a GitHub repository

func (*RepoURL) IsGitLabURL

func (r *RepoURL) IsGitLabURL() bool

IsGitLabURL checks if the URL is a GitLab repository

func (*RepoURL) String

func (r *RepoURL) String() string

String returns a human-readable representation

type ScriptExecutor

type ScriptExecutor struct {
	Timeout time.Duration
}

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

Jump to

Keyboard shortcuts

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