pkg

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TemplateIgnore = ".templateignore"
View Source
var TemplateParseIgnore = ".templateparseignore"

Functions

func CommitAndPushGithubRepo

func CommitAndPushGithubRepo(directory, branch, path, accessToken string, auth *http.BasicAuth) error

CommitAndPushGithubRepo commit and push github repo

func CopyDir

func CopyDir(srcPath string, destPath string) error

func CreateGithubRepo

func CreateGithubRepo(organization, name, description, token string, private bool) (*github.Repository, error)

CreateGithubRepo create github repo

func FileCopy

func FileCopy(src, dst string) (int64, error)

FileCopy copy file

func FileCreate

func FileCreate(content bytes.Buffer, name string, mode os.FileMode) error

FileCreate create file

func Generate

func Generate(c *TemplateConfig) (err error)

Generate example

func Generate(url, destinationPath string, cfg interface{}, githubConfig *GithubConfig, accessToken string) error {
	templatePath := filepath.Base(url)

func GetAppPath

func GetAppPath() string

GetAppPath Get the absolute path to the running directory

func GetGithubRepoAllBranches

func GetGithubRepoAllBranches(ctx context.Context, organization, name, token string) ([]*github.Branch, error)

GetGithubRepoAllBranches get all branches of github repo

func GetInstallPath

func GetInstallPath() string

GetInstallPath Different systems get different installation paths

func GetLatestVersion

func GetLatestVersion() string

GetLatestVersion get generate-tool version

func GetParseFromTemplate

func GetParseFromTemplate(dir, subPath string) (map[string]string, error)

GetParseFromTemplate get parse keys from template

func GetSubPath

func GetSubPath(directory string) ([]string, error)

GetSubPath get directory's subject path

func GetTmpPath

func GetTmpPath() string

GetTmpPath interface pid file path

func GitClone

func GitClone(url, branch, directory string, noCheckout bool, accessToken string) (*git.Repository, error)

GitClone clone git repo

func GitCloneSSH

func GitCloneSSH(url, directory, reference, privateKeyFile, password string) error

GitCloneSSH clone git repo from ssh

func GitRemote

func GitRemote(url, directory string) error

GitRemote from remote git

func IsWindows

func IsWindows() bool

IsWindows Determine whether the current system is a Windows system?

func PathCreate

func PathCreate(dir string) error

PathCreate create path

func PathExist

func PathExist(addr string) bool

PathExist path exist

Types

type Generator

type Generator struct {
	SubPath                  string
	TemplatePath             string
	DestinationPath          string
	Cfg                      interface{}
	TemplateIgnoreDirs       []string
	TemplateIgnoreFiles      []string
	TemplateParseIgnoreDirs  []string
	TemplateParseIgnoreFiles []string
}

Generator generate operator

func (*Generator) Traverse

func (e *Generator) Traverse() error

Traverse traverse all dir

func (*Generator) TraverseFunc

func (e *Generator) TraverseFunc(path string, f os.DirEntry, err error) error

TraverseFunc traverse callback

type GithubConfig

type GithubConfig struct {
	Name         string            `yaml:"name"`
	Organization string            `yaml:"organization"`
	Description  string            `yaml:"description"`
	Secrets      map[string]string `yaml:"secrets"`
	Token        string            `yaml:"token"`
}

type TemplateConfig

type TemplateConfig struct {
	Service              string        `yaml:"service"`
	TemplateUrl          string        `yaml:"templateUrl"`
	TemplateLocal        string        `yaml:"templateLocal"`
	TemplateLocalSubPath string        `yaml:"templateLocalSubPath"`
	CreateRepo           bool          `yaml:"createRepo"`
	Destination          string        `yaml:"destination"`
	Github               *GithubConfig `yaml:"github"`
	Params               interface{}   `yaml:"params"`
	Ignore               []string      `yaml:"ignore"`
}

func (*TemplateConfig) OnChange

func (e *TemplateConfig) OnChange()

Jump to

Keyboard shortcuts

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