languages

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package languages provides a plugin architecture for supporting multiple programming language ecosystems.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrLanguageNotRegistered is returned when a language is not found in the registry.
	ErrLanguageNotRegistered = errors.New("language not registered")

	// ErrNoLanguageDetected is returned when no supported language is detected.
	ErrNoLanguageDetected = errors.New("no supported language detected")

	// ErrMultipleLanguagesDetected is returned when more than one language matches.
	ErrMultipleLanguagesDetected = errors.New("multiple languages detected")
)

Functions

func DetectLanguage

func DetectLanguage(ctx context.Context, dir string) (string, error)

DetectLanguage attempts to detect which language is present in the given directory. When multiple languages match, languages with a manifest file in the root directory are preferred over those detected only via recursive scanning. Among equals, selection is alphabetical for determinism. Callers should use --language to override.

func DetectLanguageFromPaths added in v0.14.4

func DetectLanguageFromPaths(paths []string) string

DetectLanguageFromPaths detects which language is present from a list of file paths (e.g. paths returned by a remote file search). Mirrors the root-manifest preference logic of DetectLanguage without requiring disk access. Returns "" when no language is detected.

func DetectLanguages

func DetectLanguages(ctx context.Context, dir string) ([]string, error)

DetectLanguages returns all languages detected in the given directory, sorted alphabetically for deterministic output. Useful for multi-language projects.

func List

func List() []string

List returns all registered language names.

func Register

func Register(lang Language)

Register adds a language implementation to the registry. This is typically called from init() functions in each language package.

Types

type Dependency

type Dependency struct {
	// Name is the primary package/module name
	Name string

	// OldName is used for module replacements (Go-specific)
	OldName string

	// Version is the target version to update to
	Version string

	// Scope is the dependency scope (Maven-specific: compile, test, runtime, etc.)
	Scope string

	// Type is the dependency type (Maven-specific: jar, pom, etc.)
	Type string

	// Replace indicates this is a replacement directive (Go-specific)
	Replace bool

	// Additional metadata can be stored here
	Metadata map[string]any
}

Dependency represents a single dependency to be updated.

type Language

type Language interface {
	// Name returns the language identifier (e.g., "maven", "go", "rust")
	Name() string

	// Detect checks if this language is present in the given directory.
	// Returns true if manifest files for this language are found.
	Detect(ctx context.Context, dir string) (bool, error)

	// Update performs the dependency update using the provided configuration.
	Update(ctx context.Context, cfg *UpdateConfig) error

	// Validate checks if the updates were applied successfully.
	// Returns an error if any dependency wasn't updated to the expected version.
	Validate(ctx context.Context, cfg *UpdateConfig) error

	// GetManifestFiles returns the list of manifest files for this language
	// (e.g., ["go.mod", "go.sum"] for Go, ["pom.xml"] for Maven)
	GetManifestFiles() []string

	// SupportsAnalysis returns true if this language supports dependency analysis.
	SupportsAnalysis() bool
}

Language defines the interface that each language ecosystem must implement. This allows omnibump to support multiple languages (Rust, Go, Maven) with a unified interface.

func Get

func Get(name string) (Language, error)

Get retrieves a language implementation by name.

type UpdateConfig

type UpdateConfig struct {
	// RootDir is the root directory of the project
	RootDir string

	// Dependencies is the list of dependencies to update
	Dependencies []Dependency

	// Properties contains property updates (for build systems that support them)
	Properties map[string]string

	// Tidy indicates whether to run the language's "tidy" command after updates
	Tidy bool

	// ShowDiff indicates whether to show a diff of changes
	ShowDiff bool

	// DryRun indicates whether to only simulate the update without making changes
	DryRun bool

	// ManifestFile overrides the default manifest file path (e.g. a specific pom.xml).
	// When empty, each language falls back to its default filename within RootDir.
	ManifestFile string

	// Update indicates whether to update package dependencies
	Update bool

	// Options contains language-specific options as a flexible map
	Options map[string]any
}

UpdateConfig contains all configuration needed to perform a dependency update.

Directories

Path Synopsis
Package golang implements omnibump support for Go projects.
Package golang implements omnibump support for Go projects.
Package java implements omnibump support for Java projects.
Package java implements omnibump support for Java projects.
gradle
Package gradle implements Gradle build tool support for Java projects.
Package gradle implements Gradle build tool support for Java projects.
maven
Package maven implements Maven build tool support for Java projects.
Package maven implements Maven build tool support for Java projects.
Package js implements omnibump support for JavaScript projects.
Package js implements omnibump support for JavaScript projects.
php
Package php implements omnibump support for PHP projects.
Package php implements omnibump support for PHP projects.
composer
Package composer implements Composer build tool support for PHP projects within omnibump.
Package composer implements Composer build tool support for PHP projects within omnibump.
Package python implements omnibump support for Python projects.
Package python implements omnibump support for Python projects.
Package ruby implements omnibump support for Ruby projects using Bundler.
Package ruby implements omnibump support for Ruby projects using Bundler.
Package rust implements omnibump support for Rust projects.
Package rust implements omnibump support for Rust projects.

Jump to

Keyboard shortcuts

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