project

package
v0.0.0-...-e67fd50 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package project provides project-related utilities and configuration handling

Index

Constants

View Source
const (
	MsgAbsolutePathGetFailed     = "could not get absolute path"
	MsgProjectIndexAddFailed     = "failed to add project to index"
	MsgDistributionsUpdateFailed = "failed to update distributions for project"
	MsgProjectNotFound           = "not a divekit project (or any of the parent directories)"
	MsgIndexStoreNotInitialized  = "project index store is not initialized"
)

Standardized error messages as constants

Variables

This section is empty.

Functions

func FindProjectsDown

func FindProjectsDown(startPath string, dirCallback func(path string, d fs.DirEntry) error) error

FindProjectsDown wraps filepath.WalkDir to process directories. The dirCallback is called for each directory found. The callback can return filepath.SkipDir to prevent descending into a directory.

func FindProjectsUp

func FindProjectsUp(startPath string) ([]string, error)

FindProjectsUp searches for directories containing a .divekit folder, starting from startPath and moving up to the root directory. It returns a slice of absolute paths to the found project directories.

func GetConfigPath

func GetConfigPath(configName string) (string, error)

GetConfigPath returns the absolute path to the Divekit configuration file resolved relative to the project root.

func GetDistributions

func GetDistributions(projectPath string) ([]string, error)

GetDistributions reads the names of the distributions from the project's .divekit directory.

func GetProjectRoot

func GetProjectRoot() (string, error)

GetProjectRoot traverses up from the current working directory to find the project root. The project root is identified by the presence of a .divekit directory. Returns the absolute path to the project root or an error if no divekit project is found.

func IsDivekitProject

func IsDivekitProject(path string) bool

IsDivekitProject checks if the given path contains a divekit project by verifying the existence of a .divekit directory. This directory serves as the marker for divekit-managed repositories.

func ScriptDir

func ScriptDir(projectPath string) string

ScriptDir returns the scripts directory path for a project

func UpdateProjectInIndex

func UpdateProjectInIndex(ctx context.Context, store index.Store, path string) error

UpdateProjectInIndex ensures a project is in the index and its distributions are up to date. It's a convenient wrapper around Add and UpdateDistributions.

Types

type Error

type Error struct {
	apperror.Carrier
	ErrorType ErrorType
	Message   string
	Err       error // Wrapped error
}

Error represents a specific error in the project package

func NewAbsolutePathGetError

func NewAbsolutePathGetError(path string, err error) *Error

NewAbsolutePathGetError creates a new error for absolute path retrieval failures

func NewDistributionsUpdateError

func NewDistributionsUpdateError(absPath string, err error) *Error

NewDistributionsUpdateError creates a new error for distributions update failures

func NewError

func NewError(errorType ErrorType, message string, err error) *Error

NewError creates a new Error with appropriate categorization

func NewIndexStoreNotInitializedError

func NewIndexStoreNotInitializedError() *Error

NewIndexStoreNotInitializedError creates a new error when the index store is not initialized

func NewProjectIndexAddError

func NewProjectIndexAddError(absPath string, err error) *Error

NewProjectIndexAddError creates a new error for project index addition failures

func NewProjectNotFoundError

func NewProjectNotFoundError() *Error

NewProjectNotFoundError creates a new error when a divekit project cannot be found

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the wrapped error for compatibility with errors.Is/As

type ErrorType

type ErrorType int

ErrorType defines the different types of errors in the project package

const (
	ErrAbsolutePathGet ErrorType = iota
	ErrProjectIndexAdd
	ErrDistributionsUpdate
	ErrProjectNotFound
	ErrIndexStoreNotInitialized
)

Define error types as constants

Jump to

Keyboard shortcuts

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