You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.2 KiB

  1. package main
  2. import (
  3. "fmt"
  4. "runtime"
  5. "github.com/bugsnag/bugsnag-go"
  6. "github.com/fatih/color"
  7. "gopkg.in/AlecAivazis/survey.v1"
  8. )
  9. var qs = []*survey.Question{
  10. {
  11. Name: "location",
  12. Prompt: &survey.Input{
  13. Message: "Where do you want to install Wiki.js?",
  14. Default: "./wiki",
  15. },
  16. Validate: survey.Required,
  17. },
  18. {
  19. Name: "dbtype",
  20. Prompt: &survey.Select{
  21. Message: "Select a DB Driver:",
  22. Options: []string{"MariabDB", "MS SQL Server", "MySQL", "PostgreSQL", "SQLite"},
  23. Default: "PostgreSQL",
  24. },
  25. },
  26. {
  27. Name: "port",
  28. Prompt: &survey.Input{
  29. Message: "Server Port:",
  30. Default: "3000",
  31. },
  32. },
  33. }
  34. func main() {
  35. bugsnag.Configure(bugsnag.Configuration{
  36. APIKey: "37770b3b08864599fd47c4edba5aa656",
  37. ReleaseStage: "dev",
  38. })
  39. bold := color.New(color.FgWhite).Add(color.Bold)
  40. logo := `
  41. __ __ _ _ _ _
  42. / / /\ \ (_) | _(_) (_)___
  43. \ \/ \/ / | |/ / | | / __|
  44. \ /\ /| | <| |_ | \__ \
  45. \/ \/ |_|_|\_\_(_)/ |___/
  46. |__/
  47. `
  48. color.Yellow(logo)
  49. bold.Println("\nInstaller for Wiki.js 2.x")
  50. fmt.Printf("%s-%s\n\n", runtime.GOOS, runtime.GOARCH)
  51. // Check system requirements
  52. bold.Println("Verifying system requirements...")
  53. CheckNodeJs()
  54. CheckRAM()
  55. fmt.Println()
  56. // the answers will be written to this struct
  57. answers := struct {
  58. Location string
  59. DBType string `survey:"dbtype"`
  60. Port int
  61. }{}
  62. // perform the questions
  63. err := survey.Ask(qs, &answers)
  64. if err != nil {
  65. fmt.Println(err.Error())
  66. return
  67. }
  68. fmt.Printf("%s chose %d.", answers.Location, answers.Port)
  69. // Download archives...
  70. bold.Println("\nDownloading packages...")
  71. // uiprogress.Start()
  72. // bar := uiprogress.AddBar(100)
  73. // bar.AppendCompleted()
  74. // bar.PrependElapsed()
  75. // for bar.Incr() {
  76. // time.Sleep(time.Millisecond * 20)
  77. // }
  78. finish := `
  79. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  80. | |
  81. | Open http://localhost:3000/ in your browser |
  82. | to complete the installation! |
  83. | |
  84. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  85. `
  86. color.Yellow("\n\n" + finish)
  87. fmt.Println("Press any key to continue.")
  88. fmt.Scanln()
  89. }