Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
version: "2"
issues:
max-issues-per-linter: 0
max-same-issues: 0
linters:
default: all
settings:
funlen:
lines: 65
disable:
- canonicalheader
- depguard
- gomoddirectives
- musttag
- nlreturn
- tagliatelle
- varnamelen
- wsl
- noinlineerr
- funcorder
exclusions:
generated: lax
presets:
Expand All @@ -26,13 +36,16 @@ linters:
- linters:
- gochecknoglobals
text: Version is a global variable
- linters:
- ireturn
- lll
path: schema\.resolvers\.go
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
Expand All @@ -42,3 +55,4 @@ formatters:
- third_party$
- builtin$
- examples$
- schema\.resolvers\.go
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
NOTE: This repository is deprecated. All development has moved to https://github.com/nhost/nhost

<div align="center">
<h1 style="font-size: 3em; font-weight: bold;">Nhost CLI</h1>
</div>
Expand Down Expand Up @@ -88,4 +90,4 @@ This will build the binary available as the `nhost` command in the terminal.

- MacOS
- Linux
- Windows WSL2
- Windows WSL2
10 changes: 9 additions & 1 deletion cmd/software/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"runtime"
"strings"

"github.com/nhost/cli/clienv"
"github.com/nhost/cli/software"
Expand Down Expand Up @@ -42,7 +43,14 @@ func commandUpgrade(cCtx *cli.Context) error {

ce.Infoln("Upgrading to %s...", latest.TagName)

want := fmt.Sprintf("cli-%s-%s-%s.tar.gz", latest.TagName, runtime.GOOS, runtime.GOARCH)
version := latest.TagName
s := strings.Split(latest.TagName, "@")

if len(s) == 2 { //nolint:mnd
version = s[1]
}

want := fmt.Sprintf("cli-%s-%s-%s.tar.gz", version, runtime.GOOS, runtime.GOARCH)

var url string

Expand Down
2 changes: 1 addition & 1 deletion dockercompose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ func mountCACertificates(
}
}

func ComposeFileFromConfig( //nolint:funlen
func ComposeFileFromConfig(
cfg *model.ConfigConfig,
subdomain string,
projectName string,
Expand Down
20 changes: 11 additions & 9 deletions get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ NC='\033[0m'
# basic variables
INSTALL_PATH=${INSTALL_PATH:-"/usr/local/bin"}
NEED_SUDO=${NEED_SUDO:-1}
REPO="nhost/cli"
REPO="nhost/nhost"

# check for existing installation
hasCli=$(which nhost)
Expand All @@ -38,12 +38,13 @@ if [ "$?" = "1" ]; then
fi

# get release version
release=${1:-latest}
log "Getting $release version..."
if [[ "$release" == "latest" ]]; then
version=$(curl --silent "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
version=${1:-latest}
log "Getting $version version..."
if [[ "$version" == "latest" ]]; then
release=$(curl --silent https://api.github.com/repos/nhost/nhost/releases\?per_page=100 | grep tag_name | grep \"cli\@ | head -n 1 | sed 's/.*"tag_name": "\([^"]*\)".*/\1/')
version=$( echo $release | sed 's/.*@//')
else
version=$(curl --silent "https://api.github.com/repos/nhost/cli/tags" | grep "name" | sed -E 's/.*"([^"]+)".*/\1/' | grep "^$release$")
release="cli@$release"
fi

# check version exists
Expand Down Expand Up @@ -96,14 +97,15 @@ suffix="-${platform}-${arch}"

if [[ "$platform" != 'windows' ]]; then
extension=".tar.gz"
else
else
extension='.zip'
fi

# variables for install
targetFile="cli-$version$suffix$extension"

url="https://github.com/${REPO}/releases/download/${version}/${targetFile}"
encodedRelease=$(echo $release | sed 's/@/%40/g')
url="https://github.com/${REPO}/releases/download/${encodedRelease}/${targetFile}"

# remove previous download
if [ -e $targetFile ]; then
Expand All @@ -119,7 +121,7 @@ try chmod +x $targetFile

if [[ "$platform" != 'windows' ]]; then
try tar -xvf $targetFile
else
else
try unzip $targetFile
fi

Expand Down
45 changes: 35 additions & 10 deletions software/sofware.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io"
"net/http"
"strings"

"golang.org/x/mod/semver"
)
Expand All @@ -25,13 +26,45 @@ func NewManager() *Manager {
}
}

func (mgr *Manager) filterReleases(releases Releases, version string) Releases {
if !strings.HasPrefix(version, "v") {
version = "v" + version
}

// filter pre-releases and older releases
r := make(Releases, 0, len(releases))
for _, release := range releases {
s := strings.Split(release.TagName, "@")
if len(s) != 2 { //nolint:mnd
continue
}

releaseName := s[0]
releaseVersion := s[1]

if !strings.HasPrefix(releaseVersion, "v") {
releaseVersion = "v" + releaseVersion
}

if releaseName != "cli" ||
release.Prerelease ||
semver.Compare(version, releaseVersion) >= 0 {
continue
}

r = append(r, release)
}

return r
}

func (mgr *Manager) GetReleases(ctx context.Context, version string) (Releases, error) {
var releases Releases

req, err := http.NewRequestWithContext(
ctx,
http.MethodGet,
"https://api.github.com/repos/nhost/cli/releases?per_page=100",
"https://api.github.com/repos/nhost/nhost/releases?per_page=100",
nil,
)
if err != nil {
Expand Down Expand Up @@ -62,15 +95,7 @@ func (mgr *Manager) GetReleases(ctx context.Context, version string) (Releases,
}

// filter pre-releases and older releases
r := make(Releases, 0, len(releases))
for _, release := range releases {
switch {
case release.Prerelease:
case semver.Compare(version, release.TagName) >= 0:
default:
r = append(r, release)
}
}
r := mgr.filterReleases(releases, version)

mgr.cache = r

Expand Down
Loading