2017-07-16 20:06:32 +02:00
|
|
|
package brew
|
|
|
|
|
|
|
|
import "github.com/goreleaser/goreleaser/config"
|
|
|
|
|
|
|
|
type templateData struct {
|
|
|
|
Name string
|
|
|
|
Desc string
|
|
|
|
Homepage string
|
2017-09-26 23:33:22 +02:00
|
|
|
DownloadURL string
|
2017-07-16 20:06:32 +02:00
|
|
|
Repo config.Repo // FIXME: will not work for anything but github right now.
|
|
|
|
Tag string
|
|
|
|
Version string
|
|
|
|
Caveats string
|
|
|
|
File string
|
|
|
|
SHA256 string
|
|
|
|
Plist string
|
|
|
|
Install []string
|
|
|
|
Dependencies []string
|
|
|
|
Conflicts []string
|
|
|
|
Tests []string
|
|
|
|
}
|
|
|
|
|
|
|
|
const formulaTemplate = `class {{ .Name }} < Formula
|
|
|
|
desc "{{ .Desc }}"
|
|
|
|
homepage "{{ .Homepage }}"
|
2017-09-27 00:00:24 +02:00
|
|
|
url "{{ .DownloadURL }}/{{ .Repo.Owner }}/{{ .Repo.Name }}/releases/download/{{ .Tag }}/{{ .File }}"
|
2017-07-16 20:06:32 +02:00
|
|
|
version "{{ .Version }}"
|
|
|
|
sha256 "{{ .SHA256 }}"
|
|
|
|
|
|
|
|
{{- if .Dependencies }}
|
2017-11-13 21:49:45 +02:00
|
|
|
{{ range $index, $element := .Dependencies }}
|
2017-07-16 20:06:32 +02:00
|
|
|
depends_on "{{ . }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- if .Conflicts }}
|
2017-11-13 21:49:45 +02:00
|
|
|
{{ range $index, $element := .Conflicts }}
|
2017-07-16 20:06:32 +02:00
|
|
|
conflicts_with "{{ . }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
def install
|
|
|
|
{{- range $index, $element := .Install }}
|
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
|
|
|
|
{{- if .Caveats }}
|
|
|
|
|
|
|
|
def caveats
|
|
|
|
"{{ .Caveats }}"
|
|
|
|
end
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- if .Plist }}
|
|
|
|
|
|
|
|
plist_options :startup => false
|
|
|
|
|
|
|
|
def plist; <<-EOS.undent
|
|
|
|
{{ .Plist }}
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- if .Tests }}
|
|
|
|
|
|
|
|
test do
|
|
|
|
{{- range $index, $element := .Tests }}
|
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
`
|