mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-12 02:55:16 +00:00
Compare commits
3 Commits
v1.1.4
...
hotfix/v1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff8817efd9 | ||
|
|
e9e804adff | ||
|
|
b7b15f820c |
12
.travis.yml
12
.travis.yml
@@ -1,8 +1,8 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- "1.13.x"
|
||||
- "1.14.x"
|
||||
- "1.18.x"
|
||||
- "1.17.x"
|
||||
- "tip"
|
||||
|
||||
os:
|
||||
@@ -66,6 +66,14 @@ script:
|
||||
- revel new --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@$REVEL_BRANCH" -a my/testapp3 --package revelframework.com
|
||||
- revel test --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@$REVEL_BRANCH" -a my/testapp3
|
||||
|
||||
# Check vendored version of revel
|
||||
- cd $INITIALWD
|
||||
- revel new --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@$REVEL_BRANCH" -a my/testapp4 --package revelframework.com
|
||||
- cd my/testapp4
|
||||
- go mod vendor
|
||||
- cd ../..
|
||||
- revel test --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@$REVEL_BRANCH" -a my/testapp4
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- go: tip
|
||||
|
||||
2
.vscode/tasks.json
vendored
2
.vscode/tasks.json
vendored
@@ -6,7 +6,7 @@
|
||||
{
|
||||
"label": "Clean-Test-Project",
|
||||
"type": "shell",
|
||||
"command": "rm -rf ${workspaceRoot}/.temp/revel/reveltest"
|
||||
"command": "rm -rf ${workspaceRoot}/.temp/revel/reveltest && mkdir -p ${workspaceRoot}/.temp/revel/GOPATH"
|
||||
},
|
||||
{
|
||||
"label": "Update Go Mod",
|
||||
|
||||
41
go.mod
41
go.mod
@@ -1,42 +1,39 @@
|
||||
module github.com/kevin-DL/revel-cmd
|
||||
module github.com/revel/cmd
|
||||
|
||||
go 1.17
|
||||
|
||||
retract (
|
||||
v1.1.1
|
||||
v1.1.0 // v1.1.0-1.1.1 are failed releases
|
||||
v1.1.0 // v1.1.0-1.1.1 are failed releases
|
||||
v1.1.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.0.0 // indirect
|
||||
github.com/agtorre/gocolorize v1.0.0
|
||||
github.com/fsnotify/fsnotify v1.5.1
|
||||
github.com/jessevdk/go-flags v1.4.0
|
||||
github.com/mattn/go-colorable v0.1.12
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/revel/config v1.1.0
|
||||
github.com/revel/log15 v2.11.20+incompatible
|
||||
github.com/revel/revel v1.1.0
|
||||
github.com/stretchr/testify v1.7.1
|
||||
golang.org/x/tools v0.24.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
||||
gopkg.in/stack.v0 v0.0.0-20141108040640-9b43fcefddd0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.1.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.0 // indirect
|
||||
github.com/go-stack/stack v1.8.1 // indirect
|
||||
github.com/fsnotify/fsnotify v1.4.9
|
||||
github.com/go-stack/stack v1.8.0 // indirect
|
||||
github.com/inconshreveable/log15 v0.0.0-20201112154412-8562bdadbbac // indirect
|
||||
github.com/jessevdk/go-flags v1.4.0
|
||||
github.com/mattn/go-colorable v0.1.8
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/myesui/uuid v1.0.0 // indirect
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/revel/config v1.1.0
|
||||
github.com/revel/log15 v2.11.20+incompatible
|
||||
github.com/revel/pathtree v0.0.0-20140121041023-41257a1839e9 // indirect
|
||||
github.com/revel/revel v1.1.0
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/twinj/uuid v1.0.0 // indirect
|
||||
github.com/xeonx/timeago v1.0.0-rc4 // indirect
|
||||
golang.org/x/mod v0.20.0 // indirect
|
||||
golang.org/x/net v0.28.0 // indirect
|
||||
golang.org/x/sys v0.23.0 // indirect
|
||||
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect
|
||||
golang.org/x/tools v0.1.10
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
||||
gopkg.in/stack.v0 v0.0.0-20141108040640-9b43fcefddd0
|
||||
gopkg.in/stretchr/testify.v1 v1.2.2 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
|
||||
|
||||
12
go.sum
12
go.sum
@@ -1,23 +1,19 @@
|
||||
github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
|
||||
github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/agtorre/gocolorize v1.0.0 h1:TvGQd+fAqWQlDjQxSKe//Y6RaxK+RHpEU9X/zPmHW50=
|
||||
github.com/agtorre/gocolorize v1.0.0/go.mod h1:cH6imfTkHVBRJhSOeSeEZhB4zqEYSq0sXuIyehgZMIY=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
|
||||
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
|
||||
github.com/inconshreveable/log15 v0.0.0-20201112154412-8562bdadbbac h1:n1DqxAo4oWPMvH1+v+DLYlMCecgumhhgnxAPdqDIFHI=
|
||||
github.com/inconshreveable/log15 v0.0.0-20201112154412-8562bdadbbac/go.mod h1:cOaXtrgN4ScfRrD9Bre7U1thNq5RtJ8ZoP4iXVGRj6o=
|
||||
github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
|
||||
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
@@ -29,18 +25,15 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/revel/config v1.0.0 h1:UAzLPQ+x9nJeP6a+H93G+AKEosg3OO2oVLBXK9oSN2U=
|
||||
github.com/revel/config v1.0.0/go.mod h1:GT4a9px5kDGRqLizcw/md0QFErrhen76toz4qS3oIoI=
|
||||
github.com/revel/config v1.1.0/go.mod h1:GT4a9px5kDGRqLizcw/md0QFErrhen76toz4qS3oIoI=
|
||||
github.com/revel/log15 v2.11.20+incompatible h1:JkA4tbwIo/UGEMumY50zndKq816RQW3LQ0wIpRc+32U=
|
||||
github.com/revel/log15 v2.11.20+incompatible/go.mod h1:l0WmLRs+IM1hBl4noJiBc2tZQiOgZyXzS1mdmFt+5Gc=
|
||||
github.com/revel/pathtree v0.0.0-20140121041023-41257a1839e9 h1:/d6kfjzjyx19ieWqMOXHSTLFuRxLOH15ZubtcAXExKw=
|
||||
github.com/revel/pathtree v0.0.0-20140121041023-41257a1839e9/go.mod h1:TmlwoRLDvgRjoTe6rbsxIaka/CulzYrgfef7iNJcEWY=
|
||||
github.com/revel/revel v1.0.0 h1:BsPFnKuuzXEkPtrjdjZHiDcvDmbBiBQvh7Z5c6kLb/Y=
|
||||
github.com/revel/revel v1.0.0/go.mod h1:VZWJnHjpDEtuGUuZJ2NO42XryitrtwsdVaJxfDeo5yc=
|
||||
github.com/revel/revel v1.1.0/go.mod h1:hv3jPz6e9wppJehS++SrlpJChv4gRhseEwO/Bu4WyCA=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/twinj/uuid v1.0.0 h1:fzz7COZnDrXGTAOHGuUGYd6sG+JMq+AoE7+Jlu0przk=
|
||||
github.com/twinj/uuid v1.0.0/go.mod h1:mMgcE1RHFUFqe5AfiwlINXisXfDGro23fWdPUfOMjRY=
|
||||
github.com/xeonx/timeago v1.0.0-rc4 h1:9rRzv48GlJC0vm+iBpLcWAr8YbETyN9Vij+7h2ammz4=
|
||||
@@ -50,12 +43,10 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
|
||||
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -66,10 +57,8 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
@@ -79,7 +68,6 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20=
|
||||
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
|
||||
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
|
||||
@@ -2,10 +2,16 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"go/build"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/revel/cmd/utils"
|
||||
"github.com/revel/config"
|
||||
@@ -93,6 +99,15 @@ type (
|
||||
FireEventFunction func(key Event, value interface{}) (response EventResponse)
|
||||
ImportFunction func(pkgName string) error
|
||||
}
|
||||
Mod struct {
|
||||
ImportPath string
|
||||
SourcePath string
|
||||
Version string
|
||||
SourceVersion string
|
||||
Dir string // full path, $GOPATH/pkg/mod/
|
||||
Pkgs []string // sub-pkg import paths
|
||||
VendorList []string // files to vendor
|
||||
}
|
||||
)
|
||||
|
||||
// Simple Wrapped RevelCallback.
|
||||
@@ -235,6 +250,31 @@ func (rp *RevelContainer) loadModules(callback RevelCallback) (err error) {
|
||||
|
||||
// Reorder module order by key name, a poor mans sort but at least it is consistent
|
||||
sort.Strings(keys)
|
||||
modtxtPath := filepath.Join(rp.SourcePath, "vendor", "modules.txt")
|
||||
if utils.Exists(modtxtPath) {
|
||||
// Parse out require sections of module.txt
|
||||
modules := rp.vendorInitilizeLocal(modtxtPath, keys)
|
||||
for _, mod := range modules {
|
||||
for _, vendorFile := range mod.VendorList {
|
||||
x := strings.Index(vendorFile, mod.Dir)
|
||||
if x < 0 {
|
||||
utils.Logger.Crit("Error! vendor file doesn't belong to mod, strange.", "vendorFile", "mod.Dir", mod.Dir)
|
||||
}
|
||||
|
||||
localPath := fmt.Sprintf("%s%s", mod.ImportPath, vendorFile[len(mod.Dir):])
|
||||
localFile := filepath.Join(rp.SourcePath, "vendor", localPath)
|
||||
|
||||
utils.Logger.Infof("vendoring %s\n", localPath)
|
||||
|
||||
os.MkdirAll(filepath.Dir(localFile), os.ModePerm)
|
||||
if _, err := copyFile(vendorFile, localFile); err != nil {
|
||||
fmt.Printf("Error! %s - unable to copy file %s\n", err.Error(), vendorFile)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, key := range keys {
|
||||
moduleImportPath := rp.Config.StringDefault(key, "")
|
||||
if moduleImportPath == "" {
|
||||
@@ -242,8 +282,8 @@ func (rp *RevelContainer) loadModules(callback RevelCallback) (err error) {
|
||||
}
|
||||
|
||||
modulePath, err := rp.ResolveImportPath(moduleImportPath)
|
||||
utils.Logger.Info("Resolving import path ", "modulePath", modulePath, "module_import_path", moduleImportPath, "error", err)
|
||||
if err != nil {
|
||||
utils.Logger.Info("Missing module ", "module_import_path", moduleImportPath, "error", err)
|
||||
|
||||
if err := callback.PackageResolver(moduleImportPath); err != nil {
|
||||
return fmt.Errorf("failed to resolve package %w", err)
|
||||
@@ -266,6 +306,88 @@ func (rp *RevelContainer) loadModules(callback RevelCallback) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// Adds a module paths to the container object.
|
||||
func (rp *RevelContainer) vendorInitilizeLocal(modtxtPath string, revel_modules_keys []string) []*Mod {
|
||||
revel_modules := []string{"github.com/revel/revel"}
|
||||
for _, key := range revel_modules_keys {
|
||||
moduleImportPath := rp.Config.StringDefault(key, "")
|
||||
if moduleImportPath == "" {
|
||||
continue
|
||||
}
|
||||
revel_modules = append(revel_modules, moduleImportPath)
|
||||
}
|
||||
f, _ := os.Open(modtxtPath)
|
||||
defer f.Close()
|
||||
scanner := bufio.NewScanner(f)
|
||||
scanner.Split(bufio.ScanLines)
|
||||
|
||||
var (
|
||||
mod *Mod
|
||||
err error
|
||||
)
|
||||
modules := []*Mod{}
|
||||
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
|
||||
// Look for # character
|
||||
if line[0] == 35 {
|
||||
s := strings.Split(line, " ")
|
||||
if (len(s) != 6 && len(s) != 3) || s[1] == "explicit" {
|
||||
continue
|
||||
}
|
||||
|
||||
mod = &Mod{
|
||||
ImportPath: s[1],
|
||||
Version: s[2],
|
||||
}
|
||||
if s[2] == "=>" {
|
||||
// issue https://github.com/golang/go/issues/33848 added these,
|
||||
// see comments. I think we can get away with ignoring them.
|
||||
continue
|
||||
}
|
||||
// Handle "replace" in module file if any
|
||||
if len(s) > 3 && s[3] == "=>" {
|
||||
mod.SourcePath = s[4]
|
||||
|
||||
// Handle replaces with a relative target. For example:
|
||||
// "replace github.com/status-im/status-go/protocol => ./protocol"
|
||||
if strings.HasPrefix(s[4], ".") || strings.HasPrefix(s[4], "/") {
|
||||
mod.Dir, err = filepath.Abs(s[4])
|
||||
if err != nil {
|
||||
fmt.Printf("invalid relative path: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
mod.SourceVersion = s[5]
|
||||
mod.Dir = pkgModPath(mod.SourcePath, mod.SourceVersion)
|
||||
}
|
||||
} else {
|
||||
mod.Dir = pkgModPath(mod.ImportPath, mod.Version)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(mod.Dir); os.IsNotExist(err) {
|
||||
utils.Logger.Critf("Error! %q module path does not exist, check $GOPATH/pkg/mod\n", mod.Dir)
|
||||
}
|
||||
|
||||
// Determine if we need to examine this mod, based on the list of modules being imported
|
||||
for _, importPath := range revel_modules {
|
||||
if strings.HasPrefix(importPath, mod.ImportPath) {
|
||||
updateModVendorList(mod, importPath)
|
||||
}
|
||||
}
|
||||
|
||||
// Build list of files to module path source to project vendor folder
|
||||
modules = append(modules, mod)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
mod.Pkgs = append(mod.Pkgs, line)
|
||||
}
|
||||
return modules
|
||||
}
|
||||
|
||||
// Adds a module paths to the container object.
|
||||
func (rp *RevelContainer) addModulePaths(name, importPath, modulePath string) {
|
||||
utils.Logger.Info("Adding module path", "name", name, "import path", importPath, "system path", modulePath)
|
||||
@@ -313,3 +435,76 @@ func (rp *RevelContainer) ResolveImportPath(importPath string) (string, error) {
|
||||
}
|
||||
return pkgs[0].PkgPath, fmt.Errorf("%w: %s", ErrNoFiles, importPath)
|
||||
}
|
||||
|
||||
func normString(str string) (normStr string) {
|
||||
for _, char := range str {
|
||||
if unicode.IsUpper(char) {
|
||||
normStr += "!" + string(unicode.ToLower(char))
|
||||
} else {
|
||||
normStr += string(char)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func pkgModPath(importPath, version string) string {
|
||||
goPath := build.Default.GOPATH
|
||||
if goPath == "" {
|
||||
if goPath = os.Getenv("GOPATH"); goPath == "" {
|
||||
// the default GOPATH for go v1.11
|
||||
goPath = filepath.Join(os.Getenv("HOME"), "go")
|
||||
}
|
||||
}
|
||||
|
||||
normPath := normString(importPath)
|
||||
normVersion := normString(version)
|
||||
|
||||
return filepath.Join(goPath, "pkg", "mod", fmt.Sprintf("%s@%s", normPath, normVersion))
|
||||
}
|
||||
|
||||
func copyFile(src, dst string) (int64, error) {
|
||||
srcStat, err := os.Stat(src)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if !srcStat.Mode().IsRegular() {
|
||||
return 0, fmt.Errorf("%s is not a regular file", src)
|
||||
}
|
||||
|
||||
srcFile, err := os.Open(src)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer srcFile.Close()
|
||||
|
||||
dstFile, err := os.Create(dst)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer dstFile.Close()
|
||||
|
||||
return io.Copy(dstFile, srcFile)
|
||||
}
|
||||
|
||||
func updateModVendorList(mod *Mod, importPath string) {
|
||||
vendorList := []string{}
|
||||
pathPrefix := filepath.Join(mod.Dir, importPath[len(mod.ImportPath):])
|
||||
|
||||
filepath.WalkDir(pathPrefix, func(path string, d fs.DirEntry, err error) (e error) {
|
||||
if d.IsDir() {
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
utils.Logger.Crit("Failed to walk vendor dir")
|
||||
}
|
||||
utils.Logger.Info("Adding to file in vendor list", "path", path)
|
||||
vendorList = append(vendorList, path)
|
||||
return
|
||||
})
|
||||
|
||||
utils.Logger.Info("For module", "module", mod.ImportPath, "files", len(vendorList))
|
||||
|
||||
mod.VendorList = append(mod.VendorList, vendorList...)
|
||||
}
|
||||
|
||||
@@ -128,7 +128,8 @@ func (s *SourceProcessor) processPath(path string, info os.FileInfo, err error)
|
||||
}
|
||||
|
||||
// Ignore files and folders not marked tmp (since those are generated)
|
||||
if !info.IsDir() || info.Name() == "tmp" {
|
||||
// Also ignore files in the vendor folder.
|
||||
if !info.IsDir() || info.Name() == "tmp" || strings.HasPrefix(path, filepath.Join(s.revelContainer.BasePath, "vendor")) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user