From bb1e61c953acc29b96858ccab2ae922afac571b3 Mon Sep 17 00:00:00 2001 From: Michael Sverdlov Date: Wed, 14 Feb 2024 16:22:46 +0200 Subject: [PATCH 1/3] Upload empty archive when all upload files were filtered out (#1124) --- go.mod | 24 ++++++++++++------------ go.sum | 47 ++++++++++++++++++++++++----------------------- 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/go.mod b/go.mod index 86d31bb69..3d86d8c15 100644 --- a/go.mod +++ b/go.mod @@ -9,11 +9,11 @@ require ( github.com/chzyer/readline v1.5.1 github.com/forPelevin/gomoji v1.1.8 github.com/gocarina/gocsv v0.0.0-20231116093920-b87c2d0e983a - github.com/google/uuid v1.4.0 + github.com/google/uuid v1.6.0 github.com/gookit/color v1.5.4 - github.com/jedib0t/go-pretty/v6 v6.5.3 + github.com/jedib0t/go-pretty/v6 v6.5.4 github.com/jfrog/build-info-go v1.9.21 - github.com/jfrog/gofrog v1.5.1 + github.com/jfrog/gofrog v1.6.0 github.com/jfrog/jfrog-client-go v1.36.0 github.com/magiconair/properties v1.8.7 github.com/manifoldco/promptui v0.9.0 @@ -22,10 +22,10 @@ require ( github.com/stretchr/testify v1.8.4 github.com/urfave/cli v1.22.14 github.com/vbauerster/mpb/v7 v7.5.3 - golang.org/x/exp v0.0.0-20240119083558-1b970713d09a - golang.org/x/mod v0.14.0 + golang.org/x/exp v0.0.0-20240213143201-ec583247a57a + golang.org/x/mod v0.15.0 golang.org/x/sync v0.6.0 - golang.org/x/term v0.16.0 + golang.org/x/term v0.17.0 golang.org/x/text v0.14.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -39,7 +39,7 @@ require ( github.com/VividCortex/ewma v1.2.0 // indirect github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect github.com/andybalholm/brotli v1.1.0 // indirect - github.com/cloudflare/circl v1.3.3 // indirect + github.com/cloudflare/circl v1.3.7 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect @@ -88,15 +88,15 @@ require ( github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect - golang.org/x/crypto v0.18.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sys v0.16.0 // indirect - golang.org/x/tools v0.17.0 // indirect + golang.org/x/crypto v0.19.0 // indirect + golang.org/x/net v0.21.0 // indirect + golang.org/x/sys v0.17.0 // indirect + golang.org/x/tools v0.18.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) -replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240204105421-dd3f7041f3df +replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240214141548-6691c4323f52 // replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20231220102935-c8776c613ad8 diff --git a/go.sum b/go.sum index a8c5e7684..3f9260691 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,9 @@ github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObk github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04= github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= -github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= +github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= +github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= @@ -70,24 +71,24 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4er github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jedib0t/go-pretty/v6 v6.5.3 h1:GIXn6Er/anHTkVUoufs7ptEvxdD6KIhR7Axa2wYCPF0= -github.com/jedib0t/go-pretty/v6 v6.5.3/go.mod h1:5LQIxa52oJ/DlDSLv0HEkWOFMDGoWkJb9ss5KqPpJBg= +github.com/jedib0t/go-pretty/v6 v6.5.4 h1:gOGo0613MoqUcf0xCj+h/V3sHDaZasfv152G6/5l91s= +github.com/jedib0t/go-pretty/v6 v6.5.4/go.mod h1:5LQIxa52oJ/DlDSLv0HEkWOFMDGoWkJb9ss5KqPpJBg= github.com/jfrog/archiver/v3 v3.6.0 h1:OVZ50vudkIQmKMgA8mmFF9S0gA47lcag22N13iV3F1w= github.com/jfrog/archiver/v3 v3.6.0/go.mod h1:fCAof46C3rAXgZurS8kNRNdSVMKBbZs+bNNhPYxLldI= github.com/jfrog/build-info-go v1.9.21 h1:bcD0SEC2lEilhjE+aDB3xlvA8zsr4Kw/bFzvr9Tcj9I= github.com/jfrog/build-info-go v1.9.21/go.mod h1:Vxv6zmx4e1NWsx40OHaDWCCYDeYAq2yXzpJ4nsDChbE= -github.com/jfrog/gofrog v1.5.1 h1:2AXL8hHu1jJFMIoCqTp2OyRUfEqEp4nC7J8fwn6KtwE= -github.com/jfrog/gofrog v1.5.1/go.mod h1:SZ1EPJUruxrVGndOzHd+LTiwWYKMlHqhKD+eu+v5Hqg= -github.com/jfrog/jfrog-client-go v1.28.1-0.20240204105421-dd3f7041f3df h1:7yQ7m0N3AQNqGnymRP+Fka6FZCEYr9GzkTbVkUcxwtQ= -github.com/jfrog/jfrog-client-go v1.28.1-0.20240204105421-dd3f7041f3df/go.mod h1:y1WF6eiZ7V2DortiwjpMEicEH6NIJH+hOXI5QI2W3NU= +github.com/jfrog/gofrog v1.6.0 h1:jOwb37nHY2PnxePNFJ6e6279Pgkr3di05SbQQw47Mq8= +github.com/jfrog/gofrog v1.6.0/go.mod h1:SZ1EPJUruxrVGndOzHd+LTiwWYKMlHqhKD+eu+v5Hqg= +github.com/jfrog/jfrog-client-go v1.28.1-0.20240214141548-6691c4323f52 h1:eDwEWEKfz9gigNJNF60ioZFG3R/33Qq2z+5lH/FfO9Q= +github.com/jfrog/jfrog-client-go v1.28.1-0.20240214141548-6691c4323f52/go.mod h1:fV5wrs86ihQkFKfMKpGxMbNf3mbVT4LUf320C1T9C2M= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= @@ -210,14 +211,14 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= -golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= -golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= +golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE= +golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= +golang.org/x/mod v0.15.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-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -225,8 +226,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -259,15 +260,15 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= +golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= 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= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -281,8 +282,8 @@ 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.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= +golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 28d9d204f1256b70baf29d51d6091a6e27807d79 Mon Sep 17 00:00:00 2001 From: Assaf Attias <49212512+attiasas@users.noreply.github.com> Date: Thu, 15 Feb 2024 16:46:16 +0200 Subject: [PATCH 2/3] Add Pnpm technology (#1122) --- artifactory/commands/repository/template.go | 6 ++-- utils/coreutils/techutils.go | 11 ++++++- utils/coreutils/techutils_test.go | 34 ++++++++++++++++++--- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/artifactory/commands/repository/template.go b/artifactory/commands/repository/template.go index 4f4a6f59f..435df31b0 100644 --- a/artifactory/commands/repository/template.go +++ b/artifactory/commands/repository/template.go @@ -856,9 +856,9 @@ var questionMap = map[string]ioutils.QuestionInfo{ Writer: ioutils.WriteStringAnswer, }, PrimaryKeyPairRef: ioutils.FreeStringQuestionInfo, - Username: ioutils.FreeStringQuestionInfo, - Password: ioutils.FreeStringQuestionInfo, - Proxy: ioutils.FreeStringQuestionInfo, + Username: ioutils.FreeStringQuestionInfo, + Password: ioutils.FreeStringQuestionInfo, + Proxy: ioutils.FreeStringQuestionInfo, RemoteRepoChecksumPolicyType: { Options: []prompt.Suggest{ {Text: GenerateIfAbsentPolicy}, diff --git a/utils/coreutils/techutils.go b/utils/coreutils/techutils.go index 78e2321e6..ca63dc653 100644 --- a/utils/coreutils/techutils.go +++ b/utils/coreutils/techutils.go @@ -24,6 +24,7 @@ const ( Maven Technology = "maven" Gradle Technology = "gradle" Npm Technology = "npm" + Pnpm Technology = "pnpm" Yarn Technology = "yarn" Go Technology = "go" Pip Technology = "pip" @@ -77,7 +78,7 @@ var technologiesData = map[Technology]TechData{ }, Npm: { indicators: []string{"package.json", "package-lock.json", "npm-shrinkwrap.json"}, - exclude: []string{".yarnrc.yml", "yarn.lock", ".yarn"}, + exclude: []string{"pnpm-lock.yaml", ".yarnrc.yml", "yarn.lock", ".yarn"}, ciSetupSupport: true, packageDescriptors: []string{"package.json"}, formal: string(Npm), @@ -85,8 +86,16 @@ var technologiesData = map[Technology]TechData{ packageInstallationCommand: "install", applicabilityScannable: true, }, + Pnpm: { + indicators: []string{"pnpm-lock.yaml"}, + exclude: []string{".yarnrc.yml", "yarn.lock", ".yarn"}, + packageDescriptors: []string{"package.json"}, + packageVersionOperator: "@", + applicabilityScannable: true, + }, Yarn: { indicators: []string{".yarnrc.yml", "yarn.lock", ".yarn", ".yarnrc"}, + exclude: []string{"pnpm-lock.yaml"}, packageDescriptors: []string{"package.json"}, packageVersionOperator: "@", applicabilityScannable: true, diff --git a/utils/coreutils/techutils_test.go b/utils/coreutils/techutils_test.go index 7d170b9da..c69d58ebe 100644 --- a/utils/coreutils/techutils_test.go +++ b/utils/coreutils/techutils_test.go @@ -17,6 +17,7 @@ func TestDetectTechnologiesByFilePaths(t *testing.T) { }{ {"simpleMavenTest", []string{"pom.xml"}, map[Technology]bool{Maven: true}}, {"npmTest", []string{"../package.json"}, map[Technology]bool{Npm: true}}, + {"pnpmTest", []string{"../package.json", "pnpm-lock.yaml"}, map[Technology]bool{Pnpm: true}}, {"yarnTest", []string{"./package.json", "./.yarn"}, map[Technology]bool{Yarn: true}}, {"windowsGradleTest", []string{"c:\\users\\test\\package\\build.gradle"}, map[Technology]bool{Gradle: true}}, {"windowsPipTest", []string{"c:\\users\\test\\package\\setup.py"}, map[Technology]bool{Pip: true}}, @@ -73,12 +74,19 @@ func TestMapFilesToRelevantWorkingDirectories(t *testing.T) { }, expectedExcluded: noExclude, }, + { + name: "pnpmTest", + paths: []string{filepath.Join("dir", "package.json"), filepath.Join("dir", "pnpm-lock.yaml")}, + requestedDescriptors: noRequest, + expectedWorkingDir: map[string][]string{"dir": {filepath.Join("dir", "package.json"), filepath.Join("dir", "pnpm-lock.yaml")}}, + expectedExcluded: map[string][]Technology{"dir": {Npm, Yarn}}, + }, { name: "yarnTest", paths: []string{filepath.Join("dir", "package.json"), filepath.Join("dir", ".yarn")}, requestedDescriptors: noRequest, expectedWorkingDir: map[string][]string{"dir": {filepath.Join("dir", "package.json"), filepath.Join("dir", ".yarn")}}, - expectedExcluded: map[string][]Technology{"dir": {Npm}}, + expectedExcluded: map[string][]Technology{"dir": {Npm, Pnpm}}, }, { name: "golangTest", @@ -138,13 +146,20 @@ func TestMapFilesToRelevantWorkingDirectories(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { detectedWd, detectedExcluded := mapFilesToRelevantWorkingDirectories(test.paths, test.requestedDescriptors) + // Assert working directories expectedKeys := maps.Keys(test.expectedWorkingDir) actualKeys := maps.Keys(detectedWd) assert.ElementsMatch(t, expectedKeys, actualKeys, "expected: %s, actual: %s", expectedKeys, actualKeys) for key, value := range test.expectedWorkingDir { assert.ElementsMatch(t, value, detectedWd[key], "expected: %s, actual: %s", value, detectedWd[key]) } - assert.True(t, reflect.DeepEqual(test.expectedExcluded, detectedExcluded), "expected: %s, actual: %s", test.expectedExcluded, detectedExcluded) + // Assert excluded + expectedKeys = maps.Keys(test.expectedExcluded) + actualKeys = maps.Keys(detectedExcluded) + assert.ElementsMatch(t, expectedKeys, actualKeys, "expected: %s, actual: %s", expectedKeys, actualKeys) + for key, value := range test.expectedExcluded { + assert.ElementsMatch(t, value, detectedExcluded[key], "expected: %s, actual: %s", value, detectedExcluded[key]) + } }) } } @@ -178,6 +193,7 @@ func TestMapWorkingDirectoriesToTechnologies(t *testing.T) { "dir": {filepath.Join("dir", "package.json"), filepath.Join("dir", "package-lock.json"), filepath.Join("dir", "build.gradle.kts"), filepath.Join("dir", "project.sln")}, "directory": {filepath.Join("directory", "npm-shrinkwrap.json")}, "dir3": {filepath.Join("dir3", "package.json"), filepath.Join("dir3", ".yarn")}, + filepath.Join("dir3", "dir"): {filepath.Join("dir3", "dir", "package.json"), filepath.Join("dir3", "dir", "pnpm-lock.yaml")}, filepath.Join("dir", "dir2"): {filepath.Join("dir", "dir2", "go.mod")}, filepath.Join("users_dir", "test", "package"): {filepath.Join("users_dir", "test", "package", "setup.py")}, filepath.Join("users_dir", "test", "package2"): {filepath.Join("users_dir", "test", "package2", "requirements.txt")}, @@ -186,7 +202,8 @@ func TestMapWorkingDirectoriesToTechnologies(t *testing.T) { }, excludedTechAtWorkingDir: map[string][]Technology{ filepath.Join("users", "test", "package"): {Pip}, - "dir3": {Npm}, + "dir3": {Npm}, + filepath.Join("dir3", "dir"): {Npm, Yarn}, }, requestedTechs: noRequestTech, requestedDescriptors: noRequestSpecialDescriptors, @@ -196,6 +213,7 @@ func TestMapWorkingDirectoriesToTechnologies(t *testing.T) { "dir": {filepath.Join("dir", "package.json")}, "directory": {}, }, + Pnpm: {filepath.Join("dir3", "dir"): {filepath.Join("dir3", "dir", "package.json")}}, Yarn: {"dir3": {filepath.Join("dir3", "package.json")}}, Go: {filepath.Join("dir", "dir2"): {filepath.Join("dir", "dir2", "go.mod")}}, Pip: { @@ -354,6 +372,7 @@ func TestGetTechInformationFromWorkingDir(t *testing.T) { "dir": {filepath.Join("dir", "package.json"), filepath.Join("dir", "package-lock.json"), filepath.Join("dir", "build.gradle.kts"), filepath.Join("dir", "project.sln"), filepath.Join("dir", "blabla.txt")}, "directory": {filepath.Join("directory", "npm-shrinkwrap.json")}, "dir3": {filepath.Join("dir3", "package.json"), filepath.Join("dir3", ".yarn")}, + filepath.Join("dir3", "dir"): {filepath.Join("dir3", "dir", "package.json"), filepath.Join("dir3", "dir", "pnpm-lock.yaml")}, filepath.Join("dir", "dir2"): {filepath.Join("dir", "dir2", "go.mod")}, filepath.Join("users_dir", "test", "package"): {filepath.Join("users_dir", "test", "package", "setup.py")}, filepath.Join("users_dir", "test", "package2"): {filepath.Join("users_dir", "test", "package2", "requirements.txt")}, @@ -362,7 +381,8 @@ func TestGetTechInformationFromWorkingDir(t *testing.T) { } excludedTechAtWorkingDir := map[string][]Technology{ filepath.Join("users", "test", "package"): {Pip}, - "dir3": {Npm}, + "dir3": {Npm, Pnpm}, + filepath.Join("dir3", "dir"): {Npm, Yarn}, } tests := []struct { @@ -392,6 +412,12 @@ func TestGetTechInformationFromWorkingDir(t *testing.T) { "directory": {}, }, }, + { + name: "pnpmTest", + tech: Pnpm, + requestedDescriptors: map[Technology][]string{}, + expected: map[string][]string{filepath.Join("dir3", "dir"): {filepath.Join("dir3", "dir", "package.json")}}, + }, { name: "yarnTest", tech: Yarn, From 40b164662f24ce653d012badf5d5a10ce67139d8 Mon Sep 17 00:00:00 2001 From: Michael Sverdlov Date: Thu, 15 Feb 2024 18:44:28 +0200 Subject: [PATCH 3/3] Improve interactive build config creation repositories fetch efficiency (#1110) --- artifactory/utils/repositoryutils.go | 7 +- common/commands/configfile.go | 129 +++++++++++---------------- 2 files changed, 55 insertions(+), 81 deletions(-) diff --git a/artifactory/utils/repositoryutils.go b/artifactory/utils/repositoryutils.go index 20efbdf7d..db8a46e69 100644 --- a/artifactory/utils/repositoryutils.go +++ b/artifactory/utils/repositoryutils.go @@ -65,16 +65,13 @@ func GetRepositories(artDetails *config.ServerDetails, repoTypes ...RepoType) ([ if err != nil { return nil, err } - if len(repoTypes) == 0 { - return GetFilteredRepositoriesByName(sm, nil, nil) - } repos := []string{} for _, repoType := range repoTypes { - repoKey, err := GetFilteredRepositoriesByNameAndType(sm, nil, nil, repoType) + filteredRepos, err := GetFilteredRepositoriesByNameAndType(sm, nil, nil, repoType) if err != nil { return repos, err } - repos = append(repos, repoKey...) + repos = append(repos, filteredRepos...) } return repos, nil diff --git a/common/commands/configfile.go b/common/commands/configfile.go index be265e761..a7e4518ba 100644 --- a/common/commands/configfile.go +++ b/common/commands/configfile.go @@ -152,27 +152,23 @@ func handleInteractiveConfigCreation(configFile *ConfigFile, confType project.Pr } switch confType { case project.Go: - err = configFile.configGo() - case project.Pip: - err = configFile.configPip() - case project.Pipenv: - err = configFile.configPipenv() - case project.Poetry: - err = configFile.configPoetry() + return configFile.setDeployerResolver() + case project.Pip, project.Pipenv, project.Poetry: + return configFile.setResolver(false) case project.Yarn: - err = configFile.configYarn() + return configFile.setResolver(false) case project.Npm: - err = configFile.configNpm() + return configFile.setDeployerResolver() case project.Nuget, project.Dotnet: - err = configFile.configDotnet() + return configFile.configDotnet() case project.Maven: - err = configFile.configMaven() + return configFile.configMaven() case project.Gradle: - err = configFile.configGradle() + return configFile.configGradle() case project.Terraform: - err = configFile.configTerraform() + return configFile.setResolver(false) } - return errorutils.CheckError(err) + return } func writeConfigFile(configFile *ConfigFile, destination string) (err error) { @@ -394,32 +390,8 @@ func (configFile *ConfigFile) VerifyConfigFile(configFilePath string) error { return errorutils.CheckError(os.Remove(configFilePath)) } -func (configFile *ConfigFile) configGo() error { - return configFile.setDeployerResolver() -} - -func (configFile *ConfigFile) configPip() error { - return configFile.setResolver() -} - -func (configFile *ConfigFile) configPipenv() error { - return configFile.setResolver() -} - -func (configFile *ConfigFile) configPoetry() error { - return configFile.setResolver() -} - -func (configFile *ConfigFile) configYarn() error { - return configFile.setResolver() -} - -func (configFile *ConfigFile) configNpm() error { - return configFile.setDeployerResolver() -} - func (configFile *ConfigFile) configDotnet() error { - if err := configFile.setResolver(); err != nil { + if err := configFile.setResolver(false); err != nil { return err } if configFile.Resolver.ServerId != "" { @@ -429,21 +401,10 @@ func (configFile *ConfigFile) configDotnet() error { } func (configFile *ConfigFile) configMaven() error { - // Set resolution repositories - if err := configFile.setResolverId(); err != nil { - return err - } - if configFile.Resolver.ServerId != "" { - configFile.setRepo(&configFile.Resolver.ReleaseRepo, "Set resolution repository for release dependencies", configFile.Resolver.ServerId, utils.Remote) - configFile.setRepo(&configFile.Resolver.SnapshotRepo, "Set resolution repository for snapshot dependencies", configFile.Resolver.ServerId, utils.Remote) - } - // Set deployment repositories - if err := configFile.setDeployerId(); err != nil { + if err := configFile.setDeployerResolverWithSnapshot(); err != nil { return err } if configFile.Deployer.ServerId != "" { - configFile.setRepo(&configFile.Deployer.ReleaseRepo, "Set repository for release artifacts deployment", configFile.Deployer.ServerId, utils.Local) - configFile.setRepo(&configFile.Deployer.SnapshotRepo, "Set repository for snapshot artifacts deployment", configFile.Deployer.ServerId, utils.Local) configFile.setIncludeExcludePatterns() } configFile.UseWrapper = coreutils.AskYesNo("Use Maven wrapper?", true) @@ -494,11 +455,7 @@ func (configFile *ConfigFile) readGradleGlobalConfig() { configFile.UseWrapper = coreutils.AskYesNo("Use Gradle wrapper?", true) } -func (configFile *ConfigFile) configTerraform() error { - return configFile.setDeployer() -} - -func (configFile *ConfigFile) setDeployer() error { +func (configFile *ConfigFile) setDeployer(withSnapshot bool) error { // Set deployer id if err := configFile.setDeployerId(); err != nil { return err @@ -506,28 +463,57 @@ func (configFile *ConfigFile) setDeployer() error { // Set deployment repository if configFile.Deployer.ServerId != "" { - configFile.setRepo(&configFile.Deployer.Repo, "Set repository for artifacts deployment", configFile.Deployer.ServerId, utils.Local) + deployerRepos, err := getRepositories(configFile.Deployer.ServerId, utils.Virtual, utils.Local) + if err != nil { + log.Error("failed getting repositories list: " + err.Error()) + // Continue without auto complete. + deployerRepos = []string{} + } + if withSnapshot { + configFile.setRepo(&configFile.Deployer.SnapshotRepo, "Set repository for release artifacts deployment", deployerRepos) + configFile.setRepo(&configFile.Deployer.SnapshotRepo, "Set repository for snapshot artifacts deployment", deployerRepos) + } else { + configFile.setRepo(&configFile.Deployer.Repo, "Set repository for artifacts deployment", deployerRepos) + } } return nil } -func (configFile *ConfigFile) setResolver() error { +func (configFile *ConfigFile) setResolver(withSnapshot bool) error { // Set resolver id if err := configFile.setResolverId(); err != nil { return err } // Set resolution repository if configFile.Resolver.ServerId != "" { - configFile.setRepo(&configFile.Resolver.Repo, "Set repository for dependencies resolution", configFile.Resolver.ServerId, utils.Remote) + resolverRepos, err := getRepositories(configFile.Resolver.ServerId, utils.Virtual, utils.Remote) + if err != nil { + log.Error("failed getting repositories list: " + err.Error()) + // Continue without auto complete. + resolverRepos = []string{} + } + if withSnapshot { + configFile.setRepo(&configFile.Resolver.SnapshotRepo, "Set resolution repository for release dependencies", resolverRepos) + configFile.setRepo(&configFile.Resolver.SnapshotRepo, "Set resolution repository for snapshot dependencies", resolverRepos) + } else { + configFile.setRepo(&configFile.Resolver.Repo, "Set resolution repository for dependencies resolution", resolverRepos) + } } return nil } func (configFile *ConfigFile) setDeployerResolver() error { - if err := configFile.setResolver(); err != nil { + if err := configFile.setResolver(false); err != nil { return err } - return configFile.setDeployer() + return configFile.setDeployer(false) +} + +func (configFile *ConfigFile) setDeployerResolverWithSnapshot() error { + if err := configFile.setResolver(true); err != nil { + return err + } + return configFile.setDeployer(true) } func (configFile *ConfigFile) setResolverId() error { @@ -544,9 +530,13 @@ func (configFile *ConfigFile) setServerId(serverId *string, useArtifactoryQuesti return err } -func (configFile *ConfigFile) setRepo(repo *string, message string, serverId string, repoType utils.RepoType) { +func (configFile *ConfigFile) setRepo(repo *string, promptPrefix string, availableRepos []string) { if *repo == "" { - *repo = readRepo(message+ioutils.PressTabMsg, serverId, repoType, utils.Virtual) + if len(availableRepos) > 0 { + *repo = ioutils.AskFromListWithMismatchConfirmation(promptPrefix, "Repository not found.", ioutils.ConvertToSuggests(availableRepos)) + } else { + *repo = ioutils.AskString("", promptPrefix, false, false) + } } } @@ -635,19 +625,6 @@ func readArtifactoryServer(useArtifactoryQuestion string) (string, error) { return ioutils.AskFromList("", "Set Artifactory server ID", false, ioutils.ConvertToSuggests(serversIds), defaultServer), nil } -func readRepo(promptPrefix string, serverId string, repoTypes ...utils.RepoType) string { - availableRepos, err := getRepositories(serverId, repoTypes...) - if err != nil { - log.Error("failed getting repositories list: " + err.Error()) - // Continue without auto complete. - availableRepos = []string{} - } - if len(availableRepos) > 0 { - return ioutils.AskFromListWithMismatchConfirmation(promptPrefix, "Repository not found.", ioutils.ConvertToSuggests(availableRepos)) - } - return ioutils.AskString("", promptPrefix, false, false) -} - func getServersIdAndDefault() ([]string, string, error) { allConfigs, err := config.GetAllServersConfigs() if err != nil {