2018-08-14 03:31:14 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"runtime"
|
|
|
|
|
2018-08-19 05:22:59 +00:00
|
|
|
"github.com/bugsnag/bugsnag-go"
|
|
|
|
"github.com/fatih/color"
|
|
|
|
"gopkg.in/AlecAivazis/survey.v1"
|
2018-08-14 03:31:14 +00:00
|
|
|
)
|
|
|
|
|
2018-08-19 05:22:59 +00:00
|
|
|
var qs = []*survey.Question{
|
|
|
|
{
|
|
|
|
Name: "location",
|
|
|
|
Prompt: &survey.Input{
|
|
|
|
Message: "Where do you want to install Wiki.js?",
|
|
|
|
Default: "./wiki",
|
|
|
|
},
|
|
|
|
Validate: survey.Required,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "dbtype",
|
|
|
|
Prompt: &survey.Select{
|
|
|
|
Message: "Select a DB Driver:",
|
|
|
|
Options: []string{"MariabDB", "MS SQL Server", "MySQL", "PostgreSQL", "SQLite"},
|
|
|
|
Default: "PostgreSQL",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "port",
|
|
|
|
Prompt: &survey.Input{
|
|
|
|
Message: "Server Port:",
|
|
|
|
Default: "3000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2018-08-18 06:04:31 +00:00
|
|
|
|
2018-08-14 03:31:14 +00:00
|
|
|
func main() {
|
2018-08-19 05:22:59 +00:00
|
|
|
bugsnag.Configure(bugsnag.Configuration{
|
|
|
|
APIKey: "37770b3b08864599fd47c4edba5aa656",
|
|
|
|
ReleaseStage: "dev",
|
|
|
|
})
|
|
|
|
|
|
|
|
bold := color.New(color.FgWhite).Add(color.Bold)
|
|
|
|
|
|
|
|
logo := `
|
|
|
|
__ __ _ _ _ _
|
|
|
|
/ / /\ \ (_) | _(_) (_)___
|
|
|
|
\ \/ \/ / | |/ / | | / __|
|
|
|
|
\ /\ /| | <| |_ | \__ \
|
|
|
|
\/ \/ |_|_|\_\_(_)/ |___/
|
|
|
|
|__/
|
|
|
|
`
|
|
|
|
color.Yellow(logo)
|
|
|
|
|
|
|
|
bold.Println("\nInstaller for Wiki.js 2.x")
|
2018-08-18 06:04:31 +00:00
|
|
|
fmt.Printf("%s-%s\n\n", runtime.GOOS, runtime.GOARCH)
|
|
|
|
|
|
|
|
// Check system requirements
|
|
|
|
|
2018-08-19 05:22:59 +00:00
|
|
|
bold.Println("Verifying system requirements...")
|
2018-08-18 06:04:31 +00:00
|
|
|
CheckNodeJs()
|
|
|
|
CheckRAM()
|
2018-08-19 05:22:59 +00:00
|
|
|
fmt.Println()
|
2018-08-14 03:31:14 +00:00
|
|
|
|
2018-08-19 05:22:59 +00:00
|
|
|
// the answers will be written to this struct
|
|
|
|
answers := struct {
|
|
|
|
Location string
|
|
|
|
DBType string `survey:"dbtype"`
|
|
|
|
Port int
|
|
|
|
}{}
|
2018-08-14 03:31:14 +00:00
|
|
|
|
2018-08-19 05:22:59 +00:00
|
|
|
// perform the questions
|
|
|
|
err := survey.Ask(qs, &answers)
|
2018-08-14 03:31:14 +00:00
|
|
|
if err != nil {
|
2018-08-19 05:22:59 +00:00
|
|
|
fmt.Println(err.Error())
|
2018-08-14 03:31:14 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-08-19 05:22:59 +00:00
|
|
|
fmt.Printf("%s chose %d.", answers.Location, answers.Port)
|
2018-08-14 03:31:14 +00:00
|
|
|
|
|
|
|
// Download archives...
|
|
|
|
|
2018-08-19 05:22:59 +00:00
|
|
|
bold.Println("\nDownloading packages...")
|
2018-08-18 06:04:31 +00:00
|
|
|
|
2018-08-19 05:22:59 +00:00
|
|
|
// uiprogress.Start()
|
|
|
|
// bar := uiprogress.AddBar(100)
|
2018-08-14 03:31:14 +00:00
|
|
|
|
2018-08-19 05:22:59 +00:00
|
|
|
// bar.AppendCompleted()
|
|
|
|
// bar.PrependElapsed()
|
2018-08-14 03:31:14 +00:00
|
|
|
|
2018-08-19 05:22:59 +00:00
|
|
|
// for bar.Incr() {
|
|
|
|
// time.Sleep(time.Millisecond * 20)
|
|
|
|
// }
|
|
|
|
|
|
|
|
finish := `
|
|
|
|
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
|
|
| |
|
|
|
|
| Open http://localhost:3000/ in your browser |
|
|
|
|
| to complete the installation! |
|
|
|
|
| |
|
|
|
|
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
|
|
`
|
|
|
|
color.Yellow("\n\n" + finish)
|
2018-08-18 06:04:31 +00:00
|
|
|
|
2018-08-19 05:22:59 +00:00
|
|
|
fmt.Println("Press any key to continue.")
|
|
|
|
fmt.Scanln()
|
2018-08-14 03:31:14 +00:00
|
|
|
}
|