app

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ApplicationDirectory string

ApplicationDirectory root directory of the cgen application

View Source
var Log = golog.Log{
	Name: "cgen",
}

Log cgen logger

View Source
var TemplatesDirectory string

TemplatesDirectory where all template generators are cached

Functions

func Bump

func Bump(bump BumpParams) (version string, err error)

Bump bump project versions

func Confirm

func Confirm(msg string)

Confirm prompt

Types

type BumpParams

type BumpParams struct {
	Place   string
	Pattern string
	DryRun  bool
	GitPush bool
}

BumpParams options for running bump

type CGen

type CGen struct {
	BaseDir      string
	TemplatesDir string
	Generator    Generator
}

CGen application

func (*CGen) Init

func (app *CGen) Init() (err error)

Init new instance of CGEN

func (*CGen) Install

func (app *CGen) Install(url string) (out string, err error)

Install a generator from git.

func (*CGen) ListInstalled

func (app *CGen) ListInstalled() (installed []string, err error)

ListInstalled generators from ~/.cgen/generators

func (*CGen) Update

func (app *CGen) Update(name string) (err error)

Update a project

type ConfigProperties added in v0.6.2

type ConfigProperties map[string]string

ConfigProperties forgot

func ReadPropertiesFile

func ReadPropertiesFile(filename string) (ConfigProperties, error)

ReadPropertiesFile reads props

type Generator

type Generator struct {
	Template Template `json:"template"`
	Project  Project  `json:"project"`
	Options  struct {
		StaticOnly     bool `json:"StaticOnly"`
		PerformUpgrade bool `json:"PerformUpgrade"`
		PromoteFile    bool `json:"PromoteFile"`
		Verbose        bool `json:"Verbose"`
	}
}

Generator struct

func (*Generator) Ask

func (gen *Generator) Ask(q Question) (answer string, err error)

Ask a question

func (*Generator) Copy

func (gen *Generator) Copy(src, dst string) error

Copy from src to dest

func (*Generator) Exec

func (gen *Generator) Exec() (err error)

Exec run the generator

func (*Generator) Extends

func (gen *Generator) Extends() error

Extends checks to see if this template extends another template and generates that first.

func (*Generator) Init

func (gen *Generator) Init(params GeneratorParams) error

Init a new instance of Generator

func (*Generator) Prompt

func (gen *Generator) Prompt() error

Prompt user to respond in the console.

func (*Generator) Pull

func (gen *Generator) Pull() error

Pull from remote repository

func (*Generator) RunAfter

func (gen *Generator) RunAfter() (err error)

RunAfter runs all commands found in config.yaml run_after prop.

func (*Generator) RunBefore

func (gen *Generator) RunBefore() (err error)

RunBefore runs all commands found in config.yaml run_before prop.

func (*Generator) WalkFiles

func (gen *Generator) WalkFiles(inPath string, file os.FileInfo, err error) error

WalkFiles files as part of the generator

type GeneratorParams

type GeneratorParams struct {
	ProjectName      string `json:"ProjectName"`      // name of this project
	TemplateName     string `json:"TemplateName"`     // selected cgen template
	ProjectDirectory string `json:"ProjectDirectory"` // destination directory for generated files
	// options
	PerformUpgrade bool `json:"PerformUpgrade"` // perform upgrade
	PromoteFile    bool `json:"PromoteFile"`    // run file promotion mode
	StaticOnly     bool `json:"StaticOnly"`     // only copy static files, no template interpolation
	Verbose        bool `json:"Verbose"`        // use verbose logging

}

GeneratorParams struct

type Project added in v0.6.2

type Project struct {
	Name      string
	Directory string
	State     ProjectState

	StateFile string
	// contains filtered or unexported fields
}

Project struct

func (*Project) AppendAnswer added in v0.6.2

func (proj *Project) AppendAnswer(key, val string) (answer string)

AppendAnswer to proj.State.Answers map

func (*Project) Init added in v0.6.2

func (proj *Project) Init() error

Init a new instance of Generator

func (*Project) LoadHelpers added in v0.6.2

func (proj *Project) LoadHelpers()

LoadHelpers adds additional helper functions

func (*Project) SaveState added in v0.6.2

func (proj *Project) SaveState() (err error)

SaveState yaml output

type ProjectState added in v0.6.2

type ProjectState struct {
	Name      string                 `json:"name"`
	Template  string                 `yaml:"template"`
	Version   string                 `yaml:"version"`
	Timestamp string                 `yaml:"timestamp"`
	Answers   map[string]interface{} `yaml:"answers"`
}

ProjectState maintains last generated state by project

type Question

type Question struct {
	Name    string   `yaml:"name"`
	Type    string   `yaml:"type"`
	Prompt  string   `yaml:"prompt"`
	Default string   `yaml:"default"`
	Options []string `yaml:"options,omitempty"`
}

Question struct for questions file.

type Template added in v0.6.2

type Template struct {
	CgenVersion   string        `yaml:"cgen_version"`
	Extends       string        `yaml:"extends"`
	Variables     yaml.MapSlice `yaml:"variables"`
	Questions     []*Question   `yaml:"questions"`
	TemplateFiles []string      `yaml:"template_files"`
	RunAfter      []string      `yaml:"run_after"`
	RunBefore     []string      `yaml:"run_before"`
	// private properties
	Name                string
	LatestVersion       string
	LatestStableVersion string
	Directory           git.Repository
	Files               string
	ConfigFile          string
}

Template - the config.yaml

func (*Template) FileIsTemplate added in v0.6.2

func (template *Template) FileIsTemplate(filePath string) (bool, error)

FileIsTemplate checks to see if file has been marked as a template and should be expanded

func (*Template) Init added in v0.6.2

func (template *Template) Init() error

Init values for template

type VersionIncrement

type VersionIncrement string

VersionIncrement major, minor, patch, pre

func (VersionIncrement) Bump

func (increment VersionIncrement) Bump(version string) (incremented string, err error)

Bump the incoming version by version increment

func (VersionIncrement) IsValid

func (increment VersionIncrement) IsValid() error

IsValid - Version Increment

Jump to

Keyboard shortcuts

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