@ -17,6 +17,7 @@ import (
"github.com/mitchellh/go-wordwrap"
"github.com/writeas/web-core/auth"
"strconv"
"strings"
)
type SetupData struct {
@ -24,7 +25,7 @@ type SetupData struct {
Config * Config
}
func Configure ( fname string ) ( * SetupData , error ) {
func Configure ( fname string , configSections string ) ( * SetupData , error ) {
data := & SetupData { }
var err error
if fname == "" {
@ -52,9 +53,6 @@ func Configure(fname string) (*SetupData, error) {
fmt . Println ( wordwrap . WrapString ( " This quick configuration process will " + action + " the application's config file, " + fname + ".\n\n It validates your input along the way, so you can be sure any future errors aren't caused by a bad configuration. If you'd rather configure your server manually, instead run: writefreely --create-config and edit that file." , 75 ) )
fmt . Println ( )
title ( " Server setup " )
fmt . Println ( )
tmpls := & promptui . PromptTemplates {
Success : "{{ . | bold | faint }}: " ,
}
@ -62,8 +60,15 @@ func Configure(fname string) (*SetupData, error) {
Selected : fmt . Sprintf ( ` {{ .Label }} {{ . | faint }} ` ) ,
}
var selPrompt promptui . Select
var prompt promptui . Prompt
if strings . Contains ( configSections , "server" ) {
title ( " Server setup " )
fmt . Println ( )
// Environment selection
selPrompt := promptui . Select {
selPrompt = promptui . Select {
Templates : selTmpls ,
Label : "Environment" ,
Items : [ ] string { "Development" , "Production, standalone" , "Production, behind reverse proxy" } ,
@ -77,7 +82,6 @@ func Configure(fname string) (*SetupData, error) {
data . Config . Server . Dev = isDevEnv
var prompt promptui . Prompt
if isDevEnv || ! isStandalone {
// Running in dev environment or behind reverse proxy; ask for port
prompt = promptui . Prompt {
@ -138,6 +142,9 @@ func Configure(fname string) (*SetupData, error) {
}
fmt . Println ( )
}
if strings . Contains ( configSections , "db" ) {
title ( " Database setup " )
fmt . Println ( )
@ -228,6 +235,9 @@ func Configure(fname string) (*SetupData, error) {
}
fmt . Println ( )
}
if strings . Contains ( configSections , "app" ) {
title ( " App setup " )
fmt . Println ( )
@ -357,6 +367,7 @@ func Configure(fname string) (*SetupData, error) {
}
data . Config . App . Private = fedStatsType == "Private"
}
}
return data , Save ( data . Config , fname )
}