Skip to content

Commit

Permalink
Improve check new version and release 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosstrand committed May 30, 2020
1 parent 41711b7 commit fe8f0c7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
18 changes: 3 additions & 15 deletions commands/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ package commands

import (
"fmt"
"github.com/briandowns/spinner"
"github.com/fatih/color"
zeptocli "github.com/go-zepto/zepto-cli"
"github.com/go-zepto/zepto-cli/utils"
"github.com/spf13/cobra"
"os"
"os/exec"
"path"
"path/filepath"
"strings"
"github.com/briandowns/spinner"
"time"
"github.com/tcnksm/go-latest"
)

var DEFAULT_TMPL_MODULE_PATH = "github.com/go-zepto/templates/default"
Expand Down Expand Up @@ -57,19 +57,7 @@ var NewCmd = &cobra.Command{
Short: "Create a new zepto project",
Args: cobra.MinimumNArgs(2),
Run: func(cmd *cobra.Command, args []string) {

githubTag := &latest.GithubTag{
Owner: "go-zepto",
Repository: "zepto-cli",
}

res, _ := latest.Check(githubTag, zeptocli.VERSION)
if res != nil && res.Outdated {
fmt.Printf("%s is not latest. Please, consider upgrade to %s:\n go get -u github.com/go-zepto/zepto-cli/cmd/zepto", zeptocli.VERSION, res.Current)
}



utils.WarnVersion()
if args[0] == "web" {
ExecuteWeb(args)
} else if args[0] == "ms" {
Expand Down
22 changes: 22 additions & 0 deletions utils/warn_version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package utils

import (
"fmt"
"github.com/fatih/color"
zeptocli "github.com/go-zepto/zepto-cli"
"github.com/tcnksm/go-latest"
)

func WarnVersion() {
fmt.Println("zepto-cli@" + zeptocli.VERSION)
githubTag := &latest.GithubTag{
Owner: "go-zepto",
Repository: "zepto-cli",
}

res, _ := latest.Check(githubTag, zeptocli.VERSION)
if res != nil && res.Outdated {
color.Yellow("A new zepto-cli version (%s) is available.\n", res.Current)
fmt.Printf("Please, consider upgrade:\n\tgo get -u github.com/go-zepto/zepto-cli/cmd/zepto\n\n")
}
}
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package zeptocli

var VERSION = "0.0.1"
var VERSION = "0.0.2"

0 comments on commit fe8f0c7

Please sign in to comment.