Browse Source

Merge pull request #11 from gpmgo/dev

Dev
pull/103/head
无闻 11 years ago
parent
commit
af4bc4f521
  1. 2
      README.md
  2. 15
      cmd/gen.go
  3. 7
      cmd/get.go
  4. 5
      doc/github.go
  5. 25
      doc/utils.go
  6. 2
      gopm.go

2
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

15
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:")

7
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

5
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
}

25
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
}

2
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,

Loading…
Cancel
Save