Implement basic flavor support
This commit is contained in:
parent
9a3e508ce8
commit
d6c0c465e4
24 changed files with 246 additions and 82 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package manager
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"slices"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/barrel"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/barrel/composer"
|
||||
|
|
@ -27,8 +30,81 @@ type Manager struct {
|
|||
}
|
||||
}
|
||||
|
||||
// profiles contains the list of default profiles
|
||||
var (
|
||||
defaultProfile = "Drupal 10"
|
||||
profiles = map[string]Profile{
|
||||
"Drupal 9": {
|
||||
Description: "Legacy Version of Drupal with default packages",
|
||||
|
||||
Drupal: "^9",
|
||||
WissKI: "",
|
||||
InstallModules: []string{
|
||||
"drupal/inline_entity_form:^1.0@RC",
|
||||
"drupal/imagemagick",
|
||||
"drupal/image_effects",
|
||||
"drupal/colorbox",
|
||||
},
|
||||
EnableModules: []string{
|
||||
"drupal/devel:^4.1",
|
||||
"drupal/geofield:^1.40",
|
||||
"drupal/geofield_map:^2.85",
|
||||
"drupal/imce:^2.4",
|
||||
"drupal/remove_generator:^2.0",
|
||||
},
|
||||
},
|
||||
"Drupal 10": {
|
||||
Description: "Current Version of Drupal with default packages",
|
||||
|
||||
Drupal: "^10",
|
||||
WissKI: "",
|
||||
InstallModules: []string{
|
||||
|
||||
"drupal/inline_entity_form:^1.0@RC",
|
||||
"drupal/imagemagick",
|
||||
"drupal/image_effects",
|
||||
"drupal/colorbox",
|
||||
},
|
||||
EnableModules: []string{
|
||||
"drupal/devel:^5.0",
|
||||
"drupal/geofield:^1.56",
|
||||
"drupal/geofield_map:^3.0",
|
||||
"drupal/imce:^3.0",
|
||||
"drupal/remove_generator:^2.0",
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// TODO: All of these should move to the config
|
||||
|
||||
func LoadDefaultProfile() Profile {
|
||||
return LoadProfile(DefaultProfile())
|
||||
}
|
||||
|
||||
func Profiles() map[string]Profile {
|
||||
return maps.Clone(profiles)
|
||||
}
|
||||
|
||||
func LoadProfile(name string) Profile {
|
||||
return profiles[name]
|
||||
}
|
||||
|
||||
func HasProfile(name string) bool {
|
||||
_, ok := profiles[name]
|
||||
return ok
|
||||
}
|
||||
|
||||
func DefaultProfile() string {
|
||||
return defaultProfile
|
||||
}
|
||||
|
||||
// Profile represents a profile applied to a WissKI instance of the Distillery.
|
||||
type Profile struct {
|
||||
// Description is a human-readable description for this profile.
|
||||
// It is only used by the frontend.
|
||||
Description string
|
||||
|
||||
Drupal string // Version of Drupal to use
|
||||
WissKI string // Version of WissKI to use
|
||||
|
||||
|
|
@ -36,29 +112,25 @@ type Profile struct {
|
|||
EnableModules []string // Modules to be installed and enabled
|
||||
}
|
||||
|
||||
// DefaultDrupalVersion is the default drupal version
|
||||
const DefaultDrupalVersion = "^9.0.0"
|
||||
|
||||
// ApplyDefaults applies the default settings to missing profile settings.
|
||||
func (profile *Profile) ApplyDefaults() {
|
||||
// Apply copies over defaults from the other profile to this one.
|
||||
// If a field is already set, no defaults are copied.
|
||||
func (profile *Profile) Apply(other Profile) {
|
||||
if profile.Drupal == "" {
|
||||
profile.Drupal = DefaultDrupalVersion
|
||||
profile.Drupal = other.Drupal
|
||||
}
|
||||
if profile.WissKI == "" {
|
||||
profile.WissKI = other.WissKI
|
||||
}
|
||||
if profile.InstallModules == nil {
|
||||
profile.InstallModules = []string{
|
||||
"drupal/inline_entity_form:^1.0@RC",
|
||||
"drupal/imagemagick",
|
||||
"drupal/image_effects",
|
||||
"drupal/colorbox",
|
||||
}
|
||||
profile.InstallModules = slices.Clone(other.InstallModules)
|
||||
}
|
||||
if profile.EnableModules == nil {
|
||||
profile.EnableModules = []string{
|
||||
"drupal/devel:^4.1",
|
||||
"drupal/geofield:^1.40",
|
||||
"drupal/geofield_map:^2.85",
|
||||
"drupal/imce:^2.4",
|
||||
"drupal/remove_generator:^2.0",
|
||||
}
|
||||
profile.EnableModules = slices.Clone(profile.EnableModules)
|
||||
}
|
||||
}
|
||||
|
||||
// ApplyDefaults loads some set of defaults.
|
||||
// If all fields are set, no defaults are applied.
|
||||
func (profile *Profile) ApplyDefaults() {
|
||||
profile.Apply(profiles[defaultProfile])
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue