project

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create added in v0.1.1

func Create(config *Config) error

Create is a convenience wrapper to make a plan and immediately apply it.

Types

type Config added in v0.1.1

type Config struct {
	// Name is made available to templates.
	Name 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
	// ProjectDir is the directory where project files should be written.
	ProjectDir 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
	// Skeleton provides the files and values for the new project.
	Skeleton *kickoff.Skeleton
	// Values are user defined values that are merged on top of values from the
	// project skeleton.
	Values template.Values
}

Config holds the configuration for a new project.

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 OpType added in v0.3.0

type OpType uint8

OpType defines the type of operation that should be performed for a given project file, template or directory.

const (
	OpCreate OpType = iota
	OpSkipExisting
	OpSkipUser
	OpOverwrite
)

type Operation added in v0.3.0

type Operation struct {
	Type   OpType
	Source *kickoff.BufferedFile
	Dest   *Destination
}

Operation defines an operation involving a source and destination file. This is produced by a plan to review it before actually performing it.

type Plan added in v0.3.0

type Plan struct {
	OpCounts   map[OpType]int
	Operations []*Operation
	// contains filtered or unexported fields
}

Plan holds the operations to create a new project. A plan is created from a project configuration and can be inspected/printed before being applied.

func MakePlan added in v0.3.0

func MakePlan(config *Config) (*Plan, error)

MakePlan creates a creation plan for the given config.

func (*Plan) Apply added in v0.3.0

func (p *Plan) Apply() error

Apply applies the plan. It will write all necessary project files to the target directory.

func (*Plan) IsNoOp added in v0.3.0

func (p *Plan) IsNoOp() bool

IsNoOp returns true if the plan does not contain any operations or if there are solely skip operations.

func (*Plan) SkipsExisting added in v0.3.0

func (p *Plan) SkipsExisting() bool

SkipsExisting returns true if the plan skips some existing files.

Jump to

Keyboard shortcuts

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