Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
feat: make it possible to use a template and still add ap4k dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
metacosm committed Mar 15, 2019
1 parent d2bd17b commit 5a55cd5
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,28 @@ func CreateZipFile(w http.ResponseWriter, r *http.Request) {
p.PackageName = params.Get("packagename")
p.OutDir = params.Get("outdir")

if len(params["module"]) > 0 {
p.Modules = asModuleArray(params["module"])
modules := params["module"]
hasModules := len(modules) > 0
if hasModules {
p.Modules = asModuleArray(modules)
}

// As dependencies and template selection can't be used together, we force the template to be equal to "custom"
// when a user selects a different template. This is because we would like to avoid to populate a project with starters
// which are incompatible or not fully tested with the template proposed
if len(params["module"]) > 0 && p.Template != "custom" {
p.Template = "custom"
useAp4k, _ := strconv.ParseBool(params.Get("ap4k"))
if useAp4k {
// make sure we have ap4k as a dependency
p.Modules = append(p.Modules, scaffold.Module{Name: "ap4k"})
}

if hasModules && p.Template != "custom" {
if useAp4k {
// if we asked to use ap4k, keep the template value but reset the modules to only ap4k to avoid incompatibilities
p.Modules = []scaffold.Module{{Name: "ap4k"}}
} else {
// As dependencies and template selection can't be used together, we force the template to be equal to "custom"
// when a user selects a different template. This is because we would like to avoid to populate a project with starters
// which are incompatible or not fully tested with the template proposed
p.Template = "custom"
}
}

log.Infof("Received request: %s", r.URL)
Expand Down

0 comments on commit 5a55cd5

Please sign in to comment.