Skip to content

Commit

Permalink
feat: enhance gpm.yaml file
Browse files Browse the repository at this point in the history
  • Loading branch information
mkloubert committed Jan 5, 2025
1 parent 4615df0 commit 669a5dd
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
22 changes: 22 additions & 0 deletions gpm.yaml
Original file line number Diff line number Diff line change
@@ -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: "[email protected]:mkloubert/go-package-manager.git"

files:
- ^go-package-manager(\.exe)?$
Expand Down
42 changes: 37 additions & 5 deletions types/gpm_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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
}
}
}
Expand All @@ -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{}
}
Expand Down

0 comments on commit 669a5dd

Please sign in to comment.