Compare commits

..

3 Commits

Author SHA1 Message Date
Minghe Huang
3be144f644 clean up no need files 2020-03-10 10:18:07 +08:00
Minghe
2560dc23fc fix the wrong destination of copy issue (#466)
* fix the wrong destination of copy issue
* bump up version
2020-03-01 15:58:45 +08:00
dependabot-preview[bot]
3d6c3d10bf Bump github.com/golang/mock from 1.4.0 to 1.4.1 (#464)
Bumps [github.com/golang/mock](https://github.com/golang/mock) from 1.4.0 to 1.4.1.
- [Release notes](https://github.com/golang/mock/releases)
- [Changelog](https://github.com/golang/mock/blob/master/.goreleaser.yml)
- [Commits](https://github.com/golang/mock/compare/v1.4.0...v1.4.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-28 09:27:02 +08:00
7 changed files with 17 additions and 124 deletions

2
fx.go
View File

@@ -17,7 +17,7 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
)
const version = "0.9.1"
const version = "0.9.2"
func init() {
go checkForUpdate()

2
go.mod
View File

@@ -15,7 +15,7 @@ require (
github.com/gin-gonic/gin v1.4.0
github.com/gobuffalo/envy v1.8.1 // indirect
github.com/gobuffalo/packr v1.30.1
github.com/golang/mock v1.4.0
github.com/golang/mock v1.4.1
github.com/golang/snappy v0.0.1 // indirect
github.com/google/go-querystring v1.0.0
github.com/google/uuid v1.1.1

2
go.sum
View File

@@ -117,6 +117,8 @@ github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/golang/mock v1.4.0 h1:Rd1kQnQu0Hq3qvJppYSG0HtP+f5LPPUiDswTLiEegLg=
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.1 h1:ocYkMQY5RrXTYgXl7ICpV0IXwlEQGwKIsery4gyXa1U=
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=

View File

@@ -1,5 +0,0 @@
{
"master": "52.78.196.250",
"agents": [
"13.125.243.192",
],

View File

@@ -1,53 +0,0 @@
package packer
import (
"bufio"
"fmt"
"os"
"path/filepath"
"regexp"
"strings"
)
// JavaScriptExt extension of JavaScript source file
const JavaScriptExt = ".js"
func depsJavaScript(src string) ([]string, error) {
deps := []string{}
file, err := os.Open(src)
if err != nil {
return nil, err
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if strings.HasPrefix(line, "import") || strings.HasPrefix(line, "require") {
reg, err := regexp.Compile(`(\'.*\'|\".*\")`)
if err != nil {
return nil, err
}
str := reg.FindString(line)
if str != "" {
deps = append(deps, strings.ReplaceAll(strings.ReplaceAll(str, "\"", ""), "'", ""))
}
}
}
if err := scanner.Err(); err != nil {
return nil, err
}
return deps, nil
}
// Deps to get the dependencies required from a source code in a file
func Deps(src string) ([]string, error) {
switch filepath.Ext(src) {
case JavaScriptExt:
{
return depsJavaScript(src)
}
}
return nil, fmt.Errorf("not support language: %s", filepath.Ext(src))
}

View File

@@ -1,63 +0,0 @@
package packer
import (
"io/ioutil"
"os"
"reflect"
"testing"
)
func TestDeps(t *testing.T) {
cases := []struct {
name string
content string
expect []string
}{
{name: "import with singe quote", content: "import 'pkg1'", expect: []string{"pkg1"}},
{name: "import with double quote", content: `import "pkg1"`, expect: []string{"pkg1"}},
{name: "require with singe quote", content: "require 'pkg1'", expect: []string{"pkg1"}},
{name: "require with double quote", content: `require "pkg1"`, expect: []string{"pkg1"}},
{
name: "require and import with singe quote",
content: `
require 'pkg1'
import 'pkg2'`,
expect: []string{"pkg1", "pkg2"},
},
{
name: "require and import with double quote",
content: `
require "pkg1"
import "pkg2"`,
expect: []string{"pkg1", "pkg2"},
},
{
name: "require and import with double quote and single quote",
content: `
require 'pkg1'
import "pkg2"`,
expect: []string{"pkg1", "pkg2"},
},
}
for _, c := range cases {
fd, err := ioutil.TempFile("", "dep_pkg_*.js")
if err != nil {
t.Fatal(err)
}
defer os.Remove(fd.Name())
err = ioutil.WriteFile(fd.Name(), []byte(c.content), 0666)
if err != nil {
t.Fatal(err)
}
deps, err := Deps(fd.Name())
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(deps, c.expect) {
t.Fatalf("%s: should get %s but got %s", c.name, c.expect, deps)
}
}
}

View File

@@ -149,9 +149,21 @@ func merge(dest string, input ...string) error {
return err
}
if err := copy.Copy(file, dest); err != nil {
stat, err := os.Stat(path)
if err != nil {
return err
}
if stat.Mode().IsRegular() {
destDir := filepath.Join(dest, filepath.Dir(path))
if err := utils.EnsureDir(destDir); err != nil {
return err
}
if err := copy.Copy(file, destDir); err != nil {
return err
}
}
return nil
}); err != nil {
return err