project

package
v3.6.1-rc.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 23 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 added in v3.4.1

func ExtractDataFromLoadEvent[T any](event LoadEvent) T

func FormatFiles added in v3.4.1

func FormatFiles(files []string, flatten bool, formatJSON bool, write bool, outputter FuncOutput) error

func LoadFiles added in v3.4.1

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

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

Types

type Filter added in v3.4.1

type Filter func(Task) (bool, error)

type FuncOutput added in v3.4.1

type FuncOutput func(string, []byte) error

type LoadEvent added in v3.4.1

type LoadEvent struct {
	Type LoadEventType
	Data any
}

type LoadEventErrorData added in v3.4.1

type LoadEventErrorData struct {
	Err error
}

type LoadEventFinishedParsingDocumentData added in v3.4.1

type LoadEventFinishedParsingDocumentData struct {
	Path string
}

type LoadEventFinishedWalkData added in v3.4.1

type LoadEventFinishedWalkData struct{}

type LoadEventFoundDirData added in v3.4.1

type LoadEventFoundDirData struct {
	Path string
}

type LoadEventFoundFileData added in v3.4.1

type LoadEventFoundFileData struct {
	Path string
}

type LoadEventFoundTaskData added in v3.4.1

type LoadEventFoundTaskData struct {
	Task Task
}

type LoadEventStartedParsingDocumentData added in v3.4.1

type LoadEventStartedParsingDocumentData struct {
	Path string
}

type LoadEventStartedWalkData added in v3.4.1

type LoadEventStartedWalkData struct{}

type LoadEventType added in v3.4.1

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

type LoadOptions added in v3.4.1

type LoadOptions struct {
	OnlyFiles bool
}

type Matcher added in v3.4.1

type Matcher interface {
	MatchString(string) bool
}

func CompileRegex added in v3.4.1

func CompileRegex(query string) (Matcher, error)

type Project

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

func NewDirProject added in v3.4.1

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

func NewFileProject added in v3.4.1

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

func (*Project) EnvFilesReadOrder added in v3.4.1

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

func (*Project) Load added in v3.4.1

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

func (*Project) LoadEnv added in v3.4.1

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

func (*Project) LoadEnvAsMap added in v3.4.1

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

func (*Project) LoadEnvWithSource added in v3.4.1

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

func (*Project) LoadRawEnv added in v3.4.1

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

func (*Project) LoadWithOptions added in v3.4.1

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

func (*Project) Root added in v3.4.1

func (p *Project) Root() string

type ProjectOption added in v3.4.1

type ProjectOption func(*Project)

func WithEnvFilesReadOrder added in v3.4.1

func WithEnvFilesReadOrder(order []string) ProjectOption

func WithFindRepoUpward added in v3.4.1

func WithFindRepoUpward() ProjectOption

func WithIgnoreFilePatterns added in v3.4.1

func WithIgnoreFilePatterns(patterns ...string) ProjectOption

func WithLogger added in v3.4.1

func WithLogger(logger *zap.Logger) ProjectOption

func WithRespectGitignore added in v3.4.1

func WithRespectGitignore(value bool) ProjectOption

type Task added in v3.4.1

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 added in v3.4.1

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

func FilterTasksByFilename added in v3.4.1

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

func FilterTasksByFn added in v3.4.1

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

func FilterTasksByID added in v3.4.1

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

func LoadTasks added in v3.4.1

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

func (Task) ID added in v3.4.1

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