Skip to content

Commit

Permalink
Merge pull request #1552 from onflow/cf/merge-master-5-1
Browse files Browse the repository at this point in the history
Merge master into feature branch
  • Loading branch information
chasefleming authored May 1, 2024
2 parents b7f4cd6 + 5692e5f commit 4d70ea1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
go-version: "1.20"
- name: generate
run: make generate
- uses: golangci/golangci-lint-action@v3.7.0
- uses: golangci/golangci-lint-action@v5.1.0
with:
version: v1.52.2
only-new-issues: true
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ You can also release manually although this is not recommended:

To make the new version the default version that is installed

- Change `version.txt` and commit it
- **DEPRECATED** Change `version.txt` and commit it. (This file is no longer user for versions of the Flow CLI later than v1.18.0, although it should still be maintained to support older versions of the CLI for a while)

## Adding a scaffold
You can add your own scaffold by creating a GitHub repository containing the scaffold content and then making a PR
Expand Down
21 changes: 18 additions & 3 deletions internal/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package command
import (
"crypto/sha256"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -262,7 +263,7 @@ func createLogger(logFlag string, formatFlag string) output.Logger {

// checkVersion fetches latest version and compares it to local.
func checkVersion(logger output.Logger) {
resp, err := http.Get("https://raw.githubusercontent.com/onflow/flow-cli/master/version.txt")
resp, err := http.Get("https://formulae.brew.sh/api/formula/flow-cli.json")
if err != nil || resp.StatusCode >= 400 {
return
}
Expand All @@ -275,7 +276,21 @@ func checkVersion(logger output.Logger) {
}(resp.Body)

body, _ := io.ReadAll(resp.Body)
latestVersion := strings.TrimSpace(string(body))
var data map[string]interface{}
err = json.Unmarshal(body, &data)
if err != nil {
return
}

versions, ok := data["versions"].(map[string]interface{})
if !ok {
return
}

latestVersion, ok := versions["stable"].(string)
if !ok {
return
}

currentVersion := build.Semver()
if isDevelopment() {
Expand All @@ -284,7 +299,7 @@ func checkVersion(logger output.Logger) {

if currentVersion != latestVersion {
logger.Info(fmt.Sprintf(
"\n%s Version warning: a new version of Flow CLI is available (%s).\n"+
"\n%s Version warning: a new version of Flow CLI is available (v%s).\n"+
" Read the installation guide for upgrade instructions: https://docs.onflow.org/flow-cli/install\n",
output.WarningEmoji(),
strings.ReplaceAll(latestVersion, "\n", ""),
Expand Down
4 changes: 3 additions & 1 deletion internal/dependencymanager/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package dependencymanager

import (
"fmt"

"github.com/onflow/flow-cli/internal/util"

"github.com/spf13/cobra"
Expand All @@ -46,7 +47,8 @@ var addCommand = &command.Command{
Example: "flow dependencies add testnet://0afe396ebc8eee65.FlowToken",
Args: cobra.ExactArgs(1),
},
RunS: add,
RunS: add,
Flags: &struct{}{},
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.17.1
v1.18.0

0 comments on commit 4d70ea1

Please sign in to comment.