diff --git a/README.md b/README.md index cc52cc4..0acede8 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,6 @@ Use "boss [command] --help" for more information about a command. + Sample: + `boss install github.com/HashLoad/horse` + `boss install github.com/HashLoad/horse:1.0.0` + + +### For use yor project in boss create a tag with [semantic version](https://semver.org/) diff --git a/cmd/init.go b/cmd/init.go index 9fb9b90..8c437d1 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -3,11 +3,12 @@ package cmd import ( "bufio" "fmt" - "github.com/hashload/boss/models" - "github.com/spf13/cobra" "os" "path/filepath" "regexp" + + "github.com/hashload/boss/models" + "github.com/spf13/cobra" ) var initCmd = &cobra.Command{ @@ -27,7 +28,7 @@ var initCmd = &cobra.Command{ } pkgJson.Name = getParamOrDef("package name: ("+folderName+")", folderName) - pkgJson.Homepage = getParamOrDef("homepage:", "") + pkgJson.Homepage = getParamOrDef("homepage", "") pkgJson.Version = getParamOrDef("version: (1.0.0)", "1.0.0") pkgJson.Description = getParamOrDef("description", "") pkgJson.MainSrc = getParamOrDef("source folder: (src/)", "src/") @@ -55,11 +56,11 @@ func getParamOrDef(msg string, def string) string { func printHead() { println(` -This utility will walk you through creating a package.json file. +This utility will walk you through creating a boss.json file. It only covers the most common items, and tries to guess sensible defaults. Use 'boss install ' afterwards to install a package and -save it as a dependency in the package.json file. +save it as a dependency in the boss.json file. Press ^C at any time to quit. {like npm @_@ }`) diff --git a/cmd/install.go b/cmd/install.go index 9af14e3..b0af5ae 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -1,6 +1,8 @@ package cmd import ( + "strings" + "github.com/hashload/boss/core" "github.com/hashload/boss/core/gb" "github.com/hashload/boss/core/paths" @@ -8,7 +10,6 @@ import ( "github.com/hashload/boss/msg" "github.com/hashload/boss/utils" "github.com/spf13/cobra" - "strings" ) var dev bool @@ -28,7 +29,7 @@ var installCmd = &cobra.Command{ split := strings.Split(dependency, ":") var ver string if len(split) == 1 { - ver = "^1" + ver = "x" } else { ver = split[1] } @@ -42,10 +43,11 @@ var installCmd = &cobra.Command{ if loadPackage.IsNew && len(args) == 0 { return } - loadPackage.Save() paths.EnsureModulesDir() + msg.Info("Installing modules in project patch") core.EnsureDependencies(loadPackage) utils.UpdateLibraryPath() + loadPackage.Save() gb.RunGB() }, } diff --git a/core/main.go b/core/main.go index 6c74661..6581d0e 100644 --- a/core/main.go +++ b/core/main.go @@ -94,34 +94,36 @@ func contains(a []string, x string) bool { } func processOthers() { - if len(processed) > processedOld { - processedOld = len(processed) - infos, e := ioutil.ReadDir(env.GetModulesDir()) - if e != nil { - msg.Err("Error on try load dir of modules: %s", e) - } + infos, e := ioutil.ReadDir(env.GetModulesDir()) + if e != nil { + msg.Err("Error on try load dir of modules: %s", e) + } - for _, info := range infos { - if !info.IsDir() { - continue - } - if contains(processed, info.Name()) { - continue - } - msg.Info("Processing module: %s", info.Name()) + for _, info := range infos { + if !info.IsDir() { + continue + } + if contains(processed, info.Name()) { + continue + } else { + processed = append(processed, info.Name()) + } + msg.Info("Processing module: %s", info.Name()) - fileName := filepath.Join(env.GetModulesDir(), info.Name(), "boss.json") + fileName := filepath.Join(env.GetModulesDir(), info.Name(), "boss.json") - _, i := os.Stat(fileName) - if os.IsNotExist(i) { - msg.Warn("boss.json not exists in %s", info.Name()) - } + _, i := os.Stat(fileName) + if os.IsNotExist(i) { + msg.Warn("\tboss.json not exists in %s", info.Name()) + } - if packageOther, e := models.LoadPackageOther(fileName); e != nil { - msg.Err("Error on try load package %s: %s", fileName, e) - } else { - EnsureDependencies(packageOther) + if packageOther, e := models.LoadPackageOther(fileName); e != nil { + if os.IsNotExist(e) { + continue } + msg.Err("\tError on try load package %s: %s", fileName, e) + } else { + EnsureDependencies(packageOther) } } diff --git a/glide.lock b/glide.lock index 9f15da2..de0720a 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ hash: 5669ff413f338cb319d0f0df307fbc693fb2d4113b1e55fd395402a0a096d9d5 -updated: 2018-10-01T02:29:24.5836514-03:00 +updated: 2018-10-02T10:54:30.8930988-03:00 imports: - name: github.com/beevik/etree version: 9d7e8feddccb4ed1b8afb54e368bd323d2ff652c @@ -77,6 +77,7 @@ imports: version: e4b3c5e9061176387e7cea65e4dc5853801f3fb7 subpackages: - windows + - windows/registry - name: golang.org/x/text version: 905a57155faa8230500121607930ebb9dd8e139c subpackages: diff --git a/models/dep.go b/models/dep.go index 92919e5..5fb90e1 100644 --- a/models/dep.go +++ b/models/dep.go @@ -3,10 +3,11 @@ package models import ( "crypto/md5" "encoding/hex" - "github.com/hashload/boss/msg" "io" "regexp" "strings" + + "github.com/hashload/boss/msg" ) type Dependency struct { @@ -57,6 +58,9 @@ func ParseDependency(repo string, info string) Dependency { dependency := Dependency{} dependency.Repository = repo dependency.version = parsed[0] + if dependency.version == "x" { + dependency.version = "> 0.0.0" + } if re.MatchString(dependency.version) { msg.Warn("Current version for %s is not semantic (x.y.z), for comparation using %s -> %s", dependency.Repository, dependency.version, dependency.version+".0") diff --git a/models/package.go b/models/package.go index a8e9fc5..1473c15 100644 --- a/models/package.go +++ b/models/package.go @@ -3,7 +3,6 @@ package models import ( "encoding/json" . "io/ioutil" - "time" "github.com/hashload/boss/consts" ) @@ -19,18 +18,12 @@ type Package struct { MainSrc string `json:"mainsrc"` Supported string `json:"supported"` DprojName string `json:"dprojFile"` - ModifyedAt time.Time `json:"modifyedAt"` Scripts interface{} `json:"scripts,omitempty"` Dependencies interface{} `json:"dependencies,omitempty"` DevDependencies interface{} `json:"devDependencies,omitempty"` } -func (p *Package) updateTime() { - p.ModifyedAt = time.Now() -} - func (p *Package) Save() { - p.updateTime() marshal, _ := json.MarshalIndent(p, "", "\t") WriteFile(p.fileName, marshal, 664) }