Skip to content

Commit

Permalink
Merge pull request #170 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 3.3.0
  • Loading branch information
andyone authored Jan 12, 2024
2 parents 3b616ef + f60b971 commit 029e2d1
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
fetch-depth: 2

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: go

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
53 changes: 30 additions & 23 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
"github.com/essentialkaos/ek/v12/system"
"github.com/essentialkaos/ek/v12/terminal"
"github.com/essentialkaos/ek/v12/terminal/tty"
"github.com/essentialkaos/ek/v12/terminal/window"
"github.com/essentialkaos/ek/v12/timeutil"
"github.com/essentialkaos/ek/v12/tmp"
"github.com/essentialkaos/ek/v12/usage"
Expand All @@ -67,7 +66,7 @@ import (
// App info
const (
APP = "RBInstall"
VER = "3.2.0"
VER = "3.3.0"
DESC = "Utility for installing prebuilt Ruby versions to rbenv"
)

Expand Down Expand Up @@ -106,6 +105,7 @@ const (
RBENV_ALLOW_UNINSTALL = "rbenv:allow-uninstall"
RBENV_MAKE_ALIAS = "rbenv:make-alias"
GEMS_RUBYGEMS_UPDATE = "gems:rubygems-update"
GEMS_RUBYGEMS_VERSION = "gems:rubygems-version"
GEMS_ALLOW_UPDATE = "gems:allow-update"
GEMS_NO_DOCUMENT = "gems:no-document"
GEMS_SOURCE = "gems:source"
Expand Down Expand Up @@ -136,11 +136,6 @@ const (
ARCH_ARM = "arm"
)

// RubyGems versions used for old versions of Ruby
const (
MIN_RUBYGEMS_VERSION_BASE = "2.7.9"
)

// ////////////////////////////////////////////////////////////////////////////////// //

var optMap = options.Map{
Expand Down Expand Up @@ -751,8 +746,13 @@ func installVersion(rubyVersion string, reinstall bool) {

if knf.GetB(GEMS_RUBYGEMS_UPDATE) && strutil.HasPrefixAny(info.Name, "1", "2", "3") {
rgVersion := getAdvisableRubyGemsVersion(info.Name)
gemVersion := rgVersion

spinner.Show("Updating RubyGems to %s", rgVersion)
if gemVersion != "latest" && strings.Count(gemVersion, ".") < 2 {
gemVersion += ".x"
}

spinner.Show("Updating RubyGems to %s", gemVersion)
err = updateRubygemsTaskHandler(info.Name, rgVersion)
spinner.Done(err == nil)

Expand Down Expand Up @@ -1144,7 +1144,7 @@ func runGemCmd(rubyVersion, cmd, gem, gemVersion string) (string, error) {

if gemVersion == "" {
gemVersion = "latest"
} else {
} else if strings.Count(gemVersion, ".") < 2 {
gemVersion += ".x"
}

Expand Down Expand Up @@ -1357,7 +1357,7 @@ func getInstallBullet(installed bool, color string) string {
}

// printSized render format with given size and print text with give arguments
func printSized(format string, size int, a ...interface{}) {
func printSized(format string, size int, a ...any) {
fmtc.Printf(fmtc.Sprintf(format, size), a...)
}

Expand All @@ -1368,7 +1368,7 @@ func printRubyVersion(category, name string) {

// configureCategorySizes configure column size for each category
func configureCategorySizes(data map[string]index.CategoryData) {
terminalWidth := window.GetWidth()
terminalWidth := tty.GetWidth()

if terminalWidth == -1 || terminalWidth > 150 {
categorySize[index.CATEGORY_RUBY] = DEFAULT_CATEGORY_SIZE
Expand Down Expand Up @@ -1477,12 +1477,7 @@ func isVersionInstalled(rubyVersion string) bool {

// getVersionFromFile try to read version file and return defined version
func getVersionFromFile() (string, error) {
versionFile := fsutil.ProperPath("FRS",
[]string{
".ruby-version",
".rbenv-version",
},
)
versionFile := fsutil.ProperPath("FRS", []string{".ruby-version", ".rbenv-version"})

if versionFile == "" {
return "", fmtc.Errorf("Can't find proper version file")
Expand All @@ -1506,14 +1501,26 @@ func getVersionFromFile() (string, error) {
// getAdvisableRubyGemsVersion returns recommended RubyGems version for
// given version of Ruby
func getAdvisableRubyGemsVersion(rubyVersion string) string {
v, err := version.Parse(strutil.ReadField(rubyVersion, 0, false, "-"))
minVer, _ := version.Parse("2.3.0")
ver, err := version.Parse(strutil.ReadField(rubyVersion, 0, false, "-"))

if err != nil {
return "2.3"
}

v23, _ := version.Parse("2.3.0")
v26, _ := version.Parse("2.6.0")
v30, _ := version.Parse("3.0.0")

if err != nil || v.Less(minVer) {
return MIN_RUBYGEMS_VERSION_BASE
switch {
case ver.Less(v23):
return "2.3"
case ver.Less(v26):
return "3.3"
case ver.Less(v30):
return "3.4"
}

return "latest"
return knf.GetS(GEMS_RUBYGEMS_VERSION, "latest")
}

// getVersionInfo finds info about given version in index
Expand Down Expand Up @@ -1773,7 +1780,7 @@ func intSignalHandler() {
}

// printErrorAndExit print error message and exit with non-zero exit code
func printErrorAndExit(f string, a ...interface{}) {
func printErrorAndExit(f string, a ...any) {
terminal.Error(f, a...)
exit(1)
}
Expand Down
11 changes: 3 additions & 8 deletions clone/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import (
// App info
const (
APP = "RBInstall Clone"
VER = "3.1.0"
VER = "3.1.1"
DESC = "Utility for cloning RBInstall repository"
)

Expand Down Expand Up @@ -462,17 +462,12 @@ func getCurrentIndexUUID(dir string) string {
}

// printError prints error message to console
func printError(f string, a ...interface{}) {
func printError(f string, a ...any) {
fmtc.Fprintf(os.Stderr, "{r}▲ "+f+"{!}\n", a...)
}

// printError prints warning message to console
func printWarn(f string, a ...interface{}) {
fmtc.Fprintf(os.Stderr, "{y}▲ "+f+"{!}\n", a...)
}

// printErrorAndExit print error message and exit with non-zero exit code
func printErrorAndExit(f string, a ...interface{}) {
func printErrorAndExit(f string, a ...any) {
fmtc.Fprintf(os.Stderr, "{r}▲ "+f+"{!}\n", a...)
fmtc.NewLine()
os.Exit(1)
Expand Down
1 change: 1 addition & 0 deletions common/eol.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"2.4": true,
"2.5": true,
"2.6": true,
"2.7": true,
"jruby-1.6": true,
"jruby-1.7": true,
"jruby-9.0": true,
Expand Down
3 changes: 3 additions & 0 deletions common/rbinstall.knf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
# Update rubygems gem
rubygems-update: true

# Update rubygems gem to defined version
rubygems-version: latest

# Allow gems update
allow-update: true

Expand Down
11 changes: 8 additions & 3 deletions common/rbinstall.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Summary: Utility for installing prebuilt Ruby to rbenv
Name: rbinstall
Version: 3.2.0
Version: 3.3.0
Release: 0%{?dist}
Group: Applications/System
License: Apache License, Version 2.0
Expand Down Expand Up @@ -38,7 +38,7 @@ Utility for installing different prebuilt versions of Ruby to rbenv.
%package gen

Summary: Utility for generating RBInstall index
Version: 3.2.0
Version: 3.2.1
Release: 0%{?dist}
Group: Development/Tools

Expand All @@ -50,7 +50,7 @@ Utility for generating RBInstall index.
%package clone

Summary: Utility for cloning RBInstall repository
Version: 3.1.0
Version: 3.1.1
Release: 0%{?dist}
Group: Development/Tools

Expand Down Expand Up @@ -118,6 +118,11 @@ rm -rf %{buildroot}
################################################################################

%changelog
* Fri Jan 12 2024 Anton Novojilov <[email protected]> - 3.3.0-0
- [cli] Improved rubygems gem update
- [cli|gen|clone] Code refactoring
- Dependencies update

* Wed Dec 06 2023 Anton Novojilov <[email protected]> - 3.2.0-0
- [cli] Added '-P'/'--pager' option to use pager for long output of versions
- [cli|gen|clone] Improve verbose version info
Expand Down
12 changes: 6 additions & 6 deletions gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
// App info
const (
APP = "RBInstall Gen"
VER = "3.2.0"
VER = "3.2.1"
DESC = "Utility for generating RBInstall index"
)

Expand Down Expand Up @@ -94,8 +94,8 @@ var optMap = options.Map{
OPT_EOL: {Value: "eol.json"},
OPT_ALIAS: {Value: "alias.json"},
OPT_NO_COLOR: {Type: options.BOOL},
OPT_HELP: {Type: options.BOOL, Alias: "u:usage"},
OPT_VER: {Type: options.BOOL, Alias: "ver"},
OPT_HELP: {Type: options.BOOL},
OPT_VER: {Type: options.BOOL},

OPT_VERB_VER: {Type: options.BOOL},
OPT_COMPLETION: {},
Expand Down Expand Up @@ -518,17 +518,17 @@ func fmtVersionName(v string) string {
}

// printError prints error message to console
func printError(f string, a ...interface{}) {
func printError(f string, a ...any) {
fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...)
}

// printError prints warning message to console
func printWarn(f string, a ...interface{}) {
func printWarn(f string, a ...any) {
fmtc.Fprintf(os.Stderr, "{y}"+f+"{!}\n", a...)
}

// printErrorAndExit print error message and exit with non-zero exit code
func printErrorAndExit(f string, a ...interface{}) {
func printErrorAndExit(f string, a ...any) {
fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...)
os.Exit(1)
}
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ go 1.18

require (
github.com/essentialkaos/depsy v1.1.0
github.com/essentialkaos/ek/v12 v12.90.1
github.com/essentialkaos/npck v1.6.1
github.com/essentialkaos/ek/v12 v12.93.0
github.com/essentialkaos/npck v1.6.2
)

require (
github.com/essentialkaos/go-linenoise/v3 v3.4.0 // indirect
github.com/klauspost/compress v1.17.1 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/sys v0.15.0 // indirect
github.com/klauspost/compress v1.17.4 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/sys v0.16.0 // indirect
)
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk=
github.com/essentialkaos/depsy v1.1.0 h1:U6dp687UkQwXlZU17Hg2KMxbp3nfZAoZ8duaeUFYvJI=
github.com/essentialkaos/depsy v1.1.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8=
github.com/essentialkaos/ek/v12 v12.90.1 h1:ID950cnz4xgpqqFzhleP5xaVoLnPwuiykdH3FrogD/E=
github.com/essentialkaos/ek/v12 v12.90.1/go.mod h1:9efMqo1S8EtYhmeelOSTmMQDGC2vRgPkjkKKfvUD2eU=
github.com/essentialkaos/ek/v12 v12.93.0 h1:5lwuNYgUYjQHy2h57adWt2t1w5L2MxqTPKgHjyH3h6k=
github.com/essentialkaos/ek/v12 v12.93.0/go.mod h1:peB5w8zUkRuDs7m/QG5Z2gMmqzSIs2viAmxzzNFIIoo=
github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts=
github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI=
github.com/essentialkaos/npck v1.6.1 h1:cFhLRRFNbl7tBXQD2+EkzTHy6y7+oxfvwsVgbhaFvUg=
github.com/essentialkaos/npck v1.6.1/go.mod h1:Leny9a2R4otIGqZdnrs8swhI9KvwO+Rmmn2zThpPoN4=
github.com/klauspost/compress v1.17.1 h1:NE3C767s2ak2bweCZo3+rdP4U/HoyVXLv/X9f2gPS5g=
github.com/klauspost/compress v1.17.1/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/essentialkaos/npck v1.6.2 h1:OqV74UfA9qoRYbFVsZ+KYH9kY//1nU6uX/HBfAltUQ4=
github.com/essentialkaos/npck v1.6.2/go.mod h1:7ziKy4mdUrSMTihDTZKAaxf6uDH2uAlOzsD3Mj2WTyI=
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
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/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
1 change: 1 addition & 0 deletions support/support_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func collectEnvInfo() Pkgs {
getPackageInfo("rbenv"),
getPackageInfo("jemalloc"),
getPackageInfo("zlib"),
getPackageInfo("gcc"),
getPackageInfo(
"jre8", "jre11", "jre17", "jdk8", "jdk11", "jdk17",
"java-1.8.0-openjdk", "java-11-openjdk", "java-17-openjdk",
Expand Down

0 comments on commit 029e2d1

Please sign in to comment.