diff --git a/README.md b/README.md index 4de6b3abd..8574a9a26 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ USAGE: gopm [global options] command [command options] [arguments...] VERSION: - 0.6.3.0220 + 0.6.3.0311 COMMANDS: get fetch remote package(s) and dependencies to local repository diff --git a/cmd/gen.go b/cmd/gen.go index 6abd821d8..1c78171e0 100644 --- a/cmd/gen.go +++ b/cmd/gen.go @@ -41,6 +41,8 @@ Make sure you run this command in the root path of a go project.`, }, } +var commonRes = []string{"views", "templates", "static", "public", "conf"} + func runGen(ctx *cli.Context) { setup(ctx) @@ -55,9 +57,9 @@ func runGen(ctx *cli.Context) { } targetPath := parseTarget(gf.MustValue("target", "path")) - // Get dependencies. + // Get and set dependencies. imports := doc.GetAllImports([]string{workDir}, targetPath, ctx.Bool("example")) - + log.Log("%v", imports) for _, p := range imports { p = doc.GetProjectPath(p) // Skip subpackage(s) of current project. @@ -71,6 +73,15 @@ func runGen(ctx *cli.Context) { } } + // Get and set resources. + res := make([]string, 0, len(commonRes)) + for _, cr := range commonRes { + if com.IsExist(cr) { + res = append(res, cr) + } + } + gf.SetValue("res", "include", strings.Join(res, "|")) + err = goconfig.SaveConfigFile(gf, ".gopmfile") if err != nil { log.Error("gen", "Fail to save gopmfile:") diff --git a/cmd/get.go b/cmd/get.go index 7742d2d2d..a6f616b86 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -191,9 +191,6 @@ func copyToGopath(srcPath, destPath string) { // if the commit is empty string, then it downloads all dependencies, // otherwise, it only downloada package with specific commit only. func downloadPackages(ctx *cli.Context, nodes []*doc.Node) { - for _, node := range nodes { - fmt.Println(node) - } // Check all packages, they may be raw packages path. for _, n := range nodes { // Check if local reference @@ -233,8 +230,8 @@ func downloadPackages(ctx *cli.Context, nodes []*doc.Node) { n.ImportPath, n.Type, doc.CheckNodeValue(n.Value)) // Only copy when no version control. - if ctx.Bool("gopath") && com.IsExist(installPath) || - len(getVcsName(gopathDir)) == 0 { + if ctx.Bool("gopath") && (com.IsExist(installPath) || + len(getVcsName(gopathDir)) == 0) { copyToGopath(installPath, gopathDir) } continue diff --git a/doc/github.go b/doc/github.go index ffd7a77ea..0bd62c391 100644 --- a/doc/github.go +++ b/doc/github.go @@ -63,8 +63,9 @@ func getGithubDoc(client *http.Client, match map[string]string, installRepoPath err := com.HttpGetJSON(client, com.Expand("https://api.github.com/repos/{owner}/{repo}/git/refs?{cred}", match), &refs) if err != nil { - log.Error("GET", "Fail to get revision") - log.Error("", err.Error()) + log.Warn("GET", "Fail to get revision") + log.Warn("", err.Error()) + log.Help("Try 'gopm config github' to set and gain more API calls") break } diff --git a/doc/utils.go b/doc/utils.go index 327a29dea..558ab2ac9 100644 --- a/doc/utils.go +++ b/doc/utils.go @@ -56,26 +56,27 @@ func GetImports(absPath, importPath string, example bool) []string { } } - //fis := GetDirsInfo(absPath) + fis := GetDirsInfo(absPath) absPath += "/" - // Load too much, skip for now. - // dirs := make([]string, 0) - // for _, fi := range fis { - // if fi.IsDir() && !strings.Contains(fi.Name(), VENDOR) { - // dirs = append(dirs, absPath+fi.Name()) - // } - // } - imports := make([]string, 0, len(pkg.Imports)) for _, p := range pkg.Imports { if !IsGoRepoPath(p) && !strings.HasPrefix(p, importPath) { imports = append(imports, p) } } - // if len(dirs) > 0 { - // imports = append(imports, GetAllImports(dirs, importPath, example)...) - // } + + // TODO: Load too much + dirs := make([]string, 0, len(imports)) + for _, fi := range fis { + if fi.IsDir() && !strings.Contains(fi.Name(), VENDOR) { + dirs = append(dirs, absPath+fi.Name()) + } + } + + if len(dirs) > 0 { + imports = append(imports, GetAllImports(dirs, importPath, example)...) + } return imports } diff --git a/gopm.go b/gopm.go index 5f00d2467..0695a5ad9 100644 --- a/gopm.go +++ b/gopm.go @@ -29,7 +29,7 @@ import ( // Test that go1.1 tag above is included in builds. main.go refers to this definition. const go11tag = true -const APP_VER = "0.6.3.0301" +const APP_VER = "0.6.3.0312" // //cmd.CmdSearch, // cmdClean,