Skip to content

Commit

Permalink
Merge branch 'feat/init' of https://github.com/unarxiv/cvpm into feat…
Browse files Browse the repository at this point in the history
…/init
  • Loading branch information
xzyaoi committed Dec 19, 2018
2 parents c53f04e + 55adf51 commit 0d8f72c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ func validateConfig() {
// create logs folder
logsFolder := filepath.Join(cvpmPath, "logs")
createFolderIfNotExist(logsFolder)
// create webui folder
webuiFolder := filepath.Join(cvpmPath, "webui")
createFolderIfNotExist(webuiFolder)
// check if system log file exists
cvpmLogPath := filepath.Join(cvpmPath, "logs", "system.log")
createFileIfNotExist(cvpmLogPath)
Expand Down
4 changes: 4 additions & 0 deletions cli/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ You can uninstall that service by using cvpm daemon uninstall */
package main

import (
"github.com/gin-contrib/static"
"github.com/fatih/color"
"github.com/gin-gonic/gin"
"github.com/googollee/go-socket.io"
Expand Down Expand Up @@ -154,6 +155,8 @@ func BeforeResponse() gin.HandlerFunc {
/repos -> Get to fetch Running Repos
*/
func runServer(port string) {
config := readConfig()
webuiFolder := filepath.Join(config.Local.LocalFolder, "webui")
color.Red("Initiating")
var err error
socketServer, err = socketio.NewServer(nil)
Expand All @@ -163,6 +166,7 @@ func runServer(port string) {
r := gin.Default()
r.Use(BeforeResponse())
watchLogs(socketServer)
r.Use(static.Serve("/", static.LocalFile(webuiFolder, false)))
// Status Related Handlers
r.GET("/status", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
Expand Down
14 changes: 13 additions & 1 deletion cli/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package main
import (
"bufio"
"fmt"
"github.com/manifoldco/promptui"
"github.com/fatih/color"
"github.com/getsentry/raven-go"
"github.com/mitchellh/go-homedir"
Expand Down Expand Up @@ -52,6 +53,8 @@ func InstallHandler(c *cli.Context) {
color.Cyan("Installing... Please wait patiently")
pip([]string{"install", "cvpm", "--user"})
return
} else if remoteURL == "webui" {
InstallWebUi()
} else {
color.Cyan("Installing to " + localFolder)
}
Expand Down Expand Up @@ -87,6 +90,7 @@ func DaemonHandler(c *cli.Context) {
}
}

// Handle Repo Related Command
func RepoHandler(c *cli.Context) {
taskParams := c.Args().Get(0)
switch taskParams {
Expand All @@ -113,6 +117,7 @@ func RepoHandler(c *cli.Context) {
}
}

// Handle Config Related Command
func ConfigHandler(c *cli.Context) {
homepath, _ := homedir.Dir()
configFilePath := filepath.Join(homepath, "cvpm", "config.toml")
Expand Down Expand Up @@ -159,5 +164,12 @@ func ConfigHandler(c *cli.Context) {
}

func InitHandler(c *cli.Context) {

prompt := promptui.Prompt{
Label: "String",
}
result, err := prompt.Run()
if err != nil {
panic(err)
}
InitNewRepo(result)
}
6 changes: 6 additions & 0 deletions cli/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,9 @@ func InstallFromGit(remoteURL string) {
writeConfig(config)
PostInstallation(repoFolder)
}

// Init a new repoo by using bolierplate
func InitNewRepo (repoName string) {
bolierplateURL := "https://github.com/cvmodel/bolierplate.git"
CloneFromGit(bolierplateURL, repoName)
}
6 changes: 6 additions & 0 deletions cli/webui.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package main

// Install Web UI -> Download Latest and Unzip
func InstallWebUi () {

}

0 comments on commit 0d8f72c

Please sign in to comment.