From 669a5dd77a48ba1013741242e80f5cb0b9e2d55f Mon Sep 17 00:00:00 2001 From: Marcel Kloubert Date: Sun, 5 Jan 2025 11:05:27 +0100 Subject: [PATCH] feat: enhance gpm.yaml file --- CHANGELOG.md | 4 ++++ gpm.yaml | 22 ++++++++++++++++++++++ types/gpm_file.go | 42 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4dad78..9f4fa89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log (go-package-manager) +## 0.33.0 + +- feat: enhance features of `gpm.yaml` file + ## 0.32.0 - **BREAKING CHANGE**: when an environment is defined, the root base path of the application changes from `${HOME}/.gpm` to the specified path diff --git a/gpm.yaml b/gpm.yaml index 812b26d..19c4ed0 100644 --- a/gpm.yaml +++ b/gpm.yaml @@ -1,4 +1,26 @@ name: "gpm" +display_name: "Go Package Manager" +description: "A centralized enhancement and improvement of the existing Go toolchain" +homepage: "https://gpm.kloubert.dev" +license: "MIT" + +contributors: + - name: "Marcel J. Kloubert" + homepage: "https://marcel.coffee" + role: "Maintainer" + +donations: + buy_me_a_coffee: "https://www.buymeacoffee.com/mkloubert" + patreon: "https://www.patreon.com/mkloubert" + paypal: "https://paypal.me/MarcelKloubert" + +repositories: + - name: "GitHub (HTTP)" + type: "git" + url: "https://github.com/mkloubert/go-package-manager.git" + - name: "GitHub (SSH)" + type: "git" + url: "git@github.com:mkloubert/go-package-manager.git" files: - ^go-package-manager(\.exe)?$ diff --git a/types/gpm_file.go b/types/gpm_file.go index 57f27d6..1d91992 100644 --- a/types/gpm_file.go +++ b/types/gpm_file.go @@ -29,11 +29,34 @@ import ( "github.com/goccy/go-yaml" ) -// A GpmFile stores all data of a gpm.y(a)ml file. +// GpmFile stores all data of a gpm.y(a)ml file. type GpmFile struct { - Files []string `yaml:"files,omitempty"` // whitelist of file patterns which are used by pack command for example - Name string `yaml:"name,omitempty"` // the name - Scripts map[string]string `yaml:"scripts,omitempty"` // one or more scripts + Contributors []GpmFileContributor `yaml:"contributors,omitempty"` // list of contributors + Description string `yaml:"description,omitempty"` // the description + DisplayName string `yaml:"display_name,omitempty"` // the display name + Donations map[string]string `yaml:"donations,omitempty"` // one or more donation links + Files []string `yaml:"files,omitempty"` // whitelist of file patterns which are used by pack command for example + Homepage string `yaml:"homepage,omitempty"` // the homepage + License string `yaml:"license,omitempty"` // the license + Name string `yaml:"name,omitempty"` // the name + Repositories []GpmFileRepository `yaml:"repositories,omitempty"` // source code repository information + Scripts map[string]string `yaml:"scripts,omitempty"` // one or more scripts +} + +// GpmFileContributor is an item inside `Contributors` of a +// `GpmFile` instance +type GpmFileContributor struct { + Homepage string `yaml:"homepage,omitempty"` // the homepage url + Name string `yaml:"name,omitempty"` // the full name + Role string `yaml:"role,omitempty"` // the role +} + +// GpmFileRepository is an item inside `Repositories` of a +// `GpmFile` instance +type GpmFileRepository struct { + Name string `yaml:"name,omitempty"` // the full name + Type string `yaml:"type,omitempty"` // the type + Url string `yaml:"url,omitempty"` // the url } // GetFilesSectionByEnvSafe() - will return environment specific `files` section in `gpm.yaml` @@ -52,7 +75,7 @@ func (g *GpmFile) GetFilesSectionByEnvSafe(envName string) []string { if ok && maybeArray != nil { files, ok := maybeArray.([]string) if ok && files != nil { - return files + return files // found existing, valid string array } } } @@ -65,9 +88,18 @@ func (g *GpmFile) GetFilesSectionByEnvSafe(envName string) []string { func LoadGpmFile(gpmFilePath string) (GpmFile, error) { var gpm GpmFile defer func() { + if gpm.Contributors == nil { + gpm.Contributors = []GpmFileContributor{} + } + if gpm.Donations == nil { + gpm.Donations = map[string]string{} + } if gpm.Files == nil { gpm.Files = []string{} } + if gpm.Repositories == nil { + gpm.Repositories = []GpmFileRepository{} + } if gpm.Scripts == nil { gpm.Scripts = map[string]string{} }