initialize

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfirmMonorepoDefaults added in v0.13.0

func ConfirmMonorepoDefaults(info *MonorepoInfo) (bool, error)

ConfirmMonorepoDefaults asks the user whether to apply monorepo defaults.

func ConfirmOverwrite

func ConfirmOverwrite() (bool, error)

ConfirmOverwrite asks the user if they want to overwrite an existing .sley.yaml file.

func CreateMonorepoVersionFiles added in v0.13.0

func CreateMonorepoVersionFiles(monoInfo *MonorepoInfo) []string

CreateMonorepoVersionFiles creates .version files in each detected module directory if one does not already exist. Each file is initialized with "0.0.0". CreateMonorepoVersionFiles creates .version files in module directories and returns the list of created file paths.

func DefaultPluginNames

func DefaultPluginNames() []string

DefaultPluginNames returns the names of plugins that are enabled by default.

func FormatVersionSources

func FormatVersionSources(sources []VersionSource) string

FormatVersionSources formats the detected sources for display.

func GenerateConfigWithComments

func GenerateConfigWithComments(path string, selectedPlugins []string) ([]byte, error)

GenerateConfigWithComments creates a Config struct and returns it as YAML with helpful comments. The path parameter specifies the .version file path to use in the config. The selectedPlugins parameter should contain the names of plugins to enable.

func GenerateConfigWithDiscovery

func GenerateConfigWithDiscovery(path string, selectedPlugins []string, syncCandidates []discovery.SyncCandidate) ([]byte, error)

GenerateConfigWithDiscovery creates a Config with dependency-check configuration based on discovered sync candidates.

func GenerateWorkspaceConfigWithComments

func GenerateWorkspaceConfigWithComments(plugins []string, modules []DiscoveredModule) ([]byte, error)

GenerateWorkspaceConfigWithComments generates YAML config with workspace section. In workspace mode, the root path field is omitted since each module defines its own path. GenerateWorkspaceConfigWithComments generates a .sley.yaml for workspace mode. Used by both "sley init --workspace" and "sley discover".

func GenerateWorkspaceConfigWithMonorepo added in v0.13.0

func GenerateWorkspaceConfigWithMonorepo(plugins []string, modules []DiscoveredModule, monoInfo *MonorepoInfo) ([]byte, error)

GenerateWorkspaceConfigWithMonorepo generates YAML config with workspace section and monorepo defaults. This sets versioning to "independent" and configures the tag-manager prefix.

func IsValidTemplate

func IsValidTemplate(name string) bool

IsValidTemplate checks if the given name is a valid template.

func PromptPluginSelection

func PromptPluginSelection(detectionSummary string) ([]string, error)

PromptPluginSelection shows an interactive multi-select prompt for plugin selection. Returns the list of selected plugin names or an error if the user cancels.

func Run

func Run() *cli.Command

Run returns the "init" command.

func TemplateNames

func TemplateNames() []string

TemplateNames returns the names of all available templates.

func WritePluginConfig added in v0.13.0

func WritePluginConfig(sb *strings.Builder, pluginName string)

WritePluginConfig writes a single plugin configuration for workspace mode.

Types

type DiscoveredModule

type DiscoveredModule struct {
	Name    string
	Path    string
	RelPath string
	Version string
}

DiscoveredModule represents a .version file found during workspace discovery.

type MonorepoInfo added in v0.13.0

type MonorepoInfo struct {
	Type       string   // "go-work", "pnpm", "npm", "cargo"
	MarkerFile string   // path to the detected marker file
	Modules    []string // discovered module directory paths (relative)
}

MonorepoInfo holds information about a detected monorepo workspace.

func DetectMonorepo added in v0.13.0

func DetectMonorepo() (*MonorepoInfo, error)

DetectMonorepo checks for monorepo workspace markers in the current directory. Returns nil if no markers are found. Detection order: go.work, pnpm-workspace.yaml, package.json (workspaces), Cargo.toml ([workspace]).

type PluginOption

type PluginOption struct {
	Name        string
	Description string
	Default     bool
}

PluginOption represents a selectable plugin with metadata.

func AllPluginOptions

func AllPluginOptions() []PluginOption

AllPluginOptions returns all available plugins with their descriptions. The order matches the desired display order in the prompt.

type ProjectContext

type ProjectContext struct {
	IsGitRepo        bool
	HasPackageJSON   bool
	HasGoMod         bool
	HasCargoToml     bool
	HasPyprojectToml bool
}

ProjectContext holds information about the detected project environment.

func DetectProjectContext

func DetectProjectContext() *ProjectContext

DetectProjectContext analyzes the current directory to detect project type and environment. This helps provide smart defaults and suggestions during initialization.

func (*ProjectContext) FormatDetectionSummary

func (ctx *ProjectContext) FormatDetectionSummary() string

FormatDetectionSummary returns a human-readable summary of detected project features.

func (*ProjectContext) HasAnyDetection

func (ctx *ProjectContext) HasAnyDetection() bool

HasAnyDetection returns true if any project features were detected.

func (*ProjectContext) SuggestedPlugins

func (ctx *ProjectContext) SuggestedPlugins() []string

SuggestedPlugins returns a list of plugin names that would be useful for this project.

type Template

type Template struct {
	Name        string
	Description string
	Plugins     []string
}

Template represents a pre-configured set of plugins for common use cases.

func AllTemplates

func AllTemplates() []Template

AllTemplates returns all available templates.

func GetTemplate

func GetTemplate(name string) (*Template, error)

GetTemplate returns the template with the given name, or an error if not found.

type VersionSource

type VersionSource struct {
	// File is the source file path.
	File string

	// Version is the extracted version string.
	Version string

	// Format describes the file format (e.g., "package.json", "Cargo.toml").
	Format string
}

VersionSource represents a detected version from an existing file.

func DetectExistingVersions

func DetectExistingVersions() []VersionSource

DetectExistingVersions searches for version information in common project files. Returns all detected versions, allowing the user to choose which to use.

func GetBestVersionSource

func GetBestVersionSource(sources []VersionSource) *VersionSource

GetBestVersionSource returns the most appropriate version source. Priority: package.json > Cargo.toml > pyproject.toml > Chart.yaml > plain text

Jump to

Keyboard shortcuts

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