Skip to content

Commit

Permalink
Merge branch 'stable-cadence' into fix-output-json
Browse files Browse the repository at this point in the history
  • Loading branch information
ryokik committed Jul 11, 2024
2 parents 999214a + 9d41db9 commit 932334f
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 120 deletions.
28 changes: 14 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ require (
github.com/gosuri/uilive v0.0.4
github.com/logrusorgru/aurora/v4 v4.0.0
github.com/manifoldco/promptui v0.9.0
github.com/onflow/cadence v1.0.0-preview.34
github.com/onflow/cadence-tools/languageserver v1.0.0-preview.32
github.com/onflow/cadence-tools/lint v1.0.0-preview.32
github.com/onflow/cadence-tools/test v1.0.0-preview.32
github.com/onflow/cadence v1.0.0-preview.35
github.com/onflow/cadence-tools/languageserver v1.0.0-preview.33
github.com/onflow/cadence-tools/lint v1.0.0-preview.33
github.com/onflow/cadence-tools/test v1.0.0-preview.33
github.com/onflow/contract-updater/lib/go/templates v1.0.1
github.com/onflow/fcl-dev-wallet v0.8.0-stable-cadence.1
github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.18
github.com/onflow/flow-core-contracts/lib/go/templates v1.0.0
github.com/onflow/flow-emulator v1.0.0-preview.32
github.com/onflow/flow-evm-gateway v0.19.0
github.com/onflow/flow-go v0.35.14-crescendo-preview.27
github.com/onflow/flow-go-sdk v1.0.0-preview.36
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.24
github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.19
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0
github.com/onflow/flow-emulator v1.0.0-preview.33
github.com/onflow/flow-evm-gateway v0.21.0
github.com/onflow/flow-go v0.35.14-crescendo-preview.27.0.20240626210601-604590f19db9
github.com/onflow/flow-go-sdk v1.0.0-preview.37
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.25
github.com/onflow/go-ethereum v1.13.4
github.com/onflowser/flowser/v3 v3.2.1-0.20240131200229-7d4d22715f48
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
Expand All @@ -36,7 +36,7 @@ require (
github.com/rs/zerolog v1.33.0
github.com/sergi/go-diff v1.3.1
github.com/spf13/afero v1.10.0
github.com/spf13/cobra v1.8.0
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225
Expand Down Expand Up @@ -203,14 +203,14 @@ require (
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onflow/atree v0.7.0-rc.2 // indirect
github.com/onflow/crypto v0.25.1 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.1.0 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0 // indirect
github.com/onflow/flow-ft/lib/go/contracts v1.0.0 // indirect
github.com/onflow/flow-ft/lib/go/templates v1.0.0 // indirect
github.com/onflow/flow-nft/lib/go/contracts v1.2.1 // indirect
github.com/onflow/flow-nft/lib/go/templates v1.2.0 // indirect
github.com/onflow/flow/protobuf/go/flow v0.4.4 // indirect
github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 // indirect
github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba // indirect
github.com/onflow/sdks v0.6.0-preview.1 // indirect
github.com/onflow/wal v1.0.2 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
Expand Down
59 changes: 30 additions & 29 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1221,8 +1221,8 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/crate-crypto/go-ipa v0.0.0-20230601170251-1830d0757c80/go.mod h1:gzbVz57IDJgQ9rLQwfSk696JGWof8ftznEL9GoAv3NI=
github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA=
github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc=
Expand Down Expand Up @@ -2157,55 +2157,56 @@ github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs
github.com/onflow/atree v0.7.0-rc.2 h1:mZmVrl/zPlfI44EjV3FdR2QwIqT8nz1sCONUBFcML/U=
github.com/onflow/atree v0.7.0-rc.2/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ0tHf4DRuM=
github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8=
github.com/onflow/cadence v1.0.0-preview.34 h1:MJSli75W6LJVUqSx/tq4MQe64H1+EcQBD/sNgpOO4jE=
github.com/onflow/cadence v1.0.0-preview.34/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0=
github.com/onflow/cadence-tools/languageserver v1.0.0-preview.32 h1:bcXyutzucIKXvrOPU3YcTcYMNUsEVQpnPwBT4Y4n3eI=
github.com/onflow/cadence-tools/languageserver v1.0.0-preview.32/go.mod h1:jD3nHNc67XrWd/IC714vN1N7odAXjCfg8M/y+f5OdH4=
github.com/onflow/cadence-tools/lint v1.0.0-preview.32 h1:ikRHM2aBd1OT8go4Ru/UWmmoEgfRHsWo1Hh4uOlQ91o=
github.com/onflow/cadence-tools/lint v1.0.0-preview.32/go.mod h1:0DlaXiefoamdXaOvMDLY5xg+qtkjG2YP82iCaDAGkp0=
github.com/onflow/cadence-tools/test v1.0.0-preview.32 h1:UBxfDY+za0cU0Dxt2t5bro+XtnZyvdPKiAHtRIujLfk=
github.com/onflow/cadence-tools/test v1.0.0-preview.32/go.mod h1:V5JDHX9mm+ta2Ejl+oActaxGNiToaABs4M+m1a871TY=
github.com/onflow/cadence v1.0.0-preview.35 h1:HZgt/9Foa6sCSH9SNaIFUSXK6q2ZxETg0ivsZbf+hhU=
github.com/onflow/cadence v1.0.0-preview.35/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0=
github.com/onflow/cadence-tools/languageserver v1.0.0-preview.33 h1:eepGWEYAh0V/xklsh8XFpENrnWJ3x/Hu3XhUGtwiu6Y=
github.com/onflow/cadence-tools/languageserver v1.0.0-preview.33/go.mod h1:3gRwz39hOVR9++tdUbV07eEYb1p0eXtPylLOqYmequw=
github.com/onflow/cadence-tools/lint v1.0.0-preview.33 h1:nTdKGCIBW/nWDLLBjkVgvMQxgaj+9F5+8o2NMXGs1Ac=
github.com/onflow/cadence-tools/lint v1.0.0-preview.33/go.mod h1:j+eA2hhi5a+g8SIPZhLLvw9SNFaASg+LS1m+kpb6fDc=
github.com/onflow/cadence-tools/test v1.0.0-preview.33 h1:LfV5rphRD0KeTcJskMjjzA6QU3hQNNKPsVzB9OfK17w=
github.com/onflow/cadence-tools/test v1.0.0-preview.33/go.mod h1:iehbYZI1AYGWFQ4ve+OmSgPEd5c9A/ygpmoXZc3P8Lw=
github.com/onflow/contract-updater/lib/go/templates v1.0.1 h1:xPj898Y8OgLLbXH8+JeKVBV6J+nqPZjiLgGM3Abucto=
github.com/onflow/contract-updater/lib/go/templates v1.0.1/go.mod h1:OXO6s0X7OW4Q6QTfAfnjoOmibEPgs0psOfMi+tPyzQE=
github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A=
github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
github.com/onflow/fcl-dev-wallet v0.8.0-stable-cadence.1 h1:IqdUzdqFCSW0klWmA3J9c17ZyQTab9SWcWSLouX6o0Q=
github.com/onflow/fcl-dev-wallet v0.8.0-stable-cadence.1/go.mod h1:kc42jkiuoPJmxMRFjfbRO9XvnR/3XLheaOerxVMDTiw=
github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.18 h1:3IznBzxdXKrVJ8YDaA2dSQD2HQeWmsL3HsjZY86L+5o=
github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.18/go.mod h1:dZqcdrsDdvBs5433bkXC8KN0l/jCamerWcmaB1P7YM4=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.1.0 h1:AegPBm079X0qjneUYs+mRCpEUxSZ1lw5h4MbuXHlqn0=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.1.0/go.mod h1:u/mkP/B+PbV33tEG3qfkhhBlydSvAKxfLZSfB4lsJHg=
github.com/onflow/flow-core-contracts/lib/go/templates v1.0.0 h1:za6bxPPW4JIsthhasUDTa1ruKjIO8DIhun9INQfj61Y=
github.com/onflow/flow-core-contracts/lib/go/templates v1.0.0/go.mod h1:NgbMOYnMh0GN48VsNKZuiwK7uyk38Wyo8jN9+C9QE30=
github.com/onflow/flow-emulator v1.0.0-preview.32 h1:VkJL7u75XUB8077CQvojKhxSCGirGCrsjAxjTOUIpD4=
github.com/onflow/flow-emulator v1.0.0-preview.32/go.mod h1:wwHM6+cJ5s3BIS9Wj0pXTRumj9n929fqwNuXqOD1g7g=
github.com/onflow/flow-evm-gateway v0.19.0 h1:gFhwFftwrbLbveLDfTm9R9IDCPgHmHlgsveaneQ3Kz8=
github.com/onflow/flow-evm-gateway v0.19.0/go.mod h1:yvA5LRcr7xn7EniccsX19ap0yUHzfMUj2nxLyRwiu+Y=
github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.19 h1:B8WO5T36P+TJ7CodehFze8VTOXw7RcKwbFTKNEAn1d0=
github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.19/go.mod h1:Dyqp/qkvrIzVzebZi2OlauljPmr65mtVZpc12wjIhR0=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0 h1:cq3RfBr9TnTSnsGlUHMjMGZib24Horfb1XJqMpkN5ew=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0/go.mod h1:u/mkP/B+PbV33tEG3qfkhhBlydSvAKxfLZSfB4lsJHg=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0 h1:aMFJdB2CW+Dzm+AJ5QN6J1yWh+a0l2RxHN2/TtLaXUo=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0/go.mod h1:NgbMOYnMh0GN48VsNKZuiwK7uyk38Wyo8jN9+C9QE30=
github.com/onflow/flow-emulator v1.0.0-preview.33 h1:1LFVpZJrgAZjPr5Jou3dbg6zOO5GMREnmE1dr9ndnJE=
github.com/onflow/flow-emulator v1.0.0-preview.33/go.mod h1:4T/kFzo8jccGF8GbxLlu3b/jwBH6GxX8p0hTPURHZ7k=
github.com/onflow/flow-evm-gateway v0.21.0 h1:8pbSLatORAqnvycOFECwD7aFvrezbPgfJX43Z9ajirw=
github.com/onflow/flow-evm-gateway v0.21.0/go.mod h1:GkRS6AN1YS7ltXWbMNKA32btSQcXUt5EoqPJ+y5nBgo=
github.com/onflow/flow-ft/lib/go/contracts v1.0.0 h1:mToacZ5NWqtlWwk/7RgIl/jeKB/Sy/tIXdw90yKHcV0=
github.com/onflow/flow-ft/lib/go/contracts v1.0.0/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
github.com/onflow/flow-ft/lib/go/templates v1.0.0 h1:6cMS/lUJJ17HjKBfMO/eh0GGvnpElPgBXx7h5aoWJhs=
github.com/onflow/flow-ft/lib/go/templates v1.0.0/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
github.com/onflow/flow-go v0.35.14-crescendo-preview.27 h1:sWjWsutcFOP9o/etZF3Zii0eq4MMqKQchquwmyElWCQ=
github.com/onflow/flow-go v0.35.14-crescendo-preview.27/go.mod h1:P7AnyTH5W+hNm5pmhnYasIh7T6Z2kU4tiy53NJKvhZA=
github.com/onflow/flow-go v0.35.14-crescendo-preview.27.0.20240626210601-604590f19db9 h1:9GfHBXy9T8QEAkwX+KkmZjJadSOAVgiyn2n8s7sSueY=
github.com/onflow/flow-go v0.35.14-crescendo-preview.27.0.20240626210601-604590f19db9/go.mod h1:SE4kph7kpF6ydOXObtueEecGk3Hrjy/if/0UHY/eRO8=
github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo=
github.com/onflow/flow-go-sdk v1.0.0-preview.36 h1:3g72MjmZPEEVAbtDATbjwqKoNSB7yHLWswUHSAB5zwQ=
github.com/onflow/flow-go-sdk v1.0.0-preview.36/go.mod h1:mjkXIluC+kseYyd8Z1aTq73IiffAUeoY5fuX/C2Z+1w=
github.com/onflow/flow-go-sdk v1.0.0-preview.37 h1:ujeIQheD+skzFt9+eOT9nXcc1rFxVLSCzwisEI3+2DA=
github.com/onflow/flow-go-sdk v1.0.0-preview.37/go.mod h1:2aSN7RdKzxWoCtCyOJz9W/ZNqkLgQDQS3hKLYwPlvGw=
github.com/onflow/flow-nft/lib/go/contracts v1.2.1 h1:woAAS5z651sDpi7ihAHll8NvRS9uFXIXkL6xR+bKFZY=
github.com/onflow/flow-nft/lib/go/contracts v1.2.1/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE=
github.com/onflow/flow-nft/lib/go/templates v1.2.0 h1:JSQyh9rg0RC+D1930BiRXN8lrtMs+ubVMK6aQPon6Yc=
github.com/onflow/flow-nft/lib/go/templates v1.2.0/go.mod h1:p+2hRvtjLUR3MW1NsoJe5Gqgr2eeH49QB6+s6ze00w0=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231121210617-52ee94b830c2/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
github.com/onflow/flow/protobuf/go/flow v0.4.4 h1:lD1owoZGFgLcvdLZDmP0Kc4GOuQeSU3/d7hrujFzt6k=
github.com/onflow/flow/protobuf/go/flow v0.4.4/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.24 h1:D6cbWqxuwjg/vXtNWyvViCNpWjUPMYfMewA9P4oT14s=
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.24/go.mod h1:89ipBRMJE9nWRimoqaa02+l6kCQuBiVyzszI6N3a6Sk=
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.25 h1:O5+TsPkN7nzVAaDZTnAww5Dx5p9ZczQHgLOZdq0xJFI=
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.25/go.mod h1:xEMke42kCoEtqkzc7+zkaWU5l22EpThdJ1YZuKutAMY=
github.com/onflow/go-ethereum v1.13.4 h1:iNO86fm8RbBbhZ87ZulblInqCdHnAQVY8okBrNsTevc=
github.com/onflow/go-ethereum v1.13.4/go.mod h1:cE/gEUkAffhwbVmMJYz+t1dAfVNHNwZCgc3BWtZxBGY=
github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 h1:sxyWLqGm/p4EKT6DUlQESDG1ZNMN9GjPCm1gTq7NGfc=
github.com/onflow/nft-storefront/lib/go/contracts v1.0.0/go.mod h1:kMeq9zUwCrgrSojEbTUTTJpZ4WwacVm2pA7LVFr+glk=
github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba h1:rIehuhO6bj4FkwE4VzwEjX7MoAlOhUJENBJLqDqVxAo=
github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU=
github.com/onflow/sdks v0.6.0-preview.1 h1:mb/cUezuqWEP1gFZNAgUI4boBltudv4nlfxke1KBp9k=
github.com/onflow/sdks v0.6.0-preview.1/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU=
github.com/onflow/wal v1.0.2 h1:5bgsJVf2O3cfMNK12fiiTyYZ8cOrUiELt3heBJfHOhc=
github.com/onflow/wal v1.0.2/go.mod h1:iMC8gkLqu4nkbkAla5HkSBb+FGyQOZiWz3DYm2wSXCk=
github.com/onflowser/flowser/v3 v3.2.1-0.20240131200229-7d4d22715f48 h1:eBS8Rm1V9TTGpj9lcpoCi6MIwWgYQZ8crJ7cSrS39Y4=
Expand Down Expand Up @@ -2435,8 +2436,8 @@ github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
Expand Down
68 changes: 46 additions & 22 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
The destination path to install to.
.Parameter Version
The version to install.
.Parameter C1Version
The Cadence 1 version to install.
.Parameter AddToPath
Add the absolute destination path to the 'User' scope environment variable 'Path'.
.Parameter GitHubToken
Expand All @@ -23,6 +25,7 @@
#>
param (
[string] $version="",
[string] $c1Version="",
[string] $directory = "$env:APPDATA\Flow",
[bool] $addToPath = $true,
[string] $githubToken = ""
Expand All @@ -36,29 +39,27 @@ Set-ItemProperty HKCU:\Console VirtualTerminalLevel -Type DWORD 1
$ErrorActionPreference = "Stop"

$repo = "onflow/flow-cli"
$versionURL = "https://api.github.com/repos/$repo/releases/latest"
$assetsURL = "https://github.com/$repo/releases/download"

# Add the GitHub token to the web request headers if it was provided
$webRequestOptions = if ($githubToken) {
@{ 'Headers' = @{ 'Authorization' = "Bearer $githubToken" } }
@{ 'Headers' = @{ 'Authorization' = "Bearer $githubToken" } }
} else {
@{}
}

# Function to get the latest version
function Get-Version {
param (
[string]$repo,
[string]$searchTerm,
[hashtable]$webRequestOptions
[bool]$prerelease
)

$page = 1
$version = $null

while (-not $version) {
$response = Invoke-WebRequest -Uri "https://api.github.com/repos/$repo/releases?per_page=100&page=$page" -UseBasicParsing @webRequestOptions -ErrorAction SilentlyContinue
$response = Invoke-WebRequest -Uri "https://api.github.com/repos/$repo/releases?per_page=10&page=$page" -UseBasicParsing @webRequestOptions -ErrorAction SilentlyContinue
$status = $response.StatusCode

if ($status -eq 403 -and $githubTokenHeader) {
Expand All @@ -75,7 +76,7 @@ function Get-Version {
$jsonResponse = $response.Content | ConvertFrom-Json

foreach ($release in $jsonResponse) {
if ($release.tag_name -like "*$searchTerm*") {
if (($release.prerelease -eq $prerelease) -and ($release.tag_name -like "*$searchTerm*")) {
$version = $release.tag_name
break
}
Expand All @@ -87,27 +88,46 @@ function Get-Version {
return $version
}

if (-not $version) {
$version = Get-Version -repo $repo -searchTerm "cadence-v1.0.0" -webRequestOptions $webRequestOptions
}
function Install-FlowCLI {
param (
[string]$version,
[string]$destinationFileName
)

Write-Output("Installing version {0} ..." -f $version)

New-Item -ItemType Directory -Force -Path $directory | Out-Null

$progressPreference = 'silentlyContinue'

Invoke-WebRequest -Uri "$assetsURL/$version/flow-cli-$version-windows-amd64.zip" -UseBasicParsing -OutFile "$directory\flow.zip" @webRequestOptions

Write-Output("Installing version {0} ..." -f $version)
Expand-Archive -Path "$directory\flow.zip" -DestinationPath "$directory" -Force

New-Item -ItemType Directory -Force -Path $directory | Out-Null
try {
Stop-Process -Name flow -Force
Start-Sleep -Seconds 1
}
catch {}

Move-Item -Path "$directory\flow-cli.exe" -Destination "$directory\$destinationFileName" -Force
}

if (-not $version) {
Write-Output "Getting version of latest stable release ..."

$progressPreference = 'silentlyContinue'
$version = Get-Version -searchTerm '' -prerelease $false
}

Invoke-WebRequest -Uri "$assetsURL/$version/flow-cli-$version-windows-amd64.zip" -UseBasicParsing -OutFile "$directory\flow.zip" @webRequestOptions
Install-FlowCLI -version $version -destinationFileName "flow.exe"

Expand-Archive -Path "$directory\flow.zip" -DestinationPath "$directory" -Force
if (-not $c1version) {
Write-Output "Getting version of latest Cadence 1.0 preview release ..."

try {
Stop-Process -Name flow -Force
Start-Sleep -Seconds 1
$c1version = Get-Version -searchTerm "cadence-v1.0.0" -prerelease $true
}
catch {}

Move-Item -Path "$directory\flow-cli.exe" -Destination "$directory\flow-c1.exe" -Force
Install-FlowCLI -version $c1Version -destinationFileName "flow-c1.exe"

# Check if the directory is already in the PATH
$existingPaths = [Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User).Split(';')
Expand All @@ -121,7 +141,11 @@ if ($addToPath -and $existingPaths -notcontains $directory) {
}

Write-Output ""
Write-Output "Successfully installed Flow CLI $version"
Write-Output "PRE-RELEASE: Use the 'flow-c1' command to interact with this Cadence 1.0 CLI pre-release."
Write-Output "Successfully installed Flow CLI $version as 'flow'."
Write-Output "Use the 'flow' command to interact with the Flow CLI compatible with versions of Cadence before 1.0 (only)."
Write-Output ""
Write-Output "Successfully installed Flow CLI $c1Version as 'flow-c1'."
Write-Output "Use the 'flow-c1' command to interact with the Flow CLI preview compatible with Cadence 1.0 (only)."
Write-Output ""

Start-Sleep -Seconds 1
Start-Sleep -Seconds 1
Loading

0 comments on commit 932334f

Please sign in to comment.