project

package
v3.3.3-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultProjectOptions = [...]ProjectOption{
	WithFindRepoUpward(),
	WithRespectGitignore(true),
	WithEnvFilesReadOrder([]string{".env"}),
	WithIgnoreFilePatterns("node_modules", ".venv", "vendor"),
}
View Source
var ErrReturnEarly = errors.New("return early")

Functions

func ExtractDataFromLoadEvent

func ExtractDataFromLoadEvent[T any](event LoadEvent) T

func LoadFiles

func LoadFiles(ctx context.Context, p *Project) ([]string, error)

LoadFiles returns a list of file names found in the project.

Types

type Filter

type Filter func(Task) (bool, error)

type LoadEvent

type LoadEvent struct {
	Type LoadEventType
	Data any
}

type LoadEventErrorData

type LoadEventErrorData struct {
	Err error
}

type LoadEventFinishedParsingDocumentData

type LoadEventFinishedParsingDocumentData struct {
	Path string
}

type LoadEventFinishedWalkData

type LoadEventFinishedWalkData struct{}

type LoadEventFoundDirData

type LoadEventFoundDirData struct {
	Path string
}

type LoadEventFoundFileData

type LoadEventFoundFileData struct {
	Path string
}

type LoadEventFoundTaskData

type LoadEventFoundTaskData struct {
	Task Task
}

type LoadEventStartedParsingDocumentData

type LoadEventStartedParsingDocumentData struct {
	Path string
}

type LoadEventStartedWalkData

type LoadEventStartedWalkData struct{}

type LoadEventType

type LoadEventType uint8
const (
	LoadEventStartedWalk LoadEventType = iota + 1
	LoadEventFoundDir
	LoadEventFoundFile
	LoadEventFinishedWalk
	LoadEventStartedParsingDocument
	LoadEventFinishedParsingDocument
	LoadEventFoundTask
	LoadEventError
)

type LoadOptions

type LoadOptions struct {
	OnlyFiles bool
}

type Matcher

type Matcher interface {
	MatchString(string) bool
}

func CompileRegex

func CompileRegex(query string) (Matcher, error)

type Project

type Project struct {
	// contains filtered or unexported fields
}

func NewDirProject

func NewDirProject(
	dir string,
	opts ...ProjectOption,
) (*Project, error)

func NewFileProject

func NewFileProject(
	path string,
	opts ...ProjectOption,
) (*Project, error)

func (*Project) EnvFilesReadOrder

func (p *Project) EnvFilesReadOrder() []string

func (*Project) Load

func (p *Project) Load(
	ctx context.Context,
	eventc chan<- LoadEvent,
	onlyFiles bool,
)

func (*Project) LoadEnv

func (p *Project) LoadEnv() ([]string, error)

func (*Project) LoadEnvAsMap

func (p *Project) LoadEnvAsMap() (map[string]string, error)

func (*Project) LoadEnvWithSource added in v3.2.0

func (p *Project) LoadEnvWithSource() (envWithSource map[string]map[string]string, err error)

func (*Project) LoadRawEnv added in v3.2.0

func (p *Project) LoadRawEnv(file string) ([]byte, error)

func (*Project) LoadWithOptions

func (p *Project) LoadWithOptions(
	ctx context.Context,
	eventc chan<- LoadEvent,
	options LoadOptions,
)

func (*Project) Root

func (p *Project) Root() string

type ProjectOption

type ProjectOption func(*Project)

func WithEnvFilesReadOrder

func WithEnvFilesReadOrder(order []string) ProjectOption

func WithFindRepoUpward

func WithFindRepoUpward() ProjectOption

func WithIgnoreFilePatterns

func WithIgnoreFilePatterns(patterns ...string) ProjectOption

func WithLogger

func WithLogger(logger *zap.Logger) ProjectOption

func WithRespectGitignore

func WithRespectGitignore(value bool) ProjectOption

type Task

type Task struct {
	CodeBlock       *document.CodeBlock `json:"code_block"`
	DocumentPath    string              `json:"document_path"`
	RelDocumentPath string              `json:"rel_document_path"`
}

Task is struct representing a document.CodeBlock within the context of a project. Instance of document.Document can be retrieved from Task's code block. Task contains absolute and relative path to the document.

func FilterTasksByExactTaskName

func FilterTasksByExactTaskName(tasks []Task, name string) (result []Task, err error)

func FilterTasksByFilename

func FilterTasksByFilename(tasks []Task, expr string) (result []Task, err error)

func FilterTasksByFn

func FilterTasksByFn(tasks []Task, fns ...Filter) (result []Task, err error)

func FilterTasksByID

func FilterTasksByID(tasks []Task, expr string) (result []Task, err error)

func LoadTasks

func LoadTasks(ctx context.Context, p *Project) ([]Task, error)

func (Task) ID

func (t Task) ID() string

Directories

Path Synopsis
testutils provides helpers for integration tests with "internal/project" package.
testutils provides helpers for integration tests with "internal/project" package.

Jump to

Keyboard shortcuts

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