project

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: Apache-2.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ConfigFileName   = ".happy.yaml"
	ConfigVersion    = version.Version("v1.0.0")
	ConfigVersionMin = version.Version("v1.0.0")
)

Variables

View Source
var (
	Error             = errors.New("project")
	ErrOpeningProject = fmt.Errorf("%w: opening project", Error)
)

Functions

func ContainsHappyConfigFile

func ContainsHappyConfigFile(dir string) (string, bool)

ContainsHappyConfigFile reports whether dir contains the Happy config file. It returns true if the file exists and is a regular file. If the file exists, it returns the absolute path to the file.

func FindProjectDir

func FindProjectDir(wd string) (dir string, found bool, err error)

FindProjectDir locates the root of a Happy project by ascending from wd. It looks for either:

  1. A directory containing the Happy config file (ConfigFileName = "happy.yml").
  2. A Git repository marker (via git.IsRepository).

Returns:

dir:   absolute path to the discovered project root, or original wd if none found.
found: true if a project root is detected; false otherwise.
err:   any error encountered resolving wd to an absolute path.

The search ascends parent directories until it reaches the filesystem root.

func IsProjectDir

func IsProjectDir(dir string, all bool) bool

IsProjectDir reports whether dir is a Happy project root. A directory is considered a project root if it contains:

  1. The Happy config file (ConfigFileName = "happy.yml").
  2. A Git repository marker (via git.IsRepository).

It returns true if either condition is met.

Types

type Config

type Config struct {
	Version version.Setting `key:"version,save" default:"v1.0.0"`

	// Ignore defines project-relative paths that should be skipped by
	// tooling such as lint and test. This mirrors the top-level
	// "ignore" list in .happy.yaml.
	Ignore settings.StringSlice `key:"ignore,save"`

	Changelog    changelog.Config   `key:"changelog"`
	Git          GitConfig          `key:"git"`
	Linter       LinterConfig       `key:"linter"`
	Releaser     ReleaserConfig     `key:"releaser"`
	Tests        TestsConfig        `key:"tests"`
	Dependencies DependenciesConfig `key:"deps"`
}

func (*Config) Blueprint

func (c *Config) Blueprint() (*settings.Blueprint, error)

type DependenciesConfig added in v0.1.2

type DependenciesConfig struct {
	Latest DependenciesGoConfig `key:"go"`
}

func (*DependenciesConfig) Blueprint added in v0.1.2

func (c *DependenciesConfig) Blueprint() (*settings.Blueprint, error)

type DependenciesGoConfig added in v0.1.2

type DependenciesGoConfig struct {
	Latest settings.StringSlice `key:"latest"`
}

func (*DependenciesGoConfig) Blueprint added in v0.1.2

func (c *DependenciesGoConfig) Blueprint() (*settings.Blueprint, error)

type DirInfo

type DirInfo struct {
	Path           string          `json:"path"`
	HasConfigFile  bool            `json:"has_config_file"`
	ConfigFile     string          `json:"config_file"`
	HappyVersion   version.Version `json:"happy_version"`
	Version        version.Version `json:"version"`
	DependsOnHappy bool            `json:"depends_on_happy"`
	HasGit         bool            `json:"has_git"`
}

func Detect

func Detect(dir string) (info DirInfo, found bool, err error)

type GitConfig

type GitConfig struct {
	CommitterName  settings.String `key:"committer.name,save"`
	CommitterEmail settings.String `key:"committer.email,save"`
	AuthorName     settings.String `key:"author.name,save"`
	AuthorEmail    settings.String `key:"author.email,save"`
	Branch         settings.String `key:"branch,save" default:"main"`
	RemoteName     settings.String `key:"remote.name,save" default:"origin"`
	RemoteURL      settings.String `key:"remote.url,save"`
}

func (*GitConfig) Blueprint

func (c *GitConfig) Blueprint() (*settings.Blueprint, error)

type LinterConfig

type LinterConfig struct {
	Enabled      settings.Bool            `key:"enabled,save" default:"false"`
	GolangCILint LinterGolangCILintConfig `key:"golangci-lint"`
}

func (*LinterConfig) Blueprint

func (c *LinterConfig) Blueprint() (*settings.Blueprint, error)

type LinterGolangCILintConfig

type LinterGolangCILintConfig struct {
	Enabled settings.Bool   `key:"enabled,save" default:"false"`
	Path    settings.String `key:"path,save" default:""`
}

func (*LinterGolangCILintConfig) Blueprint

func (c *LinterGolangCILintConfig) Blueprint() (*settings.Blueprint, error)

type Project

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

func Open

func Open(sess *session.Context, dir string) (*Project, error)

func (*Project) Config

func (prj *Project) Config() *settings.Profile

func (*Project) Dir

func (prj *Project) Dir() DirInfo

func (*Project) Dist

func (prj *Project) Dist() string

func (*Project) GoModules

func (prj *Project) GoModules(sess *session.Context) ([]*gomodule.Package, error)

func (*Project) Lint

func (prj *Project) Lint(sess *session.Context) error

func (*Project) Release

func (prj *Project) Release(sess *session.Context, allowDirty, skipRemoteChecks bool) (err error)

func (*Project) Test

func (prj *Project) Test(sess *session.Context) error

type ReleaserConfig

type ReleaserConfig struct {
	Enabled settings.Bool   `key:"enabled,save" default:"false"`
	Dist    settings.String `key:"dist,save" default:"dist"`
}

func (*ReleaserConfig) Blueprint

func (c *ReleaserConfig) Blueprint() (*settings.Blueprint, error)

type TestsConfig

type TestsConfig struct {
	Enabled settings.Bool `key:"enabled,save" default:"false"`
}

func (*TestsConfig) Blueprint

func (t *TestsConfig) Blueprint() (*settings.Blueprint, error)

Jump to

Keyboard shortcuts

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