Compare commits

...

4 Commits

Author SHA1 Message Date
haiyux 1b862ccccc merge master 2 years ago
haiyux a657605ef5 fix new mod name 2 years ago
haiyux 6c646ecdcb fix 2 years ago
haiyux a9754b1688 fix: windows path failed where use --nomod 2 years ago
  1. 2
      .github/workflows/go.yml
  2. 3
      cmd/kratos/internal/project/new.go
  3. 4
      cmd/kratos/internal/project/project.go

@ -13,7 +13,7 @@ jobs:
build: build:
strategy: strategy:
matrix: matrix:
go: [1.18,1.19,1.20.x] go: [1.18, 1.19, 1.20.x]
name: build & test name: build & test
runs-on: ubuntu-latest runs-on: ubuntu-latest
services: services:

@ -16,6 +16,7 @@ import (
type Project struct { type Project struct {
Name string Name string
Path string Path string
Mod string
} }
// New new a project from remote repo. // New new a project from remote repo.
@ -39,7 +40,7 @@ func (p *Project) New(ctx context.Context, dir string, layout string, branch str
} }
fmt.Printf("🚀 Creating service %s, layout repo is %s, please wait a moment.\n\n", p.Name, layout) fmt.Printf("🚀 Creating service %s, layout repo is %s, please wait a moment.\n\n", p.Name, layout)
repo := base.NewRepo(layout, branch) repo := base.NewRepo(layout, branch)
if err := repo.CopyTo(ctx, to, p.Path, []string{".git", ".github"}); err != nil { if err := repo.CopyTo(ctx, to, p.Mod, []string{".git", ".github"}); err != nil {
return err return err
} }
e := os.Rename( e := os.Rename(

@ -66,7 +66,7 @@ func run(_ *cobra.Command, args []string) {
name = args[0] name = args[0]
} }
projectName, workingDir := processProjectParams(name, wd) projectName, workingDir := processProjectParams(name, wd)
p := &Project{Name: projectName, Path: projectName} p := &Project{Name: projectName, Path: projectName, Mod: name}
done := make(chan error, 1) done := make(chan error, 1)
go func() { go func() {
if !nomod { if !nomod {
@ -84,7 +84,7 @@ func run(_ *cobra.Command, args []string) {
panic(e) panic(e)
} }
// Get the relative path for adding a project based on Go modules // Get the relative path for adding a project based on Go modules
p.Path = filepath.Join(strings.TrimPrefix(workingDir, projectRoot+"/"), p.Name) p.Path = filepath.ToSlash(filepath.Join(strings.TrimPrefix(filepath.ToSlash(workingDir), filepath.ToSlash(projectRoot)+"/"), p.Name))
done <- p.Add(ctx, workingDir, repoURL, branch, mod) done <- p.Add(ctx, workingDir, repoURL, branch, mod)
}() }()
select { select {

Loading…
Cancel
Save