main.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package main
  2. import (
  3. "fmt"
  4. "runtime"
  5. "time"
  6. "github.com/gosuri/uiprogress"
  7. "github.com/manifoldco/promptui"
  8. "github.com/ttacon/chalk"
  9. )
  10. var logo = `
  11. __ __ _ _ _ _
  12. / / /\ \ (_) | _(_) (_)___
  13. \ \/ \/ / | |/ / | | / __|
  14. \ /\ /| | <| |_ | \__ \
  15. \/ \/ |_|_|\_\_(_)/ |___/
  16. |__/
  17. `
  18. var finish = `
  19. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  20. | |
  21. | Open http://localhost:3000/ in your browser |
  22. | to complete the installation! |
  23. | |
  24. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  25. `
  26. func main() {
  27. fmt.Println(chalk.Yellow.Color(logo))
  28. fmt.Println(chalk.Bold.TextStyle("Installer for Wiki.js 2.x"))
  29. fmt.Printf("%s-%s\n\n", runtime.GOOS, runtime.GOARCH)
  30. // Check system requirements
  31. fmt.Println(chalk.Bold.TextStyle("Verifying system requirements..."))
  32. CheckNodeJs()
  33. CheckRAM()
  34. fmt.Println(chalk.Bold.TextStyle("\nSetup"))
  35. // Prompt for build to install
  36. promptBuild := promptui.Select{
  37. Label: "Select Build to install",
  38. Items: []string{"Stable", "Dev"},
  39. Templates: &promptui.SelectTemplates{
  40. Help: " ",
  41. Selected: chalk.Green.Color("✔") + " Build: {{ . }}",
  42. },
  43. }
  44. _, _, err := promptBuild.Run()
  45. if err != nil {
  46. fmt.Printf("Prompt failed %v\n", err)
  47. return
  48. }
  49. // Choose database driver
  50. promptDB := promptui.Select{
  51. Label: "Select database driver",
  52. Items: []string{"MariaDB", "MySQL", "MS SQL Server", "PostgreSQL", "SQLite"},
  53. Templates: &promptui.SelectTemplates{
  54. Help: " ",
  55. Selected: chalk.Green.Color("✔") + " Database Driver: {{ . }}",
  56. },
  57. Size: 10,
  58. }
  59. _, _, err = promptDB.Run()
  60. // Port
  61. promptPort := promptui.Prompt{
  62. Label: "Port",
  63. Default: "3000",
  64. Templates: &promptui.PromptTemplates{
  65. Success: chalk.Green.Color("✔") + " Port: {{ . }}",
  66. },
  67. }
  68. _, err = promptPort.Run()
  69. // Download archives...
  70. fmt.Println(chalk.Bold.TextStyle("\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. fmt.Println("\n" + chalk.Yellow.Color(finish))
  79. }