project

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Type        ActionType
	Source      *kickoff.BufferedFile
	Destination Destination
}

Action defines an action that should be performed on project creation.

type ActionType

type ActionType uint8

ActionType defines the action that should be performed for a given project file, template or directory.

const (
	ActionTypeCreate ActionType = iota
	ActionTypeOverwrite
	ActionTypeSkipExisting
	ActionTypeSkipUser
)

type Config added in v0.1.1

type Config struct {
	// ProjectName is made available to templates. If empty the basename of the
	// target directory is used.
	ProjectName string
	// Host is the project host, e.g. github.com. Available in templates.
	Host string
	// Owner is the project owner, e.g. SCM username. Available in templates.
	Owner string
	// Gitignore template to use for creating .gitignore. If nil, no .gitignore
	// is created.
	Gitignore *gitignore.Template
	// License info for the open source license to use. If nil, no LICENSE file
	// is created.
	License *license.Info
	// If Overwrite is true, existing file in the target directory that matches
	// the name of one of the skeleton files is overwritten.
	Overwrite bool
	// OverwriteFiles can be used to selectively overwrite existing files. File
	// paths must be relative to the target directory.
	OverwriteFiles []string
	// SkipFiles can be used to selectively skip creation of files or
	// directories. File paths must be relative to the target directory.
	SkipFiles []string
	// Filesystem to use for creating the project. Can be set to
	// *afero.MemMapFs in tests or for dry running project creation. If nil
	// an *afero.OsFs is used.
	Filesystem afero.Fs
	// Values are user defined values that are merged on top of values from the
	// project skeleton.
	Values template.Values
	// Output configures the io.Writer where the project creation summary is
	// written to. If nil output is discarded.
	Output io.Writer
}

Config holds the configuration for a new project that can be created from a *kickoff.Skeleton.

type Destination

type Destination struct {
	// Base is the base dir of the project.
	Base string
	// Path is the path relative to the base dir.
	Path string
}

Destination describes the destination a project file should be written to.

func (Destination) AbsPath

func (d Destination) AbsPath() string

AbsPath returns the absolute file path of the destination.

func (Destination) Exists

func (d Destination) Exists() bool

Exists returns true if the destination already exists.

func (Destination) RelPath

func (d Destination) RelPath() string

RelPath returns the path relative to the project root.

type Project

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

Project is the type responsible for project creation.

func New

func New(targetDir string, config *Config) (*Project, error)

New creates a new *Project with given targetDir and config.

func (*Project) Create added in v0.1.1

func (p *Project) Create(s *kickoff.Skeleton) (*Result, error)

Create creates the project from given skeleton. The returned result contains information about all actions that were performed.

type Result added in v0.1.1

type Result struct {
	Stats   Stats
	Actions []Action
}

Result holds stats about project creation and the actions that were performed.

func Create added in v0.1.1

func Create(s *kickoff.Skeleton, targetDir string, config *Config) (*Result, error)

Create creates a project in targetDir from given skeleton with the provided config. The returned result contains information about all actions that were performed.

type Stats

type Stats map[ActionType]int

Stats is a map from action type to the number of times the action was performed.

func (Stats) String

func (s Stats) String() string

String implements fmt.Stringer.

Returns a string which contains counts of the actions in s.

Jump to

Keyboard shortcuts

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